MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / resetWindowListMenu

Method resetWindowListMenu

src/WizMainWindow.cpp:1488–1534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486
1487
1488void WizMainWindow::resetWindowListMenu(QMenu* menu, bool removeExists)
1489{
1490 QList<QAction*> actionList = menu->actions();
1491 QWidget * activeWidget = QApplication::activeWindow();
1492 // if current app is not active, there will no activewindow. remenber last active window to set menu item checkstate
1493 static QWidget * lastActiveWidget = activeWidget;
1494 activeWidget == nullptr ? (activeWidget = lastActiveWidget) : (lastActiveWidget = activeWidget);
1495// QIcon icon = Utils::StyleHelper::loadIcon("actionSaveAsHtml");
1496
1497 QList<QAction*> newActions;
1498 QAction* action = nullptr;
1499 if (removeExists)
1500 {
1501 action = actionByGuid(actionList, MAINWINDOW);
1502 menu->removeAction(action);
1503 }
1504
1505 action = new QAction(tr("WizNote"), menu);
1506 action->setData(MAINWINDOW);
1507 action->setCheckable(true);
1508 action->setChecked((activeWidget == nullptr || activeWidget == this));
1509 newActions.append(action);
1510
1511 QMap<QString, WizSingleDocumentViewer*>& viewerMap = m_singleViewMgr->getDocumentViewerMap();
1512 QList<QString> keys = viewerMap.keys();
1513 for (int i = 0; i < keys.count(); i++)
1514 {
1515 WizSingleDocumentViewer* viewer = viewerMap.value(keys.at(i));
1516 if (removeExists)
1517 {
1518 action = actionByGuid(actionList, keys.at(i));
1519 menu->removeAction(action);
1520 }
1521 action = new QAction(viewer->windowTitle(), menu);
1522 action->setData(keys.at(i));
1523 action->setCheckable(true);
1524 action->setChecked(viewer == activeWidget);
1525 newActions.append(action);
1526 }
1527
1528 qSort(newActions.begin(), newActions.end(), caseInsensitiveLessThan);
1529 for (QAction* action : newActions)
1530 {
1531 connect(action, SIGNAL(triggered()), SLOT(on_dockMenuAction_triggered()));
1532 }
1533 menu->addActions(newActions);
1534}
1535
1536void WizMainWindow::changeDocumentsSortTypeByAction(QAction* action)
1537{

Callers

nothing calls this directly

Calls 7

actionByGuidFunction · 0.85
connectFunction · 0.85
actionsMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
setDataMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected