From da55666e28bedf97ffb9f9c4898b6fa0797dd19b Mon Sep 17 00:00:00 2001 From: DrewTechs Date: Sat, 12 Mar 2022 03:36:54 -0500 Subject: [PATCH] Upload files to '' --- addApplicationLauncher.cpp | 110 ++++++++++++++++++ addApplicationLauncher.h | 41 +++++++ addApplicationLauncher.ui | 225 +++++++++++++++++++++++++++++++++++++ applicationlaunchers.cpp | 48 ++++++++ applicationlaunchers.h | 36 ++++++ 5 files changed, 460 insertions(+) create mode 100644 addApplicationLauncher.cpp create mode 100644 addApplicationLauncher.h create mode 100644 addApplicationLauncher.ui create mode 100644 applicationlaunchers.cpp create mode 100644 applicationlaunchers.h diff --git a/addApplicationLauncher.cpp b/addApplicationLauncher.cpp new file mode 100644 index 0000000..c83f65c --- /dev/null +++ b/addApplicationLauncher.cpp @@ -0,0 +1,110 @@ +#include "addApplicationLauncher.h" +#include "ui_addApplicationLauncher.h" + +AddApplicationLauncher::AddApplicationLauncher(QWidget *parent) : + QDialog(parent), + ui(new Ui::AddApplicationLauncher) +{ + ApplicationLaunchers* launcher = new ApplicationLaunchers(); + setApplicationLauncher(launcher); + ui->setupUi(this); +} + +AddApplicationLauncher::AddApplicationLauncher(ApplicationLaunchers* launcher, QWidget *parent) : + QDialog(parent), + ui(new Ui::AddApplicationLauncher) +{ + setApplicationLauncher(launcher); + ui->setupUi(this); + init(); +} + +AddApplicationLauncher::~AddApplicationLauncher() +{ + delete ui; +} +void AddApplicationLauncher::init() +{ + ui->applicationName_Field->setText(applicationLauncher->getApplicationName()); + ui->applicationExtension_List->addItems(applicationLauncher->getApplicationExtensions()); + ui->applicationLocation_Field->setText(applicationLauncher->getApplicationLocation()); +} +void AddApplicationLauncher::appendApplicationExtension(QString applicationExtensionName) +{ + int idx = 0; + bool extensionExists = false; + for(idx = 0; idx < ui->applicationExtension_List->count(); idx++) + { + if(ui->applicationExtension_List->item(idx)->text() == applicationExtensionName) + { + extensionExists = true; + } + } + if(extensionExists == false) + { + ui->applicationExtension_List->addItem(applicationExtensionName); // If Extension is already on the list, duplicates are not allowed. + } + +} +void AddApplicationLauncher::removeApplicationExtension() +{ + int idx = ui->applicationExtension_List->currentIndex().row(); + if(idx >= 0) + { + delete ui->applicationExtension_List->item(idx); + } +} + + +/* Setter Functions */ +void AddApplicationLauncher::setApplicationLauncher(ApplicationLaunchers* newLauncher) +{ + applicationLauncher = newLauncher; +} +/* Getter Functions */ +ApplicationLaunchers* AddApplicationLauncher::getApplicationLauncher() +{ + return applicationLauncher; +} + + +void AddApplicationLauncher::on_selectApplicationLocation_clicked() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::ExistingFile); + dialog.setNameFilter(tr("Executable File")); + QString fileName = dialog.getOpenFileName(this, tr("Open File"), "/usr/bin/", tr("Executable")); // Open Dialog + ui->applicationLocation_Field->setText(fileName); +} +void AddApplicationLauncher::on_addExtension_Button_clicked() +{ + QString appExtensionName = ui->applicationExtension_Field->text(); + if(ui->applicationExtension_Field->text() != "") + { + appendApplicationExtension(appExtensionName); + } +} +void AddApplicationLauncher::on_removeExtension_Button_clicked() +{ + removeApplicationExtension(); +} + +void AddApplicationLauncher::on_buttonBox_accepted() +{ + applicationLauncher->setApplicationName(ui->applicationName_Field->text()); + QStringList appExtensionList; + int idx = 0; + for(idx = 0; idx < ui->applicationExtension_List->count(); idx++) + { + appExtensionList.append(ui->applicationExtension_List->item(idx)->text()); + } + applicationLauncher->setApplicationExtension(appExtensionList); + applicationLauncher->setApplicationLocation(ui->applicationLocation_Field->text()); + accept(); +} + +void AddApplicationLauncher::on_buttonBox_rejected() +{ + reject(); +} + diff --git a/addApplicationLauncher.h b/addApplicationLauncher.h new file mode 100644 index 0000000..3e05301 --- /dev/null +++ b/addApplicationLauncher.h @@ -0,0 +1,41 @@ +#ifndef ADDAPPLICATIONLAUNCHER_H +#define ADDAPPLICATIONLAUNCHER_H + +#include +#include +#include "applicationlaunchers.h" + +namespace Ui { +class AddApplicationLauncher; +} + +class AddApplicationLauncher : public QDialog +{ + Q_OBJECT + +public: + explicit AddApplicationLauncher(QWidget *parent = nullptr); + AddApplicationLauncher(ApplicationLaunchers* launcher, QWidget *parent = nullptr); + ~AddApplicationLauncher(); + ApplicationLaunchers* applicationLauncher; + + void init(); + void appendApplicationExtension(QString applicationExtensionName); + void removeApplicationExtension(); + /* Setter Functions */ + void setApplicationLauncher(ApplicationLaunchers* newLauncher); + /* Getter Functions */ + ApplicationLaunchers* getApplicationLauncher(); +private slots: + void on_selectApplicationLocation_clicked(); + void on_addExtension_Button_clicked(); + void on_removeExtension_Button_clicked(); + + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); + +private: + Ui::AddApplicationLauncher *ui; +}; + +#endif // ADDAPPLICATIONLAUNCHER_H diff --git a/addApplicationLauncher.ui b/addApplicationLauncher.ui new file mode 100644 index 0000000..9210f71 --- /dev/null +++ b/addApplicationLauncher.ui @@ -0,0 +1,225 @@ + + + AddApplicationLauncher + + + + 0 + 0 + 687 + 401 + + + + Add New Application Launcher + + + + + + + + + 12 + + + + Application Name: + + + + + + + + 12 + + + + + + + + + + + + + + + 12 + + + + Application Location: + + + + + + + + 12 + + + + + + + + + + + + Qt::Horizontal + + + + 298 + 20 + + + + + + + + + 12 + + + + Select Application Location + + + + + + + + + + + + + + 12 + + + + Application Extension: + + + + + + + Qt::Horizontal + + + + 378 + 20 + + + + + + + + + + + + + + + + + + 12 + + + + + + + + + 12 + + + + Add Extension + + + + + + + + 12 + + + + Remove Extension + + + + + + + + + + + + 12 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AddApplicationLauncher + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AddApplicationLauncher + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/applicationlaunchers.cpp b/applicationlaunchers.cpp new file mode 100644 index 0000000..e0aea45 --- /dev/null +++ b/applicationlaunchers.cpp @@ -0,0 +1,48 @@ +#include "applicationlaunchers.h" + +ApplicationLaunchers::ApplicationLaunchers() +{ + +} + + +void ApplicationLaunchers::appendApplicationExtension(QString appExtension) +{ + applicationExtensions.append(appExtension); +} +void ApplicationLaunchers::removeApplicationExtension(int idx) +{ + applicationExtensions.removeAt(idx); +} + +/* Setter Functions */ +void ApplicationLaunchers::setApplicationName(QString newApplicationName) +{ + applicationName = newApplicationName; +} +void ApplicationLaunchers::setApplicationExtension(QStringList newApplicationExtensions) +{ + applicationExtensions = newApplicationExtensions; +} +void ApplicationLaunchers::setApplicationLocation(QString newApplicationLocation) +{ + applicationLocation = newApplicationLocation; +} + +/* Getter Functions */ +QString ApplicationLaunchers::getApplicationName() +{ + return applicationName; +} +QStringList ApplicationLaunchers::getApplicationExtensions() +{ + return applicationExtensions; +} +QString ApplicationLaunchers::getSingleApplicationExtension(int idx) +{ + return applicationExtensions.at(idx); +} +QString ApplicationLaunchers::getApplicationLocation() +{ + return applicationLocation; +} diff --git a/applicationlaunchers.h b/applicationlaunchers.h new file mode 100644 index 0000000..17271e1 --- /dev/null +++ b/applicationlaunchers.h @@ -0,0 +1,36 @@ +#ifndef APPLICATIONLAUNCHERS_H +#define APPLICATIONLAUNCHERS_H + +#include +#include +#include + +class ApplicationLaunchers : QObject +{ + Q_OBJECT +public: + ApplicationLaunchers(); + + void launchApplication(QString fileLocation, QString appExtension); + + void appendApplicationExtension(QString appExtension); + void removeApplicationExtension(int idx); + + /* Setter Functions */ + void setApplicationName(QString newApplicationName); + void setApplicationExtension(QStringList newApplicationExtensions); + void setApplicationLocation(QString newApplicationLocation); + + /* Getter Functions */ + QString getApplicationName(); + QStringList getApplicationExtensions(); + QString getSingleApplicationExtension(int idx); + QString getApplicationLocation(); + +private: + QString applicationName; + QStringList applicationExtensions; + QString applicationLocation; +}; + +#endif // APPLICATIONLAUNCHERS_H