mirror of
https://github.com/oguzhaninan/Stacer.git
synced 2026-05-19 05:45:38 -04:00
updated disk info
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
#include "disk_info.h"
|
||||
#include <QDebug>
|
||||
|
||||
DiskInfo::DiskInfo()
|
||||
{ }
|
||||
|
||||
QList<Disk*> DiskInfo::getDisks() const
|
||||
{
|
||||
return disks;
|
||||
@@ -12,22 +9,17 @@ QList<Disk*> DiskInfo::getDisks() const
|
||||
void DiskInfo::updateDiskInfo()
|
||||
{
|
||||
disks.clear();
|
||||
try {
|
||||
QStringList result = CommandUtil::exec("df", { "-Pl" }).split(QChar('\n'));
|
||||
|
||||
QRegExp sep("\\s+");
|
||||
for (const QString &line : result.filter(QRegExp("^/")))
|
||||
{
|
||||
Disk *disk = new Disk;
|
||||
QStringList slist = line.split(sep);
|
||||
disk->name = slist.takeFirst();
|
||||
disk->size = slist.takeFirst().toLong() << 10;
|
||||
disk->used = slist.takeFirst().toLong() << 10;
|
||||
disk->free = slist.takeFirst().toLong() << 10;
|
||||
|
||||
disks << disk;
|
||||
}
|
||||
} catch (QString &ex) {
|
||||
qCritical() << ex;
|
||||
QList<QStorageInfo> storageInfoList = QStorageInfo::mountedVolumes();
|
||||
|
||||
for(const QStorageInfo &info: storageInfoList) {
|
||||
Disk *disk = new Disk;
|
||||
disk->name = info.displayName();
|
||||
disk->device = info.device();
|
||||
disk->size = info.bytesTotal();
|
||||
disk->used = info.bytesTotal() - info.bytesFree();
|
||||
disk->free = info.bytesFree();
|
||||
|
||||
disks << disk;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,16 @@
|
||||
|
||||
#include "Utils/command_util.h"
|
||||
#include "Utils/file_util.h"
|
||||
#include <QStorageInfo>
|
||||
#include "stacer-core_global.h"
|
||||
|
||||
#define PROC_MOUNTS "/proc/mounts"
|
||||
|
||||
class Disk;
|
||||
|
||||
#include "stacer-core_global.h"
|
||||
|
||||
class STACERCORESHARED_EXPORT DiskInfo
|
||||
{
|
||||
public:
|
||||
DiskInfo();
|
||||
|
||||
QList<Disk*> getDisks() const;
|
||||
void updateDiskInfo();
|
||||
|
||||
@@ -24,12 +22,12 @@ private:
|
||||
|
||||
class Disk {
|
||||
public:
|
||||
Disk() {}
|
||||
|
||||
QString name;
|
||||
QString device;
|
||||
quint64 size;
|
||||
quint64 free;
|
||||
quint64 used;
|
||||
};
|
||||
|
||||
|
||||
#endif // DISKINFO_H
|
||||
|
||||
@@ -24,6 +24,10 @@ namespace GSchemas {
|
||||
const QString Core = "org.compiz.core";
|
||||
const QString Preferences = "org.gnome.desktop.wm.preferences";
|
||||
}
|
||||
namespace Appearance {
|
||||
const QString Desktop = "org.gnome.nautilus.desktop";
|
||||
const QString Background = "org.gnome.desktop.background";
|
||||
}
|
||||
}
|
||||
|
||||
namespace GSchemaKeys {
|
||||
@@ -62,6 +66,15 @@ namespace GSchemaKeys {
|
||||
const QString ActionMiddleClick = "action-middle-click-titlebar";
|
||||
const QString ActionRightClick = "action-right-click-titlebar";
|
||||
}
|
||||
|
||||
namespace Appearance {
|
||||
const QString ShowDesktopIcons = "show-desktop-icons";
|
||||
const QString ShowComputerIcon = "computer-icon-visible";
|
||||
const QString ShowNetworkIcon = "network-icon-visible";
|
||||
const QString ShowTrashIcon = "trash-icon-visible";
|
||||
const QString ShowVolumesIcon = "volumes-icon-visible";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace GValues {
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
FormatUtil::FormatUtil()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString FormatUtil::formatBytes(const quint64 &bytes)
|
||||
{
|
||||
#define formatUnit(v, u, t) QString().sprintf("%.1f %s", \
|
||||
|
||||
@@ -9,8 +9,6 @@ public:
|
||||
static QString formatBytes(const quint64 &bytes);
|
||||
|
||||
private:
|
||||
FormatUtil();
|
||||
|
||||
static const quint64 KIBI = 1L << 10;
|
||||
static const quint64 MEBI = 1L << 20;
|
||||
static const quint64 GIBI = 1L << 30;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
#include "info_manager.h"
|
||||
|
||||
InfoManager::InfoManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InfoManager *InfoManager::_instance = NULL;
|
||||
|
||||
InfoManager *InfoManager::ins()
|
||||
|
||||
@@ -39,7 +39,6 @@ public:
|
||||
QList<Process> getProcesses() const;
|
||||
QString getUserName() const;
|
||||
private:
|
||||
InfoManager();
|
||||
static InfoManager *_instance;
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,13 +7,28 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>801</width>
|
||||
<height>571</height>
|
||||
<height>438</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
@@ -37,6 +52,12 @@
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="lblTrashIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Trash Icon</string>
|
||||
</property>
|
||||
@@ -44,6 +65,12 @@
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="lblNetworkIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Network Icon</string>
|
||||
</property>
|
||||
@@ -87,6 +114,12 @@
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblHomeIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Home Icon</string>
|
||||
</property>
|
||||
@@ -94,6 +127,12 @@
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lblMountedIcon_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Screen Keyboard</string>
|
||||
</property>
|
||||
@@ -101,6 +140,12 @@
|
||||
</item>
|
||||
<item row="4" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>title</string>
|
||||
</property>
|
||||
@@ -137,6 +182,12 @@
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QLabel" name="lblMountedIcon_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Login Mode</string>
|
||||
</property>
|
||||
@@ -144,6 +195,12 @@
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblMountedIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mounted Volumes Icon</string>
|
||||
</property>
|
||||
@@ -193,6 +250,12 @@
|
||||
</item>
|
||||
<item row="7" column="3">
|
||||
<widget class="QLabel" name="lblMountedIcon_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Screen Reader</string>
|
||||
</property>
|
||||
@@ -201,7 +264,7 @@
|
||||
<item row="5" column="4">
|
||||
<widget class="QComboBox" name="comboBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -225,6 +288,12 @@
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lblMountedIcon_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Desktop Mode</string>
|
||||
</property>
|
||||
@@ -232,6 +301,12 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Desktop Icons</string>
|
||||
</property>
|
||||
@@ -240,7 +315,7 @@
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -277,6 +352,12 @@
|
||||
</item>
|
||||
<item row="6" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>title</string>
|
||||
</property>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>815</width>
|
||||
<height>435</height>
|
||||
<width>896</width>
|
||||
<height>467</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -45,8 +45,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>813</width>
|
||||
<height>433</height>
|
||||
<width>894</width>
|
||||
<height>465</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@@ -166,7 +166,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -364,7 +364,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -389,7 +389,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -424,7 +424,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -462,7 +462,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
|
||||
@@ -47,7 +47,7 @@ void SettingsPage::init()
|
||||
QList<Disk*> disks = InfoManager::ins()->getDisks();
|
||||
|
||||
for (const Disk *disk : disks) {
|
||||
ui->disksCmb->addItem(disk->name, disk->name);
|
||||
ui->disksCmb->addItem(QString("%1 (%2)").arg(disk->device).arg(disk->name), disk->name);
|
||||
}
|
||||
|
||||
QString dk = apm->getDiskName();
|
||||
|
||||
Reference in New Issue
Block a user