Skip to content

Commit

Permalink
Only show message with migration status in the end of the process.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila <[email protected]>
  • Loading branch information
Camila committed Sep 17, 2023
1 parent d48c684 commit 9f00412
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
12 changes: 0 additions & 12 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,6 @@ bool AccountManager::restoreFromLegacySettings()
}
settings->endGroup();
}
// const auto importedAccounts = legacyAccounts.size();
// const auto messageBox = new QMessageBox(QMessageBox::Information,
// tr("Legacy import"),
// tr("Imported %1 account from legacy client%2.")
// .arg(QString::number(importedAccounts),
// importedAccounts > 0
// ? legacyAccounts.join(", ").prepend(": ")
// : ""),
// QMessageBox::Ok);
// messageBox->setAttribute(Qt::WA_DeleteOnClose);
// //messageBox->setWindowModality(Qt::NonModal);
// messageBox->open();
return true;
}

Expand Down
26 changes: 18 additions & 8 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Application::Application(int &argc, char **argv)
qCInfo(lcApplication) << "VFS suffix plugin is available";
}

_theme->setSystrayUseMonoIcons(cfg.monoIcons());
_theme->setSystrayUseMonoIcons(ConfigFile().monoIcons());
connect(_theme, &Theme::systrayUseMonoIconsChanged, this, &Application::slotUseMonoIconsChanged);

#if defined(Q_OS_WIN)
Expand Down Expand Up @@ -430,15 +430,26 @@ bool Application::shouldExit()
void Application::setupOrRestoreSettings()
{
// try to restore legacy accounts
if (restoreLegacyAccount()) {
// to do: notify users
}
const auto accountsRestored = restoreLegacyAccount();

_folderManager.reset(new FolderMan);
FolderMan::instance()->setSyncEnabled(true);

// try to restore legacy folders or set up folders
FolderMan::instance()->setupFolders();
const auto foldersRestored = FolderMan::instance()->setupFolders();

if (accountsRestored == AccountManager::AccountsRestoreSuccessFromLegacyVersion) {
const auto importedAccounts = AccountManager::instance()->accounts();
const auto messageBox = new QMessageBox(QMessageBox::Information,
tr("Legacy import"),
tr("Imported %1 account and %2 folders from legacy client.")
.arg(QString::number(importedAccounts.size()),
QString::number(foldersRestored)),
QMessageBox::Ok);
messageBox->setAttribute(Qt::WA_DeleteOnClose);
messageBox->setWindowModality(Qt::NonModal);
messageBox->open();
}
}

void Application::createConfigFile()
Expand Down Expand Up @@ -496,7 +507,7 @@ void Application::createConfigFile()
}
}

bool Application::restoreLegacyAccount()
AccountManager::AccountsRestoreResult Application::restoreLegacyAccount()
{
ConfigFile cfg;
const auto tryMigrate = cfg.overrideServerUrl().isEmpty();
Expand All @@ -518,10 +529,9 @@ bool Application::restoreLegacyAccount()
.arg(ConfigFile().configFile()),
tr("Quit %1").arg(Theme::instance()->appNameGUI()));
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
return false;
}
}
return true;
return accountsRestoreResult;
}

void Application::slotAccountStateRemoved(AccountState *accountState)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected slots:

void handleEditLocallyFromOptions();

bool restoreLegacyAccount();
AccountManager::AccountsRestoreResult restoreLegacyAccount();
void createConfigFile();
// Attempt to setup new settings or restore legacy settings
// The settings include the accounts and folders saved in the config file
Expand Down

0 comments on commit 9f00412

Please sign in to comment.