summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar David Marcec2020-07-18 20:22:03 +1000
committerGravatar David Marcec2020-07-18 20:22:03 +1000
commitdb4502b7b7b01dc6ebec0b6a853e4a4cd60f8a84 (patch)
tree9e3040d2abcda89b4e3542768a21a65b94ec0020 /src
parentMerge pull request #4348 from lioncash/nano (diff)
downloadyuzu-db4502b7b7b01dc6ebec0b6a853e4a4cd60f8a84.tar.gz
yuzu-db4502b7b7b01dc6ebec0b6a853e4a4cd60f8a84.tar.xz
yuzu-db4502b7b7b01dc6ebec0b6a853e4a4cd60f8a84.zip
frontend: Improve wait tree readability for dark themes
Diffstat (limited to '')
-rw-r--r--src/yuzu/debugger/wait_tree.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index 9bb0a0109..5a974d2a0 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -2,9 +2,11 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <array>
5#include <fmt/format.h> 6#include <fmt/format.h>
6 7
7#include "yuzu/debugger/wait_tree.h" 8#include "yuzu/debugger/wait_tree.h"
9#include "yuzu/uisettings.h"
8#include "yuzu/util/util.h" 10#include "yuzu/util/util.h"
9 11
10#include "common/assert.h" 12#include "common/assert.h"
@@ -19,11 +21,37 @@
19#include "core/hle/kernel/thread.h" 21#include "core/hle/kernel/thread.h"
20#include "core/memory.h" 22#include "core/memory.h"
21 23
24namespace {
25
26constexpr std::array<std::array<Qt::GlobalColor, 2>, 10> WaitTreeColors{{
27 {Qt::GlobalColor::darkGreen, Qt::GlobalColor::green},
28 {Qt::GlobalColor::darkGreen, Qt::GlobalColor::green},
29 {Qt::GlobalColor::darkBlue, Qt::GlobalColor::cyan},
30 {Qt::GlobalColor::lightGray, Qt::GlobalColor::lightGray},
31 {Qt::GlobalColor::lightGray, Qt::GlobalColor::lightGray},
32 {Qt::GlobalColor::darkRed, Qt::GlobalColor::red},
33 {Qt::GlobalColor::darkYellow, Qt::GlobalColor::yellow},
34 {Qt::GlobalColor::red, Qt::GlobalColor::red},
35 {Qt::GlobalColor::darkCyan, Qt::GlobalColor::cyan},
36 {Qt::GlobalColor::gray, Qt::GlobalColor::gray},
37}};
38
39bool IsDarkTheme() {
40 const auto theme = UISettings::values.theme.toStdString();
41 return theme == "qdarkstyle" || theme == "colorful_dark";
42}
43
44} // namespace
45
22WaitTreeItem::WaitTreeItem() = default; 46WaitTreeItem::WaitTreeItem() = default;
23WaitTreeItem::~WaitTreeItem() = default; 47WaitTreeItem::~WaitTreeItem() = default;
24 48
25QColor WaitTreeItem::GetColor() const { 49QColor WaitTreeItem::GetColor() const {
26 return QColor(Qt::GlobalColor::black); 50 if (IsDarkTheme()) {
51 return QColor(Qt::GlobalColor::white);
52 } else {
53 return QColor(Qt::GlobalColor::black);
54 }
27} 55}
28 56
29std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeItem::GetChildren() const { 57std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeItem::GetChildren() const {
@@ -263,36 +291,41 @@ QString WaitTreeThread::GetText() const {
263} 291}
264 292
265QColor WaitTreeThread::GetColor() const { 293QColor WaitTreeThread::GetColor() const {
294 std::size_t color_index = 0;
295 if (IsDarkTheme()) {
296 color_index = 1;
297 }
298
266 const auto& thread = static_cast<const Kernel::Thread&>(object); 299 const auto& thread = static_cast<const Kernel::Thread&>(object);
267 switch (thread.GetStatus()) { 300 switch (thread.GetStatus()) {
268 case Kernel::ThreadStatus::Running: 301 case Kernel::ThreadStatus::Running:
269 return QColor(Qt::GlobalColor::darkGreen); 302 return QColor(WaitTreeColors[0][color_index]);
270 case Kernel::ThreadStatus::Ready: 303 case Kernel::ThreadStatus::Ready:
271 if (!thread.IsPaused()) { 304 if (!thread.IsPaused()) {
272 if (thread.WasRunning()) { 305 if (thread.WasRunning()) {
273 return QColor(Qt::GlobalColor::darkGreen); 306 return QColor(WaitTreeColors[1][color_index]);
274 } else { 307 } else {
275 return QColor(Qt::GlobalColor::darkBlue); 308 return QColor(WaitTreeColors[2][color_index]);
276 } 309 }
277 } else { 310 } else {
278 return QColor(Qt::GlobalColor::lightGray); 311 return QColor(WaitTreeColors[3][color_index]);
279 } 312 }
280 case Kernel::ThreadStatus::Paused: 313 case Kernel::ThreadStatus::Paused:
281 return QColor(Qt::GlobalColor::lightGray); 314 return QColor(WaitTreeColors[4][color_index]);
282 case Kernel::ThreadStatus::WaitHLEEvent: 315 case Kernel::ThreadStatus::WaitHLEEvent:
283 case Kernel::ThreadStatus::WaitIPC: 316 case Kernel::ThreadStatus::WaitIPC:
284 return QColor(Qt::GlobalColor::darkRed); 317 return QColor(WaitTreeColors[5][color_index]);
285 case Kernel::ThreadStatus::WaitSleep: 318 case Kernel::ThreadStatus::WaitSleep:
286 return QColor(Qt::GlobalColor::darkYellow); 319 return QColor(WaitTreeColors[6][color_index]);
287 case Kernel::ThreadStatus::WaitSynch: 320 case Kernel::ThreadStatus::WaitSynch:
288 case Kernel::ThreadStatus::WaitMutex: 321 case Kernel::ThreadStatus::WaitMutex:
289 case Kernel::ThreadStatus::WaitCondVar: 322 case Kernel::ThreadStatus::WaitCondVar:
290 case Kernel::ThreadStatus::WaitArb: 323 case Kernel::ThreadStatus::WaitArb:
291 return QColor(Qt::GlobalColor::red); 324 return QColor(WaitTreeColors[7][color_index]);
292 case Kernel::ThreadStatus::Dormant: 325 case Kernel::ThreadStatus::Dormant:
293 return QColor(Qt::GlobalColor::darkCyan); 326 return QColor(WaitTreeColors[8][color_index]);
294 case Kernel::ThreadStatus::Dead: 327 case Kernel::ThreadStatus::Dead:
295 return QColor(Qt::GlobalColor::gray); 328 return QColor(WaitTreeColors[9][color_index]);
296 default: 329 default:
297 return WaitTreeItem::GetColor(); 330 return WaitTreeItem::GetColor();
298 } 331 }