ResizableTextEdit: Force updating geometry

Possible fix for
This commit is contained in:
Jonas Kvinge 2022-11-16 21:10:23 +01:00
parent cb9cf084c0
commit 950411ef56
4 changed files with 19 additions and 9 deletions

View File

@ -446,7 +446,6 @@ set(HEADERS
widgets/qsearchfield.h widgets/qsearchfield.h
widgets/ratingwidget.h widgets/ratingwidget.h
widgets/forcescrollperpixel.h widgets/forcescrollperpixel.h
widgets/resizabletextedit.h
osd/osdbase.h osd/osdbase.h
osd/osdpretty.h osd/osdpretty.h

View File

@ -435,7 +435,7 @@ void ContextView::NoSong() {
} }
textedit_top_->setFont(QFont(font_headline_, font_size_headline_ * 1.6)); 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; QString html;
if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs()); if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs());
@ -470,9 +470,8 @@ void ContextView::UpdateFonts() {
void ContextView::SetSong() { void ContextView::SetSong() {
textedit_top_->setFont(QFont(font_headline_, font_size_headline_)); textedit_top_->setFont(QFont(font_headline_, font_size_headline_));
textedit_top_->setText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "<br />", true))); textedit_top_->SetText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "<br />", true)));
label_stop_summary_->clear(); label_stop_summary_->clear();
@ -586,7 +585,7 @@ void ContextView::SetSong() {
} }
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) { if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
textedit_play_lyrics_->setText(lyrics_); textedit_play_lyrics_->SetText(lyrics_);
textedit_play_lyrics_->show(); textedit_play_lyrics_->show();
} }
else { else {
@ -601,7 +600,7 @@ void ContextView::SetSong() {
void ContextView::UpdateSong(const Song &song) { void ContextView::UpdateSong(const Song &song) {
textedit_top_->setText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song, "<br />", true))); textedit_top_->SetText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song, "<br />", true)));
if (action_show_data_->isChecked()) { if (action_show_data_->isChecked()) {
if (song.filetype() != song_playing_.filetype()) label_filetype_->setText(song.TextForFiletype()); if (song.filetype() != song_playing_.filetype()) label_filetype_->setText(song.TextForFiletype());
@ -657,6 +656,8 @@ void ContextView::UpdateSong(const Song &song) {
song_playing_ = song; song_playing_ = song;
widget_stacked_->updateGeometry();
} }
void ContextView::ResetSong() { void ContextView::ResetSong() {
@ -683,7 +684,7 @@ void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const
lyrics_id_ = -1; lyrics_id_ = -1;
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) { if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
textedit_play_lyrics_->setText(lyrics_); textedit_play_lyrics_->SetText(lyrics_);
textedit_play_lyrics_->show(); textedit_play_lyrics_->show();
} }
else { else {

View File

@ -43,3 +43,11 @@ void ResizableTextEdit::resizeEvent(QResizeEvent *e) {
QTextEdit::resizeEvent(e); QTextEdit::resizeEvent(e);
} }
void ResizableTextEdit::SetText(const QString &text) {
QTextEdit::setText(text);
updateGeometry();
}

View File

@ -25,14 +25,16 @@
class QResizeEvent; class QResizeEvent;
class ResizableTextEdit : public QTextEdit { class ResizableTextEdit : public QTextEdit {
Q_OBJECT
public: public:
explicit ResizableTextEdit(QWidget *parent = nullptr); explicit ResizableTextEdit(QWidget *parent = nullptr);
virtual QSize sizeHint() const override; virtual QSize sizeHint() const override;
protected: void setText(const QString &text) = delete;
void SetText(const QString &text);
protected:
virtual void resizeEvent(QResizeEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override;
}; };