Merge pull request #724 from leo78913/dot-ui-mainwindow
Closes https://github.com/PrismLauncher/PrismLauncher/issues/594 Closes https://github.com/PrismLauncher/PrismLauncher/issues/69 Closes https://github.com/PrismLauncher/PrismLauncher/issues/473
This commit is contained in:
		| @@ -937,6 +937,7 @@ SET(LAUNCHER_SOURCES | ||||
| ) | ||||
|  | ||||
| qt_wrap_ui(LAUNCHER_UI | ||||
|     ui/MainWindow.ui | ||||
|     ui/setupwizard/PasteWizardPage.ui | ||||
|     ui/setupwizard/ThemeWizardPage.ui | ||||
|     ui/pages/global/AccountListPage.ui | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -60,13 +60,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(); | ||||
| @@ -106,10 +109,6 @@ private slots: | ||||
|     void on_actionChangeInstGroup_triggered(); | ||||
|  | ||||
|     void on_actionChangeInstIcon_triggered(); | ||||
|     void on_changeIconButton_clicked(bool) | ||||
|     { | ||||
|         on_actionChangeInstIcon_triggered(); | ||||
|     } | ||||
|  | ||||
|     void on_actionViewInstanceFolder_triggered(); | ||||
|  | ||||
| @@ -155,10 +154,6 @@ private slots: | ||||
|     void on_actionExportInstance_triggered(); | ||||
|  | ||||
|     void on_actionRenameInstance_triggered(); | ||||
|     void on_renameButton_clicked(bool) | ||||
|     { | ||||
|         on_actionRenameInstance_triggered(); | ||||
|     } | ||||
|  | ||||
|     void on_actionEditInstance_triggered(); | ||||
|  | ||||
| @@ -221,24 +216,27 @@ 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; | ||||
|     QToolButton *newsLabel = nullptr; | ||||
|     QLabel *m_statusLeft = nullptr; | ||||
|     QLabel *m_statusCenter = nullptr; | ||||
|     QMenu *accountMenu = nullptr; | ||||
|     QToolButton *accountMenuButton = nullptr; | ||||
|     LabeledToolButton *changeIconButton = nullptr; | ||||
|     LabeledToolButton *renameButton = nullptr; | ||||
|     QToolButton *helpMenuButton = nullptr; | ||||
|     KonamiCode * secretEventFilter = nullptr; | ||||
|  | ||||
|     std::shared_ptr<Setting> instanceToolbarSetting = nullptr; | ||||
|  | ||||
|     unique_qobject_ptr<NewsChecker> m_newsChecker; | ||||
|  | ||||
|     InstancePtr m_selectedInstance; | ||||
|   | ||||
							
								
								
									
										696
									
								
								launcher/ui/MainWindow.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										696
									
								
								launcher/ui/MainWindow.ui
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,696 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>MainWindow</class> | ||||
|  <widget class="QMainWindow" name="MainWindow"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>800</width> | ||||
|     <height>600</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <widget class="QWidget" name="centralWidget"> | ||||
|    <layout class="QHBoxLayout" name="horizontalLayout"> | ||||
|     <property name="spacing"> | ||||
|      <number>0</number> | ||||
|     </property> | ||||
|     <property name="leftMargin"> | ||||
|      <number>0</number> | ||||
|     </property> | ||||
|     <property name="topMargin"> | ||||
|      <number>0</number> | ||||
|     </property> | ||||
|     <property name="rightMargin"> | ||||
|      <number>0</number> | ||||
|     </property> | ||||
|     <property name="bottomMargin"> | ||||
|      <number>0</number> | ||||
|     </property> | ||||
|    </layout> | ||||
|   </widget> | ||||
|   <widget class="QStatusBar" name="statusBar"/> | ||||
|   <widget class="QToolBar" name="mainToolBar"> | ||||
|    <property name="windowTitle"> | ||||
|     <string>Main Toolbar</string> | ||||
|    </property> | ||||
|    <property name="allowedAreas"> | ||||
|     <set>Qt::BottomToolBarArea|Qt::TopToolBarArea</set> | ||||
|    </property> | ||||
|    <property name="toolButtonStyle"> | ||||
|     <enum>Qt::ToolButtonTextBesideIcon</enum> | ||||
|    </property> | ||||
|    <property name="floatable"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|    <attribute name="toolBarArea"> | ||||
|     <enum>TopToolBarArea</enum> | ||||
|    </attribute> | ||||
|    <attribute name="toolBarBreak"> | ||||
|     <bool>false</bool> | ||||
|    </attribute> | ||||
|    <addaction name="actionAddInstance"/> | ||||
|    <addaction name="separator"/> | ||||
|    <addaction name="actionFoldersButton"/> | ||||
|    <addaction name="actionSettings"/> | ||||
|    <addaction name="actionHelpButton"/> | ||||
|    <addaction name="actionCheckUpdate"/> | ||||
|    <addaction name="separator"/> | ||||
|    <addaction name="actionCAT"/> | ||||
|    <addaction name="actionAccountsButton"/> | ||||
|   </widget> | ||||
|   <widget class="QToolBar" name="newsToolBar"> | ||||
|    <property name="windowTitle"> | ||||
|     <string>News Toolbar</string> | ||||
|    </property> | ||||
|    <property name="allowedAreas"> | ||||
|     <set>Qt::BottomToolBarArea|Qt::TopToolBarArea</set> | ||||
|    </property> | ||||
|    <property name="iconSize"> | ||||
|     <size> | ||||
|      <width>16</width> | ||||
|      <height>16</height> | ||||
|     </size> | ||||
|    </property> | ||||
|    <property name="toolButtonStyle"> | ||||
|     <enum>Qt::ToolButtonTextBesideIcon</enum> | ||||
|    </property> | ||||
|    <property name="floatable"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|    <attribute name="toolBarArea"> | ||||
|     <enum>BottomToolBarArea</enum> | ||||
|    </attribute> | ||||
|    <attribute name="toolBarBreak"> | ||||
|     <bool>false</bool> | ||||
|    </attribute> | ||||
|    <addaction name="actionMoreNews"/> | ||||
|   </widget> | ||||
|   <widget class="WideBar" name="instanceToolBar"> | ||||
|    <property name="windowTitle"> | ||||
|     <string>Instance Toolbar</string> | ||||
|    </property> | ||||
|    <property name="allowedAreas"> | ||||
|     <set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set> | ||||
|    </property> | ||||
|    <property name="iconSize"> | ||||
|     <size> | ||||
|      <width>16</width> | ||||
|      <height>16</height> | ||||
|     </size> | ||||
|    </property> | ||||
|    <property name="toolButtonStyle"> | ||||
|     <enum>Qt::ToolButtonTextBesideIcon</enum> | ||||
|    </property> | ||||
|    <property name="floatable"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|    <property name="useDefaultAction" stdset="0"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|    <attribute name="toolBarArea"> | ||||
|     <enum>RightToolBarArea</enum> | ||||
|    </attribute> | ||||
|    <attribute name="toolBarBreak"> | ||||
|     <bool>false</bool> | ||||
|    </attribute> | ||||
|    <addaction name="actionLaunchInstance"/> | ||||
|    <addaction name="actionKillInstance"/> | ||||
|    <addaction name="separator"/> | ||||
|    <addaction name="actionEditInstance"/> | ||||
|    <addaction name="actionChangeInstGroup"/> | ||||
|    <addaction name="actionViewSelectedInstFolder"/> | ||||
|    <addaction name="actionExportInstance"/> | ||||
|    <addaction name="actionCopyInstance"/> | ||||
|    <addaction name="actionDeleteInstance"/> | ||||
|    <addaction name="actionCreateInstanceShortcut"/> | ||||
|   </widget> | ||||
|   <widget class="QMenuBar" name="menuBar"> | ||||
|    <property name="geometry"> | ||||
|     <rect> | ||||
|      <x>0</x> | ||||
|      <y>0</y> | ||||
|      <width>800</width> | ||||
|      <height>20</height> | ||||
|     </rect> | ||||
|    </property> | ||||
|    <widget class="QMenu" name="fileMenu"> | ||||
|     <property name="title"> | ||||
|      <string>&File</string> | ||||
|     </property> | ||||
|     <property name="toolTipsVisible"> | ||||
|      <bool>true</bool> | ||||
|     </property> | ||||
|     <addaction name="actionAddInstance"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionLaunchInstance"/> | ||||
|     <addaction name="actionKillInstance"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionEditInstance"/> | ||||
|     <addaction name="actionChangeInstGroup"/> | ||||
|     <addaction name="actionViewSelectedInstFolder"/> | ||||
|     <addaction name="actionExportInstance"/> | ||||
|     <addaction name="actionCopyInstance"/> | ||||
|     <addaction name="actionDeleteInstance"/> | ||||
|     <addaction name="actionCreateInstanceShortcut"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionSettings"/> | ||||
|     <addaction name="actionCloseWindow"/> | ||||
|    </widget> | ||||
|    <widget class="QMenu" name="editMenu"> | ||||
|     <property name="title"> | ||||
|      <string>&Edit</string> | ||||
|     </property> | ||||
|     <property name="toolTipsVisible"> | ||||
|      <bool>true</bool> | ||||
|     </property> | ||||
|     <addaction name="actionUndoTrashInstance"/> | ||||
|    </widget> | ||||
|    <widget class="QMenu" name="viewMenu"> | ||||
|     <property name="title"> | ||||
|      <string>&View</string> | ||||
|     </property> | ||||
|     <property name="toolTipsVisible"> | ||||
|      <bool>true</bool> | ||||
|     </property> | ||||
|     <addaction name="actionChangeTheme"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionCAT"/> | ||||
|     <addaction name="actionLockToolbars"/> | ||||
|     <addaction name="separator"/> | ||||
|    </widget> | ||||
|    <widget class="QMenu" name="foldersMenu"> | ||||
|     <property name="title"> | ||||
|      <string>F&olders</string> | ||||
|     </property> | ||||
|     <property name="toolTipsVisible"> | ||||
|      <bool>true</bool> | ||||
|     </property> | ||||
|     <addaction name="actionViewInstanceFolder"/> | ||||
|     <addaction name="actionViewCentralModsFolder"/> | ||||
|    </widget> | ||||
|    <widget class="QMenu" name="accountsMenu"> | ||||
|     <property name="title"> | ||||
|      <string>&Accounts</string> | ||||
|     </property> | ||||
|    </widget> | ||||
|    <widget class="QMenu" name="helpMenu"> | ||||
|     <property name="title"> | ||||
|      <string>&Help</string> | ||||
|     </property> | ||||
|     <property name="toolTipsVisible"> | ||||
|      <bool>true</bool> | ||||
|     </property> | ||||
|     <addaction name="actionClearMetadata"/> | ||||
|     <addaction name="actionReportBug"/> | ||||
|     <addaction name="actionAddToPATH"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionMATRIX"/> | ||||
|     <addaction name="actionDISCORD"/> | ||||
|     <addaction name="actionREDDIT"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionMoreNews"/> | ||||
|     <addaction name="actionCheckUpdate"/> | ||||
|     <addaction name="actionOpenWiki"/> | ||||
|     <addaction name="actionAbout"/> | ||||
|    </widget> | ||||
|    <addaction name="fileMenu"/> | ||||
|    <addaction name="editMenu"/> | ||||
|    <addaction name="viewMenu"/> | ||||
|    <addaction name="foldersMenu"/> | ||||
|    <addaction name="accountsMenu"/> | ||||
|    <addaction name="helpMenu"/> | ||||
|   </widget> | ||||
|   <action name="actionMoreNews"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="news"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>More news...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open the development blog to read more news about %1.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCAT"> | ||||
|    <property name="checkable"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="cat"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Meow</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>It's a fluffy kitty :3</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionLockToolbars"> | ||||
|    <property name="checkable"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Lock Toolbars</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionUndoTrashInstance"> | ||||
|    <property name="enabled"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Undo Last Instance Deletion</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionAddInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="new"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Add Instanc&e...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Add a new instance.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCheckUpdate"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="checkupdate"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Update...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Check for new updates for %1.</string> | ||||
|    </property> | ||||
|    <property name="menuRole"> | ||||
|     <enum>QAction::ApplicationSpecificRole</enum> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionSettings"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="settings"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Setti&ngs...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Change settings.</string> | ||||
|    </property> | ||||
|    <property name="menuRole"> | ||||
|     <enum>QAction::PreferencesRole</enum> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionManageAccounts"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="accounts"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Manage Accounts...</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionLaunchInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="launch"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Launch</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Launch the selected instance.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionKillInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="status-bad"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Kill</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Kill the running instance.</string> | ||||
|    </property> | ||||
|    <property name="shortcut"> | ||||
|     <string>Ctrl+K</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionRenameInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="rename"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Rename</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Rename the selected instance.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionChangeInstGroup"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="tag"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Change Group...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Change the selected instance's group.</string> | ||||
|    </property> | ||||
|    <property name="shortcut"> | ||||
|     <string>Ctrl+G</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionChangeInstIcon"> | ||||
|    <property name="text"> | ||||
|     <string>Change Icon</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Change the selected instance's icon.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionEditInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="settings"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Edit...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Change the instance settings, mods and versions.</string> | ||||
|    </property> | ||||
|    <property name="shortcut"> | ||||
|     <string>Ctrl+I</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionViewSelectedInstFolder"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="viewfolder"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Folder</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open the selected instance's root folder in a file browser.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionDeleteInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="delete"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Dele&te</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Delete the selected instance.</string> | ||||
|    </property> | ||||
|    <property name="autoRepeat"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCopyInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="copy"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Cop&y...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Copy the selected instance.</string> | ||||
|    </property> | ||||
|    <property name="shortcut"> | ||||
|     <string>Ctrl+D</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionLaunchInstanceOffline"> | ||||
|    <property name="text"> | ||||
|     <string>Launch &Offline</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Launch the selected instance in offline mode.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionLaunchInstanceDemo"> | ||||
|    <property name="text"> | ||||
|     <string>Launch &Demo</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Launch the selected instance in demo mode.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionExportInstance"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="export"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>E&xport...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Export the selected instance as a zip file.</string> | ||||
|    </property> | ||||
|    <property name="shortcut"> | ||||
|     <string>Ctrl+E</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCreateInstanceShortcut"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="shortcut"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Create Shortcut</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Creates a shortcut on your desktop to launch the selected instance.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionNoAccountsAdded"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="noaccount"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>No accounts added!</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionNoDefaultAccount"> | ||||
|    <property name="checkable"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="noaccount"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>No Default Account</string> | ||||
|    </property> | ||||
|    <property name="shortcut"> | ||||
|     <string>Ctrl+0</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCloseWindow"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="status-bad"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Close &Window</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Close the current window</string> | ||||
|    </property> | ||||
|    <property name="menuRole"> | ||||
|     <enum>QAction::QuitRole</enum> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionViewInstanceFolder"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="viewfolder"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&View Instance Folder</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open the instance folder in a file browser.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionViewCentralModsFolder"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="centralmods"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>View &Central Mods Folder</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open the central mods folder in a file browser.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionChangeTheme"> | ||||
|    <property name="text"> | ||||
|     <string>Themes</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionReportBug"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="bug"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Report a &Bug...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open the bug tracker to report a bug with %1.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionDISCORD"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="discord"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Discord Guild</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open %1 Discord guild.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionMATRIX"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="matrix"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Matrix Space</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open %1 Matrix space.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionREDDIT"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="reddit-alien"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Sub&reddit</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open %1 subreddit.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionAbout"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="about"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&About %1</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>View information about %1.</string> | ||||
|    </property> | ||||
|    <property name="menuRole"> | ||||
|     <enum>QAction::AboutRole</enum> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionClearMetadata"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="refresh"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Clear Metadata Cache</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Clear cached metadata</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionAddToPATH"> | ||||
|    <property name="enabled"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="custom-commands"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Install to &PATH</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Install a %1 symlink to /usr/local/bin</string> | ||||
|    </property> | ||||
|    <property name="visible"> | ||||
|     <bool>false</bool> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionFoldersButton"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="viewfolder"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Folders</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open one of the folders shared between instances.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionHelpButton"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="help"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Help</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Get help with %1 or Minecraft.</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionAccountsButton"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="noaccount"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Accounts</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionOpenWiki"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="help"> | ||||
|      <normaloff>.</normaloff>.</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>%1 &Help</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open the %1 wiki</string> | ||||
|    </property> | ||||
|   </action> | ||||
|  </widget> | ||||
|  <customwidgets> | ||||
|   <customwidget> | ||||
|    <class>WideBar</class> | ||||
|    <extends>QToolBar</extends> | ||||
|    <header>ui/widgets/WideBar.h</header> | ||||
|   </customwidget> | ||||
|  </customwidgets> | ||||
|  <resources/> | ||||
|  <connections/> | ||||
| </ui> | ||||
| @@ -7,12 +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); | ||||
|  | ||||
|         connect(action, &QAction::changed, this, &ActionButton::actionChanged); | ||||
|         if (m_use_default_action) { | ||||
|             setDefaultAction(action); | ||||
|         } else { | ||||
|             connect(this, &ActionButton::clicked, action, &QAction::trigger); | ||||
|         } | ||||
|         connect(action, &QAction::changed, this, &ActionButton::actionChanged); | ||||
|  | ||||
|         actionChanged(); | ||||
|     }; | ||||
| @@ -20,17 +28,24 @@ class ActionButton : public QToolButton { | ||||
|     void actionChanged() | ||||
|     { | ||||
|         setEnabled(m_action->isEnabled()); | ||||
|         // better pop up mode | ||||
|         if (m_action->menu()) { | ||||
|             setPopupMode(QToolButton::MenuButtonPopup); | ||||
|         } | ||||
|         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) | ||||
| @@ -54,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; | ||||
|  | ||||
| @@ -86,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; | ||||
|  | ||||
| @@ -102,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; | ||||
|  | ||||
| @@ -111,6 +126,15 @@ void WideBar::insertActionAfter(QAction* after, QAction* action) | ||||
|     m_menu_state = MenuState::Dirty; | ||||
| } | ||||
|  | ||||
| void WideBar::insertWidgetBefore(QAction* before, QWidget* widget) | ||||
| { | ||||
|     auto iter = getMatching(before); | ||||
|     if (iter == m_entries.end()) | ||||
|         return; | ||||
|  | ||||
|     insertWidget(iter->bar_action, widget); | ||||
| } | ||||
|  | ||||
| void WideBar::insertSpacer(QAction* action) | ||||
| { | ||||
|     auto iter = getMatching(action); | ||||
| @@ -133,7 +157,7 @@ void WideBar::insertSeparator(QAction* before) | ||||
|         return; | ||||
|  | ||||
|     BarEntry entry; | ||||
|     entry.bar_action = QToolBar::insertSeparator(before); | ||||
|     entry.bar_action = QToolBar::insertSeparator(iter->bar_action); | ||||
|     entry.type = BarEntry::Type::Separator; | ||||
|  | ||||
|     m_entries.insert(iter, entry); | ||||
| @@ -180,6 +204,10 @@ void WideBar::showVisibilityMenu(QPoint const& position) | ||||
|  | ||||
|         m_bar_menu->clear(); | ||||
|  | ||||
|         m_bar_menu->addActions(m_context_menu_actions); | ||||
|  | ||||
|         m_bar_menu->addSeparator()->setText(tr("Customize toolbar actions")); | ||||
|  | ||||
|         for (auto& entry : m_entries) { | ||||
|             if (entry.type != BarEntry::Type::Action) | ||||
|                 continue; | ||||
| @@ -206,6 +234,10 @@ void WideBar::showVisibilityMenu(QPoint const& position) | ||||
|     m_bar_menu->popup(mapToGlobal(position)); | ||||
| } | ||||
|  | ||||
| void WideBar::addContextMenuAction(QAction* action) { | ||||
|     m_context_menu_actions.append(action); | ||||
| } | ||||
|  | ||||
| [[nodiscard]] QByteArray WideBar::getVisibilityState() const | ||||
| { | ||||
|     QByteArray state; | ||||
|   | ||||
| @@ -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); | ||||
| @@ -22,10 +25,13 @@ class WideBar : public QToolBar { | ||||
|     void insertSeparator(QAction* before); | ||||
|     void insertActionBefore(QAction* before, QAction* action); | ||||
|     void insertActionAfter(QAction* after, QAction* action); | ||||
|     void insertWidgetBefore(QAction* before, QWidget* widget); | ||||
|  | ||||
|     QMenu* createContextMenu(QWidget* parent = nullptr, const QString& title = QString()); | ||||
|     void showVisibilityMenu(const QPoint&); | ||||
|  | ||||
|     void addContextMenuAction(QAction* action); | ||||
|  | ||||
|     // Ideally we would use a QBitArray for this, but it doesn't support string conversion, | ||||
|     // so using it in settings is very messy. | ||||
|  | ||||
| @@ -48,6 +54,10 @@ class WideBar : public QToolBar { | ||||
|    private: | ||||
|     QList<BarEntry> m_entries; | ||||
|  | ||||
|     QList<QAction*> m_context_menu_actions; | ||||
|  | ||||
|     bool m_use_default_action = false; | ||||
|  | ||||
|     // Menu to toggle visibility from buttons in the bar | ||||
|     std::unique_ptr<QMenu> m_bar_menu = nullptr; | ||||
|     enum class MenuState { Fresh, Dirty } m_menu_state = MenuState::Dirty; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 flow
					flow