diff --git a/locallibrarywidget.cpp b/locallibrarywidget.cpp index 3e62251..879382f 100644 --- a/locallibrarywidget.cpp +++ b/locallibrarywidget.cpp @@ -49,23 +49,8 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) : sW = QGuiApplication::screens()[0]->size().width(); sH = QGuiApplication::screens()[0]->size().height(); - // Defining what the default icon size will be - if(global::deviceID == "n705\n") { - stdIconWidth = sW / 16; - stdIconHeight = sH / 16; - } - else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") { - stdIconWidth = sW / 18; - stdIconHeight = sH / 18; - } - else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") { - stdIconWidth = sW / 16.5; - stdIconHeight = sH / 16.5; - } - else { - stdIconWidth = sW / 18; - stdIconHeight = sH / 18; - } + stdIconWidth = sW / 9.5; + stdIconHeight = sH / 9.5; for(int i = 1; i <= buttonsNumber; i++) { // Horizontal layout that will contain the book button and its icon @@ -199,7 +184,7 @@ void localLibraryWidget::setupBooksList(int pageNumber) { in++; } } - if(in < buttonsNumber) { + if(in <= buttonsNumber) { for(int i = in; i <= buttonsNumber; i++) { bookIconArray[i]->hide(); bookBtnArray[i]->hide(); @@ -210,7 +195,11 @@ void localLibraryWidget::setupBooksList(int pageNumber) { } ui->pageNumberLabel->setText("Page " + QString::number(pageNumber) + " of " + QString::number(pagesNumber)); // NOTICE: Memory leak? - ui->verticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + // Do it twice, otherwise the layout doesn't show as intended + for(int i = 0; i <= 1; i++) { + ui->verticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + } + QTimer::singleShot(100, this, SLOT(refreshScreenNative())); } void localLibraryWidget::on_previousPageBtn_clicked() @@ -246,3 +235,7 @@ void localLibraryWidget::btnOpenBook(int buttonNumber) { openBook(id); localLibraryWidget::close(); } + +void localLibraryWidget::refreshScreenNative() { + emit refreshScreen(); +} diff --git a/locallibrarywidget.h b/locallibrarywidget.h index 77dd80a..746966c 100644 --- a/locallibrarywidget.h +++ b/locallibrarywidget.h @@ -41,6 +41,7 @@ private slots: void on_nextPageBtn_clicked(); void openBook(int id); void btnOpenBook(int buttonNumber); + void refreshScreenNative(); private: Ui::localLibraryWidget * ui; @@ -51,6 +52,7 @@ private: signals: void openBookSignal(QString bookFile, bool relativePath); + void refreshScreen(); }; #endif // LOCALLIBRARYWIDGET_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 5b8d4ae..965dc06 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -986,6 +986,7 @@ void MainWindow::resetWifiIconClickedWhileReconnecting() { void MainWindow::setupLocalLibraryWidget() { localLibraryWidget * localLibraryWidgetWindow = new localLibraryWidget(); connect(localLibraryWidgetWindow, SIGNAL(openBookSignal(QString, bool)), SLOT(openBookFile(QString, bool))); + connect(localLibraryWidgetWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen())); localLibraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose); ui->homeStackedWidget->insertWidget(1, localLibraryWidgetWindow); ui->homeStackedWidget->setCurrentIndex(1);