Skip to content

Commit d6224df

Browse files
authored
add popup widget and controls quick view (openDsh#46)
* adding simple popup widget * apply overlay to modal as background * positioning dialog * close instead of reject * style when transparency not supported * update dark style * fix config file style * refactoring and cleanup * adding volume setting and brightness quick view (will refactor this later) * reset timeout when interacted with; show value for brightness and volume ; connect popups to buttons * ~update~ popup theme to scale; move values closer to buttons * hold volume button to mute * merge gst stuff in * only perform actions when slider is at final position
1 parent c552a13 commit d6224df

29 files changed

+610
-95
lines changed

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.5.1)
22
project(ia CXX)
3-
add_subdirectory(aasdk)
43

4+
add_subdirectory(aasdk)
55
set(AASDK_INCLUDE_DIRS ${aasdk_SOURCE_DIR}/include)
66
set(AASDK_LIBRARIES ${aasdk_SOURCE_DIR}/lib/libaasdk.so)
77
set(AASDK_PROTO_INCLUDE_DIRS ${aasdk_BINARY_DIR})
@@ -54,10 +54,11 @@ endif(RPI_BUILD AND NOT GST_BUILD)
5454
if(GST_BUILD)
5555
find_package(Qt5GStreamer)
5656
find_package(PkgConfig REQUIRED)
57-
pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4
58-
gstreamer-sdp-1.0>=1.4
59-
gstreamer-video-1.0>=1.4
60-
gstreamer-app-1.0>=1.4)
57+
pkg_check_modules(GST REQUIRED
58+
gstreamer-1.0>=1.4
59+
gstreamer-sdp-1.0>=1.4
60+
gstreamer-video-1.0>=1.4
61+
gstreamer-app-1.0>=1.4)
6162
add_definitions(-DUSE_GST)
6263
if(RPI_BUILD)
6364
add_definitions(-DRPI)

assets/icons/dark/dark_mode.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/icons/dark/refresh.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/icons/dark/save.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

assets/icons/dark/save_alt.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/icons/light/dark_mode.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/icons/light/refresh.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/icons/light/save.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

assets/icons/light/save_alt.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/resources.qrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<file>icons/dark/fast_forward.svg</file>
1919
<file>icons/dark/fast_rewind.svg</file>
2020
<file>icons/dark/volume_off.svg</file>
21-
<file>icons/dark/save.svg</file>
21+
<file>icons/dark/save_alt.svg</file>
2222
<file>icons/dark/bluetooth_searching.svg</file>
2323
<file>icons/dark/playlist_add_check.svg</file>
2424
<file>icons/dark/playlist_add.svg</file>
@@ -28,9 +28,11 @@
2828
<file>icons/dark/arrow_right.svg</file>
2929
<file>icons/dark/wifi.svg</file>
3030
<file>icons/dark/widgets.svg</file>
31+
<file>icons/dark/refresh.svg</file>
3132
<file>icons/dark/developer_board.svg</file>
3233
<file>icons/dark/keyboard.svg</file>
3334
<file>icons/dark/linked_camera.svg</file>
35+
<file>icons/dark/dark_mode.svg</file>
3436
<file>icons/light/play.svg</file>
3537
<file>icons/light/pause.svg</file>
3638
<file>icons/light/brightness_low.svg</file>
@@ -48,7 +50,7 @@
4850
<file>icons/light/fast_forward.svg</file>
4951
<file>icons/light/fast_rewind.svg</file>
5052
<file>icons/light/volume_off.svg</file>
51-
<file>icons/light/save.svg</file>
53+
<file>icons/light/save_alt.svg</file>
5254
<file>icons/light/bluetooth_searching.svg</file>
5355
<file>icons/light/playlist_add_check.svg</file>
5456
<file>icons/light/playlist_add.svg</file>
@@ -58,9 +60,11 @@
5860
<file>icons/light/arrow_right.svg</file>
5961
<file>icons/light/wifi.svg</file>
6062
<file>icons/light/widgets.svg</file>
63+
<file>icons/light/refresh.svg</file>
6164
<file>icons/light/developer_board.svg</file>
6265
<file>icons/light/keyboard.svg</file>
6366
<file>icons/light/linked_camera.svg</file>
67+
<file>icons/light/dark_mode.svg</file>
6468
<file>stylesheets/light.qss</file>
6569
<file>stylesheets/dark.qss</file>
6670
<file>fonts/Titillium_Web/TitilliumWeb-Regular.ttf</file>

assets/stylesheets/dark.qss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
QMainWindow,
12
QMainWindow > QFrame {
23
background-color: rgb(18, 18, 18);
34
border-radius: 8px;
@@ -239,6 +240,12 @@ Tuner::sub-page {
239240
background-color: rgb(224, 224, 224);
240241
}
241242

243+
QDialog,
244+
QDialog > QFrame {
245+
background-color: rgb(36, 36, 36);
246+
border-radius: 8px;
247+
}
248+
242249
*[add_hint="true"] {
243250
background-color: rgba(255, 255, 255, 8);
244251
}

assets/stylesheets/light.qss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
QMainWindow,
12
QMainWindow > QFrame {
23
background-color: rgb(238, 238, 238);
34
border-radius: 8px;
@@ -239,6 +240,12 @@ Tuner::sub-page {
239240
background-color: rgb(0, 0, 0);
240241
}
241242

243+
QDialog,
244+
QDialog > QFrame {
245+
background-color: rgb(252, 252, 252);
246+
border-radius: 8px;
247+
}
248+
242249
*[add_hint="true"] {
243250
background-color: rgba(0, 0, 0, 8);
244251
}

include/app/config.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ class Config : public QObject {
2121
void save();
2222

2323
inline int get_volume() { return this->volume; }
24-
inline void set_volume(int volume) { this->volume = volume; }
24+
inline void set_volume(int volume)
25+
{
26+
this->volume = volume;
27+
emit volume_changed(this->volume);
28+
}
2529

2630
inline bool get_dark_mode() { return this->dark_mode; }
2731
inline void set_dark_mode(bool dark_mode) { this->dark_mode = dark_mode; }
@@ -154,12 +158,14 @@ class Config : public QObject {
154158
QMap<QString, bool> pages;
155159

156160
signals:
161+
void volume_changed(int volume);
157162
void brightness_changed(unsigned int brightness);
158163
void si_units_changed(bool si_units);
159164
void quick_view_changed(QString quick_view);
160165
void controls_bar_changed(bool controls_bar);
161166
void scale_changed(double scale);
162167
void page_changed(QWidget *page, bool enabled);
168+
void save_status(bool status);
163169
};
164170

165171
#endif

include/app/tabs/settings.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class GeneralSettingsSubTab : public QWidget {
3737
QWidget *color_row_widget();
3838
QWidget *color_select_widget();
3939
QWidget *mouse_row_widget();
40+
QWidget *volume_row_widget();
41+
QWidget *volume_widget();
4042

4143
Config *config;
4244
Theme *theme;

include/app/theme.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ class Theme : public QObject {
2323
public:
2424
enum Orientation { BOTTOM, RIGHT };
2525

26+
static const QFont font_12;
2627
static const QFont font_14;
2728
static const QFont font_16;
2829
static const QFont font_18;
30+
static const QFont font_24;
2931
static const QFont font_36;
3032

3133
static const QSize icon_16;

include/app/widgets/dialog.hpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#ifndef DIALOG_HPP_
2+
#define DIALOG_HPP_
3+
4+
#include <QApplication>
5+
#include <QDialog>
6+
#include <QLabel>
7+
#include <QPainter>
8+
#include <QPushButton>
9+
#include <QTimer>
10+
#include <QVBoxLayout>
11+
12+
#include <app/theme.hpp>
13+
14+
class Overlay : public QWidget {
15+
Q_OBJECT
16+
17+
public:
18+
Overlay(QWidget *parent = nullptr) : QWidget(parent) { this->setAttribute(Qt::WA_NoSystemBackground, true); }
19+
20+
protected:
21+
inline void paintEvent(QPaintEvent *) { QPainter(this).fillRect(this->rect(), {0, 0, 0, 108}); }
22+
inline void mouseReleaseEvent(QMouseEvent *) { emit close(); }
23+
24+
signals:
25+
void close();
26+
};
27+
28+
class Dialog : public QDialog {
29+
Q_OBJECT
30+
31+
public:
32+
Dialog(bool fullscreen, QWidget *parent = nullptr);
33+
void open(int timeout = 0);
34+
35+
inline void set_title(QString str)
36+
{
37+
QLabel *label = new QLabel(str, this);
38+
label->setFont(QFont("Montserrat", 18, QFont::Bold));
39+
this->title->addWidget(label);
40+
qApp->processEvents();
41+
Theme::get_instance()->update();
42+
}
43+
inline void set_body(QWidget *widget)
44+
{
45+
this->body->addWidget(widget);
46+
qApp->processEvents();
47+
Theme::get_instance()->update();
48+
}
49+
inline void set_button(QPushButton *button)
50+
{
51+
if (!this->overlay_enabled && this->fullscreen) this->add_cancel_button();
52+
button->setFont(Theme::font_16);
53+
button->setFlat(true);
54+
this->buttons->addWidget(button, 0, Qt::AlignRight);
55+
qApp->processEvents();
56+
Theme::get_instance()->update();
57+
}
58+
59+
protected:
60+
void showEvent(QShowEvent *event);
61+
void keyPressEvent(QKeyEvent *event);
62+
bool eventFilter(QObject *object, QEvent *event);
63+
64+
private:
65+
QVBoxLayout *title;
66+
QVBoxLayout *body;
67+
QHBoxLayout *buttons;
68+
QTimer *timer;
69+
bool fullscreen;
70+
bool overlay_enabled = false;
71+
72+
QWidget *content_widget();
73+
void set_position();
74+
75+
inline void add_cancel_button()
76+
{
77+
QPushButton *button = new QPushButton("cancel", this);
78+
button->setFont(Theme::font_16);
79+
button->setFlat(true);
80+
connect(button, &QPushButton::clicked, [this]() { this->close(); });
81+
this->buttons->addWidget(button, 0, Qt::AlignRight);
82+
}
83+
};
84+
85+
#endif

include/app/widgets/progress.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ProgressIndicator : public QFrame {
1515

1616
public:
1717
ProgressIndicator(QWidget* parent = nullptr);
18+
QSize sizeHint();
1819

1920
inline int get_angle() { return this->angle; }
2021
inline void set_angle(int angle) { this->angle = angle; }
@@ -29,6 +30,7 @@ class ProgressIndicator : public QFrame {
2930
{
3031
this->pen_width = std::ceil(BASE_PEN_WIDTH * scale);
3132
this->ellipse_point = std::ceil(BASE_ELLIPSE_POINT * scale);
33+
this->setMinimumSize(this->sizeHint());
3234
}
3335

3436
public slots:

include/app/widgets/switch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Switch : public QAbstractButton {
3232
void paintEvent(QPaintEvent *event) override;
3333
void resizeEvent(QResizeEvent *event) override;
3434
void mouseReleaseEvent(QMouseEvent *event) override;
35+
void checkStateSet() override;
3536
void nextCheckState() override;
3637

3738
private:

include/app/window.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ class MainWindow : public QMainWindow {
3636
static void update_system_volume(int position);
3737
QWidget *window_widget();
3838
QTabWidget *tabs_widget();
39-
QWidget *controls_widget();
39+
QWidget *controls_bar_widget();
4040
QWidget *quick_view_widget();
41-
QWidget *volume_widget();
41+
QWidget *volume_widget(bool skip_buttons = false);
42+
QWidget *brightness_widget(bool skip_buttons = false);
43+
QWidget *controls_widget();
44+
QWidget *power_control_widget();
45+
QWidget *save_control_widget();
4246

4347
Config *config;
4448
Theme *theme;

src/app/config.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Config::Config()
4747

4848
void Config::save()
4949
{
50+
emit save_status(true);
51+
5052
if (this->volume != this->ia_config.value("volume", 50).toInt())
5153
this->ia_config.setValue("volume", this->volume);
5254
if (this->dark_mode != this->ia_config.value("dark_mode", false).toBool())
@@ -104,6 +106,9 @@ void Config::save()
104106

105107
this->openauto_config->setButtonCodes(this->openauto_button_codes);
106108
this->openauto_config->save();
109+
110+
this->ia_config.sync();
111+
emit save_status(false);
107112
}
108113

109114
Config *Config::get_instance()

src/app/tabs/media.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,24 @@ QWidget *LocalPlayerSubTab::seek_widget()
312312
QHBoxLayout *layout = new QHBoxLayout(widget);
313313

314314
QSlider *slider = new QSlider(Qt::Orientation::Horizontal, widget);
315+
slider->setTracking(false);
315316
slider->setRange(0, 0);
316-
QLabel *value = new QLabel(LocalPlayerSubTab::durationFmt(slider->sliderPosition()), widget);
317+
QLabel *value = new QLabel(LocalPlayerSubTab::durationFmt(slider->value()), widget);
317318
value->setFont(Theme::font_14);
318-
connect(slider, &QSlider::valueChanged,
319-
[value](int position) { value->setText(LocalPlayerSubTab::durationFmt(position)); });
320319
connect(slider, &QSlider::sliderReleased,
321-
[player = this->player, slider]() { player->setPosition(slider->value()); });
320+
[player = this->player, slider]() { player->setPosition(slider->sliderPosition()); });
321+
connect(slider, &QSlider::sliderMoved,
322+
[value](int position) { value->setText(LocalPlayerSubTab::durationFmt(position)); });
322323
connect(this->player, &QMediaPlayer::durationChanged, [slider](qint64 duration) {
323-
slider->setSliderPosition(0);
324+
slider->setValue(0);
324325
slider->setRange(0, duration);
325326
});
326-
connect(this->player, &QMediaPlayer::positionChanged,
327-
[slider](qint64 position) { slider->setSliderPosition(position); });
327+
connect(this->player, &QMediaPlayer::positionChanged, [slider, value](qint64 position) {
328+
if (!slider->isSliderDown()) {
329+
slider->setValue(position);
330+
value->setText(LocalPlayerSubTab::durationFmt(position));
331+
}
332+
});
328333

329334
layout->addStretch(4);
330335
layout->addWidget(slider, 28);

0 commit comments

Comments
 (0)