Commit bf5e124d authored by Sebastian Gottfried's avatar Sebastian Gottfried
Browse files

fix appearance of application with light-on-dark themes

In the most cases relying on theme colors instead of
fixed colors was enough, and in a few more cases for
elements with fixed background the opposite was right way
to achieve a good-looking result.

Most tricky proved to be the application background. I didn't
want to give up the Oxygen-provided background to ensure visual
consistency with the window decoration. Therefore I use Plasma's
background color but set the alpha accoardingly to the difference
between the two, if the colors are pretty similar the alpha is
zero.

BUG: 312082
FIXED-IN: 4.10 RC 2
parent acba43d4
......@@ -42,6 +42,7 @@ set(ktouch_SRCS
mainwindow.cpp
bindings/utils.cpp
bindings/stringformatter.cpp
declarativeitems/applicationbackground.cpp
declarativeitems/cursorshapearea.cpp
declarativeitems/griditem.cpp
declarativeitems/lessonfontsizecalculater.cpp
......
......@@ -27,6 +27,7 @@
#include "bindings/utils.h"
#include "bindings/stringformatter.h"
#include "declarativeitems/applicationbackground.h"
#include "declarativeitems/cursorshapearea.h"
#include "declarativeitems/griditem.h"
#include "declarativeitems/lessonfontsizecalculater.h"
......@@ -115,6 +116,7 @@ void Application::registerQmlTypes()
qmlRegisterType<LearningProgressModel>("ktouch", 1, 0, "LearningProgressModel");
qmlRegisterType<ErrorsModel>("ktouch", 1, 0, "ErrorsModel");
qmlRegisterType<ApplicationBackground>("ktouch", 1, 0, "ApplicationBackground");
qmlRegisterType<CursorShapeArea>("ktouch", 1, 0 , "CursorShapeArea");
qmlRegisterType<GridItem>("ktouch", 1, 0 , "Grid");
qmlRegisterType<LessonFontSizeCalculater>("ktouch", 1, 0, "LessonFontSizeCalculater");
......
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
*
* 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 the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "applicationbackground.h"
#include <QApplication>
#include <QPainter>
#include <plasma/theme.h>
ApplicationBackground::ApplicationBackground(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
{
setFlag(QDeclarativeItem::ItemHasNoContents, false);
}
void ApplicationBackground::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
{
const QColor appBgColor = QApplication::palette().color(QPalette::Window);
QColor color = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
const int similarity = qAbs(appBgColor.lightness() - color.lightness());
color.setAlpha(qMax(0, similarity - 50));
painter->fillRect(boundingRect(), color);
}
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
*
* 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 the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef APPLICATIONBACKGROUND_H
#define APPLICATIONBACKGROUND_H
#include <QDeclarativeItem>
class ApplicationBackground : public QDeclarativeItem
{
Q_OBJECT
public:
explicit ApplicationBackground(QDeclarativeItem *parent = 0);
protected:
void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
};
#endif // APPLICATIONBACKGROUND_H
......@@ -27,6 +27,7 @@ Item {
property alias textRole: core.textRole
property alias backgroundColor: bg.color
property color textColor: theme.textColor
signal barClicked(int row, variant bar)
signal barEntered(int row, variant bar)
......@@ -35,7 +36,7 @@ Item {
Rectangle {
id: bg
anchors.fill: parent
color: "white"
color: theme.backgroundColor
}
BarGraphCore {
......@@ -129,6 +130,7 @@ Item {
topMargin: 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 0? core.dimensions[0]: null
valueFactor: 1
}
......@@ -140,6 +142,7 @@ Item {
topMargin: (core.height - 4) / 2 + 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 0? core.dimensions[0]: null
valueFactor: 0.5
}
......@@ -151,6 +154,7 @@ Item {
topMargin: 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 1? core.dimensions[1]: null
valueFactor: 1
}
......@@ -162,6 +166,7 @@ Item {
topMargin: (core.height - 4) / 2 + 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 1? core.dimensions[1]: null
valueFactor: 0.5
}
......
......@@ -21,6 +21,7 @@ import org.kde.plasma.components 0.1 as PlasmaComponents
Item {
property Dimension dimension
property alias color: label.color
height: label.height
width: box.width + label.width + 5
......
......@@ -27,6 +27,7 @@ Item {
property alias pointRadius: core.pointRadius
property alias backgroundColor: bg.color
property color textColor: theme.textColor
signal pointClicked(int row, variant point)
signal pointEntered(int row, variant point)
......@@ -35,7 +36,7 @@ Item {
Rectangle {
id: bg
anchors.fill: parent
color: "white"
color: theme.backgroundColor
}
LineGraphCore {
......@@ -109,6 +110,7 @@ Item {
topMargin: core.pointRadius + 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 0? core.dimensions[0]: null
valueFactor: 1
}
......@@ -120,6 +122,7 @@ Item {
topMargin: core.pointRadius + (core.height - 2 * core.pointRadius - 4) / 2 + 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 0? core.dimensions[0]: null
valueFactor: 0.5
}
......@@ -131,6 +134,7 @@ Item {
topMargin: core.pointRadius + 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 1? core.dimensions[1]: null
valueFactor: 1
}
......@@ -142,6 +146,7 @@ Item {
topMargin: core.pointRadius + (core.height - 2 * core.pointRadius) / 2 + 2
}
backgroundItem: bg
color: root.textColor
dimension: core.dimensions.length > 1? core.dimensions[1]: null
valueFactor: 0.5
}
......
......@@ -28,7 +28,7 @@ Rectangle {
height: active || content.opacity > 0? childrenRect.height: 0
visible: height > 0
color: "white"
color: theme.backgroundColor
Behavior on height {
NumberAnimation {
......
......@@ -103,7 +103,7 @@ Item {
id: head
width: parent.width
height: Math.ceil(courseTitleLabel.height + 6)
color: "#fff"
color: theme.backgroundColor
Row {
anchors {
......
......@@ -61,6 +61,7 @@ Rectangle {
text: ""
height: paintedHeight
smooth: true
color: "#000000"
}
states: [
......
......@@ -68,11 +68,11 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 40
height: 250
color: "white"
color: theme.backgroundColor
border {
width: 1
color: "black"
color: theme.textColor
}
Column {
......
......@@ -296,11 +296,10 @@ FocusScope {
}
}
Rectangle {
width: parent.width
height: parent.height - ((parent.children.length - 1) * parent.spacing) - header.height
color: "#fff"
color: theme.backgroundColor
Column {
id: content
......@@ -343,6 +342,7 @@ FocusScope {
i18n("You have not passed the lesson.")
height: paintedHeight
font.pointSize: 1.5 * theme.defaultFont.pointSize
color: "#000000"
}
}
PlasmaComponents.Label {
......@@ -358,6 +358,7 @@ FocusScope {
return ""
}
height: paintedHeight
color: "#000000"
}
}
}
......
......@@ -106,6 +106,11 @@ Item {
keyboardLayoutNameFilter: keyboardLayout.isValid? keyboardLayout.name: keyboardLayoutName
}
ApplicationBackground {
id: background
anchors.fill: parent
}
HomeScreen {
id: homeScreen
anchors.fill: parent
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment