From 1a6f4c1104e8ecd469db5f27eb230994b9ee9ee2 Mon Sep 17 00:00:00 2001 From: Kevin Zander Date: Mon, 4 May 2020 21:46:25 -0500 Subject: [PATCH] Add option to move SideBar to right side of window (#5114) --- include/SetupDialog.h | 2 ++ src/gui/MainWindow.cpp | 15 +++++++++++---- src/gui/SetupDialog.cpp | 12 ++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/SetupDialog.h b/include/SetupDialog.h index 9f9ae1b3f..80a22d69c 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -74,6 +74,7 @@ private slots: void toggleNoteLabels(bool enabled); void toggleCompactTrackButtons(bool enabled); void toggleOneInstrumentTrackWindow(bool enabled); + void toggleSideBarOnRight(bool enabled); void toggleMMPZ(bool enabled); void toggleDisableBackup(bool enabled); void toggleOpenLastProject(bool enabled); @@ -130,6 +131,7 @@ private: bool m_printNoteLabels; bool m_compactTrackButtons; bool m_oneInstrumentTrackWindow; + bool m_sideBarOnRight; bool m_MMPZ; bool m_disableBackup; bool m_openLastProject; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 3eb532981..bf8863ec6 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -117,6 +117,7 @@ MainWindow::MainWindow() : splitter->setChildrenCollapsible( false ); ConfigManager* confMgr = ConfigManager::inst(); + bool sideBarOnRight = confMgr->value("ui", "sidebaronright").toInt(); emit initProgress(tr("Preparing plugin browser")); sideBar->appendTab( new PluginBrowser( splitter ) ); @@ -171,7 +172,7 @@ MainWindow::MainWindow() : embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ), splitter, dirs_as_items) ); - m_workspace = new QMdiArea( splitter ); + m_workspace = new QMdiArea(splitter); // Load background emit initProgress(tr("Loading background picture")); @@ -194,9 +195,15 @@ MainWindow::MainWindow() : m_workspace->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_workspace->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); - hbox->addWidget( sideBar ); - hbox->addWidget( splitter ); - + hbox->addWidget(sideBar); + hbox->addWidget(splitter); + // If the user wants the sidebar on the right, we move the workspace and + // the splitter to the "left" side, or the first widgets in their list + if (sideBarOnRight) + { + splitter->insertWidget(0, m_workspace); + hbox->insertWidget(0, splitter); + } // create global-toolbar at the top of our window m_toolBar = new QWidget( main_widget ); diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 885f43dec..6de547b5a 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -100,6 +100,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : "ui", "compacttrackbuttons").toInt()), m_oneInstrumentTrackWindow(ConfigManager::inst()->value( "ui", "oneinstrumenttrackwindow").toInt()), + m_sideBarOnRight(ConfigManager::inst()->value( + "ui", "sidebaronright").toInt()), m_MMPZ(!ConfigManager::inst()->value( "app", "nommpz").toInt()), m_disableBackup(!ConfigManager::inst()->value( @@ -229,6 +231,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : m_compactTrackButtons, SLOT(toggleCompactTrackButtons(bool)), true); addLedCheckBox("Enable one instrument-track-window mode", gui_tw, counter, m_oneInstrumentTrackWindow, SLOT(toggleOneInstrumentTrackWindow(bool)), true); + addLedCheckBox("Show sidebar on the right-hand side", gui_tw, counter, + m_sideBarOnRight, SLOT(toggleSideBarOnRight(bool)), true); gui_tw->setFixedHeight(YDelta + YDelta * counter); @@ -876,6 +880,8 @@ void SetupDialog::accept() QString::number(m_compactTrackButtons)); ConfigManager::inst()->setValue("ui", "oneinstrumenttrackwindow", QString::number(m_oneInstrumentTrackWindow)); + ConfigManager::inst()->setValue("ui", "sidebaronright", + QString::number(m_sideBarOnRight)); ConfigManager::inst()->setValue("app", "nommpz", QString::number(!m_MMPZ)); ConfigManager::inst()->setValue("app", "disablebackup", @@ -980,6 +986,12 @@ void SetupDialog::toggleOneInstrumentTrackWindow(bool enabled) } +void SetupDialog::toggleSideBarOnRight(bool enabled) +{ + m_sideBarOnRight = enabled; +} + + void SetupDialog::toggleMMPZ(bool enabled) { m_MMPZ = enabled;