diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-12-13 16:28:53 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-12-13 16:28:53 +0100 |
commit | 595a1b3a0e5fb098211441849a3993193beb5787 (patch) | |
tree | eb8841932a0927b7aff8570d0d4c0f0124007d0d /lib/web | |
parent | Add lang/meson.build (diff) | |
download | smolbote-595a1b3a0e5fb098211441849a3993193beb5787.tar.xz |
Profile picker menu: use QActionGroup instead of QRadioButton
Diffstat (limited to 'lib/web')
-rw-r--r-- | lib/web/profilemanager.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/web/profilemanager.cpp b/lib/web/profilemanager.cpp index 6e6281b..0bae251 100644 --- a/lib/web/profilemanager.cpp +++ b/lib/web/profilemanager.cpp @@ -10,8 +10,6 @@ #include "webprofile.h" #include <QFileInfo> #include <QWebEngineSettings> -#include <QWidgetAction> -#include <QRadioButton> ProfileManager::ProfileManager(const QHash<QString, QString> &profileSection, QObject *parent) : QObject(parent) @@ -115,20 +113,22 @@ void ProfileManager::deleteProfile(const QString &id) void ProfileManager::profilePickerMenu(QMenu *menu, WebProfile *current, std::function<void(WebProfile *)> callback) const { + auto *profileGroup = new QActionGroup(menu); + for(const auto &profileData : m_profiles) { WebProfile *profile = profileData.second->profile; - auto *profileButton = new QRadioButton(profile->name(), menu); - profileButton->setChecked(profile == current); - - auto *action = new QWidgetAction(menu); - action->setDefaultWidget(profileButton); - connect(profileButton, &QRadioButton::clicked, profile, [profile, callback]() { + auto *action = menu->addAction(profile->name(), profile, [profile, callback]() { callback(profile); }); + action->setCheckable(true); + profileGroup->addAction(action); - menu->addAction(action); + if(profile == current) + action->setChecked(true); } + + connect(menu, &QMenu::aboutToHide, profileGroup, &QActionGroup::deleteLater); } QMenu *ProfileManager::createProfileMenu(std::function<void(WebProfile *)> callback, QWidget *parent) const |