From 5f0853be87b8f7548ff519d3e8e465455658528c Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Tue, 13 Dec 2011 21:25:09 +0100 Subject: [PATCH] Display GUI options in one dialog; support warning strings in GUI options; support ignore patterns in GUI options. --- Makefile | 2 +- doc/changelog.txt | 9 + linkcheck/gui/__init__.py | 38 +- linkcheck/gui/linkchecker_ui_options.py | 203 ++++----- linkcheck/gui/options.py | 28 +- linkcheck/gui/settings.py | 19 +- linkcheck/gui/ui/options.ui | 569 +++++++++++------------- 7 files changed, 404 insertions(+), 464 deletions(-) diff --git a/Makefile b/Makefile index 4de55324..4739e48e 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,7 @@ test: localbuild .PHONY: pyflakes pyflakes: - pyflakes --force $(PY_FILES_DIRS) 2>&1 | \ + pyflakes $(PY_FILES_DIRS) 2>&1 | \ grep -v "redefinition of unused 'linkcheck'" | \ grep -v "undefined name '_'" | \ grep -v "undefined name '_n'" | cat diff --git a/doc/changelog.txt b/doc/changelog.txt index 38f72f65..cf8bce53 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -8,6 +8,15 @@ Fixes: - checking: Do not remove whitespace inside URLs given on the commandline or GUI. Only remove whitespace at the start and end. +Changes: +- gui: Display all options in one dialog instead of tabbed panes. + +Features: +- gui: Add configuration for warning strings instead of regular + expressions. The regular expressions can still be configured in + the configuration file. +- gui: Add configuration for ignore URL patterns. + 7.2 "Driver" (released 20.10.2011) diff --git a/linkcheck/gui/__init__.py b/linkcheck/gui/__init__.py index de34f5e0..cfce0f38 100644 --- a/linkcheck/gui/__init__.py +++ b/linkcheck/gui/__init__.py @@ -18,6 +18,7 @@ import os import sys import re +import copy import webbrowser from PyQt4 import QtCore, QtGui from .linkchecker_ui_main import Ui_MainWindow @@ -36,7 +37,7 @@ from .urlsave import urlsave from .settings import Settings from .recentdocs import RecentDocumentModel from .. import configuration, checker, director, add_intern_pattern, \ - strformat, fileutil, LinkCheckerError + strformat, fileutil, LinkCheckerError, get_link_pat from ..containers import enum from .. import url as urlutil from ..checker import httpheaders @@ -72,6 +73,10 @@ def get_icon (name): return icon +def warninglines2regex(lines): + return u"|".join([re.escape(line) for line in lines]) + + class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow): """The main window displaying checked URLs.""" @@ -195,6 +200,8 @@ class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow): def init_config (self): """Create a configuration object.""" self.config = configuration.Configuration() + # dictionary holding overwritten values + self.config_backup = {} # set standard GUI configuration values self.config.logger_add("gui", GuiLogger) self.config["logger"] = self.config.logger_new('gui', @@ -223,8 +230,31 @@ class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow): self.config["threads"] = 1 else: self.config.reset_loglevel() - if data["warningregex"]: - self.config["warningregex"] = re.compile(data["warningregex"]) + if data["warninglines"]: + lines = data["warninglines"].splitlines() + ro = re.compile(warninglines2regex(lines)) + self.backup_config("warningregex", ro) + # set ignore patterns + ignorepats = data["ignorelines"].strip() + if ignorepats: + self.backup_config("externlinks") + lines = ignorepats.splitlines() + for line in lines: + pat = get_link_pat(line, strict=1) + self.config["externlinks"].append(pat) + + def backup_config (self, key, value=None): + """Backup config key if not already done and set given value.""" + if key not in self.config_backup: + # make copy of containers to avoid unwanted inserted items + self.config_backup[key] = copy.copy(self.config[key]) + if value is not None: + self.config[key] = value + + def restore_config (self): + """Restore config from backup.""" + for key in self.config_backup: + self.config[key] = copy.copy(self.config_backup[key]) def get_status (self): """Return current application status.""" @@ -251,6 +281,7 @@ class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow): self.label_busy.hide() self.menubar.setEnabled(True) self.urlinput.setEnabled(True) + self.restore_config() elif status == Status.checking: self.treeView.setSortingEnabled(False) self.debug.reset() @@ -392,6 +423,7 @@ Version 2 or later. self.set_statusmsg(_("Checking '%s'.") % strformat.limit(url, 40)) url_data = checker.get_url_from(url, 0, aggregate) try: + self.backup_config('internlinks') add_intern_pattern(url_data, self.config) except UnicodeError: self.set_statusmsg(_("Error, invalid URL `%s'.") % diff --git a/linkcheck/gui/linkchecker_ui_options.py b/linkcheck/gui/linkchecker_ui_options.py index de7e513e..f1351da4 100644 --- a/linkcheck/gui/linkchecker_ui_options.py +++ b/linkcheck/gui/linkchecker_ui_options.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'ui/options.ui' # -# Created: Mon Dec 12 19:00:36 2011 +# Created: Tue Dec 13 07:09:29 2011 # by: PyQt4 UI code generator 4.8.6 # # WARNING! All changes made in this file will be lost! @@ -17,61 +17,27 @@ except AttributeError: class Ui_Options(object): def setupUi(self, Options): Options.setObjectName(_fromUtf8("Options")) - Options.setWindowModality(QtCore.Qt.ApplicationModal) - Options.resize(279, 239) - Options.setWindowTitle(_("Linkchecker options")) - self.verticalLayout = QtGui.QVBoxLayout(Options) - self.verticalLayout.setSpacing(2) - self.verticalLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.tabWidget = QtGui.QTabWidget(Options) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) - self.tabWidget.setSizePolicy(sizePolicy) - self.tabWidget.setToolTip(_fromUtf8("")) - self.tabWidget.setObjectName(_fromUtf8("tabWidget")) - self.gui_options = QtGui.QWidget() - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.gui_options.sizePolicy().hasHeightForWidth()) - self.gui_options.setSizePolicy(sizePolicy) - self.gui_options.setToolTip(_fromUtf8("")) - self.gui_options.setObjectName(_fromUtf8("gui_options")) - self.verticalLayout_3 = QtGui.QVBoxLayout(self.gui_options) - self.verticalLayout_3.setSpacing(2) + Options.resize(400, 550) + Options.setMinimumSize(QtCore.QSize(400, 550)) + Options.setWindowTitle(_("Dialog")) + self.verticalLayout_3 = QtGui.QVBoxLayout(Options) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) - self.label_8 = QtGui.QLabel(self.gui_options) - self.label_8.setMinimumSize(QtCore.QSize(240, 0)) - self.label_8.setText(_("The most common check options are configurable. They override any configuration file settings.")) - self.label_8.setTextFormat(QtCore.Qt.AutoText) - self.label_8.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) - self.label_8.setWordWrap(True) - self.label_8.setObjectName(_fromUtf8("label_8")) - self.verticalLayout_3.addWidget(self.label_8) - self.frame = QtGui.QFrame(self.gui_options) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) - self.frame.setSizePolicy(sizePolicy) - self.frame.setFrameShape(QtGui.QFrame.StyledPanel) - self.frame.setFrameShadow(QtGui.QFrame.Raised) - self.frame.setObjectName(_fromUtf8("frame")) - self.formLayout = QtGui.QFormLayout(self.frame) - self.formLayout.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint) - self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) - self.formLayout.setHorizontalSpacing(4) - self.formLayout.setVerticalSpacing(8) + self.groupBox_2 = QtGui.QGroupBox(Options) + self.groupBox_2.setTitle(_("Scanning options")) + self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) + self.verticalLayout = QtGui.QVBoxLayout(self.groupBox_2) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.widget = QtGui.QWidget(self.groupBox_2) + self.widget.setObjectName(_fromUtf8("widget")) + self.formLayout = QtGui.QFormLayout(self.widget) + self.formLayout.setMargin(0) self.formLayout.setObjectName(_fromUtf8("formLayout")) - self.label = QtGui.QLabel(self.frame) + self.label = QtGui.QLabel(self.widget) self.label.setToolTip(_("Check recursively all links up to given depth. A negative depth will enable infinite recursion.")) self.label.setText(_("Recursive depth")) self.label.setObjectName(_fromUtf8("label")) self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label) - self.recursionlevel = QtGui.QSpinBox(self.frame) + self.recursionlevel = QtGui.QSpinBox(self.widget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -84,103 +50,98 @@ class Ui_Options(object): self.recursionlevel.setProperty("value", -1) self.recursionlevel.setObjectName(_fromUtf8("recursionlevel")) self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.recursionlevel) - self.label_2 = QtGui.QLabel(self.frame) + self.label_2 = QtGui.QLabel(self.widget) self.label_2.setToolTip(_("Log all checked URLs once. Default is to log only errors and warnings.")) self.label_2.setText(_("Verbose output")) self.label_2.setObjectName(_fromUtf8("label_2")) self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label_2) - self.verbose = QtGui.QCheckBox(self.frame) + self.verbose = QtGui.QCheckBox(self.widget) self.verbose.setEnabled(True) self.verbose.setToolTip(_("Log all checked URLs once. Default is to log only errors and warnings.")) self.verbose.setText(_fromUtf8("")) self.verbose.setObjectName(_fromUtf8("verbose")) self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.verbose) - self.label_4 = QtGui.QLabel(self.frame) + self.label_4 = QtGui.QLabel(self.widget) self.label_4.setText(_("Debug")) self.label_4.setObjectName(_fromUtf8("label_4")) self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label_4) - self.debug = QtGui.QCheckBox(self.frame) + self.debug = QtGui.QCheckBox(self.widget) self.debug.setText(_fromUtf8("")) self.debug.setObjectName(_fromUtf8("debug")) self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.debug) - self.warningregex = QtGui.QLineEdit(self.frame) - self.warningregex.setObjectName(_fromUtf8("warningregex")) - self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.warningregex) - self.label_3 = QtGui.QLabel(self.frame) - self.label_3.setText(_("Warning regex")) + self.verticalLayout.addWidget(self.widget) + spacerItem = QtGui.QSpacerItem(20, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + self.label_5 = QtGui.QLabel(self.groupBox_2) + self.label_5.setText(_("Warn when one of these strings are found (one per line):")) + self.label_5.setObjectName(_fromUtf8("label_5")) + self.verticalLayout.addWidget(self.label_5) + self.warninglines = QtGui.QPlainTextEdit(self.groupBox_2) + self.warninglines.setMaximumSize(QtCore.QSize(16777215, 150)) + self.warninglines.setObjectName(_fromUtf8("warninglines")) + self.verticalLayout.addWidget(self.warninglines) + self.label_6 = QtGui.QLabel(self.groupBox_2) + self.label_6.setText(_("Ignore URLs matching one of these patterns (one per line):")) + self.label_6.setObjectName(_fromUtf8("label_6")) + self.verticalLayout.addWidget(self.label_6) + self.ignorelines = QtGui.QPlainTextEdit(self.groupBox_2) + self.ignorelines.setMaximumSize(QtCore.QSize(16777215, 150)) + self.ignorelines.setObjectName(_fromUtf8("ignorelines")) + self.verticalLayout.addWidget(self.ignorelines) + self.verticalLayout_3.addWidget(self.groupBox_2) + self.groupBox = QtGui.QGroupBox(Options) + self.groupBox.setTitle(_("Configuration file")) + self.groupBox.setObjectName(_fromUtf8("groupBox")) + self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.label_3 = QtGui.QLabel(self.groupBox) + self.label_3.setText(_("The configuration file holds advanced options and can be edited with an integrated text editor.")) + self.label_3.setWordWrap(True) self.label_3.setObjectName(_fromUtf8("label_3")) - self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.label_3) - self.verticalLayout_3.addWidget(self.frame) - self.widget = QtGui.QWidget(self.gui_options) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth()) - self.widget.setSizePolicy(sizePolicy) - self.widget.setObjectName(_fromUtf8("widget")) - self.horizontalLayout = QtGui.QHBoxLayout(self.widget) - self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.horizontalLayout.setMargin(0) - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.closeButton = QtGui.QPushButton(self.widget) - self.closeButton.setText(_("Close")) - self.closeButton.setObjectName(_fromUtf8("closeButton")) - self.horizontalLayout.addWidget(self.closeButton) - self.verticalLayout_3.addWidget(self.widget) - self.tabWidget.addTab(self.gui_options, _fromUtf8("")) - self.config_options = QtGui.QWidget() - self.config_options.setToolTip(_fromUtf8("")) - self.config_options.setObjectName(_fromUtf8("config_options")) - self.verticalLayout_5 = QtGui.QVBoxLayout(self.config_options) - self.verticalLayout_5.setSpacing(0) - self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5")) - self.label_9 = QtGui.QLabel(self.config_options) - self.label_9.setText(_("The user configuration file holds advanced options and can be edited with an integrated text editor.")) - self.label_9.setTextFormat(QtCore.Qt.AutoText) - self.label_9.setWordWrap(True) - self.label_9.setObjectName(_fromUtf8("label_9")) - self.verticalLayout_5.addWidget(self.label_9) - self.frame_2 = QtGui.QFrame(self.config_options) - self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel) - self.frame_2.setFrameShadow(QtGui.QFrame.Raised) - self.frame_2.setMidLineWidth(0) - self.frame_2.setObjectName(_fromUtf8("frame_2")) - self.verticalLayout_4 = QtGui.QVBoxLayout(self.frame_2) - self.verticalLayout_4.setSpacing(4) - self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) - self.user_config_label = QtGui.QLabel(self.frame_2) + self.verticalLayout_2.addWidget(self.label_3) + spacerItem1 = QtGui.QSpacerItem(20, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem1) + self.user_config_label_2 = QtGui.QLabel(self.groupBox) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.user_config_label.sizePolicy().hasHeightForWidth()) - self.user_config_label.setSizePolicy(sizePolicy) - self.user_config_label.setToolTip(_("Overrides system wide configuration file settings.")) - self.user_config_label.setFrameShape(QtGui.QFrame.NoFrame) - self.user_config_label.setLineWidth(0) - self.user_config_label.setText(_("/home/user/.linkchecker/linkcheckerrc")) - self.user_config_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) - self.user_config_label.setWordWrap(True) - self.user_config_label.setMargin(0) - self.user_config_label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) - self.user_config_label.setObjectName(_fromUtf8("user_config_label")) - self.verticalLayout_4.addWidget(self.user_config_label) - self.user_config_button = QtGui.QPushButton(self.frame_2) + sizePolicy.setHeightForWidth(self.user_config_label_2.sizePolicy().hasHeightForWidth()) + self.user_config_label_2.setSizePolicy(sizePolicy) + self.user_config_label_2.setToolTip(_("Overrides system wide configuration file settings.")) + self.user_config_label_2.setFrameShape(QtGui.QFrame.NoFrame) + self.user_config_label_2.setLineWidth(0) + self.user_config_label_2.setText(_("/home/user/.linkchecker/linkcheckerrc")) + self.user_config_label_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.user_config_label_2.setWordWrap(True) + self.user_config_label_2.setMargin(0) + self.user_config_label_2.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) + self.user_config_label_2.setObjectName(_fromUtf8("user_config_label_2")) + self.verticalLayout_2.addWidget(self.user_config_label_2) + self.user_config_button = QtGui.QPushButton(self.groupBox) self.user_config_button.setEnabled(False) self.user_config_button.setToolTip(_fromUtf8("")) self.user_config_button.setText(_("Edit")) self.user_config_button.setObjectName(_fromUtf8("user_config_button")) - self.verticalLayout_4.addWidget(self.user_config_button) - self.verticalLayout_5.addWidget(self.frame_2) - spacerItem = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout_5.addItem(spacerItem) - self.tabWidget.addTab(self.config_options, _fromUtf8("")) - self.verticalLayout.addWidget(self.tabWidget) + self.verticalLayout_2.addWidget(self.user_config_button) + self.verticalLayout_3.addWidget(self.groupBox) + spacerItem2 = QtGui.QSpacerItem(20, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem2) + self.widget_2 = QtGui.QWidget(Options) + self.widget_2.setObjectName(_fromUtf8("widget_2")) + self.horizontalLayout = QtGui.QHBoxLayout(self.widget_2) + self.horizontalLayout.setMargin(0) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.closeButton = QtGui.QPushButton(self.widget_2) + self.closeButton.setText(_("Close")) + self.closeButton.setObjectName(_fromUtf8("closeButton")) + self.horizontalLayout.addWidget(self.closeButton) + spacerItem3 = QtGui.QSpacerItem(317, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem3) + self.verticalLayout_3.addWidget(self.widget_2) self.retranslateUi(Options) - self.tabWidget.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(Options) def retranslateUi(self, Options): - self.tabWidget.setTabText(self.tabWidget.indexOf(self.gui_options), _("GUI options")) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.config_options), _("Configuration file")) + pass diff --git a/linkcheck/gui/options.py b/linkcheck/gui/options.py index 6a4dcb54..47bae45d 100644 --- a/linkcheck/gui/options.py +++ b/linkcheck/gui/options.py @@ -19,7 +19,6 @@ import os from PyQt4 import QtGui from .linkchecker_ui_options import Ui_Options from .editor import EditorWindow -from .validator import PyRegexValidator, check_regex from .. import configuration @@ -30,26 +29,11 @@ class LinkCheckerOptions (QtGui.QDialog, Ui_Options): """Reset all options and initialize the editor window.""" super(LinkCheckerOptions, self).__init__(parent) self.setupUi(self) - self.validator = PyRegexValidator(self.warningregex) - self.warningregex.setValidator(self.validator) - self.warningregex.textChanged.connect(self.check_warningregex) self.editor = EditorWindow(self) self.closeButton.clicked.connect(self.close) self.user_config_button.clicked.connect(self.edit_user_config) self.reset() - def check_warningregex (self, text): - """Display red text for invalid regex contents.""" - if check_regex(unicode(text)): - style = "QLineEdit {}" - self.warningregex.setStyleSheet(style) - self.warningregex.setToolTip(u"") - else: - # red text - style = "QLineEdit {color:#aa0000;}" - self.warningregex.setStyleSheet(style) - self.warningregex.setToolTip(_("Invalid regular expression")) - def reset (self): """Reset GUI and config options.""" self.user_config = configuration.get_user_config() @@ -61,7 +45,8 @@ class LinkCheckerOptions (QtGui.QDialog, Ui_Options): self.recursionlevel.setValue(-1) self.verbose.setChecked(False) self.debug.setChecked(False) - self.warningregex.setText(u"") + self.warninglines.setPlainText(u"") + self.ignorelines.setPlainText(u"") def reset_config_options (self): """Reset configuration file edit buttons.""" @@ -80,7 +65,8 @@ class LinkCheckerOptions (QtGui.QDialog, Ui_Options): debug=self.debug.isChecked(), verbose=self.verbose.isChecked(), recursionlevel=self.recursionlevel.value(), - warningregex=unicode(self.warningregex.text()), + warninglines=unicode(self.warninglines.toPlainText()), + ignorelines=unicode(self.ignorelines.toPlainText()), ) def set_options (self, data): @@ -91,8 +77,10 @@ class LinkCheckerOptions (QtGui.QDialog, Ui_Options): self.verbose.setChecked(data["verbose"]) if data["recursionlevel"] is not None: self.recursionlevel.setValue(data["recursionlevel"]) - if data["warningregex"] is not None: - self.warningregex.setText(data["warningregex"]) + if data["warninglines"] is not None: + self.warninglines.setPlainText(data["warninglines"]) + if data["ignorelines"] is not None: + self.ignorelines.setPlainText(data["ignorelines"]) def start_editor (filename, writable, editor): diff --git a/linkcheck/gui/settings.py b/linkcheck/gui/settings.py index 40f9309e..6372f261 100644 --- a/linkcheck/gui/settings.py +++ b/linkcheck/gui/settings.py @@ -87,7 +87,7 @@ class Settings (object): def read_options (self): """Return stored GUI options.""" data = dict(debug=None, verbose=None, recursionlevel=None, - warningregex=None) + warninglines=None, ignorelines=None) self.settings.beginGroup('output') for key in ("debug", "verbose"): if self.settings.contains(key): @@ -105,11 +105,12 @@ class Settings (object): else: value = -1 data['recursionlevel'] = value - if self.settings.contains('warningregex'): - value = self.settings.value('warningregex').toString() - value = unicode(value) - if not value or check_regex(value): - data['warningregex'] = value + if self.settings.contains('warninglines'): + value = self.settings.value('warninglines').toString() + data['warninglines'] = unicode(value) + if self.settings.contains('ignorelines'): + value = self.settings.value('ignorelines').toString() + data['ignorelines'] = unicode(value) self.settings.endGroup() return data @@ -120,10 +121,8 @@ class Settings (object): self.settings.setValue(key, QtCore.QVariant(data[key])) self.settings.endGroup() self.settings.beginGroup('checking') - key = "recursionlevel" - self.settings.setValue(key, QtCore.QVariant(data[key])) - key = "warningregex" - self.settings.setValue(key, QtCore.QVariant(data[key])) + for key in ("recursionlevel", "warninglines", "ignorelines"): + self.settings.setValue(key, QtCore.QVariant(data[key])) self.settings.endGroup() def read_recent_documents (self): diff --git a/linkcheck/gui/ui/options.ui b/linkcheck/gui/ui/options.ui index 3a521838..09689336 100644 --- a/linkcheck/gui/ui/options.ui +++ b/linkcheck/gui/ui/options.ui @@ -2,326 +2,277 @@ Options - - Qt::ApplicationModal - 0 0 - 279 - 239 + 400 + 550 - - Linkchecker options + + + 400 + 550 + - - - 2 - - - QLayout::SetMinimumSize - + + Dialog + + - - - - 0 - 0 - + + + Scanning options - - + + + + + + + + Check recursively all links up to given depth. A negative depth will enable infinite recursion. + + + Recursive depth + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Check recursively all links up to given depth. A negative depth will enable infinite recursion. + + + -1 + + + 100 + + + -1 + + + + + + + Log all checked URLs once. Default is to log only errors and warnings. + + + Verbose output + + + + + + + true + + + Log all checked URLs once. Default is to log only errors and warnings. + + + + + + + + + + Debug + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 10 + + + + + + + + Warn when one of these strings are found (one per line): + + + + + + + + 16777215 + 150 + + + + + + + + Ignore URLs matching one of these patterns (one per line): + + + + + + + + 16777215 + 150 + + + + + + + + + + + Configuration file - - 0 + + + + + The configuration file holds advanced options and can be edited with an integrated text editor. + + + true + + + + + + + Qt::Vertical + + + + 20 + 10 + + + + + + + + + 0 + 0 + + + + Overrides system wide configuration file settings. + + + QFrame::NoFrame + + + 0 + + + /home/user/.linkchecker/linkcheckerrc + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 0 + + + Qt::TextSelectableByMouse + + + + + + + false + + + + + + Edit + + + + + + + + + + Qt::Vertical - - - - 0 - 0 - - - - - - - GUI options - - - - 2 - - - - - - 240 - 0 - - - - The most common check options are configurable. They override any configuration file settings. - - - Qt::AutoText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QLayout::SetDefaultConstraint - - - QFormLayout::ExpandingFieldsGrow - - - 4 - - - 8 - - - - - Check recursively all links up to given depth. A negative depth will enable infinite recursion. - - - Recursive depth - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Check recursively all links up to given depth. A negative depth will enable infinite recursion. - - - -1 - - - 100 - - - -1 - - - - - - - Log all checked URLs once. Default is to log only errors and warnings. - - - Verbose output - - - - - - - true - - - Log all checked URLs once. Default is to log only errors and warnings. - - - - - - - - - - Debug - - - - - - - - - - - - - - - - - Warning regex - - - - - - - - - - - 0 - 0 - - - - - QLayout::SetMinimumSize - - - - - Close - - - - - - - - - - - - - - Configuration file - - - - 0 - - - - - The user configuration file holds advanced options and can be edited with an integrated text editor. - - - Qt::AutoText - - - true - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - 0 - - - - 4 - - - - - - 0 - 0 - - - - Overrides system wide configuration file settings. - - - QFrame::NoFrame - - - 0 - - - /home/user/.linkchecker/linkcheckerrc - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - 0 - - - Qt::TextSelectableByMouse - - - - - - - false - - - - - - Edit - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 60 - - - - - - + + + 20 + 10 + + + + + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 317 + 20 + + + + +