Filer
ApplicationBundle.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2022-23 Simon Peter <probono@puredarwin.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
32 #ifndef APPLICATIONBUNDLE_H
33 #define APPLICATIONBUNDLE_H
34 
35 #include <QString>
36 #include <QStringList>
37 #include <QIcon>
38 #include <QObject>
39 
53 class ApplicationBundle : public QObject {
54 Q_OBJECT
55 
56 public:
60  enum class Type {
61  Unknown,
62  AppBundle,
63  AppDir,
64  AppImage,
66  };
67 
72  ApplicationBundle(const QString& path);
73 
78  QString path() const;
79 
84  bool isValid() const;
85 
90  Type type() const;
91 
96  QIcon icon() const;
97 
102  QString iconName() const;
103 
108  QString name() const;
109 
114  QString executable() const;
115 
120  QStringList arguments() const;
121 
126  bool isCommandLineTool() const;
127 
132  QString typeName() const;
133 
139  bool launch(QStringList arguments) const;
140 
141 QString m_path;
142  bool m_isValid;
144  QString m_name;
145  QString m_icon;
146  QString m_executable;
147  QStringList m_arguments;
148  QIcon quadraticIcon(QIcon icon) const;
149 };
150 
151 #endif // APPLICATIONBUNDLE_H
152 
Represents an application bundle or executable in various formats.
Definition: ApplicationBundle.h:53
ApplicationBundle(const QString &path)
Constructs an ApplicationBundle object for the specified path.
Definition: ApplicationBundle.cpp:44
QStringList arguments() const
Retrieves the list of arguments passed to the executable.
Definition: ApplicationBundle.cpp:223
bool isValid() const
Checks if the application bundle is valid and exists.
Definition: ApplicationBundle.cpp:128
Type type() const
Returns the type of the application bundle.
Definition: ApplicationBundle.cpp:133
QString iconName() const
Retrieves the name of the icon file.
Definition: ApplicationBundle.cpp:206
QString m_path
Definition: ApplicationBundle.h:141
Type m_type
Definition: ApplicationBundle.h:143
QIcon icon() const
Retrieves the icon of the application bundle.
Definition: ApplicationBundle.cpp:138
bool isCommandLineTool() const
Checks if the application bundle is a command line tool.
Definition: ApplicationBundle.cpp:228
QString name() const
Retrieves the name of the application.
Definition: ApplicationBundle.cpp:213
QString path() const
Returns the path of the application bundle.
Definition: ApplicationBundle.cpp:123
bool launch(QStringList arguments) const
Launches the application.
Definition: ApplicationBundle.cpp:285
QStringList m_arguments
Definition: ApplicationBundle.h:147
QString m_icon
Definition: ApplicationBundle.h:145
bool m_isValid
Definition: ApplicationBundle.h:142
QString executable() const
Retrieves the path to the executable of the application.
Definition: ApplicationBundle.cpp:218
QString typeName() const
Gets the name of the type as a string.
Definition: ApplicationBundle.cpp:269
QString m_name
Definition: ApplicationBundle.h:144
Type
Enumerates the different types of application bundles.
Definition: ApplicationBundle.h:60
QString m_executable
Definition: ApplicationBundle.h:146
Definition: DesktopFile.h:50