From 6eea5688a8effe0551d7d60bb2ee73daec973adb Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm Date: Fri, 6 Mar 2026 11:36:39 +0100 Subject: [PATCH] Small ui improvements --- CMakeLists.txt | 1 + src/MainWindow.cpp | 6 +- src/MainWindow.ui | 718 ++++++++++++++++++++++---------------------- src/elidedlabel.cpp | 70 +++++ src/elidedlabel.h | 32 ++ 5 files changed, 467 insertions(+), 360 deletions(-) create mode 100644 src/elidedlabel.cpp create mode 100644 src/elidedlabel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a808f1..58cc8af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME} src/clickableslider.cpp ${MusicGeneratorGUI_H} res/resources.qrc + src/elidedlabel.h src/elidedlabel.cpp ) # UI file diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 0ce0b14..6888b41 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -89,6 +89,8 @@ MainWindow::MainWindow(QWidget *parent) ui->songListView->setCurrentIndex(firstIndex); } + ui->nowPlayingLabel->setText("Now Playing:"); + currentSong = songModel->getSong(0); } @@ -426,7 +428,7 @@ void MainWindow::songGenerated(const SongItem& song) { generatedSongQueue.enqueue(song); } - ui->statusLabel->setText("idle"); + ui->statusbar->showMessage("idle"); ensureSongsInQueue(); } @@ -530,7 +532,7 @@ void MainWindow::ensureSongsInQueue(bool enqeueCurrent) isGeneratingNext = true; - ui->statusLabel->setText("Generateing: "+nextSong.caption); + ui->statusbar->showMessage("Generateing: "+nextSong.caption); aceStepWorker->generateSong(nextSong, jsonTemplate, aceStepPath, qwen3ModelPath, textEncoderModelPath, ditModelPath, diff --git a/src/MainWindow.ui b/src/MainWindow.ui index d67fb70..828189b 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -1,359 +1,361 @@ - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - Aceradio - - - - :/icons/xyz.uvos.aceradio.png:/icons/xyz.uvos.aceradio.png - - - - - - - 0 - - - - Songs - - - - - - - 0 - 200 - - - - QAbstractItemView::EditTrigger::NoEditTriggers - - - QAbstractItemView::SelectionBehavior::SelectRows - - - - - - - - Info - - - - - - true - - - - - - - - Lyrics - - - - - - - Monospace - - - - true - - - - - - - - - - - - - Add Song - - - - - - - Remove Song - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::LayoutDirection::LeftToRight - - - Now Playing: - - - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter - - - - - - - - - 0:00 - - - - - - - false - - - false - - - - - - - 0:00 - - - - - - - - - QFrame::Shape::StyledPanel - - - QFrame::Shadow::Raised - - - - - - Play - - - - - - - - - - Pause - - - - - - - - - - Skip - - - - - - - - - - Stop - - - - - - - - - - Shuffle - - - - - - true - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - 0 - 0 - 800 - 32 - - - - - File - - - - - - - - - - - Settings - - - - - - - - - - - - - Save Playlist - - - Ctrl+S - - - - - - - - Load Playlist... - - - Ctrl+O - - - - - Ace Step - - - - - - - - Quit - - - Ctrl+Q - - - - - - - - Clear Playlist - - - - - - - - Save Song - - - - - - - - Append Playlist - - - - - - ClickableSlider - QWidget -
src/clickableslider.h
-
-
- - - - -
+ + MainWindow + + + + 0 + 0 + 800 + 600 + + + + Aceradio + + + + :/icons/xyz.uvos.aceradio.png:/icons/xyz.uvos.aceradio.png + + + + + + + 0 + + + + Songs + + + + + + + 0 + 200 + + + + QAbstractItemView::EditTrigger::NoEditTriggers + + + QAbstractItemView::SelectionBehavior::SelectRows + + + + + + + + Info + + + + + + true + + + + + + + + Lyrics + + + + + + + Monospace + + + + true + + + + + + + + + + + + + Add Song + + + + + + + Remove Song + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 20 + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + + + + 0:00 + + + + + + + false + + + false + + + + + + + 0:00 + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Play + + + + + + + + + + Pause + + + + + + + + + + Skip + + + + + + + + + + Stop + + + + + + + + + + Shuffle + + + + + + true + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + + + + + + + + + + + 0 + 0 + 800 + 32 + + + + + File + + + + + + + + + + + Settings + + + + + + + + + + + + + Save Playlist + + + Ctrl+S + + + + + + + + Load Playlist... + + + Ctrl+O + + + + + Ace Step + + + + + + + + Quit + + + Ctrl+Q + + + + + + + + Clear Playlist + + + + + + + + Save Song + + + + + + + + Append Playlist + + + + + + ClickableSlider + QWidget +
src/clickableslider.h
+
+ + ElidedLabel + QFrame +
src/elidedlabel.h
+ 1 +
+
+ + + + +
diff --git a/src/elidedlabel.cpp b/src/elidedlabel.cpp new file mode 100644 index 0000000..191a0fd --- /dev/null +++ b/src/elidedlabel.cpp @@ -0,0 +1,70 @@ +#include "elidedlabel.h" + +#include +#include + +ElidedLabel::ElidedLabel(const QString &text, QWidget *parent) + : QFrame(parent) + , elided(false) + , content(text) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); +} + +ElidedLabel::ElidedLabel(QWidget *parent) + : QFrame(parent) + , elided(false) + , content("") +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); +} + +void ElidedLabel::setText(const QString &newText) +{ + content = newText; + update(); +} + +void ElidedLabel::paintEvent(QPaintEvent *event) +{ + QFrame::paintEvent(event); + + QPainter painter(this); + QFontMetrics fontMetrics = painter.fontMetrics(); + + bool didElide = false; + int lineSpacing = fontMetrics.lineSpacing(); + int y = 0; + + QTextLayout textLayout(content, painter.font()); + textLayout.beginLayout(); + forever { + QTextLine line = textLayout.createLine(); + + if (!line.isValid()) + break; + + line.setLineWidth(width()); + int nextLineY = y + lineSpacing; + + if (height() >= nextLineY + lineSpacing) { + line.draw(&painter, QPoint(0, y)); + y = nextLineY; + //! [2] + //! [3] + } else { + QString lastLine = content.mid(line.textStart()); + QString elidedLastLine = fontMetrics.elidedText(lastLine, Qt::ElideRight, width()); + painter.drawText(QPoint(0, y + fontMetrics.ascent()), elidedLastLine); + line = textLayout.createLine(); + didElide = line.isValid(); + break; + } + } + textLayout.endLayout(); + + if (didElide != elided) { + elided = didElide; + emit elisionChanged(didElide); + } +} diff --git a/src/elidedlabel.h b/src/elidedlabel.h new file mode 100644 index 0000000..76df007 --- /dev/null +++ b/src/elidedlabel.h @@ -0,0 +1,32 @@ +#ifndef ELIDEDLABEL_H +#define ELIDEDLABEL_H + +#include + +class ElidedLabel : public QFrame +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(bool isElided READ isElided) + +public: + explicit ElidedLabel(const QString &text, QWidget *parent = 0); + explicit ElidedLabel(QWidget *parent = 0); + + void setText(const QString &text); + const QString & text() const { return content; } + bool isElided() const { return elided; } + +protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + +signals: + void elisionChanged(bool elided); + +private: + bool elided; + QString content; +}; + + +#endif // ELIDEDLABEL_H