diff options
-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 |