From 07b7d1d6ee1b7717f3a0cf665ecfdd3dff0c54b0 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 7 Oct 2014 16:37:44 +0200 Subject: [PATCH] Fixed #85. --- resources/text/CHANGELOG | 2 +- src/gui/formsettings.cpp | 6 ++++++ src/gui/formsettings.ui | 10 +++++++++ src/miscellaneous/application.cpp | 1 + src/miscellaneous/systemfactory.cpp | 32 +++++++++++++++++++++-------- src/miscellaneous/systemfactory.h | 5 +++++ 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 2aaa4b53d..39824a7c3 100644 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -3,7 +3,7 @@ Fixed: Added: diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 40ca73a6b..fb621996a 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -607,6 +607,11 @@ void FormSettings::loadGeneral() { tr(" (not supported on this platform)")); break; } + +#if defined(Q_OS_WIN) + m_ui->m_checkRemoveTrolltechJunk->setEnabled(true); + m_ui->m_checkRemoveTrolltechJunk->setChecked(qApp->settings()->value(APP_CFG_GEN, "remove_trolltech_junk", false).toBool()); +#endif } void FormSettings::saveGeneral() { @@ -619,6 +624,7 @@ void FormSettings::saveGeneral() { } qApp->settings()->setValue(APP_CFG_GEN, "update_on_start", m_ui->m_checkForUpdatesOnStart->isChecked()); + qApp->settings()->setValue(APP_CFG_GEN, "remove_trolltech_junk", m_ui->m_checkRemoveTrolltechJunk->isChecked()); } void FormSettings::loadInterface() { diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui index 71a4fc800..0b4746f35 100644 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -123,6 +123,16 @@ + + + + false + + + Remove junk Trolltech registry key (HKCUSoftwareTrolltech) whn application quits (Use at your own risk!) + + + diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index f51d31e4f..a139050c8 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -142,6 +142,7 @@ void Application::onAboutToQuit() { qDebug("Cleaning up resources and saving application state."); + system()->removeTrolltechJunkRegistryKeys(); mainForm()->tabWidget()->feedMessageViewer()->quit(); database()->saveDatabase(); mainForm()->saveSize(); diff --git a/src/miscellaneous/systemfactory.cpp b/src/miscellaneous/systemfactory.cpp index 908984273..9ad20726b 100755 --- a/src/miscellaneous/systemfactory.cpp +++ b/src/miscellaneous/systemfactory.cpp @@ -123,13 +123,11 @@ bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) { } #if defined(Q_OS_WIN) - QSettings registry_key("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", - QSettings::NativeFormat); + QSettings registry_key("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); switch (new_status) { case SystemFactory::Enabled: registry_key.setValue(APP_LOW_NAME, - Application::applicationFilePath().replace('/', - '\\')); + Application::applicationFilePath().replace('/', '\\')); return true; case SystemFactory::Disabled: registry_key.remove(APP_LOW_NAME); @@ -156,6 +154,22 @@ bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) { #endif } +#if defined(Q_OS_WIN) +bool SystemFactory::removeTrolltechJunkRegistryKeys() { + if (qApp->settings()->value(APP_CFG_GEN, "remove_trolltech_junk", false).toBool()) { + QSettings registry_key("HKEY_CURRENT_USER\\Software\\TrollTech", QSettings::NativeFormat); + + registry_key.remove(""); + registry_key.sync(); + + return registry_key.status() == QSettings::NoError; + } + else { + return false; + } +} +#endif + QPair SystemFactory::checkForUpdates() { QPair result; QByteArray releases_xml; @@ -223,11 +237,11 @@ void SystemFactory::handleBackgroundUpdatesCheck() { if (updates.second == QNetworkReply::NoError && updates.first.m_availableVersion != APP_VERSION) { if (SystemTrayIcon::isSystemTrayActivated()) { - qApp->trayIcon()->showMessage(tr("New version available"), - tr("Click the bubble for more information."), - QSystemTrayIcon::Information, - TRAY_ICON_BUBBLE_TIMEOUT, - qApp->mainForm(), SLOT(showUpdates())); + qApp->trayIcon()->showMessage(tr("New version available"), + tr("Click the bubble for more information."), + QSystemTrayIcon::Information, + TRAY_ICON_BUBBLE_TIMEOUT, + qApp->mainForm(), SLOT(showUpdates())); } } } diff --git a/src/miscellaneous/systemfactory.h b/src/miscellaneous/systemfactory.h index e9cbad968..1083b251d 100644 --- a/src/miscellaneous/systemfactory.h +++ b/src/miscellaneous/systemfactory.h @@ -79,6 +79,10 @@ class SystemFactory : public QObject { // new status failed. bool setAutoStartStatus(const SystemFactory::AutoStartStatus &new_status); +#if defined(Q_OS_WIN) + bool removeTrolltechJunkRegistryKeys(); +#endif + #if defined(Q_OS_LINUX) // Returns standard location where auto-start .desktop files // should be placed. @@ -89,6 +93,7 @@ class SystemFactory : public QObject { QPair checkForUpdates(); public slots: + // Performs asynchronous check for updates, result is emitted via updateCheckedAsynchronously(...) signal. void checkForUpdatesAsynchronously(); private slots: