更新文档

This commit is contained in:
feiyangqingyun
2023-09-08 13:52:30 +08:00
parent 9af16093a2
commit 8173abef29
39 changed files with 1556 additions and 1464 deletions

View File

@@ -59,128 +59,6 @@ DeviceSizeTable::DeviceSizeTable(QWidget *parent) : QTableWidget(parent)
//QTimer::singleShot(10, this, SLOT(load()));
}
QColor DeviceSizeTable::getBgColor() const
{
return this->bgColor;
}
QColor DeviceSizeTable::getChunkColor1() const
{
return this->chunkColor1;
}
QColor DeviceSizeTable::getChunkColor2() const
{
return this->chunkColor2;
}
QColor DeviceSizeTable::getChunkColor3() const
{
return this->chunkColor3;
}
QColor DeviceSizeTable::getTextColor1() const
{
return this->textColor1;
}
QColor DeviceSizeTable::getTextColor2() const
{
return this->textColor2;
}
QColor DeviceSizeTable::getTextColor3() const
{
return this->textColor3;
}
void DeviceSizeTable::load()
{
//清空原有数据
int row = this->rowCount();
for (int i = 0; i < row; ++i) {
this->removeRow(0);
}
#ifdef Q_OS_WIN
QFileInfoList list = QDir::drives();
foreach (QFileInfo dir, list) {
QString dirName = dir.absolutePath();
LPCWSTR lpcwstrDriver = (LPCWSTR)dirName.utf16();
ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes;
if (GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes)) {
QString use = QString::number((double)(liTotalBytes.QuadPart - liTotalFreeBytes.QuadPart) / GB, 'f', 1);
use += "G";
QString free = QString::number((double) liTotalFreeBytes.QuadPart / GB, 'f', 1);
free += "G";
QString all = QString::number((double) liTotalBytes.QuadPart / GB, 'f', 1);
all += "G";
int percent = 100 - ((double)liTotalFreeBytes.QuadPart / liTotalBytes.QuadPart) * 100;
insertSize(dirName, use, free, all, percent);
}
}
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
process->start("df", QStringList() << "-h");
#endif
}
void DeviceSizeTable::setBgColor(const QColor &bgColor)
{
if (this->bgColor != bgColor) {
this->bgColor = bgColor;
this->load();
}
}
void DeviceSizeTable::setChunkColor1(const QColor &chunkColor1)
{
if (this->chunkColor1 != chunkColor1) {
this->chunkColor1 = chunkColor1;
this->load();
}
}
void DeviceSizeTable::setChunkColor2(const QColor &chunkColor2)
{
if (this->chunkColor2 != chunkColor2) {
this->chunkColor2 = chunkColor2;
this->load();
}
}
void DeviceSizeTable::setChunkColor3(const QColor &chunkColor3)
{
if (this->chunkColor3 != chunkColor3) {
this->chunkColor3 = chunkColor3;
this->load();
}
}
void DeviceSizeTable::setTextColor1(const QColor &textColor1)
{
if (this->textColor1 != textColor1) {
this->textColor1 = textColor1;
this->load();
}
}
void DeviceSizeTable::setTextColor2(const QColor &textColor2)
{
if (this->textColor2 != textColor2) {
this->textColor2 = textColor2;
this->load();
}
}
void DeviceSizeTable::setTextColor3(const QColor &textColor3)
{
if (this->textColor3 != textColor3) {
this->textColor3 = textColor3;
this->load();
}
}
void DeviceSizeTable::readData()
{
#if defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
@@ -292,3 +170,125 @@ QSize DeviceSizeTable::minimumSizeHint() const
{
return QSize(200, 150);
}
QColor DeviceSizeTable::getBgColor() const
{
return this->bgColor;
}
void DeviceSizeTable::setBgColor(const QColor &bgColor)
{
if (this->bgColor != bgColor) {
this->bgColor = bgColor;
this->load();
}
}
QColor DeviceSizeTable::getChunkColor1() const
{
return this->chunkColor1;
}
void DeviceSizeTable::setChunkColor1(const QColor &chunkColor1)
{
if (this->chunkColor1 != chunkColor1) {
this->chunkColor1 = chunkColor1;
this->load();
}
}
QColor DeviceSizeTable::getChunkColor2() const
{
return this->chunkColor2;
}
void DeviceSizeTable::setChunkColor2(const QColor &chunkColor2)
{
if (this->chunkColor2 != chunkColor2) {
this->chunkColor2 = chunkColor2;
this->load();
}
}
QColor DeviceSizeTable::getChunkColor3() const
{
return this->chunkColor3;
}
void DeviceSizeTable::setChunkColor3(const QColor &chunkColor3)
{
if (this->chunkColor3 != chunkColor3) {
this->chunkColor3 = chunkColor3;
this->load();
}
}
QColor DeviceSizeTable::getTextColor1() const
{
return this->textColor1;
}
void DeviceSizeTable::setTextColor1(const QColor &textColor1)
{
if (this->textColor1 != textColor1) {
this->textColor1 = textColor1;
this->load();
}
}
QColor DeviceSizeTable::getTextColor2() const
{
return this->textColor2;
}
void DeviceSizeTable::setTextColor2(const QColor &textColor2)
{
if (this->textColor2 != textColor2) {
this->textColor2 = textColor2;
this->load();
}
}
QColor DeviceSizeTable::getTextColor3() const
{
return this->textColor3;
}
void DeviceSizeTable::setTextColor3(const QColor &textColor3)
{
if (this->textColor3 != textColor3) {
this->textColor3 = textColor3;
this->load();
}
}
void DeviceSizeTable::load()
{
//清空原有数据
int row = this->rowCount();
for (int i = 0; i < row; ++i) {
this->removeRow(0);
}
#ifdef Q_OS_WIN
QFileInfoList list = QDir::drives();
foreach (QFileInfo dir, list) {
QString dirName = dir.absolutePath();
LPCWSTR lpcwstrDriver = (LPCWSTR)dirName.utf16();
ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes;
if (GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes)) {
QString use = QString::number((double)(liTotalBytes.QuadPart - liTotalFreeBytes.QuadPart) / GB, 'f', 1);
use += "G";
QString free = QString::number((double) liTotalFreeBytes.QuadPart / GB, 'f', 1);
free += "G";
QString all = QString::number((double) liTotalBytes.QuadPart / GB, 'f', 1);
all += "G";
int percent = 100 - ((double)liTotalFreeBytes.QuadPart / liTotalBytes.QuadPart) * 100;
insertSize(dirName, use, free, all, percent);
}
}
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
process->start("df", QStringList() << "-h");
#endif
}

View File

@@ -26,6 +26,7 @@ class DeviceSizeTable : public QTableWidget
Q_PROPERTY(QColor chunkColor1 READ getChunkColor1 WRITE setChunkColor1)
Q_PROPERTY(QColor chunkColor2 READ getChunkColor2 WRITE setChunkColor2)
Q_PROPERTY(QColor chunkColor3 READ getChunkColor3 WRITE setChunkColor3)
Q_PROPERTY(QColor textColor1 READ getTextColor1 WRITE setTextColor1)
Q_PROPERTY(QColor textColor2 READ getTextColor2 WRITE setTextColor2)
Q_PROPERTY(QColor textColor3 READ getTextColor3 WRITE setTextColor3)
@@ -34,15 +35,16 @@ public:
explicit DeviceSizeTable(QWidget *parent = 0);
private:
QProcess *process; //执行命令进程
QProcess *process; //执行命令进程
QColor bgColor; //背景颜色
QColor chunkColor1; //进度颜色1
QColor chunkColor2; //进度颜色2
QColor chunkColor3; //进度颜色3
QColor textColor1; //文字颜色1
QColor textColor2; //文字颜色2
QColor textColor3; //文字颜色3
QColor bgColor; //背景颜色
QColor chunkColor1; //进度颜色1
QColor chunkColor2; //进度颜色2
QColor chunkColor3; //进度颜色3
QColor textColor1; //文字颜色1
QColor textColor2; //文字颜色2
QColor textColor3; //文字颜色3
private slots:
void readData();
@@ -50,34 +52,42 @@ private slots:
void insertSize(const QString &name, const QString &use, const QString &free, const QString &all, int percent);
public:
QColor getBgColor() const;
QColor getChunkColor1() const;
QColor getChunkColor2() const;
QColor getChunkColor3() const;
QColor getTextColor1() const;
QColor getTextColor2() const;
QColor getTextColor3() const;
//默认尺寸和最小尺寸
QSize sizeHint() const;
QSize minimumSizeHint() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
//获取和设置背景颜色
QColor getBgColor() const;
void setBgColor(const QColor &bgColor);
//获取和设置进度颜色1
QColor getChunkColor1() const;
void setChunkColor1(const QColor &chunkColor1);
//获取和设置进度颜色2
QColor getChunkColor2() const;
void setChunkColor2(const QColor &chunkColor2);
//获取和设置进度颜色3
QColor getChunkColor3() const;
void setChunkColor3(const QColor &chunkColor3);
//获取和设置文字颜色1
QColor getTextColor1() const;
void setTextColor1(const QColor &textColor1);
//获取和设置文字颜色2
QColor getTextColor2() const;
void setTextColor2(const QColor &textColor2);
//获取和设置文字颜色3
QColor getTextColor3() const;
void setTextColor3(const QColor &textColor3);
public Q_SLOTS:
//载入容量
void load();
//设置背景颜色
void setBgColor(const QColor &bgColor);
//设置进度颜色
void setChunkColor1(const QColor &chunkColor1);
void setChunkColor2(const QColor &chunkColor2);
void setChunkColor3(const QColor &chunkColor3);
//设置文字颜色
void setTextColor1(const QColor &textColor1);
void setTextColor2(const QColor &textColor2);
void setTextColor3(const QColor &textColor3);
Q_SIGNALS:
void sdcardReceive(const QString &sdcardName);
void udiskReceive(const QString &udiskName);