LibrePCB Developers Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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) noexcept;
59 ~DesktopServices() noexcept;
60
61 // General Methods
62 bool openUrl(const QUrl& url) const noexcept;
63 bool openWebUrl(const QUrl& url) const noexcept;
64 bool openLocalPath(const FilePath& filePath) const noexcept;
65
66 // Static Methods
67 static void downloadAndOpenResourceAsync(const WorkspaceSettings& settings,
68 const QString& name,
69 const QString& mediaType,
70 const QUrl& url,
71 QPointer<QWidget> parent) noexcept;
72
73 // Operator Overloadings
74 DesktopServices& operator=(const DesktopServices& rhs) = delete;
75
76private: // Methods
77 bool openDirectory(const FilePath& filePath) const noexcept;
78 bool openLocalPathWithCommand(const FilePath& filePath,
79 const QStringList& commands) const noexcept;
80 bool openUrlFallback(const QUrl& url) const noexcept;
81 static void showWaitCursor() noexcept;
82
83private: // Data
85};
86
87/*******************************************************************************
88 * End of File
89 ******************************************************************************/
90
91} // namespace editor
92} // namespace librepcb
93
94#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
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:226
static void showWaitCursor() noexcept
Definition desktopservices.cpp:255
~DesktopServices() noexcept
Definition desktopservices.cpp:49
bool openLocalPath(const FilePath &filePath) const noexcept
Definition desktopservices.cpp:80
static void downloadAndOpenResourceAsync(const WorkspaceSettings &settings, const QString &name, const QString &mediaType, const QUrl &url, QPointer< QWidget > parent) noexcept
Definition desktopservices.cpp:93
bool openUrl(const QUrl &url) const noexcept
Definition desktopservices.cpp:56
const WorkspaceSettings & mSettings
Definition desktopservices.h:84
bool openLocalPathWithCommand(const FilePath &filePath, const QStringList &commands) const noexcept
Definition desktopservices.cpp:208
bool openWebUrl(const QUrl &url) const noexcept
Definition desktopservices.cpp:64
bool openDirectory(const FilePath &filePath) const noexcept
Definition desktopservices.cpp:203
DesktopServices(const DesktopServices &other)=delete
Definition occmodel.cpp:77