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

@ -61,13 +61,16 @@ class BaseProfilerFactory;
class InstanceView;
class KonamiCode;
class InstanceTask;
class LabeledToolButton;
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
class Ui;
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
@ -107,10 +110,6 @@ private slots:
void on_actionChangeInstGroup_triggered();
void on_actionChangeInstIcon_triggered();
void on_changeIconButton_clicked(bool)
{
on_actionChangeInstIcon_triggered();
}
void on_actionViewInstanceFolder_triggered();
@ -156,10 +155,6 @@ private slots:
void on_actionExportInstance_triggered();
void on_actionRenameInstance_triggered();
void on_renameButton_clicked(bool)
{
on_actionRenameInstance_triggered();
}
void on_actionEditInstance_triggered();
@ -230,14 +225,14 @@ private:
void updateInstanceToolIcon(QString new_icon);
void setSelectedInstanceById(const QString &id);
void updateStatusCenter();
void setInstanceActionsEnabled(bool enabled);
void runModalTask(Task *task);
void instanceFromInstanceTask(InstanceTask *task);
void finalizeInstance(InstancePtr inst);
private:
std::unique_ptr<Ui> ui;
Ui::MainWindow *ui;
// these are managed by Qt's memory management model!
InstanceView *view = nullptr;
InstanceProxyModel *proxymodel = nullptr;
@ -245,9 +240,14 @@ private:
QLabel *m_statusLeft = nullptr;
QLabel *m_statusCenter = nullptr;
QMenu *accountMenu = nullptr;
LabeledToolButton *changeIconButton = nullptr;
LabeledToolButton *renameButton = nullptr;
QToolButton *accountMenuButton = nullptr;
QToolButton *helpMenuButton = nullptr;
KonamiCode * secretEventFilter = nullptr;
std::shared_ptr<Setting> instanceToolbarSetting = nullptr;
unique_qobject_ptr<NewsChecker> m_newsChecker;
InstancePtr m_selectedInstance;