Basic encryption setup working & hourglass animation

This commit is contained in:
Nicolas Mailloux 2021-10-09 11:07:10 -04:00
parent db3d40d950
commit b3da278096
11 changed files with 431 additions and 7 deletions

View file

@ -63,5 +63,8 @@
<file>resources/zoom-in.png</file> <file>resources/zoom-in.png</file>
<file>resources/zoom-out.png</file> <file>resources/zoom-out.png</file>
<file>resources/encryption.png</file> <file>resources/encryption.png</file>
<file>resources/check-display.png</file>
<file>resources/hourglass-bottom.png</file>
<file>resources/hourglass-top.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -5,6 +5,7 @@
#include <QScreen> #include <QScreen>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QTimer>
#include "functions.h" #include "functions.h"
encryptionManager::encryptionManager(QWidget *parent) : encryptionManager::encryptionManager(QWidget *parent) :
@ -21,18 +22,35 @@ encryptionManager::encryptionManager(QWidget *parent) :
ui->encryptionSetupLabel->setStyleSheet("font-size: 15pt"); ui->encryptionSetupLabel->setStyleSheet("font-size: 15pt");
ui->descriptionLabel->setStyleSheet("font-size: 9pt"); ui->descriptionLabel->setStyleSheet("font-size: 9pt");
ui->successLabel->setStyleSheet("font-size: 15pt");
ui->successDescriptionLabel->setStyleSheet("font-size: 9pt");
ui->setupContinueBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey"); ui->setupContinueBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->setupAbortBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey"); ui->setupAbortBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->exitSuccessBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
// Getting the screen's size // Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width(); float sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height(); float sH = QGuiApplication::screens()[0]->size().height();
float stdIconWidth = sW / 1.50; float stdIconWidth;
float stdIconHeight = sH / 1.50; float stdIconHeight;
{
stdIconWidth = sW / 1.50;
stdIconHeight = sH / 1.50;
QPixmap pixmap(":/resources/encryption.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->encryptionImageLabel->setPixmap(scaledPixmap);
}
{
stdIconWidth = sW / 1.65;
stdIconHeight = sH / 1.65;
QPixmap pixmap(":/resources/check-display.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->checkImageLabel->setPixmap(scaledPixmap);
}
QPixmap pixmap(":/resources/encryption.png"); hourglassAnimationWidgetWindow = new hourglassAnimationWidget();
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio); ui->hourglassWidget->insertWidget(0, hourglassAnimationWidgetWindow);
ui->encryptionImageLabel->setPixmap(scaledPixmap); ui->hourglassWidget->setCurrentIndex(0);
} }
encryptionManager::~encryptionManager() encryptionManager::~encryptionManager()
@ -42,7 +60,7 @@ encryptionManager::~encryptionManager()
void encryptionManager::on_setupContinueBtn_clicked() void encryptionManager::on_setupContinueBtn_clicked()
{ {
ui->activityWidget->hide(); ui->activityWidget->setCurrentIndex(3);
this->setStyleSheet("background-color: black"); this->setStyleSheet("background-color: black");
global::keyboard::keyboardDialog = true; global::keyboard::keyboardDialog = true;
global::keyboard::encfsDialog = true; global::keyboard::encfsDialog = true;
@ -74,6 +92,7 @@ void encryptionManager::refreshScreen() {
} }
void encryptionManager::showToast(QString messageToDisplay) { void encryptionManager::showToast(QString messageToDisplay) {
qDebug() << "showToast";
global::toast::message = messageToDisplay; global::toast::message = messageToDisplay;
toastWindow = new toast(this); toastWindow = new toast(this);
toastWindow->setAttribute(Qt::WA_DeleteOnClose); toastWindow->setAttribute(Qt::WA_DeleteOnClose);
@ -82,6 +101,8 @@ void encryptionManager::showToast(QString messageToDisplay) {
} }
void encryptionManager::setupEncryptedStorage() { void encryptionManager::setupEncryptedStorage() {
this->setStyleSheet("background-color: white");
ui->activityWidget->show();
mkEncfsDirs(); mkEncfsDirs();
std::string bootstrapPassphrase = global::encfs::passphrase.toStdString(); std::string bootstrapPassphrase = global::encfs::passphrase.toStdString();
global::encfs::passphrase = ""; global::encfs::passphrase = "";
@ -90,6 +111,18 @@ void encryptionManager::setupEncryptedStorage() {
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs"); string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase); string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
string_writeconfig("/opt/ibxd", "encfs_restart\n"); string_writeconfig("/opt/ibxd", "encfs_restart\n");
bool exitStatus;
ui->activityWidget->setCurrentIndex(3);
QTimer * t = new QTimer(this);
t->setInterval(1000);
connect(t, &QTimer::timeout, [&]() {
if(QFile::exists("/external_root/run/encrypted_storage_bootstrap_setup")) {
exitStatus = checkconfig("/external_root/run/encrypted_storage_bootstrap_setup");
QFile::remove("/external_root/run/encrypted_storage_bootstrap_setup");
setupExitWidget(exitStatus);
}
} );
t->start();
} }
void encryptionManager::mkEncfsDirs() { void encryptionManager::mkEncfsDirs() {
@ -102,3 +135,24 @@ void encryptionManager::mkEncfsDirs() {
QDir decDir; QDir decDir;
QString decPath("/mnt/onboard/onboard/encfs-decrypted"); QString decPath("/mnt/onboard/onboard/encfs-decrypted");
} }
void encryptionManager::on_exitSuccessBtn_clicked()
{
}
void encryptionManager::setupExitWidget(bool exitStatus) {
if(setupExitWidgetRan == false) {
if(exitStatus == true) {
ui->activityWidget->setCurrentIndex(1);
}
else {
string_writeconfig(".config/18-encrypted_storage/status", "false");
ui->activityWidget->setCurrentIndex(2);
}
setupExitWidgetRan = true;
}
else {
qDebug() << "setupExitWidgetRan";
}
}

View file

@ -4,6 +4,7 @@
#include <QWidget> #include <QWidget>
#include "generaldialog.h" #include "generaldialog.h"
#include "toast.h" #include "toast.h"
#include "hourglassanimationwidget.h"
namespace Ui { namespace Ui {
class encryptionManager; class encryptionManager;
@ -16,6 +17,7 @@ class encryptionManager : public QWidget
public: public:
explicit encryptionManager(QWidget *parent = nullptr); explicit encryptionManager(QWidget *parent = nullptr);
~encryptionManager(); ~encryptionManager();
bool setupExitWidgetRan = false;
private slots: private slots:
void on_setupContinueBtn_clicked(); void on_setupContinueBtn_clicked();
@ -25,11 +27,14 @@ private slots:
void showToast(QString messageToDisplay); void showToast(QString messageToDisplay);
void setupEncryptedStorage(); void setupEncryptedStorage();
void mkEncfsDirs(); void mkEncfsDirs();
void on_exitSuccessBtn_clicked();
void setupExitWidget(bool exitStatus);
private: private:
Ui::encryptionManager *ui; Ui::encryptionManager *ui;
generalDialog * generalDialogWindow; generalDialog * generalDialogWindow;
toast * toastWindow; toast * toastWindow;
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
}; };
#endif // ENCRYPTIONMANAGER_H #endif // ENCRYPTIONMANAGER_H

View file

@ -16,6 +16,9 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QStackedWidget" name="activityWidget"> <widget class="QStackedWidget" name="activityWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
@ -119,6 +122,9 @@ Would you like to enable it?</string>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
@ -151,7 +157,178 @@ Would you like to enable it?</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_2"/> <widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="successLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Storage encryption successfully setup</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_9">
<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">
<spacer name="verticalSpacer_8">
<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="7" column="0">
<widget class="QPushButton" name="exitSuccessBtn">
<property name="text">
<string>Continue</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_7">
<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="5" column="0">
<widget class="QLabel" name="successDescriptionLabel">
<property name="text">
<string>Please ensure you don't forget your passphrase, as it will be impossible to access your files without it.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_6">
<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="3" column="0">
<widget class="QLabel" name="checkImageLabel">
<property name="text">
<string>Check image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer_10">
<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 class="QWidget" name="page_3"/>
<widget class="QWidget" name="page_4">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QStackedWidget" name="hourglassWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>100</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="page_5">
<layout class="QVBoxLayout" name="verticalLayout_5"/>
</widget>
<widget class="QWidget" name="page_6"/>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_11">
<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">
<spacer name="verticalSpacer_12">
<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> </widget>
</item> </item>
</layout> </layout>

View file

@ -0,0 +1,53 @@
#include "hourglassanimationwidget.h"
#include "ui_hourglassanimationwidget.h"
#include <QScreen>
#include <QThread>
#include <QTimer>
#include <QDebug>
hourglassAnimationWidget::hourglassAnimationWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::hourglassAnimationWidget)
{
ui->setupUi(this);
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
float sH = QGuiApplication::screens()[0]->size().height();
float stdIconWidth;
float stdIconHeight;
{
stdIconWidth = sW / 1.60;
stdIconHeight = sH / 1.60;
QPixmap pixmap(":/resources/hourglass-top.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->hourglassTopLabel->setPixmap(scaledPixmap);
}
{
stdIconWidth = sW / 1.60;
stdIconHeight = sH / 1.60;
QPixmap pixmap(":/resources/hourglass-bottom.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->hourglassBottomLabel->setPixmap(scaledPixmap);
}
int i = 0;
QTimer * t = new QTimer();
t->setInterval(500);
connect(t, &QTimer::timeout, [&]() {
ui->stackedWidget->setCurrentIndex(i);
if(i == 0) {
i = 1;
}
else {
i = 0;
}
} );
t->start();
}
hourglassAnimationWidget::~hourglassAnimationWidget()
{
delete ui;
}

View file

@ -0,0 +1,22 @@
#ifndef HOURGLASSANIMATIONWIDGET_H
#define HOURGLASSANIMATIONWIDGET_H
#include <QWidget>
namespace Ui {
class hourglassAnimationWidget;
}
class hourglassAnimationWidget : public QWidget
{
Q_OBJECT
public:
explicit hourglassAnimationWidget(QWidget *parent = nullptr);
~hourglassAnimationWidget();
private:
Ui::hourglassAnimationWidget *ui;
};
#endif // HOURGLASSANIMATIONWIDGET_H

107
hourglassanimationwidget.ui Normal file
View file

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>hourglassAnimationWidget</class>
<widget class="QWidget" name="hourglassAnimationWidget">
<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">
<property name="topMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<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_2">
<item row="0" column="0">
<widget class="QLabel" name="hourglassTopLabel">
<property name="text">
<string>Hourglass TOP</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<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_3">
<item row="0" column="0">
<widget class="QLabel" name="hourglassBottomLabel">
<property name="text">
<string>Hourglass BOTTOM</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -18,6 +18,7 @@ SOURCES += \
dictionarywidget.cpp \ dictionarywidget.cpp \
encryptionmanager.cpp \ encryptionmanager.cpp \
generaldialog.cpp \ generaldialog.cpp \
hourglassanimationwidget.cpp \
koboxappsdialog.cpp \ koboxappsdialog.cpp \
koboxsettings.cpp \ koboxsettings.cpp \
main.cpp \ main.cpp \
@ -45,6 +46,7 @@ HEADERS += \
encryptionmanager.h \ encryptionmanager.h \
functions.h \ functions.h \
generaldialog.h \ generaldialog.h \
hourglassanimationwidget.h \
koboxappsdialog.h \ koboxappsdialog.h \
koboxsettings.h \ koboxsettings.h \
mainwindow.h \ mainwindow.h \
@ -70,6 +72,7 @@ FORMS += \
dictionarywidget.ui \ dictionarywidget.ui \
encryptionmanager.ui \ encryptionmanager.ui \
generaldialog.ui \ generaldialog.ui \
hourglassanimationwidget.ui \
koboxappsdialog.ui \ koboxappsdialog.ui \
koboxsettings.ui \ koboxsettings.ui \
mainwindow.ui \ mainwindow.ui \

BIN
resources/check-display.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
resources/hourglass-top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB