KoBox launcher basic implementation

I still need to fix some border bug
This commit is contained in:
Nicolas Mailloux 2021-04-29 23:36:25 -04:00
parent b38a5bd9a0
commit 253d94a059
11 changed files with 272 additions and 68 deletions

View file

@ -1,5 +1,6 @@
#include "apps.h"
#include "ui_apps.h"
#include "mainwindow.h"
#include <QFile>
#include <QProcess>
@ -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();
}

4
apps.h
View file

@ -4,6 +4,7 @@
#include <QWidget>
#include <savedwords.h>
#include <calendarapp.h>
#include <koboxappsdialog.h>
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

149
apps.ui
View file

@ -28,6 +28,13 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
@ -49,7 +56,32 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="3" column="1">
<item row="1" column="1">
<widget class="QPushButton" name="scribbleLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="calculatorLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="savedWordsLaunchBtn">
<property name="font">
<font>
@ -62,7 +94,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="calendarLabel">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
@ -70,36 +102,11 @@
</font>
</property>
<property name="text">
<string>Calendar</string>
<string>Light Maps</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="calendarLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="lightmapsLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
@ -113,19 +120,6 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Light Maps</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="scribbleLabel">
<property name="font">
<font>
@ -138,8 +132,8 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="scribbleLaunchBtn">
<item row="2" column="1">
<widget class="QPushButton" name="lightmapsLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
@ -151,7 +145,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
@ -164,8 +158,8 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="calculatorLaunchBtn">
<item row="3" column="1">
<widget class="QPushButton" name="calendarLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
@ -176,16 +170,49 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="calendarLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Calendar</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>KoBox apps</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="koboxAppsOpenButton">
<property name="font">
<font>
<family>Inter</family>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item row="4" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -211,18 +238,6 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QStackedWidget" name="rootAppsWidget">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_4"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
</layout>
</item>
</layout>

View file

@ -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 \

57
koboxappsdialog.cpp Normal file
View file

@ -0,0 +1,57 @@
#include "koboxappsdialog.h"
#include "ui_koboxappsdialog.h"
#include "functions.h"
#include <QStringListModel>
#include <QScreen>
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;
}

26
koboxappsdialog.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef KOBOXAPPSDIALOG_H
#define KOBOXAPPSDIALOG_H
#include <QWidget>
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

83
koboxappsdialog.ui Normal file
View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>koboxAppsDialog</class>
<widget class="QWidget" name="koboxAppsDialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<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">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="cancelBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="launchBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -2,9 +2,11 @@
InkBox: Open-source Qt-based eBook reader
Copyright (C) 2021 Nicolas Mailloux <nicolecrivain@gmail.com>
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

View file

@ -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()

View file

@ -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

View file

@ -27,7 +27,6 @@ public:
private slots:
void on_backBtn_clicked();
void on_clearBtn_clicked();
private: