Commit f77565c9 authored by David Redondo's avatar David Redondo 🏎 Committed by Nate Graham
Browse files

appmenu: Use existing menu in compact represenation

There's no need to reconstruct the entire menu, when it exists already.
Also shows correct behavior on Wayland because the imported menues have
correct parents compared to the new  one.
BUG:438467


(cherry picked from commit 16ae8b9e)
parent a1153e6a
Pipeline #159736 passed with stage
in 12 minutes and 26 seconds
......@@ -125,14 +125,10 @@ QMenu *AppMenuApplet::createMenu(int idx) const
QAction *action = nullptr;
if (view() == CompactView) {
menu = new QMenu();
for (int i = 0; i < m_model->rowCount(); i++) {
const QModelIndex index = m_model->index(i, 0);
const QVariant data = m_model->data(index, AppMenuModel::ActionRole);
action = (QAction *)data.value<void *>();
menu->addAction(action);
auto menuAction = static_cast<QAction*>(m_model->data(QModelIndex(), AppMenuModel::ActionRole).value<void *>());
if (menuAction) {
menu = menuAction->menu();
}
menu->setAttribute(Qt::WA_DeleteOnClose);
} else if (view() == FullView) {
const QModelIndex index = m_model->index(idx, 0);
const QVariant data = m_model->data(index, AppMenuModel::ActionRole);
......
......@@ -234,12 +234,20 @@ QList<QAction *> AppMenuModel::flatActionList()
QVariant AppMenuModel::data(const QModelIndex &index, int role) const
{
const int row = index.row();
if (row < 0 || !m_menuAvailable || !m_menu) {
if (!m_menuAvailable || !m_menu) {
return QVariant();
}
if (!index.isValid()) {
if (role == MenuRole) {
return QString();
} else if (role == ActionRole) {
return QVariant::fromValue((void *)(m_menu->menuAction()));
}
}
const auto actions = m_menu->actions();
const int row = index.row();
if (row == actions.count() && KWindowSystem::isPlatformWayland()) {
if (role == MenuRole) {
return m_searchAction->text();
......
Supports Markdown
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