From 70f4ae528586bb94c32a911401f257ac24dd1eb1 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 6 Oct 2019 17:49:16 +0200 Subject: [PATCH 1/4] Remove all icons from dropdown menu --- nw/gui/mainmenu.py | 114 ++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index a4367953..c319dc20 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -75,7 +75,7 @@ class GuiMainMenu(QMenuBar): for n in range(len(self.mainConf.recentList)): recentProject = self.mainConf.recentList[n] if recentProject == "": continue - menuItem = QAction(QIcon.fromTheme("folder-open"), "%d: %s" % (n,recentProject), self.projMenu) + menuItem = QAction("%d: %s" % (n,recentProject), self.projMenu) menuItem.triggered.connect(lambda menuItem, n=n : self.openRecentProject(menuItem, n)) self.recentMenu.addAction(menuItem) return @@ -155,38 +155,38 @@ class GuiMainMenu(QMenuBar): self.projMenu = self.addMenu("&Project") # Project > New Project - menuItem = QAction(QIcon.fromTheme("folder-new"), "New Project", self) + menuItem = QAction("New Project", self) menuItem.setStatusTip("Create new project") menuItem.triggered.connect(lambda : self.theParent.newProject(None)) self.projMenu.addAction(menuItem) # Project > Open Project - menuItem = QAction(QIcon.fromTheme("folder-open"), "Open Project", self) + menuItem = QAction("Open Project", self) menuItem.setStatusTip("Open project") menuItem.setShortcut("Ctrl+Shift+O") menuItem.triggered.connect(lambda : self.theParent.openProject(None)) self.projMenu.addAction(menuItem) # Project > Save Project - menuItem = QAction(QIcon.fromTheme("document-save"), "Save Project", self) + menuItem = QAction("Save Project", self) menuItem.setStatusTip("Save project") menuItem.setShortcut("Ctrl+Shift+S") menuItem.triggered.connect(self.theParent.saveProject) self.projMenu.addAction(menuItem) # Project > Close Project - menuItem = QAction(QIcon.fromTheme("document-revert"), "Close Project", self) + menuItem = QAction("Close Project", self) menuItem.setStatusTip("Close project") menuItem.setShortcut("Ctrl+Shift+W") menuItem.triggered.connect(lambda : self.theParent.closeProject(False)) self.projMenu.addAction(menuItem) # Project > Recent Projects - self.recentMenu = self.projMenu.addMenu(QIcon.fromTheme("document-open-recent"),"Recent Projects") + self.recentMenu = self.projMenu.addMenu("Recent Projects") self.updateRecentProjects() # Project > Project Settings - menuItem = QAction(QIcon.fromTheme("document-properties"), "Project Settings", self) + menuItem = QAction("Project Settings", self) menuItem.setStatusTip("Project settings") menuItem.setShortcut("Ctrl+Shift+,") menuItem.triggered.connect(self.theParent.editProjectDialog) @@ -196,15 +196,15 @@ class GuiMainMenu(QMenuBar): self.projMenu.addSeparator() # Project > New Root - rootMenu = self.projMenu.addMenu(QIcon.fromTheme("folder-new"), "Create Root Folder") + rootMenu = self.projMenu.addMenu("Create Root Folder") self.rootItems = {} - self.rootItems[nwItemClass.NOVEL] = QAction(QIcon.fromTheme("folder-new"), "Novel Root", rootMenu) - self.rootItems[nwItemClass.PLOT] = QAction(QIcon.fromTheme("folder-new"), "Plot Root", rootMenu) - self.rootItems[nwItemClass.CHARACTER] = QAction(QIcon.fromTheme("folder-new"), "Character Root", rootMenu) - self.rootItems[nwItemClass.WORLD] = QAction(QIcon.fromTheme("folder-new"), "Location Root", rootMenu) - self.rootItems[nwItemClass.TIMELINE] = QAction(QIcon.fromTheme("folder-new"), "Timeline Root", rootMenu) - self.rootItems[nwItemClass.OBJECT] = QAction(QIcon.fromTheme("folder-new"), "Object Root", rootMenu) - self.rootItems[nwItemClass.CUSTOM] = QAction(QIcon.fromTheme("folder-new"), "Custom Root", rootMenu) + self.rootItems[nwItemClass.NOVEL] = QAction("Novel Root", rootMenu) + self.rootItems[nwItemClass.PLOT] = QAction("Plot Root", rootMenu) + self.rootItems[nwItemClass.CHARACTER] = QAction("Character Root", rootMenu) + self.rootItems[nwItemClass.WORLD] = QAction("Location Root", rootMenu) + self.rootItems[nwItemClass.TIMELINE] = QAction("Timeline Root", rootMenu) + self.rootItems[nwItemClass.OBJECT] = QAction("Object Root", rootMenu) + self.rootItems[nwItemClass.CUSTOM] = QAction("Custom Root", rootMenu) nCount = 0 for itemClass in self.rootItems.keys(): nCount += 1 # This forces the lambdas to be unique @@ -214,7 +214,7 @@ class GuiMainMenu(QMenuBar): rootMenu.addActions(self.rootItems.values()) # Project > New Folder - menuItem = QAction(QIcon.fromTheme("folder-new"), "Create Folder", self) + menuItem = QAction("Create Folder", self) menuItem.setStatusTip("Create folder") menuItem.setShortcut("Ctrl+Shift+N") menuItem.triggered.connect(lambda : self._newTreeItem(nwItemType.FOLDER, None)) @@ -224,14 +224,14 @@ class GuiMainMenu(QMenuBar): self.projMenu.addSeparator() # Project > Edit - menuItem = QAction(QIcon.fromTheme("document-properties"), "&Edit Item", self) + menuItem = QAction("&Edit Item", self) menuItem.setStatusTip("Change item settings") menuItem.setShortcuts(["Ctrl+E", "F2"]) menuItem.triggered.connect(self.theParent.editItem) self.projMenu.addAction(menuItem) # Project > Delete - menuItem = QAction(QIcon.fromTheme("edit-delete"), "&Delete Item", self) + menuItem = QAction("&Delete Item", self) menuItem.setStatusTip("Delete selected item") menuItem.setShortcut("Ctrl+Del") menuItem.triggered.connect(lambda : self.theParent.treeView.deleteItem(None)) @@ -241,7 +241,7 @@ class GuiMainMenu(QMenuBar): self.projMenu.addSeparator() # Project > Exit - menuItem = QAction(QIcon.fromTheme("application-exit"), "Exit", self) + menuItem = QAction("Exit", self) menuItem.setStatusTip("Exit %s" % nw.__package__) menuItem.setShortcut("Ctrl+Q") menuItem.triggered.connect(self._menuExit) @@ -255,28 +255,28 @@ class GuiMainMenu(QMenuBar): self.docuMenu = self.addMenu("&Document") # Document > New - menuItem = QAction(QIcon.fromTheme("document-new"), "&New Document", self) + menuItem = QAction("&New Document", self) menuItem.setStatusTip("Create new document") menuItem.setShortcut("Ctrl+N") menuItem.triggered.connect(lambda : self._newTreeItem(nwItemType.FILE, None)) self.docuMenu.addAction(menuItem) # Document > Open - menuItem = QAction(QIcon.fromTheme("document-open"), "&Open Document", self) + menuItem = QAction("&Open Document", self) menuItem.setStatusTip("Open selected document") menuItem.setShortcut("Ctrl+O") menuItem.triggered.connect(self.theParent.openSelectedItem) self.docuMenu.addAction(menuItem) # Document > Save - menuItem = QAction(QIcon.fromTheme("document-save"), "&Save Document", self) + menuItem = QAction("&Save Document", self) menuItem.setStatusTip("Save current document") menuItem.setShortcut("Ctrl+S") menuItem.triggered.connect(self.theParent.saveDocument) self.docuMenu.addAction(menuItem) # Document > Close - menuItem = QAction(QIcon.fromTheme("document-revert"), "Close Document", self) + menuItem = QAction("Close Document", self) menuItem.setStatusTip("Close current document") menuItem.setShortcut("Ctrl+W") menuItem.triggered.connect(self.theParent.closeDocEditor) @@ -286,14 +286,14 @@ class GuiMainMenu(QMenuBar): self.docuMenu.addSeparator() # Document > Preview - menuItem = QAction(QIcon.fromTheme("text-html"), "View Document", self) + menuItem = QAction("View Document", self) menuItem.setStatusTip("View document as HTML") menuItem.setShortcut("Ctrl+R") menuItem.triggered.connect(lambda : self.theParent.viewDocument(None)) self.docuMenu.addAction(menuItem) # Document > Close Preview - menuItem = QAction(QIcon.fromTheme("text-html"), "Close Document View", self) + menuItem = QAction("Close Document View", self) menuItem.setStatusTip("Close document view pane") menuItem.setShortcut("Ctrl+Shift+R") menuItem.triggered.connect(self.theParent.closeDocViewer) @@ -303,12 +303,12 @@ class GuiMainMenu(QMenuBar): # self.docuMenu.addSeparator() # # Document > Split - # menuItem = QAction(QIcon.fromTheme("list-add"), "Split Document", self) + # menuItem = QAction("Split Document", self) # menuItem.setStatusTip("Split Selected Document") # self.docuMenu.addAction(menuItem) # # Document > Merge - # menuItem = QAction(QIcon.fromTheme("list-remove"), "Merge Document", self) + # menuItem = QAction("Merge Document", self) # menuItem.setStatusTip("Merge Selected Documents") # self.docuMenu.addAction(menuItem) @@ -320,21 +320,21 @@ class GuiMainMenu(QMenuBar): self.viewMenu = self.addMenu("&View") # View > TreeView - menuItem = QAction(QIcon.fromTheme("go-home"), "TreeView", self) + menuItem = QAction("TreeView", self) menuItem.setStatusTip("Move focus to project tree") menuItem.setShortcut("Ctrl+1") menuItem.triggered.connect(lambda : self.theParent.setFocus(1)) self.viewMenu.addAction(menuItem) # View > Document Pane 1 - menuItem = QAction(QIcon.fromTheme("go-first"), "Left Document Pane", self) + menuItem = QAction("Left Document Pane", self) menuItem.setStatusTip("Move focus to left document pane") menuItem.setShortcut("Ctrl+2") menuItem.triggered.connect(lambda : self.theParent.setFocus(2)) self.viewMenu.addAction(menuItem) # View > Document Pane 2 - menuItem = QAction(QIcon.fromTheme("go-last"), "Right Document Pane", self) + menuItem = QAction("Right Document Pane", self) menuItem.setStatusTip("Move focus to right document pane") menuItem.setShortcut("Ctrl+3") menuItem.triggered.connect(lambda : self.theParent.setFocus(3)) @@ -344,7 +344,7 @@ class GuiMainMenu(QMenuBar): self.viewMenu.addSeparator() # View > Project Timeline - menuItem = QAction(QIcon.fromTheme("x-office-spreadsheet"), "Show Project Timeline", self) + menuItem = QAction("Show Project Timeline", self) menuItem.setStatusTip("Open the project timeline window") menuItem.setShortcut("Ctrl+T") menuItem.triggered.connect(self.theParent.showTimeLineDialog) @@ -358,14 +358,14 @@ class GuiMainMenu(QMenuBar): self.editMenu = self.addMenu("&Edit") # Edit > Undo - menuItem = QAction(QIcon.fromTheme("edit-undo"), "Undo", self) + menuItem = QAction("Undo", self) menuItem.setStatusTip("Undo last change") menuItem.setShortcut("Ctrl+Z") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.UNDO)) self.editMenu.addAction(menuItem) # Edit > Redo - menuItem = QAction(QIcon.fromTheme("edit-redo"), "Redo", self) + menuItem = QAction("Redo", self) menuItem.setStatusTip("Redo last change") menuItem.setShortcut("Ctrl+Y") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.REDO)) @@ -375,21 +375,21 @@ class GuiMainMenu(QMenuBar): self.editMenu.addSeparator() # Edit > Cut - menuItem = QAction(QIcon.fromTheme("edit-cut"), "Cut", self) + menuItem = QAction("Cut", self) menuItem.setStatusTip("Cut selected text") menuItem.setShortcut("Ctrl+X") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.CUT)) self.editMenu.addAction(menuItem) # Edit > Copy - menuItem = QAction(QIcon.fromTheme("edit-copy"), "Copy", self) + menuItem = QAction("Copy", self) menuItem.setStatusTip("Copy selected text") menuItem.setShortcut("Ctrl+C") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.COPY)) self.editMenu.addAction(menuItem) # Edit > Paste - menuItem = QAction(QIcon.fromTheme("edit-paste"), "Paste", self) + menuItem = QAction("Paste", self) menuItem.setStatusTip("Paste text from clipboard") menuItem.setShortcut("Ctrl+V") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.PASTE)) @@ -399,35 +399,35 @@ class GuiMainMenu(QMenuBar): self.editMenu.addSeparator() # Edit > Find - menuItem = QAction(QIcon.fromTheme("edit-find"), "Find", self) + menuItem = QAction("Find", self) menuItem.setStatusTip("Find text in document") menuItem.setShortcut("Ctrl+F") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.FIND)) self.editMenu.addAction(menuItem) # Edit > Replace - menuItem = QAction(QIcon.fromTheme("edit-find-replace"), "Replace", self) + menuItem = QAction("Replace", self) menuItem.setStatusTip("Replace text in document") menuItem.setShortcut("Ctrl+H") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.REPLACE)) self.editMenu.addAction(menuItem) # Edit > Find Next - menuItem = QAction(QIcon.fromTheme("go-next"), "Go Next", self) + menuItem = QAction("Find Next", self) menuItem.setStatusTip("Find next occurrence text in document") menuItem.setShortcut("F3") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.GO_NEXT)) self.editMenu.addAction(menuItem) # Edit > Find Prev - menuItem = QAction(QIcon.fromTheme("go-previous"), "Go Previous", self) + menuItem = QAction("Find Previous", self) menuItem.setStatusTip("Find previous occurrence text in document") menuItem.setShortcut("Shift+F3") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.GO_PREV)) self.editMenu.addAction(menuItem) # Edit > Replace Next - menuItem = QAction(QIcon.fromTheme("go-next"), "Replace Next", self) + menuItem = QAction("Replace Next", self) menuItem.setStatusTip("Find and replace next occurrence text in document") menuItem.setShortcut("Ctrl+Shift+1") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.REPL_NEXT)) @@ -437,14 +437,14 @@ class GuiMainMenu(QMenuBar): self.editMenu.addSeparator() # Edit > Select All - menuItem = QAction(QIcon.fromTheme("edit-select-all"), "Select All", self) + menuItem = QAction("Select All", self) menuItem.setStatusTip("Select all text in document") menuItem.setShortcut("Ctrl+A") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.SEL_ALL)) self.editMenu.addAction(menuItem) # Edit > Select Paragraph - menuItem = QAction(QIcon.fromTheme("edit-select-all"), "Select Paragraph", self) + menuItem = QAction("Select Paragraph", self) menuItem.setStatusTip("Select all text in paragraph") menuItem.setShortcut("Ctrl+Shift+A") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.SEL_PARA)) @@ -458,21 +458,21 @@ class GuiMainMenu(QMenuBar): self.fmtMenu = self.addMenu("&Format") # Format > Bold Text - menuItem = QAction(QIcon.fromTheme("format-text-bold"), "Bold Text", self) + menuItem = QAction("Bold Text", self) menuItem.setStatusTip("Make selected text bold") menuItem.setShortcut("Ctrl+B") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.BOLD)) self.fmtMenu.addAction(menuItem) # Format > Italic Text - menuItem = QAction(QIcon.fromTheme("format-text-italic"), "Italic Text", self) + menuItem = QAction("Italic Text", self) menuItem.setStatusTip("Make selected text italic") menuItem.setShortcut("Ctrl+I") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.ITALIC)) self.fmtMenu.addAction(menuItem) # Format > Underline Text - menuItem = QAction(QIcon.fromTheme("format-text-underline"), "Underline Text", self) + menuItem = QAction("Underline Text", self) menuItem.setStatusTip("Underline selected text") menuItem.setShortcut("Ctrl+U") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.U_LINE)) @@ -482,14 +482,14 @@ class GuiMainMenu(QMenuBar): self.fmtMenu.addSeparator() # Format > Double Quotes - menuItem = QAction(QIcon.fromTheme("insert-text"), "Wrap Double Quotes", self) + menuItem = QAction("Wrap Double Quotes", self) menuItem.setStatusTip("Wrap selected text in double quotes") menuItem.setShortcut("Ctrl+D") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.D_QUOTE)) self.fmtMenu.addAction(menuItem) # Format > Single Quotes - menuItem = QAction(QIcon.fromTheme("insert-text"), "Wrap Single Quotes", self) + menuItem = QAction("Wrap Single Quotes", self) menuItem.setStatusTip("Wrap selected text in single quotes") menuItem.setShortcut("Ctrl+Shift+D") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.S_QUOTE)) @@ -503,14 +503,14 @@ class GuiMainMenu(QMenuBar): self.toolsMenu = self.addMenu("&Tools") # Tools > Move Up - self.toolsMoveUp = QAction(QIcon.fromTheme("go-up"), "Move Tree Item Up", self) + self.toolsMoveUp = QAction("Move Tree Item Up", self) self.toolsMoveUp.setStatusTip("Move item up") self.toolsMoveUp.setShortcut("Ctrl+Shift+Up") self.toolsMoveUp.triggered.connect(lambda : self._moveTreeItem(-1)) self.toolsMenu.addAction(self.toolsMoveUp) # Tools > Move Down - self.toolsMoveDown = QAction(QIcon.fromTheme("go-down"), "Move Tree Item Down", self) + self.toolsMoveDown = QAction("Move Tree Item Down", self) self.toolsMoveDown.setStatusTip("Move item down") self.toolsMoveDown.setShortcut("Ctrl+Shift+Down") self.toolsMoveDown.triggered.connect(lambda : self._moveTreeItem(1)) @@ -529,7 +529,7 @@ class GuiMainMenu(QMenuBar): self.toolsMenu.addAction(self.toolsSpellCheck) # Tools > Update Spell Check - menuItem = QAction(QIcon.fromTheme("tools-check-spelling"), "Re-Run Spell Check", self) + menuItem = QAction("Re-Run Spell Check", self) menuItem.setStatusTip("Run the spell checker on current document") menuItem.setShortcut("F7") menuItem.triggered.connect(self.theParent.docEditor.updateSpellCheck) @@ -539,20 +539,20 @@ class GuiMainMenu(QMenuBar): self.toolsMenu.addSeparator() # Tools > Rebuild Indices - menuItem = QAction(QIcon.fromTheme("edit-redo"), "Rebuild Indices", self) + menuItem = QAction("Rebuild Indices", self) menuItem.setStatusTip("Rebuild the tag indices and word counts") menuItem.setShortcut("F9") menuItem.triggered.connect(self.theParent.rebuildIndex) self.toolsMenu.addAction(menuItem) # Tools > Backup - menuItem = QAction(QIcon.fromTheme("drive-harddisk"), "Backup Project", self) + menuItem = QAction("Backup Project", self) menuItem.setStatusTip("Backup Project") menuItem.triggered.connect(self.theParent.backupProject) self.toolsMenu.addAction(menuItem) # Tools > Settings - menuItem = QAction(QIcon.fromTheme("preferences-system"), "Preferences", self) + menuItem = QAction("Preferences", self) menuItem.setStatusTip("Preferences") menuItem.setShortcut("Ctrl+,") menuItem.triggered.connect(self.theParent.editConfigDialog) @@ -566,13 +566,13 @@ class GuiMainMenu(QMenuBar): self.helpMenu = self.addMenu("&Help") # Help > About - menuItem = QAction(QIcon.fromTheme("help-about"), "About %s" % nw.__package__, self) + menuItem = QAction("About %s" % nw.__package__, self) menuItem.setStatusTip("About %s" % nw.__package__) menuItem.triggered.connect(self._showAbout) self.helpMenu.addAction(menuItem) # Help > About Qt5 - menuItem = QAction(QIcon.fromTheme("help-about"), "About Qt5", self) + menuItem = QAction("About Qt5", self) menuItem.setStatusTip("About Qt5") menuItem.triggered.connect(self._showAboutQt) self.helpMenu.addAction(menuItem) @@ -581,7 +581,7 @@ class GuiMainMenu(QMenuBar): self.helpMenu.addSeparator() # Document > Preview - menuItem = QAction(QIcon.fromTheme("text-html"), "Documentation", self) + menuItem = QAction("Documentation", self) menuItem.setStatusTip("View documentation") menuItem.setShortcut("F1") menuItem.triggered.connect(lambda : self.theParent.viewDocument("Help")) From 052272938ca0ff2efe36df217326c8c6cef2e442 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 6 Oct 2019 17:51:59 +0200 Subject: [PATCH 2/4] Remove icon from context menu --- nw/gui/doceditor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index d1034121..a9a319f2 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -326,8 +326,7 @@ class GuiDocEditor(QTextEdit): return mnuSuggest = QMenu() - spIcon = QIcon.fromTheme("tools-check-spelling") - mnuHead = QAction(spIcon,"Spelling Suggestion", mnuSuggest) + mnuHead = QAction("Spelling Suggestion(s)", mnuSuggest) mnuSuggest.addAction(mnuHead) mnuSuggest.addSeparator() theSuggest = self.theDict.suggestWords(theWord) From 10bd5049bc7be48ae491033754491c6c10d0c492 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 6 Oct 2019 18:36:19 +0200 Subject: [PATCH 3/4] Load all icons via the theme class --- nw/gui/configeditor.py | 7 ++++--- nw/gui/doctree.py | 11 ++++++----- nw/gui/projecteditor.py | 7 ++++--- nw/gui/searchbar.py | 7 ++++--- nw/theme.py | 33 +++++++++++++++++++++++++++++++-- 5 files changed, 49 insertions(+), 16 deletions(-) diff --git a/nw/gui/configeditor.py b/nw/gui/configeditor.py index e6851b22..69376a78 100644 --- a/nw/gui/configeditor.py +++ b/nw/gui/configeditor.py @@ -113,6 +113,7 @@ class GuiConfigEditGeneral(QWidget): self.mainConf = nw.CONFIG self.theParent = theParent + self.theTheme = theParent.theTheme self.outerBox = QGridLayout() # User Interface @@ -122,7 +123,7 @@ class GuiConfigEditGeneral(QWidget): self.guiLookTheme = QComboBox() self.guiLookTheme.setMinimumWidth(200) - self.theThemes = self.theParent.theTheme.listThemes() + self.theThemes = self.theTheme.listThemes() for themeDir, themeName in self.theThemes: self.guiLookTheme.addItem(themeName, themeDir) themeIdx = self.guiLookTheme.findData(self.mainConf.guiTheme) @@ -131,7 +132,7 @@ class GuiConfigEditGeneral(QWidget): self.guiLookSyntax = QComboBox() self.guiLookSyntax.setMinimumWidth(200) - self.theSyntaxes = self.theParent.theTheme.listSyntax() + self.theSyntaxes = self.theTheme.listSyntax() for syntaxFile, syntaxName in self.theSyntaxes: self.guiLookSyntax.addItem(syntaxName, syntaxFile) syntaxIdx = self.guiLookSyntax.findData(self.mainConf.guiSyntax) @@ -192,7 +193,7 @@ class GuiConfigEditGeneral(QWidget): if path.isdir(self.mainConf.backupPath): self.projBackupPath.setText(self.mainConf.backupPath) - self.projBackupGetPath = QPushButton(QIcon.fromTheme("folder"),"") + self.projBackupGetPath = QPushButton(self.theTheme.getIcon("folder"),"") self.projBackupGetPath.clicked.connect(self._backupFolder) self.projBackupClose = QCheckBox(self) diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py index 07002b2c..48898952 100644 --- a/nw/gui/doctree.py +++ b/nw/gui/doctree.py @@ -37,6 +37,7 @@ class GuiDocTree(QTreeWidget): self.mainConf = nw.CONFIG self.debugGUI = self.mainConf.debugGUI self.theParent = theParent + self.theTheme = theParent.theTheme self.theProject = theProject # Tree Settings @@ -382,13 +383,13 @@ class GuiDocTree(QTreeWidget): newItem.setExpanded(nwItem.isExpanded) if nwItem.itemType == nwItemType.ROOT: - newItem.setIcon(self.C_NAME, QIcon.fromTheme("drive-harddisk")) + newItem.setIcon(self.C_NAME, self.theTheme.getIcon("root")) elif nwItem.itemType == nwItemType.FOLDER: - newItem.setIcon(self.C_NAME, QIcon.fromTheme("folder")) + newItem.setIcon(self.C_NAME, self.theTheme.getIcon("folder")) elif nwItem.itemType == nwItemType.FILE: - newItem.setIcon(self.C_NAME, QIcon.fromTheme("x-office-document")) + newItem.setIcon(self.C_NAME, self.theTheme.getIcon("document")) elif nwItem.itemType == nwItemType.TRASH: - newItem.setIcon(self.C_NAME, QIcon.fromTheme("user-trash")) + newItem.setIcon(self.C_NAME, self.theTheme.getIcon("trash")) return newItem @@ -413,7 +414,7 @@ class GuiDocTree(QTreeWidget): self.addTopLevelItem(newItem) self.orphRoot = newItem newItem.setExpanded(True) - newItem.setIcon(self.C_NAME, QIcon.fromTheme("dialog-warning")) + newItem.setIcon(self.C_NAME, self.theTheme.getIcon("orphan")) return def _cleanOrphanedRoot(self): diff --git a/nw/gui/projecteditor.py b/nw/gui/projecteditor.py index 5ba2e558..7bcc4d62 100644 --- a/nw/gui/projecteditor.py +++ b/nw/gui/projecteditor.py @@ -322,6 +322,7 @@ class GuiProjectEditReplace(QWidget): QWidget.__init__(self, theParent) self.theParent = theParent + self.theTheme = theParent.theTheme self.theProject = theProject self.arChanged = False @@ -341,9 +342,9 @@ class GuiProjectEditReplace(QWidget): self.editKey = QLineEdit() self.editValue = QLineEdit() - self.saveButton = QPushButton(QIcon.fromTheme("document-save"),"") - self.addButton = QPushButton(QIcon.fromTheme("list-add"),"") - self.delButton = QPushButton(QIcon.fromTheme("list-remove"),"") + self.saveButton = QPushButton(self.theTheme.getIcon("save"),"") + self.addButton = QPushButton(self.theTheme.getIcon("add"),"") + self.delButton = QPushButton(self.theTheme.getIcon("remove"),"") self.editKey.setEnabled(False) self.editValue.setEnabled(False) diff --git a/nw/gui/searchbar.py b/nw/gui/searchbar.py index 479ca9dd..53a5883b 100644 --- a/nw/gui/searchbar.py +++ b/nw/gui/searchbar.py @@ -30,6 +30,7 @@ class GuiSearchBar(QFrame): self.mainConf = nw.CONFIG self.theParent = theParent + self.theTheme = theParent.theTheme self.repVisible = False self.setContentsMargins(0,0,0,0) @@ -41,9 +42,9 @@ class GuiSearchBar(QFrame): self.replaceBox = QLineEdit() self.searchLabel = QLabel("Search") self.replaceLabel = QLabel("Replace") - self.closeButton = QPushButton(QIcon.fromTheme("edit-delete"),"") - self.searchButton = QPushButton(QIcon.fromTheme("edit-find"),"") - self.replaceButton = QPushButton(QIcon.fromTheme("edit-find-replace"),"") + self.closeButton = QPushButton(self.theTheme.getIcon("close"),"") + self.searchButton = QPushButton(self.theTheme.getIcon("search"),"") + self.replaceButton = QPushButton(self.theTheme.getIcon("replace"),"") self.closeButton.clicked.connect(self._doClose) self.searchButton.clicked.connect(self._doSearch) diff --git a/nw/theme.py b/nw/theme.py index 24f42d41..906d0e9f 100644 --- a/nw/theme.py +++ b/nw/theme.py @@ -17,7 +17,7 @@ import nw from os import path, listdir from PyQt5.QtWidgets import qApp -from PyQt5.QtGui import QPalette, QColor +from PyQt5.QtGui import QPalette, QColor, QIcon from nw.enum import nwAlert @@ -25,12 +25,27 @@ logger = logging.getLogger(__name__) class Theme: + ICON_MAP = { + "root" : "drive-harddisk", + "folder" : "folder", + "document" : "x-office-document", + "trash" : "user-trash", + "orphan" : "dialog-warning", + "save" : "document-save", + "add" : "list-add", + "remove" : "list-remove", + "close" : "edit-delete", + "search" : "edit-find", + "replace" : "edit-find-replace", + } + def __init__(self, theParent): self.mainConf = nw.CONFIG self.theParent = theParent self.guiPalette = QPalette() self.guiPath = "gui" + self.iconPath = "icons" self.syntaxPath = "syntax" self.cssName = "style.qss" self.confName = "theme.conf" @@ -76,10 +91,16 @@ class Theme: self.colTagErr = [ 0, 0, 0] self.colRepTag = [ 0, 0, 0] + ## Icons + self.themeIcons = {} + # Changeable Settings self.guiTheme = None self.guiSyntax = None self.themeRoot = None + self.themePath = None + self.syntaxFile = None + self.confFile = None self.cssFile = None self.updateTheme() @@ -95,11 +116,14 @@ class Theme: self.guiTheme = self.mainConf.guiTheme self.guiSyntax = self.mainConf.guiSyntax self.themeRoot = self.mainConf.themeRoot - self.themePath = path.join(self.mainConf.themeRoot, self.guiPath, self.guiTheme) + self.themePath = path.join(self.mainConf.themeRoot,self.guiPath,self.guiTheme) self.syntaxFile = path.join(self.themeRoot,self.syntaxPath,self.guiSyntax+".conf") self.confFile = path.join(self.themePath,self.confName) self.cssFile = path.join(self.themePath,self.cssName) + for iconName in self.ICON_MAP: + self.themeIcons[iconName] = QIcon.fromTheme(self.ICON_MAP[iconName]) + self.loadTheme() self.loadSyntax() @@ -262,6 +286,11 @@ class Theme: return self.syntaxList + def getIcon(self, iconName, iconSize=None): + if iconName in self.themeIcons: + return self.themeIcons[iconName] + return QIcon() + ## # Internal Functions ## From 8fc3de2a3dca2aece910c2616c4d64a491fb9eae Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 6 Oct 2019 20:44:24 +0200 Subject: [PATCH 4/4] Added a set of simple icons for dark theme --- nw/theme.py | 8 ++++ nw/themes/gui/default_dark/icons/add.png | Bin 0 -> 225 bytes nw/themes/gui/default_dark/icons/close.png | Bin 0 -> 296 bytes nw/themes/gui/default_dark/icons/document.png | Bin 0 -> 256 bytes nw/themes/gui/default_dark/icons/folder.png | Bin 0 -> 280 bytes nw/themes/gui/default_dark/icons/orphan.png | Bin 0 -> 552 bytes nw/themes/gui/default_dark/icons/remove.png | Bin 0 -> 204 bytes nw/themes/gui/default_dark/icons/replace.png | Bin 0 -> 338 bytes nw/themes/gui/default_dark/icons/root.png | Bin 0 -> 357 bytes nw/themes/gui/default_dark/icons/save.png | Bin 0 -> 295 bytes nw/themes/gui/default_dark/icons/search.png | Bin 0 -> 563 bytes nw/themes/gui/default_dark/icons/trash.png | Bin 0 -> 487 bytes nw/themes/gui/default_dark/theme.conf | 36 +++++++++--------- 13 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 nw/themes/gui/default_dark/icons/add.png create mode 100644 nw/themes/gui/default_dark/icons/close.png create mode 100644 nw/themes/gui/default_dark/icons/document.png create mode 100644 nw/themes/gui/default_dark/icons/folder.png create mode 100644 nw/themes/gui/default_dark/icons/orphan.png create mode 100644 nw/themes/gui/default_dark/icons/remove.png create mode 100644 nw/themes/gui/default_dark/icons/replace.png create mode 100644 nw/themes/gui/default_dark/icons/root.png create mode 100644 nw/themes/gui/default_dark/icons/save.png create mode 100644 nw/themes/gui/default_dark/icons/search.png create mode 100644 nw/themes/gui/default_dark/icons/trash.png diff --git a/nw/theme.py b/nw/theme.py index 906d0e9f..d6958df6 100644 --- a/nw/theme.py +++ b/nw/theme.py @@ -143,6 +143,14 @@ class Theme: logger.error("Could not load theme css file") return False + # Icon Files + iconsDir = path.join(self.themePath,self.iconPath) + if path.isdir(iconsDir): + for iconName in self.ICON_MAP: + iconFile = path.join(iconsDir,iconName+".png") + if path.isfile(iconFile): + self.themeIcons[iconName] = QIcon(iconFile) + # Config File confParser = configparser.ConfigParser() try: diff --git a/nw/themes/gui/default_dark/icons/add.png b/nw/themes/gui/default_dark/icons/add.png new file mode 100644 index 0000000000000000000000000000000000000000..486320716e09c6fe506a62c7dd48c0c561ac2f26 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7X~vBw5a>_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*n~t?1I`@W0~C@hag8W(&d<$F%`0JWE=o--Nlj5G z&n(GMaQE~L2yf&Q2P*RPba4!cIGmgy!Ky54Fllw*^490}M*qFeif=lTB=tf-qV&KD zW;a=bR}5}Wsxn&{t2!;ESex~Ed#<%D=7UJiVRk#H!N6c%%A@z)Q2H#;PzFy|KbLh* G2~7ZZq(315 literal 0 HcmV?d00001 diff --git a/nw/themes/gui/default_dark/icons/close.png b/nw/themes/gui/default_dark/icons/close.png new file mode 100644 index 0000000000000000000000000000000000000000..e3ff6ae0be7756493d113a6587b72ba5f3463a53 GIT binary patch literal 296 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7X~vBw5a>_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*o356n$-T}0EHw=Tq8=H^K)}k^GX<;i&7IyQd1Pl zGfOfQ+&z5*!W;R-fr=)0x;TbJ9DW<($ag@2LwMfi=|589H@)BSdQ-~eFrLUI=8Ly! zY+0%zwA=Zf*}16SwY6K+I5vLWx2YvAz4Te==0^pL%8Vg@irL&+&d*ayKg$}?8Ce+2 z_~v@lTxD%F>5XeEb~Bvi`B=gz91+#@alTj!U*Za0=VlF)E=i|neO2E?&ob;_=svJX i!Kq{Bd=HgxM_HddOp$5d>{beN8-u5-pUXO@geCyBC}y_+ literal 0 HcmV?d00001 diff --git a/nw/themes/gui/default_dark/icons/document.png b/nw/themes/gui/default_dark/icons/document.png new file mode 100644 index 0000000000000000000000000000000000000000..0d619034c67b5fab05468ec9cc90835ad5f313d7 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7X~vBw5a>_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*aXc@=66V%1BE0@Tq8=H^K)}k^GX<;i&7IyQd1Pl zGfOfQ+&z5*!W;R-fr>IbT^vIq4ksr_url*V6ngHd{r%0}R98q$>{yogWry|y4b}~< z6PWz{{kwE-?5q9#z>j&cqJb2XN;`w1Jnzm)6Iw-_Pk8b#-kFfn#-M4LY9h|_*Tf<7 qq{S?@wtP>IoLdra#e13<*%{vG2HFeAnVtgL$>8bg=d#Wzp$PzNc1g7W literal 0 HcmV?d00001 diff --git a/nw/themes/gui/default_dark/icons/folder.png b/nw/themes/gui/default_dark/icons/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..e7e36709ff4cb460ebb78466048d2ec2416c1bbd GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7X~vBw5a>_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*aQuQb8c|o0t!i%xJHyX=jZ08=9Mrw7o{eaq^2m8 zXO?6rxO@5rgg5eu0~IxRx;TbJ9DaN4Aa8>L4{Jb{RabI}1pCJq8E-<*YYB1I?LYQU zx$(=^m{~z8pT2v%yioh`QR+-qJ`3$WC!Y1cnZBQV?SE`v({9dFg@4%IS>_9T(dTer zc)@UV`iY!|P{&iR{xCMgHfb)-RyZ(g;;9$E(i%z|XPYm2$I7zdnyb?Nb6iK$WLzGk Sa_0iw!re zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00EFmL_t(o!|jzlO9Md=hTk_a zpb^x&O*$LJ#!>{e5J4>c16oAz<9DRdN*fCiTR{XBEK~#w|AVarLoEJsB2d>y*?&e`swi!BKEkv#G|Z#rs$2KNB+A~Hd806@QpOaV9v zTl<(9jct^Qhp7nkI5bN5} zVKZ9mIg;l9dg{dwl~Os9e#Zs0){`W!0rb{G`>yM*lCZ)@=htW*3PznTR=p{1Isg#&tY2`N`RyrkSTv>ki#CsWZ=s6e?uVV qcQM9XH2(db=k5II8Hfd9VqO73Xp}t?dQkfS0000_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*o4Gb%sZMCfkKict`Q~9`MJ5Nc_j?aMX8A;sVNHO znI#zt?w-B@;f;LaKt(2=E{-7)hu>b_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*o0JsBejF41BE0@Tq8=H^K)}k^GX<;i&7IyQd1Pl zGfOfQ+&z5*!W;R-fr@r{x;TbJ98OMBwl9zoH|Rtr=*m@Z2n^F zrb2}#*_(nsUpD=DJk|aSCu7XC&#yOJu;ZPOWf>~#(DyW?m|^F%;G>LFBK$ToYiymP z#2#?CXp^ji?&*_745qs3HyN*NoAYE*#ZoTzP+fIRmUZg{8h_jUImf>$!mliKOHgaG z)-+=S1A`3$EBRF4ZB@Q^VUJ?-S;qhEsnvq28u$0rdW*+%adR6d`7)oLrYoI$sGn&U aGlS~qiX49Rl_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*n~Ls6f<2jfkKict`Q~9`MJ5Nc_j?aMX8A;sVNHO znI#zt?w-B@;f;LaKt*RgT^vIq4kw!!8~;9U(9qDC*l@7Hx`B1N%ZYyZkgXZK?Cc-; zIDUR?KIrb%mH7K;H_yCZzeJ+>B|Jrx{46o@Zn6fi7`kpTpIIMooRgT4kRTwMdgId@$-lB6!b7Gcb~iAT=FT!`JlGz= tzUJYB1dg8{5))>p?AR4_SWl3N;YEv!aNBt|Z=lB*JYD@<);T3K0RVjTfHD98 literal 0 HcmV?d00001 diff --git a/nw/themes/gui/default_dark/icons/save.png b/nw/themes/gui/default_dark/icons/save.png new file mode 100644 index 0000000000000000000000000000000000000000..6b3c44965ae65c5be4c1d7a79ef67d74252fdcca GIT binary patch literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7X~vBw5a>_2q?l?;1OBO zz@VoL!i*J5?aP3I>?NMQuI!Jw*n}ixcBPyD1PV!(xJHyX=jZ08=9Mrw7o{eaq^2m8 zXO?6rxO@5rgg5eu0~Pgqx;TbJ98OM>*#g3 z<%t-NqWgqfT2dd>B$aor6u&F@B%<#sqm{1B|IC?h*IlVelnHstz`e_1@-?MdQ4&W4 gOm0a^v1%|dFbbH+GVNaY1L!mcPgg&ebxsLQ0ET&8s{jB1 literal 0 HcmV?d00001 diff --git a/nw/themes/gui/default_dark/icons/search.png b/nw/themes/gui/default_dark/icons/search.png new file mode 100644 index 0000000000000000000000000000000000000000..8cdb5347bb30690f715d65756bf77f5e72c34720 GIT binary patch literal 563 zcmV-30?hr1P)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00EmxL_t(o!|j$qYQjJihQAms z8j*k-5vABOcz|5M)tsQ+w`UN~Q1|u(S$P2u;2A1X5jR2*V`#MPCR3&mV=`@Qq5ivs z`R9G}X6C(ti~hTev;$q&y#;ze7idMl7r+!43n89z0f++kfzFAcGhmPv#5fWB5x55k zObf4Mvo$Nc7D@nIy@gZ{JM7S-eDI}hD1>y@Rc^8_*@+X?LytzV%nV^9qGq2e6PuMpue=p#v}l zs2+CO0E&02126`#Lr)t(@s4#X;WN-lQ-Tvp@=OSEqk9Mk0F7WtZSSWJUfcU>KN#p9 zLZTWz1ZeN()KhFnJ@nK*FmxPeXX2tiqYqz1!B{P|OQ`?=002ovPDHLkV1f^b B;MV{E literal 0 HcmV?d00001 diff --git a/nw/themes/gui/default_dark/icons/trash.png b/nw/themes/gui/default_dark/icons/trash.png new file mode 100644 index 0000000000000000000000000000000000000000..96afbba0c30af2eadde9cf57860efb5d9fb1e1fc GIT binary patch literal 487 zcmVe zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00B=)L_t(o!|hiwZiFxpTu$zJ zfPWD28j2K1+z${f6-6rA$Ug{D3JSjl-4FHw^hjJ0894^~Y_ljQT~@LL7`(ePJ8J{* z>Xx`Bg%Ascld7tcpa7KPzVAu0EX&dw$mW5Ra_PG66u6tFfjrND`DC^i5s?%D&iU>f zi~W$wE`P0pO#p~^nzOyNFHhMAq?C(_ma+y+1$ZHFCM8Z4aL%31+uL=$p2itI-@j=C za9Ml1!Zgn7eVQ?-hXT@!!N=RzaTz{>U1hAsG|rG_Ke^OH5kzH_3QV|_bJE?=rUV=J zdggoeu%`g;8bHL29L>UuEkY*+wjQ8!t|MdPpHu}Z^Li+th2v6WA+YOEo7}scyHv%F zcCuLRz0QPGdxA{?L4Dw?J>g*huXiGH!H$UQprX!81&RiJF>~QqsuG`