From 4bce57b1495aec153041da0cb5bd5be8f518aea8 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Sun, 20 Jan 2019 18:20:21 -0700 Subject: Move progress bar style into constexpr strings --- src/yuzu/loading_screen.cpp | 60 ++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp index 530f5173c..608ab6f02 100644 --- a/src/yuzu/loading_screen.cpp +++ b/src/yuzu/loading_screen.cpp @@ -28,28 +28,11 @@ #include #endif -LoadingScreen::LoadingScreen(QWidget* parent) - : QWidget(parent), ui(std::make_unique()), - previous_stage(VideoCore::LoadCallbackStage::Complete) { - ui->setupUi(this); - - connect(this, &LoadingScreen::LoadProgress, this, &LoadingScreen::OnLoadProgress, - Qt::QueuedConnection); - qRegisterMetaType(); - - stage_translations = { - {VideoCore::LoadCallbackStage::Prepare, tr("Loading...")}, - {VideoCore::LoadCallbackStage::Raw, tr("Preparing Shaders %1 / %2")}, - {VideoCore::LoadCallbackStage::Binary, tr("Loading Shaders %1 / %2")}, - {VideoCore::LoadCallbackStage::Complete, tr("Launching...")}, - }; - progressbar_style = { - {VideoCore::LoadCallbackStage::Prepare, - R"( +constexpr const char* PROGRESSBAR_STYLE_PREPARE = R"( QProgressBar {} -QProgressBar::chunk {})"}, - {VideoCore::LoadCallbackStage::Raw, - R"( +QProgressBar::chunk {})"; + +constexpr const char* PROGRESSBAR_STYLE_RAW = R"( QProgressBar { background-color: black; border: 2px solid white; @@ -58,9 +41,9 @@ QProgressBar { } QProgressBar::chunk { background-color: #0ab9e6; -})"}, - {VideoCore::LoadCallbackStage::Binary, - R"( +})"; + +constexpr const char* PROGRESSBAR_STYLE_BINARY = R"( QProgressBar { background-color: black; border: 2px solid white; @@ -69,9 +52,9 @@ QProgressBar { } QProgressBar::chunk { background-color: #ff3c28; -})"}, - {VideoCore::LoadCallbackStage::Complete, - R"( +})"; + +constexpr const char* PROGRESSBAR_STYLE_COMPLETE = R"( QProgressBar { background-color: black; border: 2px solid white; @@ -80,7 +63,28 @@ QProgressBar { } QProgressBar::chunk { background-color: #ff3c28; -})"}, +})"; + +LoadingScreen::LoadingScreen(QWidget* parent) + : QWidget(parent), ui(std::make_unique()), + previous_stage(VideoCore::LoadCallbackStage::Complete) { + ui->setupUi(this); + + connect(this, &LoadingScreen::LoadProgress, this, &LoadingScreen::OnLoadProgress, + Qt::QueuedConnection); + qRegisterMetaType(); + + stage_translations = { + {VideoCore::LoadCallbackStage::Prepare, tr("Loading...")}, + {VideoCore::LoadCallbackStage::Raw, tr("Preparing Shaders %1 / %2")}, + {VideoCore::LoadCallbackStage::Binary, tr("Loading Shaders %1 / %2")}, + {VideoCore::LoadCallbackStage::Complete, tr("Launching...")}, + }; + progressbar_style = { + {VideoCore::LoadCallbackStage::Prepare, PROGRESSBAR_STYLE_PREPARE}, + {VideoCore::LoadCallbackStage::Raw, PROGRESSBAR_STYLE_RAW}, + {VideoCore::LoadCallbackStage::Binary, PROGRESSBAR_STYLE_BINARY}, + {VideoCore::LoadCallbackStage::Complete, PROGRESSBAR_STYLE_COMPLETE}, }; } -- cgit v1.2.3