From f09e5c981cfa15f0f5954fa07979cad7d217abee Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 14 Mar 2012 14:04:20 +0100 Subject: [PATCH] Fixed recalculating size of tabs after unpinning tab. + other small improvements / fixes --- src/lib/app/commandlineoptions.cpp | 20 +++---- src/lib/app/mainapplication.cpp | 55 +++++-------------- src/lib/app/mainapplication.h | 5 +- src/lib/app/qupzilla.cpp | 22 +++++--- .../bookmarksimport/bookmarksimportdialog.ui | 20 ++++++- src/lib/network/qupzillaschemehandler.cpp | 8 +-- src/lib/other/databasewriter.cpp | 4 +- src/lib/other/databasewriter.h | 2 +- src/lib/plugins/pluginproxy.cpp | 9 +-- src/lib/preferences/pluginslist.cpp | 2 +- src/lib/webview/tabbar.cpp | 7 ++- src/lib/webview/webpage.cpp | 3 +- src/main/main.cpp | 2 +- 13 files changed, 73 insertions(+), 86 deletions(-) diff --git a/src/lib/app/commandlineoptions.cpp b/src/lib/app/commandlineoptions.cpp index 235911e6d..5c32063d7 100644 --- a/src/lib/app/commandlineoptions.cpp +++ b/src/lib/app/commandlineoptions.cpp @@ -37,18 +37,18 @@ void CommandLineOptions::showHelp() const char* help = " Usage: qupzilla [options] URL \n" "\n" " QupZilla options:\n" - " -h or --help print this message \n" - " -a or --authors print QupZilla authors \n" - " -v or --version print QupZilla version \n" + " -h or --help print this message \n" + " -a or --authors print QupZilla authors \n" + " -v or --version print QupZilla version \n" "\n" - " -p or --profile= start with specified profile \n" - " -np or --no-plugins start without plugins \n" + " -p=PROFILE or --profile=PROFILE start with specified profile \n" + " -ne or --no-extensions start without extensions\n" "\n" " Options to control running QupZilla:\n" - " -nt or --new-tab open new tab\n" - " -nw or --new-window open new window\n" - " -pb or --private-browsing start private browsing\n" - " -dm or --download-manager show download manager\n" + " -nt or --new-tab open new tab\n" + " -nw or --new-window open new window\n" + " -pb or --private-browsing start private browsing\n" + " -dm or --download-manager show download manager\n" "\n" " QupZilla is a new, fast and secure web browser\n" " based on WebKit core (http://webkit.org) and\n" @@ -106,7 +106,7 @@ void CommandLineOptions::parseActions() m_actions.append(pair); } - if (arg.startsWith("-np") || arg.startsWith("--no-plugins")) { + if (arg.startsWith("-ne") || arg.startsWith("--no-extensions")) { ActionPair pair; pair.action = Qz::CL_StartWithoutAddons; pair.text = ""; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 01233be79..bf0d17542 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -57,7 +57,6 @@ #include #include #include -#include #ifdef Q_WS_WIN #define DEFAULT_CHECK_UPDATES true @@ -90,20 +89,19 @@ MainApplication::MainApplication(const QList &cm , m_networkmanager(0) , m_cookiejar(0) , m_rssmanager(0) - , m_updater(0) , m_plugins(0) , m_bookmarksModel(0) , m_downloadManager(0) , m_autofill(0) - , m_networkCache(new QNetworkDiskCache) + , m_networkCache(new QNetworkDiskCache(this)) , m_desktopNotifications(0) , m_iconProvider(new IconProvider(this)) , m_searchEnginesManager(0) - , m_dbWriter(new DatabaseWriter()) + , m_dbWriter(new DatabaseWriter(this)) , m_isClosing(false) , m_isStateChanged(false) - , m_isExited(false) , m_isRestoring(false) + , m_startingAfterCrash(false) , m_databaseConnected(false) { #if defined(Q_WS_X11) && !defined(NO_SYSTEM_DATAPATH) @@ -174,7 +172,7 @@ MainApplication::MainApplication(const QList &cm foreach(const QString & message, messages) { sendMessage(message); } - m_isExited = true; + m_isClosing = true; return; } @@ -211,13 +209,10 @@ MainApplication::MainApplication(const QList &cm Settings::createSettings(m_activeProfil + "settings.ini"); - Settings settings2; - settings2.beginGroup("SessionRestore"); - if (settings2.value("isRunning", false).toBool()) { - settings2.setValue("isCrashed", true); - } - settings2.setValue("isRunning", true); - settings2.endGroup(); + Settings settings; + m_startingAfterCrash = settings.value("SessionRestore/isRunning", false).toBool(); + bool checkUpdates = settings.value("Web-Browser-Settings/CheckUpdates", DEFAULT_CHECK_UPDATES).toBool(); + settings.setValue("SessionRestore/isRunning", true); translateApp(); @@ -228,10 +223,6 @@ MainApplication::MainApplication(const QList &cm connect(qupzilla, SIGNAL(message(Qz::AppMessageType, bool)), this, SLOT(sendMessages(Qz::AppMessageType, bool))); connect(qupzilla, SIGNAL(startingCompleted()), this, SLOT(restoreCursor())); - if (settings2.value("Web-Browser-Settings/CheckUpdates", DEFAULT_CHECK_UPDATES).toBool()) { - m_updater = new Updater(qupzilla); - } - loadSettings(); networkManager()->loadCertificates(); @@ -239,6 +230,10 @@ MainApplication::MainApplication(const QList &cm plugins()->loadPlugins(); } + if (checkUpdates) { + new Updater(qupzilla); + } + QTimer::singleShot(0, this, SLOT(postLaunch())); #ifdef Q_WS_WIN QTimer::singleShot(10 * 1000, this, SLOT(setupJumpList())); @@ -602,7 +597,6 @@ void MainApplication::saveSettings() Settings settings; settings.beginGroup("SessionRestore"); settings.setValue("isRunning", false); - settings.setValue("isCrashed", false); settings.endGroup(); settings.beginGroup("Web-Browser-Settings"); @@ -767,10 +761,6 @@ bool MainApplication::saveStateSlot() return false; } - Settings settings; - settings.beginGroup("SessionRestore"); - settings.setValue("restoreSession", false); - QFile file(m_activeProfil + "session.dat"); file.open(QIODevice::WriteOnly); QDataStream stream(&file); @@ -793,9 +783,6 @@ bool MainApplication::saveStateSlot() } file.close(); - settings.setValue("restoreSession", true); - settings.endGroup(); - QupZilla* qupzilla_ = getWindow(); if (qupzilla_ && m_mainWindows.count() == 1) { qupzilla_->tabWidget()->savePinnedTabs(); @@ -814,28 +801,12 @@ bool MainApplication::restoreStateSlot(QupZilla* window) } m_isRestoring = true; - Settings settings; - int afterStart = settings.value("Web-URL-Settings/afterLaunch", 1).toInt(); - settings.beginGroup("SessionRestore"); - if (!settings.value("restoreSession", false).toBool()) { - m_isRestoring = false; - return false; - } - if (settings.value("isCrashed", false).toBool() && afterStart != 3) { - QMessageBox::StandardButton button = QMessageBox::warning(window, tr("Last session crashed"), - tr("QupZilla crashed :-(
Oops, the last session of QupZilla was interrupted unexpectedly. We apologize for this. Would you like to try restoring the last saved state?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if (button != QMessageBox::Yes) { - m_isRestoring = false; - return false; - } - } + if (!QFile::exists(m_activeProfil + "session.dat")) { m_isRestoring = false; return false; } - settings.setValue("isCrashed", false); QFile file(m_activeProfil + "session.dat"); file.open(QIODevice::ReadOnly); QDataStream stream(&file); diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index 454a8de14..23e460489 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -72,7 +72,7 @@ public: inline QString getActiveProfilPath() { return m_activeProfil; } inline QString getActiveLanguage() { return m_activeLanguage; } inline bool isClosing() { return m_isClosing; } - inline bool isExited() { return m_isExited; } + inline bool isStartingAfterCrash() { return m_startingAfterCrash; } inline int windowCount() { return m_mainWindows.count(); } bool checkSettingsDir(); @@ -132,7 +132,6 @@ private: NetworkManager* m_networkmanager; CookieJar* m_cookiejar; RSSManager* m_rssmanager; - Updater* m_updater; PluginProxy* m_plugins; BookmarksModel* m_bookmarksModel; DownloadManager* m_downloadManager; @@ -151,8 +150,8 @@ private: bool m_isClosing; bool m_isStateChanged; - bool m_isExited; bool m_isRestoring; + bool m_startingAfterCrash; bool m_databaseConnected; QList m_postLaunchActions; diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 4e8789c86..00d8eaac6 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -129,15 +129,10 @@ void QupZilla::postLaunch() } Settings settings; - settings.beginGroup("Web-URL-Settings"); - int afterLaunch = settings.value("afterLaunch", 1).toInt(); - settings.endGroup(); - settings.beginGroup("SessionRestore"); - bool startingAfterCrash = settings.value("isCrashed", false).toBool(); - settings.endGroup(); - + int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt(); bool addTab = true; QUrl startUrl; + switch (afterLaunch) { case 0: startUrl = QUrl(""); @@ -158,9 +153,20 @@ void QupZilla::postLaunch() switch (m_startBehaviour) { case Qz::BW_FirstAppWindow: - if (startingAfterCrash || (addTab && afterLaunch == 3)) { + if (afterLaunch == 3) { addTab = !mApp->restoreStateSlot(this); } + else if (mApp->isStartingAfterCrash()) { + QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Last session crashed"), + tr("QupZilla crashed :-(
Oops, the last session " + "of QupZilla was interrupted unexpectedly. We apologize " + "for this. Would you like to try restoring the last " + "saved state?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if (button == QMessageBox::Yes) { + addTab = !mApp->restoreStateSlot(this); + } + } break; case Qz::BW_NewWindow: diff --git a/src/lib/bookmarksimport/bookmarksimportdialog.ui b/src/lib/bookmarksimport/bookmarksimportdialog.ui index 7e723e186..d758bd70c 100644 --- a/src/lib/bookmarksimport/bookmarksimportdialog.ui +++ b/src/lib/bookmarksimport/bookmarksimportdialog.ui @@ -6,10 +6,16 @@ 0 0 - 505 - 327 + 550 + 350 + + + 550 + 350 + + Import Bookmarks @@ -81,6 +87,16 @@ + + + + <b>Note:</b> Currently, only import from Html File can import also bookmark folders. + + + true + + + diff --git a/src/lib/network/qupzillaschemehandler.cpp b/src/lib/network/qupzillaschemehandler.cpp index 471cd13c6..c76e40af6 100644 --- a/src/lib/network/qupzillaschemehandler.cpp +++ b/src/lib/network/qupzillaschemehandler.cpp @@ -139,7 +139,7 @@ QString QupZillaSchemeReply::reportbugPage() bPage.replace("%TITLE%", tr("Report Issue")); bPage.replace("%REPORT-ISSUE%", tr("Report Issue")); bPage.replace("%PLUGINS-TEXT%", tr("If you are experiencing problems with QupZilla, please try to disable" - " all plugins first.
If this does not fix it, then please fill out this form: ")); + " all extenions first.
If this does not fix it, then please fill out this form: ")); bPage.replace("%EMAIL%", tr("Your E-mail")); bPage.replace("%TYPE%", tr("Issue type")); bPage.replace("%DESCRIPTION%", tr("Issue description")); @@ -301,14 +301,14 @@ QString QupZillaSchemeReply::configPage() cPage.replace("%TITLE%", tr("Configuration Information")); cPage.replace("%CONFIG%", tr("Configuration Information")); cPage.replace("%INFORMATIONS-ABOUT-VERSION%", tr("Information about version")); - cPage.replace("%CONFIG-ABOUT%", tr("This page contains information about QupZilla's current configuration, plugins, etc, all relevant information for troubleshooting. Please include these information when sending bug reports.")); + cPage.replace("%CONFIG-ABOUT%", tr("This page contains information about QupZilla's current configuration, all relevant information for troubleshooting. Please include these information when sending bug reports.")); cPage.replace("%BROWSER-IDENTIFICATION%", tr("Browser Identification")); cPage.replace("%PATHS%", tr("Paths")); cPage.replace("%BUILD-CONFIG%", tr("Build Configuration")); cPage.replace("%PREFS%", tr("Preferences")); cPage.replace("%OPTION%", tr("Option")); cPage.replace("%VALUE%", tr("Value")); - cPage.replace("%PLUGINS%", tr("Plugins")); + cPage.replace("%PLUGINS%", tr("Extensions")); cPage.replace("%PL-NAME%", tr("Name")); cPage.replace("%PL-VER%", tr("Version")); cPage.replace("%PL-AUTH%", tr("Author")); @@ -377,7 +377,7 @@ QString QupZillaSchemeReply::configPage() } if (pluginsString.isEmpty()) { - pluginsString = QString("%1").arg(tr("No available plugins.")); + pluginsString = QString("%1").arg(tr("No available extensions.")); } page.replace("%PLUGINS-INFO%", pluginsString); diff --git a/src/lib/other/databasewriter.cpp b/src/lib/other/databasewriter.cpp index 64ca23aaa..7bfe4f349 100644 --- a/src/lib/other/databasewriter.cpp +++ b/src/lib/other/databasewriter.cpp @@ -19,8 +19,8 @@ #include -DatabaseWriter::DatabaseWriter() - : QObject() +DatabaseWriter::DatabaseWriter(QObject *parent) + : QObject(parent) { } diff --git a/src/lib/other/databasewriter.h b/src/lib/other/databasewriter.h index 7280c3e62..15cd87453 100644 --- a/src/lib/other/databasewriter.h +++ b/src/lib/other/databasewriter.h @@ -28,7 +28,7 @@ class QT_QUPZILLA_EXPORT DatabaseWriter : public QObject { Q_OBJECT public: - explicit DatabaseWriter(); + explicit DatabaseWriter(QObject* parent = 0); void executeQuery(const QSqlQuery &query); diff --git a/src/lib/plugins/pluginproxy.cpp b/src/lib/plugins/pluginproxy.cpp index 1379aa82c..6e910bed6 100644 --- a/src/lib/plugins/pluginproxy.cpp +++ b/src/lib/plugins/pluginproxy.cpp @@ -92,20 +92,13 @@ void PluginProxy::registerAppEventHandler(const PluginProxy::EventHandlerType &t void PluginProxy::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r) { - if (!menu || !view || m_loadedPlugins.count() == 0) { + if (!menu || !view) { return; } - menu->addSeparator(); - int count = menu->actions().count(); - foreach(PluginInterface * iPlugin, m_loadedPlugins) { iPlugin->populateWebViewMenu(menu, view, r); } - - if (menu->actions().count() == count) { - menu->removeAction(menu->actions().at(count - 1)); - } } bool PluginProxy::processMouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) diff --git a/src/lib/preferences/pluginslist.cpp b/src/lib/preferences/pluginslist.cpp index ccc2b4168..d537a077c 100644 --- a/src/lib/preferences/pluginslist.cpp +++ b/src/lib/preferences/pluginslist.cpp @@ -217,7 +217,7 @@ void PluginsList::itemChanged(QListWidgetItem* item) if (item->checkState() == Qt::Checked && !plugin.isLoaded()) { item->setCheckState(Qt::Unchecked); - QMessageBox::critical(this, tr("Error!"), tr("Cannot load extensions")); + QMessageBox::critical(this, tr("Error!"), tr("Cannot load extension!")); } item->setData(Qt::UserRole + 10, qVariantFromValue(plugin)); diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index a2ae4ffce..34ba8d0f1 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -310,8 +310,11 @@ void TabBar::pinTab() m_pinnedTabsCount--; } - // Adjust add tab button in proper position - tabSizeHint(count() - 1); + // We need to recalculate size of all tabs and repaint tabbar + // Unfortunately, Qt doesn't offer refresh() function as a public API + + // So we are calling the lightest function that calls d->refresh() + setElideMode(elideMode()); } void TabBar::pinnedTabClosed() diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index bba54092e..f311c5286 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -37,7 +37,6 @@ #include "networkmanagerproxy.h" #include "adblockicon.h" -#include #include #include #include @@ -651,7 +650,7 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg) ui->setupUi(dialog); ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok); ui->dontAskAgain->setText(tr("Prevent this page from creating additional dialogs")); - ui->textLabel->setText(Qt::escape(msg)); + ui->textLabel->setText(msg); ui->iconLabel->setPixmap(mApp->style()->standardPixmap(QStyle::SP_MessageBoxInformation)); ui->buttonBox->setFocus(); dialog->setWindowTitle(tr("JavaScript alert - %1").arg(url().host())); diff --git a/src/main/main.cpp b/src/main/main.cpp index fe0652b96..f241d0613 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) MainApplication app(cmdActions, argc, argv); - if (app.isExited()) { + if (app.isClosing()) { // Not showing any output, otherwise XFCE shows "Failed to execute default browser. I/O error" error // if (argc == 1) { // std::cout << "QupZilla already running - activating existing window" << std::endl;