Merge pull request #195 from vkbo/gui_fixes

Gui Fixes
This commit is contained in:
Veronica K. Berglyd Olsen
2020-05-04 21:25:25 +02:00
committed by GitHub
56 changed files with 175 additions and 227 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import sys
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+56 -132
View File
@@ -8,12 +8,8 @@
File History:
Created: 2020-05-03 [0.4.5]
This class is based on Stack Overflow code by Stefan Scherfke, based
again on contribution by IMAN4K, published under license CC BY-SA 4.0.
https://stackoverflow.com/a/51825815/5825851
The above code has been modified to integrate with novelWriter, and
re-released under compatible GPLv3 (see creativecommons.org).
The core code of this class is based on Stack Overflow example by
Stefan Scherfke: https://stackoverflow.com/a/51825815/5825851
This file is a part of novelWriter
Copyright 2020, Veronica Berglyd Olsen
@@ -29,7 +25,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
@@ -50,55 +46,9 @@ class QSwitch(QAbstractButton):
self.setCheckable(True)
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self._trackRadius = 10
self._thumbRadius = 8
self._margin = max(0, self._thumbRadius - self._trackRadius)
self._baseOffset = max(self._thumbRadius, self._trackRadius)
self._endOffset = {
True: lambda: self.width() - self._baseOffset,
False: lambda: self._baseOffset,
}
self._offset = self._baseOffset
palette = self.palette()
if self._thumbRadius > self._trackRadius:
self._trackColor = {
True: palette.highlight(),
False: palette.dark(),
}
self._thumbColor = {
True: palette.highlight(),
False: palette.light(),
}
self._textColor = {
True: palette.highlightedText().color(),
False: palette.dark().color(),
}
self._thumbText = {
True: '',
False: '',
}
self._trackOpacity = 0.5
else:
self._thumbColor = {
True: palette.highlightedText(),
False: palette.light(),
}
self._trackColor = {
True: palette.highlight(),
False: palette.dark(),
}
self._textColor = {
True: palette.highlight().color(),
False: palette.dark().color(),
}
self._thumbText = {
True: nwUnicode.U_CHECK,
False: nwUnicode.U_MULT,
}
self._trackOpacity = 1.0
self.setFixedWidth(40)
self.setFixedHeight(20)
self._offset = 10
return
@@ -111,8 +61,8 @@ class QSwitch(QAbstractButton):
return self._offset
@offset.setter
def offset(self, value):
self._offset = value
def offset(self, theOffset):
self._offset = theOffset
self.update()
return
@@ -120,114 +70,88 @@ class QSwitch(QAbstractButton):
# Getters and Setters
##
def trackRadius(self):
return self._trackRadius
def setTrackRadius(self, theValue):
if isinstance(theValue, int):
if theValue > 0:
self._trackRadius = theValue
return
raise ValueError("trackRadius must be an integer > 0")
self.update()
def setChecked(self, isChecked):
"""Overload setChecked to also alter the offset.
"""
super().setChecked(isChecked)
if isChecked:
self.offset = 30
else:
self.offset = 10
return
def thumbRadius(self):
return self._thumbRadius
def setThumbRadius(self, theValue):
if isinstance(theValue, int):
if theValue > 0:
self._thumbRadius = theValue
return
raise ValueError("thumbRadius must be an integer > 0")
self.update()
return
def setChecked(self, checked):
super().setChecked(checked)
self.offset = self._endOffset[checked]()
def sizeHint(self):
return QSize(
4 * self._trackRadius + 2 * self._margin,
2 * self._trackRadius + 2 * self._margin,
)
##
# Events
##
def resizeEvent(self, event):
def resizeEvent(self, theEvent):
"""Overload resize to ensure correct offset.
"""
super().resizeEvent(event)
self.offset = self._endOffset[self.isChecked()]()
super().resizeEvent(theEvent)
if self.isChecked():
self.offset = 30
else:
self.offset = 10
return
def paintEvent(self, event):
"""Drawing the switch itself.
"""
qPaint = QPainter(self)
qPaint.setRenderHint(QPainter.Antialiasing, True)
qPaint.setPen(Qt.NoPen)
trackOpacity = self._trackOpacity
thumbOpacity = 1.0
textOpacity = 1.0
if self.isEnabled():
trackBrush = self._trackColor[self.isChecked()]
thumbBrush = self._thumbColor[self.isChecked()]
textColor = self._textColor[self.isChecked()]
qPalette = self.palette()
if self.isChecked():
trackBrush = qPalette.highlight()
thumbBrush = qPalette.highlightedText()
textColor = qPalette.highlight().color()
thumbText = nwUnicode.U_CHECK
else:
trackOpacity *= 0.8
trackBrush = self.palette().shadow()
thumbBrush = self.palette().mid()
textColor = self.palette().shadow().color()
trackBrush = qPalette.dark()
thumbBrush = qPalette.light()
textColor = qPalette.dark().color()
thumbText = nwUnicode.U_MULT
if self.isEnabled():
trackOpacity = 1.0
else:
trackOpacity = 0.6
trackBrush = qPalette.shadow()
thumbBrush = qPalette.mid()
textColor = qPalette.shadow().color()
qPaint.setBrush(trackBrush)
qPaint.setOpacity(trackOpacity)
qPaint.drawRoundedRect(
self._margin,
self._margin,
self.width() - 2*self._margin,
self.height() - 2*self._margin,
self._trackRadius,
self._trackRadius,
)
qPaint.drawRoundedRect(0, 0, 40, 20, 10, 10)
qPaint.setBrush(thumbBrush)
qPaint.setOpacity(thumbOpacity)
qPaint.drawEllipse(
self.offset - self._thumbRadius,
self._baseOffset - self._thumbRadius,
2*self._thumbRadius,
2*self._thumbRadius,
)
qPaint.setPen(textColor)
qPaint.setOpacity(textOpacity)
qPaint.drawEllipse(self.offset - 8, 2, 16, 16)
theFont = qPaint.font()
theFont.setPixelSize(1.5*self._thumbRadius)
theFont.setPixelSize(12)
qPaint.setPen(textColor)
qPaint.setFont(theFont)
qPaint.drawText(
QRectF(
self.offset - self._thumbRadius,
self._baseOffset - self._thumbRadius,
2*self._thumbRadius,
2*self._thumbRadius,
),
Qt.AlignCenter,
self._thumbText[self.isChecked()],
QRectF(self.offset - 8, 2, 16, 16),
Qt.AlignCenter, thumbText
)
return
def mouseReleaseEvent(self, event):
"""Animate the switch.
"""Animate the switch on mouse release.
"""
super().mouseReleaseEvent(event)
if event.button() == Qt.LeftButton:
doAnim = QPropertyAnimation(self, b'offset', self)
doAnim.setDuration(120)
doAnim.setStartValue(self.offset)
doAnim.setEndValue(self._endOffset[self.isChecked()]())
if self.isChecked():
doAnim.setEndValue(30)
else:
doAnim.setEndValue(10)
doAnim.start()
return
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+17 -9
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from nw.constants.enum import nwItemClass, nwItemLayout, nwOutline
@@ -237,10 +237,14 @@ class nwUnicode:
U_MULT = "\u2715" # Multiplication x
## Arrows
U_UTRI = "\u2bc5" # Up-pointing triangle
U_DTRI = "\u2bc6" # Down-pointing triangle
U_LTRI = "\u2bc7" # Left-pointing triangle
U_RTRI = "\u2bc8" # Right-pointing triangle
U_UTRI = "\u25b2" # Up-pointing triangle
U_UTRIS = "\u25b4" # Up-pointing triangle, small
U_RTRI = "\u25b6" # Right-pointing triangle
U_RTRIS = "\u25b8" # Right-pointing triangle, small
U_DTRI = "\u25bc" # Down-pointing triangle
U_DTRIS = "\u25be" # Down-pointing triangle, small
U_LTRI = "\u25c0" # Left-pointing triangle
U_LTRIS = "\u25c2" # Left-pointing triangle, small
# HTML Equivalents
@@ -276,9 +280,13 @@ class nwUnicode:
H_MULT = "&#10005;"
## Arrows
H_UTRI = "&#11205;"
H_DTRI = "&#11206;"
H_LTRI = "&#11207;"
H_RTRI = "&#11208;"
H_UTRI = "&#9650;"
H_UTRIS = "&#9652;"
H_RTRI = "&#9654;"
H_RTRIS = "&#9656;"
H_DTRI = "&#9660;"
H_DTRIS = "&#9662;"
H_LTRI = "&#9664;"
H_LTRIS = "&#9666;"
# END Class nwUnicode
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from enum import Enum
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import textwrap
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import textwrap
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+30 -24
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
@@ -120,7 +120,7 @@ class GuiConfigEditor(QDialog):
msgBox = QMessageBox()
msgBox.information(
self, "Preferences",
"Some changes will not be applied until<br>%s has been restarted" % nw.__package__
"Some changes will not be applied until %s has been restarted." % nw.__package__
)
if validEntries:
@@ -166,7 +166,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow(
"Main GUI theme",
self.selectTheme,
"Changing this requires restarting %s" % nw.__package__
"Changing this requires restarting %s." % nw.__package__
)
## Syntax Highlighting
@@ -190,7 +190,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow(
"Prefer icons for dark backgrounds",
self.preferDarkIcons,
"May improve the look of icons on dark themes"
"This may improve the look of icons on dark themes."
)
# GUI Settings
@@ -253,12 +253,14 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow(
"Run backup when closing project",
self.backupOnClose,
"This option can be overridden in project settings"
"This option can be overridden in project settings."
)
## Ask before backup
## Only enabled when "Run when closing" is checked
self.askBeforeBackup = QSwitch()
self.askBeforeBackup.setChecked(self.mainConf.askBeforeBackup)
self.askBeforeBackup.setEnabled(self.mainConf.backupOnClose)
self.mainForm.addRow(
"Ask before running backup",
self.askBeforeBackup
@@ -355,7 +357,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.mainForm.addRow(
"Font family",
self.textStyleFont,
"For the document editor and viewer"
"Font for the document editor and viewer."
)
## Font Size
@@ -381,7 +383,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.textFlowMax.setSingleStep(10)
self.textFlowMax.setValue(self.mainConf.textWidth)
self.mainForm.addRow(
"Maximum text width in Normal mode",
"Maximum text width in \"Normal Mode\"",
self.textFlowMax,
theUnit="px"
)
@@ -393,7 +395,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.zenDocWidth.setSingleStep(10)
self.zenDocWidth.setValue(self.mainConf.zenWidth)
self.mainForm.addRow(
"Maximum text width in Zen mode",
"Maximum text width in \"Zen Mode\"",
self.zenDocWidth,
theUnit="px"
)
@@ -402,9 +404,9 @@ class GuiConfigEditLayoutTab(QWidget):
self.textFlowFixed = QSwitch()
self.textFlowFixed.setChecked(not self.mainConf.textFixedW)
self.mainForm.addRow(
"Disable maximum text width in Normal mode",
"Disable maximum text width in \"Normal Mode\"",
self.textFlowFixed,
"Only fixed margins are applied to the document"
"If disabled, minimum text width is defined by the margin setting."
)
## Justify Text
@@ -424,7 +426,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.mainForm.addRow(
"Document text margin",
self.textMargin,
"The minimum horizontal text margin if max with is enabled",
"If max width is enabled, this is the minimum margin.",
theUnit="px"
)
@@ -437,7 +439,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.mainForm.addRow(
"Editor tab width",
self.tabWidth,
"This feature requires Qt 5.9 or later",
"This feature requires Qt 5.9 or later.",
theUnit="px"
)
@@ -536,7 +538,7 @@ class GuiConfigEditEditingTab(QWidget):
self.mainForm.addRow(
"Spell check provider",
self.spellToolList,
"Note that the internal spell check tool is quite slow"
"Note that the internal spell check tool is quite slow."
)
self.mainForm.addRow(
"Spell check language",
@@ -552,7 +554,7 @@ class GuiConfigEditEditingTab(QWidget):
self.mainForm.addRow(
"Big document limit",
self.bigDocLimit,
"Disables full spell checking over the size limit",
"Disables full spell checking over the size limit.",
theUnit="kb"
)
@@ -638,7 +640,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
self.mainForm.addRow(
"Auto-select word under cursor",
self.autoSelect,
"Apply formatting to word under cursor if no selection is made"
"Apply formatting to word under cursor if no selection is made."
)
## Auto-Replace as You Type Main Switch
@@ -648,7 +650,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
self.mainForm.addRow(
"Auto-replace text as you type",
self.autoReplaceMain,
"Apply formatting to word under cursor if no selection is made"
"Apply formatting to word under cursor if no selection is made."
)
# Auto-Replace
@@ -658,37 +660,41 @@ class GuiConfigEditAutoReplaceTab(QWidget):
## Auto-Replace Single Quotes
self.autoReplaceSQ = QSwitch()
self.autoReplaceSQ.setChecked(self.mainConf.doReplaceSQuote)
self.autoReplaceSQ.setEnabled(self.mainConf.doReplace)
self.mainForm.addRow(
"Auto-replace single quotes",
self.autoReplaceSQ,
"The feature will try to guess opening or closing single quote"
"The feature will try to guess opening or closing single quote."
)
## Auto-Replace Double Quotes
self.autoReplaceDQ = QSwitch()
self.autoReplaceDQ.setChecked(self.mainConf.doReplaceDQuote)
self.autoReplaceDQ.setEnabled(self.mainConf.doReplace)
self.mainForm.addRow(
"Auto-replace double quotes",
self.autoReplaceDQ,
"The feature will try to guess opening or closing quote quote"
"The feature will try to guess opening or closing quote quote."
)
## Auto-Replace Hyphens
self.autoReplaceDash = QSwitch()
self.autoReplaceDash.setChecked(self.mainConf.doReplaceDash)
self.autoReplaceDash.setEnabled(self.mainConf.doReplace)
self.mainForm.addRow(
"Auto-replace dashes",
self.autoReplaceDash,
"Auto-replace double and triple hyphens with short and long dash"
"Auto-replace double and triple hyphens with short and long dash."
)
## Auto-Replace Dots
self.autoReplaceDots = QSwitch()
self.autoReplaceDots.setChecked(self.mainConf.doReplaceDots)
self.autoReplaceDots.setEnabled(self.mainConf.doReplace)
self.mainForm.addRow(
"Auto-replace dots",
self.autoReplaceDots,
"Auto-replace three dots with ellipsis"
"Auto-replace three dots with ellipsis."
)
# Quotation Style
@@ -704,7 +710,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
self.mainForm.addRow(
"Single quote open style",
self.quoteSingleStyleO,
"Auto-replaces apostrophe before words"
"Auto-replaces apostrophe before words."
)
self.quoteSingleStyleC = QLineEdit()
@@ -715,7 +721,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
self.mainForm.addRow(
"Single quote close style",
self.quoteSingleStyleC,
"Auto-replaces apostrophe after words"
"Auto-replaces apostrophe after words."
)
## Double Quote Style
@@ -727,7 +733,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
self.mainForm.addRow(
"Double quote open style",
self.quoteDoubleStyleO,
"Auto-replaces straight quotes before words"
"Auto-replaces straight quotes before words."
)
self.quoteDoubleStyleC = QLineEdit()
@@ -738,7 +744,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
self.mainForm.addRow(
"Double quote close style",
self.quoteDoubleStyleC,
"Auto-replaces straight quotes after words"
"Auto-replaces straight quotes after words."
)
return
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+2 -2
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
@@ -92,7 +92,7 @@ class GuiDocTitleBar(QLabel):
nwItem = self.theProject.getItem(aHandle)
if nwItem is not None:
tTitle.append(nwItem.itemName)
sSep = " %s " % nwUnicode.U_RTRI
sSep = " %s " % nwUnicode.U_RSAQUO
self.setText(sSep.join(tTitle))
else:
nwItem = self.theProject.getItem(tHandle)
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+19 -9
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
@@ -46,16 +46,25 @@ class NWBackup():
def zipIt(self):
if self.mainConf.backupPath is None:
self.theParent.makeAlert(
"Cannot backup project because no backup path is set.",nwAlert.WARN
)
if self.mainConf.backupPath is None or self.mainConf.backupPath == "":
self.theParent.makeAlert((
"Cannot backup project because no backup path is set. "
"Please set a valid backup location in Tools > Preferences."
), nwAlert.WARN)
return False
if self.theProject.projName is None:
self.theParent.makeAlert(
"Cannot backup project because no project name is set.",nwAlert.WARN
)
if self.theProject.projName is None or self.theProject.projName == "":
self.theParent.makeAlert((
"Cannot backup project because no project name is set. "
"Please set a Working Title in Project > Project Settings."
), nwAlert.WARN)
return False
if not path.isdir(self.mainConf.backupPath):
self.theParent.makeAlert((
"Cannot backup project because the backup path does not exist. "
"Please set a valid backup location in Tools > Preferences."
), nwAlert.WARN)
return False
logger.info("Backing up project")
@@ -75,6 +84,7 @@ class NWBackup():
self.theProject._clearLockFile()
make_archive(baseName, "zip", self.theProject.projPath, ".")
self.theProject._writeLockFile()
logger.info("Backup written to: %s" % archName)
except Exception as e:
self.theParent.makeAlert(
["Could not write backup archive.",str(e)],
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -21,7 +21,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -23,7 +23,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -22,7 +22,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
+1 -1
View File
@@ -23,7 +23,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging