Small ui improvements
This commit is contained in:
parent
887e14add9
commit
6eea5688a8
5 changed files with 467 additions and 360 deletions
|
|
@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
|
||||||
src/clickableslider.cpp
|
src/clickableslider.cpp
|
||||||
${MusicGeneratorGUI_H}
|
${MusicGeneratorGUI_H}
|
||||||
res/resources.qrc
|
res/resources.qrc
|
||||||
|
src/elidedlabel.h src/elidedlabel.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# UI file
|
# UI file
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->songListView->setCurrentIndex(firstIndex);
|
ui->songListView->setCurrentIndex(firstIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->nowPlayingLabel->setText("Now Playing:");
|
||||||
|
|
||||||
currentSong = songModel->getSong(0);
|
currentSong = songModel->getSong(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,7 +428,7 @@ void MainWindow::songGenerated(const SongItem& song)
|
||||||
{
|
{
|
||||||
generatedSongQueue.enqueue(song);
|
generatedSongQueue.enqueue(song);
|
||||||
}
|
}
|
||||||
ui->statusLabel->setText("idle");
|
ui->statusbar->showMessage("idle");
|
||||||
|
|
||||||
ensureSongsInQueue();
|
ensureSongsInQueue();
|
||||||
}
|
}
|
||||||
|
|
@ -530,7 +532,7 @@ void MainWindow::ensureSongsInQueue(bool enqeueCurrent)
|
||||||
|
|
||||||
isGeneratingNext = true;
|
isGeneratingNext = true;
|
||||||
|
|
||||||
ui->statusLabel->setText("Generateing: "+nextSong.caption);
|
ui->statusbar->showMessage("Generateing: "+nextSong.caption);
|
||||||
aceStepWorker->generateSong(nextSong, jsonTemplate,
|
aceStepWorker->generateSong(nextSong, jsonTemplate,
|
||||||
aceStepPath, qwen3ModelPath,
|
aceStepPath, qwen3ModelPath,
|
||||||
textEncoderModelPath, ditModelPath,
|
textEncoderModelPath, ditModelPath,
|
||||||
|
|
|
||||||
|
|
@ -1,359 +1,361 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>MainWindow</class>
|
<class>MainWindow</class>
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
<height>600</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Aceradio</string>
|
<string>Aceradio</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="../res/resources.qrc">
|
<iconset resource="../res/resources.qrc">
|
||||||
<normaloff>:/icons/xyz.uvos.aceradio.png</normaloff>:/icons/xyz.uvos.aceradio.png</iconset>
|
<normaloff>:/icons/xyz.uvos.aceradio.png</normaloff>:/icons/xyz.uvos.aceradio.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="mainTabWidget">
|
<widget class="QTabWidget" name="mainTabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="songsTab">
|
<widget class="QWidget" name="songsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Songs</string>
|
<string>Songs</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="songListView">
|
<widget class="QTableView" name="songListView">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
<height>200</height>
|
<height>200</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
|
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
|
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="infoTab">
|
<widget class="QWidget" name="infoTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Info</string>
|
<string>Info</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="jsonTextEdit">
|
<widget class="QPlainTextEdit" name="jsonTextEdit">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="lyricsTab">
|
<widget class="QWidget" name="lyricsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Lyrics</string>
|
<string>Lyrics</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="lyricsTextEdit">
|
<widget class="QTextEdit" name="lyricsTextEdit">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Monospace</family>
|
<family>Monospace</family>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="buttonLayout">
|
<layout class="QHBoxLayout" name="buttonLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addSongButton">
|
<widget class="QPushButton" name="addSongButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add Song</string>
|
<string>Add Song</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="removeSongButton">
|
<widget class="QPushButton" name="removeSongButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove Song</string>
|
<string>Remove Song</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="nowPlayingLabel">
|
<widget class="ElidedLabel" name="nowPlayingLabel">
|
||||||
<property name="layoutDirection">
|
<property name="minimumSize">
|
||||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<property name="text">
|
<height>20</height>
|
||||||
<string>Now Playing:</string>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="frameShape">
|
||||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
<enum>QFrame::Shape::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="frameShadow">
|
||||||
</item>
|
<enum>QFrame::Shadow::Raised</enum>
|
||||||
<item>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="timeControlsLayout">
|
</widget>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QLabel" name="elapsedTimeLabel">
|
<item>
|
||||||
<property name="text">
|
<layout class="QHBoxLayout" name="timeControlsLayout">
|
||||||
<string>0:00</string>
|
<item>
|
||||||
</property>
|
<widget class="QLabel" name="elapsedTimeLabel">
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>0:00</string>
|
||||||
<item>
|
</property>
|
||||||
<widget class="ClickableSlider" name="positionSlider" native="true">
|
</widget>
|
||||||
<property name="mouseTracking">
|
</item>
|
||||||
<bool>false</bool>
|
<item>
|
||||||
</property>
|
<widget class="ClickableSlider" name="positionSlider" native="true">
|
||||||
<property name="tabletTracking">
|
<property name="mouseTracking">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="tabletTracking">
|
||||||
</item>
|
<bool>false</bool>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QLabel" name="durationLabel">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>0:00</string>
|
<item>
|
||||||
</property>
|
<widget class="QLabel" name="durationLabel">
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>0:00</string>
|
||||||
</layout>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QFrame" name="controlsFrame">
|
</layout>
|
||||||
<property name="frameShape">
|
</item>
|
||||||
<enum>QFrame::Shape::StyledPanel</enum>
|
<item>
|
||||||
</property>
|
<widget class="QFrame" name="controlsFrame">
|
||||||
<property name="frameShadow">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Shadow::Raised</enum>
|
<enum>QFrame::Shape::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="controlsLayout">
|
<property name="frameShadow">
|
||||||
<item>
|
<enum>QFrame::Shadow::Raised</enum>
|
||||||
<widget class="QPushButton" name="playButton">
|
</property>
|
||||||
<property name="text">
|
<layout class="QHBoxLayout" name="controlsLayout">
|
||||||
<string>Play</string>
|
<item>
|
||||||
</property>
|
<widget class="QPushButton" name="playButton">
|
||||||
<property name="icon">
|
<property name="text">
|
||||||
<iconset theme="media-playback-start"/>
|
<string>Play</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="icon">
|
||||||
</item>
|
<iconset theme="media-playback-start"/>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QPushButton" name="pauseButton">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>Pause</string>
|
<item>
|
||||||
</property>
|
<widget class="QPushButton" name="pauseButton">
|
||||||
<property name="icon">
|
<property name="text">
|
||||||
<iconset theme="media-playback-pause"/>
|
<string>Pause</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="icon">
|
||||||
</item>
|
<iconset theme="media-playback-pause"/>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QPushButton" name="skipButton">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>Skip</string>
|
<item>
|
||||||
</property>
|
<widget class="QPushButton" name="skipButton">
|
||||||
<property name="icon">
|
<property name="text">
|
||||||
<iconset theme="media-skip-forward"/>
|
<string>Skip</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="icon">
|
||||||
</item>
|
<iconset theme="media-skip-forward"/>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QPushButton" name="stopButton">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>Stop</string>
|
<item>
|
||||||
</property>
|
<widget class="QPushButton" name="stopButton">
|
||||||
<property name="icon">
|
<property name="text">
|
||||||
<iconset theme="media-playback-stop"/>
|
<string>Stop</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="icon">
|
||||||
</item>
|
<iconset theme="media-playback-stop"/>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QPushButton" name="shuffleButton">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>Shuffle</string>
|
<item>
|
||||||
</property>
|
<widget class="QPushButton" name="shuffleButton">
|
||||||
<property name="icon">
|
<property name="text">
|
||||||
<iconset theme="media-playlist-shuffle"/>
|
<string>Shuffle</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="icon">
|
||||||
<bool>true</bool>
|
<iconset theme="media-playlist-shuffle"/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="checkable">
|
||||||
</item>
|
<bool>true</bool>
|
||||||
<item>
|
</property>
|
||||||
<spacer name="horizontalSpacer_2">
|
</widget>
|
||||||
<property name="orientation">
|
</item>
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<item>
|
||||||
</property>
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="orientation">
|
||||||
<size>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
<width>40</width>
|
</property>
|
||||||
<height>20</height>
|
<property name="sizeHint" stdset="0">
|
||||||
</size>
|
<size>
|
||||||
</property>
|
<width>40</width>
|
||||||
</spacer>
|
<height>20</height>
|
||||||
</item>
|
</size>
|
||||||
</layout>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<layout class="QVBoxLayout" name="statusLayout">
|
</widget>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QProgressBar" name="progressBar">
|
<item>
|
||||||
<property name="value">
|
<layout class="QVBoxLayout" name="statusLayout">
|
||||||
<number>0</number>
|
<item>
|
||||||
</property>
|
<widget class="QProgressBar" name="progressBar">
|
||||||
</widget>
|
<property name="value">
|
||||||
</item>
|
<number>0</number>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QLabel" name="statusLabel">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string/>
|
</layout>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
</widget>
|
||||||
</layout>
|
<widget class="QMenuBar" name="menubar">
|
||||||
</item>
|
<property name="geometry">
|
||||||
</layout>
|
<rect>
|
||||||
</widget>
|
<x>0</x>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<y>0</y>
|
||||||
<property name="geometry">
|
<width>800</width>
|
||||||
<rect>
|
<height>32</height>
|
||||||
<x>0</x>
|
</rect>
|
||||||
<y>0</y>
|
</property>
|
||||||
<width>800</width>
|
<widget class="QMenu" name="menuFile">
|
||||||
<height>32</height>
|
<property name="title">
|
||||||
</rect>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<addaction name="actionSaveSong"/>
|
||||||
<property name="title">
|
<addaction name="actionSavePlaylist"/>
|
||||||
<string>File</string>
|
<addaction name="actionLoadPlaylist"/>
|
||||||
</property>
|
<addaction name="actionAppendPlaylist"/>
|
||||||
<addaction name="actionSaveSong"/>
|
<addaction name="actionClearPlaylist"/>
|
||||||
<addaction name="actionSavePlaylist"/>
|
<addaction name="actionQuit"/>
|
||||||
<addaction name="actionLoadPlaylist"/>
|
</widget>
|
||||||
<addaction name="actionAppendPlaylist"/>
|
<widget class="QMenu" name="menuSettings">
|
||||||
<addaction name="actionClearPlaylist"/>
|
<property name="title">
|
||||||
<addaction name="actionQuit"/>
|
<string>Settings</string>
|
||||||
</widget>
|
</property>
|
||||||
<widget class="QMenu" name="menuSettings">
|
<addaction name="actionAdvancedSettings"/>
|
||||||
<property name="title">
|
</widget>
|
||||||
<string>Settings</string>
|
<addaction name="menuFile"/>
|
||||||
</property>
|
<addaction name="menuSettings"/>
|
||||||
<addaction name="actionAdvancedSettings"/>
|
</widget>
|
||||||
</widget>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<addaction name="menuFile"/>
|
<action name="actionSavePlaylist">
|
||||||
<addaction name="menuSettings"/>
|
<property name="icon">
|
||||||
</widget>
|
<iconset theme="QIcon::ThemeIcon::DocumentSaveAs"/>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
</property>
|
||||||
<action name="actionSavePlaylist">
|
<property name="text">
|
||||||
<property name="icon">
|
<string>Save Playlist</string>
|
||||||
<iconset theme="QIcon::ThemeIcon::DocumentSaveAs"/>
|
</property>
|
||||||
</property>
|
<property name="shortcut">
|
||||||
<property name="text">
|
<string>Ctrl+S</string>
|
||||||
<string>Save Playlist</string>
|
</property>
|
||||||
</property>
|
</action>
|
||||||
<property name="shortcut">
|
<action name="actionLoadPlaylist">
|
||||||
<string>Ctrl+S</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset theme="QIcon::ThemeIcon::DocumentOpen"/>
|
||||||
</action>
|
</property>
|
||||||
<action name="actionLoadPlaylist">
|
<property name="text">
|
||||||
<property name="icon">
|
<string>Load Playlist...</string>
|
||||||
<iconset theme="QIcon::ThemeIcon::DocumentOpen"/>
|
</property>
|
||||||
</property>
|
<property name="shortcut">
|
||||||
<property name="text">
|
<string>Ctrl+O</string>
|
||||||
<string>Load Playlist...</string>
|
</property>
|
||||||
</property>
|
</action>
|
||||||
<property name="shortcut">
|
<action name="actionAdvancedSettings">
|
||||||
<string>Ctrl+O</string>
|
<property name="text">
|
||||||
</property>
|
<string>Ace Step</string>
|
||||||
</action>
|
</property>
|
||||||
<action name="actionAdvancedSettings">
|
</action>
|
||||||
<property name="text">
|
<action name="actionQuit">
|
||||||
<string>Ace Step</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset theme="QIcon::ThemeIcon::ApplicationExit"/>
|
||||||
</action>
|
</property>
|
||||||
<action name="actionQuit">
|
<property name="text">
|
||||||
<property name="icon">
|
<string>Quit</string>
|
||||||
<iconset theme="QIcon::ThemeIcon::ApplicationExit"/>
|
</property>
|
||||||
</property>
|
<property name="shortcut">
|
||||||
<property name="text">
|
<string>Ctrl+Q</string>
|
||||||
<string>Quit</string>
|
</property>
|
||||||
</property>
|
</action>
|
||||||
<property name="shortcut">
|
<action name="actionClearPlaylist">
|
||||||
<string>Ctrl+Q</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset theme="QIcon::ThemeIcon::EditDelete"/>
|
||||||
</action>
|
</property>
|
||||||
<action name="actionClearPlaylist">
|
<property name="text">
|
||||||
<property name="icon">
|
<string>Clear Playlist</string>
|
||||||
<iconset theme="QIcon::ThemeIcon::EditDelete"/>
|
</property>
|
||||||
</property>
|
</action>
|
||||||
<property name="text">
|
<action name="actionSaveSong">
|
||||||
<string>Clear Playlist</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset theme="QIcon::ThemeIcon::DocumentSaveAs"/>
|
||||||
</action>
|
</property>
|
||||||
<action name="actionSaveSong">
|
<property name="text">
|
||||||
<property name="icon">
|
<string>Save Song</string>
|
||||||
<iconset theme="QIcon::ThemeIcon::DocumentSaveAs"/>
|
</property>
|
||||||
</property>
|
</action>
|
||||||
<property name="text">
|
<action name="actionAppendPlaylist">
|
||||||
<string>Save Song</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset theme="QIcon::ThemeIcon::DocumentOpen"/>
|
||||||
</action>
|
</property>
|
||||||
<action name="actionAppendPlaylist">
|
<property name="text">
|
||||||
<property name="icon">
|
<string>Append Playlist</string>
|
||||||
<iconset theme="QIcon::ThemeIcon::DocumentOpen"/>
|
</property>
|
||||||
</property>
|
</action>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Append Playlist</string>
|
<customwidgets>
|
||||||
</property>
|
<customwidget>
|
||||||
</action>
|
<class>ClickableSlider</class>
|
||||||
</widget>
|
<extends>QWidget</extends>
|
||||||
<customwidgets>
|
<header>src/clickableslider.h</header>
|
||||||
<customwidget>
|
</customwidget>
|
||||||
<class>ClickableSlider</class>
|
<customwidget>
|
||||||
<extends>QWidget</extends>
|
<class>ElidedLabel</class>
|
||||||
<header>src/clickableslider.h</header>
|
<extends>QFrame</extends>
|
||||||
</customwidget>
|
<header>src/elidedlabel.h</header>
|
||||||
</customwidgets>
|
<container>1</container>
|
||||||
<resources>
|
</customwidget>
|
||||||
<include location="../res/resources.qrc"/>
|
</customwidgets>
|
||||||
</resources>
|
<resources>
|
||||||
<connections/>
|
<include location="../res/resources.qrc"/>
|
||||||
</ui>
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
|
||||||
70
src/elidedlabel.cpp
Normal file
70
src/elidedlabel.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include "elidedlabel.h"
|
||||||
|
|
||||||
|
#include <QTextLayout>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/elidedlabel.h
Normal file
32
src/elidedlabel.h
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef ELIDEDLABEL_H
|
||||||
|
#define ELIDEDLABEL_H
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue