Added confirmation dialog for account removal
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 11 Jan 2020 16:06:42 +0000 (17:06 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 11 Jan 2020 16:06:42 +0000 (17:06 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/generalsettings.cpp
src/gui/systray.cpp
src/gui/tray/UserModel.cpp

index 632ae43f838ae091f2da54edfd2dba0ffc72019a..d803299fa47dd32b43f6a0bc0bb94c78dd5cfeeb 100644 (file)
@@ -116,7 +116,8 @@ GeneralSettings::GeneralSettings(QWidget *parent)
     connect(_ui->ignoredFilesButton, &QAbstractButton::clicked, this, &GeneralSettings::slotIgnoreFilesEditor);
 
     // accountAdded means the wizard was finished and the wizard might change some options.
-    connect(AccountManager::instance(), &AccountManager::accountAdded, this, &GeneralSettings::loadMiscSettings);
+    // Update 01/2020: Show new tray window instead
+    // connect(AccountManager::instance(), &AccountManager::accountAdded, this, &GeneralSettings::loadMiscSettings);
 
     customizeStyle();
 }
index c7bbe2fe30452c1e2a58f4ed764f53793c291576..2157c75795fdcbe8f22a1cfdebdba4013338fd0f 100644 (file)
@@ -57,6 +57,9 @@ Systray::Systray() // TODO: make singleton, provide ::instance()
 
     connect(UserModel::instance(), &UserModel::newUserSelected,
         this, &Systray::slotChangeActivityModel);
+
+    connect(AccountManager::instance(), &AccountManager::accountAdded,
+        this, &Systray::showWindow);
 }
 
 Systray::~Systray()
index 8a14fc1b2da2eda7537d59e4d1bcccde6505d83a..33506f62d92d9a0d18af342c976aa6dfecc16a43 100644 (file)
@@ -4,8 +4,10 @@
 
 #include <QDesktopServices>
 #include <QIcon>
+#include <QMessageBox>
 #include <QSvgRenderer>
 #include <QPainter>
+#include <QPushButton>
 
 namespace OCC {
 
@@ -281,6 +283,21 @@ Q_INVOKABLE void UserModel::logout(const int &id)
 
 Q_INVOKABLE void UserModel::removeAccount(const int &id)
 {
+    QMessageBox messageBox(QMessageBox::Question,
+        tr("Confirm Account Removal"),
+        tr("<p>Do you really want to remove the connection to the account <i>%1</i>?</p>"
+           "<p><b>Note:</b> This will <b>not</b> delete any files.</p>")
+            .arg(_users[id].name()),
+        QMessageBox::NoButton);
+    QPushButton *yesButton =
+        messageBox.addButton(tr("Remove connection"), QMessageBox::YesRole);
+    messageBox.addButton(tr("Cancel"), QMessageBox::NoRole);
+
+    messageBox.exec();
+    if (messageBox.clickedButton() != yesButton) {
+        return;
+    }
+
     _users[id].logout();
     _users[id].removeAccount();
     if (_users.count() > 1) {