NDEVR
API Documentation
ApplicationLauncherButton.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/Button.h>
4#include <NDEVR/BasicThread.h>
5#include <NDEVR/File.h>
6#include <NDEVR/Pointer.h>
7#include <NDEVR/LocalApplicationLauncher.h>
8namespace NDEVR
9{
14 class NDEVR_WIDGETS_API ApplicationLauncherButtonManager : public QObject
15 {
16 public:
31 ApplicationLauncherButtonManager(const File& application_file, const StringView& args = StringView());
43 ApplicationLauncherButtonManager(Button* button, const File& application_file, const StringView& args = StringView());
54 void setAppFinishedCallback(std::function<void()> callback);
59 void setAppLaunchCallback(std::function<void()> callback);
64 void setMakeChildProcess(bool is_child_process);
69 void setBackupIcon(const StringView& backup_icon);
74 void setOverrideIcon(const StringView& override_icon);
84 void setEnabled(bool enabled);
93 void launch();
102 void setEnvironment(const StringView& env);
107 void setArgs(const StringView& args);
112 void setIconToApp(Button* button);
117 void setNameToApp(Button* button);
127 void setupButton(Button* button);
128 private:
132 void execute();
137 void _setupButton(Button* button);
138 protected:
143 std::function<void()> m_callback_function;
144 std::function<void()> m_launch_function;
145#if NDEVR_SUPPORTS_THREADING
147#endif
148 bool m_is_enabled = true;
149 };
150}
void setAppLaunchCallback(std::function< void()> callback)
Sets a callback to be invoked when the application is launched.
void killProcess()
Kills the currently running application process.
void setOverrideIcon(const StringView &override_icon)
Sets an icon that overrides the application's default icon.
ApplicationLauncherButtonManager(Button *button, const File &application_file, const StringView &args=StringView())
Constructs an ApplicationLauncherButtonManager with a button, application file, and optional argument...
bool m_is_enabled
Whether launching the application is currently enabled.
Buffer< QPointer< Button > > m_buttons
All buttons associated with this launcher manager.
std::function< void()> m_launch_function
Callback invoked when the application launches.
ApplicationLauncherButtonManager()
Constructs an ApplicationLauncherButtonManager with no application or button set.
ApplicationLauncherButtonManager(Button *button)
Constructs an ApplicationLauncherButtonManager and associates it with the given button.
const DynamicPointer< LocalApplicationLauncher > & launcher() const
Returns the current application launcher.
ApplicationLauncherButtonManager(const DynamicPointer< LocalApplicationLauncher > &launcher)
Constructs an ApplicationLauncherButtonManager with the given application launcher.
void setupButton(Button *button)
Configures an existing button to launch the application and reflect its running state.
void setArgs(const StringView &args)
Sets the command-line arguments for the launched application.
DynamicPointer< LocalApplicationLauncher > m_launcher
The application launcher instance.
std::function< void()> m_callback_function
Callback invoked when the application finishes.
void setEnabled(bool enabled)
Enables or disables the ability to launch the application.
void setEnvironment(const StringView &env)
Sets the environment variables for the launched application.
ApplicationLauncherButtonManager(const File &application_file, const StringView &args=StringView())
Constructs an ApplicationLauncherButtonManager from an application file path and optional arguments.
void setAppFinishedCallback(std::function< void()> callback)
Sets a callback to be invoked when the launched application finishes execution.
ApplicationLauncherButtonManager(Button *button, const DynamicPointer< LocalApplicationLauncher > &launcher)
Constructs an ApplicationLauncherButtonManager with a button and an application launcher.
void launch()
Launches the application.
void setBackupIcon(const StringView &backup_icon)
Sets a backup icon to use when the application's own icon cannot be found.
String m_backup_icon
Fallback icon name used when the application icon is unavailable.
void setApplication(DynamicPointer< LocalApplicationLauncher > launcher)
Sets the application launcher to use.
void setNameToApp(Button *button)
Sets the given button's text to the application's name.
String m_override_icon
Icon name that overrides the application's default icon.
Button * createButton()
Creates a new Button configured to launch the application.
BasicThread * m_launch_thread
Thread used to monitor the launched application process.
void setIconToApp(Button *button)
Sets the given button's icon to the application's icon.
void setMakeChildProcess(bool is_child_process)
Sets whether the launched application should run as a child process.
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
The primary namespace for the NDEVR SDK.