Browse Source

Upload files to ''

master
DrewTechs 3 years ago
parent
commit
da55666e28
  1. 110
      addApplicationLauncher.cpp
  2. 41
      addApplicationLauncher.h
  3. 225
      addApplicationLauncher.ui
  4. 48
      applicationlaunchers.cpp
  5. 36
      applicationlaunchers.h

110
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();
}

41
addApplicationLauncher.h

@ -0,0 +1,41 @@
#ifndef ADDAPPLICATIONLAUNCHER_H
#define ADDAPPLICATIONLAUNCHER_H
#include <QDialog>
#include <QFileDialog>
#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

225
addApplicationLauncher.ui

@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddApplicationLauncher</class>
<widget class="QDialog" name="AddApplicationLauncher">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>687</width>
<height>401</height>
</rect>
</property>
<property name="windowTitle">
<string>Add New Application Launcher</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Application Name: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="applicationName_Field">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Application Location: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="applicationLocation_Field">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>298</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Select Application Location</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Application Extension:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>378</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QListWidget" name="applicationExtension_List"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="applicationExtension_Field">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addExtension_Button">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Add Extension</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeExtension_Button">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Remove Extension</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddApplicationLauncher</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddApplicationLauncher</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

48
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;
}

36
applicationlaunchers.h

@ -0,0 +1,36 @@
#ifndef APPLICATIONLAUNCHERS_H
#define APPLICATIONLAUNCHERS_H
#include <QObject>
#include <QWidget>
#include <QPushButton>
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
Loading…
Cancel
Save