Merge lp:~jakuje/wallpaper-changer/qt4-compat into lp:wallpaper-changer

Proposed by Jakuje
Status: Needs review
Proposed branch: lp:~jakuje/wallpaper-changer/qt4-compat
Merge into: lp:wallpaper-changer
Diff against target: 290 lines (+91/-10)
6 files modified
src/gui/mainwindow.cpp (+11/-1)
src/gui/potd_viewer.cpp (+4/-0)
src/tools/glob.cpp (+30/-1)
src/tools/glob.h (+12/-0)
src/tools/nonguimanager.cpp (+25/-1)
src/tools/websitesnapshot.cpp (+9/-7)
To merge this branch: bzr merge lp:~jakuje/wallpaper-changer/qt4-compat
Reviewer Review Type Date Requested Status
Alex Solanos Approve
Review via email: mp+281295@code.launchpad.net

Commit message

QT4 compatible changes

To post a comment you must log in.
Revision history for this message
Alex Solanos (hakermania) :
review: Approve

Unmerged revisions

214. By Jakuje

QT4 compatibility
 * different header files with appropriate conditions
 * more portable constructs url -> toString

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gui/mainwindow.cpp'
2--- src/gui/mainwindow.cpp 2015-08-25 17:06:39 +0000
3+++ src/gui/mainwindow.cpp 2015-12-23 13:36:31 +0000
4@@ -21,7 +21,6 @@
5
6 #define QT_NO_KEYWORDS
7
8-#include <QtConcurrent/QtConcurrentRun>
9 #include <QMimeData>
10 #include <QDesktopServices>
11 #include <QRadioButton>
12@@ -32,6 +31,11 @@
13 #include <QStandardItem>
14 #include <QColorDialog>
15 #include <QShortcut>
16+#if QT_VERSION < 0x050000
17+# include <QtConcurrentRun>
18+#else
19+# include <QtConcurrent/QtConcurrentRun>
20+#endif
21
22 #ifdef Q_OS_WIN
23 #include <QtGui/private/qzipreader_p.h>
24@@ -322,7 +326,9 @@
25 void MainWindow::setupTimers(){
26 //Timer to updates progressbar and launch the changing process
27 updateSecondsTimer_ = new QTimer(this);
28+#if QT_VERSION >= 0x050000
29 updateSecondsTimer_->setTimerType(Qt::VeryCoarseTimer);
30+#endif
31 connect(updateSecondsTimer_, SIGNAL(timeout()), this, SLOT(updateSeconds()));
32
33 //Timer for folder monitoring
34@@ -4019,7 +4025,11 @@
35
36 currentlyUninstallingWallpaperClock_=true;
37
38+#if QT_VERSION < 0x050000
39+ if (!removeDir(gv.defaultWallpaperClock)) {
40+#else
41 if(!QDir(gv.defaultWallpaperClock).removeRecursively()){
42+#endif
43 globalParser_->error("Could not delete wallpaper clock, check folder's and subfolders' permissions.");
44 }
45
46
47=== modified file 'src/gui/potd_viewer.cpp'
48--- src/gui/potd_viewer.cpp 2015-08-23 16:51:21 +0000
49+++ src/gui/potd_viewer.cpp 2015-12-23 13:36:31 +0000
50@@ -23,7 +23,11 @@
51 #include "ui_potd_viewer.h"
52 #include "glob.h"
53
54+#if QT_VERSION < 0x050000
55+#include <QtGui>
56+#else
57 #include <QtWidgets>
58+#endif
59 #include <QtNetwork>
60
61 PotdViewer::PotdViewer(QWidget *parent) :
62
63=== modified file 'src/tools/glob.cpp'
64--- src/tools/glob.cpp 2015-08-25 14:34:01 +0000
65+++ src/tools/glob.cpp 2015-12-23 13:36:31 +0000
66@@ -28,12 +28,16 @@
67 #include <QSettings>
68 #include <QDirIterator>
69 #include <QPixmap>
70-#include <QtConcurrent/QtConcurrentRun>
71 #include <QPainter>
72 #include <QNetworkAccessManager>
73 #include <QEvent>
74 #include <QDesktopServices>
75 #include <QTextDocument>
76+#if QT_VERSION < 0x050000
77+# include <QtConcurrentRun>
78+#else
79+# include <QtConcurrent/QtConcurrentRun>
80+#endif
81
82 #include <iostream>
83 using namespace std;
84@@ -1260,3 +1264,28 @@
85 {
86
87 }
88+
89+#if QT_VERSION < 0x050000
90+bool removeDir(const QString & dirName)
91+{
92+ bool result = true;
93+ QDir dir(dirName);
94+
95+ if (dir.exists(dirName)) {
96+ Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
97+ if (info.isDir()) {
98+ result = removeDir(info.absoluteFilePath());
99+ }
100+ else {
101+ result = QFile::remove(info.absoluteFilePath());
102+ }
103+
104+ if (!result) {
105+ return result;
106+ }
107+ }
108+ result = dir.rmdir(dirName);
109+ }
110+ return result;
111+}
112+#endif
113
114=== modified file 'src/tools/glob.h'
115--- src/tools/glob.h 2015-08-24 17:15:53 +0000
116+++ src/tools/glob.h 2015-12-23 13:36:31 +0000
117@@ -33,7 +33,11 @@
118 #include <QRect>
119 #include <QProcess>
120 #include <QNetworkAccessManager>
121+#if QT_VERSION < 0x050000
122+#include <QDesktopServices>
123+#else
124 #include <QStandardPaths>
125+#endif
126 #include <QSettings>
127
128 #include "time.h"
129@@ -215,7 +219,11 @@
130 iconMode(true), rotateImages(false), potdIncludeDescription(true), leEnableTag(false), potdDescriptionBottom(true), wallpaperClocksHourImages(0), refreshhourinterval(0), websiteWaitAfterFinishSeconds(3),
131 websiteLoadImages(true), websiteJavaEnabled(false), websiteJavascriptCanReadClipboard(false), websiteJavascriptEnabled(true), websiteSimpleAuthEnabled(false),
132 websiteInterval(6), screenHeight(0), screenWidth(0), potdDescriptionLeftMargin(100), potdDescriptionRightMargin(0), potdDescriptionBottomTopMargin(0), appStartTime(QDateTime::currentDateTime()),
133+#if QT_VERSION < 0x050000
134+ websiteWebpageToLoad("http://google.com"), defaultPicturesLocation(homePath+"/"+QDesktopServices::displayName(QDesktopServices::PicturesLocation)), potdDescriptionFont("Ubuntu"),
135+#else
136 websiteWebpageToLoad("http://google.com"), defaultPicturesLocation(homePath+"/"+QStandardPaths::displayName(QStandardPaths::PicturesLocation)), potdDescriptionFont("Ubuntu"),
137+#endif
138 defaultIntervals(QList<int>() << 10 << 30 << 60 << 180 << 300 << 600 << 900 << 1200 << 1800 << 2700 << 3600 << 7200 << 10800 << 14400 << 21600 << 43200 << 86400)
139 {}
140 };
141@@ -296,4 +304,8 @@
142 Q_SIGNALS:
143 void updateNotification(QString message, QString image);
144 };
145+
146+#if QT_VERSION < 0x050000
147+bool removeDir(const QString & dirName);
148+#endif
149 #endif // GLOB_H
150
151=== modified file 'src/tools/nonguimanager.cpp'
152--- src/tools/nonguimanager.cpp 2015-08-25 14:34:01 +0000
153+++ src/tools/nonguimanager.cpp 2015-12-23 13:36:31 +0000
154@@ -21,8 +21,12 @@
155
156 #include "nonguimanager.h"
157
158-#include <QtConcurrent/QtConcurrentRun>
159 #include <QDesktopWidget>
160+#if QT_VERSION < 0x050000
161+# include <QtConcurrentRun>
162+#else
163+# include <QtConcurrent/QtConcurrentRun>
164+#endif
165
166 #include <iostream>
167 #include <getopt.h>
168@@ -748,7 +752,11 @@
169 connect(clientConnection, SIGNAL(disconnected()), clientConnection, SLOT(deleteLater()));
170
171 QDataStream in(clientConnection);
172+#if QT_VERSION < 0x050000
173+ in.setVersion(QDataStream::Qt_4_6);
174+#else
175 in.setVersion(QDataStream::Qt_5_2);
176+#endif
177 if (clientConnection->bytesAvailable() < (int)sizeof(quint16)) {
178 return;
179 }
180@@ -777,13 +785,21 @@
181 void NonGuiManager::socketConnected(){
182 QByteArray block;
183 QDataStream out(&block, QIODevice::WriteOnly);
184+#if QT_VERSION < 0x050000
185+ out.setVersion(QDataStream::Qt_4_6);
186+#else
187 out.setVersion(QDataStream::Qt_5_2);
188+#endif
189 out << messageToSendToServer_;
190 out.device()->seek(0);
191 socket_->write(block);
192 socket_->flush();
193 if(quitAfterMessagingMainApplication_){
194+#if QT_VERSION < 0x050000
195+ QTimer::singleShot(100, this, SLOT(quitNow()));
196+#else
197 QTimer::singleShot(100, Qt::CoarseTimer, this, SLOT(quitNow()));
198+#endif
199 }
200 }
201
202@@ -2135,7 +2151,11 @@
203 if(settings->value("first-run", true).toBool()){
204 settings->setValue("first-run", false);
205 #ifdef Q_OS_UNIX
206+#if QT_VERSION < 0x050000
207+ if (!removeDir(gv.homePath+"/.config/Wallch/")) {
208+#else
209 if(!QDir(gv.homePath+"/.config/Wallch/").removeRecursively()){
210+#endif
211 Global::error("I probably could not remove previous Wallch configurations!");
212 }
213
214@@ -2219,7 +2239,11 @@
215 settings->setValue("windows_major_version", QString::number(osvi.dwMajorVersion));
216 settings->setValue("windows_minor_version", QString::number(osvi.dwMinorVersion));
217
218+#if QT_VERSION < 0x050000
219+ if (!removeDir(QDesktopServices::writableLocation(QDesktopServices::GenericConfigLocation)+"/Mellori Studio/Wallch/")) {
220+#else
221 if(!QDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)+"/Mellori Studio/Wallch/").removeRecursively()){
222+#endif
223 Global::error("I probably could not remove previous Wallch configurations!");
224 }
225
226
227=== modified file 'src/tools/websitesnapshot.cpp'
228--- src/tools/websitesnapshot.cpp 2015-08-24 17:15:53 +0000
229+++ src/tools/websitesnapshot.cpp 2015-12-23 13:36:31 +0000
230@@ -58,15 +58,17 @@
231
232 authenticationLevel_=NoAuthentication;
233
234+#if QT_VERSION >= 0x050000
235 timeoutTimer_.setTimerType(Qt::VeryCoarseTimer);
236+ afterFinishTimer_.setTimerType(Qt::VeryCoarseTimer);
237+ priorComplexTimer_.setTimerType(Qt::VeryCoarseTimer);
238+#endif
239 timeoutTimer_.setSingleShot(true);
240 connect(&timeoutTimer_, SIGNAL(timeout()), this, SLOT(timeoutReached()));
241
242- afterFinishTimer_.setTimerType(Qt::VeryCoarseTimer);
243 afterFinishTimer_.setSingleShot(true);
244 connect(&afterFinishTimer_, SIGNAL(timeout()), this, SLOT(afterFinishTimedOut()));
245
246- priorComplexTimer_.setTimerType(Qt::VeryCoarseTimer);
247 priorComplexTimer_.setSingleShot(true);
248 connect(&priorComplexTimer_, SIGNAL(timeout()), this, SLOT(proceedToComplexAuth()));
249 }
250@@ -155,7 +157,7 @@
251 }
252
253 void WebsiteSnapshot::parseUrl(QUrl &url){
254- QString curUrl=url.url();
255+ QString curUrl=url.toString();
256 if(!curUrl.startsWith("http://") && !curUrl.startsWith("https://")){
257 curUrl="http://"+curUrl;
258 url=QUrl(curUrl);
259@@ -242,7 +244,7 @@
260 else
261 {
262 if(debug_)
263- dbg("The final url is "+urlAfterAuth_.url()+". This is the url that will be loaded after logging in.");
264+ dbg("The final url is "+urlAfterAuth_.toString()+". This is the url that will be loaded after logging in.");
265 //have to go to another page
266 connect(webPage_, SIGNAL(loadFinished(bool)), this, SLOT(afterAuthNavigation(bool)));
267 }
268@@ -361,7 +363,7 @@
269 break;
270 }
271 if(debug_)
272- dbg("Setting viewport size to QSize("+QString::number(minWidth_)+", "+QString::number(minHeight_)+"), and loading "+requestedUrl_.url());
273+ dbg("Setting viewport size to QSize("+QString::number(minWidth_)+", "+QString::number(minHeight_)+"), and loading "+requestedUrl_.toString());
274 webPage_->setViewportSize(QSize(minWidth_, minHeight_));
275 webPage_->setPreferredContentsSize(QSize(minWidth_, minHeight_));
276 webPage_->currentFrame()->load(requestedUrl_);
277@@ -481,11 +483,11 @@
278 switch(authenticationLevel_){
279 default:
280 case NoAuthentication:
281- return requestedUrl_.url();
282+ return requestedUrl_.toString();
283 break;
284 case SimpleAuthentication:
285 case ComplexAuthentication:
286- return urlAfterAuth_.url();
287+ return urlAfterAuth_.toString();
288 break;
289 }
290 }

Subscribers

People subscribed via source and target branches