Changeset View
Changeset View
Standalone View
Standalone View
src/blinken.cpp
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2005-2007 by Albert Astals Cid <aacid@kde.org> * | 2 | * Copyright (C) 2005-2007 by Albert Astals Cid <aacid@kde.org> * | ||
3 | * * | 3 | * * | ||
4 | * This program is free software; you can redistribute it and/or modify * | 4 | * This program is free software; you can redistribute it and/or modify * | ||
5 | * it under the terms of the GNU General Public License as published by * | 5 | * it under the terms of the GNU General Public License as published by * | ||
6 | * the Free Software Foundation; either version 2 of the License, or * | 6 | * the Free Software Foundation; either version 2 of the License, or * | ||
7 | * (at your option) any later version. * | 7 | * (at your option) any later version. * | ||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ | ||
9 | 9 | | |||
10 | #include "blinken.h" | 10 | #include "blinken.h" | ||
11 | 11 | | |||
12 | #include <qcursor.h> | 12 | #include <qcursor.h> | ||
aacid: I guess we don't need this now. | |||||
13 | #include <qevent.h> | 13 | #include <qevent.h> | ||
14 | #include <qpainter.h> | 14 | #include <qpainter.h> | ||
15 | #include <qsvgrenderer.h> | 15 | #include <qsvgrenderer.h> | ||
16 | #include <qtimer.h> | 16 | #include <qtimer.h> | ||
17 | #include <QAction> | 17 | #include <QAction> | ||
18 | #include <QApplication> | 18 | #include <QApplication> | ||
19 | #include <QInputDialog> | 19 | #include <QInputDialog> | ||
20 | #include <QKeySequence> | 20 | #include <QKeySequence> | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 91 | { | |||
109 | 109 | | |||
110 | // Base | 110 | // Base | ||
111 | // This -1 +1 suck but without them i got blank lines on borders | 111 | // This -1 +1 suck but without them i got blank lines on borders | ||
112 | p.drawPixmap(-1, 0, getPixmap(QStringLiteral("blinkenBase"), size()+QSize(1,1))); | 112 | p.drawPixmap(-1, 0, getPixmap(QStringLiteral("blinkenBase"), size()+QSize(1,1))); | ||
113 | 113 | | |||
114 | double xScaleButtons = 374.625 / 814.062; | 114 | double xScaleButtons = 374.625 / 814.062; | ||
115 | double yScaleButtons = 250.344 / 696.5; | 115 | double yScaleButtons = 250.344 / 696.5; | ||
116 | 116 | | |||
117 | // Red button | 117 | const auto sz = QSize((int)(width() * xScaleButtons), (int)(height() * yScaleButtons)); | ||
118 | QSize sz = QSize((int)(width() * xScaleButtons), (int)(height() * yScaleButtons)); | | |||
119 | if (m_highlighted & blinkenGame::red) | | |||
120 | { | | |||
121 | p.drawPixmap(QPointF( (double)width() / 1.975, (double)height() / 28.0), getPixmap(QStringLiteral("red_highlight"), sz)); | | |||
122 | } | | |||
123 | else | | |||
124 | { | | |||
125 | p.drawPixmap(QPointF( (double)width() / 1.975, (double)height() / 28.0), getPixmap(QStringLiteral("red_normal"), sz)); | | |||
126 | } | | |||
127 | | ||||
128 | // Green button | | |||
129 | if (m_highlighted & blinkenGame::green) | | |||
130 | { | | |||
131 | p.drawPixmap(QPointF( (double)width() / 1.975, (double)height() / 2.45), getPixmap(QStringLiteral("green_highlight"), sz)); | | |||
132 | } | | |||
133 | else | | |||
134 | { | | |||
135 | p.drawPixmap(QPointF( (double)width() / 1.975, (double)height() / 2.45), getPixmap(QStringLiteral("green_normal"), sz)); | | |||
136 | } | | |||
137 | 118 | | |||
aacid: The spacing of all the new lines is wonky, use tabs | |||||
138 | // Yellow button | 119 | auto getPixmapFor = [this, sz](blinkenGame::color color, const QString& pixmapName) -> QPixmap { | ||
139 | if (m_highlighted & blinkenGame::yellow) | 120 | return getPixmap( m_highlighted & color ? | ||
140 | { | 121 | QStringLiteral("%1_highlight").arg(pixmapName) : | ||
141 | p.drawPixmap(QPointF( (double)width() / 30.0, (double)height() / 28.0), getPixmap(QStringLiteral("yellow_highlight"), sz)); | 122 | QStringLiteral("%1_normal").arg(pixmapName), sz); | ||
142 | } | 123 | }; | ||
143 | else | 124 | | ||
144 | { | 125 | p.drawPixmap(QPointF(width() / 1.975, height() / 28.0), getPixmapFor(blinkenGame::red, QStringLiteral("red"))); | ||
145 | p.drawPixmap(QPointF( (double)width() / 30.0, (double)height() / 28.0), getPixmap(QStringLiteral("yellow_normal"), sz)); | 126 | p.drawPixmap(QPointF(width() / 1.975, height() / 2.45), getPixmapFor(blinkenGame::green, QStringLiteral("green"))); | ||
146 | } | 127 | p.drawPixmap(QPointF(width() / 30.0, height() / 28.0), getPixmapFor(blinkenGame::yellow, QStringLiteral("yellow"))); | ||
147 | 128 | p.drawPixmap(QPointF(width() / 30.0, height() / 2.45), getPixmapFor(blinkenGame::blue, QStringLiteral("blue"))); | |||
148 | // Blue button | | |||
149 | if (m_highlighted & blinkenGame::blue) | | |||
150 | { | | |||
151 | p.drawPixmap(QPointF( (double)width() / 30.0, (double)height() / 2.45), getPixmap(QStringLiteral("blue_highlight"), sz)); | | |||
152 | } | | |||
153 | else | | |||
154 | { | | |||
155 | p.drawPixmap(QPointF( (double)width() / 30.0, (double)height() / 2.45), getPixmap(QStringLiteral("blue_normal"), sz)); | | |||
156 | } | | |||
157 | 129 | | |||
158 | drawMenuQuit(p); | 130 | drawMenuQuit(p); | ||
159 | p.resetMatrix(); | 131 | p.resetMatrix(); | ||
160 | 132 | | |||
161 | // 644 525 are fixed size of preSVG blinken | 133 | // 644 525 are fixed size of preSVG blinken | ||
162 | p.scale((double)width()/644.0, (double)height()/525.0); | 134 | p.scale((double)width()/644.0, (double)height()/525.0); | ||
163 | if (m_showPreferences) | 135 | if (m_showPreferences) | ||
164 | { | 136 | { | ||
▲ Show 20 Lines • Show All 978 Lines • Show Last 20 Lines |
I guess we don't need this now.