mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-11 01:24:01 +02:00
RMG: allow the toolbar to be moved
This commit is contained in:
@@ -128,9 +128,13 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
if (!this->ui_QuitAfterEmulation &&
|
||||
!this->emulationThread->isRunning())
|
||||
{
|
||||
this->storeGeometry();
|
||||
this->storeGeometry();
|
||||
}
|
||||
|
||||
// store toolbar location to settings
|
||||
Qt::ToolBarArea toolbarArea = this->toolBarArea(this->toolBar);
|
||||
CoreSettingsSetValue(SettingsID::GUI_ToolbarArea, this->getToolbarSettingAreaFromArea(toolbarArea));
|
||||
|
||||
this->ui_NoSwitchToRomBrowser = true;
|
||||
this->on_Action_System_Shutdown();
|
||||
|
||||
@@ -222,6 +226,15 @@ void MainWindow::configureUI(QApplication* app, bool showUI)
|
||||
this->statusBar()->setVisible(this->ui_ShowStatusbar);
|
||||
this->statusBar()->addPermanentWidget(this->ui_StatusBar_Label, 1);
|
||||
|
||||
// set toolbar position according to setting
|
||||
int toolbarAreaSetting = CoreSettingsGetIntValue(SettingsID::GUI_ToolbarArea);
|
||||
Qt::ToolBarArea toolbarArea = this->getToolbarAreaFromSettingArea(toolbarAreaSetting);
|
||||
if (this->toolBarArea(this->toolBar) != toolbarArea)
|
||||
{
|
||||
this->removeToolBar(this->toolBar);
|
||||
this->addToolBar(toolbarArea, this->toolBar);
|
||||
}
|
||||
|
||||
this->ui_TimerTimeout = CoreSettingsGetIntValue(SettingsID::GUI_StatusbarMessageDuration);
|
||||
|
||||
this->ui_Widgets->addWidget(this->ui_Widget_RomBrowser);
|
||||
@@ -747,6 +760,41 @@ QString MainWindow::getSaveStateSlotText(QAction* action, int slot)
|
||||
return saveStateSlotText;
|
||||
}
|
||||
|
||||
int MainWindow::getToolbarSettingAreaFromArea(Qt::ToolBarArea area)
|
||||
{
|
||||
switch (area)
|
||||
{
|
||||
case Qt::ToolBarArea::TopToolBarArea:
|
||||
return 0;
|
||||
case Qt::ToolBarArea::BottomToolBarArea:
|
||||
return 1;
|
||||
case Qt::ToolBarArea::LeftToolBarArea:
|
||||
return 2;
|
||||
case Qt::ToolBarArea::RightToolBarArea:
|
||||
return 3;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ToolBarArea MainWindow::getToolbarAreaFromSettingArea(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return Qt::ToolBarArea::TopToolBarArea;
|
||||
case 1:
|
||||
return Qt::ToolBarArea::BottomToolBarArea;
|
||||
case 2:
|
||||
return Qt::ToolBarArea::LeftToolBarArea;
|
||||
case 3:
|
||||
return Qt::ToolBarArea::RightToolBarArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::configureActions(void)
|
||||
{
|
||||
// configure actions list
|
||||
@@ -1940,7 +1988,24 @@ void MainWindow::on_VidExt_ResizeWindow(int width, int height)
|
||||
|
||||
if (!this->toolBar->isHidden())
|
||||
{
|
||||
height += this->toolBar->height();
|
||||
Qt::ToolBarArea area = this->toolBarArea(this->toolBar);
|
||||
|
||||
// dont resize when toolbar is floating
|
||||
if (this->toolBar->isFloating())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (area == Qt::ToolBarArea::TopToolBarArea ||
|
||||
area == Qt::ToolBarArea::BottomToolBarArea)
|
||||
{
|
||||
height += this->toolBar->height();
|
||||
}
|
||||
else if (area == Qt::ToolBarArea::LeftToolBarArea ||
|
||||
area == Qt::ToolBarArea::RightToolBarArea)
|
||||
{
|
||||
width += this->toolBar->width();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->statusBar()->isHidden())
|
||||
|
||||
@@ -119,6 +119,9 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
|
||||
QString getSaveStateSlotDateTimeText(QAction* action);
|
||||
QString getSaveStateSlotText(QAction* action, int slot);
|
||||
|
||||
int getToolbarSettingAreaFromArea(Qt::ToolBarArea area);
|
||||
Qt::ToolBarArea getToolbarAreaFromSettingArea(int value);
|
||||
|
||||
void configureActions(void);
|
||||
void connectActionSignals(void);
|
||||
void updateActions(bool inEmulation, bool isPaused);
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
|
||||
Reference in New Issue
Block a user