summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/groupedlineedit.cpp7
-rw-r--r--qt-ui/locationInformation.ui2
-rw-r--r--qt-ui/locationinformation.h2
-rw-r--r--qt-ui/starwidget.cpp33
4 files changed, 31 insertions, 13 deletions
diff --git a/qt-ui/groupedlineedit.cpp b/qt-ui/groupedlineedit.cpp
index ed2428fd7..9ce5e175c 100644
--- a/qt-ui/groupedlineedit.cpp
+++ b/qt-ui/groupedlineedit.cpp
@@ -31,6 +31,10 @@
#include <QScrollBar>
#include <QTextBlock>
#include <QPainter>
+#include <QApplication>
+#include <QStyle>
+#include <QStyleOptionFocusRect>
+#include <QDebug>
struct GroupedLineEdit::Private {
struct Block {
@@ -159,9 +163,6 @@ void GroupedLineEdit::keyPressEvent(QKeyEvent *e)
void GroupedLineEdit::paintEvent(QPaintEvent *e)
{
- // for reasons we don't understand, touching the painter
- // here (even drawing the fill rect) causes the QPlainTextEdit
- // paintEvent to not draw the text on Qt4 & MacOS.
QTextLine line = document()->findBlock(0).layout()->lineAt(0);
QPainter painter(viewport());
diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui
index cb9ddb829..ad33b2a90 100644
--- a/qt-ui/locationInformation.ui
+++ b/qt-ui/locationInformation.ui
@@ -14,7 +14,7 @@
<string>GroupBox</string>
</property>
<property name="title">
- <string>Dive Site</string>
+ <string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h
index 09814e9c0..0a2f66262 100644
--- a/qt-ui/locationinformation.h
+++ b/qt-ui/locationinformation.h
@@ -51,6 +51,6 @@ signals:
void setLineEditText(const QString& text);
private:
uint32_t last_uuid;
-
};
+
#endif
diff --git a/qt-ui/starwidget.cpp b/qt-ui/starwidget.cpp
index 508d9a746..d959ed3b9 100644
--- a/qt-ui/starwidget.cpp
+++ b/qt-ui/starwidget.cpp
@@ -17,6 +17,25 @@ const QImage& StarWidget::starInactive()
return inactiveStar;
}
+QImage focusedImage(const QImage& coloredImg)
+{
+ QImage img = coloredImg;
+ for (int i = 0; i < img.width(); ++i) {
+ for (int j = 0; j < img.height(); ++j) {
+ QRgb rgb = img.pixel(i, j);
+ if (!rgb)
+ continue;
+
+ QColor c(rgb);
+ c = c.dark();
+ img.setPixel(i, j, c.rgb());
+ }
+ }
+
+ return img;
+}
+
+
int StarWidget::currentStars() const
{
return current;
@@ -44,13 +63,14 @@ void StarWidget::mouseReleaseEvent(QMouseEvent *event)
void StarWidget::paintEvent(QPaintEvent *event)
{
QPainter p(this);
- QPixmap active = QPixmap::fromImage(starActive());
+ QImage star = hasFocus() ? focusedImage(starActive()) : starActive();
+ QPixmap selected = QPixmap::fromImage(star);
QPixmap inactive = QPixmap::fromImage(starInactive());
-
const IconMetrics& metrics = defaultIconMetrics();
+
for (int i = 0; i < current; i++)
- p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, active);
+ p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, selected);
for (int i = current; i < TOTALSTARS; i++)
p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, inactive);
@@ -132,16 +152,13 @@ void StarWidget::focusOutEvent(QFocusEvent *event)
QWidget::focusOutEvent(event);
}
-
void StarWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Right) {
- if (currentStars() < TOTALSTARS) {
+ if (currentStars() < TOTALSTARS)
setCurrentStars(currentStars() + 1);
- }
} else if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Left) {
- if (currentStars() > 0) {
+ if (currentStars() > 0)
setCurrentStars(currentStars() - 1);
- }
}
}