Task#147972, support great wall and 9215 controler device disks trash files.

This commit is contained in:
hemh 2023-04-20 15:09:22 +08:00 committed by Yue-Lan
parent fa9b792399
commit 961c0c26db
6 changed files with 89 additions and 1 deletions

View File

@ -181,6 +181,12 @@ void DirectoryViewMenu::fillActions()
qDebug() << "canEject :" << canEject;
}
//task#147972 【删除回收站】选项需求
//如果是长城的机器并且带了9215控制器不再区分移动设备统一右键删除到回收站
bool trashSettings = GlobalSettings::getInstance()->getValue(TRASH_MOBILE_FILES).toBool();
if (trashSettings)
m_is_mobile_file = false;
QString homeUri = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
QString musicUri = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
QString desktop = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);

View File

@ -41,6 +41,7 @@
#include "file-operation-internal-dialog.h"
#include "sound-effect.h"
#include "global-settings.h"
#include <QUrl>
#include <QFileInfo>
@ -154,6 +155,12 @@ FileOperation *FileOperationUtils::trash(const QStringList &uris, bool addHistor
// }
// qDebug() <<"total_size:" <<total_size<<ONE_GIB_SIZE<<canNotTrash<<isBigFile;
//task#147972 【删除回收站】选项需求
//如果是长城的机器并且带了9215控制器不再区分移动设备统一右键删除到回收站
bool trashSettings = GlobalSettings::getInstance()->getValue(TRASH_MOBILE_FILES).toBool();
if (trashSettings)
break;
//file total size more than 10G, not trash but delete, task#56444
//FIXME 判断是否是移动设备文件,可能不准确, 目前暂未找到好的判断方法
bool isMobileDeviece = FileUtils::isMobileDeviceFile(uri);

View File

@ -65,6 +65,36 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
m_cache.insert(key, m_settings->value(key));
}
m_cache.insert(DISPLAY_STANDARD_ICONS, true);
if (QGSettings::isSchemaInstalled("org.ukui.peony.settings")) {
m_peonyGSettings = new QGSettings("org.ukui.peony.settings", "/org/ukui/peony/settings/", this);
connect(m_peonyGSettings, &QGSettings::changed, this, [=] (const QString &key) {
m_cache.remove(key);
m_cache.insert(key, m_peonyGSettings->get(key));
Q_EMIT this->valueChanged(key);
});
for (auto key : m_peonyGSettings->keys()) {
m_cache.remove(key);
m_cache.insert(key, m_peonyGSettings->get(key));
}
}
m_cache.insert(TRASH_MOBILE_FILES, false);
if (QGSettings::isSchemaInstalled("org.ukui.peony.settings")) {
m_peonyGSettings = new QGSettings("org.ukui.peony.settings", "/org/ukui/peony/settings/", this);
connect(m_peonyGSettings, &QGSettings::changed, this, [=] (const QString &key) {
m_cache.remove(key);
m_cache.insert(key, m_peonyGSettings->get(key));
Q_EMIT this->valueChanged(key);
});
for (auto key : m_peonyGSettings->keys()) {
m_cache.remove(key);
m_cache.insert(key, m_peonyGSettings->get(key));
}
}
m_date_format = tr("yyyy/MM/dd");
m_time_format = tr("HH:mm:ss");
if (QGSettings::isSchemaInstalled("org.ukui.control-center.panel.plugins")) {
@ -359,7 +389,7 @@ void GlobalSettings::resetAll()
void GlobalSettings::setValue(const QString &key, const QVariant &value)
{
if (key == REMOTE_SERVER_REMOTE_IP || key == DEFAULT_WINDOW_SIZE) {
if (key == REMOTE_SERVER_REMOTE_IP || key == DEFAULT_WINDOW_SIZE || !m_peonyGSettings->keys().contains(key)) {
m_cache.remove(key);
m_cache.insert(key, value);
QtConcurrent::run([=]() {

View File

@ -100,6 +100,9 @@
//Control the display of desktop standard icons
#define DISPLAY_STANDARD_ICONS "displayStandardIcons"
//control the mobile device trash file issue, if be true can trash mobile files
#define TRASH_MOBILE_FILES "trashMobileFiles"
// control center
#define UKUI_CONTROL_CENTER_PANEL_PLUGIN "org.ukui.control-center.panel.plugins" // schema
#define UKUI_CONTROL_CENTER_PANEL_PLUGIN_TIME "org.ukui.control-center.panel.plugins.time" // time format key, value is '12' or '24'

View File

@ -2,6 +2,12 @@
<schemalist>
<schema id="org.ukui.peony.settings" path="/org/ukui/peony/settings/">
<!--General-->
<key type="b" name="trash-mobile-files">
<default>false</default>
<summary>trash mobile files</summary>
<description>Control the mobile device trash file issue, if be true can trash mobile files</description>
</key>
<key type="b" name="display-standard-icons">
<default>true</default>
<summary>display standard icons</summary>

View File

@ -144,6 +144,39 @@ void trySetDefaultFolderUrlHandler() {
});
}
//task#147972, story#21858, GreatWall svn and SE9215 controler, all file provide trash option
void greatWallDeviceInit()
{
QtConcurrent::run([=]() {
QProcess process;
process.start("lspci | grep -c 88SE9215");
process.waitForFinished();
QString result = process.readAllStandardOutput();
qDebug() << "greatWallDeviceInit lspci:"<<result;
//not SE9215 controler
if (result == "0")
return;
QProcess process1;
process1.start("cat /sys/class/dmi/id/modalias");
process1.waitForFinished();
QString ret = process1.readAllStandardOutput();
QStringList infoList = ret.split(":");
for(QString info:infoList){
if (info.startsWith("cvn", Qt::CaseInsensitive)){
QString manufacturer = info.replace("cvn", "", Qt::CaseInsensitive);
qDebug() << "greatWallDeviceInit manufacturer:"<<manufacturer;
if (manufacturer.toUpper() == "GREATWALL")
{
//setGsetting value
GlobalSettings::getInstance()->setValue(TRASH_MOBILE_FILES, true);
}
break;
}
}
});
}
QRect caculateVirtualDesktopGeometry() {
QRegion screensRegion;
for (auto screen : qApp->screens()) {
@ -309,6 +342,9 @@ PeonyDesktopApplication::PeonyDesktopApplication(int &argc, char *argv[], const
auto message = this->arguments().join(' ').toUtf8();
parseCmd(message, !isRunning());
//check if is great wall device and init settings
greatWallDeviceInit();
qDebug()<<"monitor volumes change";
auto volumeManager = Peony::VolumeManager::getInstance();
connect(volumeManager,&Peony::VolumeManager::mountAdded,this,[=](const std::shared_ptr<Peony::Mount> &mount){