Tab switcher working

Rearranged layout, home button on the top left, time at top right. Apps
is no longer a window, but embedded into stackedWidget > Index page 1.
Possible to switch back and forth between main display and Apps widget.
This commit is contained in:
Nicolas Mailloux 2021-04-23 22:23:24 -04:00
parent 26434797e9
commit d1d03ae16e
9 changed files with 145 additions and 95 deletions

View file

@ -8,7 +8,6 @@ apps::apps(QWidget *parent) :
ui(new Ui::apps) ui(new Ui::apps)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->backBtn->setProperty("type", "borderless");
ui->scribbleLaunchBtn->setProperty("type", "borderless"); ui->scribbleLaunchBtn->setProperty("type", "borderless");
ui->lightmapsLaunchBtn->setProperty("type", "borderless"); ui->lightmapsLaunchBtn->setProperty("type", "borderless");
ui->calendarLaunchBtn->setProperty("type", "borderless"); ui->calendarLaunchBtn->setProperty("type", "borderless");
@ -25,7 +24,6 @@ apps::apps(QWidget *parent) :
stylesheetFile.open(QFile::ReadOnly); stylesheetFile.open(QFile::ReadOnly);
this->setStyleSheet(stylesheetFile.readAll()); this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close(); stylesheetFile.close();
QObject::connect(ui->backBtn, SIGNAL(clicked()), this, SLOT(exitSlot()));
} }
apps::~apps() apps::~apps()

42
apps.ui
View file

@ -7,13 +7,25 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>300</height> <height>321</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <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> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
@ -171,34 +183,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="1" column="0">
<widget class="QPushButton" name="backBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>
Back
</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">

View file

@ -38,5 +38,7 @@
<file>resources/minus.png</file> <file>resources/minus.png</file>
<file>resources/plus.png</file> <file>resources/plus.png</file>
<file>resources/battery_alert.png</file> <file>resources/battery_alert.png</file>
<file>resources/apps-inverted.png</file>
<file>resources/home.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -23,6 +23,10 @@ namespace global {
inline bool startBatteryWatchdog; inline bool startBatteryWatchdog;
} }
namespace mainwindow { namespace mainwindow {
namespace tabSwitcher {
inline bool appsWidgetCreated;
inline bool appsWidgetSelected;
}
inline bool updateDialog; inline bool updateDialog;
inline bool lowBatteryDialog; inline bool lowBatteryDialog;
} }

View file

@ -35,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->searchBtn->setProperty("type", "borderless"); ui->searchBtn->setProperty("type", "borderless");
ui->pushButton->setProperty("type", "borderless"); ui->pushButton->setProperty("type", "borderless");
ui->brightnessBtn->setProperty("type", "borderless"); ui->brightnessBtn->setProperty("type", "borderless");
ui->homeBtn->setProperty("type", "borderless");
ui->settingsBtn->setText(""); ui->settingsBtn->setText("");
ui->appsBtn->setText(""); ui->appsBtn->setText("");
@ -42,35 +43,35 @@ MainWindow::MainWindow(QWidget *parent)
ui->quitBtn->setText(""); ui->quitBtn->setText("");
ui->searchBtn->setText(""); ui->searchBtn->setText("");
ui->brightnessBtn->setText(""); ui->brightnessBtn->setText("");
ui->homeBtn->setText("");
ui->quoteHeadingLabel->setStyleSheet("padding: 50px"); ui->quoteHeadingLabel->setStyleSheet("padding: 30px");
// Variables // Variables
global::battery::showLowBatteryDialog = true; global::battery::showLowBatteryDialog = true;
global::battery::showCriticalBatteryAlert = true; global::battery::showCriticalBatteryAlert = true;
// Getting the screen's size // Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width(); sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height(); sH = QGuiApplication::screens()[0]->size().height();
// Defining what the default icon size will be // Defining what the default icon size will be
float stdIconWidth;
float stdIconHeight;
float brightnessIconWidth;
float brightnessIconHeight;
string_checkconfig("/opt/inkbox_device"); string_checkconfig("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n") { if(checkconfig_str_val == "n705\n") {
stdIconWidth = sW / 12; stdIconWidth = sW / 12;
stdIconHeight = sH / 12; stdIconHeight = sH / 12;
brightnessIconWidth = sW / 24; brightnessIconWidth = sW / 24;
brightnessIconHeight = sH / 24; brightnessIconHeight = sH / 24;
homeIconWidth = sW / 18;
homeIconHeight = sW / 18;
} }
else { else {
stdIconWidth = sW / 14; stdIconWidth = sW / 14;
stdIconHeight = sH / 14; stdIconHeight = sH / 14;
brightnessIconWidth = sW / 26; brightnessIconWidth = sW / 26;
brightnessIconHeight = sH / 26; brightnessIconHeight = sH / 26;
homeIconWidth = sW / 20;
homeIconHeight = sW / 20;
} }
// Setting icons up // Setting icons up
@ -85,6 +86,9 @@ MainWindow::MainWindow(QWidget *parent)
ui->quitBtn->setIcon(QIcon(":/resources/power.png")); ui->quitBtn->setIcon(QIcon(":/resources/power.png"));
ui->quitBtn->setIconSize(QSize(stdIconWidth, stdIconHeight)); ui->quitBtn->setIconSize(QSize(stdIconWidth, stdIconHeight));
ui->homeBtn->setIcon(QIcon(":/resources/home.png"));
ui->homeBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png")); ui->brightnessBtn->setIcon(QIcon(":/resources/frontlight.png"));
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight)); ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
@ -533,11 +537,19 @@ void MainWindow::on_settingsBtn_clicked()
void MainWindow::on_appsBtn_clicked() void MainWindow::on_appsBtn_clicked()
{ {
appsWindow = new apps(); ui->appsBtn->setStyleSheet("background: black");
//appsWindow->setAttribute(Qt::WA_DeleteOnClose); ui->appsBtn->setIcon(QIcon(":/resources/apps-inverted.png"));
//appsWindow->showFullScreen();
ui->stackedWidget->insertWidget(1, appsWindow); // Create the widget only once
if(global::mainwindow::tabSwitcher::appsWidgetCreated != true) {
appsWindow = new apps();
ui->stackedWidget->insertWidget(1, appsWindow);
global::mainwindow::tabSwitcher::appsWidgetCreated = true;
}
// Switch tab
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
global::mainwindow::tabSwitcher::appsWidgetSelected = true;
} }
void MainWindow::on_pushButton_clicked() void MainWindow::on_pushButton_clicked()
@ -611,3 +623,21 @@ void MainWindow::on_brightnessBtn_clicked()
brightnessDialogWindow->setAttribute(Qt::WA_DeleteOnClose); brightnessDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
brightnessDialogWindow->show(); brightnessDialogWindow->show();
} }
void MainWindow::on_homeBtn_clicked()
{
resetWindow();
}
void MainWindow::resetWindow() {
// Reset layout
ui->stackedWidget->setCurrentIndex(0);
resetIcons();
this->repaint();
}
void MainWindow::resetIcons() {
// Reset icons
ui->appsBtn->setStyleSheet("background: white");
ui->appsBtn->setIcon(QIcon(":/resources/apps.png"));
}

View file

@ -10,6 +10,7 @@
#include "usbms_splash.h" #include "usbms_splash.h"
#include "brightnessdialog.h" #include "brightnessdialog.h"
#include "generaldialog.h" #include "generaldialog.h"
using namespace std; using namespace std;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -23,6 +24,16 @@ class MainWindow : public QMainWindow
public: public:
MainWindow(QWidget *parent = nullptr); MainWindow(QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
float stdIconWidth;
float stdIconHeight;
float brightnessIconWidth;
float brightnessIconHeight;
float homeIconWidth;
float homeIconHeight;
float sW;
float sH;
bool existing_recent_books = false; bool existing_recent_books = false;
bool reboot_after_update = false; bool reboot_after_update = false;
int timerTime = 0; int timerTime = 0;
@ -30,6 +41,8 @@ public:
void openLowBatteryDialog(); void openLowBatteryDialog();
void openCriticalBatteryAlertWindow(); void openCriticalBatteryAlertWindow();
void resetWindow();
void resetIcons();
public slots: public slots:
@ -45,6 +58,7 @@ private slots:
void on_book4Btn_clicked(); void on_book4Btn_clicked();
void on_brightnessBtn_clicked(); void on_brightnessBtn_clicked();
void openUpdateDialog(); void openUpdateDialog();
void on_homeBtn_clicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>602</width>
<height>601</height> <height>601</height>
</rect> </rect>
</property> </property>
@ -17,6 +17,19 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="5">
<spacer name="horizontalSpacer_2">
<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="6"> <item row="0" column="6">
<widget class="QPushButton" name="brightnessBtn"> <widget class="QPushButton" name="brightnessBtn">
<property name="text"> <property name="text">
@ -24,6 +37,43 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="9">
<widget class="QLabel" name="batteryLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>batt</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_2">
<property name="text">
<string>―</string>
</property>
</widget>
</item>
<item row="0" column="11">
<widget class="QLabel" name="timeLabel">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QLabel" name="inkboxLabel"> <widget class="QLabel" name="inkboxLabel">
<property name="font"> <property name="font">
@ -39,19 +89,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="9">
<widget class="QLabel" name="batteryLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>batt</string>
</property>
</widget>
</item>
<item row="0" column="8"> <item row="0" column="8">
<widget class="QLabel" name="batteryIcon"> <widget class="QLabel" name="batteryIcon">
<property name="text"> <property name="text">
@ -66,23 +103,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="timeLabel">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@ -96,26 +116,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="4">
<widget class="QLabel" name="label_2">
<property name="text">
<string>―</string>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_2">
<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="7"> <item row="0" column="7">
<widget class="Line" name="line_7"> <widget class="Line" name="line_7">
<property name="frameShadow"> <property name="frameShadow">
@ -126,6 +126,23 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="10">
<widget class="Line" name="line_8">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="homeBtn">
<property name="text">
<string>Home</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -343,6 +360,7 @@
<widget class="QWidget" name="page_2"> <widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3"/> <layout class="QVBoxLayout" name="verticalLayout_3"/>
</widget> </widget>
<widget class="QWidget" name="page_3"/>
</widget> </widget>
</item> </item>
<item> <item>

BIN
resources/apps-inverted.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
resources/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB