mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Enabling actions moved to MacMenuReceiver.
This commit is contained in:
parent
ed928dc512
commit
4e87177c15
@ -601,32 +601,6 @@ void QupZilla::setupMenu()
|
||||
#endif
|
||||
}
|
||||
|
||||
void QupZilla::setEnabledSelectedMenuActions(QMenu* menu, const QList<int> indexList)
|
||||
{
|
||||
// we don't use this on other platforms
|
||||
#ifdef Q_OS_MAC
|
||||
if (!menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we mean all actions by empty list
|
||||
if (indexList.isEmpty()) {
|
||||
foreach (QAction * act, menu->actions()) {
|
||||
act->setEnabled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (int index, indexList) {
|
||||
Q_ASSERT(index < 0 || index >= menu->actions().size());
|
||||
menu->actions().at(index)->setEnabled(true);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(menu);
|
||||
Q_UNUSED(indexList);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QupZilla::loadSettings()
|
||||
{
|
||||
Settings settings;
|
||||
@ -816,8 +790,6 @@ void QupZilla::aboutToShowFileMenu()
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
m_actionCloseWindow->setEnabled(mApp->windowCount() > 1);
|
||||
#else
|
||||
setEnabledSelectedMenuActionsons(m_menuFile);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -828,8 +800,6 @@ void QupZilla::aboutToHideFileMenu()
|
||||
|
||||
void QupZilla::aboutToShowBookmarksMenu()
|
||||
{
|
||||
setEnabledSelectedMenuActions(m_menuBookmarks, QList<int>() << 0 << 1 << 2);
|
||||
|
||||
if (!MENU_RECEIVER->bookmarksMenuChanged()) {
|
||||
if (m_menuBookmarksAction) {
|
||||
m_menuBookmarksAction->setVisible(m_bookmarksToolbar->isVisible());
|
||||
@ -944,8 +914,6 @@ void QupZilla::aboutToShowBookmarksMenu()
|
||||
|
||||
void QupZilla::aboutToShowHistoryMenu()
|
||||
{
|
||||
// 2=Home, 3=Show all History, 7=Closed Tabs
|
||||
setEnabledSelectedMenuActions(m_menuHistory, QList<int>() << 2 << 3 << 7);
|
||||
TabbedWebView* view = weView();
|
||||
if (!view) {
|
||||
return;
|
||||
@ -1046,16 +1014,8 @@ void QupZilla::aboutToShowViewMenu()
|
||||
m_actionPageSource->setEnabled(true);
|
||||
|
||||
#if QTWEBKIT_FROM_2_3
|
||||
m_actionCaretBrowsing->setEnabled(true);
|
||||
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
// 7,8,9=Zoom actions, 12=Character Encoding, 15=Fullscreen
|
||||
setEnabledSelectedMenuActionsons(m_menuView, QList<int>()
|
||||
<< 0 << 1 << 2 << 7 << 8 << 9 << 12 << 15);
|
||||
// for updating reload and stop actions
|
||||
updateLoadingActions();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QupZilla::aboutToHideViewMenu()
|
||||
@ -1075,9 +1035,6 @@ void QupZilla::aboutToShowEditMenu()
|
||||
m_menuEdit->actions().at(5)->setEnabled(view->pageAction(QWebPage::Paste)->isEnabled());
|
||||
// Separator
|
||||
m_menuEdit->actions().at(7)->setEnabled(view->pageAction(QWebPage::SelectAll)->isEnabled());
|
||||
|
||||
// Find action
|
||||
m_menuEdit->actions().at(8)->setEnabled(true);
|
||||
}
|
||||
|
||||
void QupZilla::aboutToHideEditMenu()
|
||||
@ -1093,9 +1050,6 @@ void QupZilla::aboutToHideEditMenu()
|
||||
void QupZilla::aboutToShowToolsMenu()
|
||||
{
|
||||
m_actionPageInfo->setEnabled(true);
|
||||
|
||||
// enable all
|
||||
setEnabledSelectedMenuActions(m_menuTools);
|
||||
}
|
||||
|
||||
void QupZilla::aboutToHideToolsMenu()
|
||||
|
@ -215,7 +215,6 @@ private:
|
||||
|
||||
void setupUi();
|
||||
void setupMenu();
|
||||
void setEnabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
|
||||
|
||||
void disconnectObjects();
|
||||
|
||||
|
@ -36,6 +36,26 @@ bool MacMenuReceiver::bookmarksMenuChanged()
|
||||
return mApp->getWindow() && mApp->getWindow()->bookmarksMenuChanged();
|
||||
}
|
||||
|
||||
void MacMenuReceiver::setEnabledSelectedMenuActions(QMenu* menu, const QList<int> indexList)
|
||||
{
|
||||
if (!menu || mApp->windowCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we mean all actions by empty list
|
||||
if (indexList.isEmpty()) {
|
||||
foreach (QAction * act, menu->actions()) {
|
||||
act->setEnabled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (int index, indexList) {
|
||||
Q_ASSERT(index < 0 || index >= menu->actions().size());
|
||||
menu->actions().at(index)->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MacMenuReceiver::setDisabledSelectedMenuActions(QMenu* menu, const QList<int> indexList)
|
||||
{
|
||||
if (!menu) {
|
||||
@ -408,8 +428,10 @@ void MacMenuReceiver::loadActionUrlInNewNotSelectedTab(QObject* obj)
|
||||
// about to show/hide slots
|
||||
void MacMenuReceiver::aboutToShowFileMenu()
|
||||
{
|
||||
QMenu* menu = qobject_cast<QMenu*>(sender());
|
||||
setEnabledSelectedMenuActions(menu);
|
||||
if (!callSlot("aboutToShowFileMenu")) {
|
||||
setDisabledSelectedMenuActions(qobject_cast<QMenu*>(sender()), QList<int>()
|
||||
setDisabledSelectedMenuActions(menu, QList<int>()
|
||||
<< 4 << 5 << 7 << 8 << 9 << 10 << 12);
|
||||
}
|
||||
}
|
||||
@ -421,8 +443,11 @@ void MacMenuReceiver::aboutToHideFileMenu()
|
||||
|
||||
void MacMenuReceiver::aboutToShowHistoryMenu()
|
||||
{
|
||||
QMenu* menu = qobject_cast<QMenu*>(sender());
|
||||
// 2=Home, 3=Show all History, 7=Closed Tabs
|
||||
setEnabledSelectedMenuActions(menu, QList<int>() << 2 << 3 << 7);
|
||||
if (!callSlot("aboutToShowHistoryMenu")) {
|
||||
setDisabledSelectedMenuActions(qobject_cast<QMenu*>(sender()), QList<int>()
|
||||
setDisabledSelectedMenuActions(menu, QList<int>()
|
||||
<< 0 << 1 << 2 << 3 << 7);
|
||||
}
|
||||
}
|
||||
@ -439,16 +464,26 @@ void MacMenuReceiver::aboutToShowClosedTabsMenu()
|
||||
|
||||
void MacMenuReceiver::aboutToShowBookmarksMenu()
|
||||
{
|
||||
QMenu* menu = qobject_cast<QMenu*>(sender());
|
||||
setEnabledSelectedMenuActions(menu, QList<int>() << 0 << 1 << 2);
|
||||
if (!callSlot("aboutToShowBookmarksMenu")) {
|
||||
setDisabledSelectedMenuActions(qobject_cast<QMenu*>(sender()), QList<int>()
|
||||
<< 0 << 1 << 2);
|
||||
setDisabledSelectedMenuActions(menu, QList<int>() << 0 << 1 << 2);
|
||||
}
|
||||
}
|
||||
|
||||
void MacMenuReceiver::aboutToShowViewMenu()
|
||||
{
|
||||
QMenu* 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);
|
||||
// for updating reload and stop actions
|
||||
if (mApp->getWindow()) {
|
||||
mApp->getWindow()->updateLoadingActions();
|
||||
}
|
||||
|
||||
if (!callSlot("aboutToShowViewMenu")) {
|
||||
setDisabledSelectedMenuActions(qobject_cast<QMenu*>(sender()));
|
||||
setDisabledSelectedMenuActions(menu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,8 +494,11 @@ void MacMenuReceiver::aboutToHideViewMenu()
|
||||
|
||||
void MacMenuReceiver::aboutToShowEditMenu()
|
||||
{
|
||||
QMenu* menu = qobject_cast<QMenu*>(sender());
|
||||
// 8=Find
|
||||
setEnabledSelectedMenuActions(menu, QList<int>() << 8);
|
||||
if (!callSlot("aboutToShowEditMenu")) {
|
||||
setDisabledSelectedMenuActions(qobject_cast<QMenu*>(sender()));
|
||||
setDisabledSelectedMenuActions(menu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,8 +509,11 @@ void MacMenuReceiver::aboutToHideEditMenu()
|
||||
|
||||
void MacMenuReceiver::aboutToShowToolsMenu()
|
||||
{
|
||||
QMenu* menu = qobject_cast<QMenu*>(sender());
|
||||
// enable all
|
||||
setEnabledSelectedMenuActions(menu);
|
||||
if (!callSlot("aboutToShowToolsMenu")) {
|
||||
setDisabledSelectedMenuActions(qobject_cast<QMenu*>(sender()), QList<int>()
|
||||
setDisabledSelectedMenuActions(menu, QList<int>()
|
||||
<< 0 << 1 << 3 << 4 << 6 << 7 << 8);
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
bool bookmarksMenuChanged();
|
||||
|
||||
private:
|
||||
void setEnabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
|
||||
void setDisabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
|
||||
bool callSlot(const char *member, bool makeIfNoWindow = false,
|
||||
QGenericArgument val0 = QGenericArgument(0),
|
||||
|
Loading…
Reference in New Issue
Block a user