KoBox Apps dialog can scan through the extensions list

This commit is contained in:
Nicolas Mailloux 2021-04-30 12:49:33 -04:00
parent 253d94a059
commit abf9cda602
4 changed files with 79 additions and 31 deletions

1
apps.h
View file

@ -5,6 +5,7 @@
#include <savedwords.h>
#include <calendarapp.h>
#include <koboxappsdialog.h>
#include <generaldialog.h>
namespace Ui {
class apps;

View file

@ -5,17 +5,18 @@
#include <QStringListModel>
#include <QScreen>
#include <QDebug>
#include <QFontDatabase>
#include <QMessageBox>
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;
}
}

View file

@ -1,13 +1,14 @@
#ifndef KOBOXAPPSDIALOG_H
#define KOBOXAPPSDIALOG_H
#include <QWidget>
#include <QDialog>
#include <QModelIndex>
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;

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>koboxAppsDialog</class>
<widget class="QWidget" name="koboxAppsDialog">
<widget class="QDialog" name="koboxAppsDialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>468</width>
<height>361</height>
</rect>
</property>
<property name="windowTitle">
@ -19,27 +19,7 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>KoBox apps launcher</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QListView" name="appsList"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
@ -74,6 +54,39 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QListView" name="appsList"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="headerLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>KoBox apps launcher</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="definitionLabel">
<property name="text">
<string>Please select an application and click on 'Launch' to start it.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>