From e3a24d42523e05a56b0e261f986f1ec174db50bc Mon Sep 17 00:00:00 2001 From: yushuoqi Date: Sat, 16 Jul 2022 19:18:48 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20#128772,=20=E8=A7=A3=E5=86=B3=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E5=8F=B3=E9=94=AE=E5=88=A0=E9=99=A4=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E6=AD=8C=E6=9B=B2=E9=87=8D=E5=A4=8D=E5=BC=B9=E5=87=BA=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=AA=97=E5=8F=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI/tableview/tableone.cpp | 186 +++++++++++++++++++----- UI/tableview/tableone.h | 1 + translations/kylin-music_bo_CN.ts | 8 ++ translations/kylin-music_zh_CN.qm | Bin 7895 -> 7982 bytes translations/kylin-music_zh_CN.ts | 229 ++++++++++++++++-------------- 5 files changed, 283 insertions(+), 141 deletions(-) diff --git a/UI/tableview/tableone.cpp b/UI/tableview/tableone.cpp index 3cb110c..15da958 100644 --- a/UI/tableview/tableone.cpp +++ b/UI/tableview/tableone.cpp @@ -4,6 +4,7 @@ #include #include "tableone.h" #include "UI/mainwidget.h" +#include "UI/base/widgetstyle.h" #define PT_18 18 @@ -366,8 +367,8 @@ void TableOne::isDeleteSongs() //确认将选中的歌曲从歌单中删除? QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("Confirm that the selected song will be deleted from the song list?"),QMessageBox::Yes | QMessageBox::No); warn->setWindowTitle(tr("kylin-music")); -// warn->button(QMessageBox::Yes)->setText("确定"); -// warn->button(QMessageBox::No)->setText("取消"); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); + warn->button(QMessageBox::No)->setText(tr("No")); int result = warn->exec(); if(result == QMessageBox::Yes) { @@ -383,21 +384,26 @@ void TableOne::isDeleteSongs() void TableOne::isDeleteLocalSongs() { - //歌曲从本地删除后不可恢复,是否确定删除? -// QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("After the song is deleted from the local, it cannot be resumed. Is it sure to delete?"),QMessageBox::Yes | QMessageBox::No); -//// warn->button(QMessageBox::Yes)->setText("确定"); -//// warn->button(QMessageBox::No)->setText("取消"); -// int result = warn->exec(); -// if(result == QMessageBox::Yes) -// { + + if (! WidgetStyle::isWayland) { deleteLocalSongs(); -// qDebug() << "QMessageBox::Yes"; -// } -// else -// { -// qDebug() << "QMessageBox::No"; -// return; -// } + + return; + } + + //歌曲从本地删除后不可恢复,是否确定删除? + QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("After the song is deleted from the local, it cannot be resumed. Is it sure to delete?"),QMessageBox::Yes | QMessageBox::No); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); + warn->button(QMessageBox::No)->setText(tr("No")); + int result = warn->exec(); + + if(result == QMessageBox::Yes) { + deleteLocalSongsWayland(); + qDebug() << "QMessageBox::Yes"; + } else { + qDebug() << "QMessageBox::No"; + return; + } } void TableOne::deleteSongs() @@ -450,8 +456,20 @@ void TableOne::deleteSongs() void TableOne::deleteLocalSongs() { m_map = getSelectedTaskIdList(); + + QStringList trashFilenames; + for (int key: m_map.keys()) { + QString value = m_map.value(key); + QString urlFile = "file://" + value; + qDebug() << "filename: " << urlFile; + trashFilenames << urlFile; + } + qDebug() << "trashFilenames: " << trashFilenames; + + for (int key : m_map.keys()) { QString value = m_map.value(key); + QFile file(value); if(file.exists()) { @@ -502,43 +520,37 @@ void TableOne::deleteLocalSongs() } else { QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("After the song is deleted from the local, it cannot be resumed. Is it sure to delete?"),QMessageBox::Yes | QMessageBox::No); warn->setWindowTitle(tr("kylin-music")); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); + warn->button(QMessageBox::No)->setText(tr("No")); int result = warn->exec(); if(result == QMessageBox::Yes) { int ret; int index = -1; - if(nowListName != nowPlayListName && nowListName == ALLMUSIC) - { + if(nowListName != nowPlayListName && nowListName == ALLMUSIC) { index = MusicFileInformation::getInstance().findIndexFromPlayList(nowPlayListName,value); } - if(nowListName != ALLMUSIC) - { + + if(nowListName != ALLMUSIC) { ret = g_db->delMusicFromPlayList(value,nowListName); - } - else - { + } else { ret = g_db->delSongFromEveryWhere(value); } - if(ret == 0) - { + + if(ret == 0) { if((nowListName != nowPlayListName) && nowListName == ALLMUSIC && index != -1) { playController::getInstance().removeSongFromCurList(nowPlayListName,index); - } - else - { + } else { playController::getInstance().removeSongFromCurList(nowListName,key); } - if(nowListName == FAV) - { + if(nowListName == FAV) { Q_EMIT removeILoveFilepathSignal(value); } m_map.remove(key); - } - else - { + } else { qDebug() << "delete failed" << value; } selectListChanged(nowListName); @@ -551,6 +563,105 @@ void TableOne::deleteLocalSongs() } +/** + * @brief TableOne::deleteLocalSongsWayland + */ +void TableOne::deleteLocalSongsWayland() +{ + m_map = getSelectedTaskIdList(); + + QStringList trashFilenames; + for (int key: m_map.keys()) { + QString value = m_map.value(key); + QString urlFile = "file://" + value; + qDebug() << "filename: " << urlFile; + trashFilenames << urlFile; + } + qDebug() << "trashFilenames: " << trashFilenames; + + + for (int key : m_map.keys()) { + QString value = m_map.value(key); + QFile file(value); + + if(file.exists()) { + file.remove(); + + int ret; + int index = -1; + if(nowListName != nowPlayListName && nowListName == ALLMUSIC) { + index = MusicFileInformation::getInstance().findIndexFromPlayList(nowPlayListName,value); + } + + if(nowListName != ALLMUSIC) { + ret = g_db->delMusicFromPlayList(value,nowListName); + } else { + ret = g_db->delSongFromEveryWhere(value); + } + + if(ret == 0) { + if((nowListName != nowPlayListName) && nowListName == ALLMUSIC && index != -1) + { + playController::getInstance().removeSongFromCurList(nowPlayListName,index); + } else { + playController::getInstance().removeSongFromCurList(nowListName,key); + } + + if(nowListName == FAV) { + Q_EMIT removeILoveFilepathSignal(value); + } + + m_map.remove(key); + } else { + qDebug() << "delete failed" << value; + } + selectListChanged(nowListName); + Q_EMIT refreshHistoryListSignal(); + + } else { + QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("After the song is deleted from the local, it cannot be resumed. Is it sure to delete?"),QMessageBox::Yes | QMessageBox::No); + warn->setWindowTitle(tr("kylin-music")); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); + warn->button(QMessageBox::No)->setText(tr("No")); + int result = warn->exec(); + + if(result == QMessageBox::Yes) { + int ret; + int index = -1; + if(nowListName != nowPlayListName && nowListName == ALLMUSIC) { + index = MusicFileInformation::getInstance().findIndexFromPlayList(nowPlayListName,value); + } + + if(nowListName != ALLMUSIC) { + ret = g_db->delMusicFromPlayList(value,nowListName); + } else { + ret = g_db->delSongFromEveryWhere(value); + } + + if(ret == 0) { + if((nowListName != nowPlayListName) && nowListName == ALLMUSIC && index != -1) { + playController::getInstance().removeSongFromCurList(nowPlayListName,index); + } else { + playController::getInstance().removeSongFromCurList(nowListName,key); + } + + if(nowListName == FAV) { + Q_EMIT removeILoveFilepathSignal(value); + } + + m_map.remove(key); + } else { + qDebug() << "delete failed" << value; + } + selectListChanged(nowListName); + Q_EMIT refreshHistoryListSignal(); + } else { + return; + } + } + } +} + void TableOne::playSongs() { int index = tableView->currentIndex().row(); @@ -817,7 +928,8 @@ void TableOne::importFinished(int successCount, int m_failCount, int allCount) } QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("Success add %1 songs").arg(successCount),QMessageBox::Yes,Widget::mutual); warn->setWindowTitle(tr("kylin-music")); - warn->button(QMessageBox::Yes)->setText("确定"); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); +// warn->button(QMessageBox::No)->setText(tr("No")); // Add this will segment error warn->exec(); } else @@ -829,7 +941,7 @@ void TableOne::importFinished(int successCount, int m_failCount, int allCount) } QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("Add failed"),QMessageBox::Yes,Widget::mutual); warn->setWindowTitle(tr("kylin-music")); - warn->button(QMessageBox::Yes)->setText("确定"); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); warn->exec(); } } @@ -840,7 +952,7 @@ void TableOne::importFailed(int successCount, int m_failCount, int allCount) { QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("Success add %1 songs").arg(successCount),QMessageBox::Yes,Widget::mutual); warn->setWindowTitle(tr("kylin-music")); - warn->button(QMessageBox::Yes)->setText("确定"); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); warn->exec(); } else @@ -848,7 +960,7 @@ void TableOne::importFailed(int successCount, int m_failCount, int allCount) if (m_failCount > 0) { QMessageBox *warn = new QMessageBox(QMessageBox::Warning,tr("Prompt information"),tr("Repeat add"),QMessageBox::Yes,Widget::mutual); warn->setWindowTitle(tr("kylin-music")); - warn->button(QMessageBox::Yes)->setText("确定"); + warn->button(QMessageBox::Yes)->setText(tr("Yes")); warn->exec(); } } diff --git a/UI/tableview/tableone.h b/UI/tableview/tableone.h index 10f4242..45d6722 100644 --- a/UI/tableview/tableone.h +++ b/UI/tableview/tableone.h @@ -84,6 +84,7 @@ private: void isDeleteLocalSongs(); //是否从本地删除歌曲 void deleteSongs(); //从歌单中删除歌曲 void deleteLocalSongs(); //从本地以及歌单中删除歌曲 + void deleteLocalSongsWayland(); //从本地以及歌单中删除歌曲 void playSongs(); void showInfo(); diff --git a/translations/kylin-music_bo_CN.ts b/translations/kylin-music_bo_CN.ts index 612a014..177d23d 100644 --- a/translations/kylin-music_bo_CN.ts +++ b/translations/kylin-music_bo_CN.ts @@ -467,6 +467,14 @@ kylin-music + + Yes + + + + No + + TitleBar diff --git a/translations/kylin-music_zh_CN.qm b/translations/kylin-music_zh_CN.qm index dafb9f106ef7e017eb1ed4df19de82c71b2f2ea0..0ea56943692eef3bd63584a1b8ff92ce88989e46 100644 GIT binary patch delta 498 zcmca^yUuQctQQLd0|To+1A~w@14H~_1_qIp3@knC85qQ^8CX_y1L-sdmNy1Kx|e~~ zEP;W6-3~%?Y=h8J%?zwIp+NaN6T{^>{TNt#fF?>RPOKMaoH}v3zGM=Eoxmgp1_@>e zEwzrpecBPAa^Z>h|}RFea7O+<&65A513K6yQ(JY&J+^NjA25iEBk4*>Pw zVtK#=w25&BtFp5SP~XqV`b^@CcPG0unKM3|T+gH*n9Sk-GoOKh=O;(^ygr~CjX1Wp z18v~6=h!Ry59ktOjECZ0< zH2FW1nUI(!sO%3@|^Sd4q5_TCXzk*J+m^CG}mMccG=0vtU{ZeSr~-` rg0JOvZ~!f4U;|<%zx>UHVtGsg6?xIK;G)ctsgoOpg*VTWuw(-OvNL_C delta 449 zcmZ2ycinb^tQGSI29}=n3=Cpl7+6+xGcbtDGqAid0Mc#@tY!%e4D5CgnqwP;ma<`B zwFw2vPo0=9&#BG8+QY)YAaQGAzc{1c#O3;u(hPP2lYr8DAhc9EgZs22K;zF$d@s+K zJDHzR+|ZdJrere%1OH8iEVHQ$45Gyh*FqLBFtF$|hM)S(z`(Z-LW{I9ZdYw#U=aQ_ zIh;|SF<^2#qdwqGx|=x&*&~G$Z|*W08sxemIpjQs~BgnDm$w% zFoj3_pTf7fPP&vIhI zo>`4a^5*30%<`Pod MyToolButton - - + + Play 播放 - - + + Pause 暂停 - - + + Rename 重命名 - - + + Delete 删除 - + Song List 歌曲列表 - + I Love 我喜欢 @@ -225,64 +225,64 @@ PlaySongArea - + Previous 上一首 - + Next 下一首 - + Volume 音量 - + Favourite 收藏 - - - - + + + + Loop 列表循环 - + Play List 播放历史 - - - - - - + + + + + + Music Player 音乐 - + 00:00/00:00 00:00/00:00 - - + + I Love 我喜欢 - - - - + + + + Random 随机播放 @@ -291,10 +291,10 @@ 顺序播放 - - - - + + + + CurrentItemInLoop 单曲循环 @@ -336,17 +336,17 @@ SideBarWidget - + Music Player 音乐 - + Library 音乐库 - + Song List 歌曲列表 @@ -356,30 +356,30 @@ 我的歌单 - - + + New Playlist 新建歌单 - + Rename 重命名 - + I Love 我喜欢 - - + + Prompt information 提示信息 - - + + Single song name already exists!!! 歌单名已存在! @@ -476,121 +476,141 @@ 时长 - - - - + + + + Song List 歌曲列表 - + There are no songs! 还没有歌曲! - + Play All 播放全部 - + Add Music 添加音乐 - + Add local songs 添加本地音乐 - + Add local folders 添加本地文件夹 - + Add Local Songs 添加本地音乐 - + Add Local Folder 添加本地文件夹 - - - - - + + + + + I Love 我喜欢 - - - - - - + + + + + + Search Result 搜索结果 - + Play 播放 - + Delete from list 从歌单中删除 - + Remove from local 从本地删除 - + Confirm that the selected song will be deleted from the song list? 确认将选中的歌曲从歌单中删除? - - - - - - - - + + + + + + + + kylin-music 音乐 - + + + + + + + + Yes + 确定 + + + + + + + No + 取消 + + + + After the song is deleted from the local, it cannot be resumed. Is it sure to delete? 歌曲从本地删除后不可恢复,是否确定删除? - + Audio File 音频文件 - + This format file is not supported 不支持此格式文件 - + Repeat add 重复添加 - + path does not exist 路径不存在 @@ -599,13 +619,13 @@ 您确定从本地删除吗? - - + + Success add %1 songs 成功添加%1首歌曲 - + Add failed 添加失败 @@ -614,22 +634,23 @@ 删除 - + View song information 查看歌曲信息 - + Add to songlist 添加到歌单 - - - - - - + + + + + + + Prompt information 提示信息 @@ -646,7 +667,7 @@ - + songs 首歌曲 @@ -700,7 +721,7 @@ Widget - + Music Player 音乐 @@ -709,19 +730,19 @@ 歌曲列表 - - + + reduction 还原 - - + + maximize 最大化 - + Prompt information 提示信息