Skip to content

Commit 7c0e347

Browse files
committed
#1254 noteedit: only show small preview images after the image tag
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 92ba428 commit 7c0e347

File tree

6 files changed

+221
-318
lines changed

6 files changed

+221
-318
lines changed

CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
## 26.3.3
44

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))
5+
- Added small inline Markdown image previews in the note text edit with a new
6+
setting (enabled by default), supporting local files, remote http(s) image URLs,
7+
base64 `data:image/...` images, and Nextcloud `/core/preview` image URLs
8+
(for [#1254](https://github.com/pbek/QOwnNotes/issues/1254))
9+
- Inline Markdown image previews are currently only shown when no visible text
10+
follows the image tag on the same editor line, to avoid caret positioning
11+
mismatches after the image tag
912

1013
## 26.3.2
1114

src/dialogs/settingsdialog.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,6 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
178178
connect(ui->webAppServerUrlLineEdit, SIGNAL(textChanged(QString)), this, SLOT(needRestart()));
179179
connect(ui->webAppTokenLineEdit, SIGNAL(textChanged(QString)), this, SLOT(needRestart()));
180180

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);
189181
// connect(ui->layoutWidget, SIGNAL(settingsStored()),
190182
// this, SLOT(needRestart()));
191183

@@ -611,10 +603,6 @@ void SettingsDialog::storeSettings() {
611603
ui->hangingIndentCheckBox->isChecked());
612604
settings.setValue(QStringLiteral("Editor/showMarkdownImagePreviews"),
613605
ui->showMarkdownImagePreviewsCheckBox->isChecked());
614-
settings.setValue(QStringLiteral("Editor/markdownImagePreviewMaxWidth"),
615-
ui->markdownImagePreviewMaxWidthSpinBox->value());
616-
settings.setValue(QStringLiteral("Editor/markdownImagePreviewMaxHeight"),
617-
ui->markdownImagePreviewMaxHeightSpinBox->value());
618606
settings.setValue(QStringLiteral("Editor/editorWidthInDFMOnly"),
619607
ui->editorWidthInDFMOnlyCheckBox->isChecked());
620608
settings.setValue(QStringLiteral("Editor/vimMode"), ui->vimModeCheckBox->isChecked());
@@ -1011,15 +999,6 @@ void SettingsDialog::readSettings() {
1011999
settings.value(QStringLiteral("Editor/hangingIndent"), true).toBool());
10121000
ui->showMarkdownImagePreviewsCheckBox->setChecked(
10131001
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);
10231002
ui->editorWidthInDFMOnlyCheckBox->setChecked(
10241003
settings.value(QStringLiteral("Editor/editorWidthInDFMOnly"), true).toBool());
10251004
ui->vimModeCheckBox->setChecked(settings.value(QStringLiteral("Editor/vimMode")).toBool());

src/dialogs/settingsdialog.ui

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5664,6 +5664,13 @@ li.checked::marker { content: &quot;\2612&quot;; }
56645664
</property>
56655665
</widget>
56665666
</item>
5667+
<item row="10" column="0" colspan="4">
5668+
<widget class="QCheckBox" name="showMarkdownImagePreviewsCheckBox">
5669+
<property name="text">
5670+
<string>Show small Markdown preview images in the editor, if there is no text after the image</string>
5671+
</property>
5672+
</widget>
5673+
</item>
56675674
<item row="7" column="1">
56685675
<widget class="QSpinBox" name="cursorWidthSpinBox">
56695676
<property name="suffix">
@@ -5755,86 +5762,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
57555762
</layout>
57565763
</widget>
57575764
</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>
5832-
</item>
5833-
</layout>
5834-
</widget>
5835-
</item>
5836-
</layout>
5837-
</widget>
5765+
</layout>
5766+
</widget>
58385767
<widget class="QWidget" name="gitPage">
58395768
<layout class="QGridLayout" name="gridLayout_48">
58405769
<item row="5" column="1">

src/libraries/qlitehtml/src/container_qpainter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,6 @@ void DocumentContainerPrivate::load_image(const litehtml::tchar_t *src,
815815
const auto qtSrc = QString::fromUtf8(src);
816816
const auto qtBaseUrl = QString::fromUtf8(baseurl);
817817
Q_UNUSED(redraw_on_ready)
818-
qDebug() << "load_image:" << QStringLiteral("src = \"%1\";").arg(qtSrc).toUtf8().constData()
819-
<< QStringLiteral("base = \"%1\"").arg(qtBaseUrl).toUtf8().constData();
820818
const QUrl url = resolveUrl(qtSrc, qtBaseUrl);
821819
if (m_pixmaps.contains(url))
822820
return;

0 commit comments

Comments
 (0)