From d315f37c88c2a08a914acc6abf283a8f1b044422 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 19 Feb 2021 16:38:56 +0100 Subject: [PATCH] Remove translations of standard buttons and switch to native file dialogs --- nw/error.py | 1 - nw/gui/about.py | 1 - nw/gui/build.py | 4 +--- nw/gui/custom.py | 2 -- nw/gui/docmerge.py | 2 -- nw/gui/docsplit.py | 2 -- nw/gui/itemeditor.py | 2 -- nw/gui/preferences.py | 9 ++------- nw/gui/projload.py | 7 +------ nw/gui/projsettings.py | 5 +---- nw/gui/projwizard.py | 5 +---- nw/gui/wordlist.py | 2 -- nw/gui/writingstats.py | 5 +---- nw/guimain.py | 23 +---------------------- 14 files changed, 8 insertions(+), 62 deletions(-) diff --git a/nw/error.py b/nw/error.py index c29e3eb6..998b7347 100644 --- a/nw/error.py +++ b/nw/error.py @@ -68,7 +68,6 @@ class NWErrorMessage(QDialog): self.msgBody.setReadOnly(True) self.btnBox = QDialogButtonBox(QDialogButtonBox.Close) - self.btnBox.button(QDialogButtonBox.Close).setText(self.tr("Close")) self.btnBox.rejected.connect(self._doClose) # Assemble diff --git a/nw/gui/about.py b/nw/gui/about.py index 685621d3..94c66955 100644 --- a/nw/gui/about.py +++ b/nw/gui/about.py @@ -97,7 +97,6 @@ class GuiAbout(QDialog): # OK Button self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) self.buttonBox.accepted.connect(self._doClose) self.outerBox.addLayout(self.innerBox) diff --git a/nw/gui/build.py b/nw/gui/build.py index a5234be5..b6ee34d2 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -858,10 +858,8 @@ class GuiBuildNovel(QDialog): if not os.path.isdir(saveDir): saveDir = self.mainConf.homePath - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.DontUseNativeDialog savePath, _ = QFileDialog.getSaveFileName( - self, self.tr("Save Document As"), savePath, options=dlgOpt + self, self.tr("Save Document As"), savePath ) if not savePath: return False diff --git a/nw/gui/custom.py b/nw/gui/custom.py index e1ae95e1..1ecd7b8b 100644 --- a/nw/gui/custom.py +++ b/nw/gui/custom.py @@ -500,8 +500,6 @@ class QuotesDialog(QDialog): # Buttons self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doAccept) self.buttonBox.rejected.connect(self._doReject) diff --git a/nw/gui/docmerge.py b/nw/gui/docmerge.py index dfe928d5..c804c794 100644 --- a/nw/gui/docmerge.py +++ b/nw/gui/docmerge.py @@ -66,8 +66,6 @@ class GuiDocMerge(QDialog): self.listBox.setMinimumHeight(self.mainConf.pxInt(180)) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doMerge) self.buttonBox.rejected.connect(self._doClose) diff --git a/nw/gui/docsplit.py b/nw/gui/docsplit.py index 034a986c..2bffb28f 100644 --- a/nw/gui/docsplit.py +++ b/nw/gui/docsplit.py @@ -82,8 +82,6 @@ class GuiDocSplit(QDialog): self.splitLevel.currentIndexChanged.connect(self._populateList) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doSplit) self.buttonBox.rejected.connect(self._doClose) diff --git a/nw/gui/itemeditor.py b/nw/gui/itemeditor.py index 17393579..07926d33 100644 --- a/nw/gui/itemeditor.py +++ b/nw/gui/itemeditor.py @@ -117,8 +117,6 @@ class GuiItemEditor(QDialog): # Buttons self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doSave) self.buttonBox.rejected.connect(self._doClose) diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index 683eeea4..3dcff608 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -70,8 +70,6 @@ class GuiPreferences(PagedDialog): self.addTab(self.tabAuto, self.tr("Automation")) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doSave) self.buttonBox.rejected.connect(self._doClose) self.addControls(self.buttonBox) @@ -440,11 +438,8 @@ class GuiPreferencesProjects(QWidget): if not os.path.isdir(currDir): currDir = "" - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.ShowDirsOnly - dlgOpt |= QFileDialog.DontUseNativeDialog - newDir = QFileDialog.getExistingDirectory( - self, self.tr("Backup Directory"), currDir, options=dlgOpt + newDir = QFileDialog.getExistingDirectory( + self, self.tr("Backup Directory"), currDir, options=QFileDialog.ShowDirsOnly ) if newDir: self.backupPath = newDir diff --git a/nw/gui/projload.py b/nw/gui/projload.py index 24c40ca2..bb5bedfe 100644 --- a/nw/gui/projload.py +++ b/nw/gui/projload.py @@ -127,8 +127,6 @@ class GuiProjectLoad(QDialog): self.innerBox.addLayout(self.projectForm) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Open).setText(self.tr("Open")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doOpenRecent) self.buttonBox.rejected.connect(self._doCancel) @@ -190,11 +188,8 @@ class GuiProjectLoad(QDialog): self.tr("novelWriter Project File ({0})").format(nwFiles.PROJ_FILE), self.tr("All files ({0})").format("*.*"), ] - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.DontUseNativeDialog projFile, _ = QFileDialog.getOpenFileName( - self, self.tr("Open novelWriter Project"), "", - filter=";;".join(extFilter), options=dlgOpt + self, self.tr("Open novelWriter Project"), "", filter=";;".join(extFilter) ) if projFile: thePath = os.path.abspath(os.path.dirname(projFile)) diff --git a/nw/gui/projsettings.py b/nw/gui/projsettings.py index eeee08e4..fcbb2035 100644 --- a/nw/gui/projsettings.py +++ b/nw/gui/projsettings.py @@ -77,8 +77,6 @@ class GuiProjectSettings(PagedDialog): self.addTab(self.tabReplace, self.tr("Auto-Replace")) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) - self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) - self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) self.buttonBox.accepted.connect(self._doSave) self.buttonBox.rejected.connect(self._doClose) self.addControls(self.buttonBox) @@ -330,8 +328,7 @@ class GuiProjectEditStatus(QWidget): """ if self.selColour is not None: newCol = QColorDialog.getColor( - self.selColour, self, self.tr("Select Colour"), - QColorDialog.DontUseNativeDialog + self.selColour, self, self.tr("Select Colour") ) if newCol.isValid(): self.selColour = newCol diff --git a/nw/gui/projwizard.py b/nw/gui/projwizard.py index 590a48ab..6689a31e 100644 --- a/nw/gui/projwizard.py +++ b/nw/gui/projwizard.py @@ -211,11 +211,8 @@ class ProjWizardFolderPage(QWizardPage): if not os.path.isdir(lastPath): lastPath = "" - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.ShowDirsOnly - dlgOpt |= QFileDialog.DontUseNativeDialog projDir = QFileDialog.getExistingDirectory( - self, self.tr("Select Project Folder"), lastPath, options=dlgOpt + self, self.tr("Select Project Folder"), lastPath, options=QFileDialog.ShowDirsOnly ) if projDir: projName = self.field("projName") diff --git a/nw/gui/wordlist.py b/nw/gui/wordlist.py index 0e7f3747..6f1cd490 100644 --- a/nw/gui/wordlist.py +++ b/nw/gui/wordlist.py @@ -90,8 +90,6 @@ class GuiWordList(QDialog): self.editBox.addWidget(self.delButton, 0) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Save | QDialogButtonBox.Close) - self.buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Save")) - self.buttonBox.button(QDialogButtonBox.Close).setText(self.tr("Close")) self.buttonBox.accepted.connect(self._doSave) self.buttonBox.rejected.connect(self._doClose) diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py index 5cc23198..58c56516 100644 --- a/nw/gui/writingstats.py +++ b/nw/gui/writingstats.py @@ -259,7 +259,6 @@ class GuiWritingStats(QDialog): self.buttonBox.rejected.connect(self._doClose) self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close) - self.buttonBox.button(QDialogButtonBox.Close).setText(self.tr("Close")) self.btnClose.setAutoDefault(False) self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QDialogButtonBox.ActionRole) @@ -369,10 +368,8 @@ class GuiWritingStats(QDialog): fileName = "sessionStats.%s" % fileExt savePath = os.path.join(saveDir, fileName) - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.DontUseNativeDialog savePath, _ = QFileDialog.getSaveFileName( - self, self.tr("Save Data As"), savePath, options=dlgOpt + self, self.tr("Save Data As"), savePath ) if not savePath: return False diff --git a/nw/guimain.py b/nw/guimain.py index 50a0f6fa..3ea15162 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -550,11 +550,6 @@ class GuiMain(QMainWindow): logger.error("No project open") return False - # If the project is new, it may not have a path, so we need one - if self.theProject.projPath is None: - projPath = self.selectProjectPath() - self.theProject.setProjectPath(projPath) - if self.theProject.projPath is None: return False @@ -707,11 +702,8 @@ class GuiMain(QMainWindow): self.tr("novelWriter files ({0})").format("*.nwd"), self.tr("All files ({0})").format("*.*"), ] - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.DontUseNativeDialog loadFile, _ = QFileDialog.getOpenFileName( - self, self.tr("Import File"), lastPath, - options=dlgOpt, filter=";;".join(extFilter) + self, self.tr("Import File"), lastPath, filter=";;".join(extFilter) ) if not loadFile: return False @@ -931,19 +923,6 @@ class GuiMain(QMainWindow): # Main Dialogs ## - def selectProjectPath(self): - """Select where to save project. - """ - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.ShowDirsOnly - dlgOpt |= QFileDialog.DontUseNativeDialog - projPath = QFileDialog.getExistingDirectory( - self, self.tr("Save novelWriter Project"), "", options=dlgOpt - ) - if projPath: - return projPath - return None - def showProjectLoadDialog(self): """Opens the projects dialog for selecting either existing projects from a cache of recently opened projects, or provide a