2 #include "ui_musicapplication.h"
33 m_quitWindowMode(false),
47 setMaximumSize(size.width(), size.height());
63 m_player->setVolume(100);
69 connect(
m_ui->desktopLrcButton, SIGNAL(clicked(
bool)),
m_rightAreaWidget, SLOT(setDestopLrcVisible(
bool)));
71 m_ui->playButton->setFocus();
72 m_ui->lrcDisplayAllButton->hide();
75 m_ui->timeSliderWidget->setInputModule(
this);
133 return (index != -1) ? songs[index].name() : QString();
152 return (index != -1) ? songs[index].path() : QString();
176 for(
const QString &format : formats)
178 path = prefixPath + format;
179 if(QFile::exists(path))
185 path = nativePath + format;
186 if(QFile::exists(path))
236 contains = QFile::exists(path);
250 const MusicSongList ¤tSongs = items[item.
m_playlistRow].m_songs;
253 return index != -1 ? loveSongs.contains(currentSongs[index]) :
false;
268 return loveSongs.contains(currentSongs[index]);
308 m_ui->timeSliderWidget->setValue(position);
325 m_ui->timeSliderWidget->setRange(0, duration);
330 m_ui->qualityLabel->updateQuality();
382 m_ui->playedListButton->selectCurrentMedia();
385 m_ui->songTitleLabel->setText(name);
386 m_ui->moreFunctionButton->setCurrentSongName(name);
442 m_ui->playedListButton->clearQueueState();
521 m_ui->soundButton->setValue(volume);
529 m_ui->soundButton->setValue(volume);
538 menu.addAction(tr(
"Open Files"),
m_songTreeWidget, SLOT(importSongsByFiles()));
542 menu.addAction(tr(
"Files Drag Drop"))->setEnabled(
false);
545 menu.exec(QCursor::pos());
557 const QString &path = dialog.
text();
575 MusicSongItemList items;
589 if(index < 0 || index >= items.count())
654 if(0 <= index && index < items.count())
656 m_ui->playedListButton->append(items[index].m_songs);
672 if(0 <= index && index < items.count())
674 m_ui->playedListButton->append(items[index].m_songs);
715 bool contains =
true;
736 MusicToastLabel::popup(!contains ? tr(
"Add music to lovest list done") : tr(
"Remove music to lovest list done"));
755 QMenu *addNewFilesMenu = menu.addMenu(tr(
"Add New Files"));
756 addNewFilesMenu->addAction(tr(
"Open Files"),
m_songTreeWidget, SLOT(importSongsByFiles()));
757 addNewFilesMenu->addAction(tr(
"Open Dir"),
m_songTreeWidget, SLOT(importSongsByDir()));
761 QMenu *playbackModeMenu = menu.addMenu(tr(
"Playback Mode"));
763 QList<QAction*> actions;
764 actions << playbackModeMenu->addAction(tr(
"Play Once"),
this, SLOT(
playOnce()));
765 actions << playbackModeMenu->addAction(tr(
"Single Cycle"),
this, SLOT(
playOneLoop()));
766 actions << playbackModeMenu->addAction(tr(
"Order Play"),
this, SLOT(
playOrder()));
767 actions << playbackModeMenu->addAction(tr(
"List Cycle"),
this, SLOT(
playlistLoop()));
768 actions << playbackModeMenu->addAction(tr(
"Random Play"),
this, SLOT(
playRandom()));
783 actions[index]->setIcon(QIcon(
":/contextMenu/btn_selected"));
788 QMenu *remoteControlMenu = menu.addMenu(tr(
"Remote Control"));
789 remoteControlMenu->addAction(tr(
"Square Remote"),
m_topAreaWidget, SLOT(showSquareRemote()));
790 remoteControlMenu->addAction(tr(
"Rectangle Remote"),
m_topAreaWidget, SLOT(showRectangleRemote()));
791 remoteControlMenu->addAction(tr(
"Simple Style Remote"),
m_topAreaWidget, SLOT(showSimpleStyleRemote()));
792 remoteControlMenu->addAction(tr(
"Complex Style Remote"),
m_topAreaWidget, SLOT(showComplexStyleRemote()));
793 remoteControlMenu->addAction(tr(
"Ripple Remote"),
m_topAreaWidget, SLOT(showRippleRemote()));
794 remoteControlMenu->addAction(tr(
"Delete Remote"),
m_topAreaWidget, SLOT(deleteCurrentRemote()));
797 menu.addAction(QIcon(
":/contextMenu/btn_equalizer"), tr(
"Equalizer"),
m_applicationModule, SLOT(showEqualizerWidget()));
803 QAction *window = menu.addAction(tr(
"Window Top"),
m_applicationModule, SLOT(setWindowToTop()));
807 QMenu *downloadMenu = menu.addMenu(tr(
"Download"));
815 actions[index]->setIcon(QIcon(
":/contextMenu/btn_selected"));
820 menu.addAction(QIcon(
":/contextMenu/btn_update"), tr(
"New Version"),
m_applicationModule, SLOT(showVersionWidget()));
822 menu.addAction(QIcon(
":/contextMenu/btn_setting"), tr(
"Settings"),
this, SLOT(
showSettingWidget()));
824 QMenu *informationMenu = menu.addMenu(QIcon(
":/contextMenu/btn_about"), tr(
"About"));
825 informationMenu->addAction(QIcon(
":/contextMenu/btn_bug_reoprt"), tr(
"Bug Report"),
m_applicationModule, SLOT(showBugReportView()));
829 menu.addAction(QIcon(
":/contextMenu/btn_quit"), tr(
"Quit"),
this, SLOT(
quitWindow()));
830 menu.exec(QCursor::pos());
859 for(
const QString &p :
qAsConst(path))
876 std::sort(index.begin(), index.end());
878 bool contains =
false;
881 if(index.count() == 1 && index.first() == oldIndex)
886 for(
int i = index.count() - 1; i >= 0; --i)
888 m_ui->playedListButton->remove(index[i]);
889 if(i != 0 && !contains && oldIndex <= index[i] && oldIndex >= index[i - 1])
898 oldIndex -= index.count();
929 for(
const QString &p :
qAsConst(path))
931 m_ui->playedListButton->remove(playlistRow, p);
977 if(
m_ui->background->isRunning())
989 TTKAbstractMoveResizeWidget::resizeEvent(event);
993 setMinimumSize(0, 0);
994 m_ui->background->stop();
1001 TTKAbstractMoveResizeWidget::closeEvent(event);
1017 const int h =
event->y();
1018 if(h < m_ui->topWidget->height() || h > height() -
m_ui->bottomWidget->height())
1020 TTKAbstractMoveResizeWidget::contextMenuEvent(event);
1031 TTKAbstractMoveResizeWidget::enterEvent(event);
1037 TTKAbstractMoveResizeWidget::leaveEvent(event);
1051 if(
m_ui->background->isRunning())
1059 setMaximumSize(size.width(), size.height());
1073 TTKAbstractMoveResizeWidget::mouseDoubleClickEvent(event);
1074 if(event->buttons() == Qt::LeftButton)
1076 isMaximized() ? showNormal() : showMaximized();
1087 if(
object ==
m_ui->centerWidget && (QEvent::ContextMenu == event->type() || QEvent::MouseButtonPress ==
event->type()))
1105 MusicSongItemList items;
1162 for(
int i = 0; i < hotkeys.count(); ++i)
1191 value = lastPlayIndex[1].toInt();
1195 m_ui->playedListButton->append(items[value].m_songs);
1200 if(success && lastPlayIndex[0] ==
"1")
1203 const int index = lastPlayIndex[2].toInt();
1208 m_ui->playedListButton->selectCurrentMedia();
1263 if(lastPlayIndex.isEmpty())
1265 lastPlayIndex <<
"1" <<
"-1" <<
"-1";
void currentPlayLocation()
void loadCurrentSongLrc()
MusicBottomAreaWidget * m_bottomAreaWidget
#define QtEnterEvent
Event enter.
#define TTKStaticCast(x, y)
The class of the music play item.
The class of the app object module.
void setEqualizerConfig()
static MusicApplication * instance()
void setShuffleMode(bool shuffle) noexcept
QRect readWindowGeometry() const
#define MUSIC_SEARCH_PAGE
#define PLAYLIST_PATH_FULL
void sideAnimationByOff()
void addSongToLovestList(bool state=true)
MusicApplication(QWidget *parent=nullptr)
void setPlaySongChanged(int index)
MusicPlayItem currentItem() const noexcept
bool fromFile(const QString &name)
virtual void leaveEvent(QEvent *event) overridefinal
virtual void mouseMoveEvent(QMouseEvent *event) overridefinal
void positionChanged(qint64 position)
bool isEmpty() const noexcept
TTK::PlayMode playbackMode() const noexcept
void playIndexBy(int row)
static constexpr const char * BtnUnDownload
The class of the app main widget.
QString containsDownloadMedia(bool &contains) const
virtual void mouseReleaseEvent(QMouseEvent *event) overridefinal
void updateCurrentArtist()
void loadNetWorkSetting()
void setPosition(qint64 position)
The class of the playlist manager.
The class of the xml config manager.
void volumeChanged(int volume)
int find(const MusicPlayItem &item) const
static constexpr const char * BtnPlay
void writeSystemConfigToFile()
The class of the music player.
void removeItemAt(const QStringList &path, bool remove, bool current, int playlistRow)
Ui::MusicApplication * m_ui
TTK_MODULE_EXPORT QString generateNetworkSongMetaPath(const QString &path)
void add(int playlistRow, const QString &content)
virtual void mouseDoubleClickEvent(QMouseEvent *event) overridefinal
virtual bool eventFilter(QObject *object, QEvent *event) overridefinal
TTK::PlayMode playMode() const noexcept
MusicTopAreaWidget * m_topAreaWidget
void exportSongsItemList()
void setVolume(int volume)
static void popup(const QString &text)
TTK_MODULE_EXPORT void enableBreakPoint(bool enable) noexcept
virtual bool readBuffer(MusicSongItemList &items) overridefinal
void playedIndexBy(int row)
bool isMuted() const noexcept
TTK_MODULE_EXPORT QString getSaveFileName(QWidget *parent, const QString &filter="Image Files (*.png *.bmp *.jpg)")
static constexpr int PLAY_PREVIOUS_LEVEL
static constexpr const char * TinyBtnPause
MusicRightAreaWidget * m_rightAreaWidget
void writeSongItem(const QString &path, const MusicSongItemList &item)
TTK_MODULE_EXPORT QString generateNetworkSongPath(const QString &path)
void generatePlaylistItems()
void updateSoundEffectConfig(bool v)
virtual void enterEvent(QtEnterEvent *event) overridefinal
MusicSongsContainerWidget * m_songTreeWidget
bool isLastedVersion() const
static constexpr const char * BtnDownload
#define TTK_SIGNLE_SHOT(...)
bool containsLovestMedia() const
MusicPlaylist * m_playlist
void durationChanged(qint64 duration)
void currentPlaylist(QStringList &list)
TTK_MODULE_EXPORT QString lrcDirPrefix()
void playIndexClicked(int row, int column)
void updateCurrentTime(qint64 pos)
QString currentFilePath() const
#define TTK_VERSION_TIME_STR
MusicLeftAreaWidget * m_leftAreaWidget
bool isPlaying() const noexcept
static constexpr int PLAY_NEXT_LEVEL
void setPlaybackMode(TTK::PlayMode mode) noexcept
void importSongsByOutside(const QString &path, bool play)
void setCurrentIndex(int index)
QString format() const noexcept
int count() const noexcept
static const QString MenuStyle02
static constexpr const char * TinyBtnPlay
bool windowToTop() const noexcept
bool checkMusicListCurrentIndex() const
void windowConciseChanged()
The class of the tkpl config manager.
void exportSongsItem(int index)
#define MUSIC_NETWORK_LIST
bool load(const QString &name)
#define MUSIC_LOVEST_LIST
virtual void contextMenuEvent(QContextMenuEvent *event) overridefinal
int currentIndex() const noexcept
virtual void closeEvent(QCloseEvent *event) overridefinal
static constexpr const char * BtnLove
void readSongItems(const QStringList &paths, MusicSongItemList &items)
void playTimePosition(int time)
static MusicApplication * m_instance
void enhancedSongChanged(int type)
TTK_MODULE_EXPORT QStringList getOpenFileNames(QWidget *parent, const QString &filter="Image Files (*.png *.bmp *.jpg)")
static constexpr const char * BtnPause
void importSongsItemList()
The class of the music song info.
bool isValid() const noexcept
void removeLoveItemAt(const QString &path, bool current)
virtual void resizeEvent(QResizeEvent *event) overridefinal
void playerStateChanged(TTK::PlayState state)
The class of the music play list.
#define MUSIC_NORMAL_LIST
void readSystemConfigFromFile()
void windowCloseAnimation()
#define TTK_ERROR_STREAM(msg)
void setEnhance(TTK::Enhance type)
void resetCurrentSongLrcIndex()
void setMuted(bool muted)
TTK::Enhance enhance() const noexcept
QPoint readShowDesktopLrcGeometry() const
#define WINDOW_HEIGHT_MIN
virtual bool writeBuffer(const MusicSongItemList &items) overridefinal
static constexpr const char * BtnUnLove
static qint64 formatDuration(const QString &time) noexcept
MusicApplicationModule * m_applicationModule
QString currentFileName() const