Switch to side-by-side view

--- a/HelperStructs/Style.cpp
+++ b/HelperStructs/Style.cpp
@@ -1,6 +1,7 @@
 /* Copyright (C) 2011  Lucio Carreras
+ * Copyright (C) 2017 J.F. Dockes
  *
- * This file is part of sayonara player
+ * This file is part of Upplay
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,9 +22,21 @@
 
 #include "HelperStructs/Helper.h"
 #include "HelperStructs/Style.h"
+#include "upadapt/upputils.h"
+#include "utils/smallut.h"
 
+#include <iostream>
+#include <string>
+#include <regex>
+#include <array>
 
-QString Style::get_style(bool dark)
+using namespace std;
+
+/* font-size: 10pt; */
+static const string fntszexp(R"((\s*font-size\s*:\s*)([0-9]+)(pt\s*;\s*))");
+static regex fntszregex(fntszexp);
+
+QString Style::get_style(bool dark, float multiplier)
 {
 #if !defined(Q_OS_MACOS) && !defined(Q_OS_MAC)
     QString dir = Helper::getSharePath();
@@ -33,112 +46,42 @@
 
     QString commonstyle;
     Helper::read_file_into_str(dir + "/common.qss", &commonstyle);
+
+    commonstyle = u8s2qs(scale_fonts(qs2utf8s(commonstyle), multiplier));
+    
     QString style;
     if (!dark) {
         Helper::read_file_into_str(dir + "/standard.qss", &style);
     } else {
-         Helper::read_file_into_str(dir + "/dark.qss", &style);
+        Helper::read_file_into_str(dir + "/dark.qss", &style);
     }
 
     return commonstyle + style;
 }
 
-
-QString Style::get_tv_style(bool /*dark*/, QPalette*)
+// The hell if I'm studying yet another regexp syntax, let's go std
+string Style::scale_fonts(const string& style, float multiplier)
 {
-    return  "";
+    vector<string> lines;
+    stringToTokens(style, lines, "\n");
+    for (unsigned int ln = 0; ln < lines.size(); ln++) {
+        const string& line = lines[ln];
+        smatch m;
+        if (regex_match(line, m, fntszregex)) {
+            //cerr << "Got match (sz " << m.size() << ") for " << line << endl;
+            if (m.size() == 4) {
+                int fs = atoi(m[2].str().c_str());
+                int nfs = round(fs * multiplier);
+                char buf[20];
+                snprintf(buf, 20, "%d", nfs);
+                lines[ln] = m[1].str() + buf + m[3].str();
+                //cerr << "New line: [" << lines[ln] << "]\n";
+            }
+        }
+    }
+    string nstyle = string();
+    for (auto& ln : lines) {
+        nstyle += ln + "\n";
+    }
+    return nstyle;
 }
-
-
-QString Style::get_v_slider_style(bool dark, int percent)
-{
-    if (!dark) {
-        return "";
-    }
-
-    percent = 0;
-    QString darker_grey = "#2B2B2B";
-    QString dark_grey = "#555555";
-
-
-
-    QString orange = "#e8841a";
-    QString back_col = orange;
-
-    if (percent > 0) {
-        double p = percent * 1.0 / 100.0;
-        int r, g, b;
-        b = 0;
-        if (p < 0.6) {
-            r = 255;
-        } else {
-            r = (-255.0 / 0.6) * (p - 0.6) + 255;
-        }
-
-        g = (255.0) * p;
-
-
-        QString s_r;
-        QString s_g;
-        QString s_b;
-
-        s_r.sprintf("%02X", r);
-        s_g.sprintf("%02X", g);
-        s_b.sprintf("%02X", b);
-
-
-        back_col = "#" + s_g.left(2) + s_r.left(2) + s_b.left(2);
-    }
-
-
-    QString style =  QString("QSlider {") +
-                     "border-radius: 4px; " +
-                     "background: #383838; " +
-
-                     "}" +
-
-                     "QSlider::handle:vertical {" +
-                     "     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, " +
-                     "                                 stop: 0 #6B6B6B, stop: 0.4 " + dark_grey + ");" +
-                     "    height: 10px;" +
-                     "    margin-left: -5px; " +
-                     "    margin-right: -5px; " +
-                     "    min-width: 12px;" +
-                     "    border: 1px solid #2C2C2C; " +
-                     "    border-radius: 4px; " +
-                     "}" +
-
-                     "QSlider::handle:vertical:disabled {" +
-                     "    background: transparent;"
-                     "    height: 0px;"
-                     "	 border-width: 0px;"
-                     "}" +
-
-
-                     "QSlider::groove:vertical { " +
-                     "    background: #383838;" +
-                     "    width: 6px; " +
-                     "    left: 10px; right: 10px; " +
-                     "}" +
-
-
-                     "QSlider::add-page:vertical {" +
-                     /*"    background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, "  +
-                       "          stop:0 #E88417, stop: 0.3 #C46600, " +
-                       "          stop: 0.7 #C46600, stop:1 #E88417); " +*/
-                     //"      background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(255, 0, 0, 255), stop:0.505051 rgba(255, 228, 0, 255), stop:1 rgba(55, 239, 78, 255)); "
-
-                     "    background-color: " + back_col + "; "
-                     "    border-radius: 2px;" +
-
-                     "}" +
-
-                     "QSlider::sub-page:vertical, QSlider::add-page:vertical:disabled {" +
-                     "   background: " + darker_grey + ";" +
-                     //     "    background-color: " + back_col + "; "
-                     "   border-radius: 2px;" +
-
-                     "}";
-
-    return style;
-}