mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Highlighting: Fixes
This commit is contained in:
parent
636a9eb97a
commit
058e975919
4 changed files with 25 additions and 17 deletions
|
@ -81,7 +81,8 @@
|
|||
<file>resources/arrow-right.png</file>
|
||||
<file>resources/file-text.png</file>
|
||||
<file>resources/pin.png</file>
|
||||
<file>resources/highlight.png</file>
|
||||
<file>resources/unhighlight.png</file>
|
||||
<file>resources/highlight.png</file>
|
||||
<file>resources/unhighlight.png</file>
|
||||
<file>resources/view-highlights.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1041,7 +1041,7 @@ namespace {
|
|||
QJsonObject mainJsonObject;
|
||||
QJsonObject firstJsonObject;
|
||||
firstJsonObject.insert("BookPath", QJsonValue(bookPath));
|
||||
firstJsonObject.insert("Text1", QJsonValue(text));
|
||||
firstJsonObject.insert("T-" + QUuid::createUuid().toString(QUuid::WithoutBraces), QJsonValue(text));
|
||||
mainJsonObject["Book1"] = firstJsonObject;
|
||||
writeHighlightsDatabase(mainJsonObject);
|
||||
}
|
||||
|
@ -1051,30 +1051,23 @@ namespace {
|
|||
int length = jsonObject.length();
|
||||
for(int i = 1; i <= length; i++) {
|
||||
if(jsonObject["Book" + QString::number(i)].toObject().value("BookPath").toString() == bookPath) {
|
||||
log("highlightBookText: Found existing book with path '" + bookPath + "'", "functions");
|
||||
int keyCount = 0;
|
||||
// Counting number of highlights for book
|
||||
foreach(const QString& key, jsonObject["Book" + QString::number(i)].toObject().keys()) {
|
||||
keyCount++;
|
||||
}
|
||||
// First key is 'BookPath'
|
||||
int highlightsCount = keyCount - 1;
|
||||
int currentHighlightPosition = highlightsCount + 1;
|
||||
log("highlightBookText: Found existing book in database with path '" + bookPath + "'", "functions");
|
||||
|
||||
// Insert highlight
|
||||
QJsonObject highlightJsonObject = jsonObject["Book" + QString::number(i)].toObject();
|
||||
// Finding available slot for highlight in case the one we are looking for is already occupied
|
||||
if(highlightJsonObject.contains("Text" + QString::number(currentHighlightPosition))) {
|
||||
QString uuid = "T-"+ QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||
if(highlightJsonObject.contains(uuid)) {
|
||||
while(true) {
|
||||
if(highlightJsonObject.contains("Text" + QString::number(currentHighlightPosition))) {
|
||||
currentHighlightPosition++;
|
||||
if(highlightJsonObject.contains(uuid)) {
|
||||
uuid = "T-" + QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
highlightJsonObject.insert("Text" + QString::number(currentHighlightPosition), text);
|
||||
highlightJsonObject.insert(uuid, text);
|
||||
jsonObject["Book" + QString::number(i)] = highlightJsonObject;
|
||||
|
||||
writeHighlightsDatabase(jsonObject);
|
||||
|
@ -1083,9 +1076,10 @@ namespace {
|
|||
}
|
||||
|
||||
if(highlightWrote == false) {
|
||||
// This block of code is called when the book is referenced in the database, but no highlights are currently indexed
|
||||
QJsonObject bookJsonObject;
|
||||
bookJsonObject.insert("BookPath", QJsonValue(bookPath));
|
||||
bookJsonObject.insert("Text1", QJsonValue(text));
|
||||
bookJsonObject.insert("T-" + QUuid::createUuid().toString(QUuid::WithoutBraces), QJsonValue(text));
|
||||
jsonObject["Book" + QString::number(length + 1)] = bookJsonObject;
|
||||
|
||||
writeHighlightsDatabase(jsonObject);
|
||||
|
|
|
@ -72,6 +72,7 @@ reader::reader(QWidget *parent) :
|
|||
ui->increaseScaleBtn->setProperty("type", "borderless");
|
||||
ui->decreaseScaleBtn->setProperty("type", "borderless");
|
||||
ui->quitBtn->setProperty("type", "borderless");
|
||||
ui->viewHighlightsBtn->setProperty("type", "borderless");
|
||||
|
||||
// Icons
|
||||
ui->alignLeftBtn->setText("");
|
||||
|
@ -112,6 +113,8 @@ reader::reader(QWidget *parent) :
|
|||
ui->optionsBtn->setIcon(QIcon(":/resources/settings.png"));
|
||||
ui->nextBtn->setText("");
|
||||
ui->nextBtn->setIcon(QIcon(":/resources/arrow-right.png"));
|
||||
ui->viewHighlightsBtn->setText("");
|
||||
ui->viewHighlightsBtn->setIcon(QIcon(":/resources/view-highlights.png"));
|
||||
|
||||
// On the Mini with QT_FONT_DPI set to 187 (default for this device), quitBtn makes the UI go beyond the limits of the screen when the menu bar is shown
|
||||
if(global::deviceID == "n705\n") {
|
||||
|
@ -316,6 +319,7 @@ reader::reader(QWidget *parent) :
|
|||
ui->fontChooser->setStyleSheet("font-size: 9pt");
|
||||
ui->gotoBtn->setStyleSheet("font-size: 9pt; padding: 9px; font-weight: bold; background: lightGrey");
|
||||
ui->pageNumberLabel->setFont(QFont("Source Serif Pro"));
|
||||
ui->viewHighlightsBtn->setStyleSheet("padding: 9px");
|
||||
|
||||
// Hiding the menubar + definition widget + brightness widget + buttons bar widget
|
||||
ui->menuWidget->setVisible(false);
|
||||
|
@ -536,11 +540,19 @@ reader::reader(QWidget *parent) :
|
|||
else if(is_pdf == true) {
|
||||
ui->text->hide();
|
||||
ui->text->deleteLater();
|
||||
ui->line_20->hide();
|
||||
ui->line_20->deleteLater();
|
||||
ui->viewHighlightsBtn->hide();
|
||||
ui->viewHighlightsBtn->deleteLater();
|
||||
setupPng();
|
||||
}
|
||||
else if(is_image == true) {
|
||||
ui->text->hide();
|
||||
ui->text->deleteLater();
|
||||
ui->line_20->hide();
|
||||
ui->line_20->deleteLater();
|
||||
ui->viewHighlightsBtn->hide();
|
||||
ui->viewHighlightsBtn->deleteLater();
|
||||
setupPng();
|
||||
}
|
||||
else {
|
||||
|
@ -1437,6 +1449,7 @@ void reader::alignAndHighlightText(int alignment) {
|
|||
// Highlight
|
||||
QString htmlText = ui->text->toHtml();
|
||||
QJsonObject jsonObject = getHighlightsForBook(book_file);
|
||||
qDebug() << jsonObject;
|
||||
int keyCount = 1;
|
||||
foreach(const QString& key, jsonObject.keys()) {
|
||||
if(keyCount <= 1) {
|
||||
|
|
BIN
src/resources/view-highlights.png
Normal file
BIN
src/resources/view-highlights.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
Loading…
Reference in a new issue