settings: Add 'Export highlights' option

This commit is contained in:
Nicolas Mailloux 2022-08-10 20:49:47 -04:00
parent 0874729550
commit fc8c2ea8b6
4 changed files with 258 additions and 206 deletions

View file

@ -322,14 +322,16 @@ namespace {
return quoteNumber; return quoteNumber;
return 0; return 0;
} }
void writeFile(QString filename, QString content) { bool writeFile(QString filename, QString content) {
QFile file(filename); QFile file(filename);
if(file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { if(file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
QTextStream stream(&file); QTextStream stream(&file);
stream << content; stream << content;
return true;
} }
else { else {
QString function = __func__; log(function + ": Failed to write string '" + content + "' to file '" + filename + "'", "functions"); QString function = __func__; log(function + ": Failed to write string '" + content + "' to file '" + filename + "'", "functions");
return false;
} }
} }
void string_writeconfig(std::string file, std::string config_option) { void string_writeconfig(std::string file, std::string config_option) {

View file

@ -43,6 +43,7 @@ settings::settings(QWidget *parent) :
ui->previousBtn->setProperty("type", "borderless"); ui->previousBtn->setProperty("type", "borderless");
ui->nextBtn->setProperty("type", "borderless"); ui->nextBtn->setProperty("type", "borderless");
ui->repackBtn->setProperty("type", "borderless"); ui->repackBtn->setProperty("type", "borderless");
ui->exportHighlightsBtn->setProperty("type", "borderless");
ui->label->setStyleSheet("font-size: 10.5pt; font-weight: bold"); ui->label->setStyleSheet("font-size: 10.5pt; font-weight: bold");
ui->okBtn->setStyleSheet("font-weight: bold"); ui->okBtn->setStyleSheet("font-weight: bold");
ui->aboutBtn->setStyleSheet("font-size: 9pt"); ui->aboutBtn->setStyleSheet("font-size: 9pt");
@ -57,6 +58,7 @@ settings::settings(QWidget *parent) :
ui->tzComboBox->setStyleSheet("font-size: 9pt"); ui->tzComboBox->setStyleSheet("font-size: 9pt");
ui->setPasscodeBtn->setStyleSheet("font-size: 9pt"); ui->setPasscodeBtn->setStyleSheet("font-size: 9pt");
ui->repackBtn->setStyleSheet("font-size: 9pt"); ui->repackBtn->setStyleSheet("font-size: 9pt");
ui->exportHighlightsBtn->setStyleSheet("font-size: 9pt");
ui->uiScaleNumberLabel->setStyleSheet("font-size: 9pt; font-weight: bold"); ui->uiScaleNumberLabel->setStyleSheet("font-size: 9pt; font-weight: bold");
ui->previousBtn->setText(""); ui->previousBtn->setText("");
@ -1027,3 +1029,10 @@ void settings::on_tzComboBox_currentTextChanged(const QString &arg1)
} }
} }
} }
void settings::on_exportHighlightsBtn_clicked()
{
QJsonObject jsonObject = readHighlightsDatabase();
writeFile("/mnt/onboard/onboard/highlights-" + QDateTime::currentDateTime().toString("dd-MM-yy_hh.mm.ss") + ".json", QJsonDocument(jsonObject).toJson());
showToast("Highlights exported successfully");
}

View file

@ -71,6 +71,7 @@ private slots:
void on_repackBtn_clicked(); void on_repackBtn_clicked();
void on_generateSystemReportBtn_clicked(); void on_generateSystemReportBtn_clicked();
void on_tzComboBox_currentTextChanged(const QString &arg1); void on_tzComboBox_currentTextChanged(const QString &arg1);
void on_exportHighlightsBtn_clicked();
signals: signals:
void showToast(QString messageToDisplay); void showToast(QString messageToDisplay);

View file

@ -98,50 +98,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="9" 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="21" 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="18" 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="10" column="0">
<widget class="QCheckBox" name="clockCheckBox">
<property name="text">
<string>Clock: Show seconds</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"> <item row="0" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="font"> <property name="font">
@ -155,6 +111,169 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="23" 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="12" column="0">
<widget class="QCheckBox" name="quoteCheckBox">
<property name="text">
<string>Disable authors quotes</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Storage</string>
</property>
</widget>
</item>
<item row="20" 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="2" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<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="1" column="0">
<widget class="QLabel" name="wordsNumberLabel">
<property name="text">
<string>Words number/page (plain text files)</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="wordsNumber">
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="value">
<number>20</number>
</property>
</widget>
</item>
</layout>
</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>Networking</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="4" column="0"> <item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_9"> <layout class="QGridLayout" name="gridLayout_9">
<property name="bottomMargin"> <property name="bottomMargin">
@ -226,7 +345,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="font"> <property name="font">
<font> <font>
@ -239,6 +358,23 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property>
</widget>
</item>
<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="5" column="0"> <item row="5" column="0">
<widget class="QCheckBox" name="globalReadingSettingsCheckBox"> <widget class="QCheckBox" name="globalReadingSettingsCheckBox">
<property name="text"> <property name="text">
@ -246,93 +382,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="10" column="0">
<layout class="QGridLayout" name="gridLayout_6"> <widget class="Line" name="line_6">
<property name="bottomMargin"> <property name="frameShadow">
<number>0</number> <enum>QFrame::Plain</enum>
</property> </property>
<item row="1" column="1"> <property name="orientation">
<spacer name="horizontalSpacer_5"> <enum>Qt::Horizontal</enum>
<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="1" column="0">
<widget class="QLabel" name="wordsNumberLabel">
<property name="text">
<string>Words number/page (plain text files)</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="wordsNumber">
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="value">
<number>20</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="22" 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="12" column="0">
<widget class="QCheckBox" name="demoCheckBox">
<property name="text">
<string>Disable &quot;Welcome to InkBox&quot; message</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -346,59 +402,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="17" column="0"> <item row="19" column="0">
<widget class="QLabel" name="label_5"> <widget class="Line" name="line_7">
<property name="font"> <property name="frameShadow">
<font> <enum>QFrame::Plain</enum>
<family>Chivo</family>
<italic>true</italic>
</font>
</property> </property>
<property name="text"> <property name="orientation">
<string>Storage</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="19" 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"> <item row="7" column="0">
<widget class="QCheckBox" name="menuBarCheckBox"> <widget class="QCheckBox" name="menuBarCheckBox">
<property name="text"> <property name="text">
@ -406,25 +419,25 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="20" column="0"> <item row="6" column="0">
<widget class="QLabel" name="label_3"> <widget class="QCheckBox" name="readerScrollBarCheckBox">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text"> <property name="text">
<string>Networking</string> <string>Show scroll bar if needed</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="24" column="0">
<widget class="QCheckBox" name="quoteCheckBox"> <spacer name="verticalSpacer">
<property name="text"> <property name="orientation">
<string>Disable authors quotes</string> <enum>Qt::Vertical</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_15"> <layout class="QGridLayout" name="gridLayout_15">
@ -493,18 +506,45 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="23" column="0"> <item row="8" column="0">
<spacer name="verticalSpacer"> <layout class="QGridLayout" name="gridLayout_16">
<property name="orientation"> <property name="bottomMargin">
<enum>Qt::Vertical</enum> <number>0</number>
</property> </property>
<property name="sizeHint" stdset="0"> <item row="0" column="0">
<size> <widget class="QLabel" name="exportHighlightsLabel">
<width>20</width> <property name="text">
<height>40</height> <string>Export highlights</string>
</size> </property>
</property> </widget>
</spacer> </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>
</layout> </layout>
</item> </item>