diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 30bbf6854..69ef30167 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -174,6 +174,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
instanceToolbarSetting = APPLICATION->settings()->getSetting(setting_name);
ui->instanceToolBar->setVisibilityState(instanceToolbarSetting->get().toByteArray());
+
}
// set the menu for the folders and help tool buttons
diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui
index 6078ecbf4..218f0a2a2 100644
--- a/launcher/ui/MainWindow.ui
+++ b/launcher/ui/MainWindow.ui
@@ -106,6 +106,9 @@
false
+
+ true
+
RightToolBarArea
diff --git a/launcher/ui/widgets/WideBar.cpp b/launcher/ui/widgets/WideBar.cpp
index a029b0a88..717958fd3 100644
--- a/launcher/ui/widgets/WideBar.cpp
+++ b/launcher/ui/widgets/WideBar.cpp
@@ -7,15 +7,20 @@
class ActionButton : public QToolButton {
Q_OBJECT
public:
- ActionButton(QAction* action, QWidget* parent = nullptr) : QToolButton(parent), m_action(action)
+ ActionButton(QAction* action, QWidget* parent = nullptr, bool use_default_action = false) : QToolButton(parent),
+ m_action(action), m_use_default_action(use_default_action)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
// workaround for breeze and breeze forks
setProperty("_kde_toolButton_alignment", Qt::AlignLeft);
+ if (m_use_default_action) {
+ setDefaultAction(action);
+ } else {
+ connect(this, &ActionButton::clicked, action, &QAction::trigger);
+ }
connect(action, &QAction::changed, this, &ActionButton::actionChanged);
- connect(this, &ActionButton::clicked, action, &QAction::trigger);
actionChanged();
};
@@ -23,21 +28,24 @@ class ActionButton : public QToolButton {
void actionChanged()
{
setEnabled(m_action->isEnabled());
- setChecked(m_action->isChecked());
- setMenu(m_action->menu());
- if (menu()) {
+ // better pop up mode
+ if (m_action->menu()) {
setPopupMode(QToolButton::MenuButtonPopup);
}
- setCheckable(m_action->isCheckable());
- setText(m_action->text());
- setIcon(m_action->icon());
- setToolTip(m_action->toolTip());
- setHidden(!m_action->isVisible());
+ if (!m_use_default_action) {
+ setChecked(m_action->isChecked());
+ setCheckable(m_action->isCheckable());
+ setText(m_action->text());
+ setIcon(m_action->icon());
+ setToolTip(m_action->toolTip());
+ setHidden(!m_action->isVisible());
+ }
setFocusPolicy(Qt::NoFocus);
}
private:
QAction* m_action;
+ bool m_use_default_action;
};
WideBar::WideBar(const QString& title, QWidget* parent) : QToolBar(title, parent)
@@ -61,7 +69,7 @@ WideBar::WideBar(QWidget* parent) : QToolBar(parent)
void WideBar::addAction(QAction* action)
{
BarEntry entry;
- entry.bar_action = addWidget(new ActionButton(action, this));
+ entry.bar_action = addWidget(new ActionButton(action, this, m_use_default_action));
entry.menu_action = action;
entry.type = BarEntry::Type::Action;
@@ -93,7 +101,7 @@ void WideBar::insertActionBefore(QAction* before, QAction* action)
return;
BarEntry entry;
- entry.bar_action = insertWidget(iter->bar_action, new ActionButton(action, this));
+ entry.bar_action = insertWidget(iter->bar_action, new ActionButton(action, this, m_use_default_action));
entry.menu_action = action;
entry.type = BarEntry::Type::Action;
@@ -109,7 +117,7 @@ void WideBar::insertActionAfter(QAction* after, QAction* action)
return;
BarEntry entry;
- entry.bar_action = insertWidget((iter + 1)->bar_action, new ActionButton(action, this));
+ entry.bar_action = insertWidget((iter + 1)->bar_action, new ActionButton(action, this, m_use_default_action));
entry.menu_action = action;
entry.type = BarEntry::Type::Action;
diff --git a/launcher/ui/widgets/WideBar.h b/launcher/ui/widgets/WideBar.h
index 4004d4151..59bda5140 100644
--- a/launcher/ui/widgets/WideBar.h
+++ b/launcher/ui/widgets/WideBar.h
@@ -9,6 +9,9 @@
class WideBar : public QToolBar {
Q_OBJECT
+ // Why: so we can enable / disable alt shortcuts in toolbuttons
+ // with toolbuttons using setDefaultAction, theres no alt shortcuts
+ Q_PROPERTY(bool useDefaultAction MEMBER m_use_default_action)
public:
explicit WideBar(const QString& title, QWidget* parent = nullptr);
@@ -49,6 +52,8 @@ class WideBar : public QToolBar {
private:
QList m_entries;
+ bool m_use_default_action = false;
+
// Menu to toggle visibility from buttons in the bar
std::unique_ptr m_bar_menu = nullptr;
enum class MenuState { Fresh, Dirty } m_menu_state = MenuState::Dirty;