From 6d2ad96466ccc5e1f0bf4f2d4fd960b942fab7bd Mon Sep 17 00:00:00 2001 From: balloonflower Date: Mon, 19 Mar 2018 19:59:08 +0800 Subject: [PATCH] Solved the problem of Chinese messy code about file system info --- debian/changelog | 1 + plugins/systemmonitor/filesystemworker.cpp | 26 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6e7ebcd..4cc5580 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,5 +25,6 @@ kylin-assistant (1.0.0-0ubuntu1) bionic; urgency=low * Scaning system with Thread. * Renice process priority. * Make Minimize window work. + * Solved the problem of Chinese messy code about file system info. -- lixiang Mon, 29 Jan 2018 17:54:44 +0800 diff --git a/plugins/systemmonitor/filesystemworker.cpp b/plugins/systemmonitor/filesystemworker.cpp index 91cfd94..8d4885a 100644 --- a/plugins/systemmonitor/filesystemworker.cpp +++ b/plugins/systemmonitor/filesystemworker.cpp @@ -18,6 +18,7 @@ */ #include "filesystemworker.h" +#include "util.h" #include #include @@ -143,19 +144,38 @@ void FileSystemWorker::onFileSystemListChanged() for (i = 0; i < mountlist.number; i++) { DISK_INFO disk = add_disk(&entries[i], show_all_fs); if (disk.valid == 1) { - QString dev_name = QString(QLatin1String(disk.devname)); + std::string formatted_dev = make_string(g_strdup(disk.devname)); + QString dev_name = QString::fromStdString(formatted_dev); + //QString dev_name = QString(QLatin1String(disk.devname)); newDiskList.append(dev_name); if (!this->isDeviceContains(dev_name)) { FileSystemData *info = new FileSystemData(this); info->setDevName(dev_name); - info->updateDiskInfo(QString(QLatin1String(disk.mountdir)), QString(QLatin1String(disk.type)), QString(QLatin1String(g_format_size_full(disk.btotal, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bfree, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bavail, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bused, G_FORMAT_SIZE_DEFAULT))), disk.percentage/*QString::number(disk.percentage).append("%")*/); + + std::string formatted_mountdir(make_string(g_strdup(disk.mountdir))); + std::string formatted_type(make_string(g_strdup(disk.type))); + std::string formatted_btotal(make_string(g_strdup(g_format_size_full(disk.btotal, G_FORMAT_SIZE_DEFAULT)))); + std::string formatted_bfree(make_string(g_strdup(g_format_size_full(disk.bfree, G_FORMAT_SIZE_DEFAULT)))); + std::string formatted_bavail(make_string(g_strdup(g_format_size_full(disk.bavail, G_FORMAT_SIZE_DEFAULT)))); + std::string formatted_bused(make_string(g_strdup(g_format_size_full(disk.bused, G_FORMAT_SIZE_DEFAULT)))); + info->updateDiskInfo(QString::fromStdString(formatted_mountdir), QString::fromStdString(formatted_type), QString::fromStdString(formatted_btotal), QString::fromStdString(formatted_bfree), QString::fromStdString(formatted_bavail), QString::fromStdString(formatted_bused), disk.percentage/*QString::number(disk.percentage).append("%")*/); + +// info->updateDiskInfo(QString(QLatin1String(disk.mountdir)), QString(QLatin1String(disk.type)), QString(QLatin1String(g_format_size_full(disk.btotal, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bfree, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bavail, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bused, G_FORMAT_SIZE_DEFAULT))), disk.percentage/*QString::number(disk.percentage).append("%")*/); this->addDiskInfo(dev_name, info); } else {//update info which had exists FileSystemData *info = this->getDiskInfo(dev_name); if (info) { - info->updateDiskInfo(QString(QLatin1String(disk.mountdir)), QString(QLatin1String(disk.type)), QString(QLatin1String(g_format_size_full(disk.btotal, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bfree, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bavail, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bused, G_FORMAT_SIZE_DEFAULT))), disk.percentage/*QString::number(disk.percentage).append("%")*/); + std::string formatted_mountdir(make_string(g_strdup(disk.mountdir))); + std::string formatted_type(make_string(g_strdup(disk.type))); + std::string formatted_btotal(make_string(g_strdup(g_format_size_full(disk.btotal, G_FORMAT_SIZE_DEFAULT)))); + std::string formatted_bfree(make_string(g_strdup(g_format_size_full(disk.bfree, G_FORMAT_SIZE_DEFAULT)))); + std::string formatted_bavail(make_string(g_strdup(g_format_size_full(disk.bavail, G_FORMAT_SIZE_DEFAULT)))); + std::string formatted_bused(make_string(g_strdup(g_format_size_full(disk.bused, G_FORMAT_SIZE_DEFAULT)))); + info->updateDiskInfo(QString::fromStdString(formatted_mountdir), QString::fromStdString(formatted_type), QString::fromStdString(formatted_btotal), QString::fromStdString(formatted_bfree), QString::fromStdString(formatted_bavail), QString::fromStdString(formatted_bused), disk.percentage/*QString::number(disk.percentage).append("%")*/); + +// info->updateDiskInfo(QString(QLatin1String(disk.mountdir)), QString(QLatin1String(disk.type)), QString(QLatin1String(g_format_size_full(disk.btotal, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bfree, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bavail, G_FORMAT_SIZE_DEFAULT))), QString(QLatin1String(g_format_size_full(disk.bused, G_FORMAT_SIZE_DEFAULT))), disk.percentage/*QString::number(disk.percentage).append("%")*/); } } }