feat: basic run applet
This commit is contained in:
commit
dd8798121d
8 changed files with 307 additions and 0 deletions
54
.gitignore
vendored
Normal file
54
.gitignore
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.qm
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
*_qmlcache.qrc
|
4
aero-applets.pro
Normal file
4
aero-applets.pro
Normal file
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
run-applet
|
23
run-applet/main.cpp
Normal file
23
run-applet/main.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "runapplet.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLocale>
|
||||
#include <QTranslator>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QTranslator translator;
|
||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||
for (const QString &locale : uiLanguages) {
|
||||
const QString baseName = "run-applet_" + QLocale(locale).name();
|
||||
if (translator.load(":/i18n/" + baseName)) {
|
||||
a.installTranslator(&translator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
RunApplet w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
29
run-applet/run-applet.pro
Normal file
29
run-applet/run-applet.pro
Normal file
|
@ -0,0 +1,29 @@
|
|||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
runapplet.cpp
|
||||
|
||||
HEADERS += \
|
||||
runapplet.h
|
||||
|
||||
FORMS += \
|
||||
runapplet.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
run-applet_en_US.ts
|
||||
CONFIG += lrelease
|
||||
CONFIG += embed_translations
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
3
run-applet/run-applet_en_US.ts
Normal file
3
run-applet/run-applet_en_US.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US"></TS>
|
50
run-applet/runapplet.cpp
Normal file
50
run-applet/runapplet.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include "runapplet.h"
|
||||
#include "ui_runapplet.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
|
||||
RunApplet::RunApplet(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::RunApplet)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->label->setPixmap(QIcon::fromTheme("system-run-symbolic").pixmap(42, 42));
|
||||
// https://forum.qt.io/post/291563
|
||||
ui->cancelBtn->setIcon(style()->standardIcon(QStyle::SP_DialogCancelButton));
|
||||
ui->okBtn->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton));
|
||||
ui->browseBtn->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
|
||||
|
||||
connect(ui->cancelBtn, &QPushButton::clicked, this, [&]() {
|
||||
qApp->quit();
|
||||
});
|
||||
|
||||
connect(ui->okBtn, &QPushButton::clicked, this, &RunApplet::runApp);
|
||||
}
|
||||
|
||||
void RunApplet::runApp() {
|
||||
QString command = ui->comboBox->currentText();
|
||||
QStringList args = command.split(" ");
|
||||
QProcess *process = new QProcess;
|
||||
process->setProgram(args[0]);
|
||||
args.remove(0);
|
||||
process->setArguments(args);
|
||||
bool status = process->startDetached();
|
||||
|
||||
if (status) {
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
// QString errorMessage = process->errorString();
|
||||
|
||||
QMessageBox messageBox;
|
||||
messageBox.critical(0, process->program(), QString(tr("Windows cannot find '%1'. Make sure you typed the name correctly, and then try again.")).arg(process->program()));
|
||||
messageBox.setFixedSize(500,200);
|
||||
}
|
||||
|
||||
RunApplet::~RunApplet()
|
||||
{
|
||||
delete ui;
|
||||
}
|
25
run-applet/runapplet.h
Normal file
25
run-applet/runapplet.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef RUNAPPLET_H
|
||||
#define RUNAPPLET_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class RunApplet;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class RunApplet : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RunApplet(QWidget *parent = nullptr);
|
||||
~RunApplet();
|
||||
|
||||
private:
|
||||
Ui::RunApplet *ui;
|
||||
|
||||
void runApp();
|
||||
};
|
||||
#endif // RUNAPPLET_H
|
119
run-applet/runapplet.ui
Normal file
119
run-applet/runapplet.ui
Normal file
|
@ -0,0 +1,119 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RunApplet</class>
|
||||
<widget class="QDialog" name="RunApplet">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>175</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>RunApplet</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>21</y>
|
||||
<width>38</width>
|
||||
<height>38</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>63</x>
|
||||
<y>21</y>
|
||||
<width>320</width>
|
||||
<height>42</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Type the name of a program, folder, document, or Internet resource, and Windows will open it for you.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>73</y>
|
||||
<width>49</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>63</x>
|
||||
<y>70</y>
|
||||
<width>322</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="browseBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>132</y>
|
||||
<width>88</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="cancelBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>204</x>
|
||||
<y>132</y>
|
||||
<width>88</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="okBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>109</x>
|
||||
<y>132</y>
|
||||
<width>88</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Add table
Reference in a new issue