mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Online library: Ask user if he wants to sync before doing so
This commit is contained in:
parent
b684f25fa9
commit
b411c40849
6 changed files with 86 additions and 19 deletions
|
@ -130,6 +130,7 @@ namespace global {
|
|||
inline QString bookTitle;
|
||||
inline bool librarySearchDialog;
|
||||
inline bool libraryResults;
|
||||
inline bool librarySyncDialog;
|
||||
}
|
||||
namespace bookInfoDialog {
|
||||
inline bool localInfoDialog;
|
||||
|
|
|
@ -949,6 +949,39 @@ void MainWindow::on_libraryButton_clicked()
|
|||
{
|
||||
log("Launching Online Library", className);
|
||||
if(testPing() == 0 or global::deviceID == "emu\n") {
|
||||
// 'Do you want to sync?' dialog
|
||||
bool willSync = false;
|
||||
QString syncEpochQStr = readFile("/external_root/opt/storage/gutenberg/last_sync");
|
||||
if(!syncEpochQStr.isEmpty()) {
|
||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||
unsigned long syncEpoch = syncEpochQStr.toULong();
|
||||
unsigned long allowSyncEpoch = syncEpoch + 86400;
|
||||
if(currentEpoch > allowSyncEpoch) {
|
||||
willSync = true;
|
||||
}
|
||||
}
|
||||
else if(syncEpochQStr.isEmpty()) {
|
||||
willSync = true;
|
||||
}
|
||||
|
||||
if(willSync == true) {
|
||||
global::library::librarySyncDialog = true;
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
QObject::connect(generalDialogWindow, &generalDialog::syncOnlineLibrary, this, &MainWindow::launchOnlineLibrary);
|
||||
QObject::connect(generalDialogWindow, &generalDialog::noSyncOnlineLibrary, this, &MainWindow::on_homeBtn_clicked);
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();
|
||||
}
|
||||
else {
|
||||
launchOnlineLibrary();
|
||||
}
|
||||
}
|
||||
else {
|
||||
showToast("Wi-Fi connection error");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::launchOnlineLibrary() {
|
||||
resetFullWindowException = true;
|
||||
resetWindow(false);
|
||||
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
|
||||
|
@ -970,10 +1003,6 @@ void MainWindow::on_libraryButton_clicked()
|
|||
this->repaint();
|
||||
}
|
||||
}
|
||||
else {
|
||||
showToast("Wi-Fi connection error");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::resetFullWindow() {
|
||||
if(resetFullWindowException == false) {
|
||||
|
|
|
@ -101,6 +101,7 @@ private slots:
|
|||
void resetFullWindow();
|
||||
void setupLocalLibraryWidget();
|
||||
void setupHomePageWidget();
|
||||
void launchOnlineLibrary();
|
||||
|
||||
private:
|
||||
Ui::MainWindow * ui;
|
||||
|
|
|
@ -62,6 +62,14 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
|||
ui->book6Btn->setText("");
|
||||
ui->book7Btn->setText("");
|
||||
ui->book8Btn->setText("");
|
||||
ui->book1Btn->setProperty("type", "borderless");
|
||||
ui->book2Btn->setProperty("type", "borderless");
|
||||
ui->book3Btn->setProperty("type", "borderless");
|
||||
ui->book4Btn->setProperty("type", "borderless");
|
||||
ui->book5Btn->setProperty("type", "borderless");
|
||||
ui->book6Btn->setProperty("type", "borderless");
|
||||
ui->book7Btn->setProperty("type", "borderless");
|
||||
ui->book8Btn->setProperty("type", "borderless");
|
||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
||||
ui->book9Btn->setText("");
|
||||
ui->book10Btn->setText("");
|
||||
|
@ -71,6 +79,14 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
|||
ui->book14Btn->setText("");
|
||||
ui->book15Btn->setText("");
|
||||
ui->book16Btn->setText("");
|
||||
ui->book9Btn->setProperty("type", "borderless");
|
||||
ui->book10Btn->setProperty("type", "borderless");
|
||||
ui->book11Btn->setProperty("type", "borderless");
|
||||
ui->book12Btn->setProperty("type", "borderless");
|
||||
ui->book13Btn->setProperty("type", "borderless");
|
||||
ui->book14Btn->setProperty("type", "borderless");
|
||||
ui->book15Btn->setProperty("type", "borderless");
|
||||
ui->book16Btn->setProperty("type", "borderless");
|
||||
}
|
||||
else {
|
||||
ui->book9Btn->hide();
|
||||
|
|
|
@ -209,6 +209,14 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
yIncrease = 1.8;
|
||||
QTimer::singleShot(50, this, SLOT(increaseSize()));
|
||||
}
|
||||
else if(global::library::librarySyncDialog == true) {
|
||||
librarySyncDialog = true;
|
||||
ui->okBtn->setText("Continue");
|
||||
ui->cancelBtn->setText("Not now");
|
||||
ui->bodyLabel->setText("<font face='u001'>Online library requires syncing. Do you want to continue</font><font face='Inter'>?</font>");
|
||||
ui->headerLabel->setText("Sync required");
|
||||
QTimer::singleShot(50, this, SLOT(adjust_size()));
|
||||
}
|
||||
else {
|
||||
// We shouldn't be there ;)
|
||||
log("Launched without settings", className);
|
||||
|
@ -280,6 +288,10 @@ void generalDialog::on_cancelBtn_clicked()
|
|||
global::userApps::appCompatibilityText = "";
|
||||
global::userApps::appCompatibilityDialog = false;
|
||||
}
|
||||
else if(global::library::librarySyncDialog == true) {
|
||||
emit noSyncOnlineLibrary();
|
||||
global::library::librarySyncDialog = false;
|
||||
}
|
||||
generalDialog::close();
|
||||
}
|
||||
}
|
||||
|
@ -540,10 +552,15 @@ void generalDialog::on_okBtn_clicked()
|
|||
else if(global::userApps::appCompatibilityDialog == true) {
|
||||
global::userApps::launchApp = true;
|
||||
global::userApps::appCompatibilityText = "";
|
||||
global::userApps::appCompatibilityLastContinueStatus = true; // Not really necceserry, only if something fails horibly
|
||||
global::userApps::appCompatibilityLastContinueStatus = true; // Not really necessary, only needed if something fails horribly
|
||||
global::userApps::appCompatibilityDialog = false;
|
||||
generalDialog::close();
|
||||
}
|
||||
else if(global::library::librarySyncDialog == true) {
|
||||
emit syncOnlineLibrary();
|
||||
global::library::librarySyncDialog = false;
|
||||
generalDialog::close();
|
||||
}
|
||||
}
|
||||
void generalDialog::on_acceptBtn_clicked()
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
bool resetKoboxDialog = false;
|
||||
bool keyboardDialog = false;
|
||||
bool keypadDialog = false;
|
||||
bool librarySyncDialog = false;
|
||||
bool dictionaryResults = false;
|
||||
bool vncServerSet = false;
|
||||
bool vncPasswordSet = false;
|
||||
|
@ -90,6 +91,8 @@ signals:
|
|||
void openBookFile(QString book, bool relativePath);
|
||||
void cancelDisableStorageEncryption();
|
||||
void disableStorageEncryption();
|
||||
void syncOnlineLibrary();
|
||||
void noSyncOnlineLibrary();
|
||||
};
|
||||
|
||||
#endif // GENERALDIALOG_H
|
||||
|
|
Loading…
Reference in a new issue