1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[Mac Global Menu] Added some new slots to support our MENU_RECEIVER idea.

This commit is contained in:
S. Razi Alavizadeh 2013-02-07 17:31:25 +03:30
parent 860b5b8440
commit ed928dc512
6 changed files with 78 additions and 10 deletions

View File

@ -348,7 +348,7 @@ void QupZilla::setupMenu()
m_menuFile->addAction(QIcon(":/icons/menu/new-tab.png"), tr("New Tab"), MENU_RECEIVER, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T"));
m_menuFile->addAction(QIcon::fromTheme("document-open-remote"), tr("Open Location"), MENU_RECEIVER, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L"));
m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File"), MENU_RECEIVER, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O"));
m_menuFile->addAction(tr("Close Tab"), m_tabWidget, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
m_menuFile->addAction(tr("Close Tab"), MENU_RECEIVER, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
m_actionCloseWindow = m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), MENU_RECEIVER, SLOT(closeWindow()));
m_actionCloseWindow->setShortcut(QKeySequence("Ctrl+Shift+W"));
m_menuFile->addSeparator();
@ -558,7 +558,7 @@ void QupZilla::setupMenu()
*****************/
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()));
connect(m_actionRestoreTab, SIGNAL(triggered()), MENU_RECEIVER, SLOT(restoreClosedTab()));
addAction(m_actionRestoreTab);
QShortcut* reloadByPassCacheAction = new QShortcut(QKeySequence("Ctrl+F5"), this);
@ -579,7 +579,7 @@ void QupZilla::setupMenu()
connect(openLocationAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(openLocation()));
QShortcut* closeTabAction = new QShortcut(QKeySequence("Ctrl+F4"), this);
connect(closeTabAction, SIGNAL(activated()), m_tabWidget, SLOT(closeTab()));
connect(closeTabAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(closeTab()));
// Make shortcuts available even in fullscreen (menu hidden)
QList<QAction*> actions = menuBar()->actions();
@ -830,7 +830,7 @@ void QupZilla::aboutToShowBookmarksMenu()
{
setEnabledSelectedMenuActions(m_menuBookmarks, QList<int>() << 0 << 1 << 2);
if (!m_bookmarksMenuChanged) {
if (!MENU_RECEIVER->bookmarksMenuChanged()) {
if (m_menuBookmarksAction) {
m_menuBookmarksAction->setVisible(m_bookmarksToolbar->isVisible());
}
@ -971,7 +971,7 @@ void QupZilla::aboutToShowClosedTabsMenu()
title.truncate(40);
title += "..";
}
m_menuClosedTabs->addAction(_iconForUrl(tab.url), title, m_tabWidget, SLOT(restoreClosedTab()))->setData(i);
m_menuClosedTabs->addAction(_iconForUrl(tab.url), title, MENU_RECEIVER, SLOT(restoreClosedTab()))->setData(i);
i++;
}
m_menuClosedTabs->addSeparator();
@ -979,8 +979,8 @@ void QupZilla::aboutToShowClosedTabsMenu()
m_menuClosedTabs->addAction(tr("Empty"))->setEnabled(false);
}
else {
m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), m_tabWidget, SLOT(restoreAllClosedTabs()));
m_menuClosedTabs->addAction(tr("Clear list"), m_tabWidget, SLOT(clearClosedTabsList()));
m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), MENU_RECEIVER, SLOT(restoreAllClosedTabs()));
m_menuClosedTabs->addAction(tr("Clear list"), MENU_RECEIVER, SLOT(clearClosedTabsList()));
}
}
@ -2051,6 +2051,29 @@ bool QupZilla::quitApp()
return true;
}
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();
}
QByteArray QupZilla::saveState(int version) const
{
#ifdef QZ_WS_X11

View File

@ -103,6 +103,8 @@ public:
inline bool isClosing() { return m_isClosing; }
inline QUrl homepageUrl() { return m_homepage; }
inline bool bookmarksMenuChanged() { return m_bookmarksMenuChanged; }
signals:
void startingCompleted();
void message(Qz::AppMessageType mes, bool state);
@ -195,6 +197,10 @@ private slots:
void closeWindow();
bool quitApp();
void closeTab();
void restoreClosedTab(QObject* obj = 0);
void restoreAllClosedTabs();
void clearClosedTabsList();
#ifdef Q_OS_WIN
void applyBlurToMainWindow(bool force = false);
#endif

View File

@ -31,6 +31,11 @@ MacMenuReceiver::MacMenuReceiver(QObject* parent)
{
}
bool MacMenuReceiver::bookmarksMenuChanged()
{
return mApp->getWindow() && mApp->getWindow()->bookmarksMenuChanged();
}
void MacMenuReceiver::setDisabledSelectedMenuActions(QMenu* menu, const QList<int> indexList)
{
if (!menu) {
@ -335,6 +340,30 @@ void MacMenuReceiver::loadFolderBookmarks(Menu* menu)
callSlot("loadFolderBookmarks", false, Q_ARG(Menu*, menu));
}
void MacMenuReceiver::closeTab()
{
callSlot("closeTab");
}
void MacMenuReceiver::restoreClosedTab(QObject* obj)
{
if (!obj) {
obj = sender();
}
callSlot("restoreClosedTab", false, Q_ARG(QObject*, obj));
}
void MacMenuReceiver::restoreAllClosedTabs()
{
callSlot("restoreAllClosedTabs");
}
void MacMenuReceiver::clearClosedTabsList()
{
callSlot("clearClosedTabsList");
}
void MacMenuReceiver::showPageInfo()
{
callSlot("showPageInfo");

View File

@ -33,6 +33,8 @@ class QT_QUPZILLA_EXPORT MacMenuReceiver : public QObject
public:
MacMenuReceiver(QObject* parent = 0);
bool bookmarksMenuChanged();
private:
void setDisabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
bool callSlot(const char *member, bool makeIfNoWindow = false,
@ -119,5 +121,10 @@ private slots:
void loadActionUrlInNewTab(QObject* obj = 0);
void loadActionUrlInNewNotSelectedTab(QObject* obj = 0);
void loadFolderBookmarks(Menu* menu);
void closeTab();
void restoreClosedTab(QObject* obj = 0);
void restoreAllClosedTabs();
void clearClosedTabsList();
};
#endif // MACMENURECEIVER_H

View File

@ -641,15 +641,18 @@ int TabWidget::duplicateTab(int index)
return id;
}
void TabWidget::restoreClosedTab()
void TabWidget::restoreClosedTab(QObject* obj)
{
if (!obj) {
obj = sender();
}
if (!m_closedTabsManager->isClosedTabAvailable()) {
return;
}
ClosedTabsManager::Tab tab;
QAction* action = qobject_cast<QAction*>(sender());
QAction* action = qobject_cast<QAction*>(obj);
if (action && action->data().toInt() != 0) {
tab = m_closedTabsManager->getTabAt(action->data().toInt());
}

View File

@ -110,7 +110,7 @@ public slots:
void reloadAllTabs();
void stopTab(int index);
void closeAllButCurrent(int index);
void restoreClosedTab();
void restoreClosedTab(QObject* obj = 0);
void restoreAllClosedTabs();
void clearClosedTabsList();
void aboutToShowClosedTabsMenu();