This commit is contained in:
denghao 2023-11-02 10:48:36 +08:00
parent b6f6697132
commit 785a9b08a0
5 changed files with 180 additions and 12 deletions

View File

@ -771,6 +771,27 @@ void Widget::allConnect()
connect(m_titleBar->searchEdit,&SearchEdit::signalReturnPressed,musicListTable,&TableOne::slotSearchReturnPressed);
connect(&playController::getInstance(),&playController::playerStateChange,this,&Widget::slotStateChanged);
// mini模式快捷键
connect(m_miniWidget, &miniWidget::playPauseKeySignal,playSongArea,&PlaySongArea::slotPlayClicked);
connect(m_miniWidget, &miniWidget::previousPlayKeySignal, playSongArea,&PlaySongArea::slotPrevious);
connect(m_miniWidget, &miniWidget::nextPlayKeySignal, playSongArea,&PlaySongArea::slotNext);
connect(m_miniWidget, &miniWidget::addVolumeKeySignal, this, &Widget::VolumeUp);
connect(m_miniWidget, &miniWidget::downVolumeKeySignal, this, &Widget::VolumeDown);
connect(m_miniWidget, &miniWidget::miniCompleteSwitchKeySignal, this, &Widget::slotRecoverNormalWidget);
connect(m_miniWidget, &miniWidget::loveSongKeySignal, playSongArea, &PlaySongArea::slotFav);
connect(m_miniWidget, &miniWidget::changePlaybackMode,playSongArea,&PlaySongArea::setPlayMode);
// 快捷键设置
connect(m_quitWindow, &QShortcut::activated, this, &Widget::slotClose);
connect(this,&Widget::playPauseKeySignal,playSongArea,&PlaySongArea::slotPlayClicked);
connect(this, &Widget::previousPlayKeySignal, playSongArea,&PlaySongArea::slotPrevious);
connect(this, &Widget::nextPlayKeySignal, playSongArea,&PlaySongArea::slotNext);
connect(this, &Widget::addVolumeKeySignal, this, &Widget::VolumeUp);
connect(this, &Widget::downVolumeKeySignal, this, &Widget::VolumeDown);
connect(this, &Widget::miniCompleteSwitchKeySignal, this,&Widget::slotShowMiniWidget);
connect(this, &Widget::loveSongKeySignal, playSongArea, &PlaySongArea::slotFav);
connect(this, &Widget::changePlaybackMode,playSongArea,&PlaySongArea::setPlayMode);
}
void Widget::initGSettings()//初始化GSettings
@ -963,12 +984,67 @@ void Widget::keyPressEvent(QKeyEvent *event)
if(event->key() == Qt::Key_F1)
{
Q_EMIT signalShowGuide();
} else if(event->key() == Qt::Key_Space) {
Q_EMIT playPauseKeySignal();
}
else if(event->key() == Qt::Key_Space)
{
Q_EMIT signalSpaceKey();
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Left) {
qDebug() << "ctrl+left";
Q_EMIT previousPlayKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Right) {
qDebug() << "ctrl+right";
Q_EMIT nextPlayKeySignal();
}
if (event->key() == Qt::Key_Up) {
qDebug() << "ctrl+up";
Q_EMIT addVolumeKeySignal();
}
if (event->key() == Qt::Key_Down) {
qDebug() << "ctrl+down";
Q_EMIT downVolumeKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_M) {
qDebug() << "ctrl+m";
Q_EMIT miniCompleteSwitchKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_L) {
qDebug() << "ctrl+l";
Q_EMIT loveSongKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_T){
qDebug() << "ctrl+t";
if (m_playbackMode == CurrentItemInLoop){
Q_EMIT changePlaybackMode(3);
m_playbackMode = Loop;
}
else if (m_playbackMode == Loop){
Q_EMIT changePlaybackMode(4);
m_playbackMode = Random;
}
else if (m_playbackMode == Random){
Q_EMIT changePlaybackMode(1);
m_playbackMode = CurrentItemInLoop;
}
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_E) {
qDebug() << "ctrl+E";
this->m_titleBar->slotFoucusIn();
}
QWidget::keyPressEvent(event);
}
Widget::PlaybackMode Widget::playbackMode() const
{
return m_playbackMode;
}
void Widget::mousePressEvent(QMouseEvent *event)

View File

@ -51,6 +51,9 @@ class Widget : public QWidget
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ukui.kylin_music.play")
public:
enum PlaybackMode { CurrentItemOnce=0, CurrentItemInLoop, Sequential, Loop, Random }; //播放循环模式枚举
PlaybackMode playbackMode() const; //获取播放循环模式
Widget(QStringList str, QWidget *parent = nullptr);
~Widget();
//计算播放历史
@ -138,6 +141,23 @@ protected:
Q_SIGNALS:
//空格键控制播放暂停
void signalSpaceKey();
// Space 控制播放/暂停
void playPauseKeySignal();
// Ctrl+Left 控制上一首
void previousPlayKeySignal();
// Ctrl+Right 控制下一首
void nextPlayKeySignal();
// Ctrl+Up 控制音量增加
void addVolumeKeySignal();
// Ctrl+down 控制音量降低
void downVolumeKeySignal();
// Ctrl+M 切换 Mini/完整模式
void miniCompleteSwitchKeySignal();
// Ctrl+L 将歌曲添加到喜欢歌单
void loveSongKeySignal();
//Ctrl+T 切换播放模式
void changePlaybackMode(int mode);
private:
//初始化dbus
void initDbus();
@ -156,10 +176,11 @@ private:
QStringList getPath(QString playListName);
//初始化音乐
void initMusic();
PlaybackMode m_playbackMode = Loop; //当前列表的循环模式
private:
QDBusInterface *interface;
quint32 m_inhibitValue = 0; // 阻止锁屏cookie
QFocusEvent::Type type = QEvent::FocusIn;
QVBoxLayout *mainVBoxLayout = nullptr;
QHBoxLayout *mainHBoxLayout = nullptr;
TableOne *musicListTable = nullptr;

View File

@ -112,18 +112,60 @@ void miniWidget::leaveEvent(QEvent *)
void miniWidget::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Space)
{
Q_EMIT signalSpaceKey();
if(event->key() == Qt::Key_Space) {
Q_EMIT playPauseKeySignal();
}
else if(event->key() == Qt::Key_Right)
{
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Left) {
qDebug() << "ctrl+left";
Q_EMIT previousPlayKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Right) {
qDebug() << "ctrl+right";
Q_EMIT nextPlayKeySignal();
}
if (event->key() == Qt::Key_Up) {
qDebug() << "ctrl+up";
Q_EMIT addVolumeKeySignal();
}
if (event->key() == Qt::Key_Down) {
qDebug() << "ctrl+down";
Q_EMIT downVolumeKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_M) {
qDebug() << "ctrl+m";
Q_EMIT miniCompleteSwitchKeySignal();
}
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_L) {
qDebug() << "ctrl+l";
Q_EMIT loveSongKeySignal();
} else if(event->key() == Qt::Key_Right) {
return;
} else if(event->key() == Qt::Key_Left) {
return;
}
else if(event->key() == Qt::Key_Left)
{
return;
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_T){
qDebug() << "ctrl+t";
if (m_playbackMode == CurrentItemInLoop){
Q_EMIT changePlaybackMode(3);
m_playbackMode = Loop;
}
else if (m_playbackMode == Loop){
Q_EMIT changePlaybackMode(4);
m_playbackMode = Random;
}
else if (m_playbackMode == Random){
Q_EMIT changePlaybackMode(1);
m_playbackMode = CurrentItemInLoop;
}
}
QWidget::keyPressEvent(event);
}

View File

@ -42,6 +42,7 @@ class miniWidget : public QFrame
{
Q_OBJECT
public:
enum PlaybackMode { CurrentItemOnce=0, CurrentItemInLoop, Sequential, Loop, Random }; //播放循环模式枚举
explicit miniWidget(QWidget *parent = nullptr);
void mousePressEvent(QMouseEvent *);
@ -60,7 +61,25 @@ Q_SIGNALS:
void signalRefreshFav(QString listName);
//空格键控制播放暂停
void signalSpaceKey();
// Space 控制播放/暂停
void playPauseKeySignal();
// Ctrl+Left 控制上一首
void previousPlayKeySignal();
// Ctrl+Right 控制下一首
void nextPlayKeySignal();
// Ctrl+Up 控制音量增加
void addVolumeKeySignal();
// Ctrl+down 控制音量降低
void downVolumeKeySignal();
// Ctrl+M 切换 Mini/完整模式
void miniCompleteSwitchKeySignal();
// Ctrl+L 将歌曲添加到喜欢歌单
void loveSongKeySignal();
//Ctrl+T 切换播放模式
void changePlaybackMode(int mode);
private:
PlaybackMode m_playbackMode = Loop; //当前列表的循环模式
void initAction();
void initConnect();
//初始化样式

10
debian/changelog vendored
View File

@ -1,3 +1,13 @@
kylin-music (1.1.0.47-ok7) yangtze; urgency=medium
* BUG: 无
* 任务号:无
* 需求号:#22231 【快捷键优化】【音乐】新增快捷键调整需求
* 其他改动说明:无
* 其他改动影响域:无
-- denghao <denghao@kylinos.cn> Thu, 02 Nov 2023 10:09:55 +0800
kylin-music (1.1.0.47-ok6~0743) yangtze; urgency=medium
* [BUG]