1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Qt: enable background images for floating dock widgets

This commit is contained in:
Megamouse 2018-03-02 00:45:20 +01:00 committed by Ivan
parent 504e3112dd
commit 8db7ef4d5a
11 changed files with 53 additions and 26 deletions

View File

@ -226,7 +226,7 @@ QDockWidget {
font-weight: 500; font-weight: 500;
} }
[floating="true"] { [floating="true"] {
background: #b3ac98; border-image: url("GuiConfigs/YoRHa-background.jpg");
} }
QDockWidget::title { QDockWidget::title {
background: #4d4940; background: #4d4940;

View File

@ -1308,6 +1308,7 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">.\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">.\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DLLVM_AVAILABLE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE "-I.\..\Vulkan\Vulkan-LoaderAndValidationLayers\include" "-I.\.." "-I.\..\3rdparty\minidx12\Include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtOpenGL" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtQuick" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtQml" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)\." "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DLLVM_AVAILABLE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE "-I.\..\Vulkan\Vulkan-LoaderAndValidationLayers\include" "-I.\.." "-I.\..\3rdparty\minidx12\Include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtOpenGL" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtQuick" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtQml" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)\." "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras"</Command>
</CustomBuild> </CustomBuild>
<ClInclude Include="rpcs3qt\custom_dock_widget.h" />
<ClInclude Include="rpcs3qt\find_dialog.h" /> <ClInclude Include="rpcs3qt\find_dialog.h" />
<ClInclude Include="rpcs3qt\custom_table_widget_item.h" /> <ClInclude Include="rpcs3qt\custom_table_widget_item.h" />
<ClInclude Include="rpcs3qt\gamepads_settings_dialog.h" /> <ClInclude Include="rpcs3qt\gamepads_settings_dialog.h" />

View File

@ -688,6 +688,9 @@
<ClInclude Include="rpcs3qt\qt_utils.h"> <ClInclude Include="rpcs3qt\qt_utils.h">
<Filter>Gui\utils</Filter> <Filter>Gui\utils</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="rpcs3qt\custom_dock_widget.h">
<Filter>Gui</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="debug\moc_predefs.h.cbt"> <CustomBuild Include="debug\moc_predefs.h.cbt">
@ -817,4 +820,4 @@
<ItemGroup> <ItemGroup>
<ResourceCompile Include="rpcs3.rc" /> <ResourceCompile Include="rpcs3.rc" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,37 @@
#pragma once
#include <QDockWidget>
#include <QStyleOption>
#include <QPainter>
class custom_dock_widget : public QDockWidget
{
public:
explicit custom_dock_widget(const QString &title, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
: QDockWidget(title, parent, flags)
{
connect(this, &QDockWidget::topLevelChanged, [this](bool/* topLevel*/)
{
style()->unpolish(this);
style()->polish(this);
});
};
protected:
void paintEvent(QPaintEvent* event) override
{
// We need to repaint the dock widgets as plain widgets in floating mode.
// Source: https://stackoverflow.com/questions/10272091/cannot-add-a-background-image-to-a-qdockwidget
if (isFloating())
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
return;
}
// Use inherited method for docked mode because otherwise the dock would lose the title etc.
QDockWidget::paintEvent(event);
}
};

View File

@ -10,7 +10,7 @@ constexpr auto qstr = QString::fromStdString;
extern bool user_asked_for_frame_capture; extern bool user_asked_for_frame_capture;
debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent) debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent)
: QDockWidget(tr("Debugger"), parent), xgui_settings(settings) : custom_dock_widget(tr("Debugger"), parent), xgui_settings(settings)
{ {
m_update = new QTimer(this); m_update = new QTimer(this);
connect(m_update, &QTimer::timeout, this, &debugger_frame::UpdateUI); connect(m_update, &QTimer::timeout, this, &debugger_frame::UpdateUI);

View File

@ -13,11 +13,11 @@
#include "Emu/Cell/SPUDisAsm.h" #include "Emu/Cell/SPUDisAsm.h"
#include "Emu/Cell/PPUInterpreter.h" #include "Emu/Cell/PPUInterpreter.h"
#include "custom_dock_widget.h"
#include "instruction_editor_dialog.h" #include "instruction_editor_dialog.h"
#include "register_editor_dialog.h" #include "register_editor_dialog.h"
#include "gui_settings.h" #include "gui_settings.h"
#include <QDockWidget>
#include <QListWidget> #include <QListWidget>
#include <QPushButton> #include <QPushButton>
#include <QComboBox> #include <QComboBox>
@ -29,7 +29,7 @@
class debugger_list; class debugger_list;
class debugger_frame : public QDockWidget class debugger_frame : public custom_dock_widget
{ {
Q_OBJECT Q_OBJECT

View File

@ -24,7 +24,7 @@ inline std::string sstr(const QString& _in) { return _in.toStdString(); }
inline QSize sizeFromSlider(const int& pos) { return gui::gl_icon_size_min + (gui::gl_icon_size_max - gui::gl_icon_size_min) * (pos / (float)gui::gl_max_slider_pos); } inline QSize sizeFromSlider(const int& pos) { return gui::gl_icon_size_min + (gui::gl_icon_size_max - gui::gl_icon_size_min) * (pos / (float)gui::gl_max_slider_pos); }
game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, QWidget *parent) game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, QWidget *parent)
: QDockWidget(tr("Game List"), parent), xgui_settings(guiSettings), xemu_settings(emuSettings) : custom_dock_widget(tr("Game List"), parent), xgui_settings(guiSettings), xemu_settings(emuSettings)
{ {
m_isListLayout = xgui_settings->GetValue(gui::gl_listMode).toBool(); m_isListLayout = xgui_settings->GetValue(gui::gl_listMode).toBool();
m_icon_size_index = xgui_settings->GetValue(gui::gl_iconSize).toInt(); m_icon_size_index = xgui_settings->GetValue(gui::gl_iconSize).toInt();

View File

@ -3,12 +3,12 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/GameInfo.h" #include "Emu/GameInfo.h"
#include "custom_dock_widget.h"
#include "game_list.h" #include "game_list.h"
#include "game_list_grid.h" #include "game_list_grid.h"
#include "emu_settings.h" #include "emu_settings.h"
#include "game_compatibility.h" #include "game_compatibility.h"
#include <QDockWidget>
#include <QMainWindow> #include <QMainWindow>
#include <QToolBar> #include <QToolBar>
#include <QLineEdit> #include <QLineEdit>
@ -170,7 +170,7 @@ struct GUI_GameInfo
bool hasCustomConfig; bool hasCustomConfig;
}; };
class game_list_frame : public QDockWidget class game_list_frame : public custom_dock_widget
{ {
Q_OBJECT Q_OBJECT

View File

@ -103,7 +103,8 @@ struct gui_listener : logs::listener
// GUI Listener instance // GUI Listener instance
static gui_listener s_gui_listener; static gui_listener s_gui_listener;
log_frame::log_frame(std::shared_ptr<gui_settings> guiSettings, QWidget *parent) : QDockWidget(tr("Log"), parent), xgui_settings(guiSettings) log_frame::log_frame(std::shared_ptr<gui_settings> guiSettings, QWidget *parent)
: custom_dock_widget(tr("Log"), parent), xgui_settings(guiSettings)
{ {
m_tabWidget = new QTabWidget; m_tabWidget = new QTabWidget;
m_tabWidget->setObjectName("tab_widget_log"); m_tabWidget->setObjectName("tab_widget_log");

View File

@ -3,19 +3,19 @@
#include "Utilities/File.h" #include "Utilities/File.h"
#include "Utilities/Log.h" #include "Utilities/Log.h"
#include "custom_dock_widget.h"
#include "gui_settings.h" #include "gui_settings.h"
#include "find_dialog.h" #include "find_dialog.h"
#include <memory> #include <memory>
#include <QDockWidget>
#include <QTabWidget> #include <QTabWidget>
#include <QTextEdit> #include <QTextEdit>
#include <QActionGroup> #include <QActionGroup>
#include <QTimer> #include <QTimer>
#include <QKeyEvent> #include <QKeyEvent>
class log_frame : public QDockWidget class log_frame : public custom_dock_widget
{ {
Q_OBJECT Q_OBJECT

View File

@ -1328,11 +1328,6 @@ void main_window::CreateDockWindows()
guiSettings->SetValue(gui::mw_logger, false); guiSettings->SetValue(gui::mw_logger, false);
} }
}); });
connect(m_logFrame, &log_frame::topLevelChanged, [=](bool/* topLevel*/)
{
m_logFrame->style()->unpolish(m_logFrame);
m_logFrame->style()->polish(m_logFrame);
});
connect(m_debuggerFrame, &debugger_frame::DebugFrameClosed, [=]() connect(m_debuggerFrame, &debugger_frame::DebugFrameClosed, [=]()
{ {
@ -1342,11 +1337,6 @@ void main_window::CreateDockWindows()
guiSettings->SetValue(gui::mw_debugger, false); guiSettings->SetValue(gui::mw_debugger, false);
} }
}); });
connect(m_debuggerFrame, &log_frame::topLevelChanged, [=](bool/* topLevel*/)
{
m_debuggerFrame->style()->unpolish(m_debuggerFrame);
m_debuggerFrame->style()->polish(m_debuggerFrame);
});
connect(m_gameListFrame, &game_list_frame::GameListFrameClosed, [=]() connect(m_gameListFrame, &game_list_frame::GameListFrameClosed, [=]()
{ {
@ -1356,11 +1346,6 @@ void main_window::CreateDockWindows()
guiSettings->SetValue(gui::mw_gamelist, false); guiSettings->SetValue(gui::mw_gamelist, false);
} }
}); });
connect(m_gameListFrame, &log_frame::topLevelChanged, [=](bool/* topLevel*/)
{
m_gameListFrame->style()->unpolish(m_gameListFrame);
m_gameListFrame->style()->polish(m_gameListFrame);
});
connect(m_gameListFrame, &game_list_frame::RequestBoot, [this](const std::string& path){ Boot(path); }); connect(m_gameListFrame, &game_list_frame::RequestBoot, [this](const std::string& path){ Boot(path); });
} }