Przeglądaj źródła

Move progress bar style into constexpr strings

James Rowe 7 lat temu
rodzic
commit
4bce57b149
1 zmienionych plików z 32 dodań i 28 usunięć
  1. 32 28
      src/yuzu/loading_screen.cpp

+ 32 - 28
src/yuzu/loading_screen.cpp

@@ -28,28 +28,11 @@
 #include <QMovie>
 #endif
 
-LoadingScreen::LoadingScreen(QWidget* parent)
-    : QWidget(parent), ui(std::make_unique<Ui::LoadingScreen>()),
-      previous_stage(VideoCore::LoadCallbackStage::Complete) {
-    ui->setupUi(this);
-
-    connect(this, &LoadingScreen::LoadProgress, this, &LoadingScreen::OnLoadProgress,
-            Qt::QueuedConnection);
-    qRegisterMetaType<VideoCore::LoadCallbackStage>();
-
-    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<Ui::LoadingScreen>()),
+      previous_stage(VideoCore::LoadCallbackStage::Complete) {
+    ui->setupUi(this);
+
+    connect(this, &LoadingScreen::LoadProgress, this, &LoadingScreen::OnLoadProgress,
+            Qt::QueuedConnection);
+    qRegisterMetaType<VideoCore::LoadCallbackStage>();
+
+    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},
     };
 }