mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08: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() {
|
||||
// If the path changes, it is also used statically in showUserApps()
|
||||
|
|
|
@ -1167,7 +1167,7 @@ namespace {
|
|||
}
|
||||
QString purgeHtml(QString text) {
|
||||
// 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("<[^>]*>"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ void localLibraryWidget::openBook(int bookID) {
|
|||
|
||||
void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
||||
log("Book/directory button clicked, buttonNumber is " + QString::number(buttonNumber), className);
|
||||
if(mainPathAndItsEmpty == true) {
|
||||
if(mainPathIsEmpty == true) {
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
|||
}
|
||||
|
||||
void localLibraryWidget::openGoToPageDialog() {
|
||||
if(mainPathAndItsEmpty == true) {
|
||||
if(mainPathIsEmpty == true) {
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -343,8 +343,8 @@ void localLibraryWidget::openGoToPageDialog() {
|
|||
}
|
||||
|
||||
void localLibraryWidget::goToPage(int page) {
|
||||
checkIfMainPathEmpty();
|
||||
if(mainPathAndItsEmpty == true) {
|
||||
checkIfMainPathIsEmpty();
|
||||
if(mainPathIsEmpty == true) {
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
|||
}
|
||||
|
||||
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||
if(mainPathAndItsEmpty == true) {
|
||||
if(mainPathIsEmpty == true) {
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -466,11 +466,11 @@ void localLibraryWidget::setupBooksListToggle(int pageNumber) {
|
|||
|
||||
void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||
log("Showing folders for page: " + QString::number(pageNumber), className);
|
||||
QStringList dirList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
log("Full directory list: "+ dirList.join(","), className);
|
||||
QStringList directoryList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
log("Full directory list: "+ directoryList.join(","), className);
|
||||
|
||||
// Main path is set and its empty
|
||||
if(mainPathAndItsEmpty == true) {
|
||||
if(mainPathIsEmpty == true) {
|
||||
// Main path is set and is empty
|
||||
ui->pageNumberLabel->setText("0 <i>of</i> 0");
|
||||
ui->previousPageBtn->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
|
||||
QStringList directoryListFront = dirList;
|
||||
QStringList directoryListBack = dirList;
|
||||
QStringList directoryListFront = directoryList;
|
||||
QStringList directoryListBack = directoryList;
|
||||
int pageNumberAbove = pageNumber;
|
||||
while(pageNumberAbove != 1) {
|
||||
for (int i = 0; i < buttonsNumber; ++i) {
|
||||
|
@ -627,8 +627,8 @@ void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
|||
void localLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
||||
log("Main path is '" + pathForFolders + "'", className);
|
||||
|
||||
checkIfMainPathEmpty();
|
||||
if(mainPathAndItsEmpty == true) {
|
||||
checkIfMainPathIsEmpty();
|
||||
if(mainPathIsEmpty == true) {
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -781,14 +781,14 @@ void localLibraryWidget::refreshFolders() {
|
|||
goToPage(1);
|
||||
}
|
||||
|
||||
void localLibraryWidget::checkIfMainPathEmpty() {
|
||||
void localLibraryWidget::checkIfMainPathIsEmpty() {
|
||||
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/") {
|
||||
bool isDirEmpty = QDir(pathForFolders).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot).isEmpty();
|
||||
log("Main path is empty: " + QVariant(isDirEmpty).toString(), className);
|
||||
if(isDirEmpty == true) {
|
||||
bool isDirectoryEmpty = QDir(pathForFolders).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot).isEmpty();
|
||||
if(isDirectoryEmpty == true) {
|
||||
// To clean things out after a deletion
|
||||
log("Main path is empty", className);
|
||||
cleanButtons();
|
||||
booksListForPathIndex.clear();
|
||||
directoryListCount = 0;
|
||||
|
@ -796,12 +796,12 @@ void localLibraryWidget::checkIfMainPathEmpty() {
|
|||
pagesNumber = 0;
|
||||
firstPageForBooks = 0;
|
||||
lastPageFolderCount = 0;
|
||||
mainPathAndItsEmpty = true;
|
||||
showToast("The library is empty");
|
||||
mainPathIsEmpty = true;
|
||||
showToast("Library is empty");
|
||||
return void();
|
||||
}
|
||||
else {
|
||||
mainPathAndItsEmpty = false;
|
||||
mainPathIsEmpty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -849,13 +849,11 @@ void localLibraryWidget::cleanButtons() {
|
|||
if(bookBtnArray[i]->isHidden() == false) {
|
||||
bookBtnArray[i]->hide();
|
||||
}
|
||||
// I like it with those empty lines, like empty book shelves
|
||||
/*
|
||||
|
||||
if(i < buttonsNumber) {
|
||||
if(lineArray[i]->isHidden() == false) {
|
||||
lineArray[i]->hide();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,9 +53,8 @@ public:
|
|||
int fileListCount;
|
||||
int directoryListCount;
|
||||
int completeItemsList;
|
||||
// if the path is set to /mnt/onboard/onboard/, and its empty, this will be true
|
||||
bool mainPathAndItsEmpty = false;
|
||||
|
||||
// If the path is set to '/mnt/onboard/onboard/', and it's empty, this will be true
|
||||
bool mainPathIsEmpty = false;
|
||||
|
||||
private slots:
|
||||
void setupDatabase();
|
||||
|
@ -80,7 +79,7 @@ private slots:
|
|||
void calculateMaximumPagesNumberForFolders();
|
||||
void calculateIndexForPage(int pageNumber);
|
||||
void goUpFunction();
|
||||
void checkIfMainPathEmpty();
|
||||
void checkIfMainPathIsEmpty();
|
||||
// Dir without "/" at the end and begining
|
||||
void changePathAndRefresh(QString directory);
|
||||
void refreshFolders();
|
||||
|
|
Loading…
Reference in a new issue