WIP - ini edit, error check and syntax highlighting.

This commit is contained in:
Jim Miller
2014-12-29 17:12:09 -06:00
parent f1e9081c8c
commit bb098c1865
5 changed files with 272 additions and 225 deletions
+15 -9
View File
@@ -649,19 +649,25 @@ class PersonalIniTab(QWidget):
tooltip=_("Edit personal.ini"),
use_find=True,
save_size_name='ffdl:personal.ini')
error=False
while not error:
error=True
retry=True
while retry:
d.exec_()
if d.result() == d.Accepted:
self.personalini = unicode(d.get_plain_text())
errors = test_config(self.personalini)
editini = d.get_plain_text()
errors = test_config(editini)
if errors:
error = not errors_dialog(self.plugin_action.gui,
_('Go back to fix errors?'),
'<p>'+'</p><p>'.join([ '%s %s'%e for e in errors ])+'</p>')
retry = errors_dialog(self.plugin_action.gui,
_('Go back to fix errors?'),
'<p>'+'</p><p>'.join([ '%s %s'%e for e in errors ])+'</p>')
else:
retry = False
if not retry:
self.personalini = unicode(editini)
else:
# cancelled
retry = False
class ReadingListTab(QWidget):
+7 -7
View File
@@ -1260,8 +1260,6 @@ class IniTextDialog(SizePersistedDialog):
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
# button_box.button(QDialogButtonBox.Ok).setDefault(False)
# button_box.button(QDialogButtonBox.Cancel).setDefault(False)
self.l.addWidget(button_box)
# Cause our dialog size to be restored from prefs or created on first usage
@@ -1337,12 +1335,12 @@ def errors_dialog(parent,
d = ViewLog(title,html,parent)
return d.exec_() == d.Accepted
class ViewLog(QDialog):
class ViewLog(SizePersistedDialog):
def __init__(self, title, html, parent=None):
QDialog.__init__(self, parent)
def __init__(self, title, html, parent=None,
save_size_name='ffdl:view log dialog',):
SizePersistedDialog.__init__(self, parent,save_size_name)
self.l = l = QVBoxLayout()
self.setLayout(l)
@@ -1361,10 +1359,12 @@ class ViewLog(QDialog):
# self.copy_button.clicked.connect(self.copy_to_clipboard)
l.addWidget(self.bb)
self.setModal(False)
self.resize(700, 500)
self.setWindowTitle(title)
self.setWindowIcon(QIcon(I('debug.png')))
#self.show()
# Cause our dialog size to be restored from prefs or created on first usage
self.resize_dialog()
def copy_to_clipboard(self):
txt = self.tb.toPlainText()
+9 -8
View File
@@ -30,6 +30,14 @@ class IniHighlighter(QSyntaxHighlighter):
self.highlightingRules = []
if entries:
# *known* entries
reentries = r'('+(r'|'.join(entries))+r')'
self.highlightingRules.append( HighlightingRule( r"\b"+reentries+r"\b", Qt.darkGreen ) )
# true/false -- just to be nice.
self.highlightingRules.append( HighlightingRule( r"\b(true|false)\b", Qt.darkGreen ) )
# *all* keywords -- change known later.
self.errorRule = HighlightingRule( r"^[^:=\s][^:=]*[:=]", Qt.red )
self.highlightingRules.append( self.errorRule )
@@ -38,14 +46,7 @@ class IniHighlighter(QSyntaxHighlighter):
reentrykeywords = r'('+(r'|'.join([ e % r'[a-zA-Z0-9_]+' for e in entry_keywords ]))+r')'
self.highlightingRules.append( HighlightingRule( r"^(add_to_)?"+reentrykeywords+r"\s*[:=]", Qt.darkMagenta ) )
# true/false -- just to be nice.
self.highlightingRules.append( HighlightingRule( r"\b(true|false)\b", Qt.darkGreen ) )
if entries:
# *known* entries
reentries = r'('+(r'|'.join(entries))+r')'
self.highlightingRules.append( HighlightingRule( r"\b"+reentries+r"\b", Qt.darkGreen ) )
if entries: # separate from known entries so entry named keyword won't be masked.
# *known* entry keywords
reentrykeywords = r'('+(r'|'.join([ e % reentries for e in entry_keywords ]))+r')'
self.highlightingRules.append( HighlightingRule( r"^(add_to_)?"+reentrykeywords+r"\s*[:=]", Qt.blue ) )