[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [parley/KDE/4.14] src: Part I of fixing the color coding issue: make the dashboard use a struct for
From: Inge Wallin <inge () lysator ! liu ! se>
Date: 2015-02-05 0:07:52
Message-ID: E1YJ9z6-0002a5-6i () scm ! kde ! org
[Download RAW message or body]
Git commit 5d5367449422024dc975d82adda3489072f4c4b5 by Inge Wallin.
Committed on 02/02/2015 at 22:05.
Pushed by ingwa into branch 'KDE/4.14'.
Part I of fixing the color coding issue: make the dashboard use a struct for the colors.
M +3 -4 src/dashboard/barwidget.cpp
M +3 -4 src/dashboard/barwidget.h
M +2 -18 src/dashboard/dashboard.cpp
M +2 -2 src/dashboard/gradereferencewidget.cpp
M +33 -2 src/utils.cpp
M +12 -4 src/utils.h
http://commits.kde.org/parley/5d5367449422024dc975d82adda3489072f4c4b5
diff --git a/src/dashboard/barwidget.cpp b/src/dashboard/barwidget.cpp
index 4d29641..244aeaf 100644
--- a/src/dashboard/barwidget.cpp
+++ b/src/dashboard/barwidget.cpp
@@ -27,12 +27,11 @@
#include <klocalizedstring.h>
// Parley
-#include "utils.h"
#include "collectionwidget.h" // for COLLWIDTH, etc
-QColor gradeColor[11];
-
+// FIXME: Find a better home for this variable.
+ConfidenceColors globalColors = ConfidenceColors();
BarWidget::BarWidget(QWidget *parent)
@@ -124,7 +123,7 @@ void BarWidget::paintEvent(QPaintEvent *)
color = QColor(0, 0, 0, 128);
}
else {
- color = gradeColor[i];
+ color = globalColors.longTermColors[i];
}
painter.setBrush(QBrush(color));
painter.drawPath(barElementIntersectedPath);
diff --git a/src/dashboard/barwidget.h b/src/dashboard/barwidget.h
index 5f92f04..90e5d9d 100644
--- a/src/dashboard/barwidget.h
+++ b/src/dashboard/barwidget.h
@@ -20,13 +20,12 @@
#include <QPaintEvent>
#include <QWidget>
-#include "collection.h" // For struct WordCount
-
-class WordCount;
+#include "utils.h"
+#include "collection.h" // For struct WordCount
-extern QColor gradeColor[11];
+extern ConfidenceColors globalColors;
class BarWidget : public QWidget
diff --git a/src/dashboard/dashboard.cpp b/src/dashboard/dashboard.cpp
index f82f52d..66f6d6c 100644
--- a/src/dashboard/dashboard.cpp
+++ b/src/dashboard/dashboard.cpp
@@ -75,22 +75,6 @@ Dashboard::Dashboard(ParleyMainWindow *parent)
m_practiceSignalMapper = new QSignalMapper(this);
m_removeSignalMapper = new QSignalMapper(this);
- // Need 8 colors for confidence 0..7.
- // FIXME: Find a better color than gray for confidence 1.
- // FIXME: Add a color for pregrades.
- gradeColor[0] = QColor(25,38,41);
- gradeColor[1] = QColor(25,38,41,64);
- gradeColor[2] = QColor(237,21,21);
- gradeColor[3] = QColor(246,116,0);
- gradeColor[4] = QColor(201,206,59);
- gradeColor[5] = QColor(28,220,154);
- gradeColor[6] = QColor(17,209,22);
- gradeColor[7] = QColor(61,174,253);
-
- // These two are placeholders for the wordcloud background color.
- gradeColor[8] = QColor(255,221,217);
- gradeColor[9] = QColor(238,232,213);
-
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
@@ -368,8 +352,8 @@ void Dashboard::slotPracticeUrl(const KUrl & url)
// This used to go to the practice configuration but both I and
//some users wanted to go directly to the practice so I'm testing
//out this for a while.
- //m_mainWindow->showPracticeConfiguration();
- m_mainWindow->showPractice();
+ m_mainWindow->showPracticeConfiguration();
+ //m_mainWindow->showPractice();
}
void Dashboard::backgroundChanged(const QPixmap &pixmap)
diff --git a/src/dashboard/gradereferencewidget.cpp b/src/dashboard/gradereferencewidget.cpp
index 62a7002..7154f2e 100644
--- a/src/dashboard/gradereferencewidget.cpp
+++ b/src/dashboard/gradereferencewidget.cpp
@@ -26,7 +26,7 @@
#include <klocalizedstring.h>
// Parley
-#include "barwidget.h" // for gradeColor
+#include "barwidget.h" // for gradeColor^WglobalColors
GradeReferenceWidget::GradeReferenceWidget(QWidget *parent)
@@ -55,7 +55,7 @@ void GradeReferenceWidget::paintEvent(QPaintEvent *)
QPainterPath barElementPath;
barElementPath.addRect(barElement);
QPainterPath barElementIntersectedPath = roundedPath.intersected(barElementPath);
- QColor color = gradeColor[i];
+ QColor color = globalColors.longTermColors[i];
painter.setBrush(QBrush(color));
painter.drawPath(barElementIntersectedPath);
}
diff --git a/src/utils.cpp b/src/utils.cpp
index 900f05b..13b0b33 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -73,6 +73,37 @@ int WordCount::percentageCompleted() const
// class confidenceColors
-// FIXME: NYI
-//extern QColor gradeColor[11];
+ConfidenceColors::ConfidenceColors(ColorScheme colorScheme)
+{
+ initColors(colorScheme);
+}
+
+void ConfidenceColors::initColors(ColorScheme colorScheme)
+{
+ switch (colorScheme) {
+ case MultiColorScheme:
+ default: // Not default at the last line. Hope this works...
+
+ longTermColors[0] = QColor(25,38,41);
+ longTermColors[1] = QColor(Qt::yellow);
+ //longTermColors[1] = QColor(25,38,41,64);
+ longTermColors[2] = QColor(237,21,21);
+ longTermColors[3] = QColor(246,116,0);
+ longTermColors[4] = QColor(201,206,59);
+ longTermColors[5] = QColor(28,220,154);
+ longTermColors[6] = QColor(17,209,22);
+ longTermColors[7] = QColor(61,174,253);
+
+ initialTermColor = QColor(25,38,41,64);
+
+ // These two are placeholders for the wordcloud background color.
+ frontEndColors[0] = QColor(255,221,217);
+ frontEndColors[1] = QColor(238,232,213);
+ break;
+
+ case ProgressiveColorScheme:
+ // FIXME: NYI
+ break;
+ }
+}
diff --git a/src/utils.h b/src/utils.h
index fba3dbb..5e00843 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -16,8 +16,7 @@
#define UTILS_H
// Qt
-//#include <QPaintEvent>
-//#include <QWidget>
+#include <QtGui>
// KEduVocDocument library
#include <keduvocdocument.h>
@@ -41,11 +40,20 @@ struct WordCount {
};
+struct ConfidenceColors {
+ enum ColorScheme {
+ MultiColorScheme, //< The color scheme from the dashboard
+ ProgressiveColorScheme //< The color scheme from the practice component
+ };
+ ConfidenceColors(ColorScheme colorScheme = MultiColorScheme);
-//extern QColor gradeColor[11];
-
+ void initColors(ColorScheme colorScheme);
+ QColor longTermColors[KV_MAX_GRADE + 1];
+ QColor initialTermColor;
+ QColor frontEndColors[2]; // Placeholders for the wordcloud background colors
+};
#endif // UTILS_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic