From abf9cda602524e2927a6f4955d671324e077f116 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Fri, 30 Apr 2021 12:49:33 -0400 Subject: [PATCH] KoBox Apps dialog can scan through the extensions list --- apps.h | 1 + koboxappsdialog.cpp | 37 +++++++++++++++++++++++---- koboxappsdialog.h | 11 ++++++-- koboxappsdialog.ui | 61 +++++++++++++++++++++++++++------------------ 4 files changed, 79 insertions(+), 31 deletions(-) diff --git a/apps.h b/apps.h index c823aa4..4084f92 100644 --- a/apps.h +++ b/apps.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace Ui { class apps; diff --git a/koboxappsdialog.cpp b/koboxappsdialog.cpp index 7bac914..88f63df 100644 --- a/koboxappsdialog.cpp +++ b/koboxappsdialog.cpp @@ -5,17 +5,18 @@ #include #include +#include +#include +#include koboxAppsDialog::koboxAppsDialog(QWidget *parent) : - QWidget(parent), + QDialog(parent), ui(new Ui::koboxAppsDialog) { ui->setupUi(this); // Preventing outside interaction - // this->setModal(true); - // For some obscure reason, this returns a "no member named setModal in 'koboxAppsDialog' error" - // Instead, I set the modality via GUI in the "Forms" section of Qt Creator + this->setModal(true); // Stylesheet, style & misc. QFile stylesheetFile(":/resources/eink.qss"); @@ -27,6 +28,14 @@ koboxAppsDialog::koboxAppsDialog(QWidget *parent) : ui->cancelBtn->setProperty("type", "borderless"); ui->launchBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey"); ui->cancelBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey"); + ui->appsList->setStyleSheet("font-size: 9pt"); + ui->headerLabel->setStyleSheet("font-weight: bold"); + + // UI fonts + int id = QFontDatabase::addApplicationFont(":/resources/fonts/CrimsonPro-Regular.ttf"); + QString family = QFontDatabase::applicationFontFamilies(id).at(0); + QFont crimson(family); + ui->definitionLabel->setFont(QFont(crimson)); this->adjustSize(); // Centering dialog @@ -44,7 +53,7 @@ koboxAppsDialog::koboxAppsDialog(QWidget *parent) : } void koboxAppsDialog::checkApps() { - QFile apps_list("/external_root/opt/X11/extensions/extensions_list"); + QFile apps_list("/external_root/opt/X11/extensions_list"); apps_list.open(QIODevice::ReadWrite); QTextStream in (&apps_list); apps = in.readAll(); @@ -55,3 +64,21 @@ koboxAppsDialog::~koboxAppsDialog() { delete ui; } + +void koboxAppsDialog::on_cancelBtn_clicked() +{ + // Emergency TODO: Fix this giving a "free(): invalid next size(fast)..." error + koboxAppsDialog::close(); +} + +void koboxAppsDialog::on_launchBtn_clicked() +{ + index = ui->appsList->currentIndex(); + itemText = index.data(Qt::DisplayRole).toString(); + if(itemText == "") { + QMessageBox::critical(this, tr("Invalid argument"), tr("Please select an application.")); + } + else { + qDebug() << itemText; + } +} diff --git a/koboxappsdialog.h b/koboxappsdialog.h index db62ddc..37f6ebe 100644 --- a/koboxappsdialog.h +++ b/koboxappsdialog.h @@ -1,13 +1,14 @@ #ifndef KOBOXAPPSDIALOG_H #define KOBOXAPPSDIALOG_H -#include +#include +#include namespace Ui { class koboxAppsDialog; } -class koboxAppsDialog : public QWidget +class koboxAppsDialog : public QDialog { Q_OBJECT @@ -18,6 +19,12 @@ public: void checkApps(); QString apps; + QString itemText; + QModelIndex index; + +private slots: + void on_cancelBtn_clicked(); + void on_launchBtn_clicked(); private: Ui::koboxAppsDialog *ui; diff --git a/koboxappsdialog.ui b/koboxappsdialog.ui index eeaa2d2..9699ea6 100644 --- a/koboxappsdialog.ui +++ b/koboxappsdialog.ui @@ -1,7 +1,7 @@ koboxAppsDialog - + Qt::NonModal @@ -9,8 +9,8 @@ 0 0 - 400 - 300 + 468 + 361 @@ -19,27 +19,7 @@ - - - - - Inter - 75 - true - - - - KoBox apps launcher - - - Qt::AlignCenter - - - - - - - + 0 @@ -74,6 +54,39 @@ + + + + + + + + Inter + 75 + true + + + + KoBox apps launcher + + + Qt::AlignCenter + + + + + + + Please select an application and click on 'Launch' to start it. + + + Qt::AutoText + + + Qt::AlignCenter + + +