From cf83b796e11d01c6d56329aaf46f1d895a1dc014 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 5 Oct 2017 00:10:24 +0200 Subject: [PATCH] Qt: include debug tool colors in stylesheet (#3527) Qt: include debug tool colors in stylesheet --- bin/GuiConfigs/Kuroi (Dark) by Ani.qss | 37 ++++++++++++++++++++++++++ rpcs3/rpcs3_app.cpp | 8 ++++++ rpcs3/rpcs3qt/debugger_frame.cpp | 27 ++++++++++++++----- rpcs3/rpcs3qt/debugger_frame.h | 5 ++++ rpcs3/rpcs3qt/game_list_grid.cpp | 8 +++--- rpcs3/rpcs3qt/gui_settings.h | 8 ++++++ rpcs3/rpcs3qt/kernel_explorer.cpp | 4 +-- rpcs3/rpcs3qt/main_window.cpp | 5 ++++ rpcs3/rpcs3qt/memory_viewer_panel.cpp | 24 ++++++----------- rpcs3/rpcs3qt/rsx_debugger.cpp | 5 ++-- rpcs3/rpcs3qt/rsx_debugger.h | 2 +- 11 files changed, 99 insertions(+), 34 deletions(-) diff --git a/bin/GuiConfigs/Kuroi (Dark) by Ani.qss b/bin/GuiConfigs/Kuroi (Dark) by Ani.qss index 229c54ac56..cd63a0a6fe 100644 --- a/bin/GuiConfigs/Kuroi (Dark) by Ani.qss +++ b/bin/GuiConfigs/Kuroi (Dark) by Ani.qss @@ -291,3 +291,40 @@ QTextEdit#tty_frame { QLabel#tty_text { color: #ffffff; /* White */ } + +/* RSX Debugger */ +QLabel#rsx_debugger_display_buffer { + background-color: #323232; +} + +/* Kernel Explorer */ +QDialog#kernel_explorer { + background-color: #323232; +} + +/* Memory Viewer */ +QDialog#memory_viewer { + background-color: #323232; +} +QLabel#memory_viewer_address_panel { + color: #00cbff; /* Font Color: Blue */ + background-color: #323232; +} +QLabel#memory_viewer_hex_panel { + color: #bdc3c7; /* Font Color: Grey */ + background-color: #323232; +} +QLabel#memory_viewer_ascii_panel { + color: #bdc3c7; /* Font Color: Grey */ + background-color: #323232; +} + +/* Debugger colors */ +QLabel#debugger_frame_breakpoint { + color: #000000; /* Font Color: Black */ + background-color: #ffff00; /* Yellow */ +} +QLabel#debugger_frame_pc { + color: #000000; /* Font Color: Black */ + background-color: #00ff00; /* Green */ +} diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index f6fcfad85b..3fff679ee3 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -336,6 +336,14 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& sheetFilePath) QString style_rest = QString ( "QWidget#header_section { background-color: #ffffff; }" + "QDialog#kernel_explorer { background-color: rgba(240, 240, 240, 255); }" + "QDialog#memory_viewer { background-color: rgba(240, 240, 240, 255); }" + "QLabel#memory_viewer_address_panel { color: rgba(75, 135, 150, 255); background-color: rgba(240, 240, 240, 255); }" + "QLabel#memory_viewer_hex_panel { color: #000000; background-color: rgba(240, 240, 240, 255); }" + "QLabel#memory_viewer_ascii_panel { color: #000000; background-color: rgba(240, 240, 240, 255); }" + "QLabel#debugger_frame_breakpoint { color: #000000; background-color: #ffff00; }" + "QLabel#debugger_frame_pc { color: #000000; background-color: #00ff00; }" + "QLabel#rsx_debugger_display_buffer { background-color: rgba(240, 240, 240, 255); }" "QLabel#l_controller { color: #434343; }" "QLabel#gamegrid_font { font-weight: 600; font-size: 8pt; font-family: Lucida Grande; color: rgba(51, 51, 51, 255); }" ); diff --git a/rpcs3/rpcs3qt/debugger_frame.cpp b/rpcs3/rpcs3qt/debugger_frame.cpp index 52955b0c40..5900ad7634 100644 --- a/rpcs3/rpcs3qt/debugger_frame.cpp +++ b/rpcs3/rpcs3qt/debugger_frame.cpp @@ -40,6 +40,7 @@ debugger_frame::debugger_frame(std::shared_ptr settings, QWidget * m_btn_run = new QPushButton(Run, this); EnableButtons(!Emu.IsStopped()); + ChangeColors(); hbox_b_main->addWidget(m_go_to_addr); hbox_b_main->addWidget(m_go_to_pc); @@ -125,6 +126,17 @@ void debugger_frame::SaveSettings() xgui_settings->SetValue(GUI::d_splitterState, m_splitter->saveState()); } +void debugger_frame::ChangeColors() +{ + if (m_list) + { + m_list->m_color_bp = GUI::get_Label_Color("debugger_frame_breakpoint", QPalette::Background); + m_list->m_color_pc = GUI::get_Label_Color("debugger_frame_pc", QPalette::Background); + m_list->m_text_color_bp = GUI::get_Label_Color("debugger_frame_breakpoint");; + m_list->m_text_color_pc = GUI::get_Label_Color("debugger_frame_pc");; + } +} + void debugger_frame::closeEvent(QCloseEvent *event) { QDockWidget::closeEvent(event); @@ -501,18 +513,21 @@ void debugger_list::ShowAddr(u32 addr) item(i)->setText((IsBreakPoint(m_pc) ? ">>> " : " ") + qstr(m_debugFrame->m_disasm->last_opcode)); - QColor colour; - if (test(cpu->state & cpu_state_pause) && m_pc == m_debugFrame->GetPc()) { - colour = QColor(Qt::green); + item(i)->setTextColor(m_text_color_pc); + item(i)->setBackgroundColor(m_color_pc); + } + else if (IsBreakPoint(m_pc)) + { + item(i)->setTextColor(m_text_color_bp); + item(i)->setBackgroundColor(m_color_bp); } else { - colour = QColor(IsBreakPoint(m_pc) ? Qt::yellow : Qt::white); + item(i)->setTextColor(palette().color(foregroundRole())); + item(i)->setBackgroundColor(palette().color(backgroundRole())); } - - item(i)->setBackgroundColor(colour); } } diff --git a/rpcs3/rpcs3qt/debugger_frame.h b/rpcs3/rpcs3qt/debugger_frame.h index e1d92adb28..b2f096c482 100644 --- a/rpcs3/rpcs3qt/debugger_frame.h +++ b/rpcs3/rpcs3qt/debugger_frame.h @@ -68,6 +68,7 @@ public: public: explicit debugger_frame(std::shared_ptr settings, QWidget *parent = 0); void SaveSettings(); + void ChangeColors(); void UpdateUI(); void UpdateUnitList(); @@ -108,6 +109,10 @@ public: u32 m_pc; u32 m_item_count; bool m_no_thread_selected; + QColor m_color_bp; + QColor m_color_pc; + QColor m_text_color_bp; + QColor m_text_color_pc; public: debugger_list(debugger_frame* parent); diff --git a/rpcs3/rpcs3qt/game_list_grid.cpp b/rpcs3/rpcs3qt/game_list_grid.cpp index c66695ad3e..1a8f99acbe 100644 --- a/rpcs3/rpcs3qt/game_list_grid.cpp +++ b/rpcs3/rpcs3qt/game_list_grid.cpp @@ -1,5 +1,6 @@ #include "game_list_grid.h" #include "game_list_grid_delegate.h" +#include "gui_settings.h" #include #include @@ -18,11 +19,8 @@ game_list_grid::game_list_grid(const QSize& icon_size, const QColor& icon_color, } // font by stylesheet - QLabel font_dummy; - font_dummy.setObjectName("gamegrid_font"); - font_dummy.ensurePolished(); - QFont font = font_dummy.font(); - QColor font_color = font_dummy.palette().color(QPalette::Foreground); + QFont font = GUI::get_Label_Font("gamegrid_font"); + QColor font_color = GUI::get_Label_Color("gamegrid_font"); grid_item_delegate = new game_list_grid_delegate(item_size, m_margin_factor, m_text_factor, font, font_color, this); setItemDelegate(grid_item_delegate); diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index dcbb621ce4..cd0c118a50 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -63,6 +63,14 @@ namespace GUI return dummy_color.palette().color(colorRole); }; + inline QFont get_Label_Font(const QString& objectName) + { + QLabel dummy_font; + dummy_font.setObjectName(objectName); + dummy_font.ensurePolished(); + return dummy_font.font(); + }; + inline QString get_Single_Line(const QString& multi_line_string) { QString single_line_string = multi_line_string; diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index 535d0fd043..0c4a0d0408 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -28,11 +28,9 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent) { setWindowTitle(tr("Kernel Explorer")); + setObjectName("kernel_explorer"); setAttribute(Qt::WA_DeleteOnClose); setMinimumSize(QSize(700, 450)); - QPalette pal; - pal.setColor(QPalette::Background, QColor(240, 240, 240)); - setPalette(pal); //This fix the ugly background color under Windows QVBoxLayout* vbox_panel = new QVBoxLayout(); QHBoxLayout* hbox_buttons = new QHBoxLayout(); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 41030c59c7..a0b00cc849 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1081,6 +1081,11 @@ void main_window::RepaintGui() m_logFrame->RepaintTextColors(); } + if (m_debuggerFrame) + { + m_debuggerFrame->ChangeColors(); + } + RepaintToolbar(); RepaintToolBarIcons(); RepaintThumbnailIcons(); diff --git a/rpcs3/rpcs3qt/memory_viewer_panel.cpp b/rpcs3/rpcs3qt/memory_viewer_panel.cpp index e0a584a359..a8f59a3f37 100644 --- a/rpcs3/rpcs3qt/memory_viewer_panel.cpp +++ b/rpcs3/rpcs3qt/memory_viewer_panel.cpp @@ -9,6 +9,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent) : QDialog(parent) { setWindowTitle(tr("Memory Viewer")); + setObjectName("memory_viewer"); setAttribute(Qt::WA_DeleteOnClose); exit = false; m_addr = 0; @@ -16,13 +17,10 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent) m_rowcount = 16; int pSize = 10; - //Font and Colors + //Font QFont mono = QFontDatabase::systemFont(QFontDatabase::FixedFont); mono.setPointSize(pSize); m_fontMetrics = new QFontMetrics(mono); - QPalette pal_bg; - pal_bg.setColor(QPalette::Background, QColor(240, 240, 240)); - setPalette(pal_bg); //Layout: QVBoxLayout* vbox_panel = new QVBoxLayout(); @@ -138,33 +136,27 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent) //Memory Panel: Address Panel m_mem_addr = new QLabel(""); + m_mem_addr->setObjectName("memory_viewer_address_panel"); m_mem_addr->setFont(mono); m_mem_addr->setAutoFillBackground(true); m_mem_addr->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - QPalette palette_addr = m_mem_addr->palette(); - palette_addr.setColor(m_mem_addr->backgroundRole(), QColor(240, 240, 240)); - palette_addr.setColor(m_mem_addr->foregroundRole(), QColor(75, 135, 150)); - m_mem_addr->setPalette(palette_addr); + m_mem_addr->ensurePolished(); //Memory Panel: Hex Panel m_mem_hex = new QLabel(""); + m_mem_hex->setObjectName("memory_viewer_hex_panel"); m_mem_hex->setFont(mono); m_mem_hex->setAutoFillBackground(true); m_mem_hex->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - QPalette palette_hex = m_mem_hex->palette(); - palette_hex.setColor(m_mem_hex->backgroundRole(), QColor(240, 240, 240)); - palette_hex.setColor(m_mem_hex->foregroundRole(), Qt::black); - m_mem_hex->setPalette(palette_hex); + m_mem_hex->ensurePolished(); //Memory Panel: ASCII Panel m_mem_ascii = new QLabel(""); + m_mem_ascii->setObjectName("memory_viewer_ascii_panel"); m_mem_ascii->setFont(mono); m_mem_ascii->setAutoFillBackground(true); m_mem_ascii->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - QPalette palette_ascii = m_mem_ascii->palette(); - palette_ascii.setColor(m_mem_ascii->backgroundRole(), QColor(240, 240, 240)); - palette_ascii.setColor(m_mem_ascii->foregroundRole(), Qt::black); - m_mem_ascii->setPalette(palette_ascii); + m_mem_ascii->ensurePolished(); //Merge Memory Panel: hbox_mem_panel->setAlignment(Qt::AlignLeft); diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 59c1d2cd45..d06f189774 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -387,11 +387,10 @@ namespace if (img.isNull()) return; //QString title = qstr(fmt::format("Raw Image @ 0x%x", addr)); QLabel* canvas = new QLabel(); - QPalette pal_bg; - pal_bg.setColor(canvas->backgroundRole(), QColor(240, 240, 240)); - canvas->setPalette(pal_bg); //This fix the ugly background color under Windows + canvas->setObjectName("rsx_debugger_display_buffer"); canvas->setPixmap(QPixmap::fromImage(img)); canvas->setFixedSize(img.size()); + canvas->ensurePolished(); canvas->show(); } } diff --git a/rpcs3/rpcs3qt/rsx_debugger.h b/rpcs3/rpcs3qt/rsx_debugger.h index 750b278072..dc6351e6c8 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.h +++ b/rpcs3/rpcs3qt/rsx_debugger.h @@ -12,6 +12,7 @@ #include "memory_viewer_panel.h" #include "table_item_delegate.h" +#include "gui_settings.h" #include #include @@ -22,7 +23,6 @@ #include #include #include -#include #include #include #include