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

[Mac] Fixed, refresh state of menu actions

This commit is contained in:
S. Razi Alavizadeh 2013-03-16 13:06:29 +03:30
parent 3346c8f1ce
commit 0293a7bcd3
4 changed files with 40 additions and 18 deletions

View File

@ -192,7 +192,10 @@ void QupZilla::postLaunch()
}
break;
#ifdef Q_OS_MAC
case Qz::BW_MacFirstWindow:
QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions()));
#endif
case Qz::BW_NewWindow:
addTab = true;
break;
@ -247,6 +250,8 @@ void QupZilla::postLaunch()
QMainWindow::setWindowTitle(m_lastWindowTitle);
setUpdatesEnabled(true);
raise();
activateWindow();
}
void QupZilla::setupUi()
@ -701,6 +706,16 @@ void QupZilla::setupMacMenu()
m_actionPageInfo = m_menuTools->actions().at(1);
m_actionPrivateBrowsing = m_menuTools->actions().at(9);
}
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);
}
#endif
void QupZilla::loadSettings()
@ -2122,6 +2137,8 @@ void QupZilla::closeEvent(QCloseEvent* event)
return;
}
#else
QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions()));
#endif
mApp->aboutToCloseWindow(this);

View File

@ -209,6 +209,9 @@ private slots:
void restoreAllClosedTabs();
void clearClosedTabsList();
void hideNavigationSlot();
#ifdef Q_OS_MAC
void refreshStateOfAllActions();
#endif
private:
bool event(QEvent* event);

View File

@ -426,9 +426,9 @@ void MacMenuReceiver::loadActionUrlInNewNotSelectedTab(QObject* obj)
}
// about to show/hide slots
void MacMenuReceiver::aboutToShowFileMenu()
void MacMenuReceiver::aboutToShowFileMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
setEnabledSelectedMenuActions(menu);
if (!callSlot("aboutToShowFileMenu")) {
setDisabledSelectedMenuActions(menu, QList<int>()
@ -441,9 +441,9 @@ void MacMenuReceiver::aboutToHideFileMenu()
callSlot("aboutToHideFileMenu");
}
void MacMenuReceiver::aboutToShowHistoryMenu()
void MacMenuReceiver::aboutToShowHistoryMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// 2=Home, 3=Show all History, 7=Closed Tabs
setEnabledSelectedMenuActions(menu, QList<int>() << 2 << 3 << 7);
if (!callSlot("aboutToShowHistoryMenu")) {
@ -462,18 +462,18 @@ void MacMenuReceiver::aboutToShowClosedTabsMenu()
callSlot("aboutToShowClosedTabsMenu");
}
void MacMenuReceiver::aboutToShowBookmarksMenu()
void MacMenuReceiver::aboutToShowBookmarksMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
setEnabledSelectedMenuActions(menu, QList<int>() << 0 << 1 << 2);
if (!callSlot("aboutToShowBookmarksMenu")) {
setDisabledSelectedMenuActions(menu, QList<int>() << 0 << 1 << 2);
}
}
void MacMenuReceiver::aboutToShowViewMenu()
void MacMenuReceiver::aboutToShowViewMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// 7,8,9=Zoom actions, 12=Character Encoding, 15=Fullscreen
setEnabledSelectedMenuActions(menu, QList<int>()
<< 0 << 1 << 2 << 7 << 8 << 9 << 11 << 12 << 15);
@ -492,9 +492,9 @@ void MacMenuReceiver::aboutToHideViewMenu()
callSlot("aboutToHideViewMenu");
}
void MacMenuReceiver::aboutToShowEditMenu()
void MacMenuReceiver::aboutToShowEditMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// 8=Find
setEnabledSelectedMenuActions(menu, QList<int>() << 8);
if (!callSlot("aboutToShowEditMenu")) {
@ -507,9 +507,9 @@ void MacMenuReceiver::aboutToHideEditMenu()
callSlot("aboutToHideEditMenu");
}
void MacMenuReceiver::aboutToShowToolsMenu()
void MacMenuReceiver::aboutToShowToolsMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// enable all
setEnabledSelectedMenuActions(menu);
if (!callSlot("aboutToShowToolsMenu")) {

View File

@ -44,6 +44,14 @@ public:
inline QAction* menuBookmarksAction() { return m_menuBookmarksAction; }
inline void setMenuBookmarksAction(QAction* action) { m_menuBookmarksAction = action; }
public slots:
void aboutToShowFileMenu(QMenu* menu = 0);
void aboutToShowEditMenu(QMenu* menu = 0);
void aboutToShowViewMenu(QMenu* menu = 0);
void aboutToShowHistoryMenu(QMenu* menu = 0);
void aboutToShowBookmarksMenu(QMenu* menu = 0);
void aboutToShowToolsMenu(QMenu* menu = 0);
private:
void setEnabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
void setDisabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
@ -66,17 +74,11 @@ private slots:
void addTab();
void savePageScreen();
void aboutToShowFileMenu();
void aboutToHideFileMenu();
void aboutToShowHistoryMenu();
void aboutToHideHistoryMenu();
void aboutToShowClosedTabsMenu();
void aboutToShowBookmarksMenu();
void aboutToShowViewMenu();
void aboutToHideViewMenu();
void aboutToShowEditMenu();
void aboutToHideEditMenu();
void aboutToShowToolsMenu();
void aboutToHideToolsMenu();
void aboutToShowEncodingMenu();