Change autosave notification to message by rooms. (#22)

This commit is contained in:
Jeremy Bullock 2020-05-27 22:02:48 -06:00 committed by GitHub
parent 97dbaef5c6
commit f7350c4601
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 4 deletions

View file

@ -1672,6 +1672,7 @@ bool IoCmd::saveAll() {
QObject::tr("An error occured while saving. \n" QObject::tr("An error occured while saving. \n"
"Please check your work and try again.")); "Please check your work and try again."));
} }
if (result) TApp::instance()->showMessage("Saved");
return result; return result;
} }

View file

@ -415,6 +415,9 @@ centralWidget->setLayout(centralWidgetLayout);*/
/*-- タイトルバーにScene名を表示する --*/ /*-- タイトルバーにScene名を表示する --*/
connect(TApp::instance()->getCurrentScene(), SIGNAL(nameSceneChanged()), this, connect(TApp::instance()->getCurrentScene(), SIGNAL(nameSceneChanged()), this,
SLOT(changeWindowTitle())); SLOT(changeWindowTitle()));
connect(TApp::instance(), SIGNAL(sendMessage(QString)), m_topBar,
SLOT(setMessage(QString)));
changeWindowTitle(); changeWindowTitle();
// Connetto i comandi che sono in RoomTabWidget // Connetto i comandi che sono in RoomTabWidget

View file

@ -46,6 +46,10 @@
#include <QCheckBox> #include <QCheckBox>
#include <QtDebug> #include <QtDebug>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QLabel>
#include <QTimer>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
void UrlOpener::open() { QDesktopServices::openUrl(m_url); } void UrlOpener::open() { QDesktopServices::openUrl(m_url); }
@ -802,6 +806,8 @@ TopBar::TopBar(QWidget *parent) : QToolBar(parent) {
m_roomTabBar = new RoomTabWidget(this); m_roomTabBar = new RoomTabWidget(this);
m_stackedMenuBar = new StackedMenuBar(this); m_stackedMenuBar = new StackedMenuBar(this);
m_lockRoomCB = new QCheckBox(this); m_lockRoomCB = new QCheckBox(this);
m_messageLabel = new QLabel(this);
m_messageLabel->setStyleSheet("color: lightgreen;");
m_containerFrame->setObjectName("TopBarTabContainer"); m_containerFrame->setObjectName("TopBarTabContainer");
m_roomTabBar->setObjectName("TopBarTab"); m_roomTabBar->setObjectName("TopBarTab");
@ -824,6 +830,8 @@ TopBar::TopBar(QWidget *parent) : QToolBar(parent) {
} }
mainLayout->addLayout(menuLayout); mainLayout->addLayout(menuLayout);
mainLayout->addStretch(1); mainLayout->addStretch(1);
mainLayout->addWidget(m_messageLabel, 0);
mainLayout->addSpacing(2);
mainLayout->addWidget(m_roomTabBar, 0); mainLayout->addWidget(m_roomTabBar, 0);
mainLayout->addSpacing(2); mainLayout->addSpacing(2);
mainLayout->addWidget(m_lockRoomCB, 0); mainLayout->addWidget(m_lockRoomCB, 0);
@ -847,3 +855,18 @@ TopBar::TopBar(QWidget *parent) : QToolBar(parent) {
SLOT(setIsLocked(bool))); SLOT(setIsLocked(bool)));
assert(ret); assert(ret);
} }
//-----------------------------------------------------------------------------
void TopBar::setMessage(QString message) {
m_messageLabel->setText(message);
QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this);
m_messageLabel->setGraphicsEffect(eff);
QPropertyAnimation *a = new QPropertyAnimation(eff, "opacity");
a->setDuration(4000);
a->setStartValue(1);
a->setEndValue(0);
a->setEasingCurve(QEasingCurve::OutBack);
a->start(QPropertyAnimation::DeleteWhenStopped);
connect(a, SIGNAL(finished()), m_messageLabel, SLOT(clear()));
}

View file

@ -25,6 +25,7 @@ class QHBoxLayout;
class SubXsheetRoomTabContainer; class SubXsheetRoomTabContainer;
class QCheckBox; class QCheckBox;
class QXmlStreamReader; class QXmlStreamReader;
class QLabel;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -171,6 +172,7 @@ class TopBar final : public QToolBar {
RoomTabWidget *m_roomTabBar; RoomTabWidget *m_roomTabBar;
StackedMenuBar *m_stackedMenuBar; StackedMenuBar *m_stackedMenuBar;
QCheckBox *m_lockRoomCB; QCheckBox *m_lockRoomCB;
QLabel *m_messageLabel;
public: public:
TopBar(QWidget *parent); TopBar(QWidget *parent);
@ -180,6 +182,9 @@ public:
StackedMenuBar *getStackedMenuBar() const { return m_stackedMenuBar; } StackedMenuBar *getStackedMenuBar() const { return m_stackedMenuBar; }
public slots:
void setMessage(QString message);
protected: protected:
/*-- 右クリックで消えないようにする--*/ /*-- 右クリックで消えないようにする--*/
void contextMenuEvent(QContextMenuEvent *event) override { event->accept(); } void contextMenuEvent(QContextMenuEvent *event) override { event->accept(); }

View file

@ -666,9 +666,9 @@ void TApp::autosave() {
} else } else
m_autosaveSuspended = false; m_autosaveSuspended = false;
DVGui::ProgressDialog pb( // DVGui::ProgressDialog pb(
"Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1); // "Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1);
pb.show(); // pb.show();
Preferences *pref = Preferences::instance(); Preferences *pref = Preferences::instance();
if (pref->isAutosaveSceneEnabled() && pref->isAutosaveOtherFilesEnabled()) { if (pref->isAutosaveSceneEnabled() && pref->isAutosaveOtherFilesEnabled()) {
IoCmd::saveAll(); IoCmd::saveAll();
@ -678,7 +678,7 @@ void TApp::autosave() {
IoCmd::saveNonSceneFiles(); IoCmd::saveNonSceneFiles();
} }
pb.setValue(1); // pb.setValue(1);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -730,3 +730,6 @@ QString TApp::getCurrentRoomName() const {
return currentRoom->getName(); return currentRoom->getName();
} }
//-----------------------------------------------------------------------------
void TApp::showMessage(QString message) { emit(sendMessage(message)); }

View file

@ -205,6 +205,8 @@ public:
XsheetViewer *getCurrentXsheetViewer() const { return m_xsheetViewer; } XsheetViewer *getCurrentXsheetViewer() const { return m_xsheetViewer; }
void showMessage(QString message);
protected: protected:
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
@ -246,6 +248,7 @@ signals:
// NOTE: For now QEvent::TabletLeaveProximity is NOT detected on Windows. See // NOTE: For now QEvent::TabletLeaveProximity is NOT detected on Windows. See
// QTBUG-53628. // QTBUG-53628.
void tabletLeft(); void tabletLeft();
void sendMessage(QString);
void void
activeViewerChanged(); // TODO: put widgets-related stuffs in some new handle activeViewerChanged(); // TODO: put widgets-related stuffs in some new handle