refactor: Port the main window to a .ui file

some stuff still needs to be done in the c++ side because qt designer is dumb >:(

the instance toolbar icon and instance name buttons are still added manually inside MainWindow.cpp

looks almost identical, with some minor tweaks:
- the instance toolbar is now a WideBar, so you can customize what actions you want :D
- the instance toolbar buttons are now fullwidth
- the close window button is now at the end of the file menu
- the help menu has some layout changes

this also fixes some stuff:
- menus not having tooltips
- the top toolbar not connecting to the title bar in kde
- the instance toolbar separators looking weird after you move the toolbar

Signed-off-by: leo78913 <leo3758@riseup.net>
This commit is contained in:
leo78913
2022-12-30 21:08:10 -03:00
parent 3da1d6a464
commit f3acf35aea
5 changed files with 865 additions and 835 deletions

View File

@ -10,6 +10,9 @@ class ActionButton : public QToolButton {
ActionButton(QAction* action, QWidget* parent = nullptr) : QToolButton(parent), m_action(action)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
// workaround for breeze and breeze forks
setProperty("_kde_toolButton_alignment", Qt::AlignLeft);
connect(action, &QAction::changed, this, &ActionButton::actionChanged);
connect(this, &ActionButton::clicked, action, &QAction::trigger);
@ -21,6 +24,10 @@ class ActionButton : public QToolButton {
{
setEnabled(m_action->isEnabled());
setChecked(m_action->isChecked());
setMenu(m_action->menu());
if (menu()) {
setPopupMode(QToolButton::MenuButtonPopup);
}
setCheckable(m_action->isCheckable());
setText(m_action->text());
setIcon(m_action->icon());