Commit 0df27b4a authored by Calvin Buckley's avatar Calvin Buckley 🤔 Committed by Albert Astals Cid

Dock icon menu now lists windows

parent 4652a798
......@@ -642,6 +642,13 @@ void QCGTopLevel::createMenu()
this->windowMenu->addAction(_zoomAction);
connect(this->windowMenu, &QMenu::aboutToShow, this, &QCGTopLevel::windowListAboutToShow);
connect(this->windowMenu, &QMenu::triggered, this, &QCGTopLevel::windowListTriggered);
// right-clicking the dock icon should be a window list
this->macDockMenu = new QMenu(this);
connect(this->macDockMenu, &QMenu::aboutToShow, this, &QCGTopLevel::macDockMenuAboutToShow);
// it can reuse the same events, it just needs a diff menu structure
connect(this->macDockMenu, &QMenu::triggered, this, &QCGTopLevel::windowListTriggered);
this->macDockMenu->setAsDockMenu();
#endif
QMenu* helpMenu = mBar->addMenu(tr("&Help"));
......@@ -1848,20 +1855,14 @@ void QCGTopLevel::partsUnhideAllSlot()
#endif
}
void QCGTopLevel::windowListAboutToShow()
void QCGTopLevel::insertWindowList(QMenu* menu)
{
windowMenu->clear();
windowMenu->addAction(_minimizeAction);
windowMenu->addAction(_zoomAction);
windowMenu->addSeparator();
auto windowList = QApplication::topLevelWidgets();
for (int i = 0; i < windowList.size(); i++) {
QWidget *topLevelRaw = windowList[i];
if (QCGTopLevel *topLevel = qobject_cast<QCGTopLevel*>(topLevelRaw)) {
QString windowTitle = topLevel->windowTitle();
QAction *windowItem = windowMenu->addAction(windowTitle);
QAction *windowItem = menu->addAction(windowTitle);
windowItem->setData(QVariant::fromValue(topLevel));
if (topLevel == this) {
windowItem->setCheckable(true);
......@@ -1871,6 +1872,27 @@ void QCGTopLevel::windowListAboutToShow()
}
}
void QCGTopLevel::windowListAboutToShow()
{
windowMenu->clear();
windowMenu->addAction(_minimizeAction);
windowMenu->addAction(_zoomAction);
windowMenu->addSeparator();
insertWindowList(windowMenu);
}
void QCGTopLevel::macDockMenuAboutToShow()
{
macDockMenu-> clear();
insertWindowList(macDockMenu);
macDockMenu->addSeparator();
macDockMenu->addAction(_newAction);
}
void QCGTopLevel::forwardAboutToShow()
{
QMenu *popup = _forwardAction->menu();
......
......@@ -139,6 +139,8 @@ public Q_SLOTS:
void groupingAboutToShow();
void windowListTriggered(QAction*);
void windowListAboutToShow();
void macDockMenuAboutToShow();
void insertWindowList(QMenu*);
bool setEventType(EventType*);
bool setEventType2(EventType*);
......@@ -229,11 +231,11 @@ private:
QAction *_groupingMenuAction, *_closeAction;
QAction *_splittedToggleAction, *_splitDirectionToggleAction;
QAction *_layoutNext, *_layoutPrev, *_layoutRemove, *_layoutDup;
QAction *_layoutRestore, *_layoutSave;
QAction *_layoutRestore, *_layoutSave, *_toolbarToggleAction;
QAction *_upAction, *_forwardAction, *_backAction;
QAction *_configureAction, *_aboutAction, *_aboutQtAction;
QAction *_minimizeAction, *_zoomAction;
QMenu *windowMenu;
QMenu *windowMenu, *macDockMenu;
QComboBox* _eventTypeBox;
TraceFunction* _function;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment