From 5af7dbf07f75aafdd3416238bb5dfdee4ff1c229 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Thu, 13 May 2021 21:40:05 -0400 Subject: [PATCH] Manage KoBox extensions via USB --- functions.h | 1 + koboxsettings.cpp | 21 ++++++- koboxsettings.h | 4 +- koboxsettings.ui | 138 +++++++++++++++++++++++++++++++++------------- mainwindow.cpp | 3 +- usbms_splash.cpp | 16 +++++- 6 files changed, 139 insertions(+), 44 deletions(-) diff --git a/functions.h b/functions.h index de3e8c5..0a7c67c 100644 --- a/functions.h +++ b/functions.h @@ -42,6 +42,7 @@ namespace global { inline bool usbmsDialog; inline bool showUsbmsDialog; inline bool launchUsbms; + inline bool koboxExportExtensions; } namespace settings { inline bool settingsRebootDialog; diff --git a/koboxsettings.cpp b/koboxsettings.cpp index 6c9a914..92c1418 100644 --- a/koboxsettings.cpp +++ b/koboxsettings.cpp @@ -3,6 +3,7 @@ #include "functions.h" #include +#include koboxSettings::koboxSettings(QWidget *parent) : QWidget(parent), @@ -10,15 +11,16 @@ koboxSettings::koboxSettings(QWidget *parent) : { ui->setupUi(this); + // UI tweaks + ui->okBtn->setProperty("type", "borderless"); + ui->pushButton->setProperty("type", "borderless"); + // Stylesheet QFile stylesheetFile(":/resources/eink.qss"); stylesheetFile.open(QFile::ReadOnly); this->setStyleSheet(stylesheetFile.readAll()); stylesheetFile.close(); - // UI tweaks - ui->okBtn->setProperty("type", "borderless"); - if(checkconfig("/external_root/boot/flags/X11_START") == true) { ui->koboxStatusLabel->setText("KoBox is enabled"); not_user_change = true; @@ -80,3 +82,16 @@ void koboxSettings::on_spinBox_valueChanged(int arg1) string number_str = number.toStdString(); string_writeconfig(".config/00-kobox/dpiSetting", number_str); } + +void koboxSettings::on_pushButton_clicked() +{ + // Export Extensions disk image over USB with g_mass_storage + global::usbms::usbmsDialog = false; + global::usbms::launchUsbms = true; + global::usbms::koboxExportExtensions = true; + + usbmsWindow = new usbms_splash(); + usbmsWindow->setAttribute(Qt::WA_DeleteOnClose); + usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size())); + usbmsWindow->show(); +} diff --git a/koboxsettings.h b/koboxsettings.h index 8223fe2..f38f962 100644 --- a/koboxsettings.h +++ b/koboxsettings.h @@ -4,6 +4,7 @@ #include #include "generaldialog.h" +#include "usbms_splash.h" namespace Ui { class koboxSettings; @@ -23,12 +24,13 @@ public: private slots: void on_okBtn_clicked(); void on_checkBox_toggled(bool checked); - void on_spinBox_valueChanged(int arg1); + void on_pushButton_clicked(); private: Ui::koboxSettings *ui; generalDialog *generalDialogWindow; + usbms_splash *usbmsWindow; }; #endif // KOBOXSETTINGS_H diff --git a/koboxsettings.ui b/koboxsettings.ui index f06358f..8c6bedc 100644 --- a/koboxsettings.ui +++ b/koboxsettings.ui @@ -80,19 +80,6 @@ OK - - - - - Chivo - true - - - - Settings - - - @@ -103,19 +90,6 @@ OK - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -139,6 +113,45 @@ OK + + + + + Chivo + true + + + + Extensions + + + + + + + + Chivo + true + + + + Settings + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -176,17 +189,7 @@ OK - - - - QFrame::Plain - - - Qt::Horizontal - - - - + 0 @@ -229,6 +232,67 @@ OK + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + 0 + + + + + + Inter + 75 + true + + + + Go + + + + + + + Manage extensions over USB + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index aa4fe4c..7d478c1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -52,11 +52,12 @@ MainWindow::MainWindow(QWidget *parent) ui->quoteHeadingLabel->setStyleSheet("padding: 30px"); ui->homeBtn->setStyleSheet("padding: 5px"); - // Variables + // Initializing some variables global::battery::showLowBatteryDialog = true; global::battery::showCriticalBatteryAlert = true; global::usbms::showUsbmsDialog = true; global::usbms::launchUsbms = false; + global::usbms::koboxExportExtensions = false; global::mainwindow::tabSwitcher::repaint = true; // Getting the screen's size diff --git a/usbms_splash.cpp b/usbms_splash.cpp index 9bc4c94..b1c6436 100644 --- a/usbms_splash.cpp +++ b/usbms_splash.cpp @@ -60,7 +60,12 @@ void usbms_splash::usbms_launch() { QString umount_prog ("umount"); QStringList umount_args; - umount_args << "/dev/loop0"; + if(global::usbms::koboxExportExtensions == true) { + umount_args << "/dev/loop10"; + } + else { + umount_args << "/dev/loop0"; + } QProcess *umount_proc = new QProcess(); umount_proc->start(umount_prog, umount_args); umount_proc->waitForFinished(); @@ -81,7 +86,14 @@ void usbms_splash::usbms_launch() 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"; + + if(global::usbms::koboxExportExtensions == true) { + args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/extensions.img" << "removable=y" << "stall=0"; + } + else { + 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();