mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Local library: Some fixes
This commit is contained in:
parent
257d509429
commit
a034ce62af
4 changed files with 27 additions and 30 deletions
|
@ -166,7 +166,7 @@ void apps::showToastNative(QString messageToDisplay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function opens and reads the main GUI user applications' JSON file, parses and verifies its content to avoid issues in the future.
|
* This function opens and reads the main GUI user applications' JSON file, parses and verifies its contents to avoid issues in the future.
|
||||||
*/
|
*/
|
||||||
bool apps::parseJson() {
|
bool apps::parseJson() {
|
||||||
// If the path changes, it is also used statically in showUserApps()
|
// If the path changes, it is also used statically in showUserApps()
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ namespace {
|
||||||
}
|
}
|
||||||
QString purgeHtml(QString text) {
|
QString purgeHtml(QString text) {
|
||||||
// https://stackoverflow.com/questions/2799379/is-there-an-easy-way-to-strip-html-from-a-qstring-in-qt
|
// https://stackoverflow.com/questions/2799379/is-there-an-easy-way-to-strip-html-from-a-qstring-in-qt
|
||||||
// This can cause problems if someone names its directory with HTML tags, so stop here. Anki, which is a big project, also doesn't care about this
|
// This can cause problems if someone names their directory with HTML tags, so stop here. Anki, which is a big project, also doesn't care about this
|
||||||
return text.remove(QRegExp("<[^>]*>"));
|
return text.remove(QRegExp("<[^>]*>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,7 +311,7 @@ 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);
|
log("Book/directory button clicked, buttonNumber is " + QString::number(buttonNumber), className);
|
||||||
if(mainPathAndItsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openGoToPageDialog() {
|
void localLibraryWidget::openGoToPageDialog() {
|
||||||
if(mainPathAndItsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +343,8 @@ void localLibraryWidget::openGoToPageDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::goToPage(int page) {
|
void localLibraryWidget::goToPage(int page) {
|
||||||
checkIfMainPathEmpty();
|
checkIfMainPathIsEmpty();
|
||||||
if(mainPathAndItsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||||
if(mainPathAndItsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,11 +466,11 @@ void localLibraryWidget::setupBooksListToggle(int pageNumber) {
|
||||||
|
|
||||||
void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||||
log("Showing folders for page: " + QString::number(pageNumber), className);
|
log("Showing folders for page: " + QString::number(pageNumber), className);
|
||||||
QStringList dirList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
QStringList directoryList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||||
log("Full directory list: "+ dirList.join(","), className);
|
log("Full directory list: "+ directoryList.join(","), className);
|
||||||
|
|
||||||
// Main path is set and its empty
|
if(mainPathIsEmpty == true) {
|
||||||
if(mainPathAndItsEmpty == true) {
|
// Main path is set and is empty
|
||||||
ui->pageNumberLabel->setText("0 <i>of</i> 0");
|
ui->pageNumberLabel->setText("0 <i>of</i> 0");
|
||||||
ui->previousPageBtn->setEnabled(false);
|
ui->previousPageBtn->setEnabled(false);
|
||||||
ui->nextPageBtn->setEnabled(false);
|
ui->nextPageBtn->setEnabled(false);
|
||||||
|
@ -478,8 +478,8 @@ void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This part is calculating which folders to show per page
|
// This part is calculating which folders to show per page
|
||||||
QStringList directoryListFront = dirList;
|
QStringList directoryListFront = directoryList;
|
||||||
QStringList directoryListBack = dirList;
|
QStringList directoryListBack = directoryList;
|
||||||
int pageNumberAbove = pageNumber;
|
int pageNumberAbove = pageNumber;
|
||||||
while(pageNumberAbove != 1) {
|
while(pageNumberAbove != 1) {
|
||||||
for (int i = 0; i < buttonsNumber; ++i) {
|
for (int i = 0; i < buttonsNumber; ++i) {
|
||||||
|
@ -627,8 +627,8 @@ void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||||
void localLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
void localLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
||||||
log("Main path is '" + pathForFolders + "'", className);
|
log("Main path is '" + pathForFolders + "'", className);
|
||||||
|
|
||||||
checkIfMainPathEmpty();
|
checkIfMainPathIsEmpty();
|
||||||
if(mainPathAndItsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,14 +781,14 @@ void localLibraryWidget::refreshFolders() {
|
||||||
goToPage(1);
|
goToPage(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::checkIfMainPathEmpty() {
|
void localLibraryWidget::checkIfMainPathIsEmpty() {
|
||||||
if(folderFeatureEnabled == true) {
|
if(folderFeatureEnabled == true) {
|
||||||
// If the main path is empty, prevent it from well, freezing and using the cpu for 100% because of a while loop
|
// If the main path is empty, prevent it from freezing and using the CPU at 100% because of a while loop
|
||||||
if(pathForFolders == "/mnt/onboard/onboard/") {
|
if(pathForFolders == "/mnt/onboard/onboard/") {
|
||||||
bool isDirEmpty = QDir(pathForFolders).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot).isEmpty();
|
bool isDirectoryEmpty = QDir(pathForFolders).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot).isEmpty();
|
||||||
log("Main path is empty: " + QVariant(isDirEmpty).toString(), className);
|
if(isDirectoryEmpty == true) {
|
||||||
if(isDirEmpty == true) {
|
|
||||||
// To clean things out after a deletion
|
// To clean things out after a deletion
|
||||||
|
log("Main path is empty", className);
|
||||||
cleanButtons();
|
cleanButtons();
|
||||||
booksListForPathIndex.clear();
|
booksListForPathIndex.clear();
|
||||||
directoryListCount = 0;
|
directoryListCount = 0;
|
||||||
|
@ -796,12 +796,12 @@ void localLibraryWidget::checkIfMainPathEmpty() {
|
||||||
pagesNumber = 0;
|
pagesNumber = 0;
|
||||||
firstPageForBooks = 0;
|
firstPageForBooks = 0;
|
||||||
lastPageFolderCount = 0;
|
lastPageFolderCount = 0;
|
||||||
mainPathAndItsEmpty = true;
|
mainPathIsEmpty = true;
|
||||||
showToast("The library is empty");
|
showToast("Library is empty");
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mainPathAndItsEmpty = false;
|
mainPathIsEmpty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -849,13 +849,11 @@ void localLibraryWidget::cleanButtons() {
|
||||||
if(bookBtnArray[i]->isHidden() == false) {
|
if(bookBtnArray[i]->isHidden() == false) {
|
||||||
bookBtnArray[i]->hide();
|
bookBtnArray[i]->hide();
|
||||||
}
|
}
|
||||||
// I like it with those empty lines, like empty book shelves
|
|
||||||
/*
|
|
||||||
if(i < buttonsNumber) {
|
if(i < buttonsNumber) {
|
||||||
if(lineArray[i]->isHidden() == false) {
|
if(lineArray[i]->isHidden() == false) {
|
||||||
lineArray[i]->hide();
|
lineArray[i]->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,9 +53,8 @@ public:
|
||||||
int fileListCount;
|
int fileListCount;
|
||||||
int directoryListCount;
|
int directoryListCount;
|
||||||
int completeItemsList;
|
int completeItemsList;
|
||||||
// if the path is set to /mnt/onboard/onboard/, and its empty, this will be true
|
// If the path is set to '/mnt/onboard/onboard/', and it's empty, this will be true
|
||||||
bool mainPathAndItsEmpty = false;
|
bool mainPathIsEmpty = false;
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupDatabase();
|
void setupDatabase();
|
||||||
|
@ -80,7 +79,7 @@ private slots:
|
||||||
void calculateMaximumPagesNumberForFolders();
|
void calculateMaximumPagesNumberForFolders();
|
||||||
void calculateIndexForPage(int pageNumber);
|
void calculateIndexForPage(int pageNumber);
|
||||||
void goUpFunction();
|
void goUpFunction();
|
||||||
void checkIfMainPathEmpty();
|
void checkIfMainPathIsEmpty();
|
||||||
// Dir without "/" at the end and begining
|
// Dir without "/" at the end and begining
|
||||||
void changePathAndRefresh(QString directory);
|
void changePathAndRefresh(QString directory);
|
||||||
void refreshFolders();
|
void refreshFolders();
|
||||||
|
|
Loading…
Reference in a new issue