Perfect about page

pull/11/head
cutefishd 6 years ago
parent bc88c4baf5
commit adca1b382b

2
debian/control vendored

@ -29,6 +29,8 @@ Depends: qml-module-qtquick-controls2,
qml-module-qtqml,
qml-module-qtquick-window2,
qml-module-qtquick-shapes,
qml-module-qtquick-dialogs,
qml-module-qtquick-particles2,
${misc:Depends},
${shlibs:Depends}
Description: CutefishOS Settings

@ -1,6 +1,8 @@
#include "about.h"
#include <KFormat>
#include <QStorageInfo>
#include <QRegularExpression>
#ifdef Q_OS_LINUX
#include <sys/sysinfo.h>
@ -19,6 +21,11 @@ QString About::osName()
return QSysInfo::prettyProductName();
}
QString About::architecture()
{
return QSysInfo::currentCpuArchitecture();
}
QString About::kernelType()
{
return QSysInfo::kernelType();
@ -60,6 +67,37 @@ QString About::prettyProductName()
return QSysInfo::prettyProductName();
}
QString About::internalStorage()
{
QStorageInfo storage = QStorageInfo::root();
return QString("%1 / %2")
.arg(KFormat().formatByteSize(storage.bytesTotal() - storage.bytesAvailable()))
.arg(KFormat().formatByteSize(storage.bytesTotal(), 0));
}
QString About::cpuInfo()
{
QFile file("/proc/cpuinfo");
if (file.open(QIODevice::ReadOnly)) {
QString buffer = file.readAll();
QStringList modelLine = buffer.split('\n').filter(QRegularExpression("^model name"));
QStringList lines = buffer.split('\n');
int count = lines.filter(QRegularExpression("^processor")).count();
QString result;
result.append(modelLine.first().split(':').at(1));
if (count > 0)
result.append(QString(" x %1").arg(count));
return result;
}
return QString();
}
qlonglong About::calculateTotalRam() const
{
qlonglong ret = -1;

@ -9,32 +9,33 @@
class About : public QObject
{
Q_OBJECT
Q_PROPERTY(QString osName READ osName NOTIFY stub)
Q_PROPERTY(QString kernelVersion READ kernelVersion NOTIFY stub)
Q_PROPERTY(QString hostname READ hostname NOTIFY stub)
Q_PROPERTY(QString userName READ userName NOTIFY stub)
Q_PROPERTY(QString memorySize READ memorySize NOTIFY stub)
Q_PROPERTY(QString prettyProductName READ prettyProductName NOTIFY stub)
Q_PROPERTY(QString osName READ osName CONSTANT)
Q_PROPERTY(QString architecture READ architecture CONSTANT)
Q_PROPERTY(QString kernelVersion READ kernelVersion CONSTANT)
Q_PROPERTY(QString hostname READ hostname CONSTANT)
Q_PROPERTY(QString userName READ userName CONSTANT)
Q_PROPERTY(QString memorySize READ memorySize CONSTANT)
Q_PROPERTY(QString prettyProductName READ prettyProductName CONSTANT)
Q_PROPERTY(QString internalStorage READ internalStorage CONSTANT)
Q_PROPERTY(QString cpuInfo READ cpuInfo CONSTANT)
public:
explicit About(QObject *parent = nullptr);
QString osName();
QString architecture();
QString kernelType();
QString kernelVersion();
QString hostname();
QString userName();
QString settingsVersion();
QString memorySize();
QString prettyProductName();
QString internalStorage();
QString cpuInfo();
private:
qlonglong calculateTotalRam() const;
// Only here so that QML doesn't whine about non-NOTIFYable properties.
signals:
void stub();
};
#endif // ABOUT_H

@ -45,7 +45,12 @@ ItemPage {
StandardItem {
key: qsTr("System Version")
value: "0.1"
value: "0.2"
}
StandardItem {
key: qsTr("System Type")
value: about.architecture
}
StandardItem {
@ -53,10 +58,20 @@ ItemPage {
value: about.kernelVersion
}
StandardItem {
key: qsTr("Processor")
value: about.cpuInfo
}
StandardItem {
key: qsTr("RAM")
value: about.memorySize
}
StandardItem {
key: qsTr("Internal Storage")
value: about.internalStorage
}
}
}
}

@ -49,12 +49,12 @@ Item {
iconSource: "qrc:/images/sidebar/network.svg"
}
ListElement {
title: qsTr("Bluetooth")
name: "bluetooth"
page: "qrc:/qml/BluetoothPage.qml"
iconSource: "qrc:/images/sidebar/bluetooth.svg"
}
// ListElement {
// title: qsTr("Bluetooth")
// name: "bluetooth"
// page: "qrc:/qml/BluetoothPage.qml"
// iconSource: "qrc:/images/sidebar/bluetooth.svg"
// }
ListElement {
title: qsTr("Appearance")

@ -24,11 +24,11 @@ ItemPage {
anchors.topMargin: Meui.Units.smallSpacing
spacing: Meui.Units.largeSpacing
// DesktopPreview {
// Layout.alignment: Qt.AlignHCenter
// width: 500
// height: 300
// }
// DesktopPreview {
// Layout.alignment: Qt.AlignHCenter
// width: 500
// height: 300
// }
RowLayout {
spacing: Meui.Units.largeSpacing * 2
@ -73,16 +73,17 @@ ItemPage {
// spacing: Meui.Units.smallSpacing
// orientation: Qt.Horizontal
height: count * itemSize
height: count * itemHeight
clip: true
model: background.backgrounds
currentIndex: -1
cellHeight: itemSize
cellWidth: itemSize
cellHeight: calcExtraSpacing(itemHeight, _view.height) + itemHeight
cellWidth: calcExtraSpacing(itemWidth, _view.width) + itemWidth
property int itemSize: 200
property int itemWidth: 250
property int itemHeight: 150
delegate: Item {
id: item
@ -161,6 +162,17 @@ ItemPage {
}
}
}
function calcExtraSpacing(cellSize, containerSize) {
var availableColumns = Math.floor(containerSize / cellSize)
var extraSpacing = 0
if (availableColumns > 0) {
var allColumnSize = availableColumns * cellSize
var extraSpace = Math.max(containerSize - allColumnSize, Meui.Units.largeSpacing)
extraSpacing = extraSpace / availableColumns
}
return Math.floor(extraSpacing)
}
}
}

@ -18,17 +18,32 @@
<source>System Version</source>
<translation>系统版本</translation>
</message>
<message>
<location filename="../src/qml/AboutPage.qml" line="52"/>
<source>System Type</source>
<translation>系统类型</translation>
</message>
<message>
<location filename="../src/qml/AboutPage.qml" line="72"/>
<source>Internal Storage</source>
<translation>内部存储</translation>
</message>
<message>
<source>Software Version</source>
<translation type="vanished">软件版本</translation>
</message>
<message>
<location filename="../src/qml/AboutPage.qml" line="52"/>
<location filename="../src/qml/AboutPage.qml" line="57"/>
<source>Kernel Version</source>
<translation>内核版本</translation>
</message>
<message>
<location filename="../src/qml/AboutPage.qml" line="57"/>
<location filename="../src/qml/AboutPage.qml" line="62"/>
<source>Processor</source>
<translation>处理器</translation>
</message>
<message>
<location filename="../src/qml/AboutPage.qml" line="67"/>
<source>RAM</source>
<translation>内存大小</translation>
</message>
@ -418,9 +433,8 @@
<translation>用户</translation>
</message>
<message>
<location filename="../src/qml/SideBar.qml" line="53"/>
<source>Bluetooth</source>
<translation>蓝牙</translation>
<translation type="vanished">蓝牙</translation>
</message>
<message>
<location filename="../src/qml/SideBar.qml" line="67"/>

Loading…
Cancel
Save