mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08:00
Finalized working tab switcher
Settings Chooser won't disappear anymore when invoked after Apps tab was opened.
This commit is contained in:
parent
6eefeed69f
commit
7e799d999a
8 changed files with 254 additions and 130 deletions
|
@ -28,7 +28,8 @@ namespace global {
|
|||
|
||||
inline bool appsWidgetCreated;
|
||||
inline bool appsWidgetSelected;
|
||||
inline bool settingsWidgetSelected;
|
||||
inline bool settingsChooserWidgetCreated;
|
||||
inline bool settingsChooserWidgetSelected;
|
||||
}
|
||||
inline bool updateDialog;
|
||||
inline bool lowBatteryDialog;
|
||||
|
|
|
@ -22,6 +22,7 @@ SOURCES += \
|
|||
reader.cpp \
|
||||
savedwords.cpp \
|
||||
settings.cpp \
|
||||
settingschooser.cpp \
|
||||
usbms_splash.cpp
|
||||
|
||||
HEADERS += \
|
||||
|
@ -36,6 +37,7 @@ HEADERS += \
|
|||
reader.h \
|
||||
savedwords.h \
|
||||
settings.h \
|
||||
settingschooser.h \
|
||||
usbms_splash.h
|
||||
|
||||
FORMS += \
|
||||
|
@ -49,6 +51,7 @@ FORMS += \
|
|||
reader.ui \
|
||||
savedwords.ui \
|
||||
settings.ui \
|
||||
settingschooser.ui \
|
||||
usbms_splash.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
|
|
|
@ -37,8 +37,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->pushButton->setProperty("type", "borderless");
|
||||
ui->brightnessBtn->setProperty("type", "borderless");
|
||||
ui->homeBtn->setProperty("type", "borderless");
|
||||
ui->inkboxSettingsBtn->setProperty("type", "borderless");
|
||||
ui->koboxSettingsBtn->setProperty("type", "borderless");
|
||||
|
||||
ui->settingsBtn->setText("");
|
||||
ui->appsBtn->setText("");
|
||||
|
@ -47,16 +45,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->searchBtn->setText("");
|
||||
ui->brightnessBtn->setText("");
|
||||
ui->homeBtn->setText("");
|
||||
ui->inkboxSettingsBtn->setText("\t\t\tInkBox settings");
|
||||
ui->koboxSettingsBtn->setText("\t\t\tKoBox settings");
|
||||
ui->quoteLabel->setText("");
|
||||
|
||||
ui->quotePictureLabel->setText("");
|
||||
|
||||
ui->quoteHeadingLabel->setStyleSheet("padding: 30px");
|
||||
ui->homeBtn->setStyleSheet("padding: 5px");
|
||||
ui->inkboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
||||
ui->koboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
||||
|
||||
// Variables
|
||||
global::battery::showLowBatteryDialog = true;
|
||||
|
@ -104,11 +98,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
|
||||
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
|
||||
|
||||
ui->inkboxSettingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
||||
ui->inkboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||
ui->koboxSettingsBtn->setIcon(QIcon(":/resources/X11.png"));
|
||||
ui->koboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||
|
||||
// Battery
|
||||
string_checkconfig_ro("/opt/inkbox_device");
|
||||
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
|
||||
|
@ -516,10 +505,10 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::openUpdateDialog() {
|
||||
global::mainwindow::updateDialog = true;
|
||||
// We write to a temporary file to show a "Reset" prompt
|
||||
// Write to a temporary file to show a "Reset" prompt
|
||||
string_writeconfig("/inkbox/updateDialog", "true");
|
||||
|
||||
// We show the dialog
|
||||
// Show the dialog
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();
|
||||
|
@ -549,13 +538,18 @@ void MainWindow::openCriticalBatteryAlertWindow() {
|
|||
void MainWindow::on_settingsBtn_clicked()
|
||||
{
|
||||
resetWindow(false);
|
||||
if(global::mainwindow::tabSwitcher::settingsWidgetSelected != true) {
|
||||
if(global::mainwindow::tabSwitcher::settingsChooserWidgetSelected != true) {
|
||||
ui->settingsBtn->setStyleSheet("background: black");
|
||||
ui->settingsBtn->setIcon(QIcon(":/resources/settings-inverted.png"));
|
||||
|
||||
// Create widget
|
||||
settingsChooserWindow = new settingsChooser();
|
||||
ui->stackedWidget->insertWidget(2, settingsChooserWindow);
|
||||
global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = true;
|
||||
|
||||
// Switch tab
|
||||
ui->stackedWidget->setCurrentIndex(2);
|
||||
global::mainwindow::tabSwitcher::settingsWidgetSelected = true;
|
||||
global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = true;
|
||||
|
||||
// Repaint
|
||||
this->repaint();
|
||||
|
@ -572,12 +566,10 @@ void MainWindow::on_appsBtn_clicked()
|
|||
ui->appsBtn->setStyleSheet("background: black");
|
||||
ui->appsBtn->setIcon(QIcon(":/resources/apps-inverted.png"));
|
||||
|
||||
// Create the widget only once
|
||||
if(global::mainwindow::tabSwitcher::appsWidgetCreated != true) {
|
||||
// Create widget
|
||||
appsWindow = new apps();
|
||||
ui->stackedWidget->insertWidget(1, appsWindow);
|
||||
global::mainwindow::tabSwitcher::appsWidgetCreated = true;
|
||||
}
|
||||
|
||||
// Switch tab
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
|
@ -600,11 +592,7 @@ void MainWindow::on_pushButton_clicked()
|
|||
|
||||
void MainWindow::on_searchBtn_clicked()
|
||||
{
|
||||
/*global::battery::showCriticalBatteryAlert = true;
|
||||
global::battery::showLowBatteryDialog = false;
|
||||
settingsWindow = new settings();
|
||||
ui->stackedWidget->insertWidget(2, settingsWindow);
|
||||
ui->stackedWidget->setCurrentIndex(2);*/
|
||||
// Hopefully this button will do something one day...
|
||||
}
|
||||
|
||||
void MainWindow::on_quitBtn_clicked()
|
||||
|
@ -672,8 +660,20 @@ void MainWindow::resetWindow(bool resetStackedWidget) {
|
|||
if(resetStackedWidget == true) {
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
// Destroy widgets
|
||||
if(global::mainwindow::tabSwitcher::appsWidgetCreated == true) {
|
||||
appsWindow->deleteLater();
|
||||
}
|
||||
if(global::mainwindow::tabSwitcher::settingsChooserWidgetCreated == true) {
|
||||
settingsChooserWindow->deleteLater();
|
||||
}
|
||||
|
||||
global::mainwindow::tabSwitcher::appsWidgetCreated = false;
|
||||
global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = false;
|
||||
global::mainwindow::tabSwitcher::appsWidgetSelected = false;
|
||||
global::mainwindow::tabSwitcher::settingsWidgetSelected = false;
|
||||
global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = false;
|
||||
|
||||
resetIcons();
|
||||
if(global::mainwindow::tabSwitcher::repaint == true) {
|
||||
this->repaint();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include "settings.h"
|
||||
#include "settingschooser.h"
|
||||
#include "apps.h"
|
||||
#include "reader.h"
|
||||
#include "quit.h"
|
||||
|
@ -62,7 +63,7 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
settings *settingsWindow;
|
||||
settingsChooser *settingsChooserWindow;
|
||||
apps *appsWindow;
|
||||
reader *readerWindow;
|
||||
quit *quitWindow;
|
||||
|
|
101
mainwindow.ui
101
mainwindow.ui
|
@ -400,107 +400,6 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line_9">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="koboxSettingsBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<weight>50</weight>
|
||||
<italic>true</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KoBox settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="inkboxSettingsBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>InkBox settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line_10">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="Line" name="line_11">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="settingsLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
59
settingschooser.cpp
Normal file
59
settingschooser.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "settingschooser.h"
|
||||
#include "ui_settingschooser.h"
|
||||
#include "functions.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QScreen>
|
||||
|
||||
settingsChooser::settingsChooser(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::settingsChooser)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Stylesheet
|
||||
QFile stylesheetFile(":/resources/eink.qss");
|
||||
stylesheetFile.open(QFile::ReadOnly);
|
||||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
stylesheetFile.close();
|
||||
|
||||
// Getting the screen's size
|
||||
sW = QGuiApplication::screens()[0]->size().width();
|
||||
sH = QGuiApplication::screens()[0]->size().height();
|
||||
|
||||
// Defining what the default icon size will be
|
||||
string_checkconfig("/opt/inkbox_device");
|
||||
if(checkconfig_str_val == "n705\n") {
|
||||
homeIconWidth = sW / 18;
|
||||
homeIconHeight = sW / 18;
|
||||
}
|
||||
else {
|
||||
homeIconWidth = sW / 20;
|
||||
homeIconHeight = sW / 20;
|
||||
}
|
||||
|
||||
ui->inkboxSettingsBtn->setProperty("type", "borderless");
|
||||
ui->koboxSettingsBtn->setProperty("type", "borderless");
|
||||
|
||||
ui->inkboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
||||
ui->koboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
||||
ui->inkboxSettingsBtn->setText("\t\t\tInkBox settings");
|
||||
ui->koboxSettingsBtn->setText("\t\t\tKoBox settings");
|
||||
|
||||
ui->inkboxSettingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
||||
ui->inkboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||
ui->koboxSettingsBtn->setIcon(QIcon(":/resources/X11.png"));
|
||||
ui->koboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||
}
|
||||
|
||||
settingsChooser::~settingsChooser()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void settingsChooser::on_inkboxSettingsBtn_clicked()
|
||||
{
|
||||
settingsWindow = new settings();
|
||||
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
settingsWindow->showFullScreen();
|
||||
}
|
33
settingschooser.h
Normal file
33
settingschooser.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef SETTINGSCHOOSER_H
|
||||
#define SETTINGSCHOOSER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
namespace Ui {
|
||||
class settingsChooser;
|
||||
}
|
||||
|
||||
class settingsChooser : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit settingsChooser(QWidget *parent = nullptr);
|
||||
~settingsChooser();
|
||||
|
||||
float sW;
|
||||
float sH;
|
||||
float homeIconWidth;
|
||||
float homeIconHeight;
|
||||
|
||||
private slots:
|
||||
void on_inkboxSettingsBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::settingsChooser *ui;
|
||||
settings *settingsWindow;
|
||||
};
|
||||
|
||||
#endif // SETTINGSCHOOSER_H
|
128
settingschooser.ui
Normal file
128
settingschooser.ui
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>settingsChooser</class>
|
||||
<widget class="QWidget" name="settingsChooser">
|
||||
<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">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" 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="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>Settings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="koboxSettingsBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KoBox settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="inkboxSettingsBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Chivo</family>
|
||||
<weight>50</weight>
|
||||
<italic>true</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>InkBox settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</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>3</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in a new issue