add an option to lock the toolbars
Signed-off-by: leo78913 <leo3758@riseup.net>
This commit is contained in:
parent
094b57bb23
commit
3d11d044d2
@ -614,6 +614,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
// The cat
|
// The cat
|
||||||
m_settings->registerSetting("TheCat", false);
|
m_settings->registerSetting("TheCat", false);
|
||||||
|
|
||||||
|
m_settings->registerSetting("ToolbarsLocked", false);
|
||||||
|
|
||||||
m_settings->registerSetting("InstSortMode", "Name");
|
m_settings->registerSetting("InstSortMode", "Name");
|
||||||
m_settings->registerSetting("SelectedInstance", QString());
|
m_settings->registerSetting("SelectedInstance", QString());
|
||||||
|
|
||||||
|
@ -262,6 +262,8 @@ public:
|
|||||||
TranslatedAction actionNoAccountsAdded;
|
TranslatedAction actionNoAccountsAdded;
|
||||||
TranslatedAction actionNoDefaultAccount;
|
TranslatedAction actionNoDefaultAccount;
|
||||||
|
|
||||||
|
TranslatedAction actionLockToolbars;
|
||||||
|
|
||||||
QVector<TranslatedToolButton *> all_toolbuttons;
|
QVector<TranslatedToolButton *> all_toolbuttons;
|
||||||
|
|
||||||
QWidget *centralWidget = nullptr;
|
QWidget *centralWidget = nullptr;
|
||||||
@ -420,6 +422,12 @@ public:
|
|||||||
actionManageAccounts->setCheckable(false);
|
actionManageAccounts->setCheckable(false);
|
||||||
actionManageAccounts->setIcon(APPLICATION->getThemedIcon("accounts"));
|
actionManageAccounts->setIcon(APPLICATION->getThemedIcon("accounts"));
|
||||||
all_actions.append(&actionManageAccounts);
|
all_actions.append(&actionManageAccounts);
|
||||||
|
|
||||||
|
actionLockToolbars = TranslatedAction(MainWindow);
|
||||||
|
actionLockToolbars->setObjectName(QStringLiteral("actionLockToolbars"));
|
||||||
|
actionLockToolbars.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Lock Toolbars"));
|
||||||
|
actionLockToolbars->setCheckable(true);
|
||||||
|
all_actions.append(&actionLockToolbars);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createMainToolbar(QMainWindow *MainWindow)
|
void createMainToolbar(QMainWindow *MainWindow)
|
||||||
@ -427,7 +435,6 @@ public:
|
|||||||
mainToolBar = TranslatedToolbar(MainWindow);
|
mainToolBar = TranslatedToolbar(MainWindow);
|
||||||
mainToolBar->setVisible(menuBar->isNativeMenuBar() || !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool());
|
mainToolBar->setVisible(menuBar->isNativeMenuBar() || !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool());
|
||||||
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
|
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
|
||||||
mainToolBar->setMovable(true);
|
|
||||||
mainToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
mainToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
||||||
mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
mainToolBar->setFloatable(false);
|
mainToolBar->setFloatable(false);
|
||||||
@ -524,6 +531,8 @@ public:
|
|||||||
viewMenu->addAction(actionCAT);
|
viewMenu->addAction(actionCAT);
|
||||||
viewMenu->addSeparator();
|
viewMenu->addSeparator();
|
||||||
|
|
||||||
|
viewMenu->addAction(actionLockToolbars);
|
||||||
|
|
||||||
menuBar->addMenu(foldersMenu);
|
menuBar->addMenu(foldersMenu);
|
||||||
|
|
||||||
profileMenu = menuBar->addMenu(tr("&Accounts"));
|
profileMenu = menuBar->addMenu(tr("&Accounts"));
|
||||||
@ -601,7 +610,6 @@ public:
|
|||||||
{
|
{
|
||||||
newsToolBar = TranslatedToolbar(MainWindow);
|
newsToolBar = TranslatedToolbar(MainWindow);
|
||||||
newsToolBar->setObjectName(QStringLiteral("newsToolBar"));
|
newsToolBar->setObjectName(QStringLiteral("newsToolBar"));
|
||||||
newsToolBar->setMovable(true);
|
|
||||||
newsToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
newsToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
||||||
newsToolBar->setIconSize(QSize(16, 16));
|
newsToolBar->setIconSize(QSize(16, 16));
|
||||||
newsToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
newsToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
@ -736,7 +744,6 @@ public:
|
|||||||
instanceToolBar->setObjectName(QStringLiteral("instanceToolBar"));
|
instanceToolBar->setObjectName(QStringLiteral("instanceToolBar"));
|
||||||
// disabled until we have an instance selected
|
// disabled until we have an instance selected
|
||||||
instanceToolBar->setEnabled(false);
|
instanceToolBar->setEnabled(false);
|
||||||
instanceToolBar->setMovable(true);
|
|
||||||
// Qt doesn't like vertical moving toolbars, so we have to force them...
|
// Qt doesn't like vertical moving toolbars, so we have to force them...
|
||||||
// See https://github.com/PolyMC/PolyMC/issues/493
|
// See https://github.com/PolyMC/PolyMC/issues/493
|
||||||
connect(instanceToolBar, &QToolBar::orientationChanged, [=](Qt::Orientation){ instanceToolBar->setOrientation(Qt::Vertical); });
|
connect(instanceToolBar, &QToolBar::orientationChanged, [=](Qt::Orientation){ instanceToolBar->setOrientation(Qt::Vertical); });
|
||||||
@ -918,6 +925,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
connect(ui->actionCAT.operator->(), SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
|
connect(ui->actionCAT.operator->(), SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
|
||||||
setCatBackground(cat_enable);
|
setCatBackground(cat_enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lock toolbars
|
||||||
|
{
|
||||||
|
bool toolbarsLocked = APPLICATION->settings()->get("ToolbarsLocked").toBool();
|
||||||
|
ui->actionLockToolbars->setChecked(toolbarsLocked);
|
||||||
|
connect(ui->actionLockToolbars.operator->(), SIGNAL(toggled(bool)), SLOT(lockToolbars(bool)));
|
||||||
|
lockToolbars(toolbarsLocked);
|
||||||
|
}
|
||||||
// start instance when double-clicked
|
// start instance when double-clicked
|
||||||
connect(view, &InstanceView::activated, this, &MainWindow::instanceActivated);
|
connect(view, &InstanceView::activated, this, &MainWindow::instanceActivated);
|
||||||
|
|
||||||
@ -1073,8 +1088,19 @@ QMenu * MainWindow::createPopupMenu()
|
|||||||
{
|
{
|
||||||
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
||||||
filteredMenu->removeAction( ui->mainToolBar->toggleViewAction() );
|
filteredMenu->removeAction( ui->mainToolBar->toggleViewAction() );
|
||||||
|
|
||||||
|
filteredMenu->addAction(ui->actionLockToolbars);
|
||||||
|
|
||||||
return filteredMenu;
|
return filteredMenu;
|
||||||
}
|
}
|
||||||
|
void MainWindow::lockToolbars(bool state)
|
||||||
|
{
|
||||||
|
ui->mainToolBar->setMovable(!state);
|
||||||
|
ui->instanceToolBar->setMovable(!state);
|
||||||
|
ui->newsToolBar->setMovable(!state);
|
||||||
|
APPLICATION->settings()->set("ToolbarsLocked", state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::konamiTriggered()
|
void MainWindow::konamiTriggered()
|
||||||
{
|
{
|
||||||
|
@ -203,6 +203,8 @@ private slots:
|
|||||||
|
|
||||||
void globalSettingsClosed();
|
void globalSettingsClosed();
|
||||||
|
|
||||||
|
void lockToolbars(bool);
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
void keyReleaseEvent(QKeyEvent *event) override;
|
void keyReleaseEvent(QKeyEvent *event) override;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user