Local library: Fix folder long names, kobo nia sizes, some aspect ratio repairs

This commit is contained in:
Szybet 2023-06-17 21:24:45 +02:00 committed by Nicolas Mailloux
parent 6bc3c41e03
commit dbb09dcbda
2 changed files with 25 additions and 18 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ moc_*
qrc_*
.qmake.stash
.vscode
.qtc_clangd

View file

@ -41,6 +41,9 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
else if(global::deviceID == "n873\n") {
bookTitleTruncateThreshold = 45;
}
else if(global::deviceID == "n306\n") {
bookTitleTruncateThreshold = 32;
}
else {
bookTitleTruncateThreshold = 35;
}
@ -57,33 +60,29 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
stdIconWidthDivider = 9.5;
stdIconHeightDivider = 9.5;
stdIconWidth = sW / stdIconWidthDivider;
stdIconHeight = sH / stdIconHeightDivider;
}
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
else if(global::deviceID == "n613\n" or global::deviceID == "emu\n") {
stdIconWidthDivider = 8.5;
stdIconHeightDivider = 8.5;
stdIconWidth = sW / stdIconWidthDivider;
stdIconHeight = sH / stdIconHeightDivider;
}
else if(global::deviceID == "n437\n") {
stdIconWidthDivider = 8;
stdIconHeightDivider = 8;
stdIconWidth = sW / stdIconWidthDivider;
stdIconHeight = sH / stdIconHeightDivider;
}
else if(global::deviceID == "n873\n") {
stdIconWidthDivider = 9.7;
stdIconHeightDivider = 9.7;
stdIconWidth = sW / stdIconWidthDivider;
stdIconHeight = sH / stdIconHeightDivider;
}
else if(global::deviceID == "n306\n" || global::deviceID == "n236\n") {
stdIconWidthDivider = 9.1;
stdIconHeightDivider = 9.1;
}
else {
stdIconWidthDivider = 9.5;
stdIconHeightDivider = 9.5;
stdIconWidth = sW / stdIconWidthDivider;
stdIconHeight = sH / stdIconHeightDivider;
}
stdIconWidth = sW / stdIconWidthDivider;
stdIconHeight = sH / stdIconHeightDivider;
setupButtonsLook();
@ -216,11 +215,11 @@ void localLibraryWidget::setupBooksList(int pageNumber) {
if(!coverPath.isEmpty()) {
// Display book cover if found
QPixmap pixmap(coverPath);
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio));
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::IgnoreAspectRatio));
}
else {
QPixmap pixmap(":/resources/cover_unavailable.png");
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
// Display book title
@ -329,7 +328,7 @@ void localLibraryWidget::btnOpenBook(int buttonNumber) {
if(id == global::localLibrary::folderID) {
if(folderFeatureEnabled == true) {
log("A folder was selected", className);
QString directory = purgeHtml(bookBtnArray[buttonNumber]->text());
QString directory = bookBtnArray[buttonNumber]->statusTip();
changePathAndRefresh(directory);
}
}
@ -423,7 +422,7 @@ void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
if(folderFeatureEnabled == true) {
bookID = id;
log("Opening options dialog for directory", className);
QString directoryPath = purgeHtml(bookBtnArray[pseudoBookID]->text());
QString directoryPath = bookBtnArray[pseudoBookID]->statusTip();
log("Directory path is '" + directoryPath + "'", className);
global::localLibrary::bookOptionsDialog::isFolder = true;
global::localLibrary::bookOptionsDialog::folderPath = pathForFolders + directoryPath;
@ -535,7 +534,14 @@ void localLibraryWidget::setupBooksListFolders(int pageNumber) {
lineArray[in]->show();
}
bookBtnArray[in]->setText("<font face='Inter'><b>" + directoryListPure.at(directoryCount) + "</b></font>");
QString directoryNameFull = directoryListPure.at(directoryCount);
bookBtnArray[in]->setStatusTip(directoryNameFull);
QString directoryNameNotFull = directoryNameFull;
if(directoryNameNotFull.length() > bookTitleTruncateThreshold) {
directoryNameNotFull.truncate(bookTitleTruncateThreshold);
directoryNameNotFull.append("...");
}
bookBtnArray[in]->setText("<font face='Inter'><b>" + directoryNameNotFull + "</b></font>");
bookIconArray[in]->setPixmap(pixmapForFolder.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
// ID for indicating that it's a folder in btnOpenBook
@ -568,11 +574,11 @@ void localLibraryWidget::setupBooksListFolders(int pageNumber) {
if(QFile(coverPath).exists()) {
// Display book cover if found
QPixmap pixmap(coverPath);
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio));
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::IgnoreAspectRatio));
}
else {
QPixmap pixmap(":/resources/cover_unavailable.png");
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
// Display book title