Skip to content

Commit 111c84a

Browse files
gruljagastoner
authored andcommitted
Remove unused code
1 parent 697a8b1 commit 111c84a

File tree

11 files changed

+60
-360
lines changed

11 files changed

+60
-360
lines changed

src/app/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ set(MEDIAWRITER_SRCS
1212
notifications.cpp
1313
portalfiledialog.cpp
1414
releasemanager.cpp
15-
units.cpp
1615
utilities.cpp
17-
versionchecker.cpp
1816
)
1917

2018
if (UNIX AND NOT APPLE)

src/app/downloadmanager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ void DownloadManager::cancel()
137137
}
138138
}
139139

140+
void DownloadManager::stopDownload()
141+
{
142+
if (m_current) {
143+
m_current->deleteLater();
144+
mDebug() << this->metaObject()->className() << "Stopping";
145+
}
146+
}
147+
140148
bool DownloadManager::isDownloaded(const QUrl &url) const
141149
{
142150
const QString filePath = QString("%1/%2").arg(DownloadManager::dir()).arg(url.fileName());

src/app/downloadmanager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class DownloadManager : public QObject, public DownloadReceiver
163163
QNetworkReply *tryAnotherMirror();
164164

165165
Q_INVOKABLE void cancel();
166+
Q_INVOKABLE void stopDownload();
166167
Q_INVOKABLE bool isDownloaded(const QUrl &url) const;
167168

168169
// DownloadReceiver interface

src/app/main.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,14 @@
1818
*/
1919

2020
#include <QApplication>
21-
#include <QDebug>
22-
#include <QElapsedTimer>
23-
#include <QLoggingCategory>
2421
#include <QQmlApplicationEngine>
2522
#include <QQmlContext>
26-
#include <QQuickStyle>
27-
#include <QScreen>
28-
#include <QStandardPaths>
2923
#include <QTranslator>
30-
#include <QtPlugin>
3124

3225
#include "crashhandler.h"
3326
#include "drivemanager.h"
3427
#include "portalfiledialog.h"
3528
#include "releasemanager.h"
36-
#include "units.h"
37-
#include "versionchecker.h"
3829

3930
int main(int argc, char **argv)
4031
{
@@ -59,7 +50,7 @@ int main(int argc, char **argv)
5950
mDebug() << "Application constructed";
6051

6152
QTranslator translator;
62-
if (translator.load(QLocale(QLocale().language(), QLocale().country()), QLatin1String(), QLatin1String(), ":/translations"))
53+
if (translator.load(QLocale(), QLatin1String(), QLatin1String(), ":/translations"))
6354
app.installTranslator(&translator);
6455

6556
QGuiApplication::setDesktopFileName("org.fedoraproject.MediaWriter.desktop");
@@ -72,13 +63,6 @@ int main(int argc, char **argv)
7263
engine.rootContext()->setContextProperty("portalFileDialog", new PortalFileDialog(&app));
7364
engine.rootContext()->setContextProperty("mediawriterVersion", MEDIAWRITER_VERSION);
7465
engine.rootContext()->setContextProperty("releases", new ReleaseManager());
75-
engine.rootContext()->setContextProperty("units", Units::instance());
76-
engine.rootContext()->setContextProperty("versionChecker", new VersionChecker());
77-
#if (defined(__linux) || defined(_WIN32))
78-
engine.rootContext()->setContextProperty("platformSupportsDelayedWriting", true);
79-
#else
80-
engine.rootContext()->setContextProperty("platformSupportsDelayedWriting", false);
81-
#endif
8266

8367
mDebug() << "Loading the QML source code";
8468

src/app/qml/DownloadPage.qml

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Page {
4242
qsTr("Preparing %1").arg(file)
4343
else if (currentStatus === Units.DownloadStatus.Ready)
4444
qsTr("Ready to write %1").arg(file)
45+
else if (currentStatus === Units.DownloadStatus.Stopped)
46+
qsTr("%1 has been stopped").arg(file)
4547
else if (currentStatus == Units.DownloadStatus.Failed_Download)
4648
qsTr("Failed to download %1").arg(file)
4749
else
@@ -78,12 +80,12 @@ Page {
7880
}
7981

8082
QQC2.Label {
81-
visible: currentStatus == Units.DownloadStatus.Downloading
83+
visible: currentStatus == Units.DownloadStatus.Downloading || currentStatus == Units.DownloadStatus.Stopped
8284
text: downloadPage.leftStr
8385
}
8486

8587
QQC2.Label {
86-
visible: currentStatus == Units.DownloadStatus.Downloading
88+
visible: currentStatus == Units.DownloadStatus.Downloading || currentStatus == Units.DownloadStatus.Stopped
8789
text: downloadPage.rightStr
8890
}
8991
}
@@ -135,6 +137,14 @@ Page {
135137
wrapMode: QQC2.Label.Wrap
136138
}
137139

140+
QQC2.Label {
141+
id: messageContinueDownload
142+
visible: currentStatus === Units.DownloadStatus.Stopped
143+
text: qsTr("Download has been stopped.")
144+
wrapMode: Label.Wrap
145+
width: mainColumn.width
146+
}
147+
138148
QQC2.Label {
139149
id: messageSelectedImage
140150
visible: releases.selected.isLocal
@@ -228,19 +238,37 @@ Page {
228238
releases.variant
229239
}
230240
}
241+
},
242+
State {
243+
name: "stopped"
244+
when: currentStatus === Units.DownloadStatus.Stopped
245+
PropertyChanges {
246+
target: progressBar;
247+
value: releases.variant.progress.ratio
248+
}
249+
PropertyChanges {
250+
target: messageContinueDownload;
251+
visible: true
252+
}
231253
}
232254
]
233255

234-
// There will be only [Finish] button on the right side so [Cancel] button
235-
// is not necessary
236256
previousButtonVisible: currentStatus != Units.DownloadStatus.Finished
237-
previousButtonText: qsTr("Cancel")
257+
previousButtonText: {
258+
if (releases.variant.status === Units.DownloadStatus.Downloading)
259+
return qsTr("Pause")
260+
else
261+
return qsTr("Cancel")
262+
}
238263
onPreviousButtonClicked: {
239264
if (releases.variant.status === Units.DownloadStatus.Write_Verifying ||
240265
releases.variant.status === Units.DownloadStatus.Writing ||
241-
releases.variant.status === Units.DownloadStatus.Downloading ||
266+
releases.variant.status === Units.DownloadStatus.Stopped ||
242267
releases.variant.status === Units.DownloadStatus.Download_Verifying) {
243268
cancelDialog.show()
269+
} else if (releases.variant.status === Units.DownloadStatus.Downloading) {
270+
downloadManager.stopDownload()
271+
releases.variant.setStatus(Units.DownloadStatus.Stopped)
244272
} else {
245273
releases.variant.resetStatus()
246274
downloadManager.cancel()
@@ -249,7 +277,9 @@ Page {
249277
}
250278

251279
nextButtonVisible: {
252-
if (currentStatus == Units.DownloadStatus.Finished)
280+
// This will be [Finish] or [Resume] button to finish download or resume download
281+
if (currentStatus == Units.DownloadStatus.Finished ||
282+
currentStatus == Units.DownloadStatus.Stopped)
253283
return true
254284
// This will be [Retry] button to start the process again if there is a drive plugged in
255285
else if (currentStatus == Units.DownloadStatus.Ready ||
@@ -260,14 +290,15 @@ Page {
260290
return false
261291
}
262292
nextButtonText: {
263-
264293
if (releases.variant.status === Units.DownloadStatus.Write_Verifying ||
265294
releases.variant.status === Units.DownloadStatus.Writing ||
266295
releases.variant.status === Units.DownloadStatus.Downloading ||
267296
releases.variant.status === Units.DownloadStatus.Download_Verifying)
268297
return qsTr("Cancel")
269298
else if (releases.variant.status == Units.DownloadStatus.Ready)
270299
return qsTr("Write")
300+
else if (releases.variant.status === Units.DownloadStatus.Stopped)
301+
return qsTr("Resume")
271302
else if (releases.variant.status === Units.DownloadStatus.Finished)
272303
return qsTr("Finish")
273304
else
@@ -288,6 +319,13 @@ Page {
288319
releases.variant.download()
289320
drives.selected.setImage(releases.variant)
290321
drives.selected.write(releases.variant)
322+
} else if (releases.variant.status === Units.DownloadStatus.Stopped) {
323+
if (selectedOption != Units.MainSelect.Write)
324+
releases.variant.download()
325+
if (drives.length) {
326+
drives.selected.setImage(releases.variant)
327+
drives.selected.write(releases.variant)
328+
}
291329
}
292330
}
293331
}

src/app/qml/Units.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ QtObject {
5858
Downloading,
5959
Download_Verifying,
6060
Ready,
61+
Stopped,
6162
Writing_Not_Possible,
6263
Writing,
6364
Write_Verifying,

src/app/releasemanager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,13 @@ class ReleaseVariant : public QObject, public DownloadReceiver
373373
public:
374374
enum Type { LIVE = 0, NETINSTALL, FULL, ATOMIC };
375375
Q_ENUMS(Type)
376-
enum Status { PREPARING = 0, DOWNLOADING, DOWNLOAD_VERIFYING, READY, WRITING_NOT_POSSIBLE, WRITING, WRITE_VERIFYING, FINISHED, FAILED_VERIFICATION, FAILED_DOWNLOAD, FAILED };
376+
enum Status { PREPARING = 0, DOWNLOADING, DOWNLOAD_VERIFYING, READY, STOPPED, WRITING_NOT_POSSIBLE, WRITING, WRITE_VERIFYING, FINISHED, FAILED_VERIFICATION, FAILED_DOWNLOAD, FAILED };
377377
Q_ENUMS(Status)
378378
const QStringList m_statusStrings{tr("Preparing"),
379379
tr("Downloading"),
380380
tr("Checking the download"),
381381
tr("Ready to write"),
382+
tr("Download has been stopped"),
382383
tr("Image file was saved to your downloads folder. Writing is not possible"),
383384
tr("Writing"),
384385
tr("Checking the written data"),
@@ -414,7 +415,6 @@ class ReleaseVariant : public QObject, public DownloadReceiver
414415

415416
Status status() const;
416417
QString statusString() const;
417-
void setStatus(Status s);
418418
QString errorString() const;
419419
void setErrorString(const QString &o);
420420

@@ -439,6 +439,7 @@ class ReleaseVariant : public QObject, public DownloadReceiver
439439
public slots:
440440
void download();
441441
void resetStatus();
442+
void setStatus(Status s);
442443

443444
private:
444445
QString m_temporaryIso{};

src/app/units.cpp

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

0 commit comments

Comments
 (0)