diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-02-28 10:31:16 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-02-28 12:11:51 +0100 |
| commit | 803559502dd1b330da39073cffa84278df403a88 (patch) | |
| tree | ce83d68cbe825ebe1bb400df1cc7fb74c66c4fc5 /src | |
| parent | c14d071e1e883891e96d908a1054929a291748ff (diff) | |
| download | kristall-803559502dd1b330da39073cffa84278df403a88.tar.gz | |
Add preference for centred H1
Also moves the 'enable text width' checkbox to next to the text width option, to save space.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dialogs/settingsdialog.cpp | 8 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.hpp | 2 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.ui | 51 | ||||
| -rw-r--r-- | src/documentstyle.cpp | 3 | ||||
| -rw-r--r-- | src/documentstyle.hpp | 2 | ||||
| -rw-r--r-- | src/renderers/geminirenderer.cpp | 2 |
6 files changed, 48 insertions, 20 deletions
diff --git a/src/dialogs/settingsdialog.cpp b/src/dialogs/settingsdialog.cpp index 4bd0f8c..b883970 100644 --- a/src/dialogs/settingsdialog.cpp +++ b/src/dialogs/settingsdialog.cpp @@ -134,6 +134,8 @@ void SettingsDialog::setGeminiStyle(DocumentStyle const &style) this->ui->enable_justify_text->setChecked(this->current_style.justify_text); + this->ui->enable_centre_h1->setChecked(this->current_style.centre_h1); + this->ui->enable_text_width->setChecked(this->current_style.text_width_enabled); this->ui->text_width->setEnabled(this->current_style.text_width_enabled); this->ui->text_width->setValue(this->current_style.text_width); @@ -535,6 +537,12 @@ void SettingsDialog::on_enable_justify_text_clicked(bool checked) this->reloadStylePreview(); } +void SettingsDialog::on_enable_centre_h1_clicked(bool checked) +{ + this->current_style.centre_h1 = checked; + this->reloadStylePreview(); +} + void SettingsDialog::on_enable_text_width_clicked(bool checked) { this->current_style.text_width_enabled = checked; diff --git a/src/dialogs/settingsdialog.hpp b/src/dialogs/settingsdialog.hpp index 114396e..c1ba1c3 100644 --- a/src/dialogs/settingsdialog.hpp +++ b/src/dialogs/settingsdialog.hpp @@ -87,6 +87,8 @@ private slots: void on_enable_text_width_clicked(bool arg1); + void on_enable_centre_h1_clicked(bool arg1); + void on_text_width_valueChanged(int value); void on_line_height_p_valueChanged(double arg1); diff --git a/src/dialogs/settingsdialog.ui b/src/dialogs/settingsdialog.ui index 04db3e2..6c0182d 100644 --- a/src/dialogs/settingsdialog.ui +++ b/src/dialogs/settingsdialog.ui @@ -1108,12 +1108,12 @@ </widget> </item> <item> - <widget class="QCheckBox" name="enable_text_width"> + <widget class="QCheckBox" name="enable_centre_h1"> <property name="text"> - <string>Enable text width limit</string> + <string>Centre first H1 </string> </property> <property name="toolTip"> - <string>Whether to limit the width of formatted text on the page or not.</string> + <string>Whether to centre the first top-level heading in the document.</string> </property> </widget> </item> @@ -1131,20 +1131,34 @@ </widget> </item> <item row="17" column="1"> - <widget class="QSpinBox" name="text_width"> - <property name="minimum"> - <number>300</number> - </property> - <property name="value"> - <number>900</number> - </property> - <property name="maximum"> - <number>2000</number> - </property> - <property name="suffix"> - <string> px</string> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_26"> + <item> + <widget class="QSpinBox" name="text_width"> + <property name="minimum"> + <number>300</number> + </property> + <property name="value"> + <number>900</number> + </property> + <property name="maximum"> + <number>2000</number> + </property> + <property name="suffix"> + <string> px</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="enable_text_width"> + <property name="text"> + <string>Enabled</string> + </property> + <property name="toolTip"> + <string>Whether to limit the width of formatted text on the page or not.</string> + </property> + </widget> + </item> + </layout> </item> <item row="18" column="0"> @@ -1574,8 +1588,9 @@ <tabstop>page_margin_h</tabstop> <tabstop>page_margin_v</tabstop> <tabstop>enable_justify_text</tabstop> - <tabstop>enable_text_width</tabstop> + <tabstop>enable_centre_h1</tabstop> <tabstop>text_width</tabstop> + <tabstop>enable_text_width</tabstop> <tabstop>line_height_p</tabstop> <tabstop>line_height_h</tabstop> <tabstop>indent_p</tabstop> diff --git a/src/documentstyle.cpp b/src/documentstyle.cpp index c74faba..c7d6696 100644 --- a/src/documentstyle.cpp +++ b/src/documentstyle.cpp @@ -146,6 +146,7 @@ DocumentStyle::DocumentStyle(bool do_init) : theme(Fixed), "lightblue", "magenta", "cyan", "white"}), justify_text(true), text_width_enabled(true), + centre_h1(false), line_height_p(5.0), line_height_h(5.0), indent_bq(1), indent_p(1), indent_h(0), indent_l(2), @@ -272,6 +273,7 @@ bool DocumentStyle::save(QSettings &settings) const settings.setValue("justify_text", justify_text); settings.setValue("text_width_enabled", text_width_enabled); + settings.setValue("centre_h1", centre_h1); settings.setValue("text_width", text_width); settings.setValue("line_height_p", line_height_p); settings.setValue("line_height_h", line_height_h); @@ -390,6 +392,7 @@ bool DocumentStyle::load(QSettings &settings) justify_text = settings.value("justify_text", justify_text).toBool(); text_width_enabled = settings.value("text_width_enabled", text_width_enabled).toBool(); + centre_h1 = settings.value("centre_h1", centre_h1).toBool(); text_width = settings.value("text_width", text_width).toInt(); line_height_p = settings.value("line_height_p", line_height_p).toDouble(); line_height_h = settings.value("line_height_h", line_height_h).toDouble(); diff --git a/src/documentstyle.hpp b/src/documentstyle.hpp index 7dad9fb..a960863 100644 --- a/src/documentstyle.hpp +++ b/src/documentstyle.hpp @@ -53,7 +53,7 @@ struct DocumentStyle QStringList ansi_colors; - bool justify_text, text_width_enabled; + bool justify_text, text_width_enabled, centre_h1; double line_height_p; double line_height_h; int indent_bq, indent_p, indent_h, indent_l; diff --git a/src/renderers/geminirenderer.cpp b/src/renderers/geminirenderer.cpp index c55e0e6..736cd68 100644 --- a/src/renderers/geminirenderer.cpp +++ b/src/renderers/geminirenderer.cpp @@ -51,7 +51,7 @@ std::unique_ptr<GeminiDocument> GeminiRenderer::render( QTextList *current_list = nullptr; bool blockquote = false; - bool centre_first_h1 = true; + bool centre_first_h1 = themed_style.centre_h1; outline.beginBuild(); |
