eric6/Preferences/ConfigurationDialog.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 7214
f434af227a41
parent 7263
c1af2e327675
child 7362
028bf21bb5a2
equal deleted inserted replaced
7226:babe80d84a3e 7286:7eb04391adf7
5 5
6 """ 6 """
7 Module implementing a dialog for the configuration of eric6. 7 Module implementing a dialog for the configuration of eric6.
8 """ 8 """
9 9
10 from __future__ import unicode_literals
11 10
12 import os 11 import os
13 import types 12 import types
14 13
15 from PyQt5.QtCore import pyqtSignal, pyqtSlot, PYQT_VERSION, Qt, QMetaObject, \ 14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect
16 QRect
17 from PyQt5.QtGui import QPixmap 15 from PyQt5.QtGui import QPixmap
18 from PyQt5.QtWidgets import QSizePolicy, QSpacerItem, QWidget, QTreeWidget, \ 16 from PyQt5.QtWidgets import (
19 QStackedWidget, QDialog, QSplitter, QScrollArea, QApplication, \ 17 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog,
20 QDialogButtonBox, QFrame, QVBoxLayout, QTreeWidgetItem, QLabel 18 QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame,
19 QVBoxLayout, QTreeWidgetItem, QLabel
20 )
21 21
22 from E5Gui.E5Application import e5App 22 from E5Gui.E5Application import e5App
23 from E5Gui.E5LineEdit import E5ClearableLineEdit 23 from E5Gui.E5LineEdit import E5ClearableLineEdit
24 from E5Gui import E5MessageBox 24 from E5Gui import E5MessageBox
25 from E5Gui.E5MainWindow import E5MainWindow 25 from E5Gui.E5MainWindow import E5MainWindow
26 26
27 from Globals import isMacPlatform, qVersionTuple, getWebBrowserSupport 27 from Globals import isMacPlatform, getWebBrowserSupport
28 28
29 import Preferences 29 import Preferences
30 30
31 import UI.PixmapCache 31 import UI.PixmapCache
32 32
356 [self.tr("Appearance"), "preferences-styles.png", 356 [self.tr("Appearance"), "preferences-styles.png",
357 "WebBrowserAppearancePage", "0webBrowserPage", None], 357 "WebBrowserAppearancePage", "0webBrowserPage", None],
358 "webBrowserPage": 358 "webBrowserPage":
359 [self.tr("eric6 Web Browser"), "ericWeb.png", 359 [self.tr("eric6 Web Browser"), "ericWeb.png",
360 "WebBrowserPage", "0webBrowserPage", None], 360 "WebBrowserPage", "0webBrowserPage", None],
361 "helpFlashCookieManagerPage": 361 "webBrowserFlashCookieManagerPage":
362 [self.tr("Flash Cookie Manager"), 362 [self.tr("Flash Cookie Manager"),
363 "flashCookie16.png", 363 "flashCookie16.png",
364 "HelpFlashCookieManagerPage", "0webBrowserPage", None], 364 "WebBrowserFlashCookieManagerPage", "0webBrowserPage",
365 None],
365 "webBrowserVirusTotalPage": 366 "webBrowserVirusTotalPage":
366 [self.tr("VirusTotal Interface"), "virustotal.png", 367 [self.tr("VirusTotal Interface"), "virustotal.png",
367 "WebBrowserVirusTotalPage", "0webBrowserPage", None], 368 "WebBrowserVirusTotalPage", "0webBrowserPage", None],
369 "webBrowserSpellCheckingPage":
370 [self.tr("Spell checking"),
371 "preferences-spellchecking.png",
372 "WebBrowserSpellCheckingPage", "0webBrowserPage",
373 None],
368 }) 374 })
369 if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800:
370 self.configItems.update({
371 "webBrowserSpellCheckingPage":
372 [self.tr("Spell checking"),
373 "preferences-spellchecking.png",
374 "WebBrowserSpellCheckingPage", "0webBrowserPage",
375 None],
376 })
377 else:
378 try:
379 from PyQt5 import QtWebKit # __IGNORE_WARNING__
380 self.configItems.update({
381 "0helpBrowserPage":
382 [self.tr("Web Browser"), "ericWeb.png",
383 None, None, None],
384 "helpAppearancePage":
385 [self.tr("Appearance"), "preferences-styles.png",
386 "HelpAppearancePage", "0helpBrowserPage", None],
387 "helpWebBrowserPage":
388 [self.tr("eric6 Web Browser"), "ericWeb.png",
389 "HelpWebBrowserPage", "0helpBrowserPage", None],
390 "helpFlashCookieManagerPage":
391 [self.tr("Flash Cookie Manager"),
392 "flashCookie16.png",
393 "HelpFlashCookieManagerPage", "0helpBrowserPage",
394 None],
395 "helpVirusTotalPage":
396 [self.tr("VirusTotal Interface"), "virustotal.png",
397 "HelpVirusTotalPage", "0helpBrowserPage", None],
398 })
399 except ImportError:
400 pass
401 375
402 self.configItems.update( 376 self.configItems.update(
403 e5App().getObject("PluginManager").getPluginConfigData()) 377 e5App().getObject("PluginManager").getPluginConfigData())
404
405 elif displayMode == ConfigurationWidget.HelpBrowserMode:
406 self.configItems = {
407 # key : [display string, pixmap name, dialog module name or
408 # page creation function, parent key,
409 # reference to configuration page (must always be last)]
410 # The dialog module must have the module function 'create' to
411 # create the configuration page. This must have the method
412 # 'save' to save the settings.
413 "interfacePage":
414 [self.tr("Interface"), "preferences-interface.png",
415 "HelpInterfacePage", None, None],
416 "networkPage":
417 [self.tr("Network"), "preferences-network.png",
418 "NetworkPage", None, None],
419 "printerPage":
420 [self.tr("Printer"), "preferences-printer.png",
421 "PrinterPage", None, None],
422 "securityPage":
423 [self.tr("Security"), "preferences-security.png",
424 "SecurityPage", None, None],
425
426 "helpDocumentationPage":
427 [self.tr("Help Documentation"),
428 "preferences-helpdocumentation.png",
429 "HelpDocumentationPage", None, None],
430 }
431 try:
432 from PyQt5 import QtWebKit # __IGNORE_WARNING__
433 self.configItems.update({
434 "helpAppearancePage":
435 [self.tr("Appearance"), "preferences-styles.png",
436 "HelpAppearancePage", None, None],
437 "helpFlashCookieManagerPage":
438 [self.tr("Flash Cookie Manager"),
439 "flashCookie16.png",
440 "HelpFlashCookieManagerPage", None, None],
441 "helpVirusTotalPage":
442 [self.tr("VirusTotal Interface"), "virustotal.png",
443 "HelpVirusTotalPage", None, None],
444 "helpWebBrowserPage":
445 [self.tr("eric6 Web Browser"), "ericWeb.png",
446 "HelpWebBrowserPage", None, None],
447 })
448 except ImportError:
449 pass
450 378
451 elif displayMode == ConfigurationWidget.WebBrowserMode: 379 elif displayMode == ConfigurationWidget.WebBrowserMode:
452 self.configItems = { 380 self.configItems = {
453 # key : [display string, pixmap name, dialog module name or 381 # key : [display string, pixmap name, dialog module name or
454 # page creation function, parent key, 382 # page creation function, parent key,
479 "WebBrowserAppearancePage", None, None], 407 "WebBrowserAppearancePage", None, None],
480 "webBrowserPage": 408 "webBrowserPage":
481 [self.tr("eric6 Web Browser"), "ericWeb.png", 409 [self.tr("eric6 Web Browser"), "ericWeb.png",
482 "WebBrowserPage", None, None], 410 "WebBrowserPage", None, None],
483 411
484 "helpFlashCookieManagerPage": 412 "webBrowserFlashCookieManagerPage":
485 [self.tr("Flash Cookie Manager"), 413 [self.tr("Flash Cookie Manager"),
486 "flashCookie16.png", 414 "flashCookie16.png",
487 "HelpFlashCookieManagerPage", None, None], 415 "WebBrowserFlashCookieManagerPage", None, None],
488 "webBrowserVirusTotalPage": 416 "webBrowserVirusTotalPage":
489 [self.tr("VirusTotal Interface"), "virustotal.png", 417 [self.tr("VirusTotal Interface"), "virustotal.png",
490 "WebBrowserVirusTotalPage", None, None], 418 "WebBrowserVirusTotalPage", None, None],
419
420 "webBrowserSpellCheckingPage":
421 [self.tr("Spell checking"),
422 "preferences-spellchecking.png",
423 "WebBrowserSpellCheckingPage", None, None],
491 } 424 }
492
493 if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800:
494 self.configItems.update({
495 "webBrowserSpellCheckingPage":
496 [self.tr("Spell checking"),
497 "preferences-spellchecking.png",
498 "WebBrowserSpellCheckingPage", None, None],
499 })
500 425
501 elif displayMode == ConfigurationWidget.TrayStarterMode: 426 elif displayMode == ConfigurationWidget.TrayStarterMode:
502 self.configItems = { 427 self.configItems = {
503 # key : [display string, pixmap name, dialog module name or 428 # key : [display string, pixmap name, dialog module name or
504 # page creation function, parent key, 429 # page creation function, parent key,
650 self.buttonBox.setOrientation(Qt.Horizontal) 575 self.buttonBox.setOrientation(Qt.Horizontal)
651 self.buttonBox.setStandardButtons( 576 self.buttonBox.setStandardButtons(
652 QDialogButtonBox.Apply | QDialogButtonBox.Cancel | 577 QDialogButtonBox.Apply | QDialogButtonBox.Cancel |
653 QDialogButtonBox.Ok | QDialogButtonBox.Reset) 578 QDialogButtonBox.Ok | QDialogButtonBox.Reset)
654 self.buttonBox.setObjectName("buttonBox") 579 self.buttonBox.setObjectName("buttonBox")
655 if not self.fromEric and \ 580 if (
656 self.displayMode == ConfigurationWidget.DefaultMode: 581 not self.fromEric and
582 self.displayMode == ConfigurationWidget.DefaultMode
583 ):
657 self.buttonBox.button(QDialogButtonBox.Apply).hide() 584 self.buttonBox.button(QDialogButtonBox.Apply).hide()
658 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) 585 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
659 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) 586 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
660 self.verticalLayout_2.addWidget(self.buttonBox) 587 self.verticalLayout_2.addWidget(self.buttonBox)
661 588
694 childEnabled = False 621 childEnabled = False
695 text = text.lower() 622 text = text.lower()
696 for index in range(parent.childCount()): 623 for index in range(parent.childCount()):
697 itm = parent.child(index) 624 itm = parent.child(index)
698 if itm.childCount() > 0: 625 if itm.childCount() > 0:
699 enable = self.__searchChildItems(itm, text) or \ 626 enable = (
700 text == "" or text in itm.text(0).lower() 627 self.__searchChildItems(itm, text) or
628 text == "" or
629 text in itm.text(0).lower()
630 )
701 else: 631 else:
702 enable = text == "" or text in itm.text(0).lower() 632 enable = text == "" or text in itm.text(0).lower()
703 if enable: 633 if enable:
704 childEnabled = True 634 childEnabled = True
705 itm.setDisabled(not enable) 635 itm.setDisabled(not enable)
709 def __initLexers(self): 639 def __initLexers(self):
710 """ 640 """
711 Private method to initialize the dictionary of preferences lexers. 641 Private method to initialize the dictionary of preferences lexers.
712 """ 642 """
713 import QScintilla.Lexers 643 import QScintilla.Lexers
714 from .PreferencesLexer import PreferencesLexer, \ 644 from .PreferencesLexer import (
715 PreferencesLexerLanguageError 645 PreferencesLexer, PreferencesLexerLanguageError
646 )
716 647
717 self.lexers = {} 648 self.lexers = {}
718 for language in QScintilla.Lexers.getSupportedLanguages(): 649 for language in QScintilla.Lexers.getSupportedLanguages():
719 if language not in self.lexers: 650 if language not in self.lexers:
720 try: 651 try:
955 Public method to get an indication, if QtWebEngine is being used. 886 Public method to get an indication, if QtWebEngine is being used.
956 887
957 @return flag indicating the use of QtWebEngine 888 @return flag indicating the use of QtWebEngine
958 @rtype bool 889 @rtype bool
959 """ 890 """
960 return self.__webEngine or \ 891 return (
892 self.__webEngine or
961 self.displayMode == ConfigurationWidget.WebBrowserMode 893 self.displayMode == ConfigurationWidget.WebBrowserMode
894 )
962 895
963 896
964 class ConfigurationDialog(QDialog): 897 class ConfigurationDialog(QDialog):
965 """ 898 """
966 Class for the dialog variant. 899 Class for the dialog variant.

eric ide

mercurial