2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "qupzilla.h"
|
|
|
|
#include "tabwidget.h"
|
|
|
|
#include "tabbar.h"
|
|
|
|
#include "webpage.h"
|
2012-01-21 20:27:45 +01:00
|
|
|
#include "tabbedwebview.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "lineedit.h"
|
|
|
|
#include "historymodel.h"
|
|
|
|
#include "locationbar.h"
|
|
|
|
#include "searchtoolbar.h"
|
|
|
|
#include "websearchbar.h"
|
|
|
|
#include "downloadmanager.h"
|
|
|
|
#include "cookiejar.h"
|
|
|
|
#include "cookiemanager.h"
|
|
|
|
#include "bookmarksmanager.h"
|
|
|
|
#include "bookmarkstoolbar.h"
|
|
|
|
#include "clearprivatedata.h"
|
|
|
|
#include "sourceviewer.h"
|
|
|
|
#include "siteinfo.h"
|
|
|
|
#include "preferences.h"
|
|
|
|
#include "networkmanager.h"
|
|
|
|
#include "autofillmodel.h"
|
|
|
|
#include "networkmanagerproxy.h"
|
|
|
|
#include "rssmanager.h"
|
|
|
|
#include "mainapplication.h"
|
|
|
|
#include "aboutdialog.h"
|
|
|
|
#include "pluginproxy.h"
|
|
|
|
#include "qtwin.h"
|
2011-03-26 15:59:11 +01:00
|
|
|
#include "ui_closedialog.h"
|
2011-03-27 21:59:40 +02:00
|
|
|
#include "adblockmanager.h"
|
|
|
|
#include "clickablelabel.h"
|
2011-04-15 20:45:22 +02:00
|
|
|
#include "docktitlebarwidget.h"
|
|
|
|
#include "sidebar.h"
|
2011-04-25 20:56:45 +02:00
|
|
|
#include "iconprovider.h"
|
2011-04-25 15:06:59 +02:00
|
|
|
#include "progressbar.h"
|
2011-05-07 12:59:53 +02:00
|
|
|
#include "adblockicon.h"
|
|
|
|
#include "closedtabsmanager.h"
|
2011-05-09 17:58:19 +02:00
|
|
|
#include "statusbarmessage.h"
|
2011-07-11 21:08:41 +02:00
|
|
|
#include "locationbarsettings.h"
|
2011-07-29 15:39:43 +02:00
|
|
|
#include "browsinglibrary.h"
|
2011-09-11 19:15:06 +02:00
|
|
|
#include "navigationbar.h"
|
2011-09-21 14:20:49 +02:00
|
|
|
#include "pagescreen.h"
|
2011-10-14 20:14:57 +02:00
|
|
|
#include "webinspectordockwidget.h"
|
2011-10-22 22:29:33 +02:00
|
|
|
#include "bookmarksimportdialog.h"
|
2011-10-26 19:23:50 +02:00
|
|
|
#include "globalfunctions.h"
|
2011-11-06 12:05:16 +01:00
|
|
|
#include "webhistorywrapper.h"
|
2011-12-14 22:30:05 +01:00
|
|
|
#include "enhancedmenu.h"
|
2012-01-11 21:58:25 +01:00
|
|
|
#include "settings.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "webtab.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-07 12:43:18 +01:00
|
|
|
const QString QupZilla::VERSION = "1.1.5";
|
2011-04-04 19:29:03 +02:00
|
|
|
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
|
2011-10-17 09:59:09 +02:00
|
|
|
const QString QupZilla::AUTHOR = "David Rosca";
|
2012-01-01 15:29:55 +01:00
|
|
|
const QString QupZilla::COPYRIGHT = "2010-2012";
|
2012-01-06 15:03:48 +01:00
|
|
|
const QString QupZilla::WWWADDRESS = "http://www.qupzilla.com";
|
2011-10-02 17:39:59 +02:00
|
|
|
const QString QupZilla::WIKIADDRESS = "https://github.com/nowrep/QupZilla/wiki";
|
2011-03-26 15:59:11 +01:00
|
|
|
const QString QupZilla::WEBKITVERSION = qWebKitVersion();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-07 15:37:49 +02:00
|
|
|
const QIcon QupZilla::qupzillaIcon()
|
2011-09-17 11:39:25 +02:00
|
|
|
{
|
|
|
|
QIcon i;
|
|
|
|
i.addFile(":icons/exeicons/qupzilla16.png");
|
|
|
|
i.addFile(":icons/exeicons/qupzilla32.png");
|
|
|
|
i.addFile(":icons/exeicons/qupzilla48.png");
|
|
|
|
i.addFile(":icons/exeicons/qupzilla64.png");
|
|
|
|
i.addFile(":icons/exeicons/qupzilla128.png");
|
|
|
|
i.addFile(":icons/exeicons/qupzilla256.png");
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl)
|
2011-10-15 16:37:32 +02:00
|
|
|
: QMainWindow(0)
|
|
|
|
, m_historyMenuChanged(true)
|
|
|
|
, m_bookmarksMenuChanged(true)
|
2011-10-31 21:27:52 +01:00
|
|
|
, m_isClosing(false)
|
2011-10-15 16:37:32 +02:00
|
|
|
, m_startingUrl(startUrl)
|
2012-01-21 23:19:38 +01:00
|
|
|
, m_startBehaviour(type)
|
2011-12-08 18:11:05 +01:00
|
|
|
, m_menuBookmarksAction(0)
|
2012-01-11 21:58:25 +01:00
|
|
|
#ifdef Q_WS_MAC
|
2012-01-09 22:14:02 +01:00
|
|
|
, m_macMenuBar(new QMenuBar())
|
2012-01-11 21:58:25 +01:00
|
|
|
#endif
|
2011-10-15 16:37:32 +02:00
|
|
|
, m_actionPrivateBrowsing(0)
|
|
|
|
, m_statusBarMessage(new StatusBarMessage(this))
|
2011-12-26 21:23:21 +01:00
|
|
|
, m_usingTransparentBackground(false)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-09-11 19:15:06 +02:00
|
|
|
setObjectName("mainwindow");
|
2011-03-05 10:57:36 +01:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
2012-01-16 18:28:56 +01:00
|
|
|
setWindowTitle(tr("QupZilla"));
|
2011-03-02 16:57:41 +01:00
|
|
|
setUpdatesEnabled(false);
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
m_activeProfil = mApp->getActiveProfilPath();
|
2011-03-04 13:59:07 +01:00
|
|
|
m_activeLanguage = mApp->getActiveLanguage();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
setupUi();
|
|
|
|
setupMenu();
|
2012-01-08 11:38:15 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QTimer::singleShot(0, this, SLOT(postLaunch()));
|
2012-01-21 23:19:38 +01:00
|
|
|
connect(mApp, SIGNAL(message(Qz::AppMessageType, bool)), this, SLOT(receiveMessage(Qz::AppMessageType, bool)));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
void QupZilla::postLaunch()
|
|
|
|
{
|
|
|
|
loadSettings();
|
2012-01-18 18:36:10 +01:00
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
if (m_startBehaviour == Qz::BW_FirstAppWindow) {
|
2012-01-18 18:36:10 +01:00
|
|
|
m_tabWidget->restorePinnedTabs();
|
|
|
|
}
|
2011-05-07 12:59:53 +02:00
|
|
|
|
|
|
|
//Open tab from command line argument
|
|
|
|
bool addTab = true;
|
|
|
|
QStringList arguments = qApp->arguments();
|
2011-11-06 17:01:23 +01:00
|
|
|
for (int i = 0; i < qApp->arguments().count(); i++) {
|
2011-05-07 12:59:53 +02:00
|
|
|
QString arg = arguments.at(i);
|
|
|
|
if (arg.startsWith("-url=")) {
|
2011-11-06 17:01:23 +01:00
|
|
|
m_tabWidget->addView(QUrl(arg.replace("-url=", "")));
|
2011-05-07 12:59:53 +02:00
|
|
|
addTab = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-05-07 12:59:53 +02:00
|
|
|
settings.beginGroup("Web-URL-Settings");
|
2011-11-06 17:01:23 +01:00
|
|
|
int afterLaunch = settings.value("afterLaunch", 1).toInt();
|
2011-05-07 12:59:53 +02:00
|
|
|
settings.endGroup();
|
|
|
|
settings.beginGroup("SessionRestore");
|
2011-11-06 17:01:23 +01:00
|
|
|
bool startingAfterCrash = settings.value("isCrashed", false).toBool();
|
2011-05-07 12:59:53 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
QUrl startUrl;
|
2011-12-04 20:35:49 +01:00
|
|
|
switch (afterLaunch) {
|
|
|
|
case 0:
|
|
|
|
startUrl = QUrl("");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
startUrl = QUrl("qupzilla:speeddial");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
startUrl = m_homepage;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-11-03 18:51:46 +01:00
|
|
|
switch (m_startBehaviour) {
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::BW_FirstAppWindow:
|
2011-12-04 20:35:49 +01:00
|
|
|
if (startingAfterCrash || (addTab && afterLaunch == 3)) {
|
2011-05-07 12:59:53 +02:00
|
|
|
addTab = !mApp->restoreStateSlot(this);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-11-03 18:51:46 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::BW_NewWindow:
|
2011-11-03 18:51:46 +01:00
|
|
|
addTab = true;
|
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::BW_OtherRestoredWindow:
|
2011-11-03 18:51:46 +01:00
|
|
|
addTab = false;
|
|
|
|
break;
|
|
|
|
}
|
2011-05-07 12:59:53 +02:00
|
|
|
|
|
|
|
if (!m_startingUrl.isEmpty()) {
|
2012-01-21 20:27:45 +01:00
|
|
|
startUrl = QUrl::fromUserInput(m_startingUrl.toString());
|
2011-05-07 12:59:53 +02:00
|
|
|
addTab = true;
|
|
|
|
}
|
|
|
|
|
2011-12-05 19:54:17 +01:00
|
|
|
if (addTab) {
|
2012-01-21 23:19:38 +01:00
|
|
|
int index = m_tabWidget->addView(startUrl, Qz::NT_CleanSelectedTab);
|
2011-12-05 19:54:17 +01:00
|
|
|
m_tabWidget->setCurrentIndex(index);
|
|
|
|
|
|
|
|
if (startUrl.isEmpty() || startUrl.toString() == "qupzilla:speeddial") {
|
|
|
|
locationBar()->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
if (m_tabWidget->getTabBar()->normalTabsCount() <= 0 &&
|
|
|
|
m_startBehaviour != Qz::BW_OtherRestoredWindow) {
|
|
|
|
//Something went really wrong .. add one tab
|
2011-05-07 12:59:53 +02:00
|
|
|
m_tabWidget->addView(m_homepage);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2012-01-08 11:12:04 +01:00
|
|
|
aboutToShowHistoryMenu(false);
|
|
|
|
aboutToHideHistoryMenu();
|
|
|
|
aboutToShowBookmarksMenu();
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
setUpdatesEnabled(true);
|
2011-12-05 19:54:17 +01:00
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
emit startingCompleted();
|
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
void QupZilla::goNext()
|
|
|
|
{
|
|
|
|
weView()->forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::goBack()
|
|
|
|
{
|
|
|
|
weView()->back();
|
|
|
|
}
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
void QupZilla::setupUi()
|
|
|
|
{
|
2011-10-17 09:59:09 +02:00
|
|
|
int locationBarWidth;
|
|
|
|
int websearchBarWidth;
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-09-21 12:43:27 +02:00
|
|
|
settings.beginGroup("Browser-View-Settings");
|
|
|
|
if (settings.value("WindowMaximised", false).toBool()) {
|
|
|
|
resize(800, 550);
|
2011-10-01 20:06:38 +02:00
|
|
|
setWindowState(Qt::WindowMaximized);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-03 19:39:32 +02:00
|
|
|
setGeometry(settings.value("WindowGeometry", QRect(20, 20, 800, 550)).toRect());
|
2012-01-21 23:19:38 +01:00
|
|
|
if (m_startBehaviour == Qz::BW_NewWindow) {
|
2011-11-09 16:58:25 +01:00
|
|
|
// Moving window +40 x,y to be visible that this is new window
|
|
|
|
QPoint p = pos();
|
|
|
|
p.setX(p.x() + 40);
|
|
|
|
p.setY(p.y() + 40);
|
|
|
|
|
|
|
|
move(p);
|
|
|
|
}
|
2011-09-21 12:43:27 +02:00
|
|
|
}
|
|
|
|
|
2011-12-03 11:27:53 +01:00
|
|
|
locationBarWidth = settings.value("LocationBarWidth", 480).toInt();
|
|
|
|
websearchBarWidth = settings.value("WebSearchBarWidth", 140).toInt();
|
2011-10-17 09:59:09 +02:00
|
|
|
|
2011-08-02 16:19:20 +02:00
|
|
|
QWidget* widget = new QWidget(this);
|
2011-12-03 12:07:10 +01:00
|
|
|
widget->setCursor(Qt::ArrowCursor);
|
2011-09-11 19:15:06 +02:00
|
|
|
setCentralWidget(widget);
|
|
|
|
|
2011-08-02 16:19:20 +02:00
|
|
|
m_mainLayout = new QVBoxLayout(widget);
|
2011-11-06 17:01:23 +01:00
|
|
|
m_mainLayout->setContentsMargins(0, 0, 0, 0);
|
2011-08-02 16:19:20 +02:00
|
|
|
m_mainLayout->setSpacing(0);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_mainSplitter = new QSplitter(this);
|
2011-10-28 23:17:38 +02:00
|
|
|
m_mainSplitter->setObjectName("sidebar-splitter");
|
2011-09-11 19:15:06 +02:00
|
|
|
m_mainSplitter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
2011-07-11 20:30:49 +02:00
|
|
|
m_tabWidget = new TabWidget(this);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_superMenu = new QMenu(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar = new NavigationBar(this);
|
2011-10-17 09:59:09 +02:00
|
|
|
m_navigationBar->setSplitterSizes(locationBarWidth, websearchBarWidth);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_bookmarksToolbar = new BookmarksToolbar(this);
|
|
|
|
m_mainSplitter->addWidget(m_tabWidget);
|
|
|
|
m_mainLayout->addWidget(m_navigationBar);
|
|
|
|
m_mainLayout->addWidget(m_bookmarksToolbar);
|
|
|
|
m_mainLayout->addWidget(m_mainSplitter);
|
|
|
|
m_mainSplitter->setCollapsible(0, false);
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
statusBar()->setObjectName("mainwindow-statusbar");
|
2011-12-03 12:07:10 +01:00
|
|
|
statusBar()->setCursor(Qt::ArrowCursor);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_progressBar = new ProgressBar(statusBar());
|
|
|
|
m_privateBrowsing = new QLabel(this);
|
|
|
|
m_privateBrowsing->setPixmap(QPixmap(":/icons/locationbar/privatebrowsing.png"));
|
|
|
|
m_privateBrowsing->setVisible(false);
|
|
|
|
m_privateBrowsing->setToolTip(tr("Private Browsing Enabled"));
|
|
|
|
m_adblockIcon = new AdBlockIcon(this);
|
|
|
|
m_ipLabel = new QLabel(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_ipLabel->setObjectName("statusbar-ip-label");
|
2011-05-07 12:59:53 +02:00
|
|
|
m_ipLabel->setToolTip(tr("IP Address of current page"));
|
|
|
|
|
|
|
|
statusBar()->insertPermanentWidget(0, m_progressBar);
|
|
|
|
statusBar()->insertPermanentWidget(1, m_ipLabel);
|
|
|
|
statusBar()->insertPermanentWidget(2, m_privateBrowsing);
|
|
|
|
statusBar()->insertPermanentWidget(3, m_adblockIcon);
|
|
|
|
}
|
|
|
|
|
2012-01-09 22:14:02 +01:00
|
|
|
QMenuBar* QupZilla::menuBar() const
|
|
|
|
{
|
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
return m_macMenuBar;
|
|
|
|
#else
|
|
|
|
return QMainWindow::menuBar();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
TabbedWebView* QupZilla::weView() const
|
|
|
|
{
|
|
|
|
return weView(m_tabWidget->currentIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
TabbedWebView* QupZilla::weView(int index) const
|
|
|
|
{
|
|
|
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
|
|
|
|
if (!webTab) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return webTab->view();
|
|
|
|
}
|
|
|
|
|
|
|
|
LocationBar* QupZilla::locationBar() const
|
|
|
|
{
|
|
|
|
return qobject_cast<LocationBar*>(m_tabWidget->locationBars()->currentWidget());
|
|
|
|
}
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
void QupZilla::setupMenu()
|
|
|
|
{
|
2012-01-08 11:38:15 +01:00
|
|
|
// Standard actions - needed on Mac to be placed correctly in "application" menu
|
2012-01-09 22:14:02 +01:00
|
|
|
m_actionAbout = new QAction(QIcon(":/icons/qupzilla.png"), tr("&About QupZilla"), 0);
|
2012-01-08 11:38:15 +01:00
|
|
|
m_actionAbout->setMenuRole(QAction::AboutRole);
|
2012-01-08 12:38:02 +01:00
|
|
|
connect(m_actionAbout, SIGNAL(triggered()), this, SLOT(aboutQupZilla()));
|
2012-01-08 11:38:15 +01:00
|
|
|
|
2012-01-09 22:14:02 +01:00
|
|
|
m_actionPreferences = new QAction(QIcon(":/icons/faenza/settings.png"), tr("Pr&eferences"), 0);
|
2012-01-08 11:38:15 +01:00
|
|
|
m_actionPreferences->setMenuRole(QAction::PreferencesRole);
|
|
|
|
m_actionPreferences->setShortcut(QKeySequence("Ctrl+P"));
|
2012-01-08 12:38:02 +01:00
|
|
|
connect(m_actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
|
2012-01-08 11:38:15 +01:00
|
|
|
|
2012-01-09 22:14:02 +01:00
|
|
|
m_actionQuit = new QAction(QIcon::fromTheme("application-exit"), tr("Quit"), 0);
|
2012-01-08 11:38:15 +01:00
|
|
|
m_actionQuit->setMenuRole(QAction::QuitRole);
|
|
|
|
m_actionQuit->setShortcut(QKeySequence("Ctrl+Q"));
|
2012-01-08 12:38:02 +01:00
|
|
|
connect(m_actionQuit, SIGNAL(triggered()), this, SLOT(quitApp()));
|
2012-01-08 11:38:15 +01:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
menuBar()->setObjectName("mainwindow-menubar");
|
2011-12-03 12:07:10 +01:00
|
|
|
menuBar()->setCursor(Qt::ArrowCursor);
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuTools = new QMenu(tr("&Tools"));
|
|
|
|
m_menuHelp = new QMenu(tr("&Help"));
|
2011-12-13 19:18:05 +01:00
|
|
|
m_menuBookmarks = new Menu(tr("&Bookmarks"));
|
|
|
|
m_menuHistory = new Menu(tr("Hi&story"));
|
2011-05-07 12:59:53 +02:00
|
|
|
connect(m_menuHistory, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMenu()));
|
2011-11-06 12:05:16 +01:00
|
|
|
connect(m_menuHistory, SIGNAL(aboutToHide()), this, SLOT(aboutToHideHistoryMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
connect(m_menuBookmarks, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBookmarksMenu()));
|
2011-12-20 18:58:42 +01:00
|
|
|
connect(m_menuBookmarks, SIGNAL(menuMiddleClicked(Menu*)), this, SLOT(loadFolderBookmarks(Menu*)));
|
2011-05-07 12:59:53 +02:00
|
|
|
connect(m_menuHelp, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHelpMenu()));
|
|
|
|
connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
|
|
|
|
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuFile = new QMenu(tr("&File"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("window-new"), tr("&New Window"), this, SLOT(newWindow()))->setShortcut(QKeySequence("Ctrl+N"));
|
|
|
|
m_menuFile->addAction(QIcon(":/icons/menu/popup.png"), tr("New Tab"), this, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T"));
|
|
|
|
m_menuFile->addAction(tr("Open Location"), this, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L"));
|
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File"), this, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O"));
|
|
|
|
m_menuFile->addAction(tr("Close Tab"), m_tabWidget, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
|
2011-12-17 15:09:17 +01:00
|
|
|
m_actionCloseWindow = m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), this, SLOT(close()));
|
|
|
|
m_actionCloseWindow->setShortcut(QKeySequence("Ctrl+Shift+W"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuFile->addSeparator();
|
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), this, SLOT(savePage()))->setShortcut(QKeySequence("Ctrl+S"));
|
2011-09-21 14:20:49 +02:00
|
|
|
m_menuFile->addAction(tr("Save Page Screen"), this, SLOT(savePageScreen()));
|
2012-01-22 02:34:05 +01:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), this, SLOT(sendLink()));
|
2011-11-06 17:01:23 +01:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print"), this, SLOT(printPage()));
|
|
|
|
m_menuFile->addSeparator();
|
2011-10-22 22:29:33 +02:00
|
|
|
m_menuFile->addSeparator();
|
|
|
|
m_menuFile->addAction(tr("Import bookmarks..."), this, SLOT(showBookmarkImport()));
|
2012-01-08 11:38:15 +01:00
|
|
|
m_menuFile->addAction(m_actionQuit);
|
|
|
|
#ifdef Q_WS_MAC // Add standard actions to File Menu (as it won't be ever cleared) and Mac menubar should move them to "application" menu
|
|
|
|
m_menuFile->addAction(m_actionAbout);
|
|
|
|
m_menuFile->addAction(m_actionPreferences);
|
|
|
|
#endif
|
2011-05-07 12:59:53 +02:00
|
|
|
menuBar()->addMenu(m_menuFile);
|
2011-12-17 15:09:17 +01:00
|
|
|
connect(m_menuFile, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFileMenu()));
|
|
|
|
connect(m_menuFile, SIGNAL(aboutToHide()), this, SLOT(aboutToHideFileMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuEdit = new QMenu(tr("&Edit"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"))->setShortcut(QKeySequence("Ctrl+Z"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"))->setShortcut(QKeySequence("Ctrl+Shift+Z"));
|
|
|
|
m_menuEdit->addSeparator();
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"))->setShortcut(QKeySequence("Ctrl+X"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), this, SLOT(copy()))->setShortcut(QKeySequence("Ctrl+C"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"))->setShortcut(QKeySequence("Ctrl+V"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-delete"), tr("&Delete"))->setShortcut(QKeySequence("Del"));
|
|
|
|
m_menuEdit->addSeparator();
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &All"), this, SLOT(selectAll()))->setShortcut(QKeySequence("Ctrl+A"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("&Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
|
2011-12-10 13:15:07 +01:00
|
|
|
m_menuEdit->addSeparator();
|
2012-01-06 15:03:48 +01:00
|
|
|
#ifdef Q_WS_X11
|
2012-01-08 11:38:15 +01:00
|
|
|
m_menuEdit->addAction(m_actionPreferences);
|
2011-12-10 13:15:07 +01:00
|
|
|
#endif
|
2011-05-07 12:59:53 +02:00
|
|
|
menuBar()->addMenu(m_menuEdit);
|
2011-12-17 15:09:17 +01:00
|
|
|
connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu()));
|
|
|
|
connect(m_menuEdit, SIGNAL(aboutToHide()), this, SLOT(aboutToHideEditMenu()));
|
|
|
|
aboutToHideEditMenu();
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuView = new QMenu(tr("&View"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowToolbar = new QAction(tr("&Navigation Toolbar"), this);
|
|
|
|
m_actionShowToolbar->setCheckable(true);
|
|
|
|
connect(m_actionShowToolbar, SIGNAL(triggered(bool)), this, SLOT(showNavigationToolbar()));
|
|
|
|
m_actionShowBookmarksToolbar = new QAction(tr("&Bookmarks Toolbar"), this);
|
|
|
|
m_actionShowBookmarksToolbar->setCheckable(true);
|
|
|
|
connect(m_actionShowBookmarksToolbar, SIGNAL(triggered(bool)), this, SLOT(showBookmarksToolbar()));
|
|
|
|
m_actionShowStatusbar = new QAction(tr("Sta&tus Bar"), this);
|
|
|
|
m_actionShowStatusbar->setCheckable(true);
|
|
|
|
connect(m_actionShowStatusbar, SIGNAL(triggered(bool)), this, SLOT(showStatusbar()));
|
|
|
|
m_actionShowMenubar = new QAction(tr("&Menu Bar"), this);
|
|
|
|
m_actionShowMenubar->setCheckable(true);
|
|
|
|
connect(m_actionShowMenubar, SIGNAL(triggered(bool)), this, SLOT(showMenubar()));
|
|
|
|
m_actionShowFullScreen = new QAction(tr("&Fullscreen"), this);
|
|
|
|
m_actionShowFullScreen->setCheckable(true);
|
|
|
|
m_actionShowFullScreen->setShortcut(QKeySequence("F11"));
|
|
|
|
connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool)));
|
2011-09-30 21:44:18 +02:00
|
|
|
m_actionStop = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), this);
|
2011-05-07 12:59:53 +02:00
|
|
|
connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop()));
|
|
|
|
m_actionStop->setShortcut(QKeySequence("Esc"));
|
2011-09-30 21:44:18 +02:00
|
|
|
m_actionReload = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this);
|
2011-05-07 12:59:53 +02:00
|
|
|
connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload()));
|
2011-09-11 19:15:06 +02:00
|
|
|
m_actionReload->setShortcut(QKeySequence("F5"));
|
2011-05-07 12:59:53 +02:00
|
|
|
QAction* actionEncoding = new QAction(tr("Character &Encoding"), this);
|
|
|
|
m_menuEncoding = new QMenu(this);
|
|
|
|
actionEncoding->setMenu(m_menuEncoding);
|
|
|
|
connect(m_menuEncoding, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu()));
|
|
|
|
|
|
|
|
m_actionShowBookmarksSideBar = new QAction(tr("Bookmarks"), this);
|
|
|
|
m_actionShowBookmarksSideBar->setCheckable(true);
|
|
|
|
m_actionShowBookmarksSideBar->setShortcut(QKeySequence("Ctrl+B"));
|
|
|
|
connect(m_actionShowBookmarksSideBar, SIGNAL(triggered()), this, SLOT(showBookmarksSideBar()));
|
|
|
|
m_actionShowHistorySideBar = new QAction(tr("History"), this);
|
|
|
|
m_actionShowHistorySideBar->setCheckable(true);
|
|
|
|
m_actionShowHistorySideBar->setShortcut(QKeySequence("Ctrl+H"));
|
|
|
|
connect(m_actionShowHistorySideBar, SIGNAL(triggered()), this, SLOT(showHistorySideBar()));
|
|
|
|
|
|
|
|
QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
|
|
|
|
toolbarsMenu->addAction(m_actionShowMenubar);
|
|
|
|
toolbarsMenu->addAction(m_actionShowToolbar);
|
|
|
|
toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
|
|
|
|
QMenu* sidebarsMenu = new QMenu(tr("Sidebars"));
|
|
|
|
sidebarsMenu->addAction(m_actionShowBookmarksSideBar);
|
|
|
|
sidebarsMenu->addAction(m_actionShowHistorySideBar);
|
|
|
|
|
|
|
|
m_menuView->addMenu(toolbarsMenu);
|
|
|
|
m_menuView->addMenu(sidebarsMenu);
|
2011-05-31 21:11:46 +02:00
|
|
|
m_menuView->addAction(m_actionShowStatusbar);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuView->addSeparator();
|
|
|
|
m_menuView->addAction(m_actionStop);
|
|
|
|
m_menuView->addAction(m_actionReload);
|
|
|
|
m_menuView->addSeparator();
|
|
|
|
m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), this, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++"));
|
|
|
|
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), this, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
|
|
|
|
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
|
|
|
|
m_menuView->addSeparator();
|
|
|
|
m_menuView->addAction(actionEncoding);
|
|
|
|
m_menuView->addSeparator();
|
|
|
|
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
|
|
|
|
m_menuView->addAction(m_actionShowFullScreen);
|
|
|
|
menuBar()->addMenu(m_menuView);
|
|
|
|
connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu()));
|
2011-11-06 12:05:16 +01:00
|
|
|
connect(m_menuView, SIGNAL(aboutToHide()), this, SLOT(aboutToHideViewMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
|
|
|
|
menuBar()->addMenu(m_menuHistory);
|
|
|
|
menuBar()->addMenu(m_menuBookmarks);
|
|
|
|
menuBar()->addMenu(m_menuTools);
|
|
|
|
menuBar()->addMenu(m_menuHelp);
|
|
|
|
|
|
|
|
menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuClosedTabs = new QMenu(tr("Closed Tabs"));
|
|
|
|
connect(m_menuClosedTabs, SIGNAL(aboutToShow()), this, SLOT(aboutToShowClosedTabsMenu()));
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
aboutToShowToolsMenu();
|
|
|
|
aboutToShowHelpMenu();
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
m_actionRestoreTab = new QAction(QIcon::fromTheme("user-trash"), tr("Restore &Closed Tab"), this);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionRestoreTab->setShortcut(QKeySequence("Ctrl+Shift+T"));
|
|
|
|
connect(m_actionRestoreTab, SIGNAL(triggered()), m_tabWidget, SLOT(restoreClosedTab()));
|
|
|
|
addAction(m_actionRestoreTab);
|
|
|
|
|
2012-01-16 17:40:28 +01:00
|
|
|
QShortcut* reloadByPassCacheAction = new QShortcut(QKeySequence("Ctrl+F5"), this);
|
|
|
|
QShortcut* reloadByPassCacheAction2 = new QShortcut(QKeySequence("Ctrl+Shift+R"), this);
|
2012-01-08 11:12:04 +01:00
|
|
|
connect(reloadByPassCacheAction, SIGNAL(activated()), this, SLOT(reloadByPassCache()));
|
2012-01-16 17:40:28 +01:00
|
|
|
connect(reloadByPassCacheAction2, SIGNAL(activated()), this, SLOT(reloadByPassCache()));
|
2012-01-08 11:12:04 +01:00
|
|
|
|
2012-01-16 17:31:15 +01:00
|
|
|
QShortcut* reloadAction = new QShortcut(QKeySequence("Ctrl+R"), this);
|
|
|
|
connect(reloadAction, SIGNAL(activated()), this, SLOT(reload()));
|
|
|
|
|
2012-01-08 11:12:04 +01:00
|
|
|
QShortcut* backAction = new QShortcut(QKeySequence("Alt+Left"), this);
|
|
|
|
connect(backAction, SIGNAL(activated()), this, SLOT(goBack()));
|
|
|
|
|
|
|
|
QShortcut* forwardAction = new QShortcut(QKeySequence("Alt+Right"), this);
|
|
|
|
connect(forwardAction, SIGNAL(activated()), this, SLOT(goNext()));
|
2011-05-08 14:12:35 +02:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
// Make shortcuts available even in fullscreen (menu hidden)
|
2011-05-07 12:59:53 +02:00
|
|
|
QList<QAction*> actions = menuBar()->actions();
|
2011-11-06 17:01:23 +01:00
|
|
|
foreach(QAction * action, actions) {
|
|
|
|
if (action->menu()) {
|
2011-05-07 12:59:53 +02:00
|
|
|
actions += action->menu()->actions();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
addAction(action);
|
2011-05-07 12:59:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
m_superMenu->addMenu(m_menuFile);
|
|
|
|
m_superMenu->addMenu(m_menuEdit);
|
|
|
|
m_superMenu->addMenu(m_menuView);
|
|
|
|
m_superMenu->addMenu(m_menuHistory);
|
|
|
|
m_superMenu->addMenu(m_menuBookmarks);
|
|
|
|
m_superMenu->addMenu(m_menuTools);
|
|
|
|
m_superMenu->addMenu(m_menuHelp);
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::loadSettings()
|
|
|
|
{
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
//Url settings
|
|
|
|
settings.beginGroup("Web-URL-Settings");
|
2011-11-06 17:01:23 +01:00
|
|
|
m_homepage = settings.value("homepage", "qupzilla:start").toUrl();
|
2011-12-04 16:54:57 +01:00
|
|
|
m_newtab = settings.value("newTabUrl", "qupzilla:speeddial").toUrl();
|
2011-03-02 16:57:41 +01:00
|
|
|
settings.endGroup();
|
|
|
|
|
2011-04-25 15:06:59 +02:00
|
|
|
QWebSettings* websettings = mApp->webSettings();
|
2011-03-02 16:57:41 +01:00
|
|
|
websettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
|
|
|
|
|
|
|
|
//Browser Window settings
|
|
|
|
settings.beginGroup("Browser-View-Settings");
|
|
|
|
m_menuTextColor = settings.value("menuTextColor", QColor(Qt::black)).value<QColor>();
|
2011-11-06 17:01:23 +01:00
|
|
|
bool showStatusBar = settings.value("showStatusBar", true).toBool();
|
|
|
|
bool showHomeIcon = settings.value("showHomeButton", true).toBool();
|
|
|
|
bool showBackForwardIcons = settings.value("showBackForwardButtons", true).toBool();
|
|
|
|
bool showBookmarksToolbar = settings.value("showBookmarksToolbar", true).toBool();
|
|
|
|
bool showNavigationToolbar = settings.value("showNavigationToolbar", true).toBool();
|
|
|
|
bool showMenuBar = settings.value("showMenubar", true).toBool();
|
2011-10-23 14:44:18 +02:00
|
|
|
bool showAddTab = settings.value("showAddTabButton", false).toBool();
|
2011-11-06 17:01:23 +01:00
|
|
|
bool makeTransparent = settings.value("useTransparentBackground", false).toBool();
|
2012-01-14 11:46:06 +01:00
|
|
|
m_sideBarWidth = settings.value("SideBarWidth", 250).toInt();
|
|
|
|
m_webViewWidth = settings.value("WebViewWidth", 390).toInt();
|
2011-04-28 18:31:48 +02:00
|
|
|
QString activeSideBar = settings.value("SideBar", "None").toString();
|
2011-03-02 16:57:41 +01:00
|
|
|
settings.endGroup();
|
2011-03-29 20:30:05 +02:00
|
|
|
bool adBlockEnabled = settings.value("AdBlock/enabled", true).toBool();
|
|
|
|
|
|
|
|
m_adblockIcon->setEnabled(adBlockEnabled);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
statusBar()->setVisible(showStatusBar);
|
|
|
|
m_bookmarksToolbar->setVisible(showBookmarksToolbar);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->setVisible(showNavigationToolbar);
|
2011-03-02 16:57:41 +01:00
|
|
|
menuBar()->setVisible(showMenuBar);
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->buttonSuperMenu()->setVisible(!showMenuBar);
|
|
|
|
m_navigationBar->buttonHome()->setVisible(showHomeIcon);
|
|
|
|
m_navigationBar->buttonBack()->setVisible(showBackForwardIcons);
|
|
|
|
m_navigationBar->buttonNext()->setVisible(showBackForwardIcons);
|
|
|
|
m_navigationBar->buttonAddTab()->setVisible(showAddTab);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-04-28 18:31:48 +02:00
|
|
|
if (activeSideBar != "None") {
|
2011-11-06 17:01:23 +01:00
|
|
|
if (activeSideBar == "Bookmarks") {
|
2011-04-28 18:31:48 +02:00
|
|
|
m_actionShowBookmarksSideBar->trigger();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (activeSideBar == "History") {
|
2011-04-28 18:31:48 +02:00
|
|
|
m_actionShowHistorySideBar->trigger();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-04-28 18:31:48 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
//Private browsing
|
2011-11-06 17:01:23 +01:00
|
|
|
m_actionPrivateBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled));
|
|
|
|
m_privateBrowsing->setVisible(mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled));
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-12-26 21:23:21 +01:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
if (m_usingTransparentBackground && !makeTransparent) {
|
|
|
|
QtWin::enableBlurBehindWindow(this, false);
|
|
|
|
m_usingTransparentBackground = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!makeTransparent) {
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
//Opacity
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
setAttribute(Qt::WA_NoSystemBackground, false);
|
|
|
|
QPalette pal = palette();
|
|
|
|
QColor bg = pal.window().color();
|
|
|
|
bg.setAlpha(180);
|
|
|
|
pal.setColor(QPalette::Window, bg);
|
|
|
|
setPalette(pal);
|
|
|
|
ensurePolished(); // workaround Oxygen filling the background
|
|
|
|
setAttribute(Qt::WA_StyledBackground, false);
|
|
|
|
#endif
|
|
|
|
if (QtWin::isCompositionEnabled()) {
|
|
|
|
QtWin::extendFrameIntoClientArea(this);
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
2011-12-26 21:23:21 +01:00
|
|
|
|
|
|
|
m_usingTransparentBackground = true;
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-17 11:13:38 +02:00
|
|
|
void QupZilla::setWindowTitle(const QString &t)
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
|
2011-09-17 11:13:38 +02:00
|
|
|
QMainWindow::setWindowTitle(t + tr(" (Private Browsing)"));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-09-17 11:13:38 +02:00
|
|
|
QMainWindow::setWindowTitle(t);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-17 11:13:38 +02:00
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
void QupZilla::receiveMessage(Qz::AppMessageType mes, bool state)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
switch (mes) {
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::AM_SetAdBlockIconEnabled:
|
2011-03-29 20:30:05 +02:00
|
|
|
m_adblockIcon->setEnabled(state);
|
2011-03-02 16:57:41 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::AM_CheckPrivateBrowsing:
|
2011-03-02 16:57:41 +01:00
|
|
|
m_privateBrowsing->setVisible(state);
|
|
|
|
m_actionPrivateBrowsing->setChecked(state);
|
2011-12-26 20:23:54 +01:00
|
|
|
weView()->titleChanged();
|
2011-03-02 16:57:41 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::AM_ReloadSettings:
|
2011-04-26 19:47:12 +02:00
|
|
|
loadSettings();
|
|
|
|
m_tabWidget->loadSettings();
|
2011-07-11 21:08:41 +02:00
|
|
|
LocationBarSettings::instance()->loadSettings();
|
2011-04-26 19:47:12 +02:00
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::AM_HistoryStateChanged:
|
2011-07-28 12:12:00 +02:00
|
|
|
m_historyMenuChanged = true;
|
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::AM_BookmarksChanged:
|
2011-07-30 17:57:14 +02:00
|
|
|
m_bookmarksMenuChanged = true;
|
|
|
|
break;
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::AM_StartPrivateBrowsing:
|
2011-12-26 20:23:54 +01:00
|
|
|
startPrivate(state);
|
|
|
|
break;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
default:
|
2011-07-28 12:12:00 +02:00
|
|
|
qWarning("Unresolved message sent! This could never happen!");
|
2011-03-02 16:57:41 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-17 15:09:17 +01:00
|
|
|
void QupZilla::aboutToShowFileMenu()
|
|
|
|
{
|
|
|
|
m_actionCloseWindow->setEnabled(mApp->windowCount() > 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToHideFileMenu()
|
|
|
|
{
|
|
|
|
m_actionCloseWindow->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::aboutToShowBookmarksMenu()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!m_bookmarksMenuChanged) {
|
2011-12-08 18:11:05 +01:00
|
|
|
if (m_menuBookmarksAction) {
|
|
|
|
m_menuBookmarksAction->setVisible(m_bookmarksToolbar->isVisible());
|
|
|
|
}
|
2011-07-30 17:57:14 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-30 17:57:14 +02:00
|
|
|
m_bookmarksMenuChanged = false;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuBookmarks->clear();
|
2011-04-09 00:22:50 +02:00
|
|
|
m_menuBookmarks->addAction(tr("Bookmark &This Page"), this, SLOT(bookmarkPage()))->setShortcut(QKeySequence("Ctrl+D"));
|
|
|
|
m_menuBookmarks->addAction(tr("Bookmark &All Tabs"), this, SLOT(bookmarkAllTabs()));
|
2011-09-30 21:44:18 +02:00
|
|
|
m_menuBookmarks->addAction(IconProvider::fromTheme("user-bookmarks"), tr("Organize &Bookmarks"), this, SLOT(showBookmarksManager()))->setShortcut(QKeySequence("Ctrl+Shift+O"));
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuBookmarks->addSeparator();
|
|
|
|
QSqlQuery query;
|
2011-07-30 17:57:14 +02:00
|
|
|
query.exec("SELECT title, url, icon FROM bookmarks WHERE folder='bookmarksMenu'");
|
2011-11-06 17:01:23 +01:00
|
|
|
while (query.next()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
QString title = query.value(0).toString();
|
2011-07-30 17:57:14 +02:00
|
|
|
QUrl url = query.value(1).toUrl();
|
2012-01-17 19:27:24 +01:00
|
|
|
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray()));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (title.length() > 40) {
|
2011-03-02 16:57:41 +01:00
|
|
|
title.truncate(40);
|
2011-11-06 17:01:23 +01:00
|
|
|
title += "..";
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-12-13 19:18:05 +01:00
|
|
|
|
|
|
|
Action* act = new Action(icon, title);
|
|
|
|
act->setData(url);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
|
2011-12-16 20:17:17 +01:00
|
|
|
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2011-12-13 19:18:05 +01:00
|
|
|
m_menuBookmarks->addAction(act);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-17 14:30:54 +01:00
|
|
|
Menu* menuBookmarks = new Menu(_bookmarksToolbar, m_menuBookmarks);
|
2011-12-08 18:11:05 +01:00
|
|
|
menuBookmarks->setIcon(QIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)));
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-07-30 17:57:14 +02:00
|
|
|
query.exec("SELECT title, url, icon FROM bookmarks WHERE folder='bookmarksToolbar'");
|
2011-11-06 17:01:23 +01:00
|
|
|
while (query.next()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
QString title = query.value(0).toString();
|
2011-07-30 17:57:14 +02:00
|
|
|
QUrl url = query.value(1).toUrl();
|
2012-01-17 19:27:24 +01:00
|
|
|
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray()));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (title.length() > 40) {
|
2011-03-02 16:57:41 +01:00
|
|
|
title.truncate(40);
|
2011-11-06 17:01:23 +01:00
|
|
|
title += "..";
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-12-13 19:18:05 +01:00
|
|
|
|
|
|
|
Action* act = new Action(icon, title);
|
|
|
|
act->setData(url);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
|
2011-12-16 20:17:17 +01:00
|
|
|
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2011-12-13 19:18:05 +01:00
|
|
|
menuBookmarks->addAction(act);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-12-08 18:11:05 +01:00
|
|
|
if (menuBookmarks->isEmpty()) {
|
|
|
|
menuBookmarks->addAction(tr("Empty"));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-12-08 18:11:05 +01:00
|
|
|
m_menuBookmarksAction = m_menuBookmarks->addMenu(menuBookmarks);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
query.exec("SELECT name FROM folders");
|
2011-11-06 17:01:23 +01:00
|
|
|
while (query.next()) {
|
2011-10-22 22:29:33 +02:00
|
|
|
QString folderName = query.value(0).toString();
|
2011-12-13 19:18:05 +01:00
|
|
|
Menu* tempFolder = new Menu(folderName, m_menuBookmarks);
|
2011-03-02 16:57:41 +01:00
|
|
|
tempFolder->setIcon(QIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)));
|
|
|
|
|
|
|
|
QSqlQuery query2;
|
2011-10-22 22:29:33 +02:00
|
|
|
query2.exec("SELECT title, url, icon FROM bookmarks WHERE folder='" + folderName + "'");
|
2011-11-06 17:01:23 +01:00
|
|
|
while (query2.next()) {
|
2011-10-22 22:29:33 +02:00
|
|
|
QString title = query2.value(0).toString();
|
|
|
|
QUrl url = query2.value(1).toUrl();
|
2012-01-17 19:27:24 +01:00
|
|
|
QIcon icon = IconProvider::iconFromImage(QImage::fromData(query2.value(2).toByteArray()));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (title.length() > 40) {
|
2011-03-02 16:57:41 +01:00
|
|
|
title.truncate(40);
|
2011-11-06 17:01:23 +01:00
|
|
|
title += "..";
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-12-13 19:18:05 +01:00
|
|
|
|
|
|
|
Action* act = new Action(icon, title);
|
|
|
|
act->setData(url);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
|
2011-12-16 20:17:17 +01:00
|
|
|
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2011-12-13 19:18:05 +01:00
|
|
|
tempFolder->addAction(act);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-11-06 17:01:23 +01:00
|
|
|
if (tempFolder->isEmpty()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
tempFolder->addAction(tr("Empty"));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuBookmarks->addMenu(tempFolder);
|
|
|
|
}
|
|
|
|
|
2011-12-08 18:11:05 +01:00
|
|
|
m_menuBookmarksAction->setVisible(m_bookmarksToolbar->isVisible());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-09-30 21:44:18 +02:00
|
|
|
void QupZilla::aboutToShowHistoryMenu(bool loadHistory)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!weView()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-28 12:12:00 +02:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
if (!m_historyMenuChanged) {
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!m_menuHistory || m_menuHistory->actions().count() < 3) {
|
2011-11-06 12:05:16 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
|
|
|
|
m_menuHistory->actions().at(0)->setEnabled(WebHistoryWrapper::canGoBack(weView()->history()));
|
|
|
|
m_menuHistory->actions().at(1)->setEnabled(WebHistoryWrapper::canGoForward(weView()->history()));
|
2011-07-28 12:12:00 +02:00
|
|
|
return;
|
2011-11-06 12:05:16 +01:00
|
|
|
}
|
2011-07-28 12:12:00 +02:00
|
|
|
m_historyMenuChanged = false;
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!loadHistory) {
|
2011-09-30 21:44:18 +02:00
|
|
|
m_historyMenuChanged = true;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-28 12:12:00 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuHistory->clear();
|
2011-09-30 21:44:18 +02:00
|
|
|
m_menuHistory->addAction(IconProvider::standardIcon(QStyle::SP_ArrowBack), tr("&Back"), this, SLOT(goBack()))->setShortcut(QKeySequence("Ctrl+Left"));
|
|
|
|
m_menuHistory->addAction(IconProvider::standardIcon(QStyle::SP_ArrowForward), tr("&Forward"), this, SLOT(goNext()))->setShortcut(QKeySequence("Ctrl+Right"));
|
|
|
|
m_menuHistory->addAction(IconProvider::fromTheme("go-home"), tr("&Home"), this, SLOT(goHome()))->setShortcut(QKeySequence("Alt+Home"));
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
m_menuHistory->actions().at(0)->setEnabled(WebHistoryWrapper::canGoBack(weView()->history()));
|
|
|
|
m_menuHistory->actions().at(1)->setEnabled(WebHistoryWrapper::canGoForward(weView()->history()));
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
m_menuHistory->addAction(QIcon(":/icons/menu/history.png"), tr("Show &All History"), this, SLOT(showHistoryManager()))->setShortcut(QKeySequence("Ctrl+Shift+H"));
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuHistory->addSeparator();
|
|
|
|
|
2011-09-30 21:44:18 +02:00
|
|
|
if (loadHistory) {
|
|
|
|
QSqlQuery query;
|
|
|
|
query.exec("SELECT title, url FROM history ORDER BY date DESC LIMIT 10");
|
2011-11-06 17:01:23 +01:00
|
|
|
while (query.next()) {
|
2011-09-30 21:44:18 +02:00
|
|
|
QUrl url = query.value(1).toUrl();
|
|
|
|
QString title = query.value(0).toString();
|
2011-11-06 17:01:23 +01:00
|
|
|
if (title.length() > 40) {
|
2011-09-30 21:44:18 +02:00
|
|
|
title.truncate(40);
|
2011-11-06 17:01:23 +01:00
|
|
|
title += "..";
|
2011-09-30 21:44:18 +02:00
|
|
|
}
|
2011-12-13 19:18:05 +01:00
|
|
|
|
|
|
|
Action* act = new Action(_iconForUrl(url), title);
|
|
|
|
act->setData(url);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
|
2011-12-16 20:17:17 +01:00
|
|
|
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2011-12-13 19:18:05 +01:00
|
|
|
m_menuHistory->addAction(act);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-09-30 21:44:18 +02:00
|
|
|
m_menuHistory->addSeparator();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuHistory->addMenu(m_menuClosedTabs);
|
|
|
|
}
|
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
void QupZilla::aboutToHideHistoryMenu()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!m_menuHistory || m_menuHistory->actions().count() < 3) {
|
2011-11-06 12:05:16 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
|
|
|
|
m_menuHistory->actions().at(0)->setEnabled(true);
|
|
|
|
m_menuHistory->actions().at(1)->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2011-07-28 12:12:00 +02:00
|
|
|
void QupZilla::aboutToShowClosedTabsMenu()
|
|
|
|
{
|
|
|
|
m_menuClosedTabs->clear();
|
2011-05-07 12:59:53 +02:00
|
|
|
int i = 0;
|
2011-11-06 17:01:23 +01:00
|
|
|
foreach(ClosedTabsManager::Tab tab, m_tabWidget->closedTabsManager()->allClosedTabs()) {
|
2011-05-08 12:54:49 +02:00
|
|
|
QString title = tab.title;
|
2011-11-06 17:01:23 +01:00
|
|
|
if (title.length() > 40) {
|
2011-05-08 12:54:49 +02:00
|
|
|
title.truncate(40);
|
2011-11-06 17:01:23 +01:00
|
|
|
title += "..";
|
2011-05-08 12:54:49 +02:00
|
|
|
}
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuClosedTabs->addAction(_iconForUrl(tab.url), title, m_tabWidget, SLOT(restoreClosedTab()))->setData(i);
|
2011-05-07 12:59:53 +02:00
|
|
|
i++;
|
|
|
|
}
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuClosedTabs->addSeparator();
|
2011-11-06 17:01:23 +01:00
|
|
|
if (i == 0) {
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuClosedTabs->addAction(tr("Empty"))->setEnabled(false);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-28 21:59:56 +02:00
|
|
|
else {
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), m_tabWidget, SLOT(restoreAllClosedTabs()));
|
2011-07-28 21:59:56 +02:00
|
|
|
m_menuClosedTabs->addAction(tr("Clear list"), m_tabWidget, SLOT(clearClosedTabsList()));
|
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToShowHelpMenu()
|
|
|
|
{
|
|
|
|
m_menuHelp->clear();
|
2011-03-04 13:59:07 +01:00
|
|
|
mApp->plugins()->populateHelpMenu(m_menuHelp);
|
2011-09-18 15:35:44 +02:00
|
|
|
m_menuHelp->addSeparator();
|
2012-01-08 11:38:15 +01:00
|
|
|
#ifndef Q_WS_MAC
|
2011-04-09 00:22:50 +02:00
|
|
|
m_menuHelp->addAction(QIcon(":/icons/menu/qt.png"), tr("About &Qt"), qApp, SLOT(aboutQt()));
|
2012-01-08 11:38:15 +01:00
|
|
|
m_menuHelp->addAction(m_actionAbout);
|
2011-09-18 15:35:44 +02:00
|
|
|
m_menuHelp->addSeparator();
|
2012-01-08 11:38:15 +01:00
|
|
|
#endif
|
2012-01-20 13:10:05 +01:00
|
|
|
QAction* infoAction = new QAction(QIcon(":/icons/menu/informations.png"), tr("Information about application"), m_menuHelp);
|
2011-11-06 17:01:23 +01:00
|
|
|
infoAction->setData(QUrl("qupzilla:about"));
|
|
|
|
infoAction->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
|
|
|
connect(infoAction, SIGNAL(triggered()), this, SLOT(loadActionUrlInNewTab()));
|
|
|
|
m_menuHelp->addAction(infoAction);
|
2011-09-19 20:49:39 +02:00
|
|
|
m_menuHelp->addAction(tr("Report &Issue"), this, SLOT(loadActionUrlInNewTab()))->setData(QUrl("qupzilla:reportbug"));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToShowToolsMenu()
|
|
|
|
{
|
|
|
|
m_menuTools->clear();
|
2011-04-09 00:22:50 +02:00
|
|
|
m_menuTools->addAction(tr("&Web Search"), this, SLOT(webSearch()))->setShortcut(QKeySequence("Ctrl+K"));
|
|
|
|
m_menuTools->addAction(QIcon::fromTheme("dialog-information"), tr("Page &Info"), this, SLOT(showPageInfo()))->setShortcut(QKeySequence("Ctrl+I"));
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuTools->addSeparator();
|
2011-04-09 00:22:50 +02:00
|
|
|
m_menuTools->addAction(tr("&Download Manager"), this, SLOT(showDownloadManager()))->setShortcut(QKeySequence("Ctrl+Y"));
|
|
|
|
m_menuTools->addAction(tr("&Cookies Manager"), this, SLOT(showCookieManager()));
|
|
|
|
m_menuTools->addAction(tr("&AdBlock"), AdBlockManager::instance(), SLOT(showDialog()));
|
|
|
|
m_menuTools->addAction(QIcon(":/icons/menu/rss.png"), tr("RSS &Reader"), this, SLOT(showRSSManager()));
|
|
|
|
m_menuTools->addAction(QIcon::fromTheme("edit-clear"), tr("Clear Recent &History"), this, SLOT(showClearPrivateData()));
|
|
|
|
m_actionPrivateBrowsing = new QAction(tr("&Private Browsing"), this);
|
2011-10-17 23:34:57 +02:00
|
|
|
m_actionPrivateBrowsing->setShortcut(QKeySequence("Ctrl+Shift+P"));
|
2011-03-02 16:57:41 +01:00
|
|
|
m_actionPrivateBrowsing->setCheckable(true);
|
2011-03-04 13:59:07 +01:00
|
|
|
m_actionPrivateBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled));
|
2011-03-02 16:57:41 +01:00
|
|
|
connect(m_actionPrivateBrowsing, SIGNAL(triggered(bool)), this, SLOT(startPrivate(bool)));
|
|
|
|
m_menuTools->addAction(m_actionPrivateBrowsing);
|
|
|
|
m_menuTools->addSeparator();
|
2011-03-04 13:59:07 +01:00
|
|
|
mApp->plugins()->populateToolsMenu(m_menuTools);
|
2012-01-08 11:38:15 +01:00
|
|
|
#if !defined(Q_WS_X11) && !defined(Q_WS_MAC)
|
|
|
|
m_menuTools->addAction(m_actionPreferences);
|
2011-12-10 13:15:07 +01:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToShowViewMenu()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!weView()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
m_actionShowToolbar->setChecked(m_navigationBar->isVisible());
|
2011-07-19 22:49:42 +02:00
|
|
|
m_actionShowMenubar->setChecked(menuBar()->isVisible());
|
|
|
|
m_actionShowStatusbar->setChecked(statusBar()->isVisible());
|
|
|
|
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
|
|
|
|
|
2012-01-18 18:36:10 +01:00
|
|
|
if (!m_sideBar) {
|
2011-07-19 22:49:42 +02:00
|
|
|
m_actionShowBookmarksSideBar->setChecked(false);
|
|
|
|
m_actionShowHistorySideBar->setChecked(false);
|
2011-11-06 12:05:16 +01:00
|
|
|
// m_actionShowRssSideBar->setChecked(false);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-12-09 21:56:01 +01:00
|
|
|
SideBar::SideWidget actWidget = m_sideBar.data()->activeWidget();
|
2011-07-19 22:49:42 +02:00
|
|
|
m_actionShowBookmarksSideBar->setChecked(actWidget == SideBar::Bookmarks);
|
|
|
|
m_actionShowHistorySideBar->setChecked(actWidget == SideBar::History);
|
2011-11-06 12:05:16 +01:00
|
|
|
// m_actionShowRssSideBar->setChecked(actWidget == SideBar::RSS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToHideViewMenu()
|
|
|
|
{
|
|
|
|
if (m_mainLayout->count() == 4) {
|
2011-11-06 17:01:23 +01:00
|
|
|
SearchToolBar* search = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
|
|
|
|
if (!search) {
|
2011-11-06 12:05:16 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
m_actionStop->setEnabled(false);
|
2011-07-19 22:49:42 +02:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-17 15:09:17 +01:00
|
|
|
void QupZilla::aboutToShowEditMenu()
|
2011-11-27 15:43:54 +01:00
|
|
|
{
|
2011-11-28 19:17:48 +01:00
|
|
|
foreach(QAction * act, m_menuEdit->actions()) {
|
2011-11-27 15:43:54 +01:00
|
|
|
act->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-17 15:09:17 +01:00
|
|
|
void QupZilla::aboutToHideEditMenu()
|
2011-11-27 15:43:54 +01:00
|
|
|
{
|
2011-11-28 19:17:48 +01:00
|
|
|
foreach(QAction * act, m_menuEdit->actions()) {
|
2011-11-27 15:43:54 +01:00
|
|
|
act->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2011-12-10 13:15:07 +01:00
|
|
|
m_menuEdit->actions().at(9)->setEnabled(true);
|
2012-01-06 15:03:48 +01:00
|
|
|
#ifdef Q_WS_X11
|
2011-12-10 13:15:07 +01:00
|
|
|
m_menuEdit->actions().at(11)->setEnabled(true);
|
|
|
|
#endif
|
2011-11-27 15:43:54 +01:00
|
|
|
}
|
|
|
|
|
2011-03-17 20:46:53 +01:00
|
|
|
void QupZilla::aboutToShowEncodingMenu()
|
|
|
|
{
|
|
|
|
m_menuEncoding->clear();
|
|
|
|
QMenu* menuISO = new QMenu("ISO", this);
|
|
|
|
QMenu* menuUTF = new QMenu("UTF", this);
|
|
|
|
QMenu* menuWindows = new QMenu("Windows", this);
|
|
|
|
QMenu* menuIscii = new QMenu("Iscii", this);
|
|
|
|
QMenu* menuOther = new QMenu(tr("Other"), this);
|
|
|
|
|
|
|
|
QList<QByteArray> available = QTextCodec::availableCodecs();
|
|
|
|
qSort(available);
|
|
|
|
QString activeCodec = mApp->webSettings()->defaultTextEncoding();
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
foreach(QByteArray name, available) {
|
|
|
|
if (QTextCodec::codecForName(name)->aliases().contains(name)) {
|
2011-03-17 20:46:53 +01:00
|
|
|
continue;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
QAction* action = new QAction(name == "System" ? tr("Default") : name, this);
|
2011-03-17 20:46:53 +01:00
|
|
|
action->setData(name);
|
|
|
|
action->setCheckable(true);
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(changeEncoding()));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (activeCodec.compare(name, Qt::CaseInsensitive) == 0) {
|
2011-03-17 20:46:53 +01:00
|
|
|
action->setChecked(true);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-17 20:46:53 +01:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
if (name.startsWith("ISO")) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuISO->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (name.startsWith("UTF")) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuUTF->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (name.startsWith("windows")) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuWindows->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (name.startsWith("Iscii")) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuIscii->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (name == "System") {
|
2011-03-17 20:46:53 +01:00
|
|
|
m_menuEncoding->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuOther->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-17 20:46:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_menuEncoding->addSeparator();
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!menuISO->isEmpty()) {
|
2011-03-17 20:46:53 +01:00
|
|
|
m_menuEncoding->addMenu(menuISO);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
if (!menuUTF->isEmpty()) {
|
2011-03-17 20:46:53 +01:00
|
|
|
m_menuEncoding->addMenu(menuUTF);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
if (!menuWindows->isEmpty()) {
|
2011-03-17 20:46:53 +01:00
|
|
|
m_menuEncoding->addMenu(menuWindows);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
if (!menuIscii->isEmpty()) {
|
2011-03-17 20:46:53 +01:00
|
|
|
m_menuEncoding->addMenu(menuIscii);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
if (!menuOther->isEmpty()) {
|
2011-03-17 20:46:53 +01:00
|
|
|
m_menuEncoding->addMenu(menuOther);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-17 20:46:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::changeEncoding()
|
|
|
|
{
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
|
|
|
mApp->webSettings()->setDefaultTextEncoding(action->data().toString());
|
|
|
|
reload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::bookmarkPage()
|
|
|
|
{
|
2011-07-29 15:39:43 +02:00
|
|
|
mApp->browsingLibrary()->bookmarksManager()->addBookmark(weView());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-07-30 17:57:14 +02:00
|
|
|
void QupZilla::addBookmark(const QUrl &url, const QString &title, const QIcon &icon)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-07-30 17:57:14 +02:00
|
|
|
mApp->browsingLibrary()->bookmarksManager()->insertBookmark(url, title, icon);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::bookmarkAllTabs()
|
|
|
|
{
|
2011-07-29 15:39:43 +02:00
|
|
|
mApp->browsingLibrary()->bookmarksManager()->insertAllTabs();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
void QupZilla::newWindow()
|
|
|
|
{
|
|
|
|
mApp->makeNewWindow(Qz::BW_NewWindow);
|
|
|
|
}
|
|
|
|
|
2011-10-26 19:23:50 +02:00
|
|
|
void QupZilla::goHome()
|
|
|
|
{
|
|
|
|
loadAddress(m_homepage);
|
|
|
|
}
|
|
|
|
|
2011-11-27 15:43:54 +01:00
|
|
|
void QupZilla::copy()
|
|
|
|
{
|
|
|
|
if (!weView()->selectedText().isEmpty()) {
|
|
|
|
QApplication::clipboard()->setText(weView()->selectedText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
void QupZilla::selectAll()
|
|
|
|
{
|
|
|
|
weView()->selectAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::zoomIn()
|
|
|
|
{
|
|
|
|
weView()->zoomIn();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::zoomOut()
|
|
|
|
{
|
|
|
|
weView()->zoomOut();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::zoomReset()
|
|
|
|
{
|
|
|
|
weView()->zoomReset();
|
|
|
|
}
|
|
|
|
|
2011-10-26 19:23:50 +02:00
|
|
|
void QupZilla::goHomeInNewTab()
|
|
|
|
{
|
2012-01-21 23:19:38 +01:00
|
|
|
m_tabWidget->addView(m_homepage, Qz::NT_SelectedTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::stop()
|
|
|
|
{
|
|
|
|
weView()->stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::reload()
|
|
|
|
{
|
|
|
|
weView()->reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::reloadByPassCache()
|
|
|
|
{
|
|
|
|
weView()->triggerPageAction(QWebPage::ReloadAndBypassCache);
|
2011-10-26 19:23:50 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::loadActionUrl()
|
|
|
|
{
|
2011-03-17 17:03:04 +01:00
|
|
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
2011-03-02 16:57:41 +01:00
|
|
|
loadAddress(action->data().toUrl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-19 20:49:39 +02:00
|
|
|
void QupZilla::loadActionUrlInNewTab()
|
|
|
|
{
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
|
|
|
m_tabWidget->addView(action->data().toUrl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-16 20:17:17 +01:00
|
|
|
void QupZilla::loadActionUrlInNewNotSelectedTab()
|
|
|
|
{
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
2012-01-21 23:19:38 +01:00
|
|
|
m_tabWidget->addView(action->data().toUrl(), Qz::NT_NotSelectedTab);
|
2011-12-16 20:17:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-21 20:58:02 +01:00
|
|
|
void QupZilla::loadFolderBookmarks(Menu* menu)
|
2011-12-20 18:58:42 +01:00
|
|
|
{
|
|
|
|
QString folder = BookmarksModel::fromTranslatedFolder(menu->title());
|
|
|
|
if (folder.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(Bookmark b, mApp->bookmarksModel()->folderBookmarks(folder)) {
|
2012-01-21 23:19:38 +01:00
|
|
|
tabWidget()->addView(b.url, b.title, Qz::NT_NotSelectedTab);
|
2011-12-20 18:58:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-31 00:50:40 +02:00
|
|
|
void QupZilla::loadAddress(const QUrl &url)
|
|
|
|
{
|
|
|
|
weView()->load(url);
|
|
|
|
locationBar()->setText(url.toEncoded());
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::showCookieManager()
|
|
|
|
{
|
2011-03-04 13:59:07 +01:00
|
|
|
CookieManager* m = mApp->cookieManager();
|
2011-03-02 16:57:41 +01:00
|
|
|
m->refreshTable();
|
|
|
|
m->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showHistoryManager()
|
|
|
|
{
|
2011-07-29 15:39:43 +02:00
|
|
|
mApp->browsingLibrary()->showHistory(this);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showRSSManager()
|
|
|
|
{
|
2011-07-29 15:39:43 +02:00
|
|
|
mApp->browsingLibrary()->showRSS(this);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showBookmarksManager()
|
|
|
|
{
|
2011-07-29 15:39:43 +02:00
|
|
|
mApp->browsingLibrary()->showBookmarks(this);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showClearPrivateData()
|
|
|
|
{
|
|
|
|
ClearPrivateData clear(this, this);
|
|
|
|
clear.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showDownloadManager()
|
|
|
|
{
|
2011-03-04 13:59:07 +01:00
|
|
|
mApp->downManager()->show();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showPreferences()
|
|
|
|
{
|
2011-04-27 09:49:41 +02:00
|
|
|
Preferences* prefs = new Preferences(this, this);
|
|
|
|
prefs->show();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-01-02 17:23:31 +01:00
|
|
|
void QupZilla::showSource(QWebFrame* frame, const QString &selectedHtml)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2012-01-02 13:56:52 +01:00
|
|
|
if (!frame) {
|
|
|
|
frame = weView()->page()->mainFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
SourceViewer* source = new SourceViewer(frame, selectedHtml);
|
2011-10-26 19:23:50 +02:00
|
|
|
qz_centerWidgetToParent(source, this);
|
2011-03-02 16:57:41 +01:00
|
|
|
source->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showPageInfo()
|
|
|
|
{
|
2012-01-21 20:27:45 +01:00
|
|
|
SiteInfo* info = new SiteInfo(weView(), this);
|
2011-03-02 16:57:41 +01:00
|
|
|
info->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
info->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showBookmarksToolbar()
|
|
|
|
{
|
2011-04-04 20:04:29 +02:00
|
|
|
bool status = m_bookmarksToolbar->isVisible();
|
|
|
|
m_bookmarksToolbar->setVisible(!status);
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-04-04 20:04:29 +02:00
|
|
|
settings.setValue("Browser-View-Settings/showBookmarksToolbar", !status);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-04-15 20:45:22 +02:00
|
|
|
void QupZilla::showBookmarksSideBar()
|
|
|
|
{
|
2011-09-11 19:15:06 +02:00
|
|
|
addSideBar();
|
|
|
|
|
2011-12-09 21:56:01 +01:00
|
|
|
if (m_sideBar.data()->activeWidget() != SideBar::Bookmarks) {
|
|
|
|
m_sideBar.data()->showBookmarks();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-17 09:59:09 +02:00
|
|
|
else {
|
2011-12-09 21:56:01 +01:00
|
|
|
m_sideBar.data()->close();
|
2011-10-17 09:59:09 +02:00
|
|
|
}
|
2011-04-20 21:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showHistorySideBar()
|
|
|
|
{
|
2011-09-11 19:15:06 +02:00
|
|
|
addSideBar();
|
|
|
|
|
2011-12-09 21:56:01 +01:00
|
|
|
if (m_sideBar.data()->activeWidget() != SideBar::History) {
|
|
|
|
m_sideBar.data()->showHistory();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-17 09:59:09 +02:00
|
|
|
else {
|
2011-12-09 21:56:01 +01:00
|
|
|
m_sideBar.data()->close();
|
2011-10-17 09:59:09 +02:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::addSideBar()
|
|
|
|
{
|
2012-01-18 18:36:10 +01:00
|
|
|
if (m_sideBar) {
|
2011-09-11 19:15:06 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
|
|
|
|
m_sideBar = new SideBar(this);
|
|
|
|
|
2011-12-09 21:56:01 +01:00
|
|
|
m_mainSplitter->insertWidget(0, m_sideBar.data());
|
2011-09-11 19:15:06 +02:00
|
|
|
m_mainSplitter->setCollapsible(0, false);
|
2011-10-17 09:59:09 +02:00
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
m_mainSplitter->setSizes(QList<int>() << m_sideBarWidth << m_webViewWidth);
|
2011-10-17 09:59:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::saveSideBarWidth()
|
|
|
|
{
|
|
|
|
// That +1 is important here, without it, the sidebar width would
|
|
|
|
// decrease by 1 pixel every close
|
2012-01-13 16:51:58 +01:00
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
m_sideBarWidth = m_mainSplitter->sizes().at(0) + 1;
|
|
|
|
m_webViewWidth = width() - m_sideBarWidth;
|
2011-04-15 20:45:22 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::showNavigationToolbar()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!menuBar()->isVisible() && !m_actionShowToolbar->isChecked()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
showMenubar();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
bool status = m_navigationBar->isVisible();
|
|
|
|
m_navigationBar->setVisible(!status);
|
2011-04-04 20:04:29 +02:00
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-04-04 20:04:29 +02:00
|
|
|
settings.setValue("Browser-View-Settings/showNavigationToolbar", !status);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showMenubar()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!m_navigationBar->isVisible() && !m_actionShowMenubar->isChecked()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
showNavigationToolbar();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
menuBar()->setVisible(!menuBar()->isVisible());
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->buttonSuperMenu()->setVisible(!menuBar()->isVisible());
|
2011-04-04 20:04:29 +02:00
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-04-04 20:04:29 +02:00
|
|
|
settings.setValue("Browser-View-Settings/showMenubar", menuBar()->isVisible());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showStatusbar()
|
|
|
|
{
|
2011-04-04 20:04:29 +02:00
|
|
|
bool status = statusBar()->isVisible();
|
|
|
|
statusBar()->setVisible(!status);
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-04-04 20:04:29 +02:00
|
|
|
settings.setValue("Browser-View-Settings/showStatusbar", !status);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-10-14 20:14:57 +02:00
|
|
|
void QupZilla::showWebInspector()
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-10-23 10:17:06 +02:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
weView()->triggerPageAction(QWebPage::InspectElement);
|
|
|
|
#else
|
2012-01-18 18:36:10 +01:00
|
|
|
if (m_webInspectorDock) {
|
2011-12-09 21:56:01 +01:00
|
|
|
m_webInspectorDock.data()->setPage(weView()->webPage());
|
|
|
|
m_webInspectorDock.data()->show();
|
2011-10-14 20:14:57 +02:00
|
|
|
return;
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-10-14 20:14:57 +02:00
|
|
|
|
|
|
|
m_webInspectorDock = new WebInspectorDockWidget(this);
|
2011-12-09 21:56:01 +01:00
|
|
|
connect(m_tabWidget, SIGNAL(currentChanged(int)), m_webInspectorDock.data(), SLOT(tabChanged()));
|
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorDock.data());
|
2011-10-23 10:17:06 +02:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-10-22 22:29:33 +02:00
|
|
|
void QupZilla::showBookmarkImport()
|
|
|
|
{
|
|
|
|
BookmarksImportDialog* b = new BookmarksImportDialog(this);
|
|
|
|
b->show();
|
|
|
|
}
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
void QupZilla::refreshHistory()
|
|
|
|
{
|
|
|
|
m_navigationBar->refreshHistory();
|
|
|
|
}
|
|
|
|
|
2012-01-14 09:54:51 +01:00
|
|
|
void QupZilla::currentTabChanged()
|
|
|
|
{
|
2012-01-21 20:27:45 +01:00
|
|
|
TabbedWebView* view = weView();
|
2012-01-14 09:54:51 +01:00
|
|
|
if (!view) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-21 20:27:45 +01:00
|
|
|
setWindowTitle(tr("%1 - QupZilla").arg(view->title()));
|
2012-01-14 09:54:51 +01:00
|
|
|
m_ipLabel->setText(view->getIp());
|
|
|
|
view->setFocus();
|
|
|
|
|
|
|
|
updateLoadingActions();
|
|
|
|
|
|
|
|
// Setting correct tab order (LocationBar -> WebSearchBar -> WebView)
|
|
|
|
setTabOrder(locationBar(), m_navigationBar->searchLine());
|
|
|
|
setTabOrder(m_navigationBar->searchLine(), view);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::updateLoadingActions()
|
|
|
|
{
|
2012-01-21 20:27:45 +01:00
|
|
|
TabbedWebView* view = weView();
|
2012-01-14 09:54:51 +01:00
|
|
|
if (!view) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLoading = view->isLoading();
|
|
|
|
|
|
|
|
m_ipLabel->setVisible(!isLoading);
|
|
|
|
m_progressBar->setVisible(isLoading);
|
|
|
|
m_actionStop->setEnabled(isLoading);
|
|
|
|
m_actionReload->setEnabled(!isLoading);
|
|
|
|
|
|
|
|
if (isLoading) {
|
2012-01-21 20:27:45 +01:00
|
|
|
m_progressBar->setValue(view->loadProgress());
|
2012-01-14 09:54:51 +01:00
|
|
|
m_navigationBar->showStopButton();
|
|
|
|
}
|
|
|
|
else {
|
2012-01-14 12:44:14 +01:00
|
|
|
m_navigationBar->showReloadButton();
|
2012-01-14 09:54:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-21 20:27:45 +01:00
|
|
|
void QupZilla::addDeleteOnCloseWidget(QWidget* widget)
|
|
|
|
{
|
|
|
|
if (!m_deleteOnCloseWidgets.contains(widget)) {
|
|
|
|
m_deleteOnCloseWidgets.append(widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::aboutQupZilla()
|
|
|
|
{
|
|
|
|
AboutDialog about(this);
|
|
|
|
about.exec();
|
|
|
|
}
|
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
void QupZilla::addTab()
|
|
|
|
{
|
|
|
|
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTab, true);
|
|
|
|
}
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
void QupZilla::webSearch()
|
|
|
|
{
|
|
|
|
m_navigationBar->searchLine()->setFocus();
|
2011-10-21 23:26:34 +02:00
|
|
|
m_navigationBar->searchLine()->selectAll();
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::searchOnPage()
|
|
|
|
{
|
2011-09-11 19:15:06 +02:00
|
|
|
if (m_mainLayout->count() == 4) {
|
2011-11-06 17:01:23 +01:00
|
|
|
SearchToolBar* search = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
|
|
|
|
if (!search) {
|
2011-09-11 19:15:06 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-08-02 16:19:20 +02:00
|
|
|
search->searchLine()->setFocus();
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-08-02 16:19:20 +02:00
|
|
|
|
|
|
|
SearchToolBar* search = new SearchToolBar(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_mainLayout->insertWidget(3, search);
|
2011-08-02 16:19:20 +02:00
|
|
|
search->searchLine()->setFocus();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::openFile()
|
|
|
|
{
|
|
|
|
QString filePath = QFileDialog::getOpenFileName(this, tr("Open file..."), QDir::homePath(), "(*.html *.htm *.jpg *.png)");
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!filePath.isEmpty()) {
|
2011-12-17 14:30:54 +01:00
|
|
|
loadAddress(QUrl::fromLocalFile(filePath));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-16 19:07:36 +01:00
|
|
|
void QupZilla::openLocation()
|
|
|
|
{
|
|
|
|
locationBar()->setFocus();
|
|
|
|
locationBar()->selectAll();
|
|
|
|
}
|
|
|
|
|
2011-04-22 07:45:15 +02:00
|
|
|
void QupZilla::showNavigationWithFullscreen()
|
|
|
|
{
|
|
|
|
bool state;
|
2011-11-06 17:01:23 +01:00
|
|
|
if (m_navigationVisible) {
|
2011-09-11 19:15:06 +02:00
|
|
|
state = !m_navigationBar->isVisible();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-04-22 07:45:15 +02:00
|
|
|
state = !m_tabWidget->getTabBar()->isVisible();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
if (m_navigationVisible) {
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->setVisible(state);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
|
|
|
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(state);
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
if (m_bookmarksToolBarVisible) {
|
2011-04-22 07:45:15 +02:00
|
|
|
m_bookmarksToolbar->setVisible(state);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-04-22 07:45:15 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::fullScreen(bool make)
|
|
|
|
{
|
|
|
|
if (make) {
|
|
|
|
m_menuBarVisible = menuBar()->isVisible();
|
|
|
|
m_statusBarVisible = statusBar()->isVisible();
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationVisible = m_navigationBar->isVisible();
|
2011-04-22 07:45:15 +02:00
|
|
|
m_bookmarksToolBarVisible = m_bookmarksToolbar->isVisible();
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
setWindowState(windowState() | Qt::WindowFullScreen);
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
menuBar()->hide();
|
|
|
|
statusBar()->hide();
|
2011-04-22 07:45:15 +02:00
|
|
|
bookmarksToolbar()->hide();
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->hide();
|
2012-01-04 16:00:59 +01:00
|
|
|
m_tabWidget->getTabBar()->hide();
|
2011-10-24 17:46:45 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-03-02 16:57:41 +01:00
|
|
|
setWindowState(windowState() & ~Qt::WindowFullScreen);
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2011-04-22 07:45:15 +02:00
|
|
|
menuBar()->setVisible(m_menuBarVisible);
|
|
|
|
statusBar()->setVisible(m_statusBarVisible);
|
|
|
|
m_bookmarksToolbar->setVisible(m_bookmarksToolBarVisible);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->setVisible(m_navigationVisible);
|
2012-01-04 16:00:59 +01:00
|
|
|
m_tabWidget->showTabBar();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
m_actionShowFullScreen->setChecked(make);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_navigationBar->buttonExitFullscreen()->setVisible(make);
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2011-04-22 07:45:15 +02:00
|
|
|
emit setWebViewMouseTracking(make);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::savePage()
|
|
|
|
{
|
|
|
|
QNetworkRequest request(weView()->url());
|
|
|
|
|
2011-03-04 13:59:07 +01:00
|
|
|
DownloadManager* dManager = mApp->downManager();
|
2011-11-08 15:20:53 +01:00
|
|
|
dManager->download(request, weView()->webPage(), false);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-16 20:17:17 +01:00
|
|
|
void QupZilla::sendLink()
|
|
|
|
{
|
|
|
|
QUrl url = QUrl("mailto:?body=" + weView()->url().toString());
|
|
|
|
QDesktopServices::openUrl(url);
|
|
|
|
}
|
|
|
|
|
2012-01-02 17:23:31 +01:00
|
|
|
void QupZilla::printPage(QWebFrame* frame)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
QPrintPreviewDialog* dialog = new QPrintPreviewDialog(this);
|
2012-01-06 17:31:44 +01:00
|
|
|
dialog->resize(800, 750);
|
2012-01-02 13:56:52 +01:00
|
|
|
|
|
|
|
if (!frame) {
|
|
|
|
connect(dialog, SIGNAL(paintRequested(QPrinter*)), weView(), SLOT(print(QPrinter*)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
connect(dialog, SIGNAL(paintRequested(QPrinter*)), frame, SLOT(print(QPrinter*)));
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
dialog->exec();
|
2011-12-04 20:09:44 +01:00
|
|
|
|
|
|
|
dialog->deleteLater();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-09-21 14:20:49 +02:00
|
|
|
void QupZilla::savePageScreen()
|
|
|
|
{
|
2011-10-26 19:23:50 +02:00
|
|
|
PageScreen* p = new PageScreen(weView(), this);
|
2011-09-21 14:20:49 +02:00
|
|
|
p->show();
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::startPrivate(bool state)
|
|
|
|
{
|
2011-12-26 20:23:54 +01:00
|
|
|
static bool askedThisSession = false;
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-12-07 17:59:41 +01:00
|
|
|
bool askNow = settings.value("Browser-View-Settings/AskOnPrivate", true).toBool();
|
|
|
|
|
2011-12-26 20:23:54 +01:00
|
|
|
if (state && askNow && !askedThisSession) {
|
2011-03-02 16:57:41 +01:00
|
|
|
QString title = tr("Are you sure you want to turn on private browsing?");
|
|
|
|
QString text1 = tr("When private browsing is turned on, some actions concerning your privacy will be disabled:");
|
|
|
|
|
|
|
|
QStringList actions;
|
|
|
|
actions.append(tr("Webpages are not added to the history."));
|
2011-09-17 11:13:38 +02:00
|
|
|
actions.append(tr("Current cookies cannot be accessed."));
|
|
|
|
actions.append(tr("Your session is not stored."));
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
QString text2 = tr("Until you close the window, you can still click the Back and Forward "
|
2011-11-06 17:01:23 +01:00
|
|
|
"buttons to return to the webpages you have opened.");
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
QString message = QString(QLatin1String("<b>%1</b><p>%2</p><ul><li>%3</li></ul><p>%4</p>")).arg(title, text1, actions.join(QLatin1String("</li><li>")), text2);
|
|
|
|
|
|
|
|
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Start Private Browsing"),
|
2011-11-06 17:01:23 +01:00
|
|
|
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
|
|
if (button != QMessageBox::Yes) {
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-01-04 14:09:27 +01:00
|
|
|
|
|
|
|
askedThisSession = true;
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-12-07 17:59:41 +01:00
|
|
|
|
2011-12-30 16:54:37 +01:00
|
|
|
mApp->togglePrivateBrowsingMode(state);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-01-02 17:23:31 +01:00
|
|
|
void QupZilla::resizeEvent(QResizeEvent* event)
|
2011-12-29 15:21:26 +01:00
|
|
|
{
|
|
|
|
m_bookmarksToolbar->setMaximumWidth(width());
|
|
|
|
|
|
|
|
QMainWindow::resizeEvent(event);
|
|
|
|
}
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
void QupZilla::keyPressEvent(QKeyEvent* event)
|
2011-11-06 12:05:16 +01:00
|
|
|
{
|
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Back:
|
|
|
|
weView()->back();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_Forward:
|
|
|
|
weView()->forward();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_Stop:
|
|
|
|
weView()->stop();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_Refresh:
|
|
|
|
weView()->reload();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_HomePage:
|
|
|
|
goHome();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_Favorites:
|
|
|
|
showBookmarksManager();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_Search:
|
|
|
|
searchOnPage();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2011-12-16 19:07:36 +01:00
|
|
|
case Qt::Key_F6:
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_OpenUrl:
|
|
|
|
openLocation();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_History:
|
|
|
|
showHistoryManager();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_AddFavorite:
|
|
|
|
bookmarkPage();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_News:
|
|
|
|
showRSSManager();
|
|
|
|
event->accept();
|
|
|
|
break;
|
|
|
|
case Qt::Key_Tools:
|
|
|
|
showPreferences();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2011-11-07 19:56:53 +01:00
|
|
|
case Qt::Key_Tab:
|
|
|
|
if (event->modifiers() == Qt::ControlModifier) {
|
|
|
|
m_tabWidget->createKeyPressEvent(event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Qt::Key_Backtab:
|
|
|
|
if (event->modifiers() == (Qt::ControlModifier + Qt::ShiftModifier)) {
|
|
|
|
m_tabWidget->createKeyPressEvent(event);
|
|
|
|
}
|
|
|
|
break;
|
2011-11-06 12:05:16 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
QMainWindow::keyPressEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (mApp->isClosing()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-29 19:55:21 +02:00
|
|
|
|
2011-10-31 21:27:52 +01:00
|
|
|
m_isClosing = true;
|
2011-03-29 19:55:21 +02:00
|
|
|
mApp->saveStateSlot();
|
|
|
|
|
2012-01-06 15:03:48 +01:00
|
|
|
#ifndef Q_WS_MAC
|
2012-01-18 18:36:10 +01:00
|
|
|
if (mApp->windowCount() == 1) {
|
2012-01-10 19:10:16 +01:00
|
|
|
if (quitApp()) {
|
2012-01-14 11:46:06 +01:00
|
|
|
disconnectObjects();
|
2012-01-10 21:15:03 +01:00
|
|
|
event->accept();
|
2012-01-10 19:10:16 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
|
2011-03-05 10:57:36 +01:00
|
|
|
return;
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2012-01-06 15:03:48 +01:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-18 18:36:10 +01:00
|
|
|
mApp->aboutToCloseWindow(this);
|
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
disconnectObjects();
|
2011-03-02 16:57:41 +01:00
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
void QupZilla::disconnectObjects()
|
2012-01-10 18:31:38 +01:00
|
|
|
{
|
|
|
|
// Disconnecting all important widgets before deleting this window
|
|
|
|
// so it cannot happen that slots will be invoked after the object
|
|
|
|
// is deleted.
|
|
|
|
// We have to do it this way, because ~QObject is deleting all child
|
|
|
|
// objects with plain delete - not deleteLater().
|
2012-01-14 11:46:06 +01:00
|
|
|
//
|
|
|
|
// Also using own disconnectObjects() method, not default disconnect()
|
|
|
|
// because we need to retain connections to destroyed(QObject*) signal
|
|
|
|
// in order to avoid crashes for example with setting stylesheets
|
|
|
|
// (QStyleSheet backend is holding list of all widgets)
|
2012-01-10 18:31:38 +01:00
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
m_tabWidget->disconnectObjects();
|
|
|
|
m_tabWidget->getTabBar()->disconnectObjects();
|
2012-01-10 18:31:38 +01:00
|
|
|
|
|
|
|
foreach(WebTab * tab, m_tabWidget->allTabs()) {
|
2012-01-14 11:46:06 +01:00
|
|
|
tab->disconnectObjects();
|
|
|
|
tab->view()->disconnectObjects();
|
|
|
|
tab->view()->webPage()->disconnectObjects();
|
2012-01-10 18:31:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-05 13:16:13 +01:00
|
|
|
bool QupZilla::quitApp()
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2012-01-18 18:36:10 +01:00
|
|
|
if (m_sideBar) {
|
2011-10-17 09:59:09 +02:00
|
|
|
saveSideBarWidth();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-17 09:59:09 +02:00
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-12-10 22:53:01 +01:00
|
|
|
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();
|
2012-01-18 12:58:09 +01:00
|
|
|
bool askOnClose = settings.value("Browser-Tabs-Settings/AskOnClosing", true).toBool();
|
2011-03-26 15:59:11 +01:00
|
|
|
|
2011-10-17 09:59:09 +02:00
|
|
|
settings.beginGroup("Browser-View-Settings");
|
|
|
|
settings.setValue("WindowMaximised", windowState().testFlag(Qt::WindowMaximized));
|
|
|
|
settings.setValue("WindowGeometry", geometry());
|
|
|
|
settings.setValue("LocationBarWidth", m_navigationBar->splitter()->sizes().at(0));
|
|
|
|
settings.setValue("WebSearchBarWidth", m_navigationBar->splitter()->sizes().at(1));
|
2012-01-14 11:46:06 +01:00
|
|
|
settings.setValue("SideBarWidth", m_sideBarWidth);
|
|
|
|
settings.setValue("WebViewWidth", m_webViewWidth);
|
2012-01-18 12:58:09 +01:00
|
|
|
settings.endGroup();
|
2011-09-20 19:14:36 +02:00
|
|
|
|
2011-12-10 22:53:01 +01:00
|
|
|
if (askOnClose && afterLaunch != 3 && m_tabWidget->count() > 1) {
|
2012-01-21 20:27:45 +01:00
|
|
|
QDialog dialog(this);
|
2011-03-26 15:59:11 +01:00
|
|
|
Ui_CloseDialog* ui = new Ui_CloseDialog();
|
2012-01-21 20:27:45 +01:00
|
|
|
ui->setupUi(&dialog);
|
2011-12-16 19:38:29 +01:00
|
|
|
ui->textLabel->setText(tr("There are still %1 open tabs and your session won't be stored. Are you sure to quit QupZilla?").arg(m_tabWidget->count()));
|
2011-03-26 15:59:11 +01:00
|
|
|
ui->iconLabel->setPixmap(style()->standardPixmap(QStyle::SP_MessageBoxWarning));
|
2012-01-21 20:27:45 +01:00
|
|
|
if (dialog.exec() != QDialog::Accepted) {
|
2011-03-05 13:16:13 +01:00
|
|
|
return false;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
if (ui->dontAskAgain->isChecked()) {
|
2011-07-19 21:38:11 +02:00
|
|
|
settings.setValue("Browser-Tabs-Settings/AskOnClosing", false);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-01-10 19:10:16 +01:00
|
|
|
QTimer::singleShot(0, mApp, SLOT(quitApplication()));
|
2011-03-05 13:16:13 +01:00
|
|
|
return true;
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QupZilla::~QupZilla()
|
|
|
|
{
|
2012-01-21 20:27:45 +01:00
|
|
|
foreach(const QWeakPointer<QWidget> &pointer, m_deleteOnCloseWidgets) {
|
|
|
|
if (pointer) {
|
|
|
|
pointer.data()->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|