mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08:00
Working better
Also, I fixed a dictionnary lookup issue where searching words in all caps was impossible.
This commit is contained in:
parent
f1c18bada5
commit
dbd23cb33a
2 changed files with 37 additions and 41 deletions
|
@ -304,5 +304,8 @@ namespace {
|
||||||
global::kobox::resetKoboxUserDataBool = true;
|
global::kobox::resetKoboxUserDataBool = true;
|
||||||
reboot(true);
|
reboot(true);
|
||||||
}
|
}
|
||||||
|
void setDefaultWorkDir() {
|
||||||
|
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // FUNCTIONS_H
|
#endif // FUNCTIONS_H
|
||||||
|
|
75
reader.cpp
75
reader.cpp
|
@ -248,6 +248,7 @@ reader::reader(QWidget *parent) :
|
||||||
if(ui->text->hasSelectedText() == true) {
|
if(ui->text->hasSelectedText() == true) {
|
||||||
if(selected_text_lock == false) {
|
if(selected_text_lock == false) {
|
||||||
selected_text_lock = true;
|
selected_text_lock = true;
|
||||||
|
selected_text = selected_text.toLower();
|
||||||
QStringList parts = selected_text.split(' ', QString::SkipEmptyParts);
|
QStringList parts = selected_text.split(' ', QString::SkipEmptyParts);
|
||||||
for (int i = 0; i < parts.size(); ++i)
|
for (int i = 0; i < parts.size(); ++i)
|
||||||
parts[i].replace(0, 1, parts[i][0].toUpper());
|
parts[i].replace(0, 1, parts[i][0].toUpper());
|
||||||
|
@ -317,11 +318,11 @@ reader::reader(QWidget *parent) :
|
||||||
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
|
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
|
||||||
|
|
||||||
if(book_file != "") {
|
if(book_file != "") {
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
setDefaultWorkDir();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// User clicked "Cancel" button
|
// User clicked "Cancel" button
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
setDefaultWorkDir();
|
||||||
quit_restart();
|
quit_restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,11 +338,11 @@ reader::reader(QWidget *parent) :
|
||||||
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
|
book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath());
|
||||||
|
|
||||||
if(book_file != "") {
|
if(book_file != "") {
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
setDefaultWorkDir();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// User clicked "Cancel" button
|
// User clicked "Cancel" button
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
setDefaultWorkDir();
|
||||||
quit_restart();
|
quit_restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,12 +361,15 @@ reader::reader(QWidget *parent) :
|
||||||
// Retrieve split_total from tmpfs
|
// Retrieve split_total from tmpfs
|
||||||
string_checkconfig("/tmp/inkboxPageNumber");
|
string_checkconfig("/tmp/inkboxPageNumber");
|
||||||
split_total = checkconfig_str_val.toInt();
|
split_total = checkconfig_str_val.toInt();
|
||||||
|
qDebug() << "been there too";
|
||||||
setup_book(book_file, 0, true);
|
setup_book(book_file, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get text
|
// Get text; no need to do it multiple times for ePUB books
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
if(is_epub != true) {
|
||||||
setup_book(book_file, split_total, true);
|
setDefaultWorkDir();
|
||||||
|
setup_book(book_file, split_total, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Display text
|
// Display text
|
||||||
// Checking saved font size if any
|
// Checking saved font size if any
|
||||||
|
@ -526,8 +530,8 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
||||||
|
|
||||||
if(filematch_ran != true) {
|
if(filematch_ran != true) {
|
||||||
if(epub_file_match(book) == true) {
|
if(epub_file_match(book) == true) {
|
||||||
QFile::remove("/mutool_rootfs/run/book.epub");
|
QFile::remove("/run/book.epub");
|
||||||
QFile::copy(book, "/mutool_rootfs/run/book.epub");
|
QFile::copy(book, "/run/book.epub");
|
||||||
|
|
||||||
// Parsing ePUBs with `mutool'
|
// Parsing ePUBs with `mutool'
|
||||||
QString epubProg ("sh");
|
QString epubProg ("sh");
|
||||||
|
@ -540,7 +544,6 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
||||||
|
|
||||||
filematch_ran = true;
|
filematch_ran = true;
|
||||||
is_epub = true;
|
is_epub = true;
|
||||||
qDebug() << "Initial parser ran.";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// This is likely not an ePUB.
|
// This is likely not an ePUB.
|
||||||
|
@ -554,7 +557,7 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
||||||
|
|
||||||
// Checking whether the user has defined an option for the number of words per page; if not, then setting the default.
|
// Checking whether the user has defined an option for the number of words per page; if not, then setting the default.
|
||||||
// NOTE: This is only for plain text files.
|
// NOTE: This is only for plain text files.
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
setDefaultWorkDir();
|
||||||
string_checkconfig(".config/07-words_number/config");
|
string_checkconfig(".config/07-words_number/config");
|
||||||
if(checkconfig_str_val == "") {
|
if(checkconfig_str_val == "") {
|
||||||
string_writeconfig(".config/07-words_number/config", "100");
|
string_writeconfig(".config/07-words_number/config", "100");
|
||||||
|
@ -564,38 +567,32 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
||||||
// Parsing file
|
// Parsing file
|
||||||
if(is_epub == true) {
|
if(is_epub == true) {
|
||||||
if(run_parser == true) {
|
if(run_parser == true) {
|
||||||
QString epubProg ("sh");
|
if(filematch_ran != false) {
|
||||||
QStringList epubArgs;
|
QString epubProg ("sh");
|
||||||
convertMuPdfVars();
|
QStringList epubArgs;
|
||||||
epubArgs << "/mnt/onboard/.adds/inkbox/epub.sh" << mupdf::fontSize_qstr << mupdf::width_qstr << mupdf::height_qstr << mupdf::epubPageNumber_qstr;
|
convertMuPdfVars();
|
||||||
QProcess *epubProc = new QProcess();
|
epubArgs << "/mnt/onboard/.adds/inkbox/epub.sh" << mupdf::fontSize_qstr << mupdf::width_qstr << mupdf::height_qstr << mupdf::epubPageNumber_qstr;
|
||||||
epubProc->start(epubProg, epubArgs);
|
QProcess *epubProc = new QProcess();
|
||||||
epubProc->waitForFinished();
|
epubProc->start(epubProg, epubArgs);
|
||||||
|
epubProc->waitForFinished();
|
||||||
qDebug() << "Standard parser ran.";
|
}
|
||||||
|
else {
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(parser_ran != true) {
|
QString parse_prog ("python3");
|
||||||
QString parse_prog ("python3");
|
QStringList parse_args;
|
||||||
QStringList parse_args;
|
parse_args << "split-txt.py" << checkconfig_str_val;
|
||||||
parse_args << "split-txt.py" << checkconfig_str_val;
|
QProcess *parse_proc = new QProcess();
|
||||||
QProcess *parse_proc = new QProcess();
|
parse_proc->start(parse_prog, parse_args);
|
||||||
parse_proc->start(parse_prog, parse_args);
|
parse_proc->waitForFinished();
|
||||||
parse_proc->waitForFinished();
|
|
||||||
parser_ran = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changing current working directory
|
|
||||||
QDir::setCurrent("/inkbox/book");
|
|
||||||
|
|
||||||
// Reading files
|
// Reading files
|
||||||
if(is_epub != true) {
|
if(is_epub != true) {
|
||||||
if(run_parser == true) {
|
if(run_parser == true) {
|
||||||
|
@ -606,12 +603,11 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
||||||
content << f.readAll();
|
content << f.readAll();
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
ittext = content[i];
|
||||||
return content.size();
|
return content.size();
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ittext = content[i];
|
ittext = content[i];
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -621,7 +617,6 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
||||||
epubPageContent = in.readAll();
|
epubPageContent = in.readAll();
|
||||||
epubPage.close();
|
epubPage.close();
|
||||||
qDebug() << epubPageContent;
|
qDebug() << epubPageContent;
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -674,7 +669,7 @@ void reader::dictionary_lookup(string word, QString first_letter, int position)
|
||||||
}
|
}
|
||||||
definition_file.close();
|
definition_file.close();
|
||||||
|
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
setDefaultWorkDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reader::save_word(string word, bool remove) {
|
void reader::save_word(string word, bool remove) {
|
||||||
|
@ -706,7 +701,6 @@ void reader::on_nextBtn_clicked()
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
QMessageBox::critical(this, tr("Invalid argument"), tr("You've reached the end of the document."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parser_ran = true;
|
|
||||||
split_total = split_total - 1;
|
split_total = split_total - 1;
|
||||||
|
|
||||||
setup_book(book_file, split_total, false);
|
setup_book(book_file, split_total, false);
|
||||||
|
@ -738,7 +732,6 @@ void reader::on_previousBtn_clicked()
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
|
QMessageBox::critical(this, tr("Invalid argument"), tr("No previous page."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parser_ran = true;
|
|
||||||
split_total = split_total + 1;
|
split_total = split_total + 1;
|
||||||
setup_book(book_file, split_total, false);
|
setup_book(book_file, split_total, false);
|
||||||
ui->text->setText("");
|
ui->text->setText("");
|
||||||
|
|
Loading…
Reference in a new issue