mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-20 14:20:59 +00:00
Add GUI context menu
This commit is contained in:
parent
388c7e4fd4
commit
4672f48d2b
2 changed files with 41 additions and 3 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
24
linkcheck/gui/contextmenu.py
Normal file
24
linkcheck/gui/contextmenu.py
Normal 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)
|
||||
Loading…
Reference in a new issue