Add GUI context menu

This commit is contained in:
Bastian Kleineidam 2009-03-07 14:40:13 +01:00
parent 388c7e4fd4
commit 4672f48d2b
2 changed files with 41 additions and 3 deletions

View file

@ -23,6 +23,7 @@ from .logger import GuiLogger, GuiLogHandler
from .help import HelpWindow
from .options import LinkCheckerOptions
from .checker import CheckerThread
from .contextmenu import ContextMenu
from .. import configuration, checker, director, add_intern_pattern, \
strformat
from ..containers import enum
@ -47,6 +48,7 @@ class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow):
self.options = LinkCheckerOptions(parent=self)
self.progress = LinkCheckerProgress(parent=self)
self.checker = CheckerThread()
self.contextmenu = ContextMenu(parent=self)
# Note: we can't use QT assistant here because of the .exe packaging
self.assistant = HelpWindow(self, "doc/lccollection.qhc")
# setup this widget
@ -231,9 +233,21 @@ Version 2 or later.</p>
self.num += 1
def on_treeWidget_itemDoubleClicked (self, item, column):
if column == 2:
# URL column double clicked
webbrowser.open(str(item.text(column)))
"""View property page."""
pass # XXX todo
def on_treeWidget_customContextMenuRequested (self, point):
"""Show item context menu."""
item = self.treeWidget.itemAt(point)
if item is not None:
self.contextmenu.popup(QtGui.QCursor.pos())
@QtCore.pyqtSignature("")
def on_actionViewOnline_triggered (self):
"""View item URL online."""
item = self.treeWidget.currentItem()
if item is not None:
webbrowser.open(str(item.text(2)))
def set_statusbar (self, msg):
"""Show status message in status bar."""

View file

@ -0,0 +1,24 @@
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2009 Bastian Kleineidam
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
from PyQt4 import QtGui
class ContextMenu (QtGui.QMenu):
"""Show context menu."""
def __init__ (self, parent=None):
super(ContextMenu, self).__init__(parent)
self.addAction(parent.actionViewOnline)