1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
diff --git a/minitube.pro b/minitube.pro
index 2308f10..853baff 100644
--- a/minitube.pro
+++ b/minitube.pro
@@ -120,7 +120,6 @@ HEADERS += src/video.h \
src/searchwidget.h \
src/channellistview.h \
src/httputils.h \
- src/appwidget.h \
src/clickablelabel.h \
src/ytvideo.h \
src/toolbarmenu.h \
@@ -196,7 +195,6 @@ SOURCES += src/main.cpp \
src/paginatedvideosource.cpp \
src/channellistview.cpp \
src/httputils.cpp \
- src/appwidget.cpp \
src/clickablelabel.cpp \
src/ytvideo.cpp \
src/toolbarmenu.cpp \
diff --git a/src/aboutview.cpp b/src/aboutview.cpp
index e60c173..70e2a50 100644
--- a/src/aboutview.cpp
+++ b/src/aboutview.cpp
@@ -30,7 +30,6 @@ $END_LICENSE */
#include "mac_startup.h"
#include "macutils.h"
#endif
-#include "appwidget.h"
#include "clickablelabel.h"
#include "fontutils.h"
#include "iconutils.h"
@@ -197,10 +196,6 @@ AboutView::AboutView(QWidget *parent) : View(parent) {
buttonLayout->addWidget(closeButton);
layout->addLayout(buttonLayout);
-
-#ifndef APP_WIN_STORE
- verticalLayout->addWidget(new AppsWidget());
-#endif
}
void AboutView::appear() {
diff --git a/src/appwidget.cpp b/src/appwidget.cpp
deleted file mode 100644
index c9c5181..0000000
--- a/src/appwidget.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "appwidget.h"
-#include "constants.h"
-#include "http.h"
-#ifdef APP_EXTRA
-#include "updatedialog.h"
-#endif
-
-AppsWidget::AppsWidget(QWidget *parent) : QWidget(parent) {
- const int padding = 30;
-
- QBoxLayout *layout = new QHBoxLayout(this);
- layout->setMargin(padding);
- layout->setSpacing(padding*2);
- layout->setAlignment(Qt::AlignCenter);
-
-#ifdef APP_MAC
- const QString ext = "dmg";
-#elif defined APP_WIN
- const QString ext = "exe";
-#else
- const QString ext = "deb";
-#endif
-
-#ifdef APP_MAC
- setupApp("Sofa", "sofa." + ext);
-#endif
- setupApp("Finetune", "finetune." + ext);
- setupApp("Musictube", "musictube." + ext);
- setupApp("Musique", "musique." + ext);
-}
-
-void AppsWidget::setupApp(const QString &name, const QString &code) {
- AppWidget *w = new AppWidget(name, code);
- layout()->addWidget(w);
-}
-
-void AppsWidget::paintEvent(QPaintEvent *e) {
- Q_UNUSED(e);
- QStyleOption o;
- o.initFrom(this);
- QPainter p(this);
- style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
-}
-
-AppWidget::AppWidget(const QString &name, const QString &code, QWidget *parent)
- : QWidget(parent), name(name), downloadButton(nullptr) {
- const QString unixName = code.left(code.lastIndexOf('.'));
- const QString baseUrl = QLatin1String("https://") + Constants::ORG_DOMAIN;
- const QString filesUrl = baseUrl + QLatin1String("/files/");
- url = filesUrl + unixName + QLatin1String("/") + code;
- webPage = baseUrl + QLatin1String("/") + unixName;
-
- QBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(0);
- layout->setAlignment(Qt::AlignHCenter);
-
- icon = new QLabel();
- icon->setMinimumHeight(128);
- layout->addWidget(icon);
- QString pixelRatioString;
- if (devicePixelRatioF() > 1.0)
- pixelRatioString = '@' + QString::number(devicePixelRatio()) + 'x';
- const QString iconUrl = filesUrl + QLatin1String("products/") + unixName + pixelRatioString +
- QLatin1String(".png");
- QObject *reply = Http::instance().get(iconUrl);
- connect(reply, SIGNAL(data(QByteArray)), SLOT(iconDownloaded(QByteArray)));
-
- QLabel *appTitle = new QLabel(name);
- appTitle->setAlignment(Qt::AlignHCenter);
- layout->addWidget(appTitle);
-
-#ifdef APP_EXTRA
-#if !defined(APP_UBUNTU) && !defined(APP_MAC_STORE)
- downloadButton = new QPushButton(tr("Download"));
- downloadButton->setAttribute(Qt::WA_MacSmallSize);
- downloadButton->setCursor(Qt::ArrowCursor);
- QSizePolicy sp = downloadButton->sizePolicy();
- sp.setHorizontalPolicy(QSizePolicy::Fixed);
- sp.setRetainSizeWhenHidden(true);
- downloadButton->setSizePolicy(sp);
- connect(downloadButton, SIGNAL(clicked(bool)), SLOT(downloadApp()));
- layout->addWidget(downloadButton, Qt::AlignHCenter);
- layout->setAlignment(downloadButton, Qt::AlignHCenter);
- downloadButton->hide();
-#endif
-#endif
-
- setCursor(Qt::PointingHandCursor);
-}
-
-void AppWidget::enterEvent(QEvent *e) {
- Q_UNUSED(e);
- if (downloadButton) downloadButton->show();
-}
-
-void AppWidget::leaveEvent(QEvent *e) {
- Q_UNUSED(e);
- if (downloadButton) downloadButton->hide();
-}
-
-void AppWidget::mouseReleaseEvent(QMouseEvent *e) {
- if (e->button() == Qt::LeftButton) {
- QDesktopServices::openUrl(webPage);
- }
-}
-
-void AppWidget::iconDownloaded(const QByteArray &bytes) {
- QPixmap pixmap;
- pixmap.loadFromData(bytes, "PNG");
- pixmap.setDevicePixelRatio(devicePixelRatioF());
- icon->setPixmap(pixmap);
-}
-
-void AppWidget::downloadApp() {
-#ifdef APP_EXTRA
- if (!icon) return;
- UpdateDialog *dialog = new UpdateDialog(icon->pixmap(), name, QString(), url, this);
- dialog->downloadUpdate();
- dialog->show();
-#endif
-}
diff --git a/src/appwidget.h b/src/appwidget.h
deleted file mode 100644
index a5ee272..0000000
--- a/src/appwidget.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef APPWIDGET_H
-#define APPWIDGET_H
-
-#include <QtWidgets>
-
-
-class AppWidget : public QWidget {
-
- Q_OBJECT
-
-public:
- AppWidget(const QString &name, const QString &code, QWidget *parent = 0);
- QLabel *icon;
-
-protected:
- void enterEvent(QEvent *e);
- void leaveEvent(QEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
-
-private slots:
- void iconDownloaded(const QByteArray &bytes);
- void downloadApp();
-
-private:
- QPushButton *downloadButton;
- QString name;
- QString url;
- QString webPage;
-};
-
-class AppsWidget : public QWidget {
-
- Q_OBJECT
-
-public:
- AppsWidget(QWidget *parent = 0);
-
-protected:
- void paintEvent(QPaintEvent *e);
-
-private:
- void setupApp(const QString &name, const QString &code);
-
-};
-
-#endif // APPWIDGET_H
|