diff options
Diffstat (limited to 'utils/rbutilqt/sysinfo.cpp')
-rw-r--r-- | utils/rbutilqt/sysinfo.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/utils/rbutilqt/sysinfo.cpp b/utils/rbutilqt/sysinfo.cpp new file mode 100644 index 0000000000..7d05bb8c9a --- /dev/null +++ b/utils/rbutilqt/sysinfo.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Riebeling | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | #include <QDialog> | ||
20 | #include <QDir> | ||
21 | #include "sysinfo.h" | ||
22 | #include "ui_sysinfofrm.h" | ||
23 | #include "system.h" | ||
24 | #include "utils.h" | ||
25 | #include "autodetection.h" | ||
26 | |||
27 | |||
28 | Sysinfo::Sysinfo(QWidget *parent) : QDialog(parent) | ||
29 | { | ||
30 | ui.setupUi(this); | ||
31 | |||
32 | updateSysinfo(); | ||
33 | connect(ui.buttonOk, &QAbstractButton::clicked, this, &Sysinfo::close); | ||
34 | connect(ui.buttonRefresh, &QAbstractButton::clicked, this, &Sysinfo::updateSysinfo); | ||
35 | } | ||
36 | |||
37 | void Sysinfo::updateSysinfo(void) | ||
38 | { | ||
39 | ui.textBrowser->setHtml(getInfo()); | ||
40 | } | ||
41 | |||
42 | QString Sysinfo::getInfo(Sysinfo::InfoType type) | ||
43 | { | ||
44 | QString info; | ||
45 | info += tr("<b>OS</b><br/>") + System::osVersionString() + "<hr/>"; | ||
46 | info += tr("<b>Username</b><br/>%1<hr/>").arg(System::userName()); | ||
47 | #if defined(Q_OS_WIN32) | ||
48 | info += tr("<b>Permissions</b><br/>%1<hr/>").arg(System::userPermissionsString()); | ||
49 | #endif | ||
50 | info += tr("<b>Attached USB devices</b><br/>"); | ||
51 | QMultiMap<uint32_t, QString> usbids = System::listUsbDevices(); | ||
52 | QList<uint32_t> usbkeys = usbids.keys(); | ||
53 | for(int i = 0; i < usbkeys.size(); i++) { | ||
54 | info += tr("VID: %1 PID: %2, %3") | ||
55 | .arg((usbkeys.at(i)&0xffff0000)>>16, 4, 16, QChar('0')) | ||
56 | .arg(usbkeys.at(i)&0xffff, 4, 16, QChar('0')) | ||
57 | .arg(usbids.value(usbkeys.at(i))); | ||
58 | if(i + 1 < usbkeys.size()) | ||
59 | info += "<br/>"; | ||
60 | } | ||
61 | info += "<hr/>"; | ||
62 | |||
63 | info += "<b>" + tr("Filesystem") + "</b>"; | ||
64 | QStringList drives = Utils::mountpoints(); | ||
65 | info += "<table>"; | ||
66 | info += "<tr><td>" + tr("Mountpoint") + "</td><td>" + tr("Label") | ||
67 | + "</td><td>" + tr("Free") + "</td><td>" + tr("Total") + "</td><td>" | ||
68 | + tr("Type") + "</td><td></tr>"; | ||
69 | for(int i = 0; i < drives.size(); i++) { | ||
70 | info += tr("<tr><td>%1</td><td>%4</td><td>%2 GiB</td><td>%3 GiB</td><td>%5</td></tr>") | ||
71 | .arg(QDir::toNativeSeparators(drives.at(i))) | ||
72 | .arg((double)Utils::filesystemFree(drives.at(i)) / (1<<30), 0, 'f', 2) | ||
73 | .arg((double)Utils::filesystemTotal(drives.at(i)) / (1<<30), 0, 'f', 2) | ||
74 | .arg(Utils::filesystemName(drives.at(i))) | ||
75 | .arg(Utils::filesystemType(drives.at(i))); | ||
76 | } | ||
77 | info += "</table>"; | ||
78 | info += "<hr/>"; | ||
79 | if(type == InfoText) { | ||
80 | info.replace(QRegExp("(<[^>]+>)+"),"\n"); | ||
81 | } | ||
82 | |||
83 | return info; | ||
84 | } | ||
85 | |||
86 | |||
87 | void Sysinfo::changeEvent(QEvent *e) | ||
88 | { | ||
89 | if(e->type() == QEvent::LanguageChange) { | ||
90 | ui.retranslateUi(this); | ||
91 | } else { | ||
92 | QWidget::changeEvent(e); | ||
93 | } | ||
94 | } | ||
95 | |||