Skip to content

Commit 92ba428

Browse files
committed
#1254 noteedit: try to implement inline images
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent fd6ec54 commit 92ba428

File tree

7 files changed

+449
-17
lines changed

7 files changed

+449
-17
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# QOwnNotes Changelog
22

3+
## 26.3.3
4+
5+
- Added inline Markdown image previews in the note text edit with a new setting
6+
`Show Markdown images inline in editor` (enabled by default), supporting local
7+
files, remote http(s) image URLs, base64 `data:image/...` images, and Nextcloud
8+
`/core/preview` image URLs (for [#1254](https://github.com/pbek/QOwnNotes/issues/1254))
9+
310
## 26.3.2
411

512
- Moved the setting for hanging indentation in wrapped Markdown list items to the

src/build_number.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define BUILD 1275
1+
#define BUILD 1276

src/dialogs/settingsdialog.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
177177
connect(ui->aiAutocompleteCheckBox, SIGNAL(toggled(bool)), this, SLOT(needRestart()));
178178
connect(ui->webAppServerUrlLineEdit, SIGNAL(textChanged(QString)), this, SLOT(needRestart()));
179179
connect(ui->webAppTokenLineEdit, SIGNAL(textChanged(QString)), this, SLOT(needRestart()));
180+
181+
connect(ui->showMarkdownImagePreviewsCheckBox, &QCheckBox::toggled,
182+
ui->markdownImagePreviewMaxWidthLabel, &QWidget::setEnabled);
183+
connect(ui->showMarkdownImagePreviewsCheckBox, &QCheckBox::toggled,
184+
ui->markdownImagePreviewMaxWidthSpinBox, &QWidget::setEnabled);
185+
connect(ui->showMarkdownImagePreviewsCheckBox, &QCheckBox::toggled,
186+
ui->markdownImagePreviewMaxHeightLabel, &QWidget::setEnabled);
187+
connect(ui->showMarkdownImagePreviewsCheckBox, &QCheckBox::toggled,
188+
ui->markdownImagePreviewMaxHeightSpinBox, &QWidget::setEnabled);
180189
// connect(ui->layoutWidget, SIGNAL(settingsStored()),
181190
// this, SLOT(needRestart()));
182191

@@ -600,6 +609,12 @@ void SettingsDialog::storeSettings() {
600609
ui->highlightCurrentLineCheckBox->isChecked());
601610
settings.setValue(QStringLiteral("Editor/hangingIndent"),
602611
ui->hangingIndentCheckBox->isChecked());
612+
settings.setValue(QStringLiteral("Editor/showMarkdownImagePreviews"),
613+
ui->showMarkdownImagePreviewsCheckBox->isChecked());
614+
settings.setValue(QStringLiteral("Editor/markdownImagePreviewMaxWidth"),
615+
ui->markdownImagePreviewMaxWidthSpinBox->value());
616+
settings.setValue(QStringLiteral("Editor/markdownImagePreviewMaxHeight"),
617+
ui->markdownImagePreviewMaxHeightSpinBox->value());
603618
settings.setValue(QStringLiteral("Editor/editorWidthInDFMOnly"),
604619
ui->editorWidthInDFMOnlyCheckBox->isChecked());
605620
settings.setValue(QStringLiteral("Editor/vimMode"), ui->vimModeCheckBox->isChecked());
@@ -994,6 +1009,17 @@ void SettingsDialog::readSettings() {
9941009
settings.value(QStringLiteral("Editor/highlightCurrentLine"), true).toBool());
9951010
ui->hangingIndentCheckBox->setChecked(
9961011
settings.value(QStringLiteral("Editor/hangingIndent"), true).toBool());
1012+
ui->showMarkdownImagePreviewsCheckBox->setChecked(
1013+
settings.value(QStringLiteral("Editor/showMarkdownImagePreviews"), true).toBool());
1014+
ui->markdownImagePreviewMaxWidthSpinBox->setValue(
1015+
settings.value(QStringLiteral("Editor/markdownImagePreviewMaxWidth"), 1024).toInt());
1016+
ui->markdownImagePreviewMaxHeightSpinBox->setValue(
1017+
settings.value(QStringLiteral("Editor/markdownImagePreviewMaxHeight"), 1024).toInt());
1018+
const bool inlineImagePreviewEnabled = ui->showMarkdownImagePreviewsCheckBox->isChecked();
1019+
ui->markdownImagePreviewMaxWidthLabel->setEnabled(inlineImagePreviewEnabled);
1020+
ui->markdownImagePreviewMaxWidthSpinBox->setEnabled(inlineImagePreviewEnabled);
1021+
ui->markdownImagePreviewMaxHeightLabel->setEnabled(inlineImagePreviewEnabled);
1022+
ui->markdownImagePreviewMaxHeightSpinBox->setEnabled(inlineImagePreviewEnabled);
9971023
ui->editorWidthInDFMOnlyCheckBox->setChecked(
9981024
settings.value(QStringLiteral("Editor/editorWidthInDFMOnly"), true).toBool());
9991025
ui->vimModeCheckBox->setChecked(settings.value(QStringLiteral("Editor/vimMode")).toBool());

src/dialogs/settingsdialog.ui

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,12 +5698,12 @@ li.checked::marker { content: &quot;\2612&quot;; }
56985698
</layout>
56995699
</widget>
57005700
</item>
5701-
<item row="2" column="0">
5702-
<widget class="QGroupBox" name="groupBox_36">
5703-
<property name="title">
5704-
<string>Tabs and Indents</string>
5705-
</property>
5706-
<layout class="QGridLayout" name="gridLayout_74">
5701+
<item row="2" column="0">
5702+
<widget class="QGroupBox" name="groupBox_36">
5703+
<property name="title">
5704+
<string>Tabs and Indents</string>
5705+
</property>
5706+
<layout class="QGridLayout" name="gridLayout_74">
57075707
<item row="0" column="0">
57085708
<layout class="QGridLayout" name="gridLayout_73">
57095709
<item row="0" column="0" colspan="3">
@@ -5743,18 +5743,96 @@ li.checked::marker { content: &quot;\2612&quot;; }
57435743
</property>
57445744
</spacer>
57455745
</item>
5746-
<item row="2" column="0" colspan="3">
5747-
<widget class="QCheckBox" name="hangingIndentCheckBox">
5748-
<property name="text">
5749-
<string>Enable hanging indentation for Markdown lists</string>
5750-
</property>
5751-
</widget>
5752-
</item>
5753-
</layout>
5746+
<item row="2" column="0" colspan="3">
5747+
<widget class="QCheckBox" name="hangingIndentCheckBox">
5748+
<property name="text">
5749+
<string>Enable hanging indentation for Markdown lists</string>
5750+
</property>
5751+
</widget>
5752+
</item>
5753+
</layout>
5754+
</item>
5755+
</layout>
5756+
</widget>
5757+
</item>
5758+
<item row="3" column="0">
5759+
<widget class="QGroupBox" name="inlineImagePreviewGroupBox">
5760+
<property name="title">
5761+
<string>Inline Image Previews</string>
5762+
</property>
5763+
<layout class="QGridLayout" name="gridLayout_inlineImagePreview">
5764+
<property name="topMargin">
5765+
<number>18</number>
5766+
</property>
5767+
<item row="1" column="0" colspan="3">
5768+
<widget class="QCheckBox" name="showMarkdownImagePreviewsCheckBox">
5769+
<property name="text">
5770+
<string>Show Markdown images in the editor</string>
5771+
</property>
5772+
</widget>
5773+
</item>
5774+
<item row="2" column="0">
5775+
<widget class="QLabel" name="markdownImagePreviewMaxWidthLabel">
5776+
<property name="text">
5777+
<string>Maximum preview width:</string>
5778+
</property>
5779+
</widget>
5780+
</item>
5781+
<item row="2" column="1">
5782+
<widget class="QSpinBox" name="markdownImagePreviewMaxWidthSpinBox">
5783+
<property name="minimum">
5784+
<number>64</number>
5785+
</property>
5786+
<property name="maximum">
5787+
<number>4096</number>
5788+
</property>
5789+
<property name="value">
5790+
<number>1024</number>
5791+
</property>
5792+
<property name="suffix">
5793+
<string> px</string>
5794+
</property>
5795+
</widget>
5796+
</item>
5797+
<item row="2" column="2">
5798+
<spacer name="horizontalSpacer_inlineImagePreview1">
5799+
<property name="orientation">
5800+
<enum>Qt::Orientation::Horizontal</enum>
5801+
</property>
5802+
<property name="sizeHint" stdset="0">
5803+
<size>
5804+
<width>40</width>
5805+
<height>20</height>
5806+
</size>
5807+
</property>
5808+
</spacer>
5809+
</item>
5810+
<item row="3" column="0">
5811+
<widget class="QLabel" name="markdownImagePreviewMaxHeightLabel">
5812+
<property name="text">
5813+
<string>Maximum preview height:</string>
5814+
</property>
5815+
</widget>
5816+
</item>
5817+
<item row="3" column="1">
5818+
<widget class="QSpinBox" name="markdownImagePreviewMaxHeightSpinBox">
5819+
<property name="minimum">
5820+
<number>64</number>
5821+
</property>
5822+
<property name="maximum">
5823+
<number>4096</number>
5824+
</property>
5825+
<property name="value">
5826+
<number>1024</number>
5827+
</property>
5828+
<property name="suffix">
5829+
<string> px</string>
5830+
</property>
5831+
</widget>
57545832
</item>
57555833
</layout>
57565834
</widget>
5757-
</item>
5835+
</item>
57585836
</layout>
57595837
</widget>
57605838
<widget class="QWidget" name="gitPage">

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define VERSION "26.3.2"
1+
#define VERSION "26.3.3"

0 commit comments

Comments
 (0)