| 23 | namespace Menu { |
| 24 | |
| 25 | void RefreshDockMenu(QMenu *menu) { |
| 26 | menu->clear(); |
| 27 | if (!Core::IsAppLaunched()) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | const auto accounts = Core::App().domain().orderedAccounts(); |
| 32 | if (accounts.size() > 1 && !Core::App().passcodeLocked()) { |
| 33 | menu->addSeparator(); |
| 34 | const auto profilesHeader = menu->addAction( |
| 35 | tr::lng_mac_menu_profiles(tr::now)); |
| 36 | profilesHeader->setEnabled(false); |
| 37 | constexpr auto kMaxLength = 30; |
| 38 | for (const auto &account : accounts) { |
| 39 | if (account->sessionExists()) { |
| 40 | const auto name = account->session().user()->name(); |
| 41 | menu->addAction( |
| 42 | (name.size() > kMaxLength) |
| 43 | ? (name.mid(0, kMaxLength) + Ui::kQEllipsis) |
| 44 | : name, |
| 45 | [account] { |
| 46 | Core::App().ensureSeparateWindowFor(account); |
| 47 | }); |
| 48 | } |
| 49 | } |
| 50 | menu->addSeparator(); |
| 51 | } |
| 52 | |
| 53 | menu->addAction( |
| 54 | Core::App().settings().desktopNotify() |
| 55 | ? tr::lng_disable_notifications_from_tray(tr::now) |
| 56 | : tr::lng_enable_notifications_from_tray(tr::now), |
| 57 | [] { |
| 58 | auto &settings = Core::App().settings(); |
| 59 | settings.setDesktopNotify(!settings.desktopNotify()); |
| 60 | }); |
| 61 | |
| 62 | using namespace Media::Player; |
| 63 | const auto type = instance()->getActiveType(); |
| 64 | const auto state = instance()->getState(type); |
| 65 | if (!IsStoppedOrStopping(state.state)) { |
| 66 | menu->addSeparator(); |
| 67 | const auto previous = menu->addAction( |
| 68 | tr::lng_mac_menu_player_previous(tr::now), |
| 69 | [] { instance()->previous(); }); |
| 70 | previous->setEnabled(instance()->previousAvailable(type)); |
| 71 | menu->addAction( |
| 72 | IsPausedOrPausing(state.state) |
| 73 | ? tr::lng_mac_menu_player_resume(tr::now) |
| 74 | : tr::lng_mac_menu_player_pause(tr::now), |
| 75 | [] { instance()->playPause(); }); |
| 76 | const auto next = menu->addAction( |
| 77 | tr::lng_mac_menu_player_next(tr::now), |
| 78 | [] { instance()->next(); }); |
| 79 | next->setEnabled(instance()->nextAvailable(type)); |
| 80 | } |
| 81 | } |
| 82 |
nothing calls this directly
no test coverage detected