mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-08 14:04:33 +12:00
Another take on status bar (#262)
This commit is contained in:
parent
1764baf292
commit
e76b9b4a1c
|
@ -353,13 +353,31 @@ def customIcons():
|
|||
|
||||
return sorted(r)
|
||||
|
||||
def statusMessage(message, duration=5000):
|
||||
def statusMessage(message, duration=5000, importance=1):
|
||||
"""
|
||||
Shows a message in MainWindow's status bar.
|
||||
Importance: 0 = low, 1 = normal, 2 = important, 3 = critical.
|
||||
"""
|
||||
mainWindow().statusBar().show()
|
||||
mainWindow().statusBar().showMessage(message, duration)
|
||||
QTimer.singleShot(duration, mainWindow().statusBar().hide)
|
||||
from manuskript.ui import style as S
|
||||
MW.statusBar().hide()
|
||||
MW.statusLabel.setText(message)
|
||||
if importance == 0:
|
||||
MW.statusLabel.setStyleSheet("color:{};".format(S.textLighter))
|
||||
elif importance == 1:
|
||||
MW.statusLabel.setStyleSheet("color:{};".format(S.textLight))
|
||||
elif importance == 2:
|
||||
MW.statusLabel.setStyleSheet("color:{}; font-weight: bold;".format(S.text))
|
||||
elif importance == 3:
|
||||
MW.statusLabel.setStyleSheet("color:red; font-weight: bold;")
|
||||
MW.statusLabel.adjustSize()
|
||||
g = MW.statusLabel.geometry()
|
||||
# g.moveCenter(MW.mapFromGlobal(MW.geometry().center()))
|
||||
s = MW.layout().spacing() / 2
|
||||
g.setLeft(s)
|
||||
g.moveBottom(MW.mapFromGlobal(MW.geometry().bottomLeft()).y() - s)
|
||||
MW.statusLabel.setGeometry(g)
|
||||
MW.statusLabel.show()
|
||||
QTimer.singleShot(duration, MW.statusLabel.hide)
|
||||
|
||||
def openURL(url):
|
||||
"""
|
||||
|
|
|
@ -71,6 +71,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
# UI
|
||||
self.setupMoreUi()
|
||||
self.statusLabel = QLabel(self)
|
||||
self.statusLabel.setAutoFillBackground(True)
|
||||
self.statusLabel.hide()
|
||||
|
||||
# Welcome
|
||||
self.welcome.updateValues()
|
||||
|
@ -550,7 +553,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
if loadFromFile and not os.path.exists(project):
|
||||
print(self.tr("The file {} does not exist. Try again.").format(project))
|
||||
F.statusMessage(
|
||||
self.tr("The file {} does not exist. Try again.").format(project))
|
||||
self.tr("The file {} does not exist. Try again.", importance=3).format(project))
|
||||
return
|
||||
|
||||
if loadFromFile:
|
||||
|
@ -763,14 +766,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
r = loadSave.saveProject() # version=0
|
||||
self.saveTimerNoChanges.stop()
|
||||
|
||||
projectName = os.path.basename(self.currentProject)
|
||||
if r:
|
||||
feedback = self.tr("Project {} saved.").format(self.currentProject)
|
||||
feedback = self.tr("Project {} saved.").format(projectName)
|
||||
F.statusMessage(feedback, importance=0)
|
||||
else:
|
||||
feedback = self.tr("WARNING: Project {} not saved.").format(self.currentProject)
|
||||
feedback = self.tr("WARNING: Project {} not saved.").format(projectName)
|
||||
F.statusMessage(feedback, importance=3)
|
||||
|
||||
# Giving some feedback
|
||||
# Giving some feedback in console
|
||||
print(feedback)
|
||||
F.statusMessage(feedback)
|
||||
|
||||
def loadEmptyDatas(self):
|
||||
self.mdlFlatData = QStandardItemModel(self)
|
||||
|
@ -791,13 +796,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
if not errors:
|
||||
print(self.tr("Project {} loaded.").format(project))
|
||||
F.statusMessage(
|
||||
self.tr("Project {} loaded.").format(project), 5000)
|
||||
self.tr("Project {} loaded.").format(project), 2000)
|
||||
else:
|
||||
print(self.tr("Project {} loaded with some errors:").format(project))
|
||||
for e in errors:
|
||||
print(self.tr(" * {} wasn't found in project file.").format(e))
|
||||
F.statusMessage(
|
||||
self.tr("Project {} loaded with some errors.").format(project), 5000)
|
||||
self.tr("Project {} loaded with some errors.").format(project), 5000, importance = 3)
|
||||
|
||||
###############################################################################
|
||||
# MAIN CONNECTIONS
|
||||
|
|
|
@ -419,7 +419,8 @@ class outlineBasics(QAbstractItemView):
|
|||
# Check that we have at least 2 items
|
||||
if len(items) < 2:
|
||||
statusMessage(qApp.translate("outlineBasics",
|
||||
"Select at least two items. Folders are ignored."))
|
||||
"Select at least two items. Folders are ignored."),
|
||||
importance=2)
|
||||
return
|
||||
|
||||
# Check that all share the same parent
|
||||
|
@ -427,7 +428,8 @@ class outlineBasics(QAbstractItemView):
|
|||
for i in items:
|
||||
if i.parent() != p:
|
||||
statusMessage(qApp.translate("outlineBasics",
|
||||
"All items must be on the same level (share the same parent)."))
|
||||
"All items must be on the same level (share the same parent)."),
|
||||
importance=2)
|
||||
return
|
||||
|
||||
# Sort items by row
|
||||
|
|
Loading…
Reference in a new issue