Merge pull request #6672 from spycrab/qt_dynamic
Qt: Make toolbar more dynamic
This commit is contained in:
commit
dabfecfd74
|
@ -19,6 +19,8 @@
|
||||||
LogConfigWidget::LogConfigWidget(QWidget* parent) : QDockWidget(parent)
|
LogConfigWidget::LogConfigWidget(QWidget* parent) : QDockWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Log Configuration"));
|
setWindowTitle(tr("Log Configuration"));
|
||||||
|
setObjectName(QStringLiteral("logconfig"));
|
||||||
|
|
||||||
setHidden(!Settings::Instance().IsLogConfigVisible());
|
setHidden(!Settings::Instance().IsLogConfigVisible());
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ constexpr int TIMESTAMP_LENGTH = 10;
|
||||||
LogWidget::LogWidget(QWidget* parent) : QDockWidget(parent), m_timer(new QTimer(this))
|
LogWidget::LogWidget(QWidget* parent) : QDockWidget(parent), m_timer(new QTimer(this))
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Log"));
|
setWindowTitle(tr("Log"));
|
||||||
|
setObjectName(QStringLiteral("log"));
|
||||||
|
|
||||||
setHidden(!Settings::Instance().IsLogVisible());
|
setHidden(!Settings::Instance().IsLogVisible());
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
BreakpointWidget::BreakpointWidget(QWidget* parent) : QDockWidget(parent)
|
BreakpointWidget::BreakpointWidget(QWidget* parent) : QDockWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Breakpoints"));
|
setWindowTitle(tr("Breakpoints"));
|
||||||
|
setObjectName(QStringLiteral("breakpoints"));
|
||||||
|
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
auto& settings = Settings::GetQSettings();
|
auto& settings = Settings::GetQSettings();
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent)
|
CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Code"));
|
setWindowTitle(tr("Code"));
|
||||||
|
setObjectName(QStringLiteral("code"));
|
||||||
|
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
auto& settings = Settings::GetQSettings();
|
auto& settings = Settings::GetQSettings();
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
MemoryWidget::MemoryWidget(QWidget* parent) : QDockWidget(parent)
|
MemoryWidget::MemoryWidget(QWidget* parent) : QDockWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Memory"));
|
setWindowTitle(tr("Memory"));
|
||||||
|
setObjectName(QStringLiteral("memory"));
|
||||||
|
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
CreateWidgets();
|
CreateWidgets();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent)
|
RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Registers"));
|
setWindowTitle(tr("Registers"));
|
||||||
|
setObjectName(QStringLiteral("registers"));
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
auto& settings = Settings::GetQSettings();
|
auto& settings = Settings::GetQSettings();
|
||||||
|
|
|
@ -26,6 +26,8 @@ WatchWidget::WatchWidget(QWidget* parent) : QDockWidget(parent)
|
||||||
// i18n: This kind of "watch" is used for watching emulated memory.
|
// i18n: This kind of "watch" is used for watching emulated memory.
|
||||||
// It's not related to timekeeping devices.
|
// It's not related to timekeeping devices.
|
||||||
setWindowTitle(tr("Watch"));
|
setWindowTitle(tr("Watch"));
|
||||||
|
setObjectName(QStringLiteral("watch"));
|
||||||
|
|
||||||
setAllowedAreas(Qt::AllDockWidgetAreas);
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
|
|
||||||
auto& settings = Settings::GetQSettings();
|
auto& settings = Settings::GetQSettings();
|
||||||
|
|
|
@ -109,6 +109,10 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
|
||||||
|
|
||||||
if (boot_parameters)
|
if (boot_parameters)
|
||||||
StartGame(std::move(boot_parameters));
|
StartGame(std::move(boot_parameters));
|
||||||
|
|
||||||
|
QSettings& settings = Settings::GetQSettings();
|
||||||
|
|
||||||
|
restoreState(settings.value(QStringLiteral("mainwindow/state")).toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -117,6 +121,10 @@ MainWindow::~MainWindow()
|
||||||
ShutdownControllers();
|
ShutdownControllers();
|
||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
||||||
|
QSettings& settings = Settings::GetQSettings();
|
||||||
|
|
||||||
|
settings.setValue(QStringLiteral("mainwindow/state"), saveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::InitControllers()
|
void MainWindow::InitControllers()
|
||||||
|
|
|
@ -348,9 +348,23 @@ void MenuBar::AddViewMenu()
|
||||||
connect(show_log_config, &QAction::toggled, &Settings::Instance(),
|
connect(show_log_config, &QAction::toggled, &Settings::Instance(),
|
||||||
&Settings::SetLogConfigVisible);
|
&Settings::SetLogConfigVisible);
|
||||||
|
|
||||||
|
QAction* show_toolbar = view_menu->addAction(tr("Show &Toolbar"));
|
||||||
|
show_toolbar->setCheckable(true);
|
||||||
|
show_toolbar->setChecked(Settings::Instance().IsToolBarVisible());
|
||||||
|
|
||||||
|
connect(show_toolbar, &QAction::toggled, &Settings::Instance(), &Settings::SetToolBarVisible);
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::LogVisibilityChanged, show_log, &QAction::setChecked);
|
connect(&Settings::Instance(), &Settings::LogVisibilityChanged, show_log, &QAction::setChecked);
|
||||||
connect(&Settings::Instance(), &Settings::LogConfigVisibilityChanged, show_log_config,
|
connect(&Settings::Instance(), &Settings::LogConfigVisibilityChanged, show_log_config,
|
||||||
&QAction::setChecked);
|
&QAction::setChecked);
|
||||||
|
connect(&Settings::Instance(), &Settings::ToolBarVisibilityChanged, show_toolbar,
|
||||||
|
&QAction::setChecked);
|
||||||
|
|
||||||
|
QAction* lock_widgets = view_menu->addAction(tr("&Lock Widgets In Place"));
|
||||||
|
lock_widgets->setCheckable(true);
|
||||||
|
lock_widgets->setChecked(Settings::Instance().AreWidgetsLocked());
|
||||||
|
|
||||||
|
connect(lock_widgets, &QAction::toggled, &Settings::Instance(), &Settings::SetWidgetsLocked);
|
||||||
|
|
||||||
view_menu->addSeparator();
|
view_menu->addSeparator();
|
||||||
|
|
||||||
|
|
|
@ -366,3 +366,33 @@ bool Settings::IsAnalyticsEnabled() const
|
||||||
{
|
{
|
||||||
return SConfig::GetInstance().m_analytics_enabled;
|
return SConfig::GetInstance().m_analytics_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::SetToolBarVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (IsToolBarVisible() == visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GetQSettings().setValue(QStringLiteral("toolbar/visible"), visible);
|
||||||
|
|
||||||
|
emit ToolBarVisibilityChanged(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::IsToolBarVisible() const
|
||||||
|
{
|
||||||
|
return GetQSettings().value(QStringLiteral("toolbar/visible")).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetWidgetsLocked(bool locked)
|
||||||
|
{
|
||||||
|
if (AreWidgetsLocked() == locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GetQSettings().setValue(QStringLiteral("widgets/locked"), locked);
|
||||||
|
|
||||||
|
emit WidgetLockChanged(locked);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::AreWidgetsLocked() const
|
||||||
|
{
|
||||||
|
return GetQSettings().value(QStringLiteral("widgets/locked"), true).toBool();
|
||||||
|
}
|
||||||
|
|
|
@ -52,6 +52,10 @@ public:
|
||||||
void SetLogConfigVisible(bool visible);
|
void SetLogConfigVisible(bool visible);
|
||||||
bool IsControllerStateNeeded() const;
|
bool IsControllerStateNeeded() const;
|
||||||
void SetControllerStateNeeded(bool needed);
|
void SetControllerStateNeeded(bool needed);
|
||||||
|
void SetToolBarVisible(bool visible);
|
||||||
|
bool IsToolBarVisible() const;
|
||||||
|
void SetWidgetsLocked(bool visible);
|
||||||
|
bool AreWidgetsLocked() const;
|
||||||
|
|
||||||
// GameList
|
// GameList
|
||||||
QStringList GetPaths() const;
|
QStringList GetPaths() const;
|
||||||
|
@ -125,6 +129,8 @@ signals:
|
||||||
void RegistersVisibilityChanged(bool visible);
|
void RegistersVisibilityChanged(bool visible);
|
||||||
void LogVisibilityChanged(bool visible);
|
void LogVisibilityChanged(bool visible);
|
||||||
void LogConfigVisibilityChanged(bool visible);
|
void LogConfigVisibilityChanged(bool visible);
|
||||||
|
void ToolBarVisibilityChanged(bool visible);
|
||||||
|
void WidgetLockChanged(bool locked);
|
||||||
void EnableCheatsChanged(bool enabled);
|
void EnableCheatsChanged(bool enabled);
|
||||||
void WatchVisibilityChanged(bool visible);
|
void WatchVisibilityChanged(bool visible);
|
||||||
void BreakpointsVisibilityChanged(bool visible);
|
void BreakpointsVisibilityChanged(bool visible);
|
||||||
|
|
|
@ -18,10 +18,13 @@ static QSize ICON_SIZE(32, 32);
|
||||||
ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
|
ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
|
||||||
{
|
{
|
||||||
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
setMovable(false);
|
setMovable(!Settings::Instance().AreWidgetsLocked());
|
||||||
setFloatable(false);
|
setFloatable(false);
|
||||||
setIconSize(ICON_SIZE);
|
setIconSize(ICON_SIZE);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Toolbar"));
|
||||||
|
setObjectName(QStringLiteral("toolbar"));
|
||||||
|
|
||||||
MakeActions();
|
MakeActions();
|
||||||
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &ToolBar::UpdateIcons);
|
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &ToolBar::UpdateIcons);
|
||||||
UpdateIcons();
|
UpdateIcons();
|
||||||
|
@ -31,6 +34,11 @@ ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::DebugModeToggled, this, &ToolBar::OnDebugModeToggled);
|
connect(&Settings::Instance(), &Settings::DebugModeToggled, this, &ToolBar::OnDebugModeToggled);
|
||||||
|
|
||||||
|
connect(&Settings::Instance(), &Settings::ToolBarVisibilityChanged, this, &ToolBar::setVisible);
|
||||||
|
|
||||||
|
connect(&Settings::Instance(), &Settings::WidgetLockChanged, this,
|
||||||
|
[this](bool locked) { setMovable(!locked); });
|
||||||
|
|
||||||
OnEmulationStateChanged(Core::GetState());
|
OnEmulationStateChanged(Core::GetState());
|
||||||
OnDebugModeToggled(Settings::Instance().IsDebugModeEnabled());
|
OnDebugModeToggled(Settings::Instance().IsDebugModeEnabled());
|
||||||
}
|
}
|
||||||
|
@ -49,6 +57,11 @@ void ToolBar::OnEmulationStateChanged(Core::State state)
|
||||||
m_pause_action->setVisible(playing);
|
m_pause_action->setVisible(playing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolBar::closeEvent(QCloseEvent*)
|
||||||
|
{
|
||||||
|
Settings::Instance().SetToolBarVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void ToolBar::OnDebugModeToggled(bool enabled)
|
void ToolBar::OnDebugModeToggled(bool enabled)
|
||||||
{
|
{
|
||||||
m_step_action->setVisible(enabled);
|
m_step_action->setVisible(enabled);
|
||||||
|
|
|
@ -20,6 +20,7 @@ class ToolBar final : public QToolBar
|
||||||
public:
|
public:
|
||||||
explicit ToolBar(QWidget* parent = nullptr);
|
explicit ToolBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent*) override;
|
||||||
signals:
|
signals:
|
||||||
void OpenPressed();
|
void OpenPressed();
|
||||||
void PlayPressed();
|
void PlayPressed();
|
||||||
|
|
Loading…
Reference in New Issue