mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Improved USBMS prompt
Still half-working but better
This commit is contained in:
parent
49e6a7167f
commit
ef34273f37
11 changed files with 281 additions and 85 deletions
|
@ -37,7 +37,11 @@ namespace global {
|
|||
}
|
||||
inline bool updateDialog;
|
||||
inline bool lowBatteryDialog;
|
||||
}
|
||||
namespace usbms {
|
||||
inline bool usbmsDialog;
|
||||
inline bool showUsbmsDialog;
|
||||
inline bool launchUsbms;
|
||||
}
|
||||
namespace settings {
|
||||
inline bool settingsRebootDialog;
|
||||
|
|
|
@ -86,6 +86,14 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
this->adjustSize();
|
||||
string_writeconfig("/inkbox/lowBatteryDialog", "false");
|
||||
}
|
||||
else if(global::usbms::usbmsDialog == true) {
|
||||
usbmsDialog = true;
|
||||
ui->okBtn->setText("Connect");
|
||||
ui->cancelBtn->setText("Cancel");
|
||||
ui->bodyLabel->setText("Do you want to connect your device to a computer to manage books?");
|
||||
ui->headerLabel->setText("USB cable connected");
|
||||
this->adjustSize();
|
||||
}
|
||||
else {
|
||||
// We shouldn't be there ;)
|
||||
;
|
||||
|
@ -112,6 +120,9 @@ void generalDialog::on_cancelBtn_clicked()
|
|||
string_writeconfig("/tmp/cancelUpdateDialog", "true");
|
||||
generalDialog::close();
|
||||
}
|
||||
if(usbmsDialog == true) {
|
||||
generalDialog::close();
|
||||
}
|
||||
}
|
||||
|
||||
void generalDialog::on_okBtn_clicked()
|
||||
|
@ -129,7 +140,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
proc->waitForFinished();
|
||||
}
|
||||
else {
|
||||
// Restore default settings, we're not running on InkBox OS
|
||||
// Restore default settings, we're not on InkBox OS
|
||||
QString prog ("sh");
|
||||
QStringList args;
|
||||
args << "reset-config.sh";
|
||||
|
@ -153,6 +164,15 @@ void generalDialog::on_okBtn_clicked()
|
|||
proc->start(prog, args);
|
||||
proc->waitForFinished();
|
||||
}
|
||||
if(usbmsDialog == true) {
|
||||
global::usbms::usbmsDialog = false;
|
||||
global::usbms::launchUsbms = true;
|
||||
|
||||
usbmsWindow = new usbms_splash();
|
||||
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
|
||||
usbmsWindow->show();
|
||||
}
|
||||
}
|
||||
void generalDialog::on_acceptBtn_clicked()
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include "usbms_splash.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Ui {
|
||||
|
@ -21,16 +23,16 @@ public:
|
|||
bool settingsRebootDialog = false;
|
||||
bool koboxSettingsRebootDialog = false;
|
||||
bool lowBatteryDialog = false;
|
||||
bool usbmsDialog = false;
|
||||
|
||||
private slots:
|
||||
void on_cancelBtn_clicked();
|
||||
|
||||
void on_okBtn_clicked();
|
||||
|
||||
void on_acceptBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::generalDialog *ui;
|
||||
usbms_splash *usbmsWindow;
|
||||
};
|
||||
|
||||
#endif // GENERALDIALOG_H
|
||||
|
|
|
@ -49,6 +49,9 @@ koboxAppsDialog::koboxAppsDialog(QWidget *parent) :
|
|||
QStringListModel* model = new QStringListModel(this);
|
||||
QStringList list = apps.split("\n", QString::SkipEmptyParts);
|
||||
|
||||
// Apps that aren't extensions
|
||||
list.prepend("Geany");
|
||||
|
||||
if(checkconfig("/external_root/opt/root/rooted") == true) {
|
||||
list.prepend("KTerm");
|
||||
}
|
||||
|
@ -87,7 +90,7 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
// DPI setting
|
||||
string_checkconfig(".config/00-kobox/dpiSetting");
|
||||
if(checkconfig_str_val == "") {
|
||||
dpiSetting = "150";
|
||||
dpiSetting = "125";
|
||||
}
|
||||
else {
|
||||
dpiSetting = checkconfig_str_val.toStdString();
|
||||
|
@ -106,6 +109,9 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
dpModeSetting = "fullscreen";
|
||||
dpiSetting = "175";
|
||||
}
|
||||
else if(itemText == "Geany") {
|
||||
string_writeconfig("/external_root/tmp/X_program", "geany");
|
||||
}
|
||||
else {
|
||||
QString itemTextLower = itemText.toLower();
|
||||
std::string app = itemTextLower.toStdString();
|
||||
|
|
|
@ -27,6 +27,16 @@ koboxSettings::koboxSettings(QWidget *parent) :
|
|||
else {
|
||||
ui->koboxStatusLabel->setText("KoBox is <b>disabled</b>");
|
||||
}
|
||||
|
||||
// DPI setting
|
||||
string_checkconfig(".config/00-kobox/dpiSetting");
|
||||
if(checkconfig_str_val == "") {
|
||||
;
|
||||
}
|
||||
else {
|
||||
int dpi_setting = checkconfig_str_val.toInt();
|
||||
ui->spinBox->setValue(dpi_setting);
|
||||
}
|
||||
}
|
||||
|
||||
koboxSettings::~koboxSettings()
|
||||
|
@ -63,3 +73,10 @@ void koboxSettings::openSettingsRebootDialog() {
|
|||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();
|
||||
}
|
||||
|
||||
void koboxSettings::on_spinBox_valueChanged(int arg1)
|
||||
{
|
||||
QString number = QString::number(arg1);
|
||||
string number_str = number.toStdString();
|
||||
string_writeconfig(".config/00-kobox/dpiSetting", number_str);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ private slots:
|
|||
void on_okBtn_clicked();
|
||||
void on_checkBox_toggled(bool checked);
|
||||
|
||||
void on_spinBox_valueChanged(int arg1);
|
||||
|
||||
private:
|
||||
Ui::koboxSettings *ui;
|
||||
generalDialog *generalDialogWindow;
|
||||
|
|
201
koboxsettings.ui
201
koboxsettings.ui
|
@ -16,6 +16,52 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="0">
|
||||
<widget class="QPushButton" name="okBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Inter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>
|
||||
OK
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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 settings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<widget class="QWidget" name="page">
|
||||
|
@ -34,6 +80,19 @@
|
|||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="koboxStatusLabel">
|
||||
<property name="text">
|
||||
|
@ -44,6 +103,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="frameShadow">
|
||||
|
@ -54,6 +126,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KoBox status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
|
@ -91,31 +176,55 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
<item row="7" column="0">
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KoBox status</string>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="8" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Applications scale (DPI)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="minimum">
|
||||
<number>25</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>250</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -124,59 +233,7 @@
|
|||
<widget class="QWidget" name="page_2"/>
|
||||
</widget>
|
||||
</item>
|
||||
<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 settings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QStackedWidget" name="settingsWidget">
|
||||
<widget class="QWidget" name="page_5"/>
|
||||
<widget class="QWidget" name="page_6"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QPushButton" name="okBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Inter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>
|
||||
OK
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
|
|
|
@ -55,6 +55,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
// Variables
|
||||
global::battery::showLowBatteryDialog = true;
|
||||
global::battery::showCriticalBatteryAlert = true;
|
||||
global::usbms::showUsbmsDialog = true;
|
||||
global::usbms::launchUsbms = false;
|
||||
global::mainwindow::tabSwitcher::repaint = true;
|
||||
|
||||
// Getting the screen's size
|
||||
|
@ -354,21 +356,28 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
QTimer *usbmsPrompt = new QTimer(this);
|
||||
usbmsPrompt->setInterval(2000);
|
||||
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
||||
if(global::mainwindow::usbmsDialog != true) {
|
||||
;
|
||||
}
|
||||
else {
|
||||
string_checkconfig_ro("/sys/devices/platform/fsl-usb2-udc/gadget/suspended");
|
||||
if(checkconfig_str_val != "0\n") {
|
||||
// Loop again...
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
if(global::usbms::showUsbmsDialog != true) {
|
||||
;
|
||||
}
|
||||
else {
|
||||
// An USB cable is connected!
|
||||
|
||||
string_checkconfig_ro("/sys/devices/platform/fsl-usb2-udc/gadget/suspended");
|
||||
if(checkconfig_str_val != "0\n") {
|
||||
// Loop again...
|
||||
;
|
||||
}
|
||||
else {
|
||||
// An USB cable is connected!
|
||||
openUsbmsDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Do nothing, we're running along with Nickel & friends...
|
||||
;
|
||||
}
|
||||
} );
|
||||
usbmsPrompt->start();
|
||||
|
||||
// We set the brightness level saved in the config file
|
||||
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||
|
@ -551,6 +560,16 @@ void MainWindow::openLowBatteryDialog() {
|
|||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void MainWindow::openUsbmsDialog() {
|
||||
global::usbms::showUsbmsDialog = false;
|
||||
global::usbms::usbmsDialog = true;
|
||||
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void MainWindow::openCriticalBatteryAlertWindow() {
|
||||
global::battery::showCriticalBatteryAlert = true;
|
||||
global::battery::showLowBatteryDialog = false;
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
|
||||
void openLowBatteryDialog();
|
||||
void openCriticalBatteryAlertWindow();
|
||||
void openUsbmsDialog();
|
||||
void resetWindow(bool resetStackedWidget);
|
||||
void resetIcons();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QPixmap>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
|
@ -48,6 +49,71 @@ usbms_splash::usbms_splash(QWidget *parent) :
|
|||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
ui->label_2->setPixmap(scaledPixmap);
|
||||
}
|
||||
|
||||
if(global::usbms::launchUsbms == true) {
|
||||
global::usbms::launchUsbms = false;
|
||||
usbms_launch();
|
||||
}
|
||||
}
|
||||
|
||||
void usbms_splash::usbms_launch()
|
||||
{
|
||||
QString umount_prog ("umount");
|
||||
QStringList umount_args;
|
||||
umount_args << "/dev/loop0";
|
||||
QProcess *umount_proc = new QProcess();
|
||||
umount_proc->start(umount_prog, umount_args);
|
||||
umount_proc->waitForFinished();
|
||||
|
||||
QString rmmod ("rmmod");
|
||||
QStringList rmmod_args;
|
||||
rmmod_args << "g_ether.ko";
|
||||
QProcess *rmmod_proc = new QProcess();
|
||||
rmmod_proc->start(rmmod, rmmod_args);
|
||||
rmmod_proc->waitForFinished();
|
||||
|
||||
QString prog ("insmod");
|
||||
QStringList args;
|
||||
args << "/external_root/modules/arcotg_udc.ko";
|
||||
QProcess *proc = new QProcess();
|
||||
proc->start(prog, args);
|
||||
proc->waitForFinished();
|
||||
|
||||
QString prog_1 ("insmod");
|
||||
QStringList args_1;
|
||||
args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/onboard" << "removable=y" << "stall=0";
|
||||
QProcess *proc_1 = new QProcess();
|
||||
proc_1->start(prog_1, args_1);
|
||||
proc_1->waitForFinished();
|
||||
|
||||
QTimer *usbms_t = new QTimer(this);
|
||||
usbms_t->setInterval(1000);
|
||||
connect(usbms_t, &QTimer::timeout, [&]() {
|
||||
QString prog ("mass_storage.sh");
|
||||
QStringList args;
|
||||
QProcess *proc = new QProcess();
|
||||
proc->start(prog, args);
|
||||
proc->waitForFinished();
|
||||
|
||||
QFile modules("/tmp/usbevent");
|
||||
modules.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&modules);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
modules.close();
|
||||
if(contentstr.find("1") != std::string::npos) {
|
||||
QString reboot_prog ("busybox");
|
||||
QStringList reboot_args;
|
||||
reboot_args << "reboot";
|
||||
QProcess *reboot_proc = new QProcess();
|
||||
reboot_proc->start(reboot_prog, reboot_args);
|
||||
reboot_proc->waitForFinished();
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
} );
|
||||
usbms_t->start();
|
||||
}
|
||||
|
||||
usbms_splash::~usbms_splash()
|
||||
|
|
|
@ -15,6 +15,8 @@ public:
|
|||
explicit usbms_splash(QWidget *parent = nullptr);
|
||||
~usbms_splash();
|
||||
|
||||
void usbms_launch();
|
||||
|
||||
private:
|
||||
Ui::usbms_splash *ui;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue