mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Folders in local library: W.-I.-P.
This commit is contained in:
parent
6ac7d4c006
commit
cff3c2c69d
15 changed files with 864 additions and 320 deletions
|
@ -15,6 +15,8 @@
|
||||||
<file>resources/close.png</file>
|
<file>resources/close.png</file>
|
||||||
<file>resources/chevron-left.png</file>
|
<file>resources/chevron-left.png</file>
|
||||||
<file>resources/chevron-right.png</file>
|
<file>resources/chevron-right.png</file>
|
||||||
|
<file>resources/chevron-down.png</file>
|
||||||
|
<file>resources/chevron-up.png</file>
|
||||||
<file>resources/christie.png</file>
|
<file>resources/christie.png</file>
|
||||||
<file>resources/exit.png</file>
|
<file>resources/exit.png</file>
|
||||||
<file>resources/usbms.png</file>
|
<file>resources/usbms.png</file>
|
||||||
|
@ -103,5 +105,7 @@
|
||||||
<file>resources/checkbox-checked-small.png</file>
|
<file>resources/checkbox-checked-small.png</file>
|
||||||
<file>resources/checkbox-x-small.png</file>
|
<file>resources/checkbox-x-small.png</file>
|
||||||
<file>resources/checkbox-x.png</file>
|
<file>resources/checkbox-x.png</file>
|
||||||
|
<file>resources/folder.png</file>
|
||||||
|
<file>resources/question-mark.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -141,12 +141,16 @@ namespace global {
|
||||||
static inline QString pinnedBooksDatabasePath = databaseDirectoryPath + "PinnedBooks.db";
|
static inline QString pinnedBooksDatabasePath = databaseDirectoryPath + "PinnedBooks.db";
|
||||||
static inline QString highlightsDatabasePath = databaseDirectoryPath + "Highlights.db";
|
static inline QString highlightsDatabasePath = databaseDirectoryPath + "Highlights.db";
|
||||||
static inline QString todoDatabasePath = databaseDirectoryPath + "ToDo.db";
|
static inline QString todoDatabasePath = databaseDirectoryPath + "ToDo.db";
|
||||||
|
// Maximum signed integer value for 32-bit systems
|
||||||
|
static inline int folderID = 2147483647;
|
||||||
inline bool headless;
|
inline bool headless;
|
||||||
namespace bookOptionsDialog {
|
namespace bookOptionsDialog {
|
||||||
inline int bookID;
|
inline int bookID;
|
||||||
inline bool deleteOption = true;
|
inline bool deleteOption = true;
|
||||||
inline bool bookDeleted;
|
inline bool bookDeleted;
|
||||||
inline bool bookPinAction;
|
inline bool bookPinAction;
|
||||||
|
inline QString folderPath;
|
||||||
|
inline bool isFolder = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace localStorage {
|
namespace localStorage {
|
||||||
|
|
|
@ -16,11 +16,14 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
ui->previousPageBtn->setProperty("type", "borderless");
|
ui->previousPageBtn->setProperty("type", "borderless");
|
||||||
ui->previousPageBtn->setEnabled(false);
|
ui->previousPageBtn->setEnabled(false);
|
||||||
ui->nextPageBtn->setProperty("type", "borderless");
|
ui->nextPageBtn->setProperty("type", "borderless");
|
||||||
|
ui->goUpBtn->setProperty("type", "borderless");
|
||||||
|
ui->pathBtn->setProperty("type", "borderless");
|
||||||
ui->previousPageBtn->setIcon(QIcon(":/resources/chevron-left.png"));
|
ui->previousPageBtn->setIcon(QIcon(":/resources/chevron-left.png"));
|
||||||
ui->nextPageBtn->setIcon(QIcon(":/resources/chevron-right.png"));
|
ui->nextPageBtn->setIcon(QIcon(":/resources/chevron-right.png"));
|
||||||
ui->pageNumberLabel->setFont(QFont("Source Serif Pro"));
|
ui->pageNumberLabel->setFont(QFont("Source Serif Pro"));
|
||||||
ui->pageNumberLabel->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding-left: 10px; padding-right: 10px");
|
ui->pageNumberLabel->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding-left: 10px; padding-right: 10px");
|
||||||
ui->verticalLayout->setSpacing(4);
|
|
||||||
|
ui->goUpBtn->setEnabled(false);
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
if(global::deviceID == "n705\n") {
|
||||||
buttonsNumber = 3;
|
buttonsNumber = 3;
|
||||||
|
@ -119,6 +122,17 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
showToast("Generating database");
|
showToast("Generating database");
|
||||||
}
|
}
|
||||||
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
||||||
|
|
||||||
|
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/21-local_library/folders") == false) {
|
||||||
|
folderFeatureEnabled = true;
|
||||||
|
ui->goUpBtn->hide();
|
||||||
|
ui->pathBtn->hide();
|
||||||
|
ui->goUpBtn->deleteLater();
|
||||||
|
ui->pathBtn->deleteLater();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
folderFeatureEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localLibraryWidget::~localLibraryWidget()
|
localLibraryWidget::~localLibraryWidget()
|
||||||
|
@ -178,7 +192,12 @@ void localLibraryWidget::setupDatabase() {
|
||||||
databaseJsonArrayList = databaseJsonObject["database"].toArray();
|
databaseJsonArrayList = databaseJsonObject["database"].toArray();
|
||||||
// Determine maximum page number
|
// Determine maximum page number
|
||||||
booksNumber = databaseJsonArrayList.size();
|
booksNumber = databaseJsonArrayList.size();
|
||||||
pagesNumber = std::ceil((double)booksNumber / buttonsNumber);
|
if(folderFeatureEnabled == false) {
|
||||||
|
pagesNumber = std::ceil((double)booksNumber / buttonsNumber);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
calculateMaximumPagesNumberForFolders();
|
||||||
|
}
|
||||||
if(databaseJsonArrayList.isEmpty()) {
|
if(databaseJsonArrayList.isEmpty()) {
|
||||||
log("Database is empty", className);
|
log("Database is empty", className);
|
||||||
noBooksInDatabase = true;
|
noBooksInDatabase = true;
|
||||||
|
@ -278,8 +297,19 @@ void localLibraryWidget::setupBooksList(int pageNumber) {
|
||||||
|
|
||||||
void localLibraryWidget::on_previousPageBtn_clicked()
|
void localLibraryWidget::on_previousPageBtn_clicked()
|
||||||
{
|
{
|
||||||
|
log("Previous button clicked", className);
|
||||||
|
|
||||||
|
if(folderFeatureEnabled == true) {
|
||||||
|
log("Decreasing bookIndexVector by buttonsNumber", className);
|
||||||
|
bookIndexVector = (bookIndexVector - goBackInIndex) - buttonsNumber;
|
||||||
|
if(bookIndexVector < 0) {
|
||||||
|
log("Error: Shouldn't be possible to get here", className);
|
||||||
|
bookIndexVector = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentPageNumber--;
|
currentPageNumber--;
|
||||||
setupBooksList(currentPageNumber);
|
setupBooksListToggle(currentPageNumber);
|
||||||
|
|
||||||
pagesTurned = pagesTurned + 1;
|
pagesTurned = pagesTurned + 1;
|
||||||
if(pagesTurned >= 3) {
|
if(pagesTurned >= 3) {
|
||||||
|
@ -292,7 +322,7 @@ void localLibraryWidget::on_previousPageBtn_clicked()
|
||||||
void localLibraryWidget::on_nextPageBtn_clicked()
|
void localLibraryWidget::on_nextPageBtn_clicked()
|
||||||
{
|
{
|
||||||
currentPageNumber++;
|
currentPageNumber++;
|
||||||
setupBooksList(currentPageNumber);
|
setupBooksListToggle(currentPageNumber);
|
||||||
|
|
||||||
pagesTurned = pagesTurned + 1;
|
pagesTurned = pagesTurned + 1;
|
||||||
if(pagesTurned >= 3) {
|
if(pagesTurned >= 3) {
|
||||||
|
@ -309,9 +339,22 @@ void localLibraryWidget::openBook(int bookID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
||||||
|
log("Book/directory button clicked, buttonNumber is " + QString::number(buttonNumber), className);
|
||||||
int id = idList.at(buttonNumber - 1);
|
int id = idList.at(buttonNumber - 1);
|
||||||
openBook(id);
|
if(id == global::localLibrary::folderID) {
|
||||||
localLibraryWidget::close();
|
if(folderFeatureEnabled == true) {
|
||||||
|
log("A folder was selected", className);
|
||||||
|
QString directory = bookBtnArray[buttonNumber]->text();
|
||||||
|
log("Chosen directory is '" + directory + "'", className);
|
||||||
|
ui->goUpBtn->setEnabled(true);
|
||||||
|
changePathAndRefresh(directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log("A book was selected", className);
|
||||||
|
openBook(id);
|
||||||
|
localLibraryWidget::close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openGoToPageDialog() {
|
void localLibraryWidget::openGoToPageDialog() {
|
||||||
|
@ -328,8 +371,11 @@ void localLibraryWidget::goToPage(int page) {
|
||||||
showToast("Request is beyond page range");
|
showToast("Request is beyond page range");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(folderFeatureEnabled == true) {
|
||||||
|
calculateIndexForPage(page);
|
||||||
|
}
|
||||||
log("Going to page " + QString::number(page), className);
|
log("Going to page " + QString::number(page), className);
|
||||||
setupBooksList(page);
|
setupBooksListToggle(page);
|
||||||
emit refreshScreen();
|
emit refreshScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,10 +389,10 @@ void localLibraryWidget::setupDisplay() {
|
||||||
if(noBooksInDatabase == false) {
|
if(noBooksInDatabase == false) {
|
||||||
// Prevent segmentation fault if a book was the last of its page
|
// Prevent segmentation fault if a book was the last of its page
|
||||||
if(currentPageNumber > pagesNumber) {
|
if(currentPageNumber > pagesNumber) {
|
||||||
setupBooksList(currentPageNumber - 1);
|
setupBooksListToggle(currentPageNumber - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setupBooksList(currentPageNumber);
|
setupBooksListToggle(currentPageNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -366,7 +412,26 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
||||||
|
|
||||||
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||||
// Determine book ID from the book's button number
|
// Determine book ID from the book's button number
|
||||||
|
// pseudoBookID represents the button's number
|
||||||
int bookID = ((currentPageNumber * buttonsNumber) - (buttonsNumber - 1)) + (pseudoBookID - 1);
|
int bookID = ((currentPageNumber * buttonsNumber) - (buttonsNumber - 1)) + (pseudoBookID - 1);
|
||||||
|
log("BookID is " + QString::number(bookID), className);
|
||||||
|
int id = idList.at(pseudoBookID - 1);
|
||||||
|
log("ID from database is " + QString::number(id), className);
|
||||||
|
|
||||||
|
if(id == global::localLibrary::folderID) {
|
||||||
|
if(folderFeatureEnabled == true) {
|
||||||
|
bookID = id;
|
||||||
|
log("Opening options dialog for directory", className);
|
||||||
|
QString directoryPath = bookBtnArray[pseudoBookID]->text();
|
||||||
|
log("Directory path is '" + directoryPath + "'", className);
|
||||||
|
global::localLibrary::bookOptionsDialog::isFolder = true;
|
||||||
|
global::localLibrary::bookOptionsDialog::folderPath = pathForFolders + directoryPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
global::localLibrary::bookOptionsDialog::isFolder = false;
|
||||||
|
global::localLibrary::bookOptionsDialog::folderPath = "";
|
||||||
|
}
|
||||||
|
|
||||||
log("Opening book options dialog for book with pseudo-ID " + QString::number(pseudoBookID) + ", ID " + QString::number(bookID), className);
|
log("Opening book options dialog for book with pseudo-ID " + QString::number(pseudoBookID) + ", ID " + QString::number(bookID), className);
|
||||||
global::localLibrary::bookOptionsDialog::bookID = bookID;
|
global::localLibrary::bookOptionsDialog::bookID = bookID;
|
||||||
|
@ -374,6 +439,7 @@ void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &localLibraryWidget::openLocalBookInfoDialog);
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &localLibraryWidget::openLocalBookInfoDialog);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::showToast, this, &localLibraryWidget::showToast);
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::showToast, this, &localLibraryWidget::showToast);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
||||||
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::removedFolder, this, &localLibraryWidget::refreshFolders);
|
||||||
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
||||||
bookOptionsDialogWindow->show();
|
bookOptionsDialogWindow->show();
|
||||||
|
@ -397,3 +463,299 @@ void localLibraryWidget::openLocalBookInfoDialog() {
|
||||||
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookInfoDialogWindow->show();
|
bookInfoDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::setupBooksListToggle(int pageNumber) {
|
||||||
|
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/21-local_library/folders") == true) {
|
||||||
|
setupBooksListFolders(pageNumber);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setupBooksList(pageNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||||
|
log("Showing local library with folders", className);
|
||||||
|
QStringList dirList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||||
|
log("Full directory list: "+ dirList.join(","), className);
|
||||||
|
|
||||||
|
// This part is calculating which folders to show per page
|
||||||
|
QStringList directoryListFront = dirList;
|
||||||
|
QStringList directoryListBack = dirList;
|
||||||
|
int pageNumberAbove = pageNumber;
|
||||||
|
while(pageNumberAbove != 1) {
|
||||||
|
for (int i = 0; i < buttonsNumber; ++i) {
|
||||||
|
if(directoryListFront.isEmpty() == false) {
|
||||||
|
directoryListFront.removeFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pageNumberAbove = pageNumberAbove - 1;
|
||||||
|
}
|
||||||
|
log("Front directory list: " + directoryListFront.join(","), className);
|
||||||
|
|
||||||
|
int aboveRemove = pageNumber * buttonsNumber;
|
||||||
|
if(directoryListBack.count() > aboveRemove) {
|
||||||
|
while(directoryListBack.count() > aboveRemove) {
|
||||||
|
if(directoryListBack.isEmpty() == false) {
|
||||||
|
directoryListBack.removeLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("Back directory list: " + directoryListBack.join(","), className);
|
||||||
|
|
||||||
|
QStringList directoryListPure;
|
||||||
|
for(QString directory: directoryListFront) {
|
||||||
|
if(directoryListBack.contains(directory) == true) {
|
||||||
|
directoryListPure.append(directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("Final directory list: " + directoryListPure.join(","), className);
|
||||||
|
|
||||||
|
idList.clear();
|
||||||
|
int in = 1;
|
||||||
|
int directoryCount = 0; // I want to start at 0
|
||||||
|
goBackInIndex = 0;
|
||||||
|
for(int i = (1 * pageNumber * buttonsNumber) - (buttonsNumber - 1); i <= (1 * pageNumber * buttonsNumber); i++) {
|
||||||
|
if(directoryListPure.count() != directoryCount) {
|
||||||
|
// Insert a folder if here
|
||||||
|
log("Showing a folder for index " + QString::number(i), className);
|
||||||
|
|
||||||
|
// Show it, it may be hidden
|
||||||
|
bookIconArray[in]->show();
|
||||||
|
bookBtnArray[in]->show();
|
||||||
|
if(buttonsNumber - in > 0) {
|
||||||
|
lineArray[in]->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
bookBtnArray[in]->setText("<font face='Inter'><b>" + directoryListPure.at(directoryCount) + "</b></font>");
|
||||||
|
bookIconArray[in]->setPixmap(pixmapForFolder.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
|
||||||
|
// ID for indicating that it's a folder in btnOpenBook
|
||||||
|
idList.append(global::localLibrary::folderID);
|
||||||
|
directoryCount = directoryCount + 1;
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Show a book otherwise
|
||||||
|
log("bookIndexVector used: " + QString::number(bookIndexVector), className);
|
||||||
|
log("Showing a book for index: " + QString::number(i), className);
|
||||||
|
// Read database info for each book and display the corresponding information on each button
|
||||||
|
bookIconArray[in]->show();
|
||||||
|
bookBtnArray[in]->show();
|
||||||
|
if(buttonsNumber - in > 0) {
|
||||||
|
lineArray[in]->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a book is missing, it's propably because of '>='
|
||||||
|
if(bookIndexVector >= booksListForPathIndex.count()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject jsonObject = databaseJsonArrayList.at(booksListForPathIndex.at(bookIndexVector)).toObject();
|
||||||
|
QString bookTitle = jsonObject["Title"].toString();
|
||||||
|
QString bookAuthor = jsonObject["Author"].toString();
|
||||||
|
QString coverPath = jsonObject["CoverPath"].toString();
|
||||||
|
QString bookID = jsonObject["BookID"].toString();
|
||||||
|
|
||||||
|
if(!coverPath.isEmpty()) {
|
||||||
|
// Display book cover if found
|
||||||
|
QPixmap pixmap(coverPath);
|
||||||
|
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QPixmap pixmap(":/resources/cover_unavailable.png");
|
||||||
|
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display book title
|
||||||
|
idList.append(bookID.toInt());
|
||||||
|
if(bookTitle.length() > bookTitleTruncateThreshold) {
|
||||||
|
bookTitle.truncate(bookTitleTruncateThreshold);
|
||||||
|
bookTitle.append("...");
|
||||||
|
}
|
||||||
|
if(!bookAuthor.isEmpty()) {
|
||||||
|
// Book is likely an ePUB
|
||||||
|
bookBtnArray[in]->setText("<font face='Inter'><b>" + bookTitle + "</b></font>" + "<br>" + bookAuthor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Book is likely a PDF or a picture
|
||||||
|
bookBtnArray[in]->setText("<font face='Inter'><b>" + bookTitle + "</b></font>");
|
||||||
|
}
|
||||||
|
if(!bookID.isEmpty()) {
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
bookIndexVector = bookIndexVector + 1;
|
||||||
|
}
|
||||||
|
goBackInIndex = goBackInIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in <= buttonsNumber) {
|
||||||
|
for(int i = in; i <= buttonsNumber; i++) {
|
||||||
|
log("Hiding items in LocalLibrary", className);
|
||||||
|
bookIconArray[i]->hide();
|
||||||
|
bookBtnArray[i]->hide();
|
||||||
|
if(i - 1 < buttonsNumber) {
|
||||||
|
lineArray[(i - 1)]->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->pageNumberLabel->setText(QString::number(pageNumber) + " <i>of</i> " + QString::number(pagesNumber));
|
||||||
|
// NOTICE: Memory leak?
|
||||||
|
// 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set boundaries for 'Previous'/'Next' page turn buttons
|
||||||
|
currentPageNumber = pageNumber;
|
||||||
|
ui->previousPageBtn->setEnabled(true);
|
||||||
|
ui->nextPageBtn->setEnabled(true);
|
||||||
|
if(currentPageNumber - 1 < 1) {
|
||||||
|
ui->previousPageBtn->setEnabled(false);
|
||||||
|
ui->nextPageBtn->setEnabled(true);
|
||||||
|
}
|
||||||
|
if(currentPageNumber + 1 > pagesNumber) {
|
||||||
|
ui->previousPageBtn->setEnabled(true);
|
||||||
|
ui->nextPageBtn->setEnabled(false);
|
||||||
|
}
|
||||||
|
if(currentPageNumber - 1 < 1 and currentPageNumber + 1 > pagesNumber) {
|
||||||
|
ui->previousPageBtn->setEnabled(false);
|
||||||
|
ui->nextPageBtn->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets pagesNumber for folders feature, and everything else
|
||||||
|
void localLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
||||||
|
log("Main path is '" + pathForFolders + "'", className);
|
||||||
|
|
||||||
|
// Look for books in this path
|
||||||
|
booksListForPathIndex.clear();
|
||||||
|
int count = 0;
|
||||||
|
for(QJsonValue object: databaseJsonArrayList) {
|
||||||
|
QString bookPath = object.toObject()["BookPath"].toString();
|
||||||
|
QString bookDirPath = QFileInfo(bookPath).absoluteDir().path();
|
||||||
|
|
||||||
|
if(bookDirPath.at(bookDirPath.count() - 1) == "/") {
|
||||||
|
bookDirPath = bookDirPath.remove(bookDirPath.count() - 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString temporaryPathForFolders = pathForFolders;
|
||||||
|
if(temporaryPathForFolders.at(temporaryPathForFolders.count() - 1) == "/") {
|
||||||
|
temporaryPathForFolders = temporaryPathForFolders.remove(temporaryPathForFolders.count() - 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bookDirPath == temporaryPathForFolders) {
|
||||||
|
booksListForPathIndex.append(count);
|
||||||
|
}
|
||||||
|
count = count + 1;
|
||||||
|
}
|
||||||
|
QStringList list;
|
||||||
|
foreach (int number, booksListForPathIndex) {
|
||||||
|
list.append(QString::number(number));
|
||||||
|
}
|
||||||
|
|
||||||
|
directoryListCount = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name).count();
|
||||||
|
log("Directories count in directory: " + QString::number(directoryListCount), className);
|
||||||
|
completeItemsList = booksListForPathIndex.count() + directoryListCount;
|
||||||
|
log("All items: " + QString::number(completeItemsList), className);
|
||||||
|
|
||||||
|
pagesNumber = std::ceil((double)completeItemsList / buttonsNumber);
|
||||||
|
|
||||||
|
log("Total pages: " + QString::number(pagesNumber), className);
|
||||||
|
|
||||||
|
// This is the last page full of folders
|
||||||
|
firstPageForBooks = (QString::number(float(directoryListCount) / buttonsNumber).split(".").first()).toInt();
|
||||||
|
log("There are so many pages with folders: " + QString::number(firstPageForBooks), className);
|
||||||
|
|
||||||
|
// This indicates how much folders are after firstPageForBooks. It's always less than buttonsNumber
|
||||||
|
lastPageFolderCount = directoryListCount;
|
||||||
|
while(lastPageFolderCount >= buttonsNumber) {
|
||||||
|
lastPageFolderCount = lastPageFolderCount - buttonsNumber;
|
||||||
|
}
|
||||||
|
log("Start after item on the last page: " + QString::number(lastPageFolderCount), className);
|
||||||
|
|
||||||
|
// Sorting the vector if needed should be done here
|
||||||
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::calculateIndexForPage(int pageNumber) {
|
||||||
|
if(pageNumber == firstPageForBooks + 1) {
|
||||||
|
log("Variable firstPageForBooks is 0", className);
|
||||||
|
bookIndexVector = 0;
|
||||||
|
return void();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pageNumber == firstPageForBooks + 2) {
|
||||||
|
log("The page is just after firstPageForBooks", className);
|
||||||
|
bookIndexVector = buttonsNumber - lastPageFolderCount;
|
||||||
|
return void();
|
||||||
|
}
|
||||||
|
else if(pageNumber > firstPageForBooks + 2) {
|
||||||
|
bookIndexVector = buttonsNumber - lastPageFolderCount;
|
||||||
|
int pageUntilGoal = 1;
|
||||||
|
int pageDifference = pageNumber - (firstPageForBooks + 2);
|
||||||
|
log("Variable firstPageForBooks is " + QString::number(firstPageForBooks), className);
|
||||||
|
log("Variable pageDifference is " + QString::number(pageDifference), className);
|
||||||
|
if(pageDifference != 0) {
|
||||||
|
while(pageUntilGoal != pageDifference) {
|
||||||
|
log("Looping for pageUntilGoal");
|
||||||
|
bookIndexVector = bookIndexVector + buttonsNumber;
|
||||||
|
pageUntilGoal++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bookIndexVector = bookIndexVector + buttonsNumber;
|
||||||
|
log("Calculated bookIndexVector is " + QString::number(bookIndexVector), className);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log("Variable pageNumber isn't higher than firstPageForBooks", className);
|
||||||
|
bookIndexVector = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::changePathAndRefresh(QString directory) {
|
||||||
|
log("Changing path", className);
|
||||||
|
QString temporaryPathForFolders = pathForFolders + directory + "/";
|
||||||
|
if(QDir(temporaryPathForFolders).isEmpty() == false) {
|
||||||
|
pathForFolders = temporaryPathForFolders;
|
||||||
|
calculateMaximumPagesNumberForFolders();
|
||||||
|
bookIndexVector = 0;
|
||||||
|
goToPage(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
showToast("Directory is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::on_goUpBtn_clicked()
|
||||||
|
{
|
||||||
|
if(pathForFolders != "/mnt/onboard/onboard/") {
|
||||||
|
log("Changing path; going back", className);
|
||||||
|
// This can't be a one-liner
|
||||||
|
QDir temporaryPathForFolders = QDir(pathForFolders);
|
||||||
|
temporaryPathForFolders.cdUp();
|
||||||
|
pathForFolders = temporaryPathForFolders.path();
|
||||||
|
pathForFolders = pathForFolders + "/";
|
||||||
|
if(pathForFolders == "/mnt/onboard/onboard/") {
|
||||||
|
ui->goUpBtn->setDisabled(true);
|
||||||
|
}
|
||||||
|
log("New path is '" + pathForFolders + "'", className);
|
||||||
|
|
||||||
|
calculateMaximumPagesNumberForFolders();
|
||||||
|
bookIndexVector = 0;
|
||||||
|
goToPage(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::on_pathBtn_clicked()
|
||||||
|
{
|
||||||
|
log("Showing path dialog", className);
|
||||||
|
QString pathForFoldersSaved = pathForFolders;
|
||||||
|
showToast(pathForFolders.remove(0, 20));
|
||||||
|
pathForFolders = pathForFoldersSaved;
|
||||||
|
}
|
||||||
|
|
||||||
|
void localLibraryWidget::refreshFolders() {
|
||||||
|
log("Called refresh folders");
|
||||||
|
calculateMaximumPagesNumberForFolders();
|
||||||
|
bookIndexVector = 0;
|
||||||
|
goToPage(1);
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,19 @@ public:
|
||||||
int bookTitleTruncateThreshold;
|
int bookTitleTruncateThreshold;
|
||||||
QVector<int> idList;
|
QVector<int> idList;
|
||||||
bool noBooksInDatabase = true;
|
bool noBooksInDatabase = true;
|
||||||
|
// For folder feature
|
||||||
|
QString pathForFolders = "/mnt/onboard/onboard/";
|
||||||
|
bool folderFeatureEnabled = false;
|
||||||
|
int firstPageForBooks;
|
||||||
|
int lastPageFolderCount;
|
||||||
|
int bookIndexVector = 0;
|
||||||
|
int goBackInIndex = 0;
|
||||||
|
QPixmap pixmapForFolder = QPixmap(":/resources/folder.png");
|
||||||
|
QVector<int> booksListForPathIndex;
|
||||||
|
int fileListCount;
|
||||||
|
int directoryListCount;
|
||||||
|
int completeItemsList;
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupDatabase();
|
void setupDatabase();
|
||||||
|
@ -57,6 +70,16 @@ private slots:
|
||||||
void openBookOptionsDialog(int pseudoBookID);
|
void openBookOptionsDialog(int pseudoBookID);
|
||||||
void handlePossibleBookDeletion();
|
void handlePossibleBookDeletion();
|
||||||
void openLocalBookInfoDialog();
|
void openLocalBookInfoDialog();
|
||||||
|
// For folder feature
|
||||||
|
void setupBooksListFolders(int pageNumber);
|
||||||
|
void setupBooksListToggle(int pageNumber);
|
||||||
|
void calculateMaximumPagesNumberForFolders();
|
||||||
|
void calculateIndexForPage(int pageNumber);
|
||||||
|
// Dir without "/" at the end and begining
|
||||||
|
void changePathAndRefresh(QString directory);
|
||||||
|
void refreshFolders();
|
||||||
|
void on_goUpBtn_clicked();
|
||||||
|
void on_pathBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::localLibraryWidget * ui;
|
Ui::localLibraryWidget * ui;
|
||||||
|
|
|
@ -43,14 +43,31 @@
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="6">
|
<item row="0" column="3">
|
||||||
|
<widget class="QPushButton" name="pathBtn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../eink.qrc">
|
||||||
|
<normaloff>:/resources/question-mark.png</normaloff>:/resources/question-mark.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="9">
|
||||||
<widget class="QPushButton" name="nextPageBtn">
|
<widget class="QPushButton" name="nextPageBtn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="0" column="7">
|
||||||
<widget class="QClickableLabel" name="pageNumberLabel" native="true">
|
<widget class="QClickableLabel" name="pageNumberLabel" native="true">
|
||||||
<property name="text" stdset="0">
|
<property name="text" stdset="0">
|
||||||
<string/>
|
<string/>
|
||||||
|
@ -58,22 +75,13 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="0" column="5">
|
||||||
<spacer name="horizontalSpacer_3">
|
<widget class="QPushButton" name="previousPageBtn">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
</widget>
|
||||||
<enum>QSizePolicy::Maximum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="6">
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -89,7 +97,23 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="8">
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -106,10 +130,20 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QPushButton" name="previousPageBtn">
|
<widget class="QPushButton" name="goUpBtn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../eink.qrc">
|
||||||
|
<normaloff>:/resources/chevron-up.png</normaloff>:/resources/chevron-up.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
@ -125,6 +159,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -212,6 +259,8 @@ Add some via USB or explore the Online Library.</string>
|
||||||
<header>qclickablelabel.h</header>
|
<header>qclickablelabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../eink.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
BIN
src/resources/chevron-down.png
Normal file
BIN
src/resources/chevron-down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
src/resources/chevron-up.png
Normal file
BIN
src/resources/chevron-up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
src/resources/folder.png
Normal file
BIN
src/resources/folder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
src/resources/question-mark.png
Normal file
BIN
src/resources/question-mark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -338,6 +338,11 @@ settings::settings(QWidget *parent) :
|
||||||
ui->tzComboBox->setCurrentText(readFile(".config/19-timezone/config-name"));
|
ui->tzComboBox->setCurrentText(readFile(".config/19-timezone/config-name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Local library folders support
|
||||||
|
if(checkconfig(".config/21-local_library/folders") == true) {
|
||||||
|
ui->localLibraryShowFoldersCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
// Enforcing security policy if the user has not rooted the device
|
// Enforcing security policy if the user has not rooted the device
|
||||||
if(checkconfig("/external_root/opt/root/rooted") == true) {
|
if(checkconfig("/external_root/opt/root/rooted") == true) {
|
||||||
|
@ -1089,3 +1094,19 @@ void settings::on_pageSizeWidthIncBtn_clicked()
|
||||||
pageSizeWidthSaved = pageSizeWidthSaved + 5;
|
pageSizeWidthSaved = pageSizeWidthSaved + 5;
|
||||||
ui->pageSizeWidthLabel->setText(QString::number(pageSizeWidthSaved));
|
ui->pageSizeWidthLabel->setText(QString::number(pageSizeWidthSaved));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void settings::on_localLibraryShowFoldersCheckBox_toggled(bool checked)
|
||||||
|
{
|
||||||
|
QString settingString = "local library folders support";
|
||||||
|
if(checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/21-local_library/folders", "Folders");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/21-local_library/folders", "Folders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ private slots:
|
||||||
void on_pageSizeWidthDecBtn_clicked();
|
void on_pageSizeWidthDecBtn_clicked();
|
||||||
void on_pageSizeWidthIncBtn_clicked();
|
void on_pageSizeWidthIncBtn_clicked();
|
||||||
|
|
||||||
|
void on_localLibraryShowFoldersCheckBox_toggled(bool checked);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void showToast(QString messageToDisplay);
|
void showToast(QString messageToDisplay);
|
||||||
void closeIndefiniteToast();
|
void closeIndefiniteToast();
|
||||||
|
|
|
@ -68,8 +68,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>457</width>
|
<width>463</width>
|
||||||
<height>667</height>
|
<height>632</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
@ -118,139 +118,6 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="22" column="0">
|
|
||||||
<widget class="Line" name="line_3">
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="13" column="0">
|
|
||||||
<widget class="QCheckBox" name="demoCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Disable "Welcome to InkBox" message</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="21" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Chivo</family>
|
|
||||||
<italic>true</italic>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>USB networking</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="18" column="0">
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Chivo</family>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>true</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Storage</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
|
||||||
<widget class="QCheckBox" name="readerScrollBarCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show scroll bar if needed</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Chivo</family>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>true</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Reading</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="19" column="0">
|
|
||||||
<widget class="Line" name="line_7">
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QCheckBox" name="globalReadingSettingsCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Global reading settings</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="Line" name="line_8">
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="11" column="0">
|
|
||||||
<widget class="QCheckBox" name="clockCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clock: Show seconds</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="10" column="0">
|
|
||||||
<widget class="Line" name="line_6">
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="9" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Chivo</family>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>true</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Home</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="12" column="0">
|
|
||||||
<widget class="QCheckBox" name="quoteCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Disable authors quotes</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_15">
|
<layout class="QGridLayout" name="gridLayout_15">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
|
@ -363,6 +230,230 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>true</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reading</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0">
|
||||||
|
<widget class="QCheckBox" name="clockCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clock: Show seconds</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="21" column="0">
|
||||||
|
<widget class="Line" name="line_7">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="14" column="0">
|
||||||
|
<widget class="QLabel" name="label_14">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Local library</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QCheckBox" name="readerScrollBarCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show scroll bar if needed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="globalReadingSettingsCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Global reading settings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="22" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="usbmsBtn">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<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="0">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enter USB Mass Storage session</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QCheckBox" name="menuBarCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Always show status bar</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="25" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<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="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Request DHCP lease</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="requestLeaseBtn">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Request</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_16">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="exportHighlightsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export highlights</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="exportHighlightsBtn">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer_12">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="0">
|
||||||
|
<widget class="QCheckBox" name="quoteCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Disable authors quotes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="26" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>true</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Home</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
|
@ -419,45 +510,15 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="10" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_16">
|
<widget class="Line" name="line_6">
|
||||||
<property name="bottomMargin">
|
<property name="frameShadow">
|
||||||
<number>0</number>
|
<enum>QFrame::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<property name="orientation">
|
||||||
<widget class="QLabel" name="exportHighlightsLabel">
|
<enum>Qt::Horizontal</enum>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Export highlights</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="exportHighlightsBtn">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Export</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<spacer name="horizontalSpacer_12">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_9">
|
<layout class="QGridLayout" name="gridLayout_9">
|
||||||
|
@ -531,107 +592,76 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="20" column="0">
|
<item row="20" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="bottomMargin">
|
<property name="font">
|
||||||
<number>0</number>
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>true</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="usbmsBtn">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Go</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<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="0">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enter USB Mass Storage session</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0">
|
|
||||||
<widget class="QCheckBox" name="menuBarCheckBox">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Always show status bar</string>
|
<string>Storage</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="13" column="0">
|
||||||
|
<widget class="QCheckBox" name="demoCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Disable "Welcome to InkBox" message</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="23" column="0">
|
<item row="23" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="bottomMargin">
|
<property name="font">
|
||||||
<number>0</number>
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
<property name="text">
|
||||||
<spacer name="horizontalSpacer">
|
<string>USB networking</string>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Horizontal</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="sizeHint" stdset="0">
|
<item row="16" column="0">
|
||||||
<size>
|
<widget class="QCheckBox" name="localLibraryShowFoldersCheckBox">
|
||||||
<width>40</width>
|
<property name="text">
|
||||||
<height>20</height>
|
<string>Show folders</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</spacer>
|
</item>
|
||||||
</item>
|
<item row="1" column="0">
|
||||||
<item row="0" column="0">
|
<widget class="Line" name="line_8">
|
||||||
<widget class="QLabel" name="label_4">
|
<property name="frameShadow">
|
||||||
<property name="text">
|
<enum>QFrame::Plain</enum>
|
||||||
<string>Request DHCP lease</string>
|
</property>
|
||||||
</property>
|
<property name="orientation">
|
||||||
</widget>
|
<enum>Qt::Horizontal</enum>
|
||||||
</item>
|
</property>
|
||||||
<item row="0" column="2">
|
</widget>
|
||||||
<widget class="QPushButton" name="requestLeaseBtn">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Request</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="24" column="0">
|
<item row="24" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<widget class="Line" name="line_3">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
</widget>
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
</item>
|
||||||
|
<item row="15" column="0">
|
||||||
|
<widget class="Line" name="line_11">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="orientation">
|
||||||
<size>
|
<enum>Qt::Horizontal</enum>
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -83,26 +83,31 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
||||||
log("Setting up book info dialog, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
|
log("Setting up book info dialog, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QJsonObject bookJsonObject = getBookMetadata(global::localLibrary::bookOptionsDialog::bookID);
|
if(global::localLibrary::bookOptionsDialog::bookID != global::localLibrary::folderID) {
|
||||||
QString bookInfo;
|
QJsonObject bookJsonObject = getBookMetadata(global::localLibrary::bookOptionsDialog::bookID);
|
||||||
QString title = bookJsonObject["Title"].toString();
|
QString bookInfo;
|
||||||
QString author = bookJsonObject["Author"].toString();
|
QString title = bookJsonObject["Title"].toString();
|
||||||
QString publicationDate = bookJsonObject["PublicationDate"].toString();
|
QString author = bookJsonObject["Author"].toString();
|
||||||
QString path = bookJsonObject["BookPath"].toString();
|
QString publicationDate = bookJsonObject["PublicationDate"].toString();
|
||||||
if(!title.isEmpty()) {
|
QString path = bookJsonObject["BookPath"].toString();
|
||||||
bookInfo.append("<b>Title:</b> " + title + "<br>");
|
if(!title.isEmpty()) {
|
||||||
|
bookInfo.append("<b>Title:</b> " + title + "<br>");
|
||||||
|
}
|
||||||
|
if(!author.isEmpty()) {
|
||||||
|
bookInfo.append("<b>Author:</b> " + author + "<br>");
|
||||||
|
}
|
||||||
|
if(!publicationDate.isEmpty()) {
|
||||||
|
bookInfo.append("<b>Publication date:</b> " + publicationDate + "<br>");
|
||||||
|
}
|
||||||
|
if(!path.isEmpty()) {
|
||||||
|
bookInfo.append("<b>Path:</b> " + path + "<br>");
|
||||||
|
}
|
||||||
|
global::text::textBrowserContents = bookInfo;
|
||||||
}
|
}
|
||||||
if(!author.isEmpty()) {
|
else {
|
||||||
bookInfo.append("<b>Author:</b> " + author + "<br>");
|
QString bookInfo = "<b>Path:</b> " + global::localLibrary::bookOptionsDialog::folderPath;
|
||||||
|
global::text::textBrowserContents = bookInfo;
|
||||||
}
|
}
|
||||||
if(!publicationDate.isEmpty()) {
|
|
||||||
bookInfo.append("<b>Publication date:</b> " + publicationDate + "<br>");
|
|
||||||
}
|
|
||||||
if(!path.isEmpty()) {
|
|
||||||
bookInfo.append("<b>Path:</b> " + path + "<br>");
|
|
||||||
}
|
|
||||||
|
|
||||||
global::text::textBrowserContents = bookInfo;
|
|
||||||
textwidget * textwidgetWindow = new textwidget(this);
|
textwidget * textwidgetWindow = new textwidget(this);
|
||||||
ui->stackedWidget->insertWidget(1, textwidgetWindow);
|
ui->stackedWidget->insertWidget(1, textwidgetWindow);
|
||||||
ui->stackedWidget->setCurrentIndex(1);
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
|
|
@ -22,23 +22,40 @@ bookOptionsDialog::bookOptionsDialog(QWidget *parent) :
|
||||||
ui->wipeLocalReadingSettingsBtn->setProperty("type", "borderless");
|
ui->wipeLocalReadingSettingsBtn->setProperty("type", "borderless");
|
||||||
ui->infoBtn->setProperty("type", "borderless");
|
ui->infoBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
global::localLibrary::bookOptionsDialog::bookPinAction = false;
|
if(global::localLibrary::bookOptionsDialog::isFolder == true) {
|
||||||
|
global::localLibrary::bookOptionsDialog::isFolder = false;
|
||||||
bookPath = getBookMetadata(global::localLibrary::bookOptionsDialog::bookID)["BookPath"].toString();
|
isFolder = true;
|
||||||
if(isBookPinned(global::localLibrary::bookOptionsDialog::bookID)) {
|
log("Detected a folder", className);
|
||||||
bookPinned = true;
|
ui->pinBtn->hide();
|
||||||
ui->pinBtn->setText("Unpin");
|
ui->pinBtn->deleteLater();
|
||||||
|
ui->line->hide();
|
||||||
|
ui->line->deleteLater();
|
||||||
|
ui->wipeLocalReadingSettingsBtn->hide();
|
||||||
|
ui->wipeLocalReadingSettingsBtn->deleteLater();
|
||||||
|
ui->line_2->hide();
|
||||||
|
ui->line_2->deleteLater();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bookPinned = false;
|
isFolder = false;
|
||||||
|
global::localLibrary::bookOptionsDialog::bookPinAction = false;
|
||||||
|
|
||||||
|
bookPath = getBookMetadata(global::localLibrary::bookOptionsDialog::bookID)["BookPath"].toString();
|
||||||
|
if(isBookPinned(global::localLibrary::bookOptionsDialog::bookID)) {
|
||||||
|
bookPinned = true;
|
||||||
|
ui->pinBtn->setText("Unpin");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bookPinned = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bookChecksum = fileChecksum(bookPath, QCryptographicHash::Sha256);
|
||||||
|
QDir localReadingSettingsPath("/mnt/onboard/onboard/." + bookChecksum);
|
||||||
|
if(!localReadingSettingsPath.exists()) {
|
||||||
|
ui->wipeLocalReadingSettingsBtn->setEnabled(false);
|
||||||
|
ui->wipeLocalReadingSettingsBtn->setStyleSheet(ui->wipeLocalReadingSettingsBtn->styleSheet() + "color: gray");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bookChecksum = fileChecksum(bookPath, QCryptographicHash::Sha256);
|
|
||||||
QDir localReadingSettingsPath("/mnt/onboard/onboard/." + bookChecksum);
|
|
||||||
if(!localReadingSettingsPath.exists()) {
|
|
||||||
ui->wipeLocalReadingSettingsBtn->setEnabled(false);
|
|
||||||
ui->wipeLocalReadingSettingsBtn->setStyleSheet(ui->wipeLocalReadingSettingsBtn->styleSheet() + "color: gray");
|
|
||||||
}
|
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +76,15 @@ void bookOptionsDialog::on_pinBtn_clicked()
|
||||||
|
|
||||||
void bookOptionsDialog::on_deleteBtn_clicked()
|
void bookOptionsDialog::on_deleteBtn_clicked()
|
||||||
{
|
{
|
||||||
|
if(isFolder == true) {
|
||||||
|
deleteFolder();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deleteBook();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bookOptionsDialog::deleteBook() {
|
||||||
log("Deleting book '" + bookPath + "'", className);
|
log("Deleting book '" + bookPath + "'", className);
|
||||||
global::toast::delay = 3000;
|
global::toast::delay = 3000;
|
||||||
if(QFile::remove(bookPath)) {
|
if(QFile::remove(bookPath)) {
|
||||||
|
@ -71,6 +97,20 @@ void bookOptionsDialog::on_deleteBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bookOptionsDialog::deleteFolder() {
|
||||||
|
log("Removing empty directory '" + global::localLibrary::bookOptionsDialog::folderPath + "'", className);
|
||||||
|
if(QDir(global::localLibrary::bookOptionsDialog::folderPath).isEmpty() == true) {
|
||||||
|
global::toast::delay = 3000;
|
||||||
|
QDir(global::localLibrary::bookOptionsDialog::folderPath).removeRecursively();
|
||||||
|
emit showToast("Directory removed successfully");
|
||||||
|
emit removedFolder();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit showToast("Directory is not empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void bookOptionsDialog::on_infoBtn_clicked()
|
void bookOptionsDialog::on_infoBtn_clicked()
|
||||||
{
|
{
|
||||||
emit openLocalBookInfoDialog();
|
emit openLocalBookInfoDialog();
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
QString bookPath;
|
QString bookPath;
|
||||||
QString bookChecksum;
|
QString bookChecksum;
|
||||||
bool bookPinned;
|
bool bookPinned;
|
||||||
|
bool isFolder;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pinBtn_clicked();
|
void on_pinBtn_clicked();
|
||||||
|
@ -27,11 +28,14 @@ private slots:
|
||||||
void on_wipeLocalReadingSettingsBtn_clicked();
|
void on_wipeLocalReadingSettingsBtn_clicked();
|
||||||
void pinBook(int bookID);
|
void pinBook(int bookID);
|
||||||
void unpinBook(int bookID);
|
void unpinBook(int bookID);
|
||||||
|
void deleteBook();
|
||||||
|
void deleteFolder();
|
||||||
bool isBookPinned(int bookID);
|
bool isBookPinned(int bookID);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openLocalBookInfoDialog();
|
void openLocalBookInfoDialog();
|
||||||
void showToast(QString messageToDisplay);
|
void showToast(QString messageToDisplay);
|
||||||
|
void removedFolder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::bookOptionsDialog *ui;
|
Ui::bookOptionsDialog *ui;
|
||||||
|
|
Loading…
Reference in a new issue