From: Manuel Nickschas Date: Wed, 30 May 2018 23:16:47 +0000 (+0200) Subject: mono: Show a popup during database migration X-Git-Tag: travis-deploy-test~63 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=dc11e24b95e5b5e3595cc0e98eb2a572006912c7 mono: Show a popup during database migration Database upgrades may take a long while, during which the monolightic client can not be used. Show a modal popup during migration to both inform the user about what's going on, and preventing them from interacting with the client until the internal core is up and running. Show an "Initializing..." message in the status bar while the core is starting up, so there's some indication for the user besides the modal popup. --- diff --git a/src/client/client.cpp b/src/client/client.cpp index 0c71befb..6cd94c14 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -206,6 +206,12 @@ bool Client::internalCore() } +void Client::onDbUpgradeInProgress(bool inProgress) +{ + emit dbUpgradeInProgress(inProgress); +} + + /*** Network handling ***/ QList Client::networkIds() diff --git a/src/client/client.h b/src/client/client.h index 3dc261a4..3676e296 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -217,6 +217,9 @@ signals: void requestKickClient(int peerId); void passwordChanged(bool success); + //! Emitted when database schema upgrade starts or ends (only mono client) + void dbUpgradeInProgress(bool inProgress); + public slots: void disconnectFromCore(); @@ -226,6 +229,8 @@ public slots: void markBufferAsRead(BufferId id); + void onDbUpgradeInProgress(bool inProgress); + private slots: void setSyncedToCore(); void setDisconnectedFromCore(); diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index dd196d11..4127152c 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -385,6 +385,7 @@ void CoreConnection::connectToCurrentAccount() InternalPeer *peer = new InternalPeer(); _peer = peer; Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership + emit connectionMsg(tr("Initializing...")); emit connectToInternalCore(peer); setState(Connected); return; diff --git a/src/core/abstractsqlstorage.cpp b/src/core/abstractsqlstorage.cpp index fce1bb1d..89169ee9 100644 --- a/src/core/abstractsqlstorage.cpp +++ b/src/core/abstractsqlstorage.cpp @@ -139,20 +139,19 @@ Storage::State AbstractSqlStorage::init(const QVariantMap &settings, } if (installedSchemaVersion() < schemaVersion()) { - qWarning() << qPrintable(tr("Installed Schema (version %1) is not up to date. Upgrading to " - "version %2... This may take a while for major upgrades." - ).arg(installedSchemaVersion()).arg(schemaVersion())); - // TODO: The monolithic client won't show this message unless one looks into the debug log. - // This should be made more friendly, e.g. a popup message in the GUI. - if (!upgradeDb()) { + quInfo() << qPrintable(tr("Installed database schema (version %1) is not up to date. Upgrading to " + "version %2... This may take a while for major upgrades." + ).arg(installedSchemaVersion()).arg(schemaVersion())); + emit dbUpgradeInProgress(true); + auto upgradeResult = upgradeDb(); + emit dbUpgradeInProgress(false); + if (!upgradeResult) { qWarning() << qPrintable(tr("Upgrade failed...")); return NotAvailable; } - // Warning messages are also sent to the console, while Info messages aren't. Add a message - // when migration succeeds to avoid confusing folks by implying the schema upgrade failed if + // Add a message when migration succeeds to avoid confusing folks by implying the schema upgrade failed if // later functionality does not work. - qWarning() << qPrintable(tr("Installed Schema successfully upgraded to version %1." - ).arg(schemaVersion())); + quInfo() << qPrintable(tr("Installed database schema successfully upgraded to version %1.").arg(schemaVersion())); } quInfo() << qPrintable(displayName()) << "storage backend is ready. Schema version:" << installedSchemaVersion(); diff --git a/src/core/core.cpp b/src/core/core.cpp index 3f49a227..cf943b98 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -406,6 +406,8 @@ bool Core::initStorage(const QString &backend, const QVariantMap &settings, return false; } + connect(storage.get(), SIGNAL(dbUpgradeInProgress(bool)), this, SIGNAL(dbUpgradeInProgress(bool))); + Storage::State storageState = storage->init(settings, environment, loadFromEnvironment); switch (storageState) { case Storage::NeedsSetup: diff --git a/src/core/core.h b/src/core/core.h index e0ec7481..01bf477f 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -702,6 +702,9 @@ signals: //! Relay from CoreSession::sessionState(). Used for internal connection only void sessionState(const Protocol::SessionState &sessionState); + //! Emitted when database schema upgrade starts or ends + void dbUpgradeInProgress(bool inProgress); + public slots: bool init(); diff --git a/src/core/storage.h b/src/core/storage.h index f912c8b6..3930a953 100644 --- a/src/core/storage.h +++ b/src/core/storage.h @@ -551,6 +551,9 @@ signals: //! Sent when a user has been removed void userRemoved(UserId); + //! Emitted when database schema upgrade starts or ends + void dbUpgradeInProgress(bool inProgress); + protected: QString hashPassword(const QString &password); bool checkHashedPassword(const UserId user, const QString &password, const QString &hashedPassword, const Storage::HashVersion version); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 5dd6eb4c..b1a4eb7b 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -207,6 +207,7 @@ void MainWin::init() connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showNetworkConfig(NetworkId)), SLOT(showNetworkConfig(NetworkId))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString))); connect(Client::instance(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString))); + connect(Client::instance(), SIGNAL(dbUpgradeInProgress(bool)), SLOT(showMigrationWarning(bool))); connect(Client::coreConnection(), SIGNAL(startCoreSetup(QVariantList, QVariantList)), SLOT(showCoreConfigWizard(QVariantList, QVariantList))); connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(handleCoreConnectionError(QString))); @@ -828,6 +829,29 @@ void MainWin::showPasswordChangeDlg() } +void MainWin::showMigrationWarning(bool show) +{ + if (show && !_migrationWarning) { + _migrationWarning = new QMessageBox(QMessageBox::Information, + tr("Upgrading..."), + "" + tr("Your database is being upgraded") + "", + QMessageBox::NoButton, this); + _migrationWarning->setInformativeText("

" + + tr("In order to support new features, we need to make changes to your backlog database. This may take a long while.") + + "

" + + tr("Do not exit Quassel until the upgrade is complete!") + + "

"); + _migrationWarning->setStandardButtons(QMessageBox::NoButton); + _migrationWarning->show(); + } + else if (!show && _migrationWarning) { + _migrationWarning->close(); + _migrationWarning->deleteLater(); + _migrationWarning = nullptr; + } +} + + void MainWin::changeActiveBufferView(bool backwards) { if (_activeBufferViewIndex >= 0 && _activeBufferViewIndex < _bufferViews.count()) { diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index aa8aa946..6f741f55 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -50,8 +50,9 @@ class NickListWidget; class SystemTray; class TopicWidget; -class QMenu; class QLabel; +class QMenu; +class QMessageBox; class QToolBar; class KHelpMenu; @@ -97,6 +98,8 @@ public slots: void nextBuffer(); void previousBuffer(); + void showMigrationWarning(bool show); + //! Quit application void quit(); @@ -261,6 +264,8 @@ private: QWidget *_awayLog; + QMessageBox* _migrationWarning{nullptr}; + bool _layoutLoaded; QSize _normalSize; //!< Size of the non-maximized window diff --git a/src/qtui/monoapplication.cpp b/src/qtui/monoapplication.cpp index 1a8822d6..d880f33f 100644 --- a/src/qtui/monoapplication.cpp +++ b/src/qtui/monoapplication.cpp @@ -82,6 +82,8 @@ void MonolithicApplication::startInternalCore() connect(this, SIGNAL(connectInternalPeer(QPointer)), _core, SLOT(connectInternalPeer(QPointer))); connect(_core, SIGNAL(sessionState(Protocol::SessionState)), Client::coreConnection(), SLOT(internalSessionStateReceived(Protocol::SessionState))); + connect(_core, SIGNAL(dbUpgradeInProgress(bool)), Client::instance(), SLOT(onDbUpgradeInProgress(bool))); + _coreThread.start(); }