mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 06:51:26 +12:00
Qt: make dockwidget title bars optional
This commit is contained in:
parent
0236b994e4
commit
1b2e512179
6 changed files with 68 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
#include "rpcs3_app.h"
|
#include "rpcs3_app.h"
|
||||||
|
|
||||||
#include "rpcs3qt/qt_utils.h"
|
#include "rpcs3qt/qt_utils.h"
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& path)
|
||||||
|
|
||||||
// dock widget
|
// dock widget
|
||||||
"QDockWidget{ background: transparent; color: black; }"
|
"QDockWidget{ background: transparent; color: black; }"
|
||||||
"[floating = \"true\"]{ background: white; }"
|
"[floating=\"true\"]{ background: white; }"
|
||||||
"QDockWidget::title{ background: #e3e3e3; border: none; padding-top: 0.2em; padding-left: 0.2em; }"
|
"QDockWidget::title{ background: #e3e3e3; border: none; padding-top: 0.2em; padding-left: 0.2em; }"
|
||||||
"QDockWidget::close-button, QDockWidget::float-button{ background-color: #e3e3e3; }"
|
"QDockWidget::close-button, QDockWidget::float-button{ background-color: #e3e3e3; }"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
|
@ -6,16 +6,46 @@
|
||||||
|
|
||||||
class custom_dock_widget : public QDockWidget
|
class custom_dock_widget : public QDockWidget
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
std::shared_ptr<QWidget> m_title_bar_widget;
|
||||||
|
bool m_is_title_bar_visible = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit custom_dock_widget(const QString &title, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
|
explicit custom_dock_widget(const QString &title, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
|
||||||
: QDockWidget(title, parent, flags)
|
: QDockWidget(title, parent, flags)
|
||||||
{
|
{
|
||||||
|
m_title_bar_widget.reset(titleBarWidget());
|
||||||
|
|
||||||
connect(this, &QDockWidget::topLevelChanged, [this](bool/* topLevel*/)
|
connect(this, &QDockWidget::topLevelChanged, [this](bool/* topLevel*/)
|
||||||
{
|
{
|
||||||
|
SetTitleBarVisible(m_is_title_bar_visible);
|
||||||
style()->unpolish(this);
|
style()->unpolish(this);
|
||||||
style()->polish(this);
|
style()->polish(this);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
void SetTitleBarVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (visible || isFloating())
|
||||||
|
{
|
||||||
|
if (m_title_bar_widget.get() != titleBarWidget())
|
||||||
|
{
|
||||||
|
setTitleBarWidget(m_title_bar_widget.get());
|
||||||
|
QMargins margins = widget()->contentsMargins();
|
||||||
|
margins.setTop(0);
|
||||||
|
widget()->setContentsMargins(margins);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setTitleBarWidget(new QWidget());
|
||||||
|
QMargins margins = widget()->contentsMargins();
|
||||||
|
margins.setTop(1);
|
||||||
|
widget()->setContentsMargins(margins);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_is_title_bar_visible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent* event) override
|
void paintEvent(QPaintEvent* event) override
|
||||||
|
|
|
@ -149,13 +149,14 @@ namespace gui
|
||||||
const gui_save fd_decrypt_sprx = gui_save(main_window, "lastExplorePathSPRX", "");
|
const gui_save fd_decrypt_sprx = gui_save(main_window, "lastExplorePathSPRX", "");
|
||||||
const gui_save fd_cg_disasm = gui_save(main_window, "lastExplorePathCGD", "");
|
const gui_save fd_cg_disasm = gui_save(main_window, "lastExplorePathCGD", "");
|
||||||
|
|
||||||
const gui_save mw_debugger = gui_save(main_window, "debuggerVisible", false);
|
const gui_save mw_debugger = gui_save(main_window, "debuggerVisible", false);
|
||||||
const gui_save mw_logger = gui_save(main_window, "loggerVisible", true);
|
const gui_save mw_logger = gui_save(main_window, "loggerVisible", true);
|
||||||
const gui_save mw_gamelist = gui_save(main_window, "gamelistVisible", true);
|
const gui_save mw_gamelist = gui_save(main_window, "gamelistVisible", true);
|
||||||
const gui_save mw_toolBarVisible = gui_save(main_window, "toolBarVisible", true);
|
const gui_save mw_toolBarVisible = gui_save(main_window, "toolBarVisible", true);
|
||||||
const gui_save mw_geometry = gui_save(main_window, "geometry", QByteArray());
|
const gui_save mw_titleBarsVisible = gui_save(main_window, "titleBarsVisible", true);
|
||||||
const gui_save mw_windowState = gui_save(main_window, "windowState", QByteArray());
|
const gui_save mw_geometry = gui_save(main_window, "geometry", QByteArray());
|
||||||
const gui_save mw_mwState = gui_save(main_window, "wwState", QByteArray());
|
const gui_save mw_windowState = gui_save(main_window, "windowState", QByteArray());
|
||||||
|
const gui_save mw_mwState = gui_save(main_window, "wwState", QByteArray());
|
||||||
|
|
||||||
const gui_save cat_hdd_game = gui_save(game_list, "categoryVisibleHDDGame", true);
|
const gui_save cat_hdd_game = gui_save(game_list, "categoryVisibleHDDGame", true);
|
||||||
const gui_save cat_disc_game = gui_save(game_list, "categoryVisibleDiscGame", true);
|
const gui_save cat_disc_game = gui_save(game_list, "categoryVisibleDiscGame", true);
|
||||||
|
|
|
@ -1145,6 +1145,13 @@ void main_window::RepaintGui()
|
||||||
Q_EMIT RequestTrophyManagerRepaint();
|
Q_EMIT RequestTrophyManagerRepaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void main_window::ShowTitleBars(bool show)
|
||||||
|
{
|
||||||
|
m_gameListFrame->SetTitleBarVisible(show);
|
||||||
|
m_debuggerFrame->SetTitleBarVisible(show);
|
||||||
|
m_logFrame->SetTitleBarVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
void main_window::CreateActions()
|
void main_window::CreateActions()
|
||||||
{
|
{
|
||||||
ui->exitAct->setShortcuts(QKeySequence::Quit);
|
ui->exitAct->setShortcuts(QKeySequence::Quit);
|
||||||
|
@ -1371,6 +1378,12 @@ void main_window::CreateConnects()
|
||||||
guiSettings->SetValue(gui::mw_gamelist, checked);
|
guiSettings->SetValue(gui::mw_gamelist, checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(ui->showTitleBarsAct, &QAction::triggered, [=](bool checked)
|
||||||
|
{
|
||||||
|
ShowTitleBars(checked);
|
||||||
|
guiSettings->SetValue(gui::mw_titleBarsVisible, checked);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->showToolBarAct, &QAction::triggered, [=](bool checked)
|
connect(ui->showToolBarAct, &QAction::triggered, [=](bool checked)
|
||||||
{
|
{
|
||||||
ui->toolBar->setVisible(checked);
|
ui->toolBar->setVisible(checked);
|
||||||
|
@ -1606,12 +1619,15 @@ void main_window::ConfigureGuiFromSettings(bool configure_all)
|
||||||
ui->showGameListAct->setChecked(guiSettings->GetValue(gui::mw_gamelist).toBool());
|
ui->showGameListAct->setChecked(guiSettings->GetValue(gui::mw_gamelist).toBool());
|
||||||
ui->showDebuggerAct->setChecked(guiSettings->GetValue(gui::mw_debugger).toBool());
|
ui->showDebuggerAct->setChecked(guiSettings->GetValue(gui::mw_debugger).toBool());
|
||||||
ui->showToolBarAct->setChecked(guiSettings->GetValue(gui::mw_toolBarVisible).toBool());
|
ui->showToolBarAct->setChecked(guiSettings->GetValue(gui::mw_toolBarVisible).toBool());
|
||||||
|
ui->showTitleBarsAct->setChecked(guiSettings->GetValue(gui::mw_titleBarsVisible).toBool());
|
||||||
|
|
||||||
m_debuggerFrame->setVisible(ui->showDebuggerAct->isChecked());
|
m_debuggerFrame->setVisible(ui->showDebuggerAct->isChecked());
|
||||||
m_logFrame->setVisible(ui->showLogAct->isChecked());
|
m_logFrame->setVisible(ui->showLogAct->isChecked());
|
||||||
m_gameListFrame->setVisible(ui->showGameListAct->isChecked());
|
m_gameListFrame->setVisible(ui->showGameListAct->isChecked());
|
||||||
ui->toolBar->setVisible(ui->showToolBarAct->isChecked());
|
ui->toolBar->setVisible(ui->showToolBarAct->isChecked());
|
||||||
|
|
||||||
|
ShowTitleBars(ui->showTitleBarsAct->isChecked());
|
||||||
|
|
||||||
ui->showHiddenEntriesAct->setChecked(guiSettings->GetValue(gui::gl_show_hidden).toBool());
|
ui->showHiddenEntriesAct->setChecked(guiSettings->GetValue(gui::gl_show_hidden).toBool());
|
||||||
m_gameListFrame->SetShowHidden(ui->showHiddenEntriesAct->isChecked()); // prevent GetValue in m_gameListFrame->LoadSettings
|
m_gameListFrame->SetShowHidden(ui->showHiddenEntriesAct->isChecked()); // prevent GetValue in m_gameListFrame->LoadSettings
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ private:
|
||||||
void CreateConnects();
|
void CreateConnects();
|
||||||
void CreateDockWindows();
|
void CreateDockWindows();
|
||||||
void EnableMenus(bool enabled);
|
void EnableMenus(bool enabled);
|
||||||
|
void ShowTitleBars(bool show);
|
||||||
void InstallPkg(const QString& dropPath = "", bool is_bulk = false);
|
void InstallPkg(const QString& dropPath = "", bool is_bulk = false);
|
||||||
void InstallPup(const QString& dropPath = "");
|
void InstallPup(const QString& dropPath = "");
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,7 @@
|
||||||
<addaction name="showDebuggerAct"/>
|
<addaction name="showDebuggerAct"/>
|
||||||
<addaction name="showLogAct"/>
|
<addaction name="showLogAct"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="showTitleBarsAct"/>
|
||||||
<addaction name="showToolBarAct"/>
|
<addaction name="showToolBarAct"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="showGameListAct"/>
|
<addaction name="showGameListAct"/>
|
||||||
|
@ -956,6 +957,14 @@
|
||||||
<string>Add Games</string>
|
<string>Add Games</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="showTitleBarsAct">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Title Bars</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue