MCPcopy Create free account
hub / github.com/SeptemberHX/dde-top-panel / updateMenu

Method updateMenu

widgets/ActiveWindowControlWidget.cpp:276–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void ActiveWindowControlWidget::updateMenu() {
277 qDebug() << "ActiveWindowControlWidget#updateMenu() starts, current winID reported by menuModel is " << this->m_appMenuModel->winId()
278 << ", current winID reported by panel is " << this->currActiveWinId;
279 foreach (auto *label, this->buttonLabelListBak) {
280 label->deleteLater();
281 }
282 this->buttonLabelListBak.clear();
283
284 QList<QString> existedMenu; // tricks for twice menu of libreoffice
285 for (int r = 0; r < m_appMenuModel->rowCount(); ++r) {
286 QString menuStr = m_appMenuModel->data(m_appMenuModel->index(r, 0), AppMenuModel::MenuRole).toString();
287
288 // tricks to remove useless old menus
289 existedMenu.append(menuStr);
290
291 // create new clickable label for the new menu item
292 auto *m_label = new QClickableLabel(this->m_menuWidget);
293 menuStr = menuStr.remove('&');
294 int index = menuStr.lastIndexOf('(');
295 if (index > 0) {
296 menuStr = menuStr.mid(0, index);
297 }
298 m_label->setText(QString(" %1 ").arg(menuStr));
299 m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
300 connect(m_label, &QClickableLabel::clicked, this, &ActiveWindowControlWidget::menuLabelClicked);
301 this->buttonLabelListBak.append(m_label);
302 }
303
304 qDebug() << "organizeMenu() triggered by menuUpdate event";
305 this->organizeMenu();
306 qDebug() << "ActiveWindowControlWidget#updateMenu() ends";
307}
308
309void ActiveWindowControlWidget::menuLabelClicked() {
310 auto *label = dynamic_cast<QClickableLabel*>(sender());

Callers

nothing calls this directly

Calls 7

organizeMenuMethod · 0.95
foreachFunction · 0.85
winIdMethod · 0.80
rowCountMethod · 0.80
dataMethod · 0.80
setTextMethod · 0.80
QStringClass · 0.50

Tested by

no test coverage detected