Skip to content

Commit 7b2fbc2

Browse files
ivaradimgallien
authored andcommitted
fix(tray): GNOME + AppIndicator compatibility
The account submenu does not work in a standard (Ubuntu) GNOME environment, for the following reasons: * If the submenu is empty, no `aboutToShow` event is sent. This patch pre-populates the submenu. * If the submenu is updated when handling `aboutToShow`, it will be closed immediately. This patch causes the event handler to only fetch the activities in this case. It will still enable dynamic updates for KDE, i.e. `dataChanged` will be called. In case of GNOME, however, the menu is not marked visible, thus the `dataChanged` handler will not update (and thus close) the menu. However, since the tray menu is built when opening, the contents will be relatively recent even there, though not updating. Signed-off-by: István Váradi <ivaradi@varadiistvan.hu>
1 parent d7576fc commit 7b2fbc2

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/gui/trayaccountpopup_qt.cpp‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,10 @@ void addRecentActivities(QMenu *menu, const int userId, const QVariantList &rece
701701

702702
void populateAccountMenu(QMenu *menu, const int userId, const bool fetchActivityPreview = true)
703703
{
704-
setFixedMenuWidth(menu);
705-
clearDynamicMenu(menu);
704+
if (!fetchActivityPreview) {
705+
setFixedMenuWidth(menu);
706+
clearDynamicMenu(menu);
707+
}
706708

707709
const auto userModel = UserModel::instance();
708710
if (!userModel || userId < 0 || userId >= userModel->rowCount()) {
@@ -716,6 +718,7 @@ void populateAccountMenu(QMenu *menu, const int userId, const bool fetchActivity
716718
};
717719
if (fetchActivityPreview && policy.fetchActivityPreview()) {
718720
userModel->fetchActivityPreview(userId);
721+
return;
719722
}
720723

721724
const auto menuIconPalette = nativeMenuIconPalette(menu);
@@ -807,9 +810,6 @@ void populateAccountMenu(QMenu *menu, const int userId, const bool fetchActivity
807810
QCoreApplication::translate("TrayWindowHeader", "Apps"));
808811
setFixedMenuWidth(appsMenu);
809812
appsMenu->menuAction()->setEnabled(populateAppsMenu(appsMenu, userId));
810-
QObject::connect(appsMenu, &QMenu::aboutToShow, appsMenu, [appsMenu, userId] {
811-
appsMenu->menuAction()->setEnabled(populateAppsMenu(appsMenu, userId));
812-
});
813813

814814
menu->addSeparator();
815815

@@ -842,8 +842,9 @@ void populateTrayMenu(QMenu *menu, Systray *systray)
842842

843843
const auto accountMenu = addSubMenu(menu, accountIcon, accountText);
844844
setFixedMenuWidth(accountMenu);
845+
populateAccountMenu(accountMenu, userId, false);
845846
QObject::connect(accountMenu, &QMenu::aboutToShow, accountMenu, [accountMenu, userId] {
846-
populateAccountMenu(accountMenu, userId);
847+
populateAccountMenu(accountMenu, userId, true);
847848
});
848849
QObject::connect(userModel,
849850
&QAbstractItemModel::dataChanged,

0 commit comments

Comments
 (0)