2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2013-01-24 17:47:50 +01:00
|
|
|
* Copyright (C) 2010-2013 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"
|
2012-04-30 16:33:14 +02:00
|
|
|
#include "history.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "locationbar.h"
|
|
|
|
#include "searchtoolbar.h"
|
|
|
|
#include "websearchbar.h"
|
2013-01-17 15:24:30 +01:00
|
|
|
#include "pluginproxy.h"
|
|
|
|
#include "sidebar.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#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"
|
2013-01-24 17:47:50 +01:00
|
|
|
#include "autofill.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "networkmanagerproxy.h"
|
|
|
|
#include "rssmanager.h"
|
|
|
|
#include "mainapplication.h"
|
|
|
|
#include "aboutdialog.h"
|
2012-03-15 19:35:37 +01:00
|
|
|
#include "checkboxdialog.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"
|
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-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"
|
2013-01-22 19:04:22 +01:00
|
|
|
#include "qztools.h"
|
2013-03-08 21:01:55 +01:00
|
|
|
#include "actioncopy.h"
|
2012-10-20 11:31:45 +02:00
|
|
|
#include "reloadstopbutton.h"
|
2011-12-14 22:30:05 +01:00
|
|
|
#include "enhancedmenu.h"
|
2013-02-11 13:08:11 +01:00
|
|
|
#include "navigationcontainer.h"
|
2012-01-11 21:58:25 +01:00
|
|
|
#include "settings.h"
|
2013-02-09 13:00:45 +01:00
|
|
|
#include "qzsettings.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "webtab.h"
|
2012-02-05 17:13:08 +01:00
|
|
|
#include "speeddial.h"
|
2013-02-09 14:08:12 +01:00
|
|
|
#include "menubar.h"
|
2012-04-02 19:33:05 +02:00
|
|
|
#include "qtwin.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-08-31 15:19:07 +02:00
|
|
|
#include <QKeyEvent>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QSplitter>
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QShortcut>
|
|
|
|
#include <QStackedWidget>
|
|
|
|
#include <QSqlQuery>
|
|
|
|
#include <QTextCodec>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QNetworkRequest>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QPrintPreviewDialog>
|
|
|
|
#include <QWebFrame>
|
2012-04-04 13:21:53 +02:00
|
|
|
#include <QWebHistory>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
2012-12-22 12:47:45 +01:00
|
|
|
#if QT_VERSION < 0x050000
|
|
|
|
#include "qwebkitversion.h"
|
2012-12-22 15:01:55 +01:00
|
|
|
#endif
|
|
|
|
|
2012-12-22 12:47:45 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-09-06 11:39:42 +02:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
2012-12-22 15:01:55 +01:00
|
|
|
#endif
|
2012-12-20 14:45:35 +01:00
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
#define MENU_RECEIVER this
|
|
|
|
#else
|
|
|
|
#include "macmenureceiver.h"
|
|
|
|
#define MENU_RECEIVER mApp->macMenuReceiver()
|
|
|
|
#endif
|
|
|
|
|
2013-03-17 10:32:39 +01:00
|
|
|
const QString QupZilla::VERSION = "1.5.0";
|
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";
|
2013-02-11 09:59:53 +01:00
|
|
|
const QString QupZilla::COPYRIGHT = "2010-2013";
|
2012-01-06 15:03:48 +01:00
|
|
|
const QString QupZilla::WWWADDRESS = "http://www.qupzilla.com";
|
2012-04-17 14:00:32 +02:00
|
|
|
const QString QupZilla::WIKIADDRESS = "https://github.com/QupZilla/qupzilla/wiki";
|
2011-03-26 15:59:11 +01:00
|
|
|
const QString QupZilla::WEBKITVERSION = qWebKitVersion();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl)
|
2012-04-17 14:00:32 +02:00
|
|
|
: QMainWindow(0)
|
2011-10-15 16:37:32 +02:00
|
|
|
, m_historyMenuChanged(true)
|
|
|
|
, m_bookmarksMenuChanged(true)
|
2011-10-31 21:27:52 +01:00
|
|
|
, m_isClosing(false)
|
2012-03-13 17:51:37 +01:00
|
|
|
, m_isStarting(false)
|
2011-10-15 16:37:32 +02:00
|
|
|
, m_startingUrl(startUrl)
|
2013-02-15 22:18:46 +01:00
|
|
|
, m_windowType(type)
|
2011-12-08 18:11:05 +01:00
|
|
|
, m_menuBookmarksAction(0)
|
2011-10-15 16:37:32 +02:00
|
|
|
, m_actionPrivateBrowsing(0)
|
2012-04-01 16:36:38 +02:00
|
|
|
, m_sideBarManager(new SideBarManager(this))
|
2011-10-15 16:37:32 +02:00
|
|
|
, 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
|
|
|
|
2012-06-26 11:49:39 +02:00
|
|
|
if (mApp->isPrivateSession()) {
|
|
|
|
setProperty("private", QVariant(true));
|
|
|
|
}
|
|
|
|
|
2012-03-13 17:51:37 +01:00
|
|
|
m_isStarting = true;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-12-22 12:47:45 +01:00
|
|
|
#ifndef QZ_WS_X11
|
2012-07-09 23:45:49 +02:00
|
|
|
setUpdatesEnabled(false);
|
|
|
|
#endif
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
setupUi();
|
|
|
|
setupMenu();
|
2012-01-08 11:38:15 +01:00
|
|
|
|
2013-02-09 15:44:17 +01:00
|
|
|
m_hideNavigationTimer = new QTimer(this);
|
|
|
|
m_hideNavigationTimer->setInterval(1000);
|
|
|
|
m_hideNavigationTimer->setSingleShot(true);
|
|
|
|
connect(m_hideNavigationTimer, SIGNAL(timeout()), this, SLOT(hideNavigationSlot()));
|
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(receiveMessage(Qz::AppMessageType,bool)));
|
2013-02-09 15:44:17 +01:00
|
|
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(postLaunch()));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
void QupZilla::postLaunch()
|
|
|
|
{
|
2012-12-22 12:47:45 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-03-13 17:51:37 +01:00
|
|
|
setUpdatesEnabled(false);
|
2012-07-09 23:45:49 +02:00
|
|
|
#endif
|
2012-03-13 17:51:37 +01:00
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
loadSettings();
|
2012-01-18 18:36:10 +01:00
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2012-03-14 14:04:20 +01:00
|
|
|
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();
|
2012-03-10 13:57:50 +01:00
|
|
|
bool addTab = true;
|
2011-05-07 12:59:53 +02:00
|
|
|
QUrl startUrl;
|
2012-03-14 14:04:20 +01:00
|
|
|
|
2011-12-04 20:35:49 +01:00
|
|
|
switch (afterLaunch) {
|
|
|
|
case 0:
|
2012-09-02 11:42:41 +02:00
|
|
|
startUrl = QUrl();
|
2011-12-04 20:35:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
startUrl = QUrl("qupzilla:speeddial");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
startUrl = m_homepage;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-02-15 22:18:46 +01:00
|
|
|
switch (m_windowType) {
|
2012-01-21 23:19:38 +01:00
|
|
|
case Qz::BW_FirstAppWindow:
|
2012-08-21 20:28:38 +02:00
|
|
|
if (mApp->isStartingAfterCrash()) {
|
|
|
|
addTab = true;
|
|
|
|
startUrl = QUrl("qupzilla:restore");
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-08-21 20:28:38 +02:00
|
|
|
else if (afterLaunch == 3 && mApp->restoreManager()) {
|
|
|
|
addTab = !mApp->restoreStateSlot(this, mApp->restoreManager()->restoreData());
|
2012-03-14 14:04:20 +01:00
|
|
|
}
|
2011-11-03 18:51:46 +01:00
|
|
|
break;
|
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
case Qz::BW_MacFirstWindow:
|
2013-03-17 10:32:39 +01:00
|
|
|
#ifdef Q_OS_MAC
|
2013-03-16 10:36:29 +01:00
|
|
|
QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions()));
|
|
|
|
#endif
|
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
|
|
|
|
2012-09-06 11:39:42 +02:00
|
|
|
show();
|
|
|
|
|
2011-05-07 12:59:53 +02:00
|
|
|
if (!m_startingUrl.isEmpty()) {
|
2013-02-19 11:56:47 +01:00
|
|
|
startUrl = m_startingUrl;
|
2011-05-07 12:59:53 +02:00
|
|
|
addTab = true;
|
|
|
|
}
|
|
|
|
|
2011-12-05 19:54:17 +01:00
|
|
|
if (addTab) {
|
2012-07-13 11:04:14 +02:00
|
|
|
QNetworkRequest request(startUrl);
|
|
|
|
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
|
|
|
|
|
|
|
|
m_tabWidget->addView(request, Qz::NT_CleanSelectedTabAtTheEnd);
|
2011-12-05 19:54:17 +01:00
|
|
|
|
2012-09-04 12:42:45 +02:00
|
|
|
if (startUrl.isEmpty() || startUrl.toString() == QLatin1String("qupzilla:speeddial")) {
|
2011-12-05 19:54:17 +01:00
|
|
|
locationBar()->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 22:18:46 +01:00
|
|
|
if (m_tabWidget->getTabBar()->normalTabsCount() <= 0 && m_windowType != Qz::BW_OtherRestoredWindow) {
|
2012-01-21 23:19:38 +01:00
|
|
|
//Something went really wrong .. add one tab
|
2012-07-13 11:04:14 +02:00
|
|
|
QNetworkRequest request(m_homepage);
|
|
|
|
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
|
|
|
|
|
|
|
|
m_tabWidget->addView(request, Qz::NT_SelectedTabAtTheEnd);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
aboutToHideEditMenu();
|
2011-12-05 19:54:17 +01:00
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
// fill menus even if user don't call them
|
2013-02-18 21:03:46 +01:00
|
|
|
if (m_windowType == Qz::BW_FirstAppWindow) {
|
2013-02-07 14:01:01 +01:00
|
|
|
aboutToShowBookmarksMenu();
|
|
|
|
aboutToShowHistoryMostMenu();
|
|
|
|
aboutToShowHistoryRecentMenu();
|
|
|
|
aboutToShowEncodingMenu();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-05 13:16:34 +01:00
|
|
|
mApp->plugins()->emitMainWindowCreated(this);
|
2011-05-07 12:59:53 +02:00
|
|
|
emit startingCompleted();
|
2012-03-13 17:51:37 +01:00
|
|
|
|
|
|
|
m_isStarting = false;
|
2012-07-04 19:13:44 +02:00
|
|
|
QMainWindow::setWindowTitle(m_lastWindowTitle);
|
2012-03-13 17:51:37 +01:00
|
|
|
|
|
|
|
setUpdatesEnabled(true);
|
2013-03-16 10:36:29 +01:00
|
|
|
raise();
|
|
|
|
activateWindow();
|
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 {
|
2012-02-01 20:31:51 +01:00
|
|
|
if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) {
|
|
|
|
setGeometry(QRect(20, 20, 800, 550));
|
|
|
|
}
|
|
|
|
|
2013-02-15 22:18:46 +01:00
|
|
|
if (m_windowType == 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();
|
2012-04-04 18:48:54 +02:00
|
|
|
settings.endGroup();
|
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);
|
2012-08-30 10:46:58 +02:00
|
|
|
|
2013-02-11 13:08:11 +01:00
|
|
|
m_navigationContainer = new NavigationContainer(this);
|
2013-02-09 13:00:45 +01:00
|
|
|
QVBoxLayout* l = new QVBoxLayout(m_navigationContainer);
|
|
|
|
l->setContentsMargins(0, 0, 0, 0);
|
|
|
|
l->setSpacing(0);
|
|
|
|
l->addWidget(m_navigationBar);
|
|
|
|
l->addWidget(m_bookmarksToolbar);
|
|
|
|
m_navigationContainer->setLayout(l);
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
m_mainSplitter->addWidget(m_tabWidget);
|
2013-02-09 13:00:45 +01:00
|
|
|
m_mainLayout->addWidget(m_navigationContainer);
|
2011-09-11 19:15:06 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::setupMenu()
|
|
|
|
{
|
2013-02-08 15:21:00 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
if (menuBar()) {
|
|
|
|
setupMacMenu();
|
|
|
|
setupOtherActions();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mApp->macMenuReceiver()->setMenuBar(new QMenuBar(0));
|
|
|
|
}
|
2013-02-09 14:08:12 +01:00
|
|
|
#else
|
|
|
|
setMenuBar(new MenuBar(this));
|
2013-02-08 15:21:00 +01:00
|
|
|
#endif
|
|
|
|
|
2012-01-08 11:38:15 +01:00
|
|
|
// Standard actions - needed on Mac to be placed correctly in "application" menu
|
2013-03-08 21:01:55 +01:00
|
|
|
m_actionAbout = new QAction(QIcon::fromTheme("help-about"), tr("&About QupZilla"), 0);
|
2012-01-08 11:38:15 +01:00
|
|
|
m_actionAbout->setMenuRole(QAction::AboutRole);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionAbout, SIGNAL(triggered()), MENU_RECEIVER, 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);
|
2012-02-01 15:37:45 +01:00
|
|
|
m_actionPreferences->setShortcut(QKeySequence(QKeySequence::Preferences));
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionPreferences, SIGNAL(triggered()), MENU_RECEIVER, 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);
|
2012-12-10 12:47:28 +01:00
|
|
|
QKeySequence quitSequence = QKeySequence(QKeySequence::Quit);
|
2012-12-22 12:47:45 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-12-10 12:47:28 +01:00
|
|
|
// QKeySequence::Quit returns a non-empty sequence on X11 only when running Gnome or Kde
|
2012-12-10 14:59:12 +01:00
|
|
|
if (quitSequence.isEmpty()) {
|
2012-12-10 12:47:28 +01:00
|
|
|
quitSequence = QKeySequence(Qt::CTRL + Qt::Key_Q);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
m_actionQuit->setShortcut(quitSequence);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionQuit, SIGNAL(triggered()), MENU_RECEIVER, SLOT(quitApp()));
|
2012-01-08 11:38:15 +01:00
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
/*************
|
|
|
|
* File Menu *
|
|
|
|
*************/
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuFile = new QMenu(tr("&File"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuFile->addAction(QIcon(":/icons/menu/new-tab.png"), tr("New Tab"), MENU_RECEIVER, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T"));
|
2013-03-08 21:01:55 +01:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("window-new"), tr("&New Window"), MENU_RECEIVER, SLOT(newWindow()))->setShortcut(QKeySequence("Ctrl+N"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-open-remote"), tr("Open Location"), MENU_RECEIVER, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L"));
|
2013-03-16 20:50:35 +01:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File..."), MENU_RECEIVER, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O"));
|
2013-02-07 15:01:25 +01:00
|
|
|
m_menuFile->addAction(tr("Close Tab"), MENU_RECEIVER, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_actionCloseWindow = m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), MENU_RECEIVER, SLOT(closeWindow()));
|
2011-12-17 15:09:17 +01:00
|
|
|
m_actionCloseWindow->setShortcut(QKeySequence("Ctrl+Shift+W"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuFile->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), MENU_RECEIVER, SLOT(savePage()))->setShortcut(QKeySequence("Ctrl+S"));
|
|
|
|
m_menuFile->addAction(tr("Save Page Screen"), MENU_RECEIVER, SLOT(savePageScreen()));
|
|
|
|
m_menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), MENU_RECEIVER, SLOT(sendLink()));
|
|
|
|
m_menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), MENU_RECEIVER, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P"));
|
2011-11-06 17:01:23 +01:00
|
|
|
m_menuFile->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuFile->addAction(tr("Import bookmarks..."), MENU_RECEIVER, SLOT(showBookmarkImport()));
|
2012-01-08 11:38:15 +01:00
|
|
|
m_menuFile->addAction(m_actionQuit);
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_MAC // Add standard actions to File Menu (as it won't be ever cleared) and Mac menubar should move them to "application" menu
|
2012-01-08 11:38:15 +01:00
|
|
|
m_menuFile->addAction(m_actionAbout);
|
|
|
|
m_menuFile->addAction(m_actionPreferences);
|
|
|
|
#endif
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuFile, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowFileMenu()));
|
|
|
|
connect(m_menuFile, SIGNAL(aboutToHide()), MENU_RECEIVER, SLOT(aboutToHideFileMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
/*************
|
|
|
|
* Edit Menu *
|
|
|
|
*************/
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuEdit = new QMenu(tr("&Edit"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"), MENU_RECEIVER, SLOT(editUndo()))->setShortcut(QKeySequence("Ctrl+Z"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"), MENU_RECEIVER, SLOT(editRedo()))->setShortcut(QKeySequence("Ctrl+Shift+Z"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuEdit->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"), MENU_RECEIVER, SLOT(editCut()))->setShortcut(QKeySequence("Ctrl+X"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), MENU_RECEIVER, SLOT(editCopy()))->setShortcut(QKeySequence("Ctrl+C"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"), MENU_RECEIVER, SLOT(editPaste()))->setShortcut(QKeySequence("Ctrl+V"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuEdit->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &All"), MENU_RECEIVER, SLOT(editSelectAll()))->setShortcut(QKeySequence("Ctrl+A"));
|
|
|
|
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("&Find"), MENU_RECEIVER, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
|
2011-12-10 13:15:07 +01:00
|
|
|
m_menuEdit->addSeparator();
|
2012-12-22 12:47:45 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-01-08 11:38:15 +01:00
|
|
|
m_menuEdit->addAction(m_actionPreferences);
|
2011-12-10 13:15:07 +01:00
|
|
|
#endif
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuEdit, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowEditMenu()));
|
|
|
|
connect(m_menuEdit, SIGNAL(aboutToHide()), MENU_RECEIVER, SLOT(aboutToHideEditMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
/*************
|
|
|
|
* View Menu *
|
|
|
|
*************/
|
2011-11-01 18:16:46 +01:00
|
|
|
m_menuView = new QMenu(tr("&View"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_actionShowToolbar = new QAction(tr("&Navigation Toolbar"), MENU_RECEIVER);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowToolbar->setCheckable(true);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionShowToolbar, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(showNavigationToolbar()));
|
|
|
|
m_actionShowBookmarksToolbar = new QAction(tr("&Bookmarks Toolbar"), MENU_RECEIVER);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowBookmarksToolbar->setCheckable(true);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionShowBookmarksToolbar, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(showBookmarksToolbar()));
|
|
|
|
m_actionShowStatusbar = new QAction(tr("Sta&tus Bar"), MENU_RECEIVER);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowStatusbar->setCheckable(true);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionShowStatusbar, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(showStatusbar()));
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowMenubar = new QAction(tr("&Menu Bar"), this);
|
|
|
|
m_actionShowMenubar->setCheckable(true);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionShowMenubar, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(showMenubar()));
|
2013-02-08 15:21:00 +01:00
|
|
|
m_menuEncoding = new QMenu(this);
|
|
|
|
#else
|
|
|
|
m_menuEncoding = new QMenu(0);
|
2012-01-26 16:22:09 +01:00
|
|
|
#endif
|
2013-02-09 13:00:45 +01:00
|
|
|
m_actionTabsOnTop = new QAction(tr("&Tabs on Top"), MENU_RECEIVER);
|
|
|
|
m_actionTabsOnTop->setCheckable(true);
|
2013-02-14 19:06:38 +01:00
|
|
|
connect(m_actionTabsOnTop, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(triggerTabsOnTop(bool)));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_actionShowFullScreen = new QAction(tr("&Fullscreen"), MENU_RECEIVER);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowFullScreen->setCheckable(true);
|
2013-02-14 19:06:38 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionShowFullScreen->setShortcut(QKeySequence("F11"));
|
2013-02-14 19:06:38 +01:00
|
|
|
#else
|
|
|
|
m_actionShowFullScreen->setShortcut(QKeySequence("Ctrl+F11"));
|
|
|
|
#endif
|
2013-02-17 11:05:35 +01:00
|
|
|
connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(toggleFullScreen(bool)));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_actionStop = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), MENU_RECEIVER);
|
|
|
|
connect(m_actionStop, SIGNAL(triggered()), MENU_RECEIVER, SLOT(stop()));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_actionStop->setShortcut(QKeySequence("Esc"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_actionReload = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), MENU_RECEIVER);
|
|
|
|
connect(m_actionReload, SIGNAL(triggered()), MENU_RECEIVER, SLOT(reload()));
|
2011-09-11 19:15:06 +02:00
|
|
|
m_actionReload->setShortcut(QKeySequence("F5"));
|
2013-02-07 14:01:01 +01:00
|
|
|
QAction* actionEncoding = new QAction(tr("Character &Encoding"), MENU_RECEIVER);
|
2011-05-07 12:59:53 +02:00
|
|
|
actionEncoding->setMenu(m_menuEncoding);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuEncoding, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowEncodingMenu()));
|
|
|
|
m_actionCaretBrowsing = new QAction(tr("Enable &Caret Browsing"), MENU_RECEIVER);
|
2013-01-09 18:47:36 +01:00
|
|
|
m_actionCaretBrowsing->setVisible(false);
|
2012-12-22 13:52:46 +01:00
|
|
|
m_actionCaretBrowsing->setCheckable(true);
|
|
|
|
m_actionCaretBrowsing->setShortcut(QKeySequence("F7"));
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_actionCaretBrowsing, SIGNAL(triggered()), MENU_RECEIVER, SLOT(triggerCaretBrowsing()));
|
2013-01-09 18:47:36 +01:00
|
|
|
|
2013-01-20 12:10:28 +01:00
|
|
|
#if QTWEBKIT_FROM_2_3
|
2013-01-09 18:47:36 +01:00
|
|
|
m_actionCaretBrowsing->setVisible(true);
|
2012-12-22 13:52:46 +01:00
|
|
|
#endif
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2013-02-09 14:08:12 +01:00
|
|
|
m_toolbarsMenu = new QMenu(tr("Toolbars"));
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2013-02-09 14:08:12 +01:00
|
|
|
m_toolbarsMenu->addAction(m_actionShowMenubar);
|
2012-01-26 16:22:09 +01:00
|
|
|
#endif
|
2013-02-09 14:08:12 +01:00
|
|
|
m_toolbarsMenu->addAction(m_actionShowToolbar);
|
|
|
|
m_toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
|
|
|
|
m_toolbarsMenu->addSeparator();
|
|
|
|
m_toolbarsMenu->addAction(m_actionTabsOnTop);
|
2011-05-07 12:59:53 +02:00
|
|
|
QMenu* sidebarsMenu = new QMenu(tr("Sidebars"));
|
2012-04-01 16:36:38 +02:00
|
|
|
m_sideBarManager->setSideBarMenu(sidebarsMenu);
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2013-02-09 14:08:12 +01:00
|
|
|
m_menuView->addMenu(m_toolbarsMenu);
|
2011-05-07 12:59:53 +02:00
|
|
|
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();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), MENU_RECEIVER, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++"));
|
|
|
|
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), MENU_RECEIVER, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
|
|
|
|
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), MENU_RECEIVER, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuView->addSeparator();
|
2012-12-22 13:52:46 +01:00
|
|
|
m_menuView->addAction(m_actionCaretBrowsing);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuView->addAction(actionEncoding);
|
|
|
|
m_menuView->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_actionPageSource = m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), MENU_RECEIVER, SLOT(showSource()));
|
2013-01-26 21:58:09 +01:00
|
|
|
m_actionPageSource->setShortcut(QKeySequence("Ctrl+U"));
|
|
|
|
m_actionPageSource->setEnabled(false);
|
2011-05-07 12:59:53 +02:00
|
|
|
m_menuView->addAction(m_actionShowFullScreen);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuView, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowViewMenu()));
|
|
|
|
connect(m_menuView, SIGNAL(aboutToHide()), MENU_RECEIVER, SLOT(aboutToHideViewMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
/****************
|
|
|
|
* History Menu *
|
|
|
|
****************/
|
2012-01-26 16:22:09 +01:00
|
|
|
m_menuHistory = new Menu(tr("Hi&story"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuHistory->addAction(qIconProvider->standardIcon(QStyle::SP_ArrowBack), tr("&Back"), MENU_RECEIVER, SLOT(goBack()))->setShortcut(QKeySequence("Ctrl+Left"));
|
|
|
|
m_menuHistory->addAction(qIconProvider->standardIcon(QStyle::SP_ArrowForward), tr("&Forward"), MENU_RECEIVER, SLOT(goNext()))->setShortcut(QKeySequence("Ctrl+Right"));
|
|
|
|
m_menuHistory->addAction(qIconProvider->fromTheme("go-home"), tr("&Home"), MENU_RECEIVER, SLOT(goHome()))->setShortcut(QKeySequence("Alt+Home"));
|
|
|
|
m_menuHistory->addAction(QIcon(":/icons/menu/history.png"), tr("Show &All History"), MENU_RECEIVER, SLOT(showHistoryManager()))->setShortcut(QKeySequence("Ctrl+Shift+H"));
|
2012-01-26 16:22:09 +01:00
|
|
|
m_menuHistory->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuHistory, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowHistoryMenu()));
|
|
|
|
connect(m_menuHistory, SIGNAL(aboutToHide()), MENU_RECEIVER, SLOT(aboutToHideHistoryMenu()));
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2011-07-28 12:12:00 +02:00
|
|
|
m_menuClosedTabs = new QMenu(tr("Closed Tabs"));
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuClosedTabs, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowClosedTabsMenu()));
|
2011-07-28 12:12:00 +02:00
|
|
|
|
2012-01-23 17:30:34 +01:00
|
|
|
m_menuHistoryRecent = new Menu(tr("Recently Visited"), m_menuHistory);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuHistoryRecent, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowHistoryRecentMenu()));
|
2012-01-23 00:14:01 +01:00
|
|
|
|
2012-01-23 17:30:34 +01:00
|
|
|
m_menuHistoryMost = new Menu(tr("Most Visited"), m_menuHistory);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuHistoryMost, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowHistoryMostMenu()));
|
2012-01-23 00:14:01 +01:00
|
|
|
|
2012-01-26 16:22:09 +01:00
|
|
|
m_menuHistory->addMenu(m_menuHistoryRecent);
|
|
|
|
m_menuHistory->addMenu(m_menuHistoryMost);
|
|
|
|
m_menuHistory->addMenu(m_menuClosedTabs);
|
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
/******************
|
|
|
|
* Bookmarks Menu *
|
|
|
|
******************/
|
|
|
|
m_menuBookmarks = new Menu(tr("&Bookmarks"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuBookmarks->addAction(tr("Bookmark &This Page"), MENU_RECEIVER, SLOT(bookmarkPage()))->setShortcut(QKeySequence("Ctrl+D"));
|
|
|
|
m_menuBookmarks->addAction(tr("Bookmark &All Tabs"), MENU_RECEIVER, SLOT(bookmarkAllTabs()));
|
|
|
|
m_menuBookmarks->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("Organize &Bookmarks"), MENU_RECEIVER, SLOT(showBookmarksManager()))->setShortcut(QKeySequence("Ctrl+Shift+O"));
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuBookmarks->addSeparator();
|
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuBookmarks, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowBookmarksMenu()));
|
|
|
|
connect(m_menuBookmarks, SIGNAL(menuMiddleClicked(Menu*)), MENU_RECEIVER, SLOT(loadFolderBookmarks(Menu*)));
|
2012-02-01 15:37:45 +01:00
|
|
|
|
|
|
|
/**************
|
|
|
|
* Tools Menu *
|
|
|
|
**************/
|
|
|
|
m_menuTools = new QMenu(tr("&Tools"));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuTools->addAction(tr("&Web Search"), MENU_RECEIVER, SLOT(webSearch()))->setShortcut(QKeySequence("Ctrl+K"));
|
|
|
|
m_actionPageInfo = m_menuTools->addAction(QIcon::fromTheme("dialog-information"), tr("Page &Info"), MENU_RECEIVER, SLOT(showPageInfo()));
|
2013-01-26 21:58:09 +01:00
|
|
|
m_actionPageInfo->setShortcut(QKeySequence("Ctrl+I"));
|
|
|
|
m_actionPageInfo->setEnabled(false);
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuTools->addSeparator();
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuTools->addAction(tr("&Download Manager"), MENU_RECEIVER, SLOT(showDownloadManager()))->setShortcut(QKeySequence("Ctrl+Y"));
|
|
|
|
m_menuTools->addAction(tr("&Cookies Manager"), MENU_RECEIVER, SLOT(showCookieManager()));
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuTools->addAction(tr("&AdBlock"), AdBlockManager::instance(), SLOT(showDialog()));
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuTools->addAction(QIcon(":/icons/menu/rss.png"), tr("RSS &Reader"), MENU_RECEIVER, SLOT(showRSSManager()));
|
|
|
|
m_menuTools->addAction(tr("Web In&spector"), MENU_RECEIVER, SLOT(showWebInspector()))->setShortcut(QKeySequence("Ctrl+Shift+I"));
|
|
|
|
m_menuTools->addAction(QIcon::fromTheme("edit-clear"), tr("Clear Recent &History"), MENU_RECEIVER, SLOT(showClearPrivateData()))->setShortcut(QKeySequence("Ctrl+Shift+Del"));
|
|
|
|
m_actionPrivateBrowsing = new QAction(tr("&Private Browsing"), MENU_RECEIVER);
|
2012-02-01 15:37:45 +01:00
|
|
|
m_actionPrivateBrowsing->setShortcut(QKeySequence("Ctrl+Shift+P"));
|
2012-06-26 11:49:39 +02:00
|
|
|
m_actionPrivateBrowsing->setVisible(!mApp->isPrivateSession());
|
|
|
|
connect(m_actionPrivateBrowsing, SIGNAL(triggered(bool)), mApp, SLOT(startPrivateBrowsing()));
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuTools->addAction(m_actionPrivateBrowsing);
|
|
|
|
m_menuTools->addSeparator();
|
2012-12-22 12:47:45 +01:00
|
|
|
#if !defined(QZ_WS_X11) && !defined(Q_OS_MAC)
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuTools->addAction(m_actionPreferences);
|
|
|
|
#endif
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(m_menuTools, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowToolsMenu()));
|
|
|
|
connect(m_menuTools, SIGNAL(aboutToHide()), MENU_RECEIVER, SLOT(aboutToHideToolsMenu()));
|
2012-02-01 15:37:45 +01:00
|
|
|
|
|
|
|
/*************
|
|
|
|
* Help Menu *
|
|
|
|
*************/
|
|
|
|
m_menuHelp = new QMenu(tr("&Help"));
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuHelp->addAction(QIcon(":/icons/menu/qt.png"), tr("About &Qt"), qApp, SLOT(aboutQt()));
|
|
|
|
m_menuHelp->addAction(m_actionAbout);
|
|
|
|
m_menuHelp->addSeparator();
|
|
|
|
#endif
|
2013-03-08 21:01:55 +01:00
|
|
|
QAction* infoAction = new QAction(QIcon::fromTheme("help-contents"), tr("Information about application"), m_menuHelp);
|
2012-02-01 15:37:45 +01:00
|
|
|
infoAction->setData(QUrl("qupzilla:about"));
|
|
|
|
infoAction->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(infoAction, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrlInNewTab()));
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuHelp->addAction(infoAction);
|
2013-02-07 14:01:01 +01:00
|
|
|
m_menuHelp->addAction(tr("Configuration Information"), MENU_RECEIVER, SLOT(loadActionUrlInNewTab()))->setData(QUrl("qupzilla:config"));
|
|
|
|
m_menuHelp->addAction(tr("Report &Issue"), MENU_RECEIVER, SLOT(loadActionUrlInNewTab()))->setData(QUrl("qupzilla:reportbug"));
|
2012-02-01 15:37:45 +01:00
|
|
|
|
|
|
|
/************
|
|
|
|
* Menu Bar *
|
|
|
|
************/
|
|
|
|
menuBar()->addMenu(m_menuFile);
|
|
|
|
menuBar()->addMenu(m_menuEdit);
|
|
|
|
menuBar()->addMenu(m_menuView);
|
2012-01-26 16:22:09 +01:00
|
|
|
menuBar()->addMenu(m_menuHistory);
|
|
|
|
menuBar()->addMenu(m_menuBookmarks);
|
|
|
|
menuBar()->addMenu(m_menuTools);
|
|
|
|
menuBar()->addMenu(m_menuHelp);
|
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
/*****************
|
|
|
|
* Other Actions *
|
|
|
|
*****************/
|
2013-02-08 15:21:00 +01:00
|
|
|
setupOtherActions();
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC
|
2013-03-08 21:01:55 +01:00
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(0), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(1), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(3), this));
|
|
|
|
|
|
|
|
m_superMenu->addSeparator();
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(7), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(10), this));
|
|
|
|
|
|
|
|
m_superMenu->addSeparator();
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuEdit->actions().at(7), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuEdit->actions().at(8), this));
|
|
|
|
|
2013-03-11 14:32:46 +01:00
|
|
|
m_superMenu->addSeparator();
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuHistory->actions().at(3), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuBookmarks->actions().at(2), this));
|
|
|
|
|
2013-03-08 21:01:55 +01:00
|
|
|
m_superMenu->addSeparator();
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_actionPreferences, this));
|
|
|
|
|
|
|
|
m_superMenu->addSeparator();
|
2013-02-08 15:21:00 +01:00
|
|
|
m_superMenu->addMenu(m_menuView);
|
|
|
|
m_superMenu->addMenu(m_menuHistory);
|
|
|
|
m_superMenu->addMenu(m_menuBookmarks);
|
|
|
|
m_superMenu->addMenu(m_menuTools);
|
2013-03-08 21:01:55 +01:00
|
|
|
|
|
|
|
m_superMenu->addSeparator();
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_actionAbout, this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuHelp->actions().at(3), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuHelp->actions().at(4), this));
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_menuHelp->actions().at(5), this));
|
|
|
|
|
|
|
|
m_superMenu->addSeparator();
|
|
|
|
m_superMenu->addAction(new ActionCopy(m_actionQuit, this));
|
2013-03-16 14:57:08 +01:00
|
|
|
#else
|
|
|
|
ActionCopy* copyActionPrivateBrowsing = new ActionCopy(m_actionPrivateBrowsing);
|
|
|
|
copyActionPrivateBrowsing->setText(copyActionPrivateBrowsing->text().remove(QLatin1Char('&')));
|
|
|
|
mApp->macDockMenu()->addAction(copyActionPrivateBrowsing);
|
|
|
|
mApp->macDockMenu()->addAction(m_menuFile->actions().at(1));
|
|
|
|
mApp->macDockMenu()->addAction(m_menuFile->actions().at(0));
|
2013-02-08 15:21:00 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::setupOtherActions()
|
|
|
|
{
|
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"));
|
2013-02-07 15:01:25 +01:00
|
|
|
connect(m_actionRestoreTab, SIGNAL(triggered()), MENU_RECEIVER, SLOT(restoreClosedTab()));
|
2011-05-07 12:59:53 +02:00
|
|
|
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);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(reloadByPassCacheAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(reloadByPassCache()));
|
|
|
|
connect(reloadByPassCacheAction2, SIGNAL(activated()), MENU_RECEIVER, 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);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(reloadAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(reload()));
|
2012-01-16 17:31:15 +01:00
|
|
|
|
2012-01-08 11:12:04 +01:00
|
|
|
QShortcut* backAction = new QShortcut(QKeySequence("Alt+Left"), this);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(backAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(goBack()));
|
2012-01-08 11:12:04 +01:00
|
|
|
|
|
|
|
QShortcut* forwardAction = new QShortcut(QKeySequence("Alt+Right"), this);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(forwardAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(goNext()));
|
2011-05-08 14:12:35 +02:00
|
|
|
|
2012-03-03 21:35:02 +01:00
|
|
|
QShortcut* openLocationAction = new QShortcut(QKeySequence("Alt+D"), this);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(openLocationAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(openLocation()));
|
2012-03-03 21:35:02 +01:00
|
|
|
|
2013-01-22 11:30:09 +01:00
|
|
|
QShortcut* closeTabAction = new QShortcut(QKeySequence("Ctrl+F4"), this);
|
2013-02-07 15:01:25 +01:00
|
|
|
connect(closeTabAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(closeTab()));
|
2013-01-22 11:30:09 +01: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();
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (QAction* action, actions) {
|
2011-11-06 17:01:23 +01:00
|
|
|
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
|
|
|
}
|
2013-02-08 15:21:00 +01:00
|
|
|
}
|
2011-05-07 12:59:53 +02:00
|
|
|
|
2013-02-08 15:21:00 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
void QupZilla::setupMacMenu()
|
|
|
|
{
|
|
|
|
// menus
|
|
|
|
m_menuFile = menuBar()->actions().at(0)->menu();
|
|
|
|
m_menuEdit = menuBar()->actions().at(1)->menu();
|
|
|
|
m_menuView = menuBar()->actions().at(2)->menu();
|
|
|
|
m_menuHistory = qobject_cast<Menu*>(menuBar()->actions().at(3)->menu());
|
|
|
|
m_menuBookmarks = qobject_cast<Menu*>(menuBar()->actions().at(4)->menu());
|
|
|
|
m_menuTools = menuBar()->actions().at(5)->menu();
|
|
|
|
m_menuHelp = menuBar()->actions().at(6)->menu();
|
|
|
|
|
2013-02-14 19:06:38 +01:00
|
|
|
m_toolbarsMenu = m_menuView->actions().at(0)->menu();
|
2013-02-08 15:21:00 +01:00
|
|
|
m_menuEncoding = m_menuView->actions().at(12)->menu();
|
|
|
|
|
|
|
|
m_menuHistoryRecent = qobject_cast<Menu*>(m_menuHistory->actions().at(5)->menu());
|
|
|
|
m_menuHistoryMost = qobject_cast<Menu*>(m_menuHistory->actions().at(6)->menu());
|
|
|
|
m_menuClosedTabs = m_menuHistory->actions().at(7)->menu();
|
|
|
|
|
|
|
|
// actions
|
|
|
|
m_actionCloseWindow = m_menuFile->actions().at(5);
|
|
|
|
m_actionQuit = m_menuFile->actions().at(13);
|
|
|
|
m_actionAbout = m_menuFile->actions().at(14);
|
|
|
|
m_actionPreferences = m_menuFile->actions().at(15);
|
|
|
|
|
|
|
|
m_actionShowToolbar = m_menuView->actions().at(0)->menu()->actions().at(0);
|
|
|
|
m_actionShowBookmarksToolbar = m_menuView->actions().at(0)->menu()->actions().at(1);
|
2013-02-14 19:06:38 +01:00
|
|
|
m_actionTabsOnTop = m_menuView->actions().at(0)->menu()->actions().at(3);
|
2013-02-08 15:21:00 +01:00
|
|
|
m_actionShowStatusbar = m_menuView->actions().at(2);
|
|
|
|
m_actionStop = m_menuView->actions().at(4);
|
|
|
|
m_actionReload = m_menuView->actions().at(5);
|
|
|
|
m_actionCaretBrowsing = m_menuView->actions().at(11);
|
|
|
|
m_actionPageSource = m_menuView->actions().at(14);
|
|
|
|
m_actionShowFullScreen = m_menuView->actions().at(15);
|
|
|
|
|
|
|
|
m_actionPageInfo = m_menuTools->actions().at(1);
|
|
|
|
m_actionPrivateBrowsing = m_menuTools->actions().at(9);
|
2011-05-07 12:59:53 +02:00
|
|
|
}
|
2013-03-16 10:36:29 +01:00
|
|
|
|
|
|
|
void QupZilla::refreshStateOfAllActions()
|
|
|
|
{
|
|
|
|
mApp->macMenuReceiver()->aboutToShowFileMenu(m_menuFile);
|
|
|
|
mApp->macMenuReceiver()->aboutToShowHistoryMenu(m_menuHistory);
|
|
|
|
mApp->macMenuReceiver()->aboutToShowBookmarksMenu(m_menuBookmarks);
|
|
|
|
mApp->macMenuReceiver()->aboutToShowViewMenu(m_menuView);
|
|
|
|
mApp->macMenuReceiver()->aboutToShowEditMenu(m_menuEdit);
|
|
|
|
mApp->macMenuReceiver()->aboutToShowToolsMenu(m_menuTools);
|
|
|
|
}
|
2013-02-08 15:21:00 +01:00
|
|
|
#endif
|
2011-05-07 12:59:53 +02:00
|
|
|
|
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-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");
|
2011-11-06 17:01:23 +01:00
|
|
|
bool showStatusBar = settings.value("showStatusBar", true).toBool();
|
2012-10-20 11:31:45 +02:00
|
|
|
bool showReloadButton = settings.value("showReloadButton", true).toBool();
|
|
|
|
bool showHomeButton = settings.value("showHomeButton", true).toBool();
|
|
|
|
bool showBackForwardButtons = settings.value("showBackForwardButtons", true).toBool();
|
|
|
|
bool showAddTabButton = settings.value("showAddTabButton", false).toBool();
|
2012-07-19 19:56:58 +02:00
|
|
|
bool showWebSearchBar = settings.value("showWebSearchBar", true).toBool();
|
2011-11-06 17:01:23 +01:00
|
|
|
bool showBookmarksToolbar = settings.value("showBookmarksToolbar", true).toBool();
|
|
|
|
bool showNavigationToolbar = settings.value("showNavigationToolbar", true).toBool();
|
|
|
|
bool showMenuBar = settings.value("showMenubar", true).toBool();
|
|
|
|
bool makeTransparent = settings.value("useTransparentBackground", false).toBool();
|
2012-01-14 11:46:06 +01:00
|
|
|
m_sideBarWidth = settings.value("SideBarWidth", 250).toInt();
|
2012-02-02 15:54:38 +01:00
|
|
|
m_webViewWidth = settings.value("WebViewWidth", 2000).toInt();
|
2012-02-04 19:43:43 +01:00
|
|
|
const QString &activeSideBar = settings.value("SideBar", "None").toString();
|
2013-03-01 22:53:50 +01:00
|
|
|
|
|
|
|
// Make sure both menubar and navigationbar are not hidden
|
|
|
|
// Fixes #781
|
|
|
|
if (!showNavigationToolbar) {
|
|
|
|
showMenuBar = true;
|
|
|
|
settings.setValue("showMenubar", true);
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
settings.endGroup();
|
2012-11-28 11:27:30 +01:00
|
|
|
|
|
|
|
settings.beginGroup("Shortcuts");
|
|
|
|
m_useTabNumberShortcuts = settings.value("useTabNumberShortcuts", true).toBool();
|
|
|
|
m_useSpeedDialNumberShortcuts = settings.value("useSpeedDialNumberShortcuts", true).toBool();
|
|
|
|
settings.endGroup();
|
2011-03-29 20:30:05 +02:00
|
|
|
|
2012-12-02 00:59:17 +01:00
|
|
|
m_adblockIcon->setEnabled(settings.value("AdBlock/enabled", true).toBool());
|
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);
|
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2013-03-08 21:01:55 +01:00
|
|
|
m_navigationBar->setSuperMenuVisible(!showMenuBar);
|
2012-01-26 16:22:09 +01:00
|
|
|
#endif
|
2012-10-20 11:31:45 +02:00
|
|
|
m_navigationBar->buttonReloadStop()->setVisible(showReloadButton);
|
|
|
|
m_navigationBar->buttonHome()->setVisible(showHomeButton);
|
|
|
|
m_navigationBar->buttonBack()->setVisible(showBackForwardButtons);
|
|
|
|
m_navigationBar->buttonNext()->setVisible(showBackForwardButtons);
|
2012-07-19 19:56:58 +02:00
|
|
|
m_navigationBar->searchLine()->setVisible(showWebSearchBar);
|
2012-10-20 11:31:45 +02:00
|
|
|
m_navigationBar->buttonAddTab()->setVisible(showAddTabButton);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-04-30 16:33:14 +02:00
|
|
|
m_sideBarManager->showSideBar(activeSideBar, false);
|
2011-04-28 18:31:48 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
//Private browsing
|
2012-06-26 11:49:39 +02:00
|
|
|
m_privateBrowsing->setVisible(mApp->isPrivateSession());
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2011-12-26 21:23:21 +01:00
|
|
|
if (m_usingTransparentBackground && !makeTransparent) {
|
2012-08-30 10:46:58 +02:00
|
|
|
QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0);
|
2011-12-26 21:23:21 +01:00
|
|
|
QtWin::enableBlurBehindWindow(this, false);
|
2013-03-03 21:04:21 +01:00
|
|
|
QtWin::enableBlurBehindWindow(m_tabWidget->getTabBar(), false);
|
2011-12-26 21:23:21 +01:00
|
|
|
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
|
2012-12-22 12:47:45 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2011-03-02 16:57:41 +01:00
|
|
|
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
|
2012-08-30 10:46:58 +02:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2011-03-02 16:57:41 +01:00
|
|
|
if (QtWin::isCompositionEnabled()) {
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
2011-12-26 21:23:21 +01:00
|
|
|
|
|
|
|
m_usingTransparentBackground = true;
|
2012-08-30 10:46:58 +02:00
|
|
|
|
2013-03-07 17:26:21 +01:00
|
|
|
QtWin::enableBlurBehindWindow(m_tabWidget->getTabBar(), true);
|
2012-08-30 10:46:58 +02:00
|
|
|
applyBlurToMainWindow();
|
2013-01-19 23:22:30 +01:00
|
|
|
update();
|
|
|
|
|
2012-08-30 10:46:58 +02:00
|
|
|
//install event filter
|
|
|
|
menuBar()->installEventFilter(this);
|
|
|
|
m_navigationBar->installEventFilter(this);
|
|
|
|
m_bookmarksToolbar->installEventFilter(this);
|
|
|
|
statusBar()->installEventFilter(this);
|
2013-02-16 13:32:33 +01:00
|
|
|
m_navigationContainer->installEventFilter(this);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2012-08-30 10:46:58 +02:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 17:01:08 +01:00
|
|
|
void QupZilla::goNext()
|
|
|
|
{
|
|
|
|
weView()->forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::goBack()
|
|
|
|
{
|
|
|
|
weView()->back();
|
|
|
|
}
|
|
|
|
|
|
|
|
QMenuBar* QupZilla::menuBar() const
|
|
|
|
{
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_MAC
|
2013-02-08 15:21:00 +01:00
|
|
|
return mApp->macMenuReceiver()->menuBar();
|
2012-02-01 17:01:08 +01:00
|
|
|
#else
|
|
|
|
return QMainWindow::menuBar();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2013-02-15 22:18:46 +01:00
|
|
|
Qz::BrowserWindow QupZilla::windowType() const
|
|
|
|
{
|
|
|
|
return m_windowType;
|
|
|
|
}
|
|
|
|
|
2013-02-09 14:08:12 +01:00
|
|
|
QWidget* QupZilla::navigationContainer() const
|
2013-02-09 13:00:45 +01:00
|
|
|
{
|
|
|
|
if (!qzSettings->tabsOnTop) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_navigationContainer;
|
|
|
|
}
|
|
|
|
|
2013-02-09 14:08:12 +01:00
|
|
|
void QupZilla::popupToolbarsMenu(const QPoint &pos)
|
|
|
|
{
|
|
|
|
aboutToShowViewMenu();
|
|
|
|
m_toolbarsMenu->exec(pos);
|
|
|
|
aboutToHideViewMenu();
|
|
|
|
}
|
|
|
|
|
2011-09-17 11:13:38 +02:00
|
|
|
void QupZilla::setWindowTitle(const QString &t)
|
|
|
|
{
|
2012-03-13 17:51:37 +01:00
|
|
|
QString title = t;
|
|
|
|
|
2012-06-26 11:49:39 +02:00
|
|
|
if (mApp->isPrivateSession()) {
|
2012-03-13 17:51:37 +01:00
|
|
|
title.append(tr(" (Private Browsing)"));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-03-13 17:51:37 +01:00
|
|
|
|
|
|
|
if (m_isStarting) {
|
|
|
|
m_lastWindowTitle = title;
|
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-03-13 17:51:37 +01:00
|
|
|
|
|
|
|
QMainWindow::setWindowTitle(title);
|
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();
|
|
|
|
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:
|
2013-02-08 14:07:51 +01:00
|
|
|
setBookmarksMenuChanged(true);
|
2011-07-30 17:57:14 +02:00
|
|
|
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()
|
|
|
|
{
|
2013-02-07 14:01:01 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2011-12-17 15:09:17 +01:00
|
|
|
m_actionCloseWindow->setEnabled(mApp->windowCount() > 1);
|
2013-02-07 14:01:01 +01:00
|
|
|
#endif
|
2011-12-17 15:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToHideFileMenu()
|
|
|
|
{
|
|
|
|
m_actionCloseWindow->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::aboutToShowBookmarksMenu()
|
|
|
|
{
|
2013-02-08 14:07:51 +01:00
|
|
|
if (!bookmarksMenuChanged()) {
|
|
|
|
if (menuBookmarksAction()) {
|
|
|
|
menuBookmarksAction()->setVisible(m_bookmarksToolbar->isVisible());
|
2011-12-08 18:11:05 +01:00
|
|
|
}
|
2011-07-30 17:57:14 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2013-02-08 14:07:51 +01:00
|
|
|
setBookmarksMenuChanged(false);
|
2011-07-30 17:57:14 +02:00
|
|
|
|
2012-02-04 18:45:59 +01:00
|
|
|
while (m_menuBookmarks->actions().count() != 4) {
|
2012-02-01 15:37:45 +01:00
|
|
|
QAction* act = m_menuBookmarks->actions().at(4);
|
|
|
|
if (act->menu()) {
|
|
|
|
act->menu()->clear();
|
|
|
|
}
|
|
|
|
m_menuBookmarks->removeAction(act);
|
|
|
|
delete act;
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
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();
|
2012-02-04 19:43:43 +01:00
|
|
|
const QUrl &url = query.value(1).toUrl();
|
2012-04-22 20:51:28 +02:00
|
|
|
const QIcon &icon = qIconProvider->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);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(act, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrl()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), MENU_RECEIVER, 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();
|
2012-02-04 19:43:43 +01:00
|
|
|
const QUrl &url = query.value(1).toUrl();
|
2012-04-22 20:51:28 +02:00
|
|
|
const QIcon &icon = qIconProvider->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);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(act, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrl()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), MENU_RECEIVER, 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()) {
|
2012-01-23 17:30:34 +01:00
|
|
|
menuBookmarks->addAction(tr("Empty"))->setEnabled(false);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2013-02-08 14:07:51 +01:00
|
|
|
setMenuBookmarksAction(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()) {
|
2012-02-04 19:43:43 +01:00
|
|
|
const 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;
|
2012-02-04 19:43:43 +01:00
|
|
|
query2.prepare("SELECT title, url, icon FROM bookmarks WHERE folder=?");
|
|
|
|
query2.addBindValue(folderName);
|
|
|
|
query2.exec();
|
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();
|
2012-02-04 19:43:43 +01:00
|
|
|
const QUrl &url = query2.value(1).toUrl();
|
2012-04-22 20:51:28 +02:00
|
|
|
const QIcon &icon = qIconProvider->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);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(act, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrl()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), MENU_RECEIVER, 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()) {
|
2012-01-23 17:30:34 +01:00
|
|
|
tempFolder->addAction(tr("Empty"))->setEnabled(false);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
m_menuBookmarks->addMenu(tempFolder);
|
|
|
|
}
|
|
|
|
|
2012-09-08 19:42:40 +02:00
|
|
|
m_menuBookmarks->addSeparator();
|
|
|
|
|
|
|
|
query.exec("SELECT title, url, icon FROM bookmarks WHERE folder='unsorted'");
|
|
|
|
while (query.next()) {
|
|
|
|
QString title = query.value(0).toString();
|
|
|
|
const QUrl &url = query.value(1).toUrl();
|
|
|
|
const QIcon &icon = qIconProvider->iconFromImage(QImage::fromData(query.value(2).toByteArray()));
|
|
|
|
if (title.length() > 40) {
|
|
|
|
title.truncate(40);
|
|
|
|
title += "..";
|
|
|
|
}
|
|
|
|
|
|
|
|
Action* act = new Action(icon, title);
|
|
|
|
act->setData(url);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(act, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrl()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), MENU_RECEIVER, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2012-09-08 19:42:40 +02:00
|
|
|
m_menuBookmarks->addAction(act);
|
|
|
|
}
|
|
|
|
|
2013-02-08 14:07:51 +01:00
|
|
|
menuBookmarksAction()->setVisible(m_bookmarksToolbar->isVisible());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-01-26 16:22:09 +01:00
|
|
|
void QupZilla::aboutToShowHistoryMenu()
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2012-04-04 13:21:53 +02:00
|
|
|
TabbedWebView* view = weView();
|
|
|
|
if (!view) {
|
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
|
|
|
|
2012-04-04 13:21:53 +02:00
|
|
|
m_menuHistory->actions().at(0)->setEnabled(view->history()->canGoBack());
|
|
|
|
m_menuHistory->actions().at(1)->setEnabled(view->history()->canGoForward());
|
2011-07-28 12:12:00 +02:00
|
|
|
}
|
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
void QupZilla::aboutToHideHistoryMenu()
|
|
|
|
{
|
|
|
|
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;
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (const 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
|
|
|
}
|
2013-02-07 15:01:25 +01:00
|
|
|
m_menuClosedTabs->addAction(_iconForUrl(tab.url), title, MENU_RECEIVER, 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 {
|
2013-02-07 15:01:25 +01:00
|
|
|
m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), MENU_RECEIVER, SLOT(restoreAllClosedTabs()));
|
|
|
|
m_menuClosedTabs->addAction(tr("Clear list"), MENU_RECEIVER, SLOT(clearClosedTabsList()));
|
2011-07-28 21:59:56 +02:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-01-23 00:14:01 +01:00
|
|
|
void QupZilla::aboutToShowHistoryRecentMenu()
|
|
|
|
{
|
|
|
|
m_menuHistoryRecent->clear();
|
|
|
|
QSqlQuery query;
|
2012-01-23 17:30:34 +01:00
|
|
|
query.exec("SELECT title, url FROM history ORDER BY date DESC LIMIT 15");
|
|
|
|
while (query.next()) {
|
2012-02-04 19:43:43 +01:00
|
|
|
const QUrl &url = query.value(1).toUrl();
|
2012-01-23 17:30:34 +01:00
|
|
|
QString title = query.value(0).toString();
|
|
|
|
if (title.length() > 40) {
|
|
|
|
title.truncate(40);
|
|
|
|
title += "..";
|
2012-01-23 00:14:01 +01:00
|
|
|
}
|
2012-01-23 17:30:34 +01:00
|
|
|
|
|
|
|
Action* act = new Action(_iconForUrl(url), title);
|
|
|
|
act->setData(url);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(act, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrl()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), MENU_RECEIVER, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2012-01-23 17:30:34 +01:00
|
|
|
m_menuHistoryRecent->addAction(act);
|
2012-01-23 00:14:01 +01:00
|
|
|
}
|
2012-01-23 17:30:34 +01:00
|
|
|
|
|
|
|
if (m_menuHistoryRecent->isEmpty()) {
|
2012-01-23 00:14:01 +01:00
|
|
|
m_menuHistoryRecent->addAction(tr("Empty"))->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToShowHistoryMostMenu()
|
|
|
|
{
|
|
|
|
m_menuHistoryMost->clear();
|
|
|
|
|
2013-02-26 12:56:11 +01:00
|
|
|
const QVector<HistoryEntry> &mostList = mApp->history()->mostVisited(10);
|
2012-01-23 17:30:34 +01:00
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (const HistoryEntry &entry, mostList) {
|
2012-01-23 17:30:34 +01:00
|
|
|
QString title = entry.title;
|
|
|
|
if (title.length() > 40) {
|
|
|
|
title.truncate(40);
|
|
|
|
title += "..";
|
2012-01-23 00:14:01 +01:00
|
|
|
}
|
2012-01-23 17:30:34 +01:00
|
|
|
|
|
|
|
Action* act = new Action(_iconForUrl(entry.url), title);
|
|
|
|
act->setData(entry.url);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(act, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrl()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), MENU_RECEIVER, SLOT(loadActionUrlInNewNotSelectedTab()));
|
2012-01-23 17:30:34 +01:00
|
|
|
m_menuHistoryMost->addAction(act);
|
2012-01-23 00:14:01 +01:00
|
|
|
}
|
2012-01-23 17:30:34 +01:00
|
|
|
|
2012-01-24 19:12:31 +01:00
|
|
|
if (m_menuHistoryMost->isEmpty()) {
|
2012-01-23 00:14:01 +01:00
|
|
|
m_menuHistoryMost->addAction(tr("Empty"))->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void QupZilla::aboutToShowViewMenu()
|
|
|
|
{
|
2011-09-11 19:15:06 +02:00
|
|
|
m_actionShowToolbar->setChecked(m_navigationBar->isVisible());
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2011-07-19 22:49:42 +02:00
|
|
|
m_actionShowMenubar->setChecked(menuBar()->isVisible());
|
2013-02-08 14:07:51 +01:00
|
|
|
#else
|
|
|
|
m_sideBarManager->setSideBarMenu(m_menuView->actions().at(1)->menu());
|
2012-01-26 16:22:09 +01:00
|
|
|
#endif
|
2013-02-08 14:07:51 +01:00
|
|
|
|
2011-07-19 22:49:42 +02:00
|
|
|
m_actionShowStatusbar->setChecked(statusBar()->isVisible());
|
|
|
|
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
|
2013-02-09 13:00:45 +01:00
|
|
|
m_actionTabsOnTop->setChecked(qzSettings->tabsOnTop);
|
2012-12-22 13:52:46 +01:00
|
|
|
|
2013-01-26 21:58:09 +01:00
|
|
|
m_actionPageSource->setEnabled(true);
|
|
|
|
|
2013-01-25 19:52:30 +01:00
|
|
|
#if QTWEBKIT_FROM_2_3
|
2012-12-22 13:52:46 +01:00
|
|
|
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
|
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:58:09 +01:00
|
|
|
void QupZilla::aboutToHideViewMenu()
|
|
|
|
{
|
2013-02-09 01:17:58 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2013-01-26 21:58:09 +01:00
|
|
|
m_actionPageSource->setEnabled(false);
|
2013-02-09 01:17:58 +01:00
|
|
|
#endif
|
2013-01-26 21:58:09 +01:00
|
|
|
}
|
|
|
|
|
2011-12-17 15:09:17 +01:00
|
|
|
void QupZilla::aboutToShowEditMenu()
|
2011-11-27 15:43:54 +01:00
|
|
|
{
|
2012-02-01 15:37:45 +01:00
|
|
|
WebView* view = weView();
|
|
|
|
|
|
|
|
m_menuEdit->actions().at(0)->setEnabled(view->pageAction(QWebPage::Undo)->isEnabled());
|
|
|
|
m_menuEdit->actions().at(1)->setEnabled(view->pageAction(QWebPage::Redo)->isEnabled());
|
|
|
|
// Separator
|
|
|
|
m_menuEdit->actions().at(3)->setEnabled(view->pageAction(QWebPage::Cut)->isEnabled());
|
|
|
|
m_menuEdit->actions().at(4)->setEnabled(view->pageAction(QWebPage::Copy)->isEnabled());
|
|
|
|
m_menuEdit->actions().at(5)->setEnabled(view->pageAction(QWebPage::Paste)->isEnabled());
|
|
|
|
// Separator
|
|
|
|
m_menuEdit->actions().at(7)->setEnabled(view->pageAction(QWebPage::SelectAll)->isEnabled());
|
2011-11-27 15:43:54 +01:00
|
|
|
}
|
|
|
|
|
2011-12-17 15:09:17 +01:00
|
|
|
void QupZilla::aboutToHideEditMenu()
|
2011-11-27 15:43:54 +01:00
|
|
|
{
|
2013-02-09 01:17:58 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (QAction* act, m_menuEdit->actions()) {
|
2011-11-27 15:43:54 +01:00
|
|
|
act->setEnabled(false);
|
|
|
|
}
|
2013-02-09 01:17:58 +01:00
|
|
|
#endif
|
2011-11-27 15:43:54 +01:00
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
m_menuEdit->actions().at(8)->setEnabled(true);
|
|
|
|
m_actionPreferences->setEnabled(true);
|
2011-11-27 15:43:54 +01:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:58:09 +01:00
|
|
|
void QupZilla::aboutToShowToolsMenu()
|
|
|
|
{
|
|
|
|
m_actionPageInfo->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::aboutToHideToolsMenu()
|
|
|
|
{
|
2013-02-09 01:17:58 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2013-01-26 21:58:09 +01:00
|
|
|
m_actionPageInfo->setEnabled(false);
|
2013-02-09 01:17:58 +01:00
|
|
|
#endif
|
2013-01-26 21:58:09 +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);
|
2012-02-04 19:43:43 +01:00
|
|
|
const QString &activeCodec = mApp->webSettings()->defaultTextEncoding();
|
2011-03-17 20:46:53 +01:00
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (const QByteArray &name, available) {
|
2012-12-22 12:03:54 +01:00
|
|
|
QTextCodec* codec = QTextCodec::codecForName(name);
|
|
|
|
if (codec && codec->aliases().contains(name)) {
|
2011-03-17 20:46:53 +01:00
|
|
|
continue;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-09-04 12:42:45 +02:00
|
|
|
|
|
|
|
const QString nameString = QString::fromUtf8(name);
|
|
|
|
|
|
|
|
QAction* action = new QAction(nameString, 0);
|
|
|
|
action->setData(nameString);
|
2011-03-17 20:46:53 +01:00
|
|
|
action->setCheckable(true);
|
2013-02-07 14:01:01 +01:00
|
|
|
connect(action, SIGNAL(triggered()), MENU_RECEIVER, SLOT(changeEncoding()));
|
2012-09-04 12:42:45 +02:00
|
|
|
if (activeCodec.compare(nameString, 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
|
|
|
|
2012-09-04 12:42:45 +02:00
|
|
|
if (nameString.startsWith(QLatin1String("ISO"))) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuISO->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-09-04 12:42:45 +02:00
|
|
|
else if (nameString.startsWith(QLatin1String("UTF"))) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuUTF->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-09-04 12:42:45 +02:00
|
|
|
else if (nameString.startsWith(QLatin1String("windows"))) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuWindows->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-09-04 12:42:45 +02:00
|
|
|
else if (nameString.startsWith(QLatin1String("Iscii"))) {
|
2011-03-17 20:46:53 +01:00
|
|
|
menuIscii->addAction(action);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-09-04 12:42:45 +02:00
|
|
|
else if (nameString == QLatin1String("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
|
|
|
}
|
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
void QupZilla::changeEncoding(QObject* obj)
|
2011-03-17 20:46:53 +01:00
|
|
|
{
|
2013-02-07 14:01:01 +01:00
|
|
|
if (!obj) {
|
|
|
|
obj = sender();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(obj)) {
|
2012-03-30 12:02:49 +02:00
|
|
|
const QString &encoding = action->data().toString();
|
|
|
|
mApp->webSettings()->setDefaultTextEncoding(encoding);
|
|
|
|
|
|
|
|
Settings settings;
|
|
|
|
settings.setValue("Web-Browser-Settings/DefaultEncoding", encoding);
|
|
|
|
|
2011-03-17 20:46:53 +01:00
|
|
|
reload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-22 13:52:46 +01:00
|
|
|
void QupZilla::triggerCaretBrowsing()
|
|
|
|
{
|
2013-01-20 12:10:28 +01:00
|
|
|
#if QTWEBKIT_FROM_2_3
|
2012-12-22 13:52:46 +01:00
|
|
|
bool enable = !mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled);
|
|
|
|
|
|
|
|
Settings settings;
|
|
|
|
settings.beginGroup("Web-Browser-Settings");
|
|
|
|
settings.setValue("CaretBrowsing", enable);
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
mApp->webSettings()->setAttribute(QWebSettings::CaretBrowsingEnabled, enable);
|
|
|
|
#endif
|
2013-01-09 18:47:36 +01:00
|
|
|
}
|
2012-12-22 13:52:46 +01:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
void QupZilla::editUndo()
|
2011-11-27 15:43:54 +01:00
|
|
|
{
|
2012-02-01 15:37:45 +01:00
|
|
|
weView()->triggerPageAction(QWebPage::Undo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::editRedo()
|
|
|
|
{
|
|
|
|
weView()->triggerPageAction(QWebPage::Redo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::editCut()
|
|
|
|
{
|
|
|
|
weView()->triggerPageAction(QWebPage::Cut);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::editCopy()
|
|
|
|
{
|
|
|
|
weView()->triggerPageAction(QWebPage::Copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::editPaste()
|
|
|
|
{
|
|
|
|
weView()->triggerPageAction(QWebPage::Paste);
|
2011-11-27 15:43:54 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 15:37:45 +01:00
|
|
|
void QupZilla::editSelectAll()
|
2012-01-21 23:19:38 +01:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-02-09 13:00:45 +01:00
|
|
|
void QupZilla::loadActionUrl(QObject* obj)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2013-02-07 14:01:01 +01:00
|
|
|
if (!obj) {
|
|
|
|
obj = sender();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(obj)) {
|
2011-03-02 16:57:41 +01:00
|
|
|
loadAddress(action->data().toUrl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
void QupZilla::loadActionUrlInNewTab(QObject* obj)
|
2011-09-19 20:49:39 +02:00
|
|
|
{
|
2013-02-07 14:01:01 +01:00
|
|
|
if (!obj) {
|
|
|
|
obj = sender();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(obj)) {
|
2012-02-07 18:37:44 +01:00
|
|
|
m_tabWidget->addView(action->data().toUrl(), Qz::NT_SelectedTabAtTheEnd);
|
2011-09-19 20:49:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-07 14:01:01 +01:00
|
|
|
void QupZilla::loadActionUrlInNewNotSelectedTab(QObject* obj)
|
2011-12-16 20:17:17 +01:00
|
|
|
{
|
2013-02-07 14:01:01 +01:00
|
|
|
if (!obj) {
|
|
|
|
obj = sender();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(obj)) {
|
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
|
|
|
{
|
2012-02-04 19:43:43 +01:00
|
|
|
const QString &folder = BookmarksModel::fromTranslatedFolder(menu->title());
|
2011-12-20 18:58:42 +01:00
|
|
|
if (folder.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (const 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)
|
|
|
|
{
|
2012-01-22 16:28:11 +01:00
|
|
|
weView()->setFocus();
|
2011-07-31 00:50:40 +02:00
|
|
|
weView()->load(url);
|
|
|
|
}
|
|
|
|
|
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();
|
2012-02-17 18:55:34 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
m->show();
|
2012-02-17 18:55:34 +01:00
|
|
|
m->raise();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-04-30 16:33:14 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
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);
|
2013-01-22 19:04:22 +01:00
|
|
|
QzTools::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
|
|
|
}
|
|
|
|
|
2012-04-01 16:36:38 +02:00
|
|
|
SideBar* QupZilla::addSideBar()
|
2011-09-11 19:15:06 +02:00
|
|
|
{
|
2012-01-18 18:36:10 +01:00
|
|
|
if (m_sideBar) {
|
2012-04-01 16:36:38 +02:00
|
|
|
return m_sideBar.data();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2012-04-01 16:36:38 +02:00
|
|
|
m_sideBar = new SideBar(m_sideBarManager, this);
|
2011-09-11 19:15:06 +02:00
|
|
|
|
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);
|
2012-04-01 16:36:38 +02:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2012-08-30 10:46:58 +02:00
|
|
|
if (QtWin::isCompositionEnabled()) {
|
|
|
|
applyBlurToMainWindow();
|
|
|
|
m_sideBar.data()->installEventFilter(this);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-01 16:36:38 +02:00
|
|
|
return m_sideBar.data();
|
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()
|
|
|
|
{
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
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());
|
2013-03-08 21:01:55 +01:00
|
|
|
m_navigationBar->setSuperMenuVisible(!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());
|
2012-01-26 16:22:09 +01:00
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
2012-02-04 18:45:59 +01:00
|
|
|
void QupZilla::showWebInspector(bool toggle)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2012-01-18 18:36:10 +01:00
|
|
|
if (m_webInspectorDock) {
|
2012-02-04 18:45:59 +01:00
|
|
|
if (toggle) {
|
2012-03-16 16:57:24 +01:00
|
|
|
m_webInspectorDock.data()->toggleVisibility();
|
2012-02-04 18:45:59 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
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());
|
2012-08-30 10:46:58 +02:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2012-08-30 10:46:58 +02:00
|
|
|
if (QtWin::isCompositionEnabled()) {
|
|
|
|
applyBlurToMainWindow();
|
|
|
|
m_webInspectorDock.data()->installEventFilter(this);
|
|
|
|
}
|
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
2013-02-09 13:00:45 +01:00
|
|
|
void QupZilla::triggerTabsOnTop(bool enable)
|
|
|
|
{
|
|
|
|
if (enable) {
|
|
|
|
m_tabWidget->showNavigationBar(m_navigationContainer);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_mainLayout->insertWidget(0, m_navigationContainer);
|
|
|
|
}
|
|
|
|
|
2013-02-22 18:31:44 +01:00
|
|
|
Settings settings;
|
|
|
|
settings.setValue("Browser-Tabs-Settings/TabsOnTop", enable);
|
2013-02-09 13:00:45 +01:00
|
|
|
qzSettings->tabsOnTop = enable;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2013-01-25 19:52:30 +01:00
|
|
|
SearchToolBar* search = searchToolBar();
|
|
|
|
if (search) {
|
|
|
|
search->setWebView(view);
|
|
|
|
}
|
|
|
|
|
2012-01-14 09:54:51 +01:00
|
|
|
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-06-27 18:29:00 +02:00
|
|
|
m_progressBar->setValue(view->loadingProgress());
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-21 20:28:38 +02:00
|
|
|
void QupZilla::restoreWindowState(const RestoreManager::WindowData &d)
|
2012-03-13 17:51:37 +01:00
|
|
|
{
|
2012-09-06 11:39:42 +02:00
|
|
|
restoreState(d.windowState);
|
2012-08-21 20:28:38 +02:00
|
|
|
m_tabWidget->restoreState(d.tabsState, d.currentTab);
|
2012-03-13 17:51:37 +01:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2013-01-25 23:49:46 +01:00
|
|
|
m_tabWidget->addView(QUrl(), Qz::NT_SelectedNewEmptyTab, true);
|
2012-01-21 23:19:38 +01:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2013-01-25 19:52:30 +01:00
|
|
|
SearchToolBar* toolBar = searchToolBar();
|
2013-02-09 13:00:45 +01:00
|
|
|
const int searchPos = qzSettings->tabsOnTop ? 1 : 2;
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2013-01-25 19:52:30 +01:00
|
|
|
if (!toolBar) {
|
|
|
|
toolBar = new SearchToolBar(weView(), this);
|
2013-02-09 13:00:45 +01:00
|
|
|
m_mainLayout->insertWidget(searchPos, toolBar);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-08-02 16:19:20 +02:00
|
|
|
|
2013-01-25 19:52:30 +01:00
|
|
|
toolBar->focusSearchLine();
|
2012-08-30 10:46:58 +02:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2012-08-30 10:46:58 +02:00
|
|
|
if (QtWin::isCompositionEnabled()) {
|
|
|
|
applyBlurToMainWindow();
|
2013-01-28 10:52:55 +01:00
|
|
|
toolBar->installEventFilter(this);
|
2012-08-30 10:46:58 +02:00
|
|
|
}
|
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::openFile()
|
|
|
|
{
|
2012-04-06 10:15:17 +02:00
|
|
|
const QString &fileTypes = QString("%1(*.html *.htm *.shtml *.shtm *.xhtml);;"
|
2012-03-10 23:24:54 +01:00
|
|
|
"%2(*.png *.jpg *.jpeg *.bmp *.gif *.svg *.tiff);;"
|
|
|
|
"%3(*.txt);;"
|
2012-03-04 18:30:34 +01:00
|
|
|
"%4(*.*)").arg(tr("HTML files"), tr("Image files"), tr("Text files"), tr("All files"));
|
|
|
|
|
|
|
|
const QString &filePath = QFileDialog::getOpenFileName(this, tr("Open file..."), QDir::homePath(), fileTypes);
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-02-09 15:44:17 +01:00
|
|
|
bool QupZilla::fullScreenNavigationVisible() const
|
2011-04-22 07:45:15 +02:00
|
|
|
{
|
2013-02-09 15:44:17 +01:00
|
|
|
return m_navigationContainer->isVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::showNavigationWithFullScreen()
|
|
|
|
{
|
|
|
|
if (m_hideNavigationTimer->isActive()) {
|
|
|
|
m_hideNavigationTimer->stop();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-09 15:44:17 +01:00
|
|
|
m_navigationContainer->show();
|
|
|
|
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::hideNavigationWithFullScreen()
|
|
|
|
{
|
|
|
|
if (!m_hideNavigationTimer->isActive()) {
|
|
|
|
m_hideNavigationTimer->start();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2013-02-09 15:44:17 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-09 15:44:17 +01:00
|
|
|
void QupZilla::hideNavigationSlot()
|
|
|
|
{
|
|
|
|
TabbedWebView* view = weView();
|
2013-02-24 10:57:58 +01:00
|
|
|
bool mouseInView = view && view->underMouse();
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-09 15:44:17 +01:00
|
|
|
if (isFullScreen() && mouseInView) {
|
|
|
|
m_navigationContainer->hide();
|
|
|
|
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(false);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-04-22 07:45:15 +02:00
|
|
|
}
|
|
|
|
|
2013-02-17 11:05:35 +01:00
|
|
|
bool QupZilla::event(QEvent* event)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2013-02-17 11:05:35 +01:00
|
|
|
switch (event->type()) {
|
|
|
|
case QEvent::WindowStateChange: {
|
|
|
|
QWindowStateChangeEvent* ev = static_cast<QWindowStateChangeEvent*>(event);
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-17 11:05:35 +01:00
|
|
|
if (!(ev->oldState() & Qt::WindowFullScreen) && windowState() & Qt::WindowFullScreen) {
|
|
|
|
// Enter fullscreen
|
|
|
|
m_windowStates = ev->oldState();
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-17 11:05:35 +01:00
|
|
|
m_menuBarVisible = menuBar()->isVisible();
|
|
|
|
m_statusBarVisible = statusBar()->isVisible();
|
|
|
|
menuBar()->hide();
|
|
|
|
statusBar()->hide();
|
|
|
|
m_navigationContainer->hide();
|
|
|
|
m_tabWidget->getTabBar()->hide();
|
2012-09-21 07:13:27 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2013-03-08 21:01:55 +01:00
|
|
|
m_navigationBar->setSuperMenuVisible(false);
|
2012-09-21 07:13:27 +02:00
|
|
|
#endif
|
2013-02-17 11:05:35 +01:00
|
|
|
m_hideNavigationTimer->stop();
|
|
|
|
m_actionShowFullScreen->setChecked(true);
|
|
|
|
m_navigationBar->buttonExitFullscreen()->setVisible(true);
|
|
|
|
emit setWebViewMouseTracking(true);
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-02-17 11:05:35 +01:00
|
|
|
if (m_usingTransparentBackground) {
|
|
|
|
QtWin::extendFrameIntoClientArea(this, 0, 0, 0 , 0);
|
|
|
|
QtWin::enableBlurBehindWindow(this, false);
|
|
|
|
}
|
2012-08-20 21:44:29 +02:00
|
|
|
#endif
|
2013-02-17 11:05:35 +01:00
|
|
|
}
|
|
|
|
else if (ev->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) {
|
|
|
|
// Leave fullscreen
|
|
|
|
setWindowState(m_windowStates);
|
|
|
|
|
|
|
|
menuBar()->setVisible(m_menuBarVisible);
|
|
|
|
statusBar()->setVisible(m_statusBarVisible);
|
|
|
|
m_navigationContainer->show();
|
|
|
|
m_tabWidget->showTabBar();
|
2013-02-26 12:58:04 +01:00
|
|
|
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
|
2012-09-21 07:13:27 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2013-03-08 21:01:55 +01:00
|
|
|
m_navigationBar->setSuperMenuVisible(!m_menuBarVisible);
|
2012-09-21 07:13:27 +02:00
|
|
|
#endif
|
2013-02-17 11:05:35 +01:00
|
|
|
m_hideNavigationTimer->stop();
|
|
|
|
m_actionShowFullScreen->setChecked(false);
|
|
|
|
m_navigationBar->buttonExitFullscreen()->setVisible(false);
|
|
|
|
emit setWebViewMouseTracking(false);
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-02-17 11:05:35 +01:00
|
|
|
if (m_usingTransparentBackground) {
|
|
|
|
applyBlurToMainWindow(true);
|
|
|
|
}
|
2012-08-20 21:44:29 +02:00
|
|
|
#endif
|
2013-02-17 11:05:35 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-17 11:05:35 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2013-02-17 11:05:35 +01:00
|
|
|
return QMainWindow::event(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::toggleFullScreen(bool make)
|
|
|
|
{
|
|
|
|
if (make) {
|
|
|
|
showFullScreen();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
showNormal();
|
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::savePage()
|
|
|
|
{
|
2012-08-14 18:53:55 +02:00
|
|
|
weView()->savePageAs();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-12-16 20:17:17 +01:00
|
|
|
void QupZilla::sendLink()
|
|
|
|
{
|
2012-04-01 18:57:42 +02:00
|
|
|
weView()->sendPageByMail();
|
2011-12-16 20:17:17 +01:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-05 13:16:34 +01:00
|
|
|
if (mApp->plugins()->processKeyPress(Qz::ON_QupZilla, this, event)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-05 17:13:08 +01:00
|
|
|
int number = -1;
|
2013-02-17 11:05:35 +01:00
|
|
|
TabbedWebView* view = weView();
|
2012-02-05 17:13:08 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Back:
|
2013-02-17 11:05:35 +01:00
|
|
|
if (view) {
|
|
|
|
weView()->back();
|
|
|
|
event->accept();
|
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_Forward:
|
2013-02-17 11:05:35 +01:00
|
|
|
if (view) {
|
|
|
|
weView()->forward();
|
|
|
|
event->accept();
|
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_Stop:
|
2013-02-17 11:05:35 +01:00
|
|
|
if (view) {
|
|
|
|
weView()->stop();
|
|
|
|
event->accept();
|
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_Refresh:
|
2013-02-17 11:05:35 +01:00
|
|
|
if (view) {
|
|
|
|
weView()->reload();
|
|
|
|
event->accept();
|
|
|
|
}
|
2011-11-06 12:05:16 +01:00
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_HomePage:
|
|
|
|
goHome();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_Favorites:
|
|
|
|
showBookmarksManager();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_Search:
|
|
|
|
searchOnPage();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
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;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_History:
|
|
|
|
showHistoryManager();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_AddFavorite:
|
|
|
|
bookmarkPage();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_News:
|
|
|
|
showRSSManager();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
case Qt::Key_Tools:
|
|
|
|
showPreferences();
|
|
|
|
event->accept();
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-07 19:56:53 +01:00
|
|
|
case Qt::Key_Tab:
|
|
|
|
if (event->modifiers() == Qt::ControlModifier) {
|
2012-03-22 17:19:10 +01:00
|
|
|
m_tabWidget->nextTab();
|
|
|
|
event->accept();
|
2011-11-07 19:56:53 +01:00
|
|
|
}
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-07 19:56:53 +01:00
|
|
|
case Qt::Key_Backtab:
|
|
|
|
if (event->modifiers() == (Qt::ControlModifier + Qt::ShiftModifier)) {
|
2012-03-22 17:19:10 +01:00
|
|
|
m_tabWidget->previousTab();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::Key_PageDown:
|
|
|
|
if (event->modifiers() == Qt::ControlModifier) {
|
|
|
|
m_tabWidget->nextTab();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::Key_PageUp:
|
|
|
|
if (event->modifiers() == Qt::ControlModifier) {
|
|
|
|
m_tabWidget->previousTab();
|
|
|
|
event->accept();
|
2011-11-07 19:56:53 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-11-06 12:05:16 +01:00
|
|
|
|
2012-07-14 11:46:53 +02:00
|
|
|
case Qt::Key_Equal:
|
2013-02-17 11:05:35 +01:00
|
|
|
if (view && event->modifiers() == Qt::ControlModifier) {
|
2012-07-14 11:46:53 +02:00
|
|
|
weView()->zoomIn();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-01-26 21:58:09 +01:00
|
|
|
case Qt::Key_I:
|
|
|
|
if (event->modifiers() == Qt::ControlModifier) {
|
|
|
|
showPageInfo();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::Key_U:
|
|
|
|
if (event->modifiers() == Qt::ControlModifier) {
|
|
|
|
showSource();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_1:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 1;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_2:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 2;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_3:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 3;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_4:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 4;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_5:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 5;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_6:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 6;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_7:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 7;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
case Qt::Key_8:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 8;
|
2012-02-05 16:00:23 +01:00
|
|
|
break;
|
|
|
|
case Qt::Key_9:
|
2012-02-05 17:13:08 +01:00
|
|
|
number = 9;
|
|
|
|
break;
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2011-11-06 12:05:16 +01:00
|
|
|
default:
|
2012-02-05 17:13:08 +01:00
|
|
|
break;
|
2011-11-06 12:05:16 +01:00
|
|
|
}
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2012-02-05 17:13:08 +01:00
|
|
|
if (number != -1) {
|
2012-11-28 11:27:30 +01:00
|
|
|
if (event->modifiers() & Qt::AltModifier && m_useTabNumberShortcuts) {
|
2012-02-05 17:13:08 +01:00
|
|
|
if (number == 9) {
|
|
|
|
number = m_tabWidget->count();
|
|
|
|
}
|
|
|
|
m_tabWidget->setCurrentIndex(number - 1);
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 11:27:30 +01:00
|
|
|
if (event->modifiers() & Qt::ControlModifier && m_useSpeedDialNumberShortcuts) {
|
2012-02-05 17:13:08 +01:00
|
|
|
const QUrl &url = mApp->plugins()->speedDial()->urlForShortcut(number - 1);
|
|
|
|
if (url.isValid()) {
|
|
|
|
loadAddress(url);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-05 16:00:23 +01:00
|
|
|
|
|
|
|
QMainWindow::keyPressEvent(event);
|
2011-11-06 12:05:16 +01:00
|
|
|
}
|
|
|
|
|
2012-03-05 13:16:34 +01:00
|
|
|
void QupZilla::keyReleaseEvent(QKeyEvent* event)
|
|
|
|
{
|
|
|
|
if (mApp->plugins()->processKeyRelease(Qz::ON_QupZilla, this, event)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMainWindow::keyReleaseEvent(event);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-08-14 12:35:24 +02:00
|
|
|
Settings settings;
|
|
|
|
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();
|
|
|
|
bool askOnClose = settings.value("Browser-Tabs-Settings/AskOnClosing", true).toBool();
|
|
|
|
|
|
|
|
if (afterLaunch == 3 && mApp->windowCount() == 1) {
|
|
|
|
askOnClose = false;
|
|
|
|
}
|
|
|
|
|
2012-09-08 19:28:47 +02:00
|
|
|
if (askOnClose && m_tabWidget->normalTabsCount() > 1) {
|
2012-08-14 12:35:24 +02:00
|
|
|
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, this);
|
|
|
|
dialog.setText(tr("There are still %1 open tabs and your session won't be stored. \nAre you sure to quit QupZilla?").arg(m_tabWidget->count()));
|
|
|
|
dialog.setCheckBoxText(tr("Don't ask again"));
|
|
|
|
dialog.setWindowTitle(tr("There are still open tabs"));
|
|
|
|
dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
|
|
|
|
|
|
|
|
if (dialog.exec() != QDialog::Accepted) {
|
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog.isChecked()) {
|
|
|
|
settings.setValue("Browser-Tabs-Settings/AskOnClosing", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-31 21:27:52 +01:00
|
|
|
m_isClosing = true;
|
2011-03-29 19:55:21 +02:00
|
|
|
mApp->saveStateSlot();
|
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_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
|
|
|
}
|
2013-03-16 10:36:29 +01:00
|
|
|
#else
|
|
|
|
QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions()));
|
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();
|
|
|
|
}
|
|
|
|
|
2013-01-25 19:52:30 +01:00
|
|
|
SearchToolBar* QupZilla::searchToolBar()
|
|
|
|
{
|
|
|
|
SearchToolBar* toolBar = 0;
|
2013-02-09 13:00:45 +01:00
|
|
|
const int searchPos = qzSettings->tabsOnTop ? 1 : 2;
|
2013-01-25 19:52:30 +01:00
|
|
|
|
2013-02-09 13:00:45 +01:00
|
|
|
if (m_mainLayout->count() == searchPos + 1) {
|
|
|
|
toolBar = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(searchPos)->widget());
|
2013-01-25 19:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return toolBar;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (WebTab* tab, m_tabWidget->allTabs()) {
|
2012-01-14 11:46:06 +01:00
|
|
|
tab->disconnectObjects();
|
|
|
|
tab->view()->disconnectObjects();
|
2012-04-03 20:23:15 +02:00
|
|
|
tab->view()->page()->disconnectObjects();
|
2012-01-10 18:31:38 +01:00
|
|
|
}
|
2012-01-22 15:15:43 +01:00
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (const QPointer<QWidget> &pointer, m_deleteOnCloseWidgets) {
|
2012-01-22 15:15:43 +01:00
|
|
|
if (pointer) {
|
|
|
|
pointer.data()->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
2012-03-05 13:16:34 +01:00
|
|
|
|
|
|
|
mApp->plugins()->emitMainWindowDeleted(this);
|
2012-01-10 18:31:38 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 17:01:08 +01:00
|
|
|
void QupZilla::closeWindow()
|
|
|
|
{
|
2013-02-07 14:01:01 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
close();
|
|
|
|
#else
|
2012-02-01 17:01:08 +01:00
|
|
|
if (mApp->windowCount() > 1) {
|
|
|
|
close();
|
|
|
|
}
|
2013-02-07 14:01:01 +01:00
|
|
|
#endif
|
2012-02-01 17:01:08 +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-07-04 19:13:44 +02:00
|
|
|
if (!mApp->isPrivateSession()) {
|
|
|
|
Settings settings;
|
|
|
|
settings.beginGroup("Browser-View-Settings");
|
|
|
|
settings.setValue("WindowMaximised", windowState().testFlag(Qt::WindowMaximized));
|
|
|
|
settings.setValue("LocationBarWidth", m_navigationBar->splitter()->sizes().at(0));
|
|
|
|
settings.setValue("WebSearchBarWidth", m_navigationBar->splitter()->sizes().at(1));
|
|
|
|
settings.setValue("SideBarWidth", m_sideBarWidth);
|
|
|
|
settings.setValue("WebViewWidth", m_webViewWidth);
|
2013-02-09 15:47:06 +01:00
|
|
|
|
|
|
|
if (!isFullScreen()) {
|
|
|
|
settings.setValue("WindowGeometry", saveGeometry());
|
|
|
|
}
|
2012-07-04 19:13:44 +02:00
|
|
|
settings.endGroup();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-09-06 11:39:42 +02:00
|
|
|
mApp->quitApplication();
|
2011-03-05 13:16:13 +01:00
|
|
|
return true;
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2013-02-07 15:01:25 +01:00
|
|
|
void QupZilla::closeTab()
|
|
|
|
{
|
|
|
|
m_tabWidget->closeTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::restoreClosedTab(QObject* obj)
|
|
|
|
{
|
|
|
|
if (!obj) {
|
|
|
|
obj = sender();
|
|
|
|
}
|
|
|
|
m_tabWidget->restoreClosedTab(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::restoreAllClosedTabs()
|
|
|
|
{
|
|
|
|
m_tabWidget->restoreAllClosedTabs();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::clearClosedTabsList()
|
|
|
|
{
|
|
|
|
m_tabWidget->clearClosedTabsList();
|
|
|
|
}
|
|
|
|
|
2013-02-08 14:07:51 +01:00
|
|
|
bool QupZilla::bookmarksMenuChanged()
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
return mApp->macMenuReceiver()->bookmarksMenuChanged();
|
|
|
|
#else
|
|
|
|
return m_bookmarksMenuChanged;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::setBookmarksMenuChanged(bool changed)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
mApp->macMenuReceiver()->setBookmarksMenuChanged(changed);
|
|
|
|
#else
|
|
|
|
m_bookmarksMenuChanged = changed;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction* QupZilla::menuBookmarksAction()
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
return mApp->macMenuReceiver()->menuBookmarksAction();
|
|
|
|
#else
|
|
|
|
return m_menuBookmarksAction;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::setMenuBookmarksAction(QAction* action)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
mApp->macMenuReceiver()->setMenuBookmarksAction(action);
|
|
|
|
#else
|
|
|
|
m_menuBookmarksAction = action;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-09-06 11:39:42 +02:00
|
|
|
QByteArray QupZilla::saveState(int version) const
|
|
|
|
{
|
2012-12-22 15:01:55 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-09-06 11:39:42 +02:00
|
|
|
QByteArray data;
|
|
|
|
QDataStream stream(&data, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
stream << QMainWindow::saveState(version);
|
|
|
|
stream << getCurrentVirtualDesktop();
|
|
|
|
|
|
|
|
return data;
|
|
|
|
#else
|
|
|
|
return QMainWindow::saveState(version);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QupZilla::restoreState(const QByteArray &state, int version)
|
|
|
|
{
|
2012-12-22 15:01:55 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-09-06 11:39:42 +02:00
|
|
|
QByteArray windowState;
|
|
|
|
int desktopId = -1;
|
|
|
|
|
|
|
|
QDataStream stream(state);
|
|
|
|
stream >> windowState;
|
|
|
|
stream >> desktopId;
|
|
|
|
|
|
|
|
moveToVirtualDesktop(desktopId);
|
|
|
|
|
|
|
|
return QMainWindow::restoreState(windowState, version);
|
|
|
|
#else
|
2012-09-07 20:31:55 +02:00
|
|
|
return QMainWindow::restoreState(state, version);
|
2012-09-06 11:39:42 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-22 15:01:55 +01:00
|
|
|
#ifdef QZ_WS_X11
|
2012-09-06 11:39:42 +02:00
|
|
|
int QupZilla::getCurrentVirtualDesktop() const
|
|
|
|
{
|
2013-01-22 19:04:22 +01:00
|
|
|
Display* display = static_cast<Display*>(QzTools::X11Display(this));
|
2012-09-06 11:39:42 +02:00
|
|
|
Atom actual_type;
|
|
|
|
int actual_format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytes;
|
|
|
|
unsigned long* data;
|
|
|
|
|
|
|
|
Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
|
|
|
if (net_wm_desktop == None) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int status = XGetWindowProperty(display, winId(), net_wm_desktop, 0, 1,
|
|
|
|
False, XA_CARDINAL, &actual_type, &actual_format,
|
|
|
|
&nitems, &bytes, (unsigned char**) &data);
|
|
|
|
|
|
|
|
if (status != Success || data == NULL) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int desktop = *data;
|
|
|
|
XFree(data);
|
|
|
|
|
|
|
|
return desktop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QupZilla::moveToVirtualDesktop(int desktopId)
|
|
|
|
{
|
|
|
|
// Don't move when window is already visible or it is first app window
|
2013-02-15 22:18:46 +01:00
|
|
|
if (desktopId < 0 || isVisible() || m_windowType == Qz::BW_FirstAppWindow) {
|
2012-09-06 11:39:42 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:04:22 +01:00
|
|
|
Display* display = static_cast<Display*>(QzTools::X11Display(this));
|
2012-09-06 11:39:42 +02:00
|
|
|
|
|
|
|
Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
|
|
|
if (net_wm_desktop == None) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-04 23:50:20 +01:00
|
|
|
// Fixes issue when the property wasn't set on some X servers
|
2012-12-22 15:01:55 +01:00
|
|
|
// hmmm does it?
|
|
|
|
//setVisible(true);
|
2012-11-04 23:50:20 +01:00
|
|
|
|
2012-09-06 11:39:42 +02:00
|
|
|
XChangeProperty(display, winId(), net_wm_desktop, XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (unsigned char*) &desktopId, 1L);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-01-19 23:22:30 +01:00
|
|
|
#if (QT_VERSION < 0x050000)
|
2012-08-31 15:19:07 +02:00
|
|
|
bool QupZilla::winEvent(MSG* message, long* result)
|
2012-08-30 10:46:58 +02:00
|
|
|
{
|
2013-01-19 23:22:30 +01:00
|
|
|
#else
|
|
|
|
bool QupZilla::nativeEvent(const QByteArray &eventType, void* _message, long* result)
|
|
|
|
{
|
|
|
|
Q_UNUSED(eventType)
|
|
|
|
MSG* message = static_cast<MSG*>(_message);
|
|
|
|
#endif
|
2012-08-30 10:46:58 +02:00
|
|
|
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
|
|
|
|
Settings settings;
|
|
|
|
settings.beginGroup("Browser-View-Settings");
|
|
|
|
m_usingTransparentBackground = settings.value("useTransparentBackground", false).toBool();
|
|
|
|
settings.endGroup();
|
|
|
|
if (m_usingTransparentBackground && QtWin::isCompositionEnabled()) {
|
|
|
|
setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0);
|
|
|
|
QTimer::singleShot(0, this, SLOT(applyBlurToMainWindow()));
|
|
|
|
|
|
|
|
//install event filter
|
|
|
|
menuBar()->installEventFilter(this);
|
|
|
|
m_navigationBar->installEventFilter(this);
|
|
|
|
m_bookmarksToolbar->installEventFilter(this);
|
|
|
|
statusBar()->installEventFilter(this);
|
|
|
|
|
|
|
|
if (m_sideBar) {
|
|
|
|
m_sideBar.data()->installEventFilter(this);
|
|
|
|
}
|
|
|
|
|
2013-02-09 13:00:45 +01:00
|
|
|
SearchToolBar* search = searchToolBar();
|
|
|
|
if (search) {
|
|
|
|
search->installEventFilter(this);
|
2012-08-30 10:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_webInspectorDock) {
|
|
|
|
m_webInspectorDock.data()->installEventFilter(this);
|
|
|
|
}
|
|
|
|
|
2012-08-31 15:19:07 +02:00
|
|
|
if (isVisible()) {
|
2012-08-30 10:46:58 +02:00
|
|
|
hide();
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
setUpdatesEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
2013-01-19 23:22:30 +01:00
|
|
|
#if (QT_VERSION < 0x050000)
|
2012-08-30 10:46:58 +02:00
|
|
|
return QMainWindow::winEvent(message, result);
|
2013-01-19 23:22:30 +01:00
|
|
|
#else
|
|
|
|
return QMainWindow::nativeEvent(eventType, _message, result);
|
|
|
|
#endif
|
2012-08-30 10:46:58 +02:00
|
|
|
}
|
|
|
|
|
2013-03-16 19:46:22 +01:00
|
|
|
void QupZilla::paintEvent(QPaintEvent* event)
|
|
|
|
{
|
|
|
|
if (m_usingTransparentBackground && !m_actionShowFullScreen->isChecked()) {
|
|
|
|
QPainter p(this);
|
|
|
|
p.setCompositionMode(QPainter::CompositionMode_Clear);
|
|
|
|
p.fillRect(event->rect(), QColor(0, 0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMainWindow::paintEvent(event);
|
|
|
|
}
|
|
|
|
|
2012-08-30 10:46:58 +02:00
|
|
|
void QupZilla::applyBlurToMainWindow(bool force)
|
|
|
|
{
|
2013-02-22 23:11:33 +01:00
|
|
|
if (isClosing()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-31 15:19:07 +02:00
|
|
|
if (!force && (m_actionShowFullScreen->isChecked() || !m_usingTransparentBackground)) {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-30 10:46:58 +02:00
|
|
|
int topMargin = 0;
|
|
|
|
int bottomMargin = 1;
|
|
|
|
int rightMargin = 1;
|
|
|
|
int leftMargin = 1;
|
|
|
|
|
|
|
|
if (m_sideBar) {
|
2012-08-31 15:19:07 +02:00
|
|
|
if (isRightToLeft()) {
|
2012-08-30 10:46:58 +02:00
|
|
|
rightMargin += m_sideBar.data()->width() + m_mainSplitter->handleWidth();
|
2012-08-31 15:19:07 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-08-30 10:46:58 +02:00
|
|
|
leftMargin += m_sideBar.data()->width() + m_mainSplitter->handleWidth();
|
2012-08-31 15:19:07 +02:00
|
|
|
}
|
2012-08-30 10:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
topMargin += menuBar()->isVisible() ? menuBar()->height() : 0;
|
|
|
|
topMargin += m_navigationBar->isVisible() ? m_navigationBar->height() : 0;
|
|
|
|
topMargin += m_bookmarksToolbar->isVisible() ? m_bookmarksToolbar->height() : 0;
|
|
|
|
topMargin += m_tabWidget->getTabBar()->height();
|
|
|
|
|
2013-02-09 13:00:45 +01:00
|
|
|
SearchToolBar* search = searchToolBar();
|
|
|
|
if (search) {
|
|
|
|
bottomMargin += search->height();
|
2012-08-30 10:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bottomMargin += statusBar()->isVisible() ? statusBar()->height() : 0;
|
|
|
|
|
|
|
|
if (m_webInspectorDock) {
|
|
|
|
bottomMargin += m_webInspectorDock.data()->isVisible()
|
2012-08-31 15:19:07 +02:00
|
|
|
? m_webInspectorDock.data()->height()
|
|
|
|
+ m_webInspectorDock.data()->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent)
|
|
|
|
: 0;
|
2012-08-30 10:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QtWin::extendFrameIntoClientArea(this, leftMargin, topMargin, rightMargin, bottomMargin);
|
|
|
|
}
|
|
|
|
|
2012-08-31 15:19:07 +02:00
|
|
|
bool QupZilla::eventFilter(QObject* object, QEvent* event)
|
2012-08-30 10:46:58 +02:00
|
|
|
{
|
|
|
|
switch (event->type()) {
|
|
|
|
case QEvent::Hide:
|
2013-02-16 13:32:33 +01:00
|
|
|
if (object == m_navigationContainer) {
|
|
|
|
m_navigationBar->removeEventFilter(this);
|
|
|
|
m_bookmarksToolbar->removeEventFilter(this);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QEvent::Show:
|
|
|
|
if (object == m_navigationContainer) {
|
|
|
|
m_navigationBar->installEventFilter(this);
|
|
|
|
m_bookmarksToolbar->installEventFilter(this);
|
|
|
|
break;
|
|
|
|
}
|
2012-08-30 10:46:58 +02:00
|
|
|
case QEvent::Resize:
|
2013-02-16 13:32:33 +01:00
|
|
|
case QEvent::DeferredDelete:
|
|
|
|
if (object == m_navigationContainer) {
|
|
|
|
break;
|
|
|
|
}
|
2012-08-30 10:46:58 +02:00
|
|
|
applyBlurToMainWindow();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QMainWindow::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QupZilla::~QupZilla()
|
|
|
|
{
|
|
|
|
}
|