swift
downloadcomponent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_COMPONENTS_DOWNLOADCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_DOWNLOADCOMPONENT_H
8 
9 #include <QFileDialog>
10 #include <QFlags>
11 #include <QNetworkReply>
12 #include <QScopedPointer>
13 #include <QWizard>
14 
15 #include "gui/loadindicator.h"
17 #include "gui/swiftguiexport.h"
19 
20 namespace Ui
21 {
22  class CDownloadComponent;
23 }
24 namespace swift::gui::components
25 {
30  {
31  Q_OBJECT
32 
33  public:
35  enum ModeFlag
36  {
40  SwiftInstaller = StartAfterDownload | ShutdownSwift
41  };
42  Q_DECLARE_FLAGS(Mode, ModeFlag)
43 
44 
45  explicit CDownloadComponent(QWidget *parent = nullptr);
46 
48  virtual ~CDownloadComponent();
49 
51  bool setDownloadFile(const swift::misc::network::CRemoteFile &remoteFile);
52 
54  bool setDownloadFiles(const swift::misc::network::CRemoteFileList &remoteFiles);
55 
57  bool setDownloadDirectory(const QString &path);
58 
60  bool triggerDownloadingOfFiles(int delayMs = -1);
61 
63  bool isDownloading() const;
64 
66  bool haveAllDownloadsCompleted() const;
67 
69  Mode getMode() const;
70 
72  void setMode(Mode mode);
73 
75  void clear();
76 
78  void cancelOngoingDownloads();
79 
80  signals:
83 
84  private:
85  static constexpr std::chrono::milliseconds OverlayMsgTimeout { 5000 };
86  QScopedPointer<Ui::CDownloadComponent> ui;
87  const QFileDialog::Options m_fileDialogOptions { QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly |
88  QFileDialog::DontResolveSymlinks };
89  swift::misc::network::CRemoteFile m_fileInProgress;
91  swift::misc::network::CRemoteFileList m_waitingForDownload;
92  QNetworkReply *m_reply = nullptr;
93 
95  void selectDownloadDirectory();
96 
98  bool triggerDownloadingOfNextFile();
99 
101  bool triggerDownloadingOfFile(const swift::misc::network::CRemoteFile &remoteFile);
102 
104  void downloadedFile(const swift::misc::CStatusMessage &status);
105 
107  void lastFileDownloaded();
108 
110  void startDownloadedExecutable();
111 
113  bool existsDownloadDir() const;
114 
116  void openDownloadDir();
117 
119  void resetDownloadDir();
120 
122  void showStartedFileMessage(const swift::misc::network::CRemoteFile &rf);
123 
125  void showCompletedFileMessage(const swift::misc::network::CRemoteFile &rf);
126 
128  void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
129 
131  void showFileInfo();
132  };
133 } // namespace swift::gui::components
134 
135 Q_DECLARE_METATYPE(swift::gui::components::CDownloadComponent::Mode)
137 Q_DECLARE_OPERATORS_FOR_FLAGS(swift::gui::components::CDownloadComponent::Mode)
138 
139 #endif // SWIFT_GUI_COMPONENTS_DOWNLOADCOMPONENT_H
Enable widget class for load indicator.
Using this class provides a QFrame with the overlay functionality already integrated.
@ ShutdownSwift
for installers, stop swift before running
void allDownloadsCompleted()
All downloads have been completed.
Streamable status message, e.g.
Value object encapsulating a list of remote files.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.