aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-13 16:28:53 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-13 16:28:53 +0100
commit595a1b3a0e5fb098211441849a3993193beb5787 (patch)
treeeb8841932a0927b7aff8570d0d4c0f0124007d0d
parentAdd lang/meson.build (diff)
downloadsmolbote-595a1b3a0e5fb098211441849a3993193beb5787.tar.xz
Profile picker menu: use QActionGroup instead of QRadioButton
-rw-r--r--lib/web/profilemanager.cpp18
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