diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index 071de8cbd..b2873eca6 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -61,7 +61,7 @@ AdBlockSubscription::AdBlockSubscription(QObject* parent) void AdBlockSubscription::loadRules() { - QString fileName = mApp->getActiveProfilPath() + "adblocklist.txt"; + QString fileName = mApp->currentProfilePath() + "adblocklist.txt"; QFile file(fileName); if (file.exists()) { @@ -126,7 +126,7 @@ void AdBlockSubscription::rulesDownloaded() return; } - QString fileName = mApp->getActiveProfilPath() + "adblocklist.txt"; + QString fileName = mApp->currentProfilePath() + "adblocklist.txt"; QFile file(fileName); if (!file.open(QFile::ReadWrite | QFile::Truncate)) { qWarning() << "AdBlockSubscription::" << __FUNCTION__ << "Unable to open adblock file for writing:" << fileName; @@ -161,7 +161,7 @@ void AdBlockSubscription::rulesDownloaded() void AdBlockSubscription::saveRules() { - QString fileName = mApp->getActiveProfilPath() + "adblocklist.txt"; + QString fileName = mApp->currentProfilePath() + "adblocklist.txt"; QFile file(fileName); if (!file.open(QFile::ReadWrite | QFile::Truncate)) { diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index ec836cd9a..e63534c11 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -561,27 +561,14 @@ void MainApplication::connectDatabase() void MainApplication::translateApp() { - QLocale locale; Settings settings; - settings.beginGroup("Language"); - QString file = settings.value("language", locale.name().append(".qm")).toString(); - QString shortLoc = file.left(2); - QString longLoc = file.left(5); - - if (file == "" || !QFile::exists(TRANSLATIONSDIR + file)) { - return; - } + const QString &file = settings.value("Language/language", QLocale::system().name()).toString(); QTranslator* app = new QTranslator(this); - app->load(TRANSLATIONSDIR + file); - QTranslator* sys = new QTranslator(this); + app->load(file, TRANSLATIONSDIR); - if (QFile::exists(TRANSLATIONSDIR + "qt_" + longLoc + ".qm")) { - sys->load(TRANSLATIONSDIR + "qt_" + longLoc + ".qm"); - } - else if (QFile::exists(TRANSLATIONSDIR + "qt_" + shortLoc + ".qm")) { - sys->load(TRANSLATIONSDIR + "qt_" + shortLoc + ".qm"); - } + QTranslator* sys = new QTranslator(this); + sys->load("qt_" + file, TRANSLATIONSDIR); m_activeLanguage = file; @@ -645,7 +632,7 @@ void MainApplication::saveSettings() m_iconProvider->saveIconsToDatabase(); AdBlockManager::instance()->save(); - QFile::remove(getActiveProfilPath() + "WebpageIcons.db"); + QFile::remove(currentProfilePath() + "WebpageIcons.db"); Settings::syncSettings(); } diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index 6354f62f6..be1f8aa72 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -70,8 +70,8 @@ public: QList mainWindows(); inline static MainApplication* getInstance() { return static_cast(QCoreApplication::instance()); } - inline QString getActiveProfilPath() { return m_activeProfil; } - inline QString getActiveLanguage() { return m_activeLanguage; } + inline QString currentProfilePath() { return m_activeProfil; } + inline QString currentLanguage() { return m_activeLanguage; } inline bool isClosing() { return m_isClosing; } inline bool isStartingAfterCrash() { return m_startingAfterCrash; } inline int windowCount() { return m_mainWindows.count(); } diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 6ea64a767..d5f1e01b4 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -79,7 +79,7 @@ #include #include -const QString QupZilla::VERSION = "1.1.8"; +const QString QupZilla::VERSION = "1.2.0"; const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; const QString QupZilla::AUTHOR = "David Rosca"; const QString QupZilla::COPYRIGHT = "2010-2012"; @@ -109,8 +109,6 @@ QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl) setWindowTitle(tr("QupZilla")); m_isStarting = true; - m_activeProfil = mApp->getActiveProfilPath(); - m_activeLanguage = mApp->getActiveLanguage(); setupUi(); setupMenu(); @@ -236,6 +234,7 @@ void QupZilla::setupUi() locationBarWidth = settings.value("LocationBarWidth", 480).toInt(); websearchBarWidth = settings.value("WebSearchBarWidth", 140).toInt(); + settings.endGroup(); QWidget* widget = new QWidget(this); widget->setCursor(Qt::ArrowCursor); diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index 2d980d1ba..f30f0710d 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -95,9 +95,6 @@ public: inline QAction* actionReload() { return m_actionReload; } inline QMenu* superMenu() { return m_superMenu; } - inline QString activeProfil() { return m_activeProfil; } - inline QString activeLanguage() { return m_activeLanguage; } - inline bool isClosing() { return m_isClosing; } inline QUrl homepageUrl() { return m_homepage; } @@ -262,8 +259,6 @@ private: ProgressBar* m_progressBar; QLabel* m_ipLabel; - QString m_activeProfil; - QString m_activeLanguage; QString m_lastWindowTitle; int m_sideBarWidth; diff --git a/src/lib/app/settings.cpp b/src/lib/app/settings.cpp index f8205651f..6028fab65 100644 --- a/src/lib/app/settings.cpp +++ b/src/lib/app/settings.cpp @@ -23,6 +23,12 @@ QSettings* Settings::m_settings = 0; Settings::Settings() { +#ifdef QT_DEBUG + if (!m_settings->group().isEmpty()) { + qWarning("Settings: Creating object with opened group!"); + m_settings->endGroup(); + } +#endif } void Settings::createSettings(const QString &fileName) @@ -62,7 +68,10 @@ QSettings* Settings::globalSettings() Settings::~Settings() { +#ifdef QT_DEBUG if (!m_settings->group().isEmpty()) { + qWarning("Settings: Deleting object with opened group!"); m_settings->endGroup(); } +#endif } diff --git a/src/lib/cookies/cookiejar.cpp b/src/lib/cookies/cookiejar.cpp index e2d544124..20372c6c5 100644 --- a/src/lib/cookies/cookiejar.cpp +++ b/src/lib/cookies/cookiejar.cpp @@ -53,7 +53,7 @@ CookieJar::CookieJar(QupZilla* mainClass, QObject* parent) : QNetworkCookieJar(parent) , p_QupZilla(mainClass) { - m_activeProfil = mApp->getActiveProfilPath(); + m_activeProfil = mApp->currentProfilePath(); loadSettings(); } diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 9a5eaadb3..98a3c7e51 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -82,7 +82,7 @@ void NetworkManager::loadSettings() if (settings.value("AllowLocalCache", true).toBool()) { m_diskCache = mApp->networkCache(); - m_diskCache->setCacheDirectory(mApp->getActiveProfilPath() + "/networkcache"); + m_diskCache->setCacheDirectory(mApp->currentProfilePath() + "/networkcache"); m_diskCache->setMaximumCacheSize(settings.value("MaximumCacheSize", 50).toInt() * 1024 * 1024); //MegaBytes setCache(m_diskCache); } @@ -370,7 +370,7 @@ void NetworkManager::removeLocalCertificate(const QSslCertificate &cert) //Delete cert file from profile bool deleted = false; - QDirIterator it(mApp->getActiveProfilPath() + "certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); + QDirIterator it(mApp->currentProfilePath() + "certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while (it.hasNext()) { const QString &filePath = it.next(); const QList &certs = QSslCertificate::fromPath(filePath); @@ -404,13 +404,13 @@ void NetworkManager::addLocalCertificate(const QSslCertificate &cert) m_localCerts.append(cert); QSslSocket::addDefaultCaCertificate(cert); - QDir dir(mApp->getActiveProfilPath()); + QDir dir(mApp->currentProfilePath()); if (!dir.exists("certificates")) { dir.mkdir("certificates"); } QString certFileName = fileNameForCert(cert); - QString fileName = qz_ensureUniqueFilename(mApp->getActiveProfilPath() + "certificates/" + certFileName); + QString fileName = qz_ensureUniqueFilename(mApp->currentProfilePath() + "certificates/" + certFileName); QFile file(fileName); if (file.open(QFile::WriteOnly)) { @@ -486,7 +486,7 @@ void NetworkManager::loadCertificates() } } #else - m_localCerts += QSslCertificate::fromPath(mApp->getActiveProfilPath() + "certificates/*.crt", QSsl::Pem, QRegExp::Wildcard); + m_localCerts += QSslCertificate::fromPath(mApp->currentProfilePath() + "certificates/*.crt", QSsl::Pem, QRegExp::Wildcard); #endif QSslSocket::setDefaultCaCertificates(m_caCerts + m_localCerts); diff --git a/src/lib/network/qupzillaschemehandler.cpp b/src/lib/network/qupzillaschemehandler.cpp index 6a2e5361a..93ffa1b3e 100644 --- a/src/lib/network/qupzillaschemehandler.cpp +++ b/src/lib/network/qupzillaschemehandler.cpp @@ -333,10 +333,10 @@ QString QupZillaSchemeReply::configPage() QString("
%1
%2
").arg(tr("Platform"), qz_buildSystem())); cPage.replace("%PATHS-TEXT%", - QString("
%1
%2
").arg(tr("Profile"), mApp->getActiveProfilPath()) + - QString("
%1
%2
").arg(tr("Settings"), mApp->getActiveProfilPath() + "settings.ini") + - QString("
%1
%2
").arg(tr("Saved session"), mApp->getActiveProfilPath() + "session.dat") + - QString("
%1
%2
").arg(tr("Pinned tabs"), mApp->getActiveProfilPath() + "pinnedtabs.dat") + + QString("
%1
%2
").arg(tr("Profile"), mApp->currentProfilePath()) + + QString("
%1
%2
").arg(tr("Settings"), mApp->currentProfilePath() + "settings.ini") + + QString("
%1
%2
").arg(tr("Saved session"), mApp->currentProfilePath() + "session.dat") + + QString("
%1
%2
").arg(tr("Pinned tabs"), mApp->currentProfilePath() + "pinnedtabs.dat") + QString("
%1
%2
").arg(tr("Data"), mApp->DATADIR) + QString("
%1
%2
").arg(tr("Themes"), mApp->THEMESDIR) + QString("
%1
%2
").arg(tr("Translations"), mApp->TRANSLATIONSDIR)); diff --git a/src/lib/other/browsinglibrary.cpp b/src/lib/other/browsinglibrary.cpp index a90fceef5..6a5e09948 100644 --- a/src/lib/other/browsinglibrary.cpp +++ b/src/lib/other/browsinglibrary.cpp @@ -148,7 +148,7 @@ void BrowsingLibrary::showRSS(QupZilla* mainClass) void BrowsingLibrary::optimizeDatabase() { mApp->setOverrideCursor(Qt::WaitCursor); - QString profilePath = mApp->getActiveProfilPath(); + QString profilePath = mApp->currentProfilePath(); QString sizeBefore = DownloadItem::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); mApp->history()->optimizeHistory(); QString sizeAfter = DownloadItem::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index 42df11c41..6145ae06d 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -54,14 +54,14 @@ void ClearPrivateData::historyClicked(bool state) void ClearPrivateData::clearLocalStorage() { - const QString &profile = mApp->getActiveProfilPath(); + const QString &profile = mApp->currentProfilePath(); qz_removeDir(profile + "LocalStorage"); } void ClearPrivateData::clearWebDatabases() { - const QString &profile = mApp->getActiveProfilPath(); + const QString &profile = mApp->currentProfilePath(); QWebDatabase::removeAllDatabases(); qz_removeDir(profile + "Databases"); @@ -72,7 +72,7 @@ void ClearPrivateData::clearCache() mApp->webSettings()->clearMemoryCaches(); mApp->networkManager()->cache()->clear(); - QFile::remove(mApp->getActiveProfilPath() + "ApplicationCache.db"); + QFile::remove(mApp->currentProfilePath() + "ApplicationCache.db"); } void ClearPrivateData::clearIcons() diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 179450b95..a2308f3d8 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -118,7 +118,7 @@ void Plugins::loadPlugins() return; } - QDir settingsDir(mApp->getActiveProfilPath() + "extensions/"); + QDir settingsDir(mApp->currentProfilePath() + "extensions/"); if (!settingsDir.exists()) { settingsDir.mkdir(settingsDir.absolutePath()); } @@ -200,7 +200,7 @@ PluginInterface* Plugins::initPlugin(PluginInterface* interface, QPluginLoader* return 0; } - interface->init(mApp->getActiveProfilPath() + "extensions/"); + interface->init(mApp->currentProfilePath() + "extensions/"); if (!interface->testPlugin()) { interface->unload(); @@ -208,7 +208,7 @@ PluginInterface* Plugins::initPlugin(PluginInterface* interface, QPluginLoader* return 0; } - qApp->installTranslator(interface->getTranslator(mApp->getActiveLanguage())); + qApp->installTranslator(interface->getTranslator(mApp->currentLanguage())); return interface; } diff --git a/src/lib/plugins/speeddial.cpp b/src/lib/plugins/speeddial.cpp index c06735a6a..9afe35b6b 100644 --- a/src/lib/plugins/speeddial.cpp +++ b/src/lib/plugins/speeddial.cpp @@ -60,11 +60,11 @@ void SpeedDial::loadSettings() } changed(allPages); - m_thumbnailsDir = mApp->getActiveProfilPath() + "thumbnails/"; + m_thumbnailsDir = mApp->currentProfilePath() + "thumbnails/"; // If needed, create thumbnails directory if (!QDir(m_thumbnailsDir).exists()) { - QDir(mApp->getActiveProfilPath()).mkdir("thumbnails"); + QDir(mApp->currentProfilePath()).mkdir("thumbnails"); } } diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index e214b1e83..24b4115cf 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -126,7 +126,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) connect(ui->newTabUseCurrent, SIGNAL(clicked()), this, SLOT(useActualNewTab())); //PROFILES - m_actProfileName = mApp->getActiveProfilPath(); + m_actProfileName = mApp->currentProfilePath(); m_actProfileName = m_actProfileName.left(m_actProfileName.length() - 1); m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/")); m_actProfileName.remove("/"); @@ -351,14 +351,12 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) //OTHER //Languages QString activeLanguage = ""; - if (!p_QupZilla->activeLanguage().isEmpty()) { - activeLanguage = p_QupZilla->activeLanguage(); - QString loc = activeLanguage; - loc.remove(".qm"); - QLocale locale(loc); + if (!mApp->currentLanguage().isEmpty()) { + activeLanguage = mApp->currentLanguage(); + QLocale locale(activeLanguage); QString country = QLocale::countryToString(locale.country()); QString language = QLocale::languageToString(locale.language()); - ui->languages->addItem(language + ", " + country + " (" + loc + ")", activeLanguage); + ui->languages->addItem(language + ", " + country + " (" + activeLanguage + ")", activeLanguage); } ui->languages->addItem("English (en_US)"); @@ -374,7 +372,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) QLocale locale(loc); QString country = QLocale::countryToString(locale.country()); QString language = QLocale::languageToString(locale.language()); - ui->languages->addItem(language + ", " + country + " (" + loc + ")", name); + ui->languages->addItem(language + ", " + country + " (" + loc + ")", loc); } // Proxy Configuration diff --git a/src/lib/tools/certificateinfowidget.cpp b/src/lib/tools/certificateinfowidget.cpp index 080e4a804..0a6490521 100644 --- a/src/lib/tools/certificateinfowidget.cpp +++ b/src/lib/tools/certificateinfowidget.cpp @@ -311,7 +311,7 @@ CertificateInfoWidget::CertificateInfoWidget(const QSslCertificate &cert, QWidge ui->issuedByO->setText(showCertInfo(cert.issuerInfo(QSslCertificate::Organization))); ui->issuedByOU->setText(showCertInfo(cert.issuerInfo(QSslCertificate::OrganizationalUnitName))); //Validity - QLocale locale = QLocale(mApp->getActiveLanguage().left(5)); + QLocale locale = QLocale(mApp->currentLanguage()); ui->validityIssuedOn->setText(locale.toString(cert.effectiveDate(), "dddd d. MMMM yyyy")); ui->validityExpiresOn->setText(locale.toString(cert.expiryDate(), "dddd d. MMMM yyyy")); } diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 1309d904a..24f734058 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -71,6 +71,7 @@ void TabBar::loadSettings() settings.beginGroup("Browser-Tabs-Settings"); setMovable(settings.value("makeTabsMovable", true).toBool()); + if (settings.value("ActivateLastTabWhenClosingActual", false).toBool()) { setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); } diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index 4132ceee8..52f97d2f0 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -130,8 +130,8 @@ void TabWidget::loadSettings() m_dontQuitWithOneTab = settings.value("dontQuitWithOneTab", false).toBool(); m_closedInsteadOpened = settings.value("closedInsteadOpenedTabs", false).toBool(); m_newTabAfterActive = settings.value("newTabAfterActive", true).toBool(); - settings.endGroup(); + settings.beginGroup("Web-URL-Settings"); m_urlOnNewTab = settings.value("newTabUrl", "qupzilla:speeddial").toUrl(); settings.endGroup(); @@ -647,7 +647,7 @@ void TabWidget::savePinnedTabs() stream << tabs; stream << tabsHistory; - QFile file(mApp->getActiveProfilPath() + "pinnedtabs.dat"); + QFile file(mApp->currentProfilePath() + "pinnedtabs.dat"); file.open(QIODevice::WriteOnly); file.write(data); file.close(); @@ -655,7 +655,7 @@ void TabWidget::savePinnedTabs() void TabWidget::restorePinnedTabs() { - QFile file(mApp->getActiveProfilPath() + "pinnedtabs.dat"); + QFile file(mApp->currentProfilePath() + "pinnedtabs.dat"); file.open(QIODevice::ReadOnly); QByteArray sd = file.readAll(); file.close(); diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index e53c4fb24..a296557b0 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -803,7 +803,7 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send text..."), this, SLOT(sendLinkByMail()))->setData(selectedText); menu->addSeparator(); - QString langCode = mApp->getActiveLanguage().left(2); + QString langCode = mApp->currentLanguage().left(2); QUrl googleTranslateUrl = QUrl(QString("http://translate.google.com/#auto|%1|%2").arg(langCode, selectedText)); Action* gtwact = new Action(QIcon(":icons/menu/translate.png"), tr("Google Translate")); gtwact->setData(googleTranslateUrl); diff --git a/src/plugins/AccessKeysNavigation/akn_plugin.cpp b/src/plugins/AccessKeysNavigation/akn_plugin.cpp index 98128f87b..e8d337bca 100644 --- a/src/plugins/AccessKeysNavigation/akn_plugin.cpp +++ b/src/plugins/AccessKeysNavigation/akn_plugin.cpp @@ -66,7 +66,7 @@ bool AKN_Plugin::testPlugin() QTranslator* AKN_Plugin::getTranslator(const QString &locale) { QTranslator* translator = new QTranslator(this); - translator->load(":/accesskeysnavigation/locale/" + locale); + translator->load(locale, ":/accesskeysnavigation/locale/"); return translator; } diff --git a/src/plugins/MouseGestures/mousegestures.cpp b/src/plugins/MouseGestures/mousegestures.cpp index 95e8a99eb..c9d08bf72 100644 --- a/src/plugins/MouseGestures/mousegestures.cpp +++ b/src/plugins/MouseGestures/mousegestures.cpp @@ -72,8 +72,8 @@ bool MouseGestures::mousePress(QObject* obj, QMouseEvent* event) if (frame->scrollBarGeometry(Qt::Vertical).contains(event->pos()) || frame->scrollBarGeometry(Qt::Horizontal).contains(event->pos())) { - return false; -} + return false; + } m_filter->mouseButtonPressEvent(event); diff --git a/src/plugins/MouseGestures/mousegesturesplugin.cpp b/src/plugins/MouseGestures/mousegesturesplugin.cpp index 5aeabc86b..2f161c59f 100644 --- a/src/plugins/MouseGestures/mousegesturesplugin.cpp +++ b/src/plugins/MouseGestures/mousegesturesplugin.cpp @@ -35,7 +35,7 @@ PluginSpec MouseGesturesPlugin::pluginSpec() spec.name = "Mouse Gestures"; spec.info = "Mouse gestures for QupZilla"; spec.description = "Provides support for navigating in webpages by mouse gestures"; - spec.version = "0.2.1"; + spec.version = "0.3.1"; spec.author = "David Rosca "; spec.icon = QPixmap(":/mousegestures/data/icon.png"); spec.hasSettings = true; @@ -69,7 +69,7 @@ bool MouseGesturesPlugin::testPlugin() QTranslator* MouseGesturesPlugin::getTranslator(const QString &locale) { QTranslator* translator = new QTranslator(this); - translator->load(":/mousegestures/locale/" + locale); + translator->load(locale, ":/mousegestures/locale/"); return translator; } diff --git a/src/plugins/TestPlugin/testplugin.cpp b/src/plugins/TestPlugin/testplugin.cpp index 09a3335a1..8aeced310 100644 --- a/src/plugins/TestPlugin/testplugin.cpp +++ b/src/plugins/TestPlugin/testplugin.cpp @@ -98,7 +98,7 @@ QTranslator* TestPlugin::getTranslator(const QString &locale) // QString locale will contains "fr_FR.qm" for French locale QTranslator* translator = new QTranslator(this); - translator->load(":/testplugin/locale/" + locale); + translator->load(locale, ":/testplugin/locale/"); return translator; }