From 950411ef56c7681d6cd06c39aec742d972a0969b Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Wed, 16 Nov 2022 21:10:23 +0100 Subject: [PATCH] ResizableTextEdit: Force updating geometry Possible fix for --- src/CMakeLists.txt | 1 - src/context/contextview.cpp | 13 +++++++------ src/widgets/resizabletextedit.cpp | 8 ++++++++ src/widgets/resizabletextedit.h | 6 ++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6476227..ebdc9ba1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -446,7 +446,6 @@ set(HEADERS widgets/qsearchfield.h widgets/ratingwidget.h widgets/forcescrollperpixel.h - widgets/resizabletextedit.h osd/osdbase.h osd/osdpretty.h diff --git a/src/context/contextview.cpp b/src/context/contextview.cpp index 60ada0b8..2d206cb5 100644 --- a/src/context/contextview.cpp +++ b/src/context/contextview.cpp @@ -435,7 +435,7 @@ void ContextView::NoSong() { } textedit_top_->setFont(QFont(font_headline_, font_size_headline_ * 1.6)); - textedit_top_->setText(tr("No song playing")); + textedit_top_->SetText(tr("No song playing")); QString html; if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs()); @@ -470,9 +470,8 @@ void ContextView::UpdateFonts() { void ContextView::SetSong() { - textedit_top_->setFont(QFont(font_headline_, font_size_headline_)); - textedit_top_->setText(QString("%1
%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "
", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "
", true))); + textedit_top_->SetText(QString("%1
%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "
", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "
", true))); label_stop_summary_->clear(); @@ -586,7 +585,7 @@ void ContextView::SetSong() { } if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) { - textedit_play_lyrics_->setText(lyrics_); + textedit_play_lyrics_->SetText(lyrics_); textedit_play_lyrics_->show(); } else { @@ -601,7 +600,7 @@ void ContextView::SetSong() { void ContextView::UpdateSong(const Song &song) { - textedit_top_->setText(QString("%1
%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "
", true), Utilities::ReplaceMessage(summary_fmt_, song, "
", true))); + textedit_top_->SetText(QString("%1
%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "
", true), Utilities::ReplaceMessage(summary_fmt_, song, "
", true))); if (action_show_data_->isChecked()) { if (song.filetype() != song_playing_.filetype()) label_filetype_->setText(song.TextForFiletype()); @@ -657,6 +656,8 @@ void ContextView::UpdateSong(const Song &song) { song_playing_ = song; + widget_stacked_->updateGeometry(); + } void ContextView::ResetSong() { @@ -683,7 +684,7 @@ void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const lyrics_id_ = -1; if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) { - textedit_play_lyrics_->setText(lyrics_); + textedit_play_lyrics_->SetText(lyrics_); textedit_play_lyrics_->show(); } else { diff --git a/src/widgets/resizabletextedit.cpp b/src/widgets/resizabletextedit.cpp index 7c468481..67b5e318 100644 --- a/src/widgets/resizabletextedit.cpp +++ b/src/widgets/resizabletextedit.cpp @@ -43,3 +43,11 @@ void ResizableTextEdit::resizeEvent(QResizeEvent *e) { QTextEdit::resizeEvent(e); } + +void ResizableTextEdit::SetText(const QString &text) { + + QTextEdit::setText(text); + + updateGeometry(); + +} diff --git a/src/widgets/resizabletextedit.h b/src/widgets/resizabletextedit.h index 4454c84e..c648761d 100644 --- a/src/widgets/resizabletextedit.h +++ b/src/widgets/resizabletextedit.h @@ -25,14 +25,16 @@ class QResizeEvent; class ResizableTextEdit : public QTextEdit { - Q_OBJECT public: explicit ResizableTextEdit(QWidget *parent = nullptr); virtual QSize sizeHint() const override; -protected: + void setText(const QString &text) = delete; + void SetText(const QString &text); + + protected: virtual void resizeEvent(QResizeEvent *event) override; };