LibrePCB Developers Documentation
desktopservices.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_DESKTOPSERVICES_H
21#define LIBREPCB_EDITOR_DESKTOPSERVICES_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33class FilePath;
34class WorkspaceSettings;
35
36namespace editor {
37
38/*******************************************************************************
39 * Class DesktopServices
40 ******************************************************************************/
41
51class DesktopServices final {
52 Q_DECLARE_TR_FUNCTIONS(DesktopServices)
53
54public:
55 // Constructors / Destructor
56 DesktopServices() = delete;
57 DesktopServices(const DesktopServices& other) = delete;
58 explicit DesktopServices(const WorkspaceSettings& settings,
59 QWidget* parent) noexcept;
60 ~DesktopServices() noexcept;
61
62 // General Methods
63 bool openUrl(const QUrl& url) const noexcept;
64 bool openWebUrl(const QUrl& url) const noexcept;
65 bool openLocalPath(const FilePath& filePath) const noexcept;
66
67 // Static Methods
68 static void downloadAndOpenResourceAsync(const WorkspaceSettings& settings,
69 const QString& name,
70 const QString& mediaType,
71 const QUrl& url,
72 QPointer<QWidget> parent) noexcept;
73
74 // Operator Overloadings
75 DesktopServices& operator=(const DesktopServices& rhs) = delete;
76
77private: // Methods
78 bool openDirectory(const FilePath& filePath) const noexcept;
79 bool openLocalPathWithCommand(const FilePath& filePath,
80 const QStringList& commands) const noexcept;
81 bool openUrlFallback(const QUrl& url) const noexcept;
82 static void showWaitCursor() noexcept;
83
84private: // Data
86 QPointer<QWidget> mParent;
87};
88
89/*******************************************************************************
90 * End of File
91 ******************************************************************************/
92
93} // namespace editor
94} // namespace librepcb
95
96#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
Container for all workspace related settings.
Definition: workspacesettings.h:60
Provides methods to access common desktop services.
Definition: desktopservices.h:51
bool openUrlFallback(const QUrl &url) const noexcept
Definition: desktopservices.cpp:235
static void showWaitCursor() noexcept
Definition: desktopservices.cpp:264
~DesktopServices() noexcept
Definition: desktopservices.cpp:50
bool openLocalPath(const FilePath &filePath) const noexcept
Definition: desktopservices.cpp:85
static void downloadAndOpenResourceAsync(const WorkspaceSettings &settings, const QString &name, const QString &mediaType, const QUrl &url, QPointer< QWidget > parent) noexcept
Definition: desktopservices.cpp:98
bool openUrl(const QUrl &url) const noexcept
Definition: desktopservices.cpp:57
const WorkspaceSettings & mSettings
Definition: desktopservices.h:85
bool openLocalPathWithCommand(const FilePath &filePath, const QStringList &commands) const noexcept
Definition: desktopservices.cpp:213
bool openWebUrl(const QUrl &url) const noexcept
Definition: desktopservices.cpp:65
bool openDirectory(const FilePath &filePath) const noexcept
Definition: desktopservices.cpp:208
QPointer< QWidget > mParent
Definition: desktopservices.h:86
DesktopServices(const DesktopServices &other)=delete
Definition: occmodel.cpp:77