From 253d94a059fba2c7baf5ef0e074ed114c1a5ce4c Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Thu, 29 Apr 2021 23:36:25 -0400 Subject: [PATCH] KoBox launcher basic implementation I still need to fix some border bug --- apps.cpp | 10 +++ apps.h | 4 ++ apps.ui | 149 ++++++++++++++++++++++++-------------------- inkbox.pro | 3 + koboxappsdialog.cpp | 57 +++++++++++++++++ koboxappsdialog.h | 26 ++++++++ koboxappsdialog.ui | 83 ++++++++++++++++++++++++ main.cpp | 2 + mainwindow.cpp | 3 + mainwindow.h | 2 + savedwords.h | 1 - 11 files changed, 272 insertions(+), 68 deletions(-) create mode 100644 koboxappsdialog.cpp create mode 100644 koboxappsdialog.h create mode 100644 koboxappsdialog.ui diff --git a/apps.cpp b/apps.cpp index 8c1da73..b6afa93 100644 --- a/apps.cpp +++ b/apps.cpp @@ -1,5 +1,6 @@ #include "apps.h" #include "ui_apps.h" +#include "mainwindow.h" #include #include @@ -8,12 +9,14 @@ apps::apps(QWidget *parent) : ui(new Ui::apps) { ui->setupUi(this); + ui->koboxAppsOpenButton->setProperty("type", "borderless"); ui->scribbleLaunchBtn->setProperty("type", "borderless"); ui->lightmapsLaunchBtn->setProperty("type", "borderless"); ui->calendarLaunchBtn->setProperty("type", "borderless"); ui->savedWordsLaunchBtn->setProperty("type", "borderless"); ui->calculatorLaunchBtn->setProperty("type", "borderless"); + ui->koboxAppsOpenButton->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->scribbleLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->lightmapsLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->calendarLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); @@ -69,3 +72,10 @@ void apps::on_calculatorLaunchBtn_clicked() process.startDetached("calculator", QStringList()); qApp->quit(); } + +void apps::on_koboxAppsOpenButton_clicked() +{ + koboxAppsDialogWindow = new koboxAppsDialog(); + koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose); + koboxAppsDialogWindow->show(); +} diff --git a/apps.h b/apps.h index c271d39..c823aa4 100644 --- a/apps.h +++ b/apps.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Ui { class apps; @@ -25,10 +26,13 @@ private slots: void on_calendarLaunchBtn_clicked(); void on_calculatorLaunchBtn_clicked(); + void on_koboxAppsOpenButton_clicked(); + private: Ui::apps *ui; savedwords *savedWordsWindow; calendarApp *calendarWindow; + koboxAppsDialog *koboxAppsDialogWindow; }; #endif // APPS_H diff --git a/apps.ui b/apps.ui index 5c01a56..9dbe1e0 100644 --- a/apps.ui +++ b/apps.ui @@ -28,6 +28,13 @@ + + + + 0 + + + @@ -49,7 +56,32 @@ 0 - + + + + + Inter + false + + + + Launch + + + + + + + + Inter + + + + Launch + + + + @@ -62,7 +94,7 @@ - + 75 @@ -70,36 +102,11 @@ - Calendar + Light Maps - - - - - Inter - - - - Launch - - - - - - - - Inter - false - - - - Launch - - - - + @@ -113,19 +120,6 @@ - - - - 75 - true - - - - Light Maps - - - - @@ -138,8 +132,8 @@ - - + + Inter @@ -151,7 +145,7 @@ - + @@ -164,8 +158,8 @@ - - + + Inter @@ -176,16 +170,49 @@ + + + + + 75 + true + + + + Calendar + + + + + + + + 75 + true + + + + KoBox apps + + + + + + + + Inter + 50 + false + + + + Open + + + - - - - 0 - - - - + Qt::Vertical @@ -211,18 +238,6 @@ - - - - - - - - - - - - diff --git a/inkbox.pro b/inkbox.pro index e6e4acd..fafa4c8 100644 --- a/inkbox.pro +++ b/inkbox.pro @@ -16,6 +16,7 @@ SOURCES += \ brightnessdialog.cpp \ calendarapp.cpp \ generaldialog.cpp \ + koboxappsdialog.cpp \ koboxsettings.cpp \ main.cpp \ mainwindow.cpp \ @@ -33,6 +34,7 @@ HEADERS += \ calendarapp.h \ functions.h \ generaldialog.h \ + koboxappsdialog.h \ koboxsettings.h \ mainwindow.h \ quit.h \ @@ -48,6 +50,7 @@ FORMS += \ brightnessdialog.ui \ calendarapp.ui \ generaldialog.ui \ + koboxappsdialog.ui \ koboxsettings.ui \ mainwindow.ui \ quit.ui \ diff --git a/koboxappsdialog.cpp b/koboxappsdialog.cpp new file mode 100644 index 0000000..7bac914 --- /dev/null +++ b/koboxappsdialog.cpp @@ -0,0 +1,57 @@ +#include "koboxappsdialog.h" +#include "ui_koboxappsdialog.h" + +#include "functions.h" + +#include +#include + +koboxAppsDialog::koboxAppsDialog(QWidget *parent) : + QWidget(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 + + // Stylesheet, style & misc. + QFile stylesheetFile(":/resources/eink.qss"); + stylesheetFile.open(QFile::ReadOnly); + this->setStyleSheet(stylesheetFile.readAll()); + stylesheetFile.close(); + + ui->launchBtn->setProperty("type", "borderless"); + 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"); + + this->adjustSize(); + // Centering dialog + QRect screenGeometry = QGuiApplication::screens()[0]->geometry(); + int x = (screenGeometry.width() - this->width()) / 2; + int y = (screenGeometry.height() - this->height()) / 2; + this->move(x, y); + + checkApps(); + QStringListModel* model = new QStringListModel(this); + QStringList list = apps.split("\n", QString::SkipEmptyParts); + model->setStringList(list); + ui->appsList->setModel(model); + ui->appsList->setEditTriggers(QAbstractItemView::NoEditTriggers); +} + +void koboxAppsDialog::checkApps() { + QFile apps_list("/external_root/opt/X11/extensions/extensions_list"); + apps_list.open(QIODevice::ReadWrite); + QTextStream in (&apps_list); + apps = in.readAll(); + apps_list.close(); +} + +koboxAppsDialog::~koboxAppsDialog() +{ + delete ui; +} diff --git a/koboxappsdialog.h b/koboxappsdialog.h new file mode 100644 index 0000000..db62ddc --- /dev/null +++ b/koboxappsdialog.h @@ -0,0 +1,26 @@ +#ifndef KOBOXAPPSDIALOG_H +#define KOBOXAPPSDIALOG_H + +#include + +namespace Ui { +class koboxAppsDialog; +} + +class koboxAppsDialog : public QWidget +{ + Q_OBJECT + +public: + explicit koboxAppsDialog(QWidget *parent = nullptr); + ~koboxAppsDialog(); + + void checkApps(); + + QString apps; + +private: + Ui::koboxAppsDialog *ui; +}; + +#endif // KOBOXAPPSDIALOG_H diff --git a/koboxappsdialog.ui b/koboxappsdialog.ui new file mode 100644 index 0000000..eeaa2d2 --- /dev/null +++ b/koboxappsdialog.ui @@ -0,0 +1,83 @@ + + + koboxAppsDialog + + + Qt::NonModal + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + Inter + 75 + true + + + + KoBox apps launcher + + + Qt::AlignCenter + + + + + + + + + + 0 + + + + + + Inter + 75 + true + + + + Back + + + + + + + + Inter + 75 + true + + + + Launch + + + + + + + + + + + + diff --git a/main.cpp b/main.cpp index a5c9af4..e777457 100644 --- a/main.cpp +++ b/main.cpp @@ -2,9 +2,11 @@ InkBox: Open-source Qt-based eBook reader Copyright (C) 2021 Nicolas Mailloux SPDX-License-Identifier: GPL-3.0-only + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the diff --git a/mainwindow.cpp b/mainwindow.cpp index a409a86..98594f5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -600,6 +600,9 @@ void MainWindow::on_pushButton_clicked() void MainWindow::on_searchBtn_clicked() { // Hopefully this button will do something one day... + koboxAppsDialogWindow = new koboxAppsDialog(this); + koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose); + koboxAppsDialogWindow->show(); } void MainWindow::on_quitBtn_clicked() diff --git a/mainwindow.h b/mainwindow.h index 93ba49a..25fadb3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -12,6 +12,7 @@ #include "brightnessdialog.h" #include "generaldialog.h" #include "koboxsettings.h" +#include "koboxappsdialog.h" using namespace std; @@ -73,5 +74,6 @@ private: brightnessDialog *brightnessDialogWindow; generalDialog *generalDialogWindow; koboxSettings *koboxSettingsWindow; + koboxAppsDialog *koboxAppsDialogWindow; }; #endif // MAINWINDOW_H diff --git a/savedwords.h b/savedwords.h index beec26c..9345ebf 100644 --- a/savedwords.h +++ b/savedwords.h @@ -27,7 +27,6 @@ public: private slots: void on_backBtn_clicked(); - void on_clearBtn_clicked(); private: