mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Added ClosedTabsManager class which handles list of closed tabs and
offers to restore them one by one
This commit is contained in:
parent
36dc77bea6
commit
5cafc27cf0
@ -79,7 +79,6 @@ SOURCES += main.cpp\
|
|||||||
plugins/plugins.cpp \
|
plugins/plugins.cpp \
|
||||||
preferences/pluginslist.cpp \
|
preferences/pluginslist.cpp \
|
||||||
plugins/pluginproxy.cpp \
|
plugins/pluginproxy.cpp \
|
||||||
app/appui.cpp \
|
|
||||||
tools/clickablelabel.cpp \
|
tools/clickablelabel.cpp \
|
||||||
downloads/downloadoptionsdialog.cpp \
|
downloads/downloadoptionsdialog.cpp \
|
||||||
tools/treewidget.cpp \
|
tools/treewidget.cpp \
|
||||||
@ -117,7 +116,8 @@ SOURCES += main.cpp\
|
|||||||
desktopnotifications/desktopnotificationsfactory.cpp \
|
desktopnotifications/desktopnotificationsfactory.cpp \
|
||||||
tools/progressbar.cpp \
|
tools/progressbar.cpp \
|
||||||
tools/iconprovider.cpp \
|
tools/iconprovider.cpp \
|
||||||
network/networkproxyfactory.cpp
|
network/networkproxyfactory.cpp \
|
||||||
|
tools/closedtabsmanager.cpp
|
||||||
|
|
||||||
HEADERS += 3rdparty/squeezelabel.h \
|
HEADERS += 3rdparty/squeezelabel.h \
|
||||||
3rdparty/qtwin.h \
|
3rdparty/qtwin.h \
|
||||||
@ -193,7 +193,8 @@ HEADERS += 3rdparty/squeezelabel.h \
|
|||||||
desktopnotifications/desktopnotificationsfactory.h \
|
desktopnotifications/desktopnotificationsfactory.h \
|
||||||
tools/progressbar.h \
|
tools/progressbar.h \
|
||||||
tools/iconprovider.h \
|
tools/iconprovider.h \
|
||||||
network/networkproxyfactory.h
|
network/networkproxyfactory.h \
|
||||||
|
tools/closedtabsmanager.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
@ -52,6 +52,7 @@ AdBlockDialog::AdBlockDialog(QWidget *parent)
|
|||||||
, m_itemChangingBlock(false)
|
, m_itemChangingBlock(false)
|
||||||
, m_manager(AdBlockManager::instance())
|
, m_manager(AdBlockManager::instance())
|
||||||
{
|
{
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
adblockCheckBox->setChecked(m_manager->isEnabled());
|
adblockCheckBox->setChecked(m_manager->isEnabled());
|
||||||
|
|
||||||
|
@ -124,10 +124,9 @@ void AdBlockManager::save()
|
|||||||
|
|
||||||
AdBlockDialog* AdBlockManager::showDialog()
|
AdBlockDialog* AdBlockManager::showDialog()
|
||||||
{
|
{
|
||||||
if (!m_adBlockDialog) {
|
if (!m_adBlockDialog)
|
||||||
m_adBlockDialog = new AdBlockDialog(mApp->getWindow());
|
m_adBlockDialog = new AdBlockDialog(mApp->getWindow());
|
||||||
m_adBlockDialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
}
|
|
||||||
m_adBlockDialog->show();
|
m_adBlockDialog->show();
|
||||||
return m_adBlockDialog;
|
return m_adBlockDialog;
|
||||||
}
|
}
|
||||||
@ -135,8 +134,7 @@ AdBlockDialog* AdBlockManager::showDialog()
|
|||||||
void AdBlockManager::showRule()
|
void AdBlockManager::showRule()
|
||||||
{
|
{
|
||||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
||||||
AdBlockDialog* dialog = showDialog();
|
showDialog()->search->setText(action->data().toString());
|
||||||
dialog->search->setText(action->data().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,336 +0,0 @@
|
|||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2011 nowrep
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#include "qupzilla.h"
|
|
||||||
#include "autofillmodel.h"
|
|
||||||
#include "bookmarkstoolbar.h"
|
|
||||||
#include "locationbar.h"
|
|
||||||
#include "clickablelabel.h"
|
|
||||||
#include "adblockicon.h"
|
|
||||||
#include "progressbar.h"
|
|
||||||
|
|
||||||
void QupZilla::postLaunch()
|
|
||||||
{
|
|
||||||
loadSettings();
|
|
||||||
m_tabWidget->restorePinnedTabs();
|
|
||||||
|
|
||||||
//Open tab from command line argument
|
|
||||||
bool addTab = true;
|
|
||||||
QStringList arguments = qApp->arguments();
|
|
||||||
for (int i = 0;i<qApp->arguments().count();i++) {
|
|
||||||
QString arg = arguments.at(i);
|
|
||||||
if (arg.startsWith("-url=")) {
|
|
||||||
m_tabWidget->addView(QUrl(arg.replace("-url=","")));
|
|
||||||
addTab = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QSettings settings(m_activeProfil+"settings.ini", QSettings::IniFormat);
|
|
||||||
settings.beginGroup("Web-URL-Settings");
|
|
||||||
int afterLaunch = settings.value("afterLaunch",1).toInt();
|
|
||||||
settings.endGroup();
|
|
||||||
settings.beginGroup("SessionRestore");
|
|
||||||
bool startingAfterCrash = settings.value("isCrashed",false).toBool();
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
QUrl startUrl;
|
|
||||||
if (m_tryRestore) {
|
|
||||||
if (afterLaunch == 0)
|
|
||||||
startUrl = QUrl("");
|
|
||||||
else if (afterLaunch == 1)
|
|
||||||
startUrl = m_homepage;
|
|
||||||
else
|
|
||||||
startUrl = m_homepage;
|
|
||||||
|
|
||||||
if ( startingAfterCrash || (addTab && afterLaunch == 2) )
|
|
||||||
addTab = !mApp->restoreStateSlot(this);
|
|
||||||
} else
|
|
||||||
startUrl = m_homepage;
|
|
||||||
|
|
||||||
if (!m_startingUrl.isEmpty()) {
|
|
||||||
startUrl = WebView::guessUrlFromString(m_startingUrl.toString());
|
|
||||||
addTab = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addTab)
|
|
||||||
m_tabWidget->addView(startUrl);
|
|
||||||
|
|
||||||
aboutToShowHistoryMenu();
|
|
||||||
aboutToShowBookmarksMenu();
|
|
||||||
|
|
||||||
if (m_tabWidget->count() == 0) //Something went really wrong .. add one tab
|
|
||||||
m_tabWidget->addView(m_homepage);
|
|
||||||
|
|
||||||
setUpdatesEnabled(true);
|
|
||||||
emit startingCompleted();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QupZilla::setupUi()
|
|
||||||
{
|
|
||||||
setContentsMargins(0,0,0,0);
|
|
||||||
|
|
||||||
m_navigation = new QToolBar(this);
|
|
||||||
m_navigation->setWindowTitle(tr("Navigation"));
|
|
||||||
m_navigation->setObjectName("Navigation bar");
|
|
||||||
addToolBar(m_navigation);
|
|
||||||
m_navigation->setMovable(false);
|
|
||||||
m_navigation->setStyleSheet("QToolBar{background-image:url(:icons/transp.png); border:none;}");
|
|
||||||
|
|
||||||
m_buttonBack = new QAction(QIcon(":/icons/navigation/zpet.png"),tr("Back"),this);
|
|
||||||
m_buttonBack->setEnabled(false);
|
|
||||||
m_buttonNext = new QAction(QIcon(":/icons/navigation/vpred.png"),tr("Forward"),this);
|
|
||||||
m_buttonNext->setEnabled(false);
|
|
||||||
m_buttonStop = new QAction(QIcon(":/icons/navigation/stop.png"),tr("Stop"),this);
|
|
||||||
m_buttonReload = new QAction(QIcon(":/icons/navigation/reload.png"),tr("Reload"),this);
|
|
||||||
m_buttonReload->setShortcut(QKeySequence("F5"));
|
|
||||||
m_buttonHome = new QAction(QIcon(":/icons/navigation/home.png"),tr("Home"),this);
|
|
||||||
|
|
||||||
m_menuBack = new QMenu();
|
|
||||||
m_buttonBack->setMenu(m_menuBack);
|
|
||||||
connect(m_menuBack, SIGNAL(aboutToShow()),this, SLOT(aboutToShowHistoryBackMenu()));
|
|
||||||
|
|
||||||
m_menuForward = new QMenu();
|
|
||||||
m_buttonNext->setMenu(m_menuForward);
|
|
||||||
connect(m_menuForward, SIGNAL(aboutToShow()),this, SLOT(aboutToShowHistoryNextMenu()));
|
|
||||||
|
|
||||||
m_supMenu = new QToolButton(this);
|
|
||||||
m_supMenu->setPopupMode(QToolButton::InstantPopup);
|
|
||||||
m_supMenu->setIcon(QIcon(":/icons/qupzilla.png"));
|
|
||||||
m_supMenu->setToolTip(tr("Main Menu"));
|
|
||||||
m_superMenu = new QMenu(this);
|
|
||||||
m_supMenu->setMenu(m_superMenu);
|
|
||||||
|
|
||||||
m_navigation->addAction(m_buttonBack);
|
|
||||||
m_navigation->addAction(m_buttonNext);
|
|
||||||
m_navigation->addAction(m_buttonReload);
|
|
||||||
m_navigation->addAction(m_buttonStop);
|
|
||||||
m_navigation->addAction(m_buttonHome);
|
|
||||||
|
|
||||||
m_locationBar = new LocationBar(this);
|
|
||||||
m_searchLine = new WebSearchBar(this);
|
|
||||||
|
|
||||||
m_navigationSplitter = new QSplitter(m_navigation);
|
|
||||||
m_navigationSplitter->addWidget(m_locationBar);
|
|
||||||
m_navigationSplitter->addWidget(m_searchLine);
|
|
||||||
|
|
||||||
m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
|
||||||
m_navigationSplitter->setCollapsible(0, false);
|
|
||||||
|
|
||||||
m_navigation->addWidget(m_navigationSplitter);
|
|
||||||
int splitterWidth = m_navigationSplitter->width();
|
|
||||||
QList<int> sizes;
|
|
||||||
sizes << (int)((double)splitterWidth * .75) << (int)((double)splitterWidth * .25);
|
|
||||||
m_navigationSplitter->setSizes(sizes);
|
|
||||||
|
|
||||||
m_actionExitFullscreen = new QAction(tr("Exit Fullscreen"),this);
|
|
||||||
m_actionExitFullscreen->setVisible(false);
|
|
||||||
m_navigation->addAction(m_actionExitFullscreen);
|
|
||||||
m_navigation->addWidget(m_supMenu);
|
|
||||||
m_navigation->addWidget(new QLabel()); //Elegant spacer -,-
|
|
||||||
m_navigation->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
|
|
||||||
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);
|
|
||||||
m_ipLabel->setStyleSheet("padding-right: 5px;");
|
|
||||||
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);
|
|
||||||
|
|
||||||
m_bookmarksToolbar = new BookmarksToolbar(this);
|
|
||||||
addToolBar(m_bookmarksToolbar);
|
|
||||||
insertToolBarBreak(m_bookmarksToolbar);
|
|
||||||
|
|
||||||
m_tabWidget = new TabWidget(this);
|
|
||||||
setCentralWidget(m_tabWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QupZilla::setupMenu()
|
|
||||||
{
|
|
||||||
m_menuTools = new QMenu(tr("Tools"));
|
|
||||||
m_menuHelp = new QMenu(tr("Help"));
|
|
||||||
m_menuBookmarks = new QMenu(tr("Bookmarks"));
|
|
||||||
m_menuHistory = new QMenu(tr("History"));
|
|
||||||
connect(m_menuHistory, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMenu()));
|
|
||||||
connect(m_menuBookmarks, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBookmarksMenu()));
|
|
||||||
connect(m_menuHelp, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHelpMenu()));
|
|
||||||
connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
|
|
||||||
|
|
||||||
m_menuFile = new QMenu(tr("File"));
|
|
||||||
m_menuFile->addAction(QIcon::fromTheme("window-new"), tr("&New Window"), this, SLOT(newWindow()))->setShortcut(QKeySequence("Ctrl+N"));
|
|
||||||
m_menuFile->addAction(QIcon(":/icons/menu/popup.png"), tr("New Tab"), this, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T"));
|
|
||||||
m_menuFile->addAction(tr("Open Location"), this, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L"));
|
|
||||||
m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File"), this, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O"));
|
|
||||||
m_menuFile->addAction(tr("Close Tab"), m_tabWidget, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
|
|
||||||
m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+Shift+W"));
|
|
||||||
m_menuFile->addSeparator();
|
|
||||||
m_menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), this, SLOT(savePage()))->setShortcut(QKeySequence("Ctrl+S"));
|
|
||||||
m_menuFile->addAction(tr("Send Link..."), this, SLOT(sendLink()));
|
|
||||||
m_menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print"), this, SLOT(printPage()));
|
|
||||||
m_menuFile->addSeparator();
|
|
||||||
m_menuFile->addAction(QIcon::fromTheme("application-exit"), tr("Quit"), this, SLOT(quitApp()))->setShortcut(QKeySequence("Ctrl+Q"));
|
|
||||||
menuBar()->addMenu(m_menuFile);
|
|
||||||
|
|
||||||
m_menuEdit = new QMenu(tr("Edit"));
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"))->setShortcut(QKeySequence("Ctrl+Z"));
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"))->setShortcut(QKeySequence("Ctrl+Shift+Z"));
|
|
||||||
m_menuEdit->addSeparator();
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"))->setShortcut(QKeySequence("Ctrl+X"));
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), this, SLOT(copy()))->setShortcut(QKeySequence("Ctrl+C"));
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"))->setShortcut(QKeySequence("Ctrl+V"));
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-delete"), tr("&Delete"))->setShortcut(QKeySequence("Del"));
|
|
||||||
m_menuEdit->addSeparator();
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &All"), this, SLOT(selectAll()))->setShortcut(QKeySequence("Ctrl+A"));
|
|
||||||
m_menuEdit->addSeparator();
|
|
||||||
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("&Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
|
|
||||||
menuBar()->addMenu(m_menuEdit);
|
|
||||||
|
|
||||||
m_menuView = new QMenu(tr("View"));
|
|
||||||
m_actionShowToolbar = new QAction(tr("&Navigation Toolbar"), this);
|
|
||||||
m_actionShowToolbar->setCheckable(true);
|
|
||||||
connect(m_actionShowToolbar, SIGNAL(triggered(bool)), this, SLOT(showNavigationToolbar()));
|
|
||||||
m_actionShowBookmarksToolbar = new QAction(tr("&Bookmarks Toolbar"), this);
|
|
||||||
m_actionShowBookmarksToolbar->setCheckable(true);
|
|
||||||
connect(m_actionShowBookmarksToolbar, SIGNAL(triggered(bool)), this, SLOT(showBookmarksToolbar()));
|
|
||||||
m_actionShowStatusbar = new QAction(tr("Sta&tus Bar"), this);
|
|
||||||
m_actionShowStatusbar->setCheckable(true);
|
|
||||||
connect(m_actionShowStatusbar, SIGNAL(triggered(bool)), this, SLOT(showStatusbar()));
|
|
||||||
m_actionShowMenubar = new QAction(tr("&Menu Bar"), this);
|
|
||||||
m_actionShowMenubar->setCheckable(true);
|
|
||||||
connect(m_actionShowMenubar, SIGNAL(triggered(bool)), this, SLOT(showMenubar()));
|
|
||||||
m_actionShowFullScreen = new QAction(tr("&Fullscreen"), this);
|
|
||||||
m_actionShowFullScreen->setCheckable(true);
|
|
||||||
m_actionShowFullScreen->setShortcut(QKeySequence("F11"));
|
|
||||||
connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool)));
|
|
||||||
m_actionStop = new QAction(
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
style()->standardIcon(QStyle::SP_BrowserStop)
|
|
||||||
#else
|
|
||||||
QIcon(":/icons/faenza/stop.png")
|
|
||||||
#endif
|
|
||||||
, tr("&Stop"), this);
|
|
||||||
connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop()));
|
|
||||||
m_actionStop->setShortcut(QKeySequence("Esc"));
|
|
||||||
m_actionReload = new QAction(
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
style()->standardIcon(QStyle::SP_BrowserReload)
|
|
||||||
#else
|
|
||||||
QIcon(":/icons/faenza/reload.png")
|
|
||||||
#endif
|
|
||||||
, tr("&Reload"), this);
|
|
||||||
connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload()));
|
|
||||||
m_actionReload->setShortcut(QKeySequence("Ctrl+R"));
|
|
||||||
QAction* actionEncoding = new QAction(tr("Character &Encoding"), this);
|
|
||||||
m_menuEncoding = new QMenu(this);
|
|
||||||
actionEncoding->setMenu(m_menuEncoding);
|
|
||||||
connect(m_menuEncoding, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu()));
|
|
||||||
|
|
||||||
m_actionShowBookmarksSideBar = new QAction(tr("Bookmarks"), this);
|
|
||||||
m_actionShowBookmarksSideBar->setCheckable(true);
|
|
||||||
m_actionShowBookmarksSideBar->setShortcut(QKeySequence("Ctrl+B"));
|
|
||||||
connect(m_actionShowBookmarksSideBar, SIGNAL(triggered()), this, SLOT(showBookmarksSideBar()));
|
|
||||||
m_actionShowHistorySideBar = new QAction(tr("History"), this);
|
|
||||||
m_actionShowHistorySideBar->setCheckable(true);
|
|
||||||
m_actionShowHistorySideBar->setShortcut(QKeySequence("Ctrl+H"));
|
|
||||||
connect(m_actionShowHistorySideBar, SIGNAL(triggered()), this, SLOT(showHistorySideBar()));
|
|
||||||
// m_actionShowRssSideBar = new QAction(tr("RSS Reader"), this);
|
|
||||||
// m_actionShowRssSideBar->setCheckable(true);
|
|
||||||
// connect(m_actionShowRssSideBar, SIGNAL(triggered()), this, SLOT(showRssSideBar()));
|
|
||||||
|
|
||||||
QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
|
|
||||||
toolbarsMenu->addAction(m_actionShowMenubar);
|
|
||||||
toolbarsMenu->addAction(m_actionShowToolbar);
|
|
||||||
toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
|
|
||||||
toolbarsMenu->addAction(m_actionShowStatusbar);
|
|
||||||
connect(toolbarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolbarsMenu()));
|
|
||||||
QMenu* sidebarsMenu = new QMenu(tr("Sidebars"));
|
|
||||||
sidebarsMenu->addAction(m_actionShowBookmarksSideBar);
|
|
||||||
sidebarsMenu->addAction(m_actionShowHistorySideBar);
|
|
||||||
// sidebarsMenu->addAction(m_actionShowRssSideBar);
|
|
||||||
connect(sidebarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowSidebarsMenu()));
|
|
||||||
|
|
||||||
m_menuView->addMenu(toolbarsMenu);
|
|
||||||
m_menuView->addMenu(sidebarsMenu);
|
|
||||||
m_menuView->addSeparator();
|
|
||||||
m_menuView->addAction(m_actionStop);
|
|
||||||
m_menuView->addAction(m_actionReload);
|
|
||||||
m_menuView->addSeparator();
|
|
||||||
m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), this, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++"));
|
|
||||||
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), this, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
|
|
||||||
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
|
|
||||||
m_menuView->addSeparator();
|
|
||||||
m_menuView->addAction(actionEncoding);
|
|
||||||
m_menuView->addSeparator();
|
|
||||||
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
|
|
||||||
m_menuView->addAction(m_actionShowFullScreen);
|
|
||||||
menuBar()->addMenu(m_menuView);
|
|
||||||
connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu()));
|
|
||||||
|
|
||||||
menuBar()->addMenu(m_menuHistory);
|
|
||||||
menuBar()->addMenu(m_menuBookmarks);
|
|
||||||
menuBar()->addMenu(m_menuTools);
|
|
||||||
menuBar()->addMenu(m_menuHelp);
|
|
||||||
|
|
||||||
menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
|
|
||||||
aboutToShowToolsMenu();
|
|
||||||
aboutToShowHelpMenu();
|
|
||||||
|
|
||||||
connect(m_locationBar, SIGNAL(returnPressed()), this, SLOT(urlEnter()));
|
|
||||||
connect(m_buttonBack, SIGNAL(triggered()), this, SLOT(goBack()));
|
|
||||||
connect(m_buttonNext, SIGNAL(triggered()), this, SLOT(goNext()));
|
|
||||||
connect(m_buttonStop, SIGNAL(triggered()), this, SLOT(stop()));
|
|
||||||
connect(m_buttonReload, SIGNAL(triggered()), this, SLOT(reload()));
|
|
||||||
connect(m_buttonHome, SIGNAL(triggered()), this, SLOT(goHome()));
|
|
||||||
connect(m_actionExitFullscreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool)));
|
|
||||||
|
|
||||||
//Make shortcuts available even in fullscreen (menu hidden)
|
|
||||||
QList<QAction*> actions = menuBar()->actions();
|
|
||||||
foreach (QAction* action, actions) {
|
|
||||||
if (action->menu())
|
|
||||||
actions += action->menu()->actions();
|
|
||||||
addAction(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_superMenu->addMenu(m_menuFile);
|
|
||||||
m_superMenu->addMenu(m_menuEdit);
|
|
||||||
m_superMenu->addMenu(m_menuView);
|
|
||||||
m_superMenu->addMenu(m_menuHistory);
|
|
||||||
m_superMenu->addMenu(m_menuBookmarks);
|
|
||||||
m_superMenu->addMenu(m_menuTools);
|
|
||||||
m_superMenu->addMenu(m_menuHelp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QupZilla::setBackground(QColor textColor)
|
|
||||||
{
|
|
||||||
QString color = textColor.name();
|
|
||||||
setStyleSheet("QMainWindow { background-image: url("+m_activeProfil+"background.png); background-position: top right; } QToolBar{background-image:url(:icons/transp.png); border:none;}"
|
|
||||||
"QMenuBar{color:"+color+";background-image:url(:icons/transp.png); border:none;} QStatusBar{background-image:url(:icons/transp.png); border:none; color:"+color+";}"
|
|
||||||
"QMenuBar:item{spacing: 5px; padding: 2px 6px;background: transparent;}"
|
|
||||||
"QMenuBar::item:pressed { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 lightgray, stop:1 darkgray); border: 1px solid darkgrey; border-top-left-radius: 4px;border-top-right-radius: 4px; border-bottom: none;}"
|
|
||||||
);
|
|
||||||
m_navigation->setStyleSheet("QSplitter::handle{background-color:transparent;}");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -50,6 +50,8 @@
|
|||||||
#include "sidebar.h"
|
#include "sidebar.h"
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
#include "progressbar.h"
|
#include "progressbar.h"
|
||||||
|
#include "adblockicon.h"
|
||||||
|
#include "closedtabsmanager.h"
|
||||||
|
|
||||||
const QString QupZilla::VERSION = "1.0.0-b2";
|
const QString QupZilla::VERSION = "1.0.0-b2";
|
||||||
//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
|
//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
|
||||||
@ -85,6 +87,322 @@ QupZilla::QupZilla(bool tryRestore, QUrl startUrl) :
|
|||||||
connect(mApp, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(receiveMessage(MainApplication::MessageType,bool)));
|
connect(mApp, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(receiveMessage(MainApplication::MessageType,bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QupZilla::postLaunch()
|
||||||
|
{
|
||||||
|
loadSettings();
|
||||||
|
m_tabWidget->restorePinnedTabs();
|
||||||
|
|
||||||
|
//Open tab from command line argument
|
||||||
|
bool addTab = true;
|
||||||
|
QStringList arguments = qApp->arguments();
|
||||||
|
for (int i = 0;i<qApp->arguments().count();i++) {
|
||||||
|
QString arg = arguments.at(i);
|
||||||
|
if (arg.startsWith("-url=")) {
|
||||||
|
m_tabWidget->addView(QUrl(arg.replace("-url=","")));
|
||||||
|
addTab = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings settings(m_activeProfil+"settings.ini", QSettings::IniFormat);
|
||||||
|
settings.beginGroup("Web-URL-Settings");
|
||||||
|
int afterLaunch = settings.value("afterLaunch",1).toInt();
|
||||||
|
settings.endGroup();
|
||||||
|
settings.beginGroup("SessionRestore");
|
||||||
|
bool startingAfterCrash = settings.value("isCrashed",false).toBool();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
QUrl startUrl;
|
||||||
|
if (m_tryRestore) {
|
||||||
|
if (afterLaunch == 0)
|
||||||
|
startUrl = QUrl("");
|
||||||
|
else if (afterLaunch == 1)
|
||||||
|
startUrl = m_homepage;
|
||||||
|
else
|
||||||
|
startUrl = m_homepage;
|
||||||
|
|
||||||
|
if ( startingAfterCrash || (addTab && afterLaunch == 2) )
|
||||||
|
addTab = !mApp->restoreStateSlot(this);
|
||||||
|
} else
|
||||||
|
startUrl = m_homepage;
|
||||||
|
|
||||||
|
if (!m_startingUrl.isEmpty()) {
|
||||||
|
startUrl = WebView::guessUrlFromString(m_startingUrl.toString());
|
||||||
|
addTab = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addTab)
|
||||||
|
m_tabWidget->addView(startUrl);
|
||||||
|
|
||||||
|
aboutToShowHistoryMenu();
|
||||||
|
aboutToShowBookmarksMenu();
|
||||||
|
|
||||||
|
if (m_tabWidget->count() == 0) //Something went really wrong .. add one tab
|
||||||
|
m_tabWidget->addView(m_homepage);
|
||||||
|
|
||||||
|
setUpdatesEnabled(true);
|
||||||
|
emit startingCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QupZilla::setupUi()
|
||||||
|
{
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
m_navigation = new QToolBar(this);
|
||||||
|
m_navigation->setWindowTitle(tr("Navigation"));
|
||||||
|
m_navigation->setObjectName("Navigation bar");
|
||||||
|
addToolBar(m_navigation);
|
||||||
|
m_navigation->setMovable(false);
|
||||||
|
m_navigation->setStyleSheet("QToolBar{background-image:url(:icons/transp.png); border:none;}");
|
||||||
|
|
||||||
|
m_buttonBack = new QAction(QIcon(":/icons/navigation/zpet.png"),tr("Back"),this);
|
||||||
|
m_buttonBack->setEnabled(false);
|
||||||
|
m_buttonNext = new QAction(QIcon(":/icons/navigation/vpred.png"),tr("Forward"),this);
|
||||||
|
m_buttonNext->setEnabled(false);
|
||||||
|
m_buttonStop = new QAction(QIcon(":/icons/navigation/stop.png"),tr("Stop"),this);
|
||||||
|
m_buttonReload = new QAction(QIcon(":/icons/navigation/reload.png"),tr("Reload"),this);
|
||||||
|
m_buttonReload->setShortcut(QKeySequence("F5"));
|
||||||
|
m_buttonHome = new QAction(QIcon(":/icons/navigation/home.png"),tr("Home"),this);
|
||||||
|
|
||||||
|
m_menuBack = new QMenu();
|
||||||
|
m_buttonBack->setMenu(m_menuBack);
|
||||||
|
connect(m_menuBack, SIGNAL(aboutToShow()),this, SLOT(aboutToShowHistoryBackMenu()));
|
||||||
|
|
||||||
|
m_menuForward = new QMenu();
|
||||||
|
m_buttonNext->setMenu(m_menuForward);
|
||||||
|
connect(m_menuForward, SIGNAL(aboutToShow()),this, SLOT(aboutToShowHistoryNextMenu()));
|
||||||
|
|
||||||
|
m_supMenu = new QToolButton(this);
|
||||||
|
m_supMenu->setPopupMode(QToolButton::InstantPopup);
|
||||||
|
m_supMenu->setIcon(QIcon(":/icons/qupzilla.png"));
|
||||||
|
m_supMenu->setToolTip(tr("Main Menu"));
|
||||||
|
m_superMenu = new QMenu(this);
|
||||||
|
m_supMenu->setMenu(m_superMenu);
|
||||||
|
|
||||||
|
m_navigation->addAction(m_buttonBack);
|
||||||
|
m_navigation->addAction(m_buttonNext);
|
||||||
|
m_navigation->addAction(m_buttonReload);
|
||||||
|
m_navigation->addAction(m_buttonStop);
|
||||||
|
m_navigation->addAction(m_buttonHome);
|
||||||
|
|
||||||
|
m_locationBar = new LocationBar(this);
|
||||||
|
m_searchLine = new WebSearchBar(this);
|
||||||
|
|
||||||
|
m_navigationSplitter = new QSplitter(m_navigation);
|
||||||
|
m_navigationSplitter->addWidget(m_locationBar);
|
||||||
|
m_navigationSplitter->addWidget(m_searchLine);
|
||||||
|
|
||||||
|
m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||||||
|
m_navigationSplitter->setCollapsible(0, false);
|
||||||
|
|
||||||
|
m_navigation->addWidget(m_navigationSplitter);
|
||||||
|
int splitterWidth = m_navigationSplitter->width();
|
||||||
|
QList<int> sizes;
|
||||||
|
sizes << (int)((double)splitterWidth * .75) << (int)((double)splitterWidth * .25);
|
||||||
|
m_navigationSplitter->setSizes(sizes);
|
||||||
|
|
||||||
|
m_actionExitFullscreen = new QAction(tr("Exit Fullscreen"),this);
|
||||||
|
m_actionExitFullscreen->setVisible(false);
|
||||||
|
m_navigation->addAction(m_actionExitFullscreen);
|
||||||
|
m_navigation->addWidget(m_supMenu);
|
||||||
|
m_navigation->addWidget(new QLabel()); //Elegant spacer -,-
|
||||||
|
m_navigation->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
|
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);
|
||||||
|
m_ipLabel->setStyleSheet("padding-right: 5px;");
|
||||||
|
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);
|
||||||
|
|
||||||
|
m_bookmarksToolbar = new BookmarksToolbar(this);
|
||||||
|
addToolBar(m_bookmarksToolbar);
|
||||||
|
insertToolBarBreak(m_bookmarksToolbar);
|
||||||
|
|
||||||
|
m_tabWidget = new TabWidget(this);
|
||||||
|
setCentralWidget(m_tabWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QupZilla::setupMenu()
|
||||||
|
{
|
||||||
|
m_menuTools = new QMenu(tr("Tools"));
|
||||||
|
m_menuHelp = new QMenu(tr("Help"));
|
||||||
|
m_menuBookmarks = new QMenu(tr("Bookmarks"));
|
||||||
|
m_menuHistory = new QMenu(tr("History"));
|
||||||
|
connect(m_menuHistory, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMenu()));
|
||||||
|
connect(m_menuBookmarks, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBookmarksMenu()));
|
||||||
|
connect(m_menuHelp, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHelpMenu()));
|
||||||
|
connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
|
||||||
|
|
||||||
|
m_menuFile = new QMenu(tr("File"));
|
||||||
|
m_menuFile->addAction(QIcon::fromTheme("window-new"), tr("&New Window"), this, SLOT(newWindow()))->setShortcut(QKeySequence("Ctrl+N"));
|
||||||
|
m_menuFile->addAction(QIcon(":/icons/menu/popup.png"), tr("New Tab"), this, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T"));
|
||||||
|
m_menuFile->addAction(tr("Open Location"), this, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L"));
|
||||||
|
m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File"), this, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O"));
|
||||||
|
m_menuFile->addAction(tr("Close Tab"), m_tabWidget, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
|
||||||
|
m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+Shift+W"));
|
||||||
|
m_menuFile->addSeparator();
|
||||||
|
m_menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), this, SLOT(savePage()))->setShortcut(QKeySequence("Ctrl+S"));
|
||||||
|
m_menuFile->addAction(tr("Send Link..."), this, SLOT(sendLink()));
|
||||||
|
m_menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print"), this, SLOT(printPage()));
|
||||||
|
m_menuFile->addSeparator();
|
||||||
|
m_menuFile->addAction(QIcon::fromTheme("application-exit"), tr("Quit"), this, SLOT(quitApp()))->setShortcut(QKeySequence("Ctrl+Q"));
|
||||||
|
menuBar()->addMenu(m_menuFile);
|
||||||
|
|
||||||
|
m_menuEdit = new QMenu(tr("Edit"));
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"))->setShortcut(QKeySequence("Ctrl+Z"));
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"))->setShortcut(QKeySequence("Ctrl+Shift+Z"));
|
||||||
|
m_menuEdit->addSeparator();
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"))->setShortcut(QKeySequence("Ctrl+X"));
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), this, SLOT(copy()))->setShortcut(QKeySequence("Ctrl+C"));
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"))->setShortcut(QKeySequence("Ctrl+V"));
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-delete"), tr("&Delete"))->setShortcut(QKeySequence("Del"));
|
||||||
|
m_menuEdit->addSeparator();
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &All"), this, SLOT(selectAll()))->setShortcut(QKeySequence("Ctrl+A"));
|
||||||
|
m_menuEdit->addSeparator();
|
||||||
|
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("&Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
|
||||||
|
menuBar()->addMenu(m_menuEdit);
|
||||||
|
|
||||||
|
m_menuView = new QMenu(tr("View"));
|
||||||
|
m_actionShowToolbar = new QAction(tr("&Navigation Toolbar"), this);
|
||||||
|
m_actionShowToolbar->setCheckable(true);
|
||||||
|
connect(m_actionShowToolbar, SIGNAL(triggered(bool)), this, SLOT(showNavigationToolbar()));
|
||||||
|
m_actionShowBookmarksToolbar = new QAction(tr("&Bookmarks Toolbar"), this);
|
||||||
|
m_actionShowBookmarksToolbar->setCheckable(true);
|
||||||
|
connect(m_actionShowBookmarksToolbar, SIGNAL(triggered(bool)), this, SLOT(showBookmarksToolbar()));
|
||||||
|
m_actionShowStatusbar = new QAction(tr("Sta&tus Bar"), this);
|
||||||
|
m_actionShowStatusbar->setCheckable(true);
|
||||||
|
connect(m_actionShowStatusbar, SIGNAL(triggered(bool)), this, SLOT(showStatusbar()));
|
||||||
|
m_actionShowMenubar = new QAction(tr("&Menu Bar"), this);
|
||||||
|
m_actionShowMenubar->setCheckable(true);
|
||||||
|
connect(m_actionShowMenubar, SIGNAL(triggered(bool)), this, SLOT(showMenubar()));
|
||||||
|
m_actionShowFullScreen = new QAction(tr("&Fullscreen"), this);
|
||||||
|
m_actionShowFullScreen->setCheckable(true);
|
||||||
|
m_actionShowFullScreen->setShortcut(QKeySequence("F11"));
|
||||||
|
connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool)));
|
||||||
|
m_actionStop = new QAction(
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
style()->standardIcon(QStyle::SP_BrowserStop)
|
||||||
|
#else
|
||||||
|
QIcon(":/icons/faenza/stop.png")
|
||||||
|
#endif
|
||||||
|
, tr("&Stop"), this);
|
||||||
|
connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop()));
|
||||||
|
m_actionStop->setShortcut(QKeySequence("Esc"));
|
||||||
|
m_actionReload = new QAction(
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
style()->standardIcon(QStyle::SP_BrowserReload)
|
||||||
|
#else
|
||||||
|
QIcon(":/icons/faenza/reload.png")
|
||||||
|
#endif
|
||||||
|
, tr("&Reload"), this);
|
||||||
|
connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload()));
|
||||||
|
m_actionReload->setShortcut(QKeySequence("Ctrl+R"));
|
||||||
|
QAction* actionEncoding = new QAction(tr("Character &Encoding"), this);
|
||||||
|
m_menuEncoding = new QMenu(this);
|
||||||
|
actionEncoding->setMenu(m_menuEncoding);
|
||||||
|
connect(m_menuEncoding, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu()));
|
||||||
|
|
||||||
|
m_actionShowBookmarksSideBar = new QAction(tr("Bookmarks"), this);
|
||||||
|
m_actionShowBookmarksSideBar->setCheckable(true);
|
||||||
|
m_actionShowBookmarksSideBar->setShortcut(QKeySequence("Ctrl+B"));
|
||||||
|
connect(m_actionShowBookmarksSideBar, SIGNAL(triggered()), this, SLOT(showBookmarksSideBar()));
|
||||||
|
m_actionShowHistorySideBar = new QAction(tr("History"), this);
|
||||||
|
m_actionShowHistorySideBar->setCheckable(true);
|
||||||
|
m_actionShowHistorySideBar->setShortcut(QKeySequence("Ctrl+H"));
|
||||||
|
connect(m_actionShowHistorySideBar, SIGNAL(triggered()), this, SLOT(showHistorySideBar()));
|
||||||
|
// m_actionShowRssSideBar = new QAction(tr("RSS Reader"), this);
|
||||||
|
// m_actionShowRssSideBar->setCheckable(true);
|
||||||
|
// connect(m_actionShowRssSideBar, SIGNAL(triggered()), this, SLOT(showRssSideBar()));
|
||||||
|
|
||||||
|
QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
|
||||||
|
toolbarsMenu->addAction(m_actionShowMenubar);
|
||||||
|
toolbarsMenu->addAction(m_actionShowToolbar);
|
||||||
|
toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
|
||||||
|
toolbarsMenu->addAction(m_actionShowStatusbar);
|
||||||
|
connect(toolbarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolbarsMenu()));
|
||||||
|
QMenu* sidebarsMenu = new QMenu(tr("Sidebars"));
|
||||||
|
sidebarsMenu->addAction(m_actionShowBookmarksSideBar);
|
||||||
|
sidebarsMenu->addAction(m_actionShowHistorySideBar);
|
||||||
|
// sidebarsMenu->addAction(m_actionShowRssSideBar);
|
||||||
|
connect(sidebarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowSidebarsMenu()));
|
||||||
|
|
||||||
|
m_menuView->addMenu(toolbarsMenu);
|
||||||
|
m_menuView->addMenu(sidebarsMenu);
|
||||||
|
m_menuView->addSeparator();
|
||||||
|
m_menuView->addAction(m_actionStop);
|
||||||
|
m_menuView->addAction(m_actionReload);
|
||||||
|
m_menuView->addSeparator();
|
||||||
|
m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), this, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++"));
|
||||||
|
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), this, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
|
||||||
|
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
|
||||||
|
m_menuView->addSeparator();
|
||||||
|
m_menuView->addAction(actionEncoding);
|
||||||
|
m_menuView->addSeparator();
|
||||||
|
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
|
||||||
|
m_menuView->addAction(m_actionShowFullScreen);
|
||||||
|
menuBar()->addMenu(m_menuView);
|
||||||
|
connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu()));
|
||||||
|
|
||||||
|
menuBar()->addMenu(m_menuHistory);
|
||||||
|
menuBar()->addMenu(m_menuBookmarks);
|
||||||
|
menuBar()->addMenu(m_menuTools);
|
||||||
|
menuBar()->addMenu(m_menuHelp);
|
||||||
|
|
||||||
|
menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
|
aboutToShowToolsMenu();
|
||||||
|
aboutToShowHelpMenu();
|
||||||
|
|
||||||
|
connect(m_locationBar, SIGNAL(returnPressed()), this, SLOT(urlEnter()));
|
||||||
|
connect(m_buttonBack, SIGNAL(triggered()), this, SLOT(goBack()));
|
||||||
|
connect(m_buttonNext, SIGNAL(triggered()), this, SLOT(goNext()));
|
||||||
|
connect(m_buttonStop, SIGNAL(triggered()), this, SLOT(stop()));
|
||||||
|
connect(m_buttonReload, SIGNAL(triggered()), this, SLOT(reload()));
|
||||||
|
connect(m_buttonHome, SIGNAL(triggered()), this, SLOT(goHome()));
|
||||||
|
connect(m_actionExitFullscreen, SIGNAL(triggered(bool)), this, SLOT(fullScreen(bool)));
|
||||||
|
|
||||||
|
m_actionRestoreTab = new QAction(QIcon::fromTheme("user-trash"),tr("Restore &Closed Tab"), this);
|
||||||
|
m_actionRestoreTab->setShortcut(QKeySequence("Ctrl+Shift+T"));
|
||||||
|
connect(m_actionRestoreTab, SIGNAL(triggered()), m_tabWidget, SLOT(restoreClosedTab()));
|
||||||
|
addAction(m_actionRestoreTab);
|
||||||
|
|
||||||
|
//Make shortcuts available even in fullscreen (menu hidden)
|
||||||
|
QList<QAction*> actions = menuBar()->actions();
|
||||||
|
foreach (QAction* action, actions) {
|
||||||
|
if (action->menu())
|
||||||
|
actions += action->menu()->actions();
|
||||||
|
addAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_superMenu->addMenu(m_menuFile);
|
||||||
|
m_superMenu->addMenu(m_menuEdit);
|
||||||
|
m_superMenu->addMenu(m_menuView);
|
||||||
|
m_superMenu->addMenu(m_menuHistory);
|
||||||
|
m_superMenu->addMenu(m_menuBookmarks);
|
||||||
|
m_superMenu->addMenu(m_menuTools);
|
||||||
|
m_superMenu->addMenu(m_menuHelp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QupZilla::setBackground(QColor textColor)
|
||||||
|
{
|
||||||
|
QString color = textColor.name();
|
||||||
|
setStyleSheet("QMainWindow { background-image: url("+m_activeProfil+"background.png); background-position: top right; } QToolBar{background-image:url(:icons/transp.png); border:none;}"
|
||||||
|
"QMenuBar{color:"+color+";background-image:url(:icons/transp.png); border:none;} QStatusBar{background-image:url(:icons/transp.png); border:none; color:"+color+";}"
|
||||||
|
"QMenuBar:item{spacing: 5px; padding: 2px 6px;background: transparent;}"
|
||||||
|
"QMenuBar::item:pressed { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 lightgray, stop:1 darkgray); border: 1px solid darkgrey; border-top-left-radius: 4px;border-top-right-radius: 4px; border-bottom: none;}"
|
||||||
|
);
|
||||||
|
m_navigation->setStyleSheet("QSplitter::handle{background-color:transparent;}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void QupZilla::loadSettings()
|
void QupZilla::loadSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(m_activeProfil+"settings.ini", QSettings::IniFormat);
|
QSettings settings(m_activeProfil+"settings.ini", QSettings::IniFormat);
|
||||||
@ -362,6 +680,17 @@ void QupZilla::aboutToShowHistoryMenu()
|
|||||||
}
|
}
|
||||||
m_menuHistory->addAction(_iconForUrl(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
m_menuHistory->addAction(_iconForUrl(url), title, this, SLOT(loadActionUrl()))->setData(url);
|
||||||
}
|
}
|
||||||
|
m_menuHistory->addSeparator();
|
||||||
|
QMenu* menuClosedTabs = new QMenu(tr("Closed Tabs"));
|
||||||
|
int i = 0;
|
||||||
|
foreach (ClosedTabsManager::Tab tab, m_tabWidget->closedTabsManager()->allClosedTabs()) {
|
||||||
|
menuClosedTabs->addAction(_iconForUrl(tab.url), tab.title, m_tabWidget, SLOT(restoreClosedTab()))->setData(i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (i == 0)
|
||||||
|
menuClosedTabs->addAction(tr("Empty"))->setEnabled(false);
|
||||||
|
|
||||||
|
m_menuHistory->addMenu(menuClosedTabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QupZilla::aboutToShowHelpMenu()
|
void QupZilla::aboutToShowHelpMenu()
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define QUPZILLA_H
|
#define QUPZILLA_H
|
||||||
|
|
||||||
//Comment for release building
|
//Comment for release building
|
||||||
//#define DEVELOPING
|
#define DEVELOPING
|
||||||
|
|
||||||
#ifdef QT_NO_DEBUG
|
#ifdef QT_NO_DEBUG
|
||||||
#ifdef DEVELOPING
|
#ifdef DEVELOPING
|
||||||
@ -110,8 +110,8 @@ public:
|
|||||||
inline QDockWidget* inspectorDock(){ return m_webInspectorDock; }
|
inline QDockWidget* inspectorDock(){ return m_webInspectorDock; }
|
||||||
inline QLabel* ipLabel(){ return m_ipLabel; }
|
inline QLabel* ipLabel(){ return m_ipLabel; }
|
||||||
inline QColor menuTextColor() { return m_menuTextColor; }
|
inline QColor menuTextColor() { return m_menuTextColor; }
|
||||||
inline QAction* acShowBookmarksToolbar() { return m_actionShowBookmarksToolbar; }
|
|
||||||
inline QMenu* menuHelp() { return m_menuHelp; }
|
inline QMenu* menuHelp() { return m_menuHelp; }
|
||||||
|
inline QAction* actionRestoreTab() { return m_actionRestoreTab; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loadHistory();
|
void loadHistory();
|
||||||
@ -223,6 +223,7 @@ private:
|
|||||||
QAction* m_actionPrivateBrowsing;
|
QAction* m_actionPrivateBrowsing;
|
||||||
QAction* m_actionStop;
|
QAction* m_actionStop;
|
||||||
QAction* m_actionReload;
|
QAction* m_actionReload;
|
||||||
|
QAction* m_actionRestoreTab;
|
||||||
|
|
||||||
QLabel* m_privateBrowsing;
|
QLabel* m_privateBrowsing;
|
||||||
ClickableLabel* m_adblockIcon;
|
ClickableLabel* m_adblockIcon;
|
||||||
|
45
src/tools/closedtabsmanager.cpp
Normal file
45
src/tools/closedtabsmanager.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include "closedtabsmanager.h"
|
||||||
|
#include "webview.h"
|
||||||
|
|
||||||
|
ClosedTabsManager::ClosedTabsManager(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClosedTabsManager::saveView(WebView* view)
|
||||||
|
{
|
||||||
|
Tab tab;
|
||||||
|
tab.url = view->url();
|
||||||
|
tab.title = view->title();
|
||||||
|
QDataStream tabHistoryStream(&tab.history, QIODevice::WriteOnly);
|
||||||
|
tabHistoryStream << view->history();
|
||||||
|
|
||||||
|
m_closedTabs.prepend(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClosedTabsManager::Tab ClosedTabsManager::getFirstClosedTab()
|
||||||
|
{
|
||||||
|
Tab tab;
|
||||||
|
if (m_closedTabs.count() > 0) {
|
||||||
|
tab = m_closedTabs.takeFirst();
|
||||||
|
m_closedTabs.removeOne(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClosedTabsManager::Tab ClosedTabsManager::getTabAt(int index)
|
||||||
|
{
|
||||||
|
Tab tab;
|
||||||
|
if (m_closedTabs.count() > 0) {
|
||||||
|
tab = m_closedTabs.at(index);
|
||||||
|
m_closedTabs.removeOne(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClosedTabsManager::isClosedTabAvailable()
|
||||||
|
{
|
||||||
|
return (m_closedTabs.count() != 0);
|
||||||
|
}
|
41
src/tools/closedtabsmanager.h
Normal file
41
src/tools/closedtabsmanager.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef CLOSEDTABSMANAGER_H
|
||||||
|
#define CLOSEDTABSMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
class WebView;
|
||||||
|
class ClosedTabsManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ClosedTabsManager(QObject* parent = 0);
|
||||||
|
struct Tab {
|
||||||
|
QUrl url;
|
||||||
|
QByteArray history;
|
||||||
|
QString title;
|
||||||
|
|
||||||
|
bool operator==(const Tab &a)
|
||||||
|
{
|
||||||
|
return (a.url == url) && (a.history == history);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void saveView(WebView* view);
|
||||||
|
ClosedTabsManager::Tab getFirstClosedTab();
|
||||||
|
ClosedTabsManager::Tab getTabAt(int index);
|
||||||
|
|
||||||
|
bool isClosedTabAvailable();
|
||||||
|
|
||||||
|
QList<ClosedTabsManager::Tab> allClosedTabs() { return m_closedTabs; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<ClosedTabsManager::Tab> m_closedTabs;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CLOSEDTABSMANAGER_H
|
@ -87,8 +87,9 @@ void TabBar::contextMenuRequested(const QPoint &position)
|
|||||||
menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab()));
|
menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab()));
|
||||||
menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
|
menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
QAction* action = menu.addAction(QIcon::fromTheme("user-trash"),tr("Restore &Closed Tab"), tabWidget, SLOT(restoreClosedTab()));
|
QAction* action = p_QupZilla->actionRestoreTab();
|
||||||
tabWidget->canRestoreTab() ? action->setEnabled(true) : action->setEnabled(false);
|
tabWidget->canRestoreTab() ? action->setEnabled(true) : action->setEnabled(false);
|
||||||
|
menu.addAction(action);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent()));
|
menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent()));
|
||||||
menu.addAction(QIcon::fromTheme("window-close"),tr("Cl&ose"), this, SLOT(closeTab()));
|
menu.addAction(QIcon::fromTheme("window-close"),tr("Cl&ose"), this, SLOT(closeTab()));
|
||||||
@ -105,6 +106,7 @@ void TabBar::contextMenuRequested(const QPoint &position)
|
|||||||
QPoint pos = QCursor::pos();
|
QPoint pos = QCursor::pos();
|
||||||
QPoint p(pos.x(), pos.y()+1);
|
QPoint p(pos.x(), pos.y()+1);
|
||||||
menu.exec(p);
|
menu.exec(p);
|
||||||
|
p_QupZilla->actionRestoreTab()->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize TabBar::tabSizeHint(int index) const
|
QSize TabBar::tabSizeHint(int index) const
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
#include "webtab.h"
|
#include "webtab.h"
|
||||||
#include "clickablelabel.h"
|
#include "clickablelabel.h"
|
||||||
|
#include "closedtabsmanager.h"
|
||||||
|
|
||||||
class NewTabButton : public QToolButton
|
class NewTabButton : public QToolButton
|
||||||
{
|
{
|
||||||
@ -97,10 +98,8 @@ private:
|
|||||||
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) :
|
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) :
|
||||||
QTabWidget(parent)
|
QTabWidget(parent)
|
||||||
,p_QupZilla(mainClass)
|
,p_QupZilla(mainClass)
|
||||||
,m_canRestoreTab(false)
|
|
||||||
,m_lastTabIndex(0)
|
,m_lastTabIndex(0)
|
||||||
,m_lastTabUrl(0)
|
,m_closedTabsManager(new ClosedTabsManager(this))
|
||||||
,m_lastTabHistory(0)
|
|
||||||
{
|
{
|
||||||
m_tabBar = new TabBar(p_QupZilla);
|
m_tabBar = new TabBar(p_QupZilla);
|
||||||
setTabBar(m_tabBar);
|
setTabBar(m_tabBar);
|
||||||
@ -267,14 +266,8 @@ void TabWidget::closeTab(int index)
|
|||||||
disconnect(weView(index), SIGNAL(changed()), mApp, SLOT(setChanged()));
|
disconnect(weView(index), SIGNAL(changed()), mApp, SLOT(setChanged()));
|
||||||
disconnect(weView(index), SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
|
disconnect(weView(index), SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
|
||||||
//Save last tab url and history
|
//Save last tab url and history
|
||||||
if (!weView(index)->url().isEmpty()) {
|
m_closedTabsManager->saveView(weView(index));
|
||||||
m_lastTabUrl = weView(index)->url().toString();
|
|
||||||
QDataStream tabHistoryStream(&m_lastTabHistory, QIODevice::WriteOnly);
|
|
||||||
tabHistoryStream << *weView(index)->history();
|
|
||||||
m_canRestoreTab = true;
|
|
||||||
}
|
|
||||||
//weView(index)->page()->~QWebPage();
|
|
||||||
//weView(index)->~QWebView();
|
|
||||||
delete weView(index);
|
delete weView(index);
|
||||||
removeTab(index);
|
removeTab(index);
|
||||||
|
|
||||||
@ -310,7 +303,7 @@ void TabWidget::tabChanged(int index)
|
|||||||
|
|
||||||
void TabWidget::reloadAllTabs()
|
void TabWidget::reloadAllTabs()
|
||||||
{
|
{
|
||||||
for (int i = 0;i<count();i++) {
|
for (int i = 0; i<count(); i++) {
|
||||||
reloadTab(i);
|
reloadTab(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,13 +333,26 @@ void TabWidget::duplicateTab(int index)
|
|||||||
|
|
||||||
void TabWidget::restoreClosedTab()
|
void TabWidget::restoreClosedTab()
|
||||||
{
|
{
|
||||||
if (m_lastTabUrl.isEmpty())
|
if (!m_closedTabsManager->isClosedTabAvailable())
|
||||||
return;
|
return;
|
||||||
int index = addView(QUrl());
|
|
||||||
QDataStream historyStream(m_lastTabHistory);
|
ClosedTabsManager::Tab tab;
|
||||||
|
|
||||||
|
QAction* action = qobject_cast<QAction*>(sender());
|
||||||
|
if (action && action->data().toInt() != 0)
|
||||||
|
tab = m_closedTabsManager->getTabAt(action->data().toInt());
|
||||||
|
else
|
||||||
|
tab = m_closedTabsManager->getFirstClosedTab();
|
||||||
|
int index = addView(QUrl(), tab.title);
|
||||||
|
QDataStream historyStream(tab.history);
|
||||||
historyStream >> *weView(index)->history();
|
historyStream >> *weView(index)->history();
|
||||||
weView(index)->load(m_lastTabUrl);
|
|
||||||
m_canRestoreTab = false;
|
weView(index)->load(tab.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TabWidget::canRestoreTab()
|
||||||
|
{
|
||||||
|
return m_closedTabsManager->isClosedTabAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<WebTab*> TabWidget::allTabs(bool withPinned)
|
QList<WebTab*> TabWidget::allTabs(bool withPinned)
|
||||||
|
@ -32,6 +32,7 @@ class TabBar;
|
|||||||
class WebTab;
|
class WebTab;
|
||||||
class TabListButton;
|
class TabListButton;
|
||||||
class NewTabButton;
|
class NewTabButton;
|
||||||
|
class ClosedTabsManager;
|
||||||
|
|
||||||
class TabWidget : public QTabWidget
|
class TabWidget : public QTabWidget
|
||||||
{
|
{
|
||||||
@ -50,7 +51,8 @@ public:
|
|||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
inline TabBar* getTabBar() { return m_tabBar; }
|
inline TabBar* getTabBar() { return m_tabBar; }
|
||||||
inline bool canRestoreTab() { return m_canRestoreTab; }
|
inline ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
|
||||||
|
bool canRestoreTab();
|
||||||
QList<WebTab*> allTabs(bool withPinned = true);
|
QList<WebTab*> allTabs(bool withPinned = true);
|
||||||
|
|
||||||
|
|
||||||
@ -80,16 +82,14 @@ private:
|
|||||||
QUrl m_urlOnNewTab;
|
QUrl m_urlOnNewTab;
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
|
||||||
bool m_canRestoreTab;
|
|
||||||
int m_lastTabIndex;
|
int m_lastTabIndex;
|
||||||
QUrl m_lastTabUrl;
|
|
||||||
QByteArray m_lastTabHistory;
|
|
||||||
|
|
||||||
TabBar* m_tabBar;
|
TabBar* m_tabBar;
|
||||||
|
|
||||||
QMenu* m_menuTabs;
|
QMenu* m_menuTabs;
|
||||||
NewTabButton* m_buttonAddTab;
|
NewTabButton* m_buttonAddTab;
|
||||||
TabListButton* m_buttonListTabs;
|
TabListButton* m_buttonListTabs;
|
||||||
|
ClosedTabsManager* m_closedTabsManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TABWIDGET_H
|
#endif // TABWIDGET_H
|
||||||
|
@ -33,7 +33,7 @@ WebTab::WebTab(QupZilla* mainClass, QWidget* parent)
|
|||||||
m_view = new WebView(p_QupZilla);
|
m_view = new WebView(p_QupZilla);
|
||||||
m_layout->addWidget(m_view);
|
m_layout->addWidget(m_view);
|
||||||
|
|
||||||
setAutoFillBackground(true); // We don't want opaque this
|
setAutoFillBackground(true); // We don't want this transparent
|
||||||
|
|
||||||
connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
|
connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
|
||||||
}
|
}
|
||||||
@ -65,8 +65,8 @@ void WebTab::pinTab(int index)
|
|||||||
} else { // Pin tab
|
} else { // Pin tab
|
||||||
m_pinned = true;
|
m_pinned = true;
|
||||||
tabWidget->setCurrentIndex(0); // <<-- those 2 lines fixes
|
tabWidget->setCurrentIndex(0); // <<-- those 2 lines fixes
|
||||||
tabWidget->getTabBar()->moveTab(index, 0);// | weird bug with bad
|
tabWidget->getTabBar()->moveTab(index, 0); // | weird behavior with bad
|
||||||
tabWidget->setTabText(0, ""); // | tabwidget update if we
|
tabWidget->setTabText(0, ""); // | tabwidget update if we
|
||||||
tabWidget->setCurrentIndex(0); // <<-- are moving current tab
|
tabWidget->setCurrentIndex(0); // <<-- are moving current tab
|
||||||
tabWidget->getTabBar()->updateCloseButton(0);
|
tabWidget->getTabBar()->updateCloseButton(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user