Updated UI layout; improved UI handling.

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3836 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2008-06-30 23:18:48 +00:00
parent 573453d68b
commit c9e9f95da1
2 changed files with 205 additions and 181 deletions

View file

@ -24,22 +24,46 @@ from linkcheck import configuration, checker, director, add_intern_pattern, \
class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
"""Initialize UI."""
super(LinkCheckerMain, self).__init__(parent)
self.setupUi(self)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowContextHelpButtonHint)
self.setWindowTitle(configuration.App)
self.textEdit.setFontFamily("mono")
self.checker = Checker()
settings = QtCore.QSettings('bfk', configuration.AppName)
settings.beginGroup('mainwindow')
if settings.contains('size'):
self.resize(settings.value('size').toSize())
self.move(settings.value('pos').toPoint())
settings.endGroup()
self.connect(self.checker, QtCore.SIGNAL("finished()"), self.updateUi)
self.connect(self.checker, QtCore.SIGNAL("terminated()"), self.updateUi)
self.connect(self.checker, QtCore.SIGNAL("addMessage(QString)"), self.addMessage)
self.connect(self.checker, QtCore.SIGNAL("setStatus(QString)"), self.setStatus)
self.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.check_or_cancel)
self.connect(self.actionQuit, QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()"))
self.connect(self.actionQuit, QtCore.SIGNAL("triggered()"), self.close)
self.connect(self.actionAbout, QtCore.SIGNAL("triggered()"), self.about)
self.updateUi()
def closeEvent (self, e=None):
"""Save settings on close."""
settings = QtCore.QSettings('bfk', configuration.AppName)
settings.beginGroup('mainwindow')
settings.setValue("size", QtCore.QVariant(self.size()))
settings.setValue("pos", QtCore.QVariant(self.pos()))
settings.endGroup()
settings.sync()
if e is not None:
e.accept()
def about (self):
"""Display about dialog."""
d = {
"app": configuration.App,
"appname": configuration.AppName,
@ -55,12 +79,14 @@ Version 2 or later.</p>
</qt>""") % d)
def check_or_cancel (self):
"""Run a new check or cancel active check."""
if self.aggregate is None:
self.check()
else:
self.cancel()
def check (self):
"""Check given URL."""
self.pushButton.setEnabled(False)
self.textEdit.setText("")
config = self.get_config()
@ -91,10 +117,12 @@ Version 2 or later.</p>
self.checker.check(self.aggregate)
def cancel (self):
"""Cancel running check."""
self.setStatus(_("Aborting."))
director.abort(self.aggregate)
def get_config (self):
"""Return check configuration."""
config = configuration.Configuration()
config["recursionlevel"] = self.spinBox.value()
config.logger_add("gui", GuiLogger)
@ -105,14 +133,17 @@ Version 2 or later.</p>
return config
def addMessage (self, msg):
"""Add new log message to text edit widget."""
text = self.textEdit.toPlainText()
self.textEdit.setText(text+msg)
self.textEdit.moveCursor(QtGui.QTextCursor.End)
def setStatus (self, msg):
"""Show status message in status bar."""
self.statusBar.showMessage(msg)
def updateUi (self):
"""Reset UI."""
self.pushButton.setText(_("Check"))
self.aggregate = None
self.pushButton.setEnabled(True)
@ -120,6 +151,7 @@ Version 2 or later.</p>
class Checker (QtCore.QThread):
"""Separate checker thread."""
def __init__ (self, parent=None):
super(Checker, self).__init__(parent)
@ -143,6 +175,7 @@ class Checker (QtCore.QThread):
from linkcheck.logger.text import TextLogger
class GuiLogger (TextLogger):
"""Custom logger class to delegate log messages to the UI."""
def __init__ (self, **args):
super(GuiLogger, self).__init__(**args)
@ -159,6 +192,7 @@ class GuiLogger (TextLogger):
class StatusLogger (object):
"""Custom status logger to delegate status message to the UI."""
def __init__ (self, widget):
self.widget = widget

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>500</height>
<width>408</width>
<height>511</height>
</rect>
</property>
<property name="sizePolicy" >
@ -26,190 +26,180 @@
<rect>
<x>0</x>
<y>26</y>
<width>400</width>
<height>455</height>
<width>408</width>
<height>466</height>
</rect>
</property>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>20</x>
<y>20</y>
<width>351</width>
<height>411</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>URL</string>
</property>
<property name="buddy" >
<cstring>lineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<widget class="QLineEdit" name="lineEdit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Recursion</string>
</property>
<property name="buddy" >
<cstring>spinBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QSpinBox" name="spinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Show all</string>
</property>
<property name="buddy" >
<cstring>checkBox</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<item>
<widget class="QCheckBox" name="checkBox" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="horizontalSpacer_4" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Check</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit" >
<property name="undoRedoEnabled" >
<bool>false</bool>
</property>
<property name="lineWrapMode" >
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>URL</string>
</property>
<property name="buddy" >
<cstring>lineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<widget class="QLineEdit" name="lineEdit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Recursion</string>
</property>
<property name="buddy" >
<cstring>spinBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QSpinBox" name="spinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Show all</string>
</property>
<property name="buddy" >
<cstring>checkBox</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<item>
<widget class="QCheckBox" name="checkBox" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="horizontalSpacer_4" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Check</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit" >
<property name="undoRedoEnabled" >
<bool>false</bool>
</property>
<property name="lineWrapMode" >
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>408</width>
<height>26</height>
</rect>
</property>
@ -232,8 +222,8 @@
<property name="geometry" >
<rect>
<x>0</x>
<y>481</y>
<width>400</width>
<y>492</y>
<width>408</width>
<height>19</height>
</rect>
</property>