Prepare new maemo release
[maemo-rb.git] / rbutil / rbutilqt / sysinfo.cpp
blobaeee76d0568957540550d8618c2a8bc77f3018f8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
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.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
19 #include <QDialog>
20 #include "sysinfo.h"
21 #include "ui_sysinfofrm.h"
22 #include "system.h"
23 #include "utils.h"
24 #include "autodetection.h"
27 Sysinfo::Sysinfo(QWidget *parent) : QDialog(parent)
29 ui.setupUi(this);
31 updateSysinfo();
32 connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(close()));
33 connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(updateSysinfo()));
36 void Sysinfo::updateSysinfo(void)
38 ui.textBrowser->setHtml(getInfo());
41 QString Sysinfo::getInfo()
43 QString info;
44 info += tr("<b>OS</b><br/>") + System::osVersionString() + "<hr/>";
45 info += tr("<b>Username</b><br/>%1<hr/>").arg(System::userName());
46 #if defined(Q_OS_WIN32)
47 info += tr("<b>Permissions</b><br/>%1<hr/>").arg(System::userPermissionsString());
48 #endif
49 info += tr("<b>Attached USB devices</b><br/>");
50 QMap<uint32_t, QString> usbids = System::listUsbDevices();
51 QList<uint32_t> usbkeys = usbids.keys();
52 for(int i = 0; i < usbkeys.size(); i++) {
53 info += tr("VID: %1 PID: %2, %3")
54 .arg((usbkeys.at(i)&0xffff0000)>>16, 4, 16, QChar('0'))
55 .arg(usbkeys.at(i)&0xffff, 4, 16, QChar('0'))
56 .arg(usbids.value(usbkeys.at(i)));
57 if(i + 1 < usbkeys.size())
58 info += "<br/>";
60 info += "<hr/>";
62 info += "<b>" + tr("Filesystem") + "</b>";
63 QStringList drives = Utils::mountpoints();
64 info += "<table>";
65 info += "<tr><td>" + tr("Mountpoint") + "</td><td>" + tr("Label")
66 + "</td><td>" + tr("Free") + "</td><td>" + tr("Total") + "</td><td>"
67 + tr("Cluster Size") + "</td></tr>";
68 for(int i = 0; i < drives.size(); i++) {
69 info += tr("<tr><td>%1</td><td>%4</td><td>%2 GiB</td><td>%3 GiB</td><td>%5</td></tr>")
70 .arg(QDir::toNativeSeparators(drives.at(i)))
71 .arg((double)Utils::filesystemFree(drives.at(i)) / (1<<30), 0, 'f', 2)
72 .arg((double)Utils::filesystemTotal(drives.at(i)) / (1<<30), 0, 'f', 2)
73 .arg(Utils::filesystemName(drives.at(i)))
74 .arg(Utils::filesystemClusterSize(drives.at(i)));
76 info += "</table>";
77 info += "<hr/>";
79 return info;
83 void Sysinfo::changeEvent(QEvent *e)
85 if(e->type() == QEvent::LanguageChange) {
86 ui.retranslateUi(this);
87 } else {
88 QWidget::changeEvent(e);