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 // Operator Overloadings
68 DesktopServices& operator=(const DesktopServices& rhs) = delete;
69
70private: // Methods
71 bool openDirectory(const FilePath& filePath) const noexcept;
72 bool openLocalPathWithCommand(const FilePath& filePath,
73 const QStringList& commands) const noexcept;
74 bool openUrlFallback(const QUrl& url) const noexcept;
75 static void showWaitCursor() noexcept;
76
77private: // Data
79 QPointer<QWidget> mParent;
80};
81
82/*******************************************************************************
83 * End of File
84 ******************************************************************************/
85
86} // namespace editor
87} // namespace librepcb
88
89#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:125
static void showWaitCursor() noexcept
Definition: desktopservices.cpp:154
~DesktopServices() noexcept
Definition: desktopservices.cpp:46
bool openLocalPath(const FilePath &filePath) const noexcept
Definition: desktopservices.cpp:81
bool openUrl(const QUrl &url) const noexcept
Definition: desktopservices.cpp:53
const WorkspaceSettings & mSettings
Definition: desktopservices.h:78
bool openLocalPathWithCommand(const FilePath &filePath, const QStringList &commands) const noexcept
Definition: desktopservices.cpp:103
bool openWebUrl(const QUrl &url) const noexcept
Definition: desktopservices.cpp:61
bool openDirectory(const FilePath &filePath) const noexcept
Definition: desktopservices.cpp:98
QPointer< QWidget > mParent
Definition: desktopservices.h:79
DesktopServices(const DesktopServices &other)=delete
Definition: occmodel.cpp:77