1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

Qt: make dockwidget title bars optional

This commit is contained in:
Megamouse 2019-01-08 22:32:23 +01:00
parent 0236b994e4
commit 1b2e512179
6 changed files with 68 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#include "rpcs3_app.h"
#include "rpcs3_app.h"
#include "rpcs3qt/qt_utils.h"
@ -385,7 +385,7 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& path)
// dock widget
"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::close-button, QDockWidget::float-button{ background-color: #e3e3e3; }"

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QDockWidget>
#include <QStyleOption>
@ -6,16 +6,46 @@
class custom_dock_widget : public QDockWidget
{
private:
std::shared_ptr<QWidget> m_title_bar_widget;
bool m_is_title_bar_visible = true;
public:
explicit custom_dock_widget(const QString &title, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
: QDockWidget(title, parent, flags)
{
m_title_bar_widget.reset(titleBarWidget());
connect(this, &QDockWidget::topLevelChanged, [this](bool/* topLevel*/)
{
SetTitleBarVisible(m_is_title_bar_visible);
style()->unpolish(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:
void paintEvent(QPaintEvent* event) override

View File

@ -149,13 +149,14 @@ namespace gui
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 mw_debugger = gui_save(main_window, "debuggerVisible", false);
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_toolBarVisible = gui_save(main_window, "toolBarVisible", true);
const gui_save mw_geometry = gui_save(main_window, "geometry", 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 mw_debugger = gui_save(main_window, "debuggerVisible", false);
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_toolBarVisible = gui_save(main_window, "toolBarVisible", true);
const gui_save mw_titleBarsVisible = gui_save(main_window, "titleBarsVisible", true);
const gui_save mw_geometry = gui_save(main_window, "geometry", 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_disc_game = gui_save(game_list, "categoryVisibleDiscGame", true);

View File

@ -1145,6 +1145,13 @@ void main_window::RepaintGui()
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()
{
ui->exitAct->setShortcuts(QKeySequence::Quit);
@ -1371,6 +1378,12 @@ void main_window::CreateConnects()
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)
{
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->showDebuggerAct->setChecked(guiSettings->GetValue(gui::mw_debugger).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_logFrame->setVisible(ui->showLogAct->isChecked());
m_gameListFrame->setVisible(ui->showGameListAct->isChecked());
ui->toolBar->setVisible(ui->showToolBarAct->isChecked());
ShowTitleBars(ui->showTitleBarsAct->isChecked());
ui->showHiddenEntriesAct->setChecked(guiSettings->GetValue(gui::gl_show_hidden).toBool());
m_gameListFrame->SetShowHidden(ui->showHiddenEntriesAct->isChecked()); // prevent GetValue in m_gameListFrame->LoadSettings

View File

@ -116,6 +116,7 @@ private:
void CreateConnects();
void CreateDockWindows();
void EnableMenus(bool enabled);
void ShowTitleBars(bool show);
void InstallPkg(const QString& dropPath = "", bool is_bulk = false);
void InstallPup(const QString& dropPath = "");

View File

@ -263,6 +263,7 @@
<addaction name="showDebuggerAct"/>
<addaction name="showLogAct"/>
<addaction name="separator"/>
<addaction name="showTitleBarsAct"/>
<addaction name="showToolBarAct"/>
<addaction name="separator"/>
<addaction name="showGameListAct"/>
@ -956,6 +957,14 @@
<string>Add Games</string>
</property>
</action>
<action name="showTitleBarsAct">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show Title Bars</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>