rewrite info, setting, cpu, network...

This commit is contained in:
李 翔 2018-01-17 11:45:16 +08:00
parent 9ab67deeea
commit a822a10ace
157 changed files with 548534 additions and 6352 deletions

View File

@ -64,7 +64,7 @@ class Desktop_Autostart_Manage():
else:
if OPTION_N in all_options and config.getboolean(SECTION, OPTION_N):
self.dic.setdefault(OPTION_N, []).append(filename)
else:
else:
#OPTION_O in all_options or OPTION_NOT in all_options or OPTION_X in all_options:
if (OPTION_O in all_options and current_desktop_env not in config.get(SECTION, OPTION_O)) or (OPTION_NOT in all_options and current_desktop_env in config.get(SECTION, OPTION_NOT)):
self.dic.setdefault('*showin', []).append(filename)

View File

@ -11,6 +11,7 @@ class SingleInstance(object):
def __init__(self,pidPath):
self.pidPath = pidPath
self.lasterror = False
if os.path.exists(pidPath):
# Make sure it is not a "stale" pidFile
pid = open(pidPath, 'r').read().strip()

View File

@ -24,8 +24,8 @@
#include <QDebug>
#include <QBoxLayout>
CleanerDetailWidget::CleanerDetailWidget(QWidget *parent, SessionDispatcher *seroxy, SystemDispatcher *syproxy, MainWindow *window, Toolkits *kits, QString skin)
: QWidget(parent), sessionproxy(seroxy), systemproxy(syproxy), parentWindow(window), toolKits(kits),cur_skin(skin),
CleanerDetailWidget::CleanerDetailWidget(QWidget *parent, /*SessionDispatcher *seroxy, SystemDispatcher *syproxy, */MainWindow *window, Toolkits *kits, QString skin)
: QWidget(parent), /*sessionproxy(seroxy), systemproxy(syproxy), */parentWindow(window), toolKits(kits),cur_skin(skin),
ui(new Ui::CleanerDetailWidget)
{
ui->setupUi(this);
@ -1150,8 +1150,9 @@ void CleanerDetailWidget::receiveCleanSignal()
else
{
// qDebug() << "args is.........." << argsData;
systemproxy->set_user_homedir_qt();
systemproxy->cleanAllSelectItems(argsData);
emit this->startCleanSystem(argsData);
// systemproxy->set_user_homedir_qt();
// systemproxy->cleanAllSelectItems(argsData);
}
}

View File

@ -44,7 +44,7 @@ class CleanerDetailWidget : public QWidget
Q_OBJECT
public:
explicit CleanerDetailWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, SystemDispatcher *syproxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png");
explicit CleanerDetailWidget(QWidget *parent = 0, /*SessionDispatcher *seroxy = 0, SystemDispatcher *syproxy = 0, */MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png");
~CleanerDetailWidget();
void setUIData();
void setLanguage();
@ -64,6 +64,7 @@ signals:
void notifyMainCheckBox(int status);
// void showActionAnimaiton();
void sendScanOverStatus(bool status);
void startCleanSystem(QMap<QString, QVariant> itemsMap);
private:
void initTitleBar();
@ -71,8 +72,8 @@ private:
private:
Ui::CleanerDetailWidget *ui;
MainWindow *parentWindow;
SessionDispatcher *sessionproxy;
SystemDispatcher *systemproxy;
// SessionDispatcher *sessionproxy;
// SystemDispatcher *systemproxy;
Toolkits *toolKits;
QMap<QString, QVariant> argsData;
CleanListWidget *cache_apt_items ;

View File

@ -22,8 +22,8 @@
#include "../src/mainwindow.h"
#include "../component/cleangroup.h"
CleanerMainWidget::CleanerMainWidget(QWidget *parent, SessionDispatcher *seroxy, MainWindow *window, Toolkits *kits, QString skin)
: QWidget(parent), sessionproxy(seroxy), parentWindow(window), toolKits(kits)
CleanerMainWidget::CleanerMainWidget(QWidget *parent, /*SessionDispatcher *seroxy, */MainWindow *window, Toolkits *kits, QString skin)
: QWidget(parent), /*sessionproxy(seroxy), */parentWindow(window), toolKits(kits)
{
this->setFixedSize(900, 403);
this->setObjectName("transparentWidget");
@ -156,7 +156,8 @@ void CleanerMainWidget::receiveScanSignal()
{
// qDebug() << "args is.........." << argsMap;
emit this->showActionAnimaiton();
sessionproxy->scanSystemCleanerItems(argsMap);
emit this->startScanSystem(argsMap);
// sessionproxy->scanSystemCleanerItems(argsMap);
}
}

View File

@ -33,7 +33,7 @@ class CleanerMainWidget : public QWidget
{
Q_OBJECT
public:
explicit CleanerMainWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png");
explicit CleanerMainWidget(QWidget *parent = 0, /*SessionDispatcher *seroxy = 0, */MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png");
~CleanerMainWidget();
void setLanguage();
void getAllScanSelectedItems();
@ -45,6 +45,7 @@ public slots:
signals:
void showActionAnimaiton();
void startScanSystem(QMap<QString, QVariant> itemsMap);
private:
MainWindow *parentWindow;
@ -60,7 +61,7 @@ private:
CleanerItems *trace_items;
QMap<QString, QVariant> argsMap;
SessionDispatcher *sessionproxy;
// SessionDispatcher *sessionproxy;
Toolkits *toolKits;
};

View File

@ -23,6 +23,7 @@
KylinTitleBar::KylinTitleBar(QWidget *parent) :
QWidget(parent)
, left_btn_pressed(false)
{
this->setWindowFlags(Qt::FramelessWindowHint);
this->setFixedHeight(32);

View File

@ -62,6 +62,11 @@ NormalWidget::~NormalWidget() {
}
}
void NormalWidget::resetData()
{
cardcount = 0;
}
void NormalWidget::calculate_data()
{
this->scrollArea->setGeometry(-1, -1, this->width() + 2, this->height() + 2);

View File

@ -35,6 +35,7 @@ public:
void calculate_data();
void add_card(QWidget *card);
QWidget *cardPanel;
void resetData();
private:
int cardcount;

View File

@ -19,6 +19,47 @@
#include "settingaction.h"
namespace {
//const QMap<SettingModuleID::SettingModuleID, QString> titleMap()
//{
// QMap<SettingAction::SettingModuleID, QString> m;
// m.insert(SettingAction::ThemePage, "a");
// m.insert(SettingAction::IconPage, "b");
// m.insert(SettingAction::MousePage, "c");
// m.insert(SettingAction::SoundPage, "d");
// return m;
//}
//int filterTitleAccordModuleName(SettingAction::SettingModuleID id)
//{
// return titleMap().value(id);
//}
const QMap<QString, QString> titleMap()
{
QMap<QString, QString> tMap;
tMap.insert("ThemePage", QObject::tr("Choose the theme what you want"));
tMap.insert("IconPage", QObject::tr("Set the desktop icon theme and the visibility of desktop icons"));
tMap.insert("MousePage", QObject::tr("Replace the theme and size of the mouse pointer, and theme change need to restart system"));
tMap.insert("SoundPage", QObject::tr("Set the sound theme you want"));
tMap.insert("PanelPage", QObject::tr("Setting the panel mode of auto hide and icon size"));
tMap.insert("MenuPage", QObject::tr("Manage display of the start menu"));
tMap.insert("WindowPage", QObject::tr("Window Manager settings"));
tMap.insert("FontPage", QObject::tr("According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings"));
tMap.insert("TouchPadPage", QObject::tr("Setting the relevant properties of your touchpad,make the operation more convenient"));
tMap.insert("EnergyPage", QObject::tr("Save energy to let the computer longer standby time"));
tMap.insert("FMPage", QObject::tr("Manage the file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked"));
return tMap;
}
QString filterTitleAccordModuleName(QString moduleName)
{
return titleMap().value(moduleName);
}
}
SettingAction::SettingAction(QString cur_desktop, QWidget *parent)
: QWidget(parent), desktop(cur_desktop)
{
@ -26,6 +67,8 @@ SettingAction::SettingAction(QString cur_desktop, QWidget *parent)
this->setAutoFillBackground(true);
this->setObjectName("transparentWidget");
m_moduleName = "";
back_btn = new QPushButton();
back_btn->setCursor(Qt::PointingHandCursor);
back_btn->setFixedSize(91,39);
@ -34,6 +77,7 @@ SettingAction::SettingAction(QString cur_desktop, QWidget *parent)
back_btn->setIcon(pixmap);
back_btn->setIconSize(pixmap.size());
back_btn->setObjectName("backgroundButton");
back_btn->setText(tr("Back"));
connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget()));
img_label = new QLabel();
title_label = new QLabel();
@ -73,7 +117,7 @@ SettingAction::SettingAction(QString cur_desktop, QWidget *parent)
layout2->addWidget(back_btn);
layout2->addStretch();
layout2->setMargin(0);
layout2->setContentsMargins(0, 0, 0, 0);
layout2->setContentsMargins(0, 20, 0, 0);
QHBoxLayout *main_layout = new QHBoxLayout();
// main_layout->addWidget(img_label, 0, Qt::AlignVCenter);
@ -105,9 +149,28 @@ SettingAction::~SettingAction()
}
}
QString SettingAction::getModuleName() /*const*/
{
return this->m_moduleName;
}
//void SettingAction::setModuleName(const QString &name)
void SettingAction::setModuleName(QString name)
{
this->m_moduleName = name;
const QString title = filterTitleAccordModuleName(name);
if (title.isEmpty() || title.isNull()) {
title_label->setText(tr("There may be a mistake."));
}
else {
title_label->setText(title);
}
}
void SettingAction::setLanguage(int index)
{
back_btn->setText(tr("Back"));
/*back_btn->setText(tr("Back"));
switch (index) {
case 1:
title_label->setText(tr("Choose the theme what you want"));
@ -171,5 +234,5 @@ void SettingAction::setLanguage(int index)
break;
default:
break;
}
}*/
}

View File

@ -34,11 +34,34 @@ class SettingAction : public QWidget
{
Q_OBJECT
public:
/*enum SettingModuleID{
ThemePage = 0,
IconPage,
MousePage,
SoundPage,
PanelPage,
MenuPage,
WindowPage,
FontPage,
TouchPadPage,
EnergyPage,
FMPage
};*/
explicit SettingAction(QString cur_dekstop = "", QWidget *parent = 0);
~SettingAction();
// void setParentWindow(MainWindow* window) { p_mainwindow = window;}
void setLanguage(int index);
// QString getModuleName() const;
// void setModuleName(const QString &name);
QString getModuleName();
void setModuleName(QString name);
// SettingModuleID getModuleNameID() const;
// void setModuleNameID(const SettingModuleID &id);
signals:
void showSettingMainWidget();
@ -49,6 +72,8 @@ private:
// QLabel *description_label;
// MainWindow *p_mainwindow;
QString desktop;
QString m_moduleName;
// SettingModuleID m_id;
};
#endif // SETTINGACTION_H

View File

@ -36,13 +36,32 @@ ThreadPool *ThreadPool::Instance()
return &threadPool;
}
QThread *ThreadPool::createNewThread()
QThread *ThreadPool::newThread()
{
QThread *thread = new QThread;
// qDebug() << "add <<<<<<<" << thread;
thread_pool.push_back(thread);
return thread;
}
void ThreadPool::moveToNewThread(QObject *obj)
{
QThread *work = newThread();
obj->moveToThread(work);
work->start();
}
//QThread *ThreadPool::createNewThread()
//{
// QThread *thread = new QThread;
// thread_pool.push_back(thread);
// return thread;
//}
void ThreadPool::exitAllThreads()
{
foreach (QThread *thread, thread_pool) {

View File

@ -29,7 +29,10 @@ public:
~ThreadPool();
static ThreadPool *Instance();
QThread *createNewThread();
// QThread *createNewThread();
QThread *newThread();
void moveToNewThread(QObject *obj);
void exitAllThreads();
private:

View File

@ -29,6 +29,9 @@ SessionDispatcher::SessionDispatcher(QObject *parent)
QDBusConnection::sessionBus());
// QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QVariantMap)), this, SLOT(handlerAutoManageData(QVariantMap)));
QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QStringList)), this, SLOT(handlerAutoManageData(QStringList)));
QObject::connect(sessioniface, SIGNAL(autostartmanage_status_signal(QString)), this, SLOT(handlerAutoManageStatus(QString)));
QObject::connect(sessioniface, SIGNAL(autostartmanage_error_signal(QString)), this, SLOT(handlerAutoManageError(QString)));
@ -496,11 +499,13 @@ bool SessionDispatcher::get_show_devices_qt() {
bool SessionDispatcher::set_launcher_autohide_qt(bool flag) {
QDBusReply<bool> reply = sessioniface->call("set_launcher_autohide", flag);
return reply.value();
// return true;
}
bool SessionDispatcher::get_launcher_autohide_qt() {
QDBusReply<bool> reply = sessioniface->call("get_launcher_autohide");
return reply.value();
// return true;
}
bool SessionDispatcher::set_launcher_icon_size_qt(int num) {
@ -511,15 +516,18 @@ bool SessionDispatcher::set_launcher_icon_size_qt(int num) {
int SessionDispatcher::get_launcher_icon_size_qt() {
QDBusReply<int> reply = sessioniface->call("get_launcher_icon_size");
return reply.value();
// return 32;
}
bool SessionDispatcher::set_launcher_have_showdesktopicon_qt(bool flag) {
QDBusReply<bool> reply = sessioniface->call("set_launcher_have_showdesktopicon", flag);
return reply.value();
// return true;
}
bool SessionDispatcher::get_launcher_have_showdesktopicon_qt() {
QDBusReply<bool> reply = sessioniface->call("get_launcher_have_showdesktopicon");
return reply.value();
// return true;
}
//-----------------------------------------------mate----------------------------------------------
@ -551,6 +559,7 @@ int SessionDispatcher::get_mate_panel_icon_size_qt(QString positon)
double SessionDispatcher::get_launcher_transparency_qt() {
QDBusReply<double> reply = sessioniface->call("get_launcher_transparency");
return reply.value();
// return 0.0;
}
bool SessionDispatcher::set_launcher_transparency_qt(double opacity) {
@ -562,14 +571,17 @@ bool SessionDispatcher::set_launcher_transparency_qt(double opacity) {
QStringList SessionDispatcher::get_all_launcher_icon_colourings_qt() {
QDBusReply<QStringList> reply = sessioniface->call("get_all_launcher_icon_colourings");
return reply.value();
// return QStringList();
}
int SessionDispatcher::get_launcher_icon_colouring_qt() {
QDBusReply<int> reply = sessioniface->call("get_launcher_icon_colouring");
return reply.value();
// return 0;
}
bool SessionDispatcher::set_launcher_icon_colouring_qt(int colouring) {
qDebug() << "WWWWWWWWWWWWWWW set_launcher_icon_colouring_qt colouring===="<<colouring;
QDBusReply<bool> reply = sessioniface->call("set_launcher_icon_colouring", colouring);
return reply.value();
}
@ -1266,7 +1278,6 @@ void SessionDispatcher::set_current_lid_battery_qt(QString value)
sessioniface->call("set_current_lid_battery", value);
}
QString SessionDispatcher::get_current_lid_ac_qt()
{
QDBusReply<QString> reply = sessioniface->call("get_current_lid_ac");
@ -1278,7 +1289,6 @@ void SessionDispatcher::set_current_lid_ac_qt(QString value)
sessioniface->call("set_current_lid_ac", value);
}
QString SessionDispatcher::get_current_sleep_timeout_display_battery_qt()
{
QDBusReply<int> reply = sessioniface->call("get_current_sleep_timeout_display_battery");
@ -1301,7 +1311,6 @@ void SessionDispatcher::set_current_sleep_timeout_display_ac_qt(int value)
sessioniface->call("set_current_sleep_timeout_display_ac", value);
}
QString SessionDispatcher::get_current_sleep_timeout_battery_qt()
{
QDBusReply<int> reply = sessioniface->call("get_current_sleep_timeout_battery");
@ -1328,12 +1337,14 @@ QString SessionDispatcher::get_current_launcher_position_qt()
{
QDBusReply<QString> reply = sessioniface->call("get_current_launcher_position");
return reply.value();
// return QString();
}
QStringList SessionDispatcher::get_all_launcher_position_qt()
{
QDBusReply<QStringList> reply = sessioniface->call("get_all_launcher_position");
return reply.value();
// return QStringList();
}
bool SessionDispatcher::set_launcher_position_qt(QString position)
@ -1356,6 +1367,7 @@ void SessionDispatcher::handler_notify_boolean(QString key, bool value)
void SessionDispatcher::handler_notify_int(QString key, int value)
{
qDebug() << "SessionDispatcher::handler_notify_int===============";
emit int_value_notify(key, value);
}

View File

@ -29,6 +29,8 @@ SystemDispatcher::SystemDispatcher(QObject *parent)
//kobe
clean_thread = new KThread(this);
this->initData();
}
SystemDispatcher::~SystemDispatcher() {
@ -77,7 +79,10 @@ void SystemDispatcher::initData()
QObject::connect(systemiface,SIGNAL(youker_apt_signal(QString, QStringList)),this,SIGNAL(get_apt_signal(QString, QStringList)));
// QObject::connect(systemiface,SIGNAL(youker_fetch_signal(QString, QStringList)),this,SLOT(handlerFetchSignal(QString, QStringList)));
// QObject::connect(systemiface,SIGNAL(youker_apt_signal(QString, QStringList)),this,SLOT(handlerAptSignal(QString, QStringList)));
emit this->dbusInitFinished();
// emit this->dbusInitFinished();
}
//void SystemDispatcher::handlerFetchSignal(QString msg_type, QStringList msg)

View File

@ -100,7 +100,7 @@ signals:
void get_fetch_signal(QString msg_type, QStringList msg);
void get_apt_signal(QString msg_type, QStringList msg);
void dbusInitFinished();
// void dbusInitFinished();
public slots:
void handler_interrupt_clean(bool status);

5
debian/changelog vendored
View File

@ -5,5 +5,10 @@ kylin-assistant (1.0.0-0ubuntu1) bionic; urgency=low
* Add qtsingleapplication.
* Let the child window display normal.
* Add PingBack.
* Rewrite systeminfo frame.
* Rewrite setting frame.
* Separate data and graphics.
* Add Cpu.
* Add Network.
-- lixiang <lixiang@kylinos.cn> Thu, 21 Dec 2017 14:52:56 +0800

2
debian/rules vendored
View File

@ -15,7 +15,7 @@ override_dh_auto_configure:
kylin-assistant.pro
%:
dh $@ --with python2 --fail-missing --parallel
dh $@ --with python3 --fail-missing --parallel
override_dh_install:
./autogen.sh

View File

@ -1,191 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "audiowidget.h"
#include "computerpage.h"
AudioWidget::AudioWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403/* - 10*/);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403/* - 10*/);
dataOK = false;
}
AudioWidget::~AudioWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void AudioWidget::clear_page_list()
{
for(int i=0; i<page_list.count(); i++)
{
ComputerPage *page = page_list.at(i);
delete page;
page = NULL;
}
page_list.clear();
if (scroll_widget)
scroll_widget->resetWidget();
}
bool AudioWidget::getStatus()
{
return this->dataOK;
}
bool AudioWidget::displaySwitch()
{
audio_info_map.clear();
audio_info_map = systemproxy->get_audiocard_info_qt();
if (audio_info_map.empty() || audio_info_map.count() <= 0)
{
return false;
}
else
{
return true;
}
}
void AudioWidget::initData()
{
this->clear_page_list();
// audio_info_map.clear();
audio_info_map = systemproxy->get_audiocard_info_qt();//?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用
QMap<QString, QVariant>::iterator iter = audio_info_map.find("MulNum");
qDebug() << iter.value().toInt();
int mulNum = 0;
if (iter == audio_info_map.end())
{
mulNum = 0;
}
else
{
mulNum = iter.value().toInt();
}
if(mulNum == 0)
{
}
else
{
if(mulNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Audio Info"));
page_list.append(page);
audio_info_map.remove("MulNum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = audio_info_map.begin(); it != audio_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, audio_info_map.value("MulVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else if(mulNum > 1)
{
for(int i=0;i<mulNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Audio Info %1").arg(i+1));
page_list.append(page);
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = audio_info_map.begin();
QMap<QString, QVariant>::iterator itend = audio_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "MulNum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("MulVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
}
/*QMap<QString, QVariant>::iterator iter = audio_info_map.find("MulNum");
int mulNum = 0;
if (iter == audio_info_map.end())
{
mulNum = 0;
}
else{
mulNum = iter.value().toInt();
}
if(audio_info_map.count() == 1 && audio_info_map.contains("kylinkobe"))
{
}
else {
if(mulNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Audio Info"));
audio_info_map.remove("MulNum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = audio_info_map.begin(); it != audio_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, audio_info_map.value("MulVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
else if(mulNum > 1)
{
for(int i=0;i<mulNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Audio Info %1").arg(i+1));
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = audio_info_map.begin();
QMap<QString, QVariant>::iterator itend = audio_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "MulNum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("MulVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
}
}*/
// dataOK = true;
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUDIOWIDGET_H
#define AUDIOWIDGET_H
#include <QWidget>
#include <QMap>
#include <QVariant>
#include "../component/scrollwidget.h"
class SystemDispatcher;
class AudioWidget : public QWidget
{
Q_OBJECT
public:
explicit AudioWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~AudioWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
QMap<QString, QVariant> audio_info_map;
QMap<QString, QVariant> tmp_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
QList<ComputerPage *> page_list;
};
#endif // AUDIOWIDGET_H

View File

@ -1,136 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "batterywidget.h"
BatteryWidget::BatteryWidget(QWidget *parent, SessionDispatcher *proxy) :
QWidget(parent),
sessionproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
page = NULL;
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
BatteryWidget::~BatteryWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void BatteryWidget::clear_page_list()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget)
scroll_widget->resetWidget();
}
bool BatteryWidget::getStatus()
{
return this->dataOK;
}
void BatteryWidget::initData()
{
this->clear_page_list();
QMap<QString, QVariant> tmpMap = sessionproxy->read_battery_info_qt();
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
page = NULL;
}
else {
QMap<QString,QVariant>::iterator it; //遍历map
QStringList powerlist;
powerlist << "POWER_SUPPLY_NAME" << "POWER_SUPPLY_MANUFACTURER" << "POWER_SUPPLY_MODEL_NAME" << "POWER_SUPPLY_TECHNOLOGY" << "POWER_SUPPLY_VOLTAGE_NOW" << "POWER_SUPPLY_ENERGY_FULL_DESIGN" << "POWER_SUPPLY_ENERGY_FULL" << "POWER_SUPPLY_ENERGY_NOW" << "POWER_SUPPLY_SERIAL_NUMBER";
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
QList<QString>::Iterator itstart = powerlist.begin(), itend = powerlist.end();
for(;itstart !=itend;itstart++)
{
if(*itstart == it.key())
{
if (it.key() == "POWER_SUPPLY_SERIAL_NUMBER")
{
if (it.value().toString().replace(" " ,"").length() > 0)
battery_info_map.insert(it.key(), it.value());
}
else {
if (it.value().toString().length() > 0)
battery_info_map.insert(it.key(), it.value());
}
break;
}
}
}
if(battery_info_map.isEmpty() || battery_info_map.count() <= 0) {
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Battery Info"));
page->setMap(battery_info_map, battery_info_map.value("POWER_SUPPLY_MANUFACTURER").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
/*QMap<QString,QVariant>::iterator it; //遍历map
QStringList powerlist;
powerlist << "POWER_SUPPLY_NAME" << "POWER_SUPPLY_MANUFACTURER" << "POWER_SUPPLY_MODEL_NAME" << "POWER_SUPPLY_TECHNOLOGY" << "POWER_SUPPLY_VOLTAGE_NOW" << "POWER_SUPPLY_ENERGY_FULL_DESIGN" << "POWER_SUPPLY_ENERGY_FULL" << "POWER_SUPPLY_ENERGY_NOW" << "POWER_SUPPLY_SERIAL_NUMBER";
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
QList<QString>::Iterator itstart = powerlist.begin(), itend = powerlist.end();
for(;itstart !=itend;itstart++)
{
if(*itstart == it.key())
{
if (it.key() == "POWER_SUPPLY_SERIAL_NUMBER")
{
if (it.value().toString().replace(" " ,"").length() > 0)
battery_info_map.insert(it.key(), it.value());
}
else {
if (it.value().toString().length() > 0)
battery_info_map.insert(it.key(), it.value());
}
break;
}
}
// if(it.key() != "POWER_SUPPLY_CAPACITY" && it.key() != "POWER_SUPPLY_CYCLE_COUNT" && it.key() != "POWER_SUPPLY_POWER_NOW" && it.key() != "POWER_SUPPLY_PRESENT" && it.key() != "POWER_SUPPLY_STATUS" && it.key() != "POWER_SUPPLY_VOLTAGE_MIN_DESIGN" )
// {
// if (it.value().toString().length() > 0)
// battery_info_map.insert(it.key(), it.value());
// }
}
if(battery_info_map.count() == 1 && battery_info_map.contains("kylinkobe")) {
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Battery Info"));
page->setMap(battery_info_map, battery_info_map.value("POWER_SUPPLY_MANUFACTURER").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}*/
// dataOK = true;
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BATTERYWIDGET_H
#define BATTERYWIDGET_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
class QVariant;
class SessionDispatcher;
class BatteryWidget : public QWidget
{
Q_OBJECT
public:
explicit BatteryWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0);
~BatteryWidget();
void initData();
bool getStatus();
void clear_page_list();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
ComputerPage *page;
QMap<QString, QVariant> battery_info_map;
SessionDispatcher *sessionproxy;
bool dataOK;
};
#endif // BATTERYWIDGET_H

View File

@ -1,119 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "boardwidget.h"
BoardWidget::BoardWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
page = NULL;
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
BoardWidget::~BoardWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void BoardWidget::clear_page_list()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget)
scroll_widget->resetWidget();
}
bool BoardWidget::displaySwitch()
{
QMap<QString, QVariant> tmpMap = systemproxy->get_board_info_qt();
// if (tmpMap.isEmpty() || tmpMap.count() <= 0)
// {
// return false;
// }
// else
// {
// QMap<QString,QVariant>::iterator it;
// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it )
// {
// if (it.value().toString().length() > 0)
// {
// board_info_map.insert(it.key(), it.value());
// }
// }
// return true;
// }
QMap<QString,QVariant>::iterator it;
bool sflag = false;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it )
{
if (it.value().toString().length() > 0)
{
board_info_map.insert(it.key(), it.value());
sflag = true;
}
}
if (sflag)
return true;
else
return false;
}
bool BoardWidget::getStatus()
{
return this->dataOK;
}
void BoardWidget::initData()
{
this->clear_page_list();
page = new ComputerPage(scroll_widget->zone, tr("Board Info"));
page->setMap(board_info_map, board_info_map.value("BoaVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
/*QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
board_info_map.insert(it.key(), it.value());
}
}
if(board_info_map.count() == 1 && board_info_map.contains("kylinkobe"))
{
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Board Info"));
page->setMap(board_info_map, board_info_map.value("BoaVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}*/
// dataOK = true;
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BOARDWIDGET_H
#define BOARDWIDGET_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
class QVariant;
class SystemDispatcher;
class BoardWidget : public QWidget
{
Q_OBJECT
public:
explicit BoardWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~BoardWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
ComputerPage *page;
QMap<QString, QVariant> board_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
};
#endif // BOARDWIDGET_H

View File

@ -1,161 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cdrowwidget.h"
#include "computerpage.h"
CDRowWidget::CDRowWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
CDRowWidget::~CDRowWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void CDRowWidget::clear_page_list()
{
for(int i=0; i<page_list.count(); i++)
{
ComputerPage *page = page_list.at(i);
delete page;
page = NULL;
}
page_list.clear();
if (scroll_widget)
scroll_widget->resetWidget();
}
bool CDRowWidget::getStatus()
{
return this->dataOK;
}
void CDRowWidget::initData()
{
this->clear_page_list();
cdrom_info_map.clear();
cdrom_info_map = systemproxy->get_cdrom_info_qt();
int cdNum = 0;
if (cdrom_info_map.isEmpty() || cdrom_info_map.count() <= 0) {
cdNum = 0;
}
else {
QMap<QString, QVariant>::iterator iter = cdrom_info_map.find("Dvdnum");
if (iter == cdrom_info_map.end()) {
cdNum = 0;
}
else {
cdNum = iter.value().toInt();
if(cdNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("CDROM Info"));
page_list.append(page);
cdrom_info_map.remove("Dvdnum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = cdrom_info_map.begin(); it != cdrom_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, cdrom_info_map.value("DvdVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else if(cdNum > 1)
{
for(int i=0;i<cdNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("CDROM Info %1").arg(i+1));
page_list.append(page);
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = cdrom_info_map.begin();
QMap<QString, QVariant>::iterator itend = cdrom_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "Dvdnum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("DvdVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
}
}
/*if(cdrom_info_map.count() == 1 && cdrom_info_map.contains("kylinkobe"))
{
}
else {
if(cdNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("CDROM Info"));
cdrom_info_map.remove("Dvdnum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = cdrom_info_map.begin(); it != cdrom_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, cdrom_info_map.value("DvdVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
else if(cdNum > 1)
{
for(int i=0;i<cdNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("CDROM Info %1").arg(i+1));
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = cdrom_info_map.begin();
QMap<QString, QVariant>::iterator itend = cdrom_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "Dvdnum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("DvdVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
}
}*/
// dataOK = true;
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CDROWWIDGET_H
#define CDROWWIDGET_H
#include <QWidget>
#include "../component/scrollwidget.h"
#include <QMap>
#include <QVariant>
class SystemDispatcher;
class CDRowWidget : public QWidget
{
Q_OBJECT
public:
explicit CDRowWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~CDRowWidget();
void initData();
bool getStatus();
void clear_page_list();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
QMap<QString, QVariant> cdrom_info_map;
QMap<QString, QVariant> tmp_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
QList<ComputerPage *> page_list;
};
#endif // CDROWWIDGET_H

View File

@ -1,905 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "computerpage.h"
#include "../component/utils.h"
#include <QDebug>
#include <QLabel>
#include <QComboBox>
#include <QGroupBox>
#include <QFormLayout>
#include <QBitmap>
#include <QRadioButton>
ComputerPage::ComputerPage(QWidget *parent, QString title/*, QString manufacturer*/) :
QWidget(parent), title_context(title)/*, vendor(manufacturer)*/
{
// this->setWindowFlags(Qt::FramelessWindowHint);
sensor = false;
page_height = 0;
title_label = NULL;
time_label = NULL;
logo_label = NULL;
group_box = NULL;
form_layout = NULL;
ondemand_radio = NULL;
powersave_radio = NULL;
performance_radio = NULL;
layout = NULL;
in0_label = NULL;
in2_label = NULL;
in3_label = NULL;
in5_label = NULL;
in6_label = NULL;
tr1_label = NULL;
tr2_label = NULL;
tr3_label = NULL;
tr4_label = NULL;
tr5_label = NULL;
tr6_label = NULL;
fanin1_label = NULL;
}
ComputerPage::~ComputerPage()
{
for(int i=0; i<label_list.count(); i++)
{
QLabel *label = label_list.at(i);
delete label;
label = NULL;
}
label_list.clear();
page_height = 0;
if(title_label != NULL)
{
delete title_label;
title_label = NULL;
}
if(time_label != NULL)
{
delete time_label;
time_label = NULL;
}
if(logo_label != NULL)
{
delete logo_label;
logo_label = NULL;
}
if(ondemand_radio != NULL)
{
delete ondemand_radio;
ondemand_radio = NULL;
}
if(powersave_radio != NULL)
{
delete powersave_radio;
powersave_radio = NULL;
}
if(performance_radio != NULL)
{
delete performance_radio;
performance_radio = NULL;
}
if(layout != NULL)
{
delete layout;
layout = NULL;
}
if(in0_label != NULL)
{
delete in0_label;
in0_label = NULL;
}
if(in2_label != NULL)
{
delete in2_label;
in2_label = NULL;
}
if(in3_label != NULL)
{
delete in3_label;
in3_label = NULL;
}
if(in5_label != NULL)
{
delete in5_label;
in5_label = NULL;
}
if(in6_label != NULL)
{
delete in6_label;
in6_label = NULL;
}
if(tr1_label != NULL)
{
delete tr1_label;
tr1_label = NULL;
}
if(tr2_label != NULL)
{
delete tr2_label;
tr2_label = NULL;
}
if(tr3_label != NULL)
{
delete tr3_label;
tr3_label = NULL;
}
if(tr4_label != NULL)
{
delete tr4_label;
tr4_label = NULL;
}
if(tr5_label != NULL)
{
delete tr5_label;
tr5_label = NULL;
}
if(tr6_label != NULL)
{
delete tr6_label;
tr6_label = NULL;
}
if(fanin1_label != NULL)
{
delete fanin1_label;
fanin1_label = NULL;
}
if(form_layout != NULL)
{
delete form_layout;
form_layout = NULL;
}
if(group_box != NULL)
{
delete group_box;
group_box = NULL;
}
}
void ComputerPage::setLanguage() {
group_box->setTitle(tr("%1").arg(title_context));
}
void ComputerPage::initUI(bool cpu)
{
group_box = new QGroupBox();
group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}");
QFont group_box_font = group_box->font();
group_box_font.setBold(true);
group_box->setFont(group_box_font);
group_box->setFixedWidth(720);
form_layout = new QFormLayout();
// form_layout->setSizeConstraint(QLayout::SetFixedSize);//frame will fixed with content's width
form_layout->setSpacing(ITEMVSPACE);
form_layout->setHorizontalSpacing(ITEMHSPACE);
form_layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
form_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
QMap<QString,QVariant>::iterator it; //遍历map
if (sensor) {
in0_label = new QLabel();
in2_label = new QLabel();
in3_label = new QLabel();
in5_label = new QLabel();
in6_label = new QLabel();
tr1_label = new QLabel();
tr2_label = new QLabel();
tr3_label = new QLabel();
tr4_label = new QLabel();
tr5_label = new QLabel();
tr6_label = new QLabel();
fanin1_label = new QLabel();
in0_label->setFixedHeight(ITEMHEIGHT);
in2_label->setFixedHeight(ITEMHEIGHT);
in3_label->setFixedHeight(ITEMHEIGHT);
in5_label->setFixedHeight(ITEMHEIGHT);
in6_label->setFixedHeight(ITEMHEIGHT);
tr1_label->setFixedHeight(ITEMHEIGHT);
tr2_label->setFixedHeight(ITEMHEIGHT);
tr3_label->setFixedHeight(ITEMHEIGHT);
tr4_label->setFixedHeight(ITEMHEIGHT);
tr5_label->setFixedHeight(ITEMHEIGHT);
tr6_label->setFixedHeight(ITEMHEIGHT);
fanin1_label->setFixedHeight(ITEMHEIGHT);
for (it = info_map.begin(); it != info_map.end(); ++it ) {
if(it.key() == "IN0") {
in0_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in0_label);
page_height += in0_label->height();
}
else if(it.key() == "IN2") {
in2_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in2_label);
page_height += in2_label->height();
}
else if(it.key() == "IN3") {
in3_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in3_label);
page_height += in3_label->height();
}
else if(it.key() == "IN5") {
in5_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in5_label);
page_height += in5_label->height();
}
else if(it.key() == "IN6") {
in6_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in6_label);
page_height += in6_label->height();
}
else if(it.key() == "TR1") {
tr1_label->setText(it.value().toString());
form_layout->addRow("ATX_3V3", tr1_label);
page_height += tr1_label->height();
}
else if(it.key() == "TR2") {
tr2_label->setText(it.value().toString());
form_layout->addRow("ATX_5V", tr2_label);
page_height += tr2_label->height();
}
else if(it.key() == "TR3") {
tr3_label->setText(it.value().toString());
form_layout->addRow("ATX_12V", tr3_label);
page_height += tr3_label->height();
}
else if(it.key() == "TR4") {
tr4_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), tr4_label);
page_height += tr4_label->height();
}
else if(it.key() == "TR5") {
tr5_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), tr5_label);
page_height += tr5_label->height();
}
else if(it.key() == "TR6") {
tr6_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), tr6_label);
page_height += tr6_label->height();
}
else if(it.key() == "FANIN1") {
fanin1_label->setText(it.value().toString());
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), fanin1_label);
page_height += fanin1_label->height();
}
page_height += ITEMVSPACE;
}
}
else {
for (it = info_map.begin(); it != info_map.end(); ++it ) {
if(it.key() == "uptime")
{
time_label = new QLabel();
int time_value = it.value().toInt();
int hour_value = time_value/60;
int minutes_value =time_value%60;
if(hour_value < 1)
{
time_label->setText(QString::number(minutes_value) + tr(" Minutes"));//分钟
}
else
{
time_label->setText(QString::number(hour_value) + tr(" Hours ") + QString::number(minutes_value) + tr(" Minutes"));//小时 分钟
}
time_label->setFixedHeight(ITEMHEIGHT);
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), time_label);
page_height += time_label->height();
}
else {
QString valueStr = it.value().toString().trimmed();
if (QString::compare(valueStr, "UNKOWN", Qt::CaseInsensitive) == 0 || QString::compare(valueStr, "UNKNOWN", Qt::CaseInsensitive) == 0) {//for arm memory
//do nothing
}
else if (it.key().length() > 0 && valueStr.length() > 0) {//20161228
QLabel *label = new QLabel();
label_list.append(label);
if (it.key() == "cpu_cores") {
label->setText(tr("%1 ").arg(valueStr));
}
else if (it.key() == "CpuVersion" && valueStr.contains("v1.0")) {
label->setText(tr("%1 64bit").arg(valueStr));
}
else {
if (QString::compare(valueStr, "1500a v1.0 64 bits", Qt::CaseInsensitive) == 0)//2017
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
else if (QString::compare(valueStr, "phytium", Qt::CaseInsensitive) == 0)//2017
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
else if (QString::compare(valueStr, "4 cores", Qt::CaseInsensitive) == 0)//2017
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
else if (QString::compare(valueStr, "4 thread/core", Qt::CaseInsensitive) == 0)//2017
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
else if (QString::compare(valueStr, "32bit", Qt::CaseInsensitive) == 0)//2017
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
else if (QString::compare(valueStr, "64bit", Qt::CaseInsensitive) == 0)//2017
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
else if (QString::compare(valueStr, "Ethernet interface", Qt::CaseInsensitive) == 0) {
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
}
else if (QString::compare(valueStr, "Wireless interface", Qt::CaseInsensitive) == 0) {
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
}
else if (QString::compare(valueStr, "YHKylin community", Qt::CaseInsensitive) == 0) {
label->setText(tr("%1").arg(this->translatorSwitch(valueStr)));
}
else
{
QFont ft;
QFontMetrics fm(ft);
QString elided_text = fm.elidedText(tr("%1").arg(valueStr), Qt::ElideRight, 400);
label->setText(elided_text);
if(elided_text.endsWith(""))
label->setToolTip(tr("%1").arg(valueStr));
// label->setText(tr("%1").arg(valueStr));
}
}
label->setFixedHeight(ITEMHEIGHT);
form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), label);
page_height += label->height();
}
}
page_height += ITEMVSPACE;
}
}
if (cpu) {
if (systemProxy) {
QStringList cpulist = systemProxy->get_cpufreq_scaling_governer_list_qt();
if (cpulist.length() > 0) {
ondemand_radio = new QRadioButton();
ondemand_radio->setFocusPolicy(Qt::NoFocus);
ondemand_radio->setFixedHeight(ITEMHEIGHT);
ondemand_radio->setText(tr("Ondemand"));
ondemand_radio->setObjectName("ondemandradio");
ondemand_radio->setChecked(false);
ondemand_radio->hide();
powersave_radio = new QRadioButton();
powersave_radio->setFixedHeight(ITEMHEIGHT);
powersave_radio->setFocusPolicy(Qt::NoFocus);
powersave_radio->setText(tr("Powersave"));
powersave_radio->setObjectName("powersaveradio");
powersave_radio->setChecked(false);
powersave_radio->hide();
performance_radio = new QRadioButton();
performance_radio->setFixedHeight(ITEMHEIGHT);
performance_radio->setFocusPolicy(Qt::NoFocus);
performance_radio->setText(tr("Performance"));
performance_radio->setObjectName("performanceradio");
performance_radio->setChecked(false);
performance_radio->hide();
connect(ondemand_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
connect(powersave_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
connect(performance_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
layout = new QHBoxLayout();
layout->setSpacing(10);
layout->addWidget(ondemand_radio);
layout->addWidget(powersave_radio);
layout->addWidget(performance_radio);
layout->addStretch();
QString cur_cpu = systemProxy->get_current_cpufreq_scaling_governer_qt();
QList<QString>::Iterator it = cpulist.begin(), itend = cpulist.end();
bool showed = false;
for(;it != itend; it++)
{
if(*it == "ondemand") {
if (cur_cpu == *it) {
ondemand_radio->setChecked(true);
powersave_radio->setChecked(false);
performance_radio->setChecked(false);
}
ondemand_radio->show();
showed = true;
}
else if(*it == "powersave") {
if (cur_cpu == *it) {
powersave_radio->setChecked(true);
ondemand_radio->setChecked(false);
performance_radio->setChecked(false);
}
powersave_radio->show();
showed = true;
}
else if(*it == "performance") {
if (cur_cpu == *it) {
performance_radio->setChecked(true);
ondemand_radio->setChecked(false);
powersave_radio->setChecked(false);
}
performance_radio->show();
showed = true;
}
}
if (showed) {
form_layout->addRow(tr("CPU FM mode"), layout);
page_height += ITEMHEIGHT;
}
}
}
}
page_height += ITEMVSPACE*2;//every groupbox has tow separate line
page_height += 30;
page_height += ITEMHSPACE;//ContentsMargin's height
info_map.clear(); //清空map
group_box->setLayout(form_layout);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(group_box);
layout->setMargin(0);
layout->setContentsMargins(ITEMHSPACE, ITEMHSPACE, 0, 0);
setLayout(layout);
if(!vendor.isEmpty())
{
logo_label = new QLabel(this);
logo_label->setAutoFillBackground(true);
logo_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小
QPixmap label_pixmap(":/vendor/res/manufacturer/" + vendor + ".jpg");
if (label_pixmap.isNull())
{
// label_pixmap = QPixmap(":/vendor/res/manufacturer/UBUNTUKYLIN.jpg");
label_pixmap = QPixmap("");
}
logo_label->setPixmap(label_pixmap);
logo_label->setFixedSize(label_pixmap.size());
logo_label->setGeometry(QRect(720 - logo_label->width(), 40, logo_label->width(), logo_label->height()));
logo_label->setMask(label_pixmap.mask());
// QImage image(":/vendor/res/manufacturer/UBUNTUKYLIN.jpg");
// if (!image.isNull()) {
// image = image.scaled(logo_label->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
// logo_label->setPixmap(QPixmap::fromImage(image));
// }
// logo_label->setGeometry(QRect(720 - logo_label->width(), 40, logo_label->width(), logo_label->height()));
}
this->setLanguage();
}
void ComputerPage::setRadioButtonRowStatus()
{
QObject *obj = sender(); //返回发出信号的对象用QObject类型接收
QRadioButton* pbtn = qobject_cast<QRadioButton*>(obj);
QString obj_name = pbtn->objectName();
if(obj_name == "ondemandradio") {
systemProxy->adjust_cpufreq_scaling_governer_qt("ondemand");
}
else if(obj_name == "powersaveradio") {
systemProxy->adjust_cpufreq_scaling_governer_qt("powersave");
}
else if(obj_name == "performanceradio") {
systemProxy->adjust_cpufreq_scaling_governer_qt("performance");
}
}
void ComputerPage::resetTimeValue(QString value)
{
time_label->setText(value);
}
void ComputerPage::resetSensor(QMap<QString, QVariant> sensormap)
{
if (sensor) {
QMap<QString,QVariant>::iterator it; //遍历map
for (it = sensormap.begin(); it != sensormap.end(); ++it ) {
if(it.key() == "IN0") {
if (in0_label)
in0_label->setText(it.value().toString());
}
else if(it.key() == "IN2") {
if (in2_label)
in2_label->setText(it.value().toString());
}
else if(it.key() == "IN3") {
if (in3_label)
in3_label->setText(it.value().toString());
}
else if(it.key() == "IN5") {
if (in5_label)
in5_label->setText(it.value().toString());
}
else if(it.key() == "IN6") {
if (in6_label)
in6_label->setText(it.value().toString());
}
else if(it.key() == "TR1") {
if (tr1_label)
tr1_label->setText(it.value().toString());
}
else if(it.key() == "TR2") {
if (tr2_label)
tr2_label->setText(it.value().toString());
}
else if(it.key() == "TR3") {
if (tr3_label)
tr3_label->setText(it.value().toString());
}
else if(it.key() == "TR4") {
if (tr4_label)
tr4_label->setText(it.value().toString());
}
else if(it.key() == "TR5") {
if (tr5_label)
tr5_label->setText(it.value().toString());
}
else if(it.key() == "TR6") {
if (tr6_label)
tr6_label->setText(it.value().toString());
}
else if(it.key() == "FANIN1") {
if (fanin1_label)
fanin1_label->setText(it.value().toString());
}
}
}
}
QString ComputerPage::translatorSwitch(QString orgStr)
{
if(orgStr == "MulProduct")//声卡型号
return tr("Audio Model");
else if(orgStr == "MulVendor")//制造商
return tr("Vendor");
else if(orgStr == "MulBusinfo")//总线地址
return tr("Bus Address");
else if(orgStr == "MulDrive")//声卡驱动
return tr("Audio Driver");
else if(orgStr == "POWER_SUPPLY_NAME")//设备名
return tr("Device Name");
else if(orgStr == "POWER_SUPPLY_MANUFACTURER")//发行商
return tr("Manufacturer");
// else if(orgStr == "POWER_SUPPLY_CAPACITY")//
// return tr("POWER_SUPPLY_CAPACITY");
// else if(orgStr == "POWER_SUPPLY_CYCLE_COUNT")//
// return tr("POWER_SUPPLY_CYCLE_COUNT");
// else if(orgStr == "POWER_SUPPLY_POWER_NOW")//
// return tr("POWER_SUPPLY_POWER_NOW");
// else if(orgStr == "POWER_SUPPLY_PRESENT")//
// return tr("POWER_SUPPLY_PRESENT");
// else if(orgStr == "POWER_SUPPLY_STATUS")//
// return tr("POWER_SUPPLY_STATUS");
// else if(orgStr == "POWER_SUPPLY_VOLTAGE_MIN_DESIGN")//
// return tr("POWER_SUPPLY_VOLTAGE_MIN_DESIGN");
// POWER_SUPPLY_CAPACITY_LEVEL
// POWER_SUPPLY_CHARGE_FULL
// POWER_SUPPLY_CHARGE_FULL_DESIGN
// POWER_SUPPLY_CHARGE_NOW
// POWER_SUPPLY_CURRENT_NOW
// POWER_SUPPLY_PROP_STATUS
// POWER_SUPPLY_PROP_CHARGE_TYPE
// POWER_SUPPLY_PROP_HEALTH
// POWER_SUPPLY_PROP_PRESENT,
// POWER_SUPPLY_PROP_TECHNOLOGY,
// POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
// POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
// POWER_SUPPLY_PROP_VOLTAGE_NOW,
// POWER_SUPPLY_PROP_CAPACITY,
// POWER_SUPPLY_PROP_CURRENT_NOW,
// POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
// POWER_SUPPLY_PROP_TEMP,
// POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL
// POWER_SUPPLY_ATTR
// POWER_SUPPLY_CURRENT_MAX
// SEQNUM
// POWER_SUPPLY_CHARGING_ENABLED
// POWER_SUPPLY_CHARGE_TYPE
// POWER_SUPPLY_HEALTH
// POWER_SUPPLY_VOLTAGE_MAX_DESIGN
// POWER_SUPPLY_TEMP
// POWER_SUPPLY_SYSTEM_TEMP_LEVEL
else if(orgStr == "POWER_SUPPLY_MODEL_NAME")//型号
return tr("Model");
else if(orgStr == "POWER_SUPPLY_TECHNOLOGY")//技术
return tr("Technology");
else if(orgStr == "POWER_SUPPLY_VOLTAGE_NOW")//电压
return tr("Voltage");
else if(orgStr == "POWER_SUPPLY_ENERGY_FULL_DESIGN")//能量(设计)
return tr("Energy Designed");
else if(orgStr == "POWER_SUPPLY_ENERGY_FULL")//满时能量
return tr("Energy Full");
else if(orgStr == "POWER_SUPPLY_ENERGY_NOW")//能量
return tr("Energy Now");
else if(orgStr == "POWER_SUPPLY_SERIAL_NUMBER")//序列号
return tr("Serial Number");
else if(orgStr == "BoaVendor")//主板型号
return tr("Motherboard Model");
else if(orgStr == "BoaProduct")//主板产商
return tr("Motherboard Vendor");
else if(orgStr == "BoaSerial")//序列号
return tr("Serial Number");
else if(orgStr == "BioVendor")//BIOS产商
return tr("BIOS Vendor");
else if(orgStr == "BioVersion")//BIOS版本
return tr("BIOS Version");
else if(orgStr == "BioRelease")//发布日期
return tr("Release Date");
else if(orgStr == "DvdProduct")//光驱型号
return tr("CD-ROM Model");
else if(orgStr == "DvdVendor")//制造商
return tr("Vendor");
else if(orgStr == "DvdName")//设备名称
return tr("Device Name");
else if(orgStr == "DvdFw")//固件版本
return tr("Firmware Version");
else if(orgStr == "DvdSerial")//序列号
return tr("Serial Number");
else if(orgStr == "CpuVersion")//处理器:
return tr("CPU");
else if(orgStr == "CpuVendor")//制造商:
return tr("Vendor");
else if(orgStr == "CpuSerial")//序列号:
return tr("Serial Number");
else if(orgStr == "CpuSlot")//插座/插槽:
return tr("Socket/Slot");
else if(orgStr == "CpuCapacity")//最大主频:
return tr("Maximum Frequency");
else if(orgStr == "CpuSize")//当前主频:
return tr("Current Frequency");
else if(orgStr == "CpuClock")//前端总线:
return tr("FSB");
else if(orgStr == "cpu_cores")//核心数目:
return tr("Core Number");
else if(orgStr == "cpu_siblings")//线程
return tr("Thread");
else if(orgStr == "clflush_size")//一级缓存:
return tr("L1 Cache");
else if(orgStr == "cache_size")//二级缓存:
return tr("L2 Cache");
// else if(orgStr == "1500a v1.0 64 bits")//1500a v1.0 64位
// return tr("1500a v1.0 64 bits");
else if(orgStr == "phytium")//飞腾
return tr("phytium");
else if(orgStr == "4 cores")//4核
return tr("4 cores");
else if(orgStr == "4 thread/core")//4线程/核
return tr("4 thread/core");
else if(orgStr == "desktopenvironment")//桌面环境
return tr("Desktop Environment");
else if(orgStr == "cpu")
return tr("CPU");
else if(orgStr == "hostname")
return tr("Host Name");
else if(orgStr == "ram")
return tr("Memery Capacity");
else if(orgStr == "terminal")
return tr("Terminal");
else if(orgStr == "distribution")//发行版
return tr("Distribution");
else if(orgStr == "language")//语言
return tr("Language");
else if(orgStr == "currrent_user")//当前用户
return tr("User");
else if(orgStr == "home_path")//用户主目录
return tr("Home Folder");
else if(orgStr == "Host bridge")//主桥
return tr("Host bridge");
else if(orgStr == "VGA compatible controller")//VGA兼容控制器
return tr("VGA Model");
else if(orgStr == "USB controller")//USB控制器
return tr("USB Model");
else if(orgStr == "Communication controller")//通信控制器
return tr("Communication Model");
else if(orgStr == "Ethernet controller")//以太网控制器
return tr("Ethernet Model");
else if(orgStr == "Audio device")//音频设备
return tr("Audio Model");
else if(orgStr == "PCI bridge")//PCI桥
return tr("PCI bridge");
else if(orgStr == "ISA bridge")//ISA桥
return tr("ISA bridge");
else if(orgStr == "SATA controller")//SATA控制器
return tr("SATA Model");
else if(orgStr == "SMBus")//系统管理总线
return tr("SMBus");
else if(orgStr == "System peripheral")//系统外围
return tr("System peripheral");
else if(orgStr == "driver in use")//使用的驱动
return tr("Driver in use");
else if(orgStr == "existing drivers")//可选的驱动
return tr("existing drivers");
else if(orgStr == "IDE interface")//IDE接口
return tr("IDE interface");
else if(orgStr == "Signal processing controller")//信号处理控制器
return tr("SP controller");
else if(orgStr == "Network controller")//网络控制器
return tr("Network controller");
else if(orgStr == "Multimedia audio controller")//多媒体音频控制器
return tr("Multimedia audio controller");
else if(orgStr == "DiskProduct")//硬盘型号:
return tr("HDD Model");
else if(orgStr == "DiskVendor")//硬盘厂商:
return tr("HDD Vendor");
else if(orgStr == "DiskCapacity")//硬盘容量:
return tr("HDD Capacity");
else if(orgStr == "DiskName")//设备名称:
return tr("Device Name");
else if(orgStr == "DiskFw")//固件版本:
return tr("Firmware Version");
else if(orgStr == "DiskSerial")//序列号:
return tr("Serial Number");
else if(orgStr == "MemSlot")//插槽号:
return tr("Slot Number");
else if(orgStr == "MemProduct")//内存型号:
return tr("Memory Model");
else if(orgStr == "MemVendor")//制造商:
return tr("Vendor");
else if(orgStr == "MemSerial")//序列号:
return tr("Serial Number");
else if(orgStr == "MemSize")//内存大小:
return tr("Memory Size");
else if(orgStr == "MemWidth")//数据宽度:
return tr("Data Width");
else if(orgStr == "MemInfo")//内存条信息:
return tr("Memory Info");
else if(orgStr == "Vga_product")//显卡型号:
return tr("Graphics Card Model");
else if(orgStr == "Mon_chip")//当前显卡:
return tr("Current Graphics Card");
else if(orgStr == "Vga_vendor")//显卡制造商:
return tr("Graphics Card Vendor");
else if(orgStr == "Vga_Drive")//显卡驱动:
return tr("Graphics Driver");
else if(orgStr == "Vga_businfo")//显卡总线地址:
return tr("Bus Address");
else if(orgStr == "Mon_gamma")//伽马值
return tr("Gamma");
else if(orgStr == "Mon_in")//屏幕尺寸(英寸)
return tr("Screen Size(inch)");
else if(orgStr == "Mon_maxmode")//最大分辨率
return tr("Max Resolution");
else if(orgStr == "Mon_output")//当前接口
return tr("Current Interface");
else if(orgStr == "Mon_product")//显示器型号:
return tr("Monitor Model");
else if(orgStr == "Mon_size")//可视面积
return tr("Visual Area");
else if(orgStr == "Mon_support")//支持接口
return tr("Support Interface");
else if(orgStr == "Mon_vendor")//显示器制造商
return tr("Monitor Manufacturers");
else if(orgStr == "Mon_week")//生产日期_周
return tr("Date of production/Week");
else if(orgStr == "Mon_year")//生产日期_年
return tr("Date of production/Year");
else if(orgStr == "NetVendor")//制造商:
return tr("Vendor");
else if(orgStr == "NetProduct")//网卡型号:
return tr("NIC Model");
else if(orgStr == "NetDrive")//有线网卡驱动:
return tr("NIC Driver");
else if(orgStr == "NetBusinfo")//总线地址:
return tr("Bus Address");
else if(orgStr == "NetLogicalname")//设备名称:
return tr("Device Name");
else if(orgStr == "NetIp")//IP地址
return tr("IP Address");
else if(orgStr == "NetSerial")//MAC地址
return tr("Mac Address");
else if(orgStr == "NetLink")//连接状态:
return tr("Connection Status");
else if(orgStr == "NetCapacity")//最大带宽:
return tr("Max Bandwidth");
else if(orgStr == "WlanVendor")//制造商:
return tr("Vendor");
else if(orgStr == "WlanDrive")//无线网卡驱动:
return tr("WLan NIC Driver");
else if(orgStr == "WlanProduct")//网卡型号:
return tr("WLan NIC Model");
else if(orgStr == "WlanBusinfo")//总线地址:
return tr("Bus Address");
else if(orgStr == "WlanLogicalname")//设备名称:
return tr("Device Name:");
else if(orgStr == "WlanSerial")//序列号:
return tr("Serial Number");
else if(orgStr == "WlanIp")//IP地址
return tr("IP Address");
else if (orgStr == "VNIC") {
return tr("VNIC");
}
else if (orgStr == "NetType") {
return tr("NetType");
}
else if (orgStr == "Ethernet interface") {
return tr("Ethernet interface");
}
else if (orgStr == "Wireless interface") {
return tr("Wireless interface");
}
else if(orgStr == "ComVendor")//制造商:
return tr("Vendor");
else if(orgStr == "ComProduct")//电脑型号:
return tr("Model");
else if(orgStr == "ComVersion")//电脑版本:
return tr("Version");
else if(orgStr == "ComSerial")//序列号:
return tr("Serial Number");
else if(orgStr == "node")//主机名:
return tr("Hostname");
else if(orgStr == "uptime")//持续运行时间:
return tr("Running Time");
else if(orgStr == "system")//操作系统类型:
return tr("OS Types");
else if(orgStr == "osname")//操作系统版本:
return tr("OS Version");
else if(orgStr == "architecture")//系统位数:
return tr("Kernel Bit");
else if(orgStr == "release")//内核版本:
return tr("Kernel Version");
else if(orgStr == "machine")//内核架构:
return tr("Kernel Arch");
else if (orgStr == "32bit")
return tr("32bit");
else if (orgStr == "64bit" || orgStr == "64 bits")
return tr("64bit");
else if (orgStr == "YHKylin community")
return tr("YHKylin community");
else if(orgStr == "IN0")//内存参考电压
return tr("Memory reference voltage");
else if(orgStr == "IN2")//SATA控制器电压
return tr("SATA controller voltage");
else if(orgStr == "IN3")//内存电压
return tr("Memory voltage");
else if(orgStr == "IN5")//CPU管脚电压
return tr("CPU pin voltage");
else if(orgStr == "IN6")//桥片电压
return tr("Bridge voltage");
else if(orgStr == "TR4")//CPU核电压
return tr("CPU core voltage");
else if(orgStr == "TR5")//CPU温度
return tr("CPU temperature");
else if(orgStr == "TR6")//主板温度
return tr("Motherboard temperature");
else if(orgStr == "FANIN1")//CPU风扇转速
return tr("CPU fan speed");
else
return orgStr;
}
//void ComputerPage::resizeEvent(QResizeEvent *event)
//{
// //获取当前窗口高度
//// this->resize(700, page_height);
//// page_height = height();
// QWidget::resizeEvent(event);
//}

View File

@ -1,114 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMPUTERPAGE_H
#define COMPUTERPAGE_H
#include <QWidget>
#include <QMap>
#include <QVariant>
#include "../dbusproxy/youkersessiondbus.h"
#include "../dbusproxy/youkersystemdbus.h"
class QLabel;
class QComboBox;
class QRadioButton;
class QGroupBox;
class QFormLayout;
class QHBoxLayout;
class ComputerPage : public QWidget
{
Q_OBJECT
public:
explicit ComputerPage(QWidget *parent = 0, QString title = "computer"/*, QString manufacturer = "UbuntuKylin"*/);
~ComputerPage();
void setLanguage();
int page_height;
void initUI(bool cpu);
void setMap(QMap<QString ,QVariant> tmp, const QString &manufacturer) {
info_map = tmp;
vendor = manufacturer;
}
void setsensor(bool flag) {
sensor = flag;
}
void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;}
QString translatorSwitch(QString orgStr);
void resetTimeValue(QString value);
void resetSensor(QMap<QString, QVariant> sensormap);
public slots:
void setRadioButtonRowStatus();
private:
QString title_context;
QLabel *title_label;
QString vendor;
// void resizeEvent(QResizeEvent *);
QMap<QString ,QVariant> info_map;
QLabel *logo_label;
QLabel *time_label;
QGroupBox *group_box;
QFormLayout *form_layout;
bool sensor;
QRadioButton *ondemand_radio;
QRadioButton *powersave_radio;
QRadioButton *performance_radio;
SystemDispatcher *systemProxy;
QHBoxLayout *layout;
QLabel *in0_label;
QLabel *in2_label;
QLabel *in3_label;
QLabel *in5_label;
QLabel *in6_label;
QLabel *tr1_label;
QLabel *tr2_label;
QLabel *tr3_label;
QLabel *tr4_label;
QLabel *tr5_label;
QLabel *tr6_label;
QLabel *fanin1_label;
QList<QLabel *> label_list;
/*
else if(orgStr == "IN0")//内存参考电压
return tr("Memory reference voltage");
else if(orgStr == "IN2")//SATA控制器电压
return tr("SATA controller voltage");
else if(orgStr == "IN3")//内存电压
return tr("Memory voltage");
else if(orgStr == "IN5")//CPU管脚电压
return tr("CPU pin voltage");
else if(orgStr == "IN6")//桥片电压
return tr("Bridge voltage");
else if(orgStr == "TR4")//CPU核电压
return tr("CPU core voltage");
else if(orgStr == "TR5")//CPU温度
return tr("CPU temperature");
else if(orgStr == "TR6")//主板温度
return tr("Motherboard temperature");
else if(orgStr == "FANIN1")//CPU风扇转速
return tr("CPU fan speed");
// ATX_3V3 TR1
// ATX_5V TR2
// ATX_12V TR3*/
};
#endif // COMPUTERPAGE_H

View File

@ -1,131 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cpuwidget.h"
CpuWidget::CpuWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
page = NULL;
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403 - 3);
dataOK = false;
// timer = new QTimer(this);
// connect(timer, SIGNAL(timeout()), this, SLOT(updateCpuTemp()));
}
CpuWidget::~CpuWidget()
{
// disconnect(timer,SIGNAL(timeout()),this,SLOT(updateCpuTemp()));
// if(timer->isActive()) {
// timer->stop();
// }
// if (timer != NULL) {
// delete timer;
// timer = NULL;
// }
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void CpuWidget::clear_page_list()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget)
scroll_widget->resetWidget();
}
bool CpuWidget::displaySwitch()
{
QMap<QString, QVariant> tmpMap = systemproxy->get_cpu_info_qt();
// if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
// return false;
// }
// else
// {
// QMap<QString,QVariant>::iterator it;
// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
// if (it.value().toString().length() > 0) {
// cpu_info_map.insert(it.key(), it.value());
// }
// }
// return true;
// }
QMap<QString,QVariant>::iterator it;
bool sflag = false;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it )
{
if (it.value().toString().length() > 0)
{
cpu_info_map.insert(it.key(), it.value());
sflag = true;
}
}
if (sflag)
return true;
else
return false;
}
bool CpuWidget::getStatus()
{
return this->dataOK;
}
void CpuWidget::initData()
{
this->clear_page_list();
page = new ComputerPage(scroll_widget->zone, tr("CPU Info"));
page->setSystemDbusProxy(systemproxy);
page->setMap(cpu_info_map, cpu_info_map.value("CpuVendor").toString().toUpper());
page->initUI(true);
scroll_widget->addScrollWidget(page);
/*QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
cpu_info_map.insert(it.key(), it.value());
}
}
if(cpu_info_map.count() == 1 && cpu_info_map.contains("kylinkobe"))
{
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("CPU Info"));
page->setMap(cpu_info_map, cpu_info_map.value("CpuVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}*/
// dataOK = true;
}
//void CpuWidget::updateCpuTemp()
//{
//}

View File

@ -1,57 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CPUWIDGET_H
#define CPUWIDGET_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
//#include <QTimer>
class QVariant;
class SystemDispatcher;
class CpuWidget : public QWidget
{
Q_OBJECT
public:
explicit CpuWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~CpuWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
// void updateCpuTemp();
private:
ScrollWidget *scroll_widget;
ComputerPage *page;
QMap<QString, QVariant> cpu_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
// QTimer *timer;
};
#endif // CPUWIDGET_H

View File

@ -1,117 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "desktopwidget.h"
DesktopWidget::DesktopWidget(QWidget *parent, SessionDispatcher *proxy) :
QWidget(parent),
sessionProxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
dataOK = false;
page = NULL;
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
}
DesktopWidget::~DesktopWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void DesktopWidget::clear_page_list()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget)
scroll_widget->resetWidget();
}
bool DesktopWidget::displaySwitch()
{
QMap<QString, QVariant> tmpMap = sessionProxy->get_system_message_qt();
// if (tmpMap.isEmpty() || tmpMap.count() <= 0)
// {
// return false;
// }
// else
// {
// QMap<QString,QVariant>::iterator it;
// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
// if (it.value().toString().length() > 0) {
// desktop_info_map.insert(it.key(), it.value());
// }
// }
// return true;
// }
QMap<QString,QVariant>::iterator it;
bool sflag = false;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it )
{
if (it.value().toString().length() > 0)
{
desktop_info_map.insert(it.key(), it.value());
sflag = true;
}
}
if (sflag)
return true;
else
return false;
}
bool DesktopWidget::getStatus()
{
return this->dataOK;
}
void DesktopWidget::initData()
{
this->clear_page_list();
page = new ComputerPage(scroll_widget->zone, tr("Desktop Info"));
page->setMap(desktop_info_map, "");
page->initUI(false);
scroll_widget->addScrollWidget(page);
/*QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
desktop_info_map.insert(it.key(), it.value());
}
}
if(desktop_info_map.count() == 1 && desktop_info_map.contains("kylinkobe"))
{
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Desktop Info"));
page->setMap(desktop_info_map, "UBUNTUKYLIN");
page->initUI();
scroll_widget->addScrollWidget(page);
}*/
// dataOK = true;
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DESKTOPWIDGET_H
#define DESKTOPWIDGET_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
class QVariant;
class SessionDispatcher;
class DesktopWidget : public QWidget
{
Q_OBJECT
public:
explicit DesktopWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0);
~DesktopWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
ComputerPage *page;
QMap<QString, QVariant> desktop_info_map;
SessionDispatcher *sessionProxy;
bool dataOK;
};
#endif // DESKTOPWIDGET_H

View File

@ -1,94 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "driverwidget.h"
#include "devicemanager.h"
#include <QDebug>
DriverWidget::DriverWidget(QWidget *parent/*, SystemDispatcher *proxy*/) :
QWidget(parent)
// systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
this->initData();
if(driver_info_map.count() != 0)
{
page = new ComputerPage(scroll_widget->zone, tr("Driver Info"));
page->setMap(driver_info_map,"");
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else {
page = NULL;
}
}
DriverWidget::~DriverWidget()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void DriverWidget::initData()
{
DeviceManager manager;
QStringList list = manager.getDeviceMsg();
for (int i=0 ; i < list.length() ; i++) {
QStringList splitlist = list.at(i).split(";");
if(splitlist.length() == 1) {
QStringList name = splitlist.at(0).split(":");
driver_info_map.insert(name.at(0).trimmed(), name.at(1));
// driver_info_map.insert("deviceName", name.at(0));
// driver_info_map.insert("deviceNameText", name.at(1));
}
else if(splitlist.length() == 2) {
QStringList name1 = splitlist.at(0).split(":");
QStringList name2 = splitlist.at(1).split(":");
driver_info_map.insert(name1.at(0).trimmed(), name1.at(1));
driver_info_map.insert(name2.at(0).trimmed(), name2.at(1));
// driver_info_map.insert("deviceName", name1.at(0));
// driver_info_map.insert("deviceNameText", name1.at(1));
// driver_info_map.insert("inUseName", name2.at(0));
// driver_info_map.insert("inUseNameText", name2.at(1));
}
else if(splitlist.length() == 3) {
QStringList name3 = splitlist[0].split(":");
QStringList name4 = splitlist[1].split(":");
QStringList name5 = splitlist[2].split(":");
driver_info_map.insert(name3.at(0).trimmed(), name3.at(1));
driver_info_map.insert(name4.at(0).trimmed(), name4.at(1));
driver_info_map.insert(name5.at(0).trimmed(), name5.at(1));
// driver_info_map.insert("deviceName", name3.at(0));
// driver_info_map.insert("deviceNameText", name3.at(1));
// driver_info_map.insert("inUseName", name4.at(0));
// driver_info_map.insert("inUseNameText", name4.at(1));
// driver_info_map.insert("existName", name5.at(0));
// driver_info_map.insert("existNameText", name5.at(1));
}
}
}

View File

@ -1,193 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hdwidget.h"
#include "computerpage.h"
HDWidget::HDWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
HDWidget::~HDWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void HDWidget::clear_page_list()
{
for(int i=0; i<page_list.count(); i++)
{
ComputerPage *page = page_list.at(i);
delete page;
page = NULL;
}
page_list.clear();
if (scroll_widget)
scroll_widget->resetWidget();
}
bool HDWidget::displaySwitch()
{
hd_info_map.clear();
hd_info_map = systemproxy->get_harddisk_info_qt();
if (hd_info_map.isEmpty() || hd_info_map.count() <= 0)
{
return false;
}
else
{
return true;
}
}
bool HDWidget::getStatus()
{
return this->dataOK;
}
void HDWidget::initData()
{
this->clear_page_list();
//0711
// hd_info_map.insert("DiskCapacity", "465.8 GiB, 500107862016 bytes<1_1>14.9 GiB, 16013942784 bytes");
// hd_info_map.insert("DiskFw", "0002LIM1<1_1>U21B001");
// hd_info_map.insert("DiskName", "/dev/sda<1_1>/dev/sdb");
// hd_info_map.insert("DiskNum", "2");
// hd_info_map.insert("DiskProduct", "ST500LM021-1KJ152<1_1>SanDisk SSD U110 16GB");
// hd_info_map.insert("DiskSerial", "W6227R7B<1_1>144116411501");
// hd_info_map.insert("DiskVendor", "Seagate<1_1>Seagate");
hd_info_map = systemproxy->get_harddisk_info_qt(); //?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用
QMap<QString, QVariant>::iterator iter = hd_info_map.find("DiskNum");
int diskNum = 0;
if (iter == hd_info_map.end()) {
diskNum = 0;
}
else{
diskNum = iter.value().toInt();
}
if(diskNum == 0) {
}
else {
if(diskNum == 1) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("HardWare Info"));
page_list.append(page);
hd_info_map.remove("DiskNum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = hd_info_map.begin(); it != hd_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, hd_info_map.value("DiskVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else if(diskNum > 1) {
for(int i=0;i<diskNum;i++) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("HardWare Info %1").arg(i+1));
page_list.append(page);
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = hd_info_map.begin();
QMap<QString, QVariant>::iterator itend = hd_info_map.end();
for (;itbegin != itend; ++itbegin) {
if(itbegin.key() != "DiskNum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
if (QString::compare(result, "$", Qt::CaseInsensitive) != 0)//20161228
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("DiskVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
}
/*QMap<QString, QVariant>::iterator iter = hd_info_map.find("DiskNum");
int diskNum = 0;
if (iter == hd_info_map.end())
{
diskNum = 0;
}
else{
diskNum = iter.value().toInt();
}
if(hd_info_map.count() == 1 && hd_info_map.contains("kylinkobe"))
{
}
else {
if(diskNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("HardWare Info"));
hd_info_map.remove("DiskNum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = hd_info_map.begin(); it != hd_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, hd_info_map.value("DiskVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
else if(diskNum > 1)
{
for(int i=0;i<diskNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("HardWare Info %1").arg(i+1));
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = hd_info_map.begin();
QMap<QString, QVariant>::iterator itend = hd_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "DiskNum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
if (QString::compare(result, "$", Qt::CaseInsensitive) != 0)//20161228
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("DiskVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
}
}*/
// dataOK = true;
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HDWIDGET_H
#define HDWIDGET_H
#include <QWidget>
#include "../component/scrollwidget.h"
#include <QMap>
#include <QVariant>
class SystemDispatcher;
class HDWidget : public QWidget
{
Q_OBJECT
public:
explicit HDWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~HDWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
QMap<QString, QVariant> hd_info_map;
QMap<QString, QVariant> tmp_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
QList<ComputerPage *> page_list;
};
#endif // HDWIDGET_H

163
info/infogui.cpp Normal file
View File

@ -0,0 +1,163 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "infogui.h"
#include "infounitwidget.h"
#include <QApplication>
#include <QResizeEvent>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QDebug>
InfoGui::InfoGui(QWidget *parent)
: QWidget(parent)
{
// this->setAutoFillBackground(true);
// QPalette palette;
// palette.setColor(QPalette::Background, QColor("#0d87ca"));
// this->setPalette(palette);
// setFixedSize(750, 403);
m_infoGuiName = "";
m_vLayout = new QVBoxLayout,
m_widget = new QFrame;
m_scrollArea = new QScrollArea;
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_vLayout->setSpacing(10);
m_vLayout->setMargin(0);
m_widget->setLayout(m_vLayout);
m_widget->setFixedWidth(m_scrollArea->width());
m_scrollArea->setWidget(m_widget);
QVBoxLayout *layout = new QVBoxLayout;//QHBoxLayout *mainLayout = static_cast<QHBoxLayout *>(layout());
layout->addWidget(m_scrollArea);
layout->setContentsMargins(5, 5, 5, 5);
layout->setSpacing(0);
this->setLayout(layout);
// this->loadOnePage(0, "AAA1", QMap<QString, QVariant>());
// this->loadOnePage(1, "AAA2", QMap<QString, QVariant>());
}
const QString InfoGui::infoGuiName() const
{
return this->m_infoGuiName;
}
void InfoGui::setInfoGuiName(const QString &name)
{
if (name != m_infoGuiName)
m_infoGuiName = name;
}
InfoGui::~InfoGui()
{
qDeleteAll(m_pageList);
m_pageList.clear();
if (m_vLayout) {
delete m_vLayout;
m_vLayout = nullptr;
}
if (m_widget) {
delete m_widget;
m_widget = nullptr;
}
if (m_scrollArea) {
delete m_scrollArea;
m_scrollArea = nullptr;
}
}
void InfoGui::clearWidget()
{
qDeleteAll(m_pageList);
m_pageList.clear();
}
void InfoGui::loadOnePage(int index, const QString &title, QMap<QString, QVariant> infoMap)
{
InfoUnitWidget *m_testWidget = new InfoUnitWidget(title);
QMap<QString,QVariant>::iterator it; //遍历map
for (it = infoMap.begin(); it != infoMap.end(); ++it) {
QString valueStr = it.value().toString().trimmed();
if (QString::compare(valueStr, "UNKOWN", Qt::CaseInsensitive) == 0 || QString::compare(valueStr, "UNKNOWN", Qt::CaseInsensitive) == 0) {//for arm memory
//do nothing
}
else if (it.key().length() > 0 && valueStr.length() > 0) {
m_testWidget->addInfoItem(it.key(), valueStr);
}
}
m_vLayout->addWidget(m_testWidget, 0, Qt::AlignTop);//m_vLayout->insertWidget(index, m_testWidget);
m_pageList.append(m_testWidget);
}
void InfoGui::updatePageData(const QString &title, QMap<QString, QVariant> infoMap)
{
if (m_pageList.count() <= 0) {
InfoUnitWidget *m_testWidget = new InfoUnitWidget(title);
QMap<QString,QVariant>::iterator it; //遍历map
for (it = infoMap.begin(); it != infoMap.end(); ++it) {
QString valueStr = it.value().toString().trimmed();
if (QString::compare(valueStr, "UNKOWN", Qt::CaseInsensitive) == 0 || QString::compare(valueStr, "UNKNOWN", Qt::CaseInsensitive) == 0) {//for arm memory
//do nothing
}
else if (it.key().length() > 0 && valueStr.length() > 0) {
m_testWidget->addInfoItem(it.key(), valueStr);
}
}
m_vLayout->addWidget(m_testWidget, 0, Qt::AlignTop);//m_vLayout->insertWidget(index, m_testWidget);
m_pageList.append(m_testWidget);
}
foreach (InfoUnitWidget *widget, m_pageList) {
if (widget->title() == title) {
QMap<QString,QVariant>::iterator it; //遍历map
for (it = infoMap.begin(); it != infoMap.end(); ++it) {
QString valueStr = it.value().toString().trimmed();
if (QString::compare(valueStr, "UNKOWN", Qt::CaseInsensitive) == 0 || QString::compare(valueStr, "UNKNOWN", Qt::CaseInsensitive) == 0) {//for arm memory
//do nothing
}
else if (it.key().length() > 0 && valueStr.length() > 0) {
widget->refreshInfoItem(it.key(), valueStr);
}
}
break;
}
}
}
void InfoGui::updateRunningTime(const QString &runningTime)
{
foreach (InfoUnitWidget *widget, m_pageList) {
int index = widget->getCurrentRunningTimeUIIndex();
if (index >= 0) {
// getInfoItem
}
}
}

54
info/infogui.h Normal file
View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INFOGUI_H
#define INFOGUI_H
#include "infounitwidget.h"
#include <QMap>
class QVBoxLayout;
class QScrollArea;
class InfoGui : public QWidget
{
Q_OBJECT
public:
explicit InfoGui(QWidget *parent = 0);
~InfoGui();
const QString infoGuiName() const;
void setInfoGuiName(const QString &name);
void clearWidget();
void loadOnePage(int index, const QString &title, QMap<QString, QVariant> infoMap);
void updatePageData(const QString &title, QMap<QString, QVariant> infoMap);
void updateRunningTime(const QString &runningTime);
private:
QVBoxLayout *m_vLayout = nullptr;
QFrame *m_widget = nullptr;
QScrollArea *m_scrollArea = nullptr;
QList<InfoUnitWidget *> m_pageList;
QString m_infoGuiName;
};
#endif // INFOGUI_H

152
info/infoitemline.cpp Normal file
View File

@ -0,0 +1,152 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "infoitemline.h"
#include <QHBoxLayout>
InfoItemLine::InfoItemLine(QFrame *parent)
: QFrame(parent)
{
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
this->setFixedHeight(36);
m_key = "";
m_keyLabel = new QLabel;
m_valueLabel = new QLabel;
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
mainLayout->setContentsMargins(20, 0, 10, 0);
mainLayout->addWidget(m_keyLabel);
mainLayout->addSpacing(10);
mainLayout->addWidget(m_valueLabel);
mainLayout->addStretch();
this->setLayout(mainLayout);
}
InfoItemLine::~InfoItemLine()
{
delete m_keyLabel;
delete m_valueLabel;
}
void InfoItemLine::setInfoKey(const QString &key)
{
m_keyLabel->setText(key);
m_key = key;
}
void InfoItemLine::setInfoValue(const QString &value)
{
m_valueLabel->setText(value);
}
QString InfoItemLine::getLineKey()
{
return m_key;
}
void InfoItemLine::createCpuSwitcherGroup()
{
/*ondemand_radio = new QRadioButton();
ondemand_radio->setFocusPolicy(Qt::NoFocus);
ondemand_radio->setFixedHeight(30);
ondemand_radio->setText(tr("Ondemand"));
ondemand_radio->setObjectName("ondemandradio");
ondemand_radio->setChecked(false);
ondemand_radio->hide();
powersave_radio = new QRadioButton();
powersave_radio->setFixedHeight(30);
powersave_radio->setFocusPolicy(Qt::NoFocus);
powersave_radio->setText(tr("Powersave"));
powersave_radio->setObjectName("powersaveradio");
powersave_radio->setChecked(false);
powersave_radio->hide();
performance_radio = new QRadioButton();
performance_radio->setFixedHeight(30);
performance_radio->setFocusPolicy(Qt::NoFocus);
performance_radio->setText(tr("Performance"));
performance_radio->setObjectName("performanceradio");
performance_radio->setChecked(false);
performance_radio->hide();
connect(ondemand_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
connect(powersave_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
connect(performance_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
layout = new QHBoxLayout();
layout->setSpacing(10);
layout->addWidget(ondemand_radio);
layout->addWidget(powersave_radio);
layout->addWidget(performance_radio);
layout->addStretch();
QString cur_cpu = systemProxy->get_current_cpufreq_scaling_governer_qt();
QList<QString>::Iterator it = cpulist.begin(), itend = cpulist.end();
bool showed = false;
for(;it != itend; it++)
{
if(*it == "ondemand") {
if (cur_cpu == *it) {
ondemand_radio->setChecked(true);
powersave_radio->setChecked(false);
performance_radio->setChecked(false);
}
ondemand_radio->show();
showed = true;
}
else if(*it == "powersave") {
if (cur_cpu == *it) {
powersave_radio->setChecked(true);
ondemand_radio->setChecked(false);
performance_radio->setChecked(false);
}
powersave_radio->show();
showed = true;
}
else if(*it == "performance") {
if (cur_cpu == *it) {
performance_radio->setChecked(true);
ondemand_radio->setChecked(false);
powersave_radio->setChecked(false);
}
performance_radio->show();
showed = true;
}
}*/
}
void InfoItemLine::setRadioButtonRowStatus()
{
//emit this->clicked("aaa");
/*QObject *obj = sender(); //返回发出信号的对象用QObject类型接收
QRadioButton* pbtn = qobject_cast<QRadioButton*>(obj);
QString obj_name = pbtn->objectName();
if(obj_name == "ondemandradio") {
systemProxy->adjust_cpufreq_scaling_governer_qt("ondemand");
}
else if(obj_name == "powersaveradio") {
systemProxy->adjust_cpufreq_scaling_governer_qt("powersave");
}
else if(obj_name == "performanceradio") {
systemProxy->adjust_cpufreq_scaling_governer_qt("performance");
}*/
}

56
info/infoitemline.h Normal file
View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INFOITEMLINE_H
#define INFOITEMLINE_H
#include <QLabel>
class QRadioButton;
class InfoItemLine : public QFrame
{
Q_OBJECT
public:
explicit InfoItemLine(QFrame *parent = 0);
~InfoItemLine();
void setInfoKey(const QString &key);
void setInfoValue(const QString &value);
void createCpuSwitcherGroup();
QString getLineKey();
public slots:
void setRadioButtonRowStatus();
signals:
void clicked(const QString &context) const;
private:
QLabel *m_keyLabel = nullptr;
QLabel *m_valueLabel = nullptr;
QString m_key;
// QRadioButton *ondemand_radio = nullptr;
// QRadioButton *powersave_radio = nullptr;
// QRadioButton *performance_radio = nullptr;
};
#endif // INFOITEMLINE_H

87
info/infoitemsgroup.cpp Normal file
View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "infoitemsgroup.h"
#include "infoitemline.h"
#include <QVBoxLayout>
#include <QDebug>
InfoItemsGroup::InfoItemsGroup(QFrame *parent) :
QFrame(parent),
m_layout(new QVBoxLayout)
{
m_layout->setMargin(0);
m_layout->setSpacing(1);
this->setLayout(m_layout);
}
InfoItemsGroup::~InfoItemsGroup()
{
/*if (m_layout) {
foreach (QObject *child, m_layout->children()) {
QWidget *widget = static_cast<QWidget *>(child);
widget->deleteLater();
}
}*/
for (int i = 0; i != m_layout->count(); ++i)
{
QLayoutItem *child = m_layout->takeAt(0);
QWidget *w = child->widget();
w->removeEventFilter(this);
w->setParent(nullptr);
delete child;
child = nullptr;
}
/*QLayoutItem *child;
while ((child = m_layout->takeAt(0)) != 0) {
if (child->widget())
child->widget()->deleteLater();
delete child;
}*/
}
int InfoItemsGroup::appendItem(InfoItemLine *item)
{
m_layout->insertWidget(m_layout->count(), item);
item->installEventFilter(this);
return m_layout->count() - 1;
}
void InfoItemsGroup::removeItem(InfoItemLine *item)
{
m_layout->removeWidget(item);
item->removeEventFilter(this);
}
InfoItemLine *InfoItemsGroup::getInfoItem(int index)
{
if(index < 0)
return NULL;
if(index < m_layout->count())
{
return qobject_cast<InfoItemLine *>(m_layout->itemAt(index)->widget());
}
return NULL;
}

45
info/infoitemsgroup.h Normal file
View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INFOITEMSGROUP_H
#define INFOITEMSGROUP_H
#include <QFrame>
class QVBoxLayout;
class InfoItemLine;
class InfoItemsGroup : public QFrame
{
Q_OBJECT
public:
explicit InfoItemsGroup(QFrame *parent = 0);
~InfoItemsGroup();
int appendItem(InfoItemLine *item);
void removeItem(InfoItemLine *item);
InfoItemLine* getInfoItem(int index);
private:
QVBoxLayout *m_layout = nullptr;
};
#endif // INFOITEMSGROUP_H

137
info/infounitwidget.cpp Normal file
View File

@ -0,0 +1,137 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "infounitwidget.h"
#include "infoitemline.h"
#include "infoitemsgroup.h"
#include <QEvent>
#include <QDebug>
#include <QPainter>
InfoUnitWidget::InfoUnitWidget(QString title, QWidget *parent)
: QWidget(parent)
, m_currentRunningTimeUIIndex(-1)
{
//kobe: QHBoxLayout *mainLayout = static_cast<QHBoxLayout *>(layout());
m_titleLabel = new QLabel;
m_titleLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
m_titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
m_vendorLabel = new QLabel;
m_vendorLabel->setFixedSize(48, 48);
this->setInfoTitle(title);
this->setInfoVendor(":/vendor/res/manufacturer/ACER.jpg");
QHBoxLayout *headerLayout = new QHBoxLayout;
headerLayout->setContentsMargins(10, 0, 0, 0);
headerLayout->addWidget(m_titleLabel);
headerLayout->addStretch();
headerLayout->addWidget(m_vendorLabel);
headerLayout->setAlignment(m_vendorLabel, Qt::AlignCenter);
QFrame *headerWidget = new QFrame;
headerWidget->setStyleSheet("QFrame {padding: 5px 0;} QFrame:hover {background-color: rgba(255, 255, 255, 0.1);border-radius: 4px;}");
headerWidget->setLayout(headerLayout);
m_infoLayout = new QVBoxLayout;
m_infoLayout->addWidget(headerWidget);
m_infoLayout->setSpacing(5);
m_infoLayout->setMargin(0);
m_infoItemsGroup = new InfoItemsGroup;
m_infoLayout->addWidget(m_infoItemsGroup);
setLayout(m_infoLayout);
// m_infoItemsGroup->getInfoItem()
}
InfoUnitWidget::~InfoUnitWidget()
{
m_currentRunningTimeUIIndex = -1;
QList<InfoItemLine *> items = findChildren<InfoItemLine*>();
for (InfoItemLine *item : items) {
m_infoItemsGroup->removeItem(item);
item->deleteLater();
}
if (m_infoItemsGroup) {
delete m_infoItemsGroup;
m_infoItemsGroup = 0;
}
}
const QString InfoUnitWidget::title() const
{
return m_titleLabel->text();
}
void InfoUnitWidget::setInfoTitle(const QString &title)
{
m_titleLabel->setText(title);
setAccessibleName(title);
}
void InfoUnitWidget::setInfoVendor(const QString &vendor)
{
QPainterPath painterPath;
painterPath.addEllipse(QRect(0, 0, 48, 48));
const QPixmap pixmap = QPixmap(vendor).scaled(48, 48, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap pic(48, 48);
pic.fill(Qt::transparent);
QPainter painter(&pic);
painter.setRenderHint(QPainter::Antialiasing);
painter.setClipPath(painterPath);
painter.drawPixmap(QRect(0, 0, 48, 48), pixmap);
m_vendorLabel->setPixmap(pic);
}
void InfoUnitWidget::addInfoItem(const QString &key, const QString &value)
{
InfoItemLine *w = new InfoItemLine;
const int index = m_infoItemsGroup->appendItem(w);
if (key == "uptime") {
m_currentRunningTimeUIIndex = index;
}
w->setInfoKey(key);
w->setInfoValue(value);
connect(w, &InfoItemLine::clicked, [=] (const QString &context) { qDebug() << context; });
}
void InfoUnitWidget::refreshInfoItem(const QString &key, const QString &value)
{
QList<InfoItemLine *> items = findChildren<InfoItemLine*>();
for (InfoItemLine *item : items) {
if (item->getLineKey() == key) {
item->setInfoValue(value);
}
}
}
int InfoUnitWidget::getCurrentRunningTimeUIIndex()
{
return m_currentRunningTimeUIIndex;
}

58
info/infounitwidget.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INFOUNITWIDGET_H
#define INFOUNITWIDGET_H
#include "infounitwidget.h"
#include "infoitemsgroup.h"
#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
class InfoUnitWidget : public QWidget
{
Q_OBJECT
public:
explicit InfoUnitWidget(QString title, QWidget *parent = 0);
~InfoUnitWidget();
const QString title() const;
void setInfoTitle(const QString &title);
void setInfoVendor(const QString &vendor);
int getCurrentRunningTimeUIIndex();
void refreshInfoItem(const QString &key, const QString &value);
protected:
QVBoxLayout *m_infoLayout = nullptr;
public slots:
void addInfoItem(const QString &key, const QString &value);
private:
InfoItemsGroup *m_infoItemsGroup = nullptr;
QLabel *m_titleLabel = nullptr;
QLabel *m_vendorLabel = nullptr;
int m_currentRunningTimeUIIndex;
};
#endif // INFOUNITWIDGET_H

View File

@ -1,181 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "memorywidget.h"
#include "computerpage.h"
#include "../dbusproxy/youkersystemdbus.h"
#include <QDebug>
MemoryWidget::MemoryWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
MemoryWidget::~MemoryWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void MemoryWidget::clear_page_list()
{
for(int i=0; i<page_list.count(); i++)
{
ComputerPage *page = page_list.at(i);
delete page;
page = NULL;
}
page_list.clear();
if (scroll_widget)
scroll_widget->resetWidget();
}
bool MemoryWidget::displaySwitch()
{
memory_info_map.clear();
memory_info_map = systemproxy->get_memory_info_qt();
if (memory_info_map.isEmpty() || memory_info_map.count() <= 0)
{
return false;
}
else
{
return true;
}
}
bool MemoryWidget::getStatus()
{
return this->dataOK;
}
void MemoryWidget::initData()
{
this->clear_page_list();
memory_info_map = systemproxy->get_memory_info_qt();//?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用
QMap<QString, QVariant>::iterator iter = memory_info_map.find("Memnum");
int memoryNum = 0;
if (iter == memory_info_map.end()) {
memoryNum = 0;
}
else{
memoryNum = iter.value().toInt();
}
if(memoryNum == 0) {
}
else {
if(memoryNum == 1) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Memory Info"));
page_list.append(page);
memory_info_map.remove("Memnum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = memory_info_map.begin(); it != memory_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, "UBUNTUKYLIN");
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else if(memoryNum > 1) {
for(int i=0;i<memoryNum;i++) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Memory Info %1").arg(i+1));
page_list.append(page);
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = memory_info_map.begin();
QMap<QString, QVariant>::iterator itend = memory_info_map.end();
for (;itbegin != itend; ++itbegin) {
if(itbegin.key() != "Memnum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("MemVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
}
/*QMap<QString, QVariant>::iterator iter = memory_info_map.find("Memnum");
int memoryNum = 0;
if (iter == memory_info_map.end())
{
memoryNum = 0;
}
else{
memoryNum = iter.value().toInt();
}
if(memory_info_map.count() == 1 && memory_info_map.contains("kylinkobe"))
{
}
else {
if(memoryNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Memory Info"));
memory_info_map.remove("Memnum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = memory_info_map.begin(); it != memory_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, "UBUNTUKYLIN");
page->initUI();
scroll_widget->addScrollWidget(page);
}
else if(memoryNum > 1)
{
for(int i=0;i<memoryNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Memory Info %1").arg(i+1));
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = memory_info_map.begin();
QMap<QString, QVariant>::iterator itend = memory_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "Memnum" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("MemVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
}
}*/
// dataOK = true;
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MEMORYWIDGET_H
#define MEMORYWIDGET_H
#include <QWidget>
#include "../component/scrollwidget.h"
#include <QMap>
#include <QVariant>
class SystemDispatcher;
class MemoryWidget : public QWidget
{
Q_OBJECT
public:
explicit MemoryWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~MemoryWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
QMap<QString, QVariant> memory_info_map;
QMap<QString, QVariant> tmp_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
QList<ComputerPage *> page_list;
};
#endif // MEMORYWIDGET_H

View File

@ -1,188 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "monitorwidget.h"
#include "computerpage.h"
MonitorWidget::MonitorWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
MonitorWidget::~MonitorWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void MonitorWidget::clear_page_list()
{
for(int i=0; i<page_list.count(); i++)
{
ComputerPage *page = page_list.at(i);
delete page;
page = NULL;
}
page_list.clear();
if (scroll_widget)
scroll_widget->resetWidget();
}
bool MonitorWidget::displaySwitch()
{
monitor_info_map.clear();
monitor_info_map = systemproxy->get_monitor_info_qt();
if (monitor_info_map.isEmpty() || monitor_info_map.count() <= 0)
{
return false;
}
else
{
return true;
}
}
bool MonitorWidget::getStatus()
{
return this->dataOK;
}
void MonitorWidget::initData()
{
this->clear_page_list();
//0711
// monitor_info_map.insert("Mon_chip", "Intel(R) HD Graphics 4400");
// monitor_info_map.insert("Vga_Drive", "i915<1_1>nouveau");
// monitor_info_map.insert("Vga_businfo", "pci@0000:00:02.0 <1_1>pci@0000:04:00.0");
// monitor_info_map.insert("Vga_num", "2");
// monitor_info_map.insert("Vga_product", "Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])<1_1>NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] (rev a1) (prog-if 00 [VGA controller]");
// monitor_info_map.insert("Vga_vendor", "Intel<1_1>Nvidia");
monitor_info_map = systemproxy->get_monitor_info_qt();//?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用
QMap<QString, QVariant>::iterator iter = monitor_info_map.find("Vga_num");
int vgaNum = 0;
if (iter == monitor_info_map.end()) {
vgaNum = 0;
}
else {
vgaNum = iter.value().toInt();
}
if(vgaNum == 0) {
}
else {
if(vgaNum == 1) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Monitor Info"));
page_list.append(page);
monitor_info_map.remove("Vga_num");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = monitor_info_map.begin(); it != monitor_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, monitor_info_map.value("Vga_vendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else if(vgaNum > 1) {
for(int i=0;i<vgaNum;i++) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Monitor Info %1").arg(i+1));
page_list.append(page);
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = monitor_info_map.begin();
QMap<QString, QVariant>::iterator itend = monitor_info_map.end();
for (;itbegin != itend; ++itbegin) {
if(itbegin.key() != "Vga_num" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("Vga_vendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
}
/*QMap<QString, QVariant>::iterator iter = monitor_info_map.find("Vga_num");
int vgaNum = 0;
if (iter == monitor_info_map.end())
{
vgaNum = 0;
}
else{
vgaNum = iter.value().toInt();
}
if(monitor_info_map.count() == 1 && monitor_info_map.contains("kylinkobe"))
{
}
else {
if(vgaNum == 1)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Monitor Info"));
monitor_info_map.remove("Vga_num");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = monitor_info_map.begin(); it != monitor_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(tmpMap, monitor_info_map.value("Vga_vendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
else if(vgaNum > 1)
{
for(int i=0;i<vgaNum;i++)
{
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Monitor Info %1").arg(i+1));
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = monitor_info_map.begin();
QMap<QString, QVariant>::iterator itend = monitor_info_map.end();
for (;itbegin != itend; ++itbegin)
{
if(itbegin.key() != "Vga_num" && itbegin.value().toString().contains("<1_1>")) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
tmp_info_map.insert(itbegin.key(), result);
}
}
}
page->setMap(tmp_info_map, tmp_info_map.value("Vga_vendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
}
}*/
// dataOK = true;
}

View File

@ -1,55 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MONITORWIDGET_H
#define MONITORWIDGET_H
#include <QWidget>
#include "../component/scrollwidget.h"
#include <QMap>
#include <QVariant>
class SystemDispatcher;
class MonitorWidget : public QWidget
{
Q_OBJECT
public:
explicit MonitorWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~MonitorWidget();
void initData();
bool getStatus();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
private:
ScrollWidget *scroll_widget;
QMap<QString, QVariant> monitor_info_map;
QMap<QString, QVariant> tmp_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
QList<ComputerPage *> page_list;
};
#endif // MONITORWIDGET_H

View File

@ -1,505 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "nicwidget.h"
#include <QDebug>
NicWidget::NicWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
dataOK = false;
}
NicWidget::~NicWidget()
{
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void NicWidget::clear_page_list()
{
for(int i=0; i<page_list.count(); i++)
{
ComputerPage *page = page_list.at(i);
delete page;
page = NULL;
}
page_list.clear();
if (scroll_widget)
scroll_widget->resetWidget();
}
bool NicWidget::getStatus()
{
return this->dataOK;
}
void NicWidget::slot_network_info(QMap<QString, QVariant> info)
{
// qDebug() << "slot_network_info=" << info;
this->clear_page_list();
wire_info_map.clear();
wire_info_map = info;
if (wire_info_map.isEmpty() || wire_info_map.count() <= 1) {//may be wire_info_map only contains NetNum
}
else {
QMap<QString, QVariant>::iterator iter = wire_info_map.find("NetNum");
int netNum = 0;
if (iter == wire_info_map.end()) {
netNum = 0;
}
else{
netNum = iter.value().toInt();
}
wire_info_map.remove("NetNum");
// qDebug() << netNum;
if(netNum == 0) {
}
else {
if(netNum == 1) {
if (wire_info_map.contains("NetLogicalname")) {
QMap<QString,QVariant>::iterator iter = wire_info_map.find("NetLogicalname");
QString netcard = iter.value().toString();
if (netcard.startsWith("veth") || netcard.startsWith("virbr")) {
wire_info_map["NetType"] = "VNIC";
}
}
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
page_list.append(page);
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
if (wire_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) {
page->setMap(tmpMap, "INTEL");
}
else if (wire_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) {
page->setMap(tmpMap, "REALTEK");
}
else {
page->setMap(tmpMap, "");
}
page->initUI(false);
scroll_widget->addScrollWidget(page);
page->show();
}
else if(netNum > 1) {
for(int i=0;i<netNum;i++) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(i+1));
page_list.append(page);
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = wire_info_map.begin();
QMap<QString, QVariant>::iterator itend = wire_info_map.end();
for (;itbegin != itend; ++itbegin) {
if(itbegin.value().toString().contains("<1_1>")) {
QStringList tmplist = itbegin.value().toString().split("<1_1>");
if (tmplist.length() >= i) {
QString result = tmplist.at(i);
if (result.length() > 0)
tmp_info_map.insert(itbegin.key(), result);
}
}
}
if (tmp_info_map.contains("NetLogicalname")) {
if (tmp_info_map.value("NetLogicalname").toString().startsWith("veth") || tmp_info_map.value("NetLogicalname").toString().startsWith("virbr")) {
tmp_info_map["NetType"] = QVariant("VNIC");
}
}
// qDebug() << "tmp_info_map=" << tmp_info_map;
if (tmp_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) {
page->setMap(tmp_info_map, "INTEL");
}
else if (tmp_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) {
page->setMap(tmp_info_map, "REALTEK");
}
else {
page->setMap(tmp_info_map, "");
}
page->initUI(false);
scroll_widget->addScrollWidget(page);
page->show();
}
}
}
}
// dataOK = true;
}
void NicWidget::initData()
{
/*wire_info_map.clear();
wire_info_map = systemproxy->get_networkcard_info_qt();
if (wire_info_map.isEmpty() || wire_info_map.count() <= 1) {//may be wire_info_map only contains NetNum
}
else {
QMap<QString, QVariant>::iterator iter = wire_info_map.find("NetNum");
int netNum = 0;
if (iter == wire_info_map.end()) {
netNum = 0;
}
else{
netNum = iter.value().toInt();
}
wire_info_map.remove("NetNum");
if(netNum == 0) {
}
else {
if(netNum == 1) {
if (wire_info_map.contains("NetLogicalname")) {
QMap<QString,QVariant>::iterator iter = wire_info_map.find("NetLogicalname");
QString netcard = iter.value().toString();
if (netcard.startsWith("veth") || netcard.startsWith("virbr")) {
wire_info_map["NetType"] = "VNIC";
}
}
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
tmpMap.insert(it.key(), it.value());
}
}
if (wire_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) {
page->setMap(tmpMap, "INTEL");
}
else if (wire_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) {
page->setMap(tmpMap, "REALTEK");
}
else {
page->setMap(tmpMap, "");
}
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
else if(netNum > 1) {
for(int i=0;i<netNum;i++) {
ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(i+1));
tmp_info_map.clear();
QMap<QString, QVariant>::iterator itbegin = wire_info_map.begin();
QMap<QString, QVariant>::iterator itend = wire_info_map.end();
for (;itbegin != itend; ++itbegin) {
if(itbegin.value().toString().contains("<1_1>")) {
QStringList tmplist = itbegin.value().toString().split("<1_1>");
if (tmplist.length() >= i) {
QString result = tmplist.at(i);
if (result.length() > 0)
tmp_info_map.insert(itbegin.key(), result);
}
}
}
if (tmp_info_map.contains("NetLogicalname")) {
if (tmp_info_map.value("NetLogicalname").toString().startsWith("veth") || tmp_info_map.value("NetLogicalname").toString().startsWith("virbr")) {
tmp_info_map["NetType"] = QVariant("VNIC");
}
}
if (tmp_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) {
page->setMap(tmp_info_map, "INTEL");
}
else if (tmp_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) {
page->setMap(tmp_info_map, "REALTEK");
}
else {
page->setMap(tmp_info_map, "");
}
page->initUI(false);
scroll_widget->addScrollWidget(page);
}
}
}
}
dataOK = true;*/
/*QMap<QString, QVariant> tmpMap = systemproxy->get_networkcard_info_qt();
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
page2 = NULL;
}
else {
QMap<QString,QVariant>::iterator it;//遍历map
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if(it.key().startsWith("Wlan")) {
if (it.value().toString().length() > 0) {
wireless_info_map.insert(it.key(), it.value());
}
}
else {
if (it.value().toString().length() > 0) {
wire_info_map.insert(it.key(), it.value());
}
}
}
QMap<QString, QVariant>::iterator iter = tmpMap.find("NetNum");
int netNum = 0;
if (iter == tmpMap.end()) {
netNum = 0;
}
else {
netNum = iter.value().toInt();
}
if(wire_info_map.isEmpty() || wire_info_map.count() <= 0) {
}
else {
if(netNum == 1) {
ComputerPage *page = NULL;
if (wire_info_map.contains("NetLogicalname")) {
QMap<QString,QVariant>::iterator iter = wire_info_map.find("NetLogicalname");
QString netcard = iter.value().toString();
if (netcard.startsWith("veth") || netcard.startsWith("virbr")) {
page = new ComputerPage(scroll_widget->zone, tr("Vir NIC Info"));
}
else {
page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
}
}
else {
page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
}
// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
wire_info_map.remove("NetNum");
QMap<QString, QVariant> tmpMap;
QMap<QString,QVariant>::iterator it;
for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) {
if (it.value().toString().length() > 0) {
if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228
tmpMap.insert(it.key(), it.value());
}
}
page->setMap(wire_info_map, wire_info_map.value("NetVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
else if(netNum > 1) {
int vir = 0;
int nic = 0;
bool pageInit = false;
for(int i=0;i<netNum;i++) {
ComputerPage *page = NULL;
tmp_info_map.clear();
pageInit = false;
QMap<QString, QVariant>::iterator itbegin = wire_info_map.begin();
QMap<QString, QVariant>::iterator itend = wire_info_map.end();
for (;itbegin != itend; ++itbegin) {
if(itbegin.key() != "NetNum" && itbegin.value().toString().contains("<1_1>")) {
int len = itbegin.value().toString().split("<1_1>").length();
if (len > i) {
QString result = itbegin.value().toString().split("<1_1>").at(i);
if (result.length() > 0) {
if (QString::compare(result, "$", Qt::CaseInsensitive) != 0) {
tmp_info_map.insert(itbegin.key(), result);
if (itbegin.key() == "NetLogicalname") {
if (result.startsWith("veth") || result.startsWith("virbr")) {
if (!pageInit) {
vir ++;
page = new ComputerPage(scroll_widget->zone, tr("Vir NIC Info %1").arg(vir));
}
}
else {
if (!pageInit) {
nic ++;
page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(nic));
}
}
pageInit = true;
}
}
}
}
else {
tmp_info_map.insert(itbegin.key(), "unknown");
}
}
}
// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(i+1));
page->setMap(tmp_info_map, tmp_info_map.value("NetVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
}
}
}
if (wireless_info_map.isEmpty() || wireless_info_map.count() == 0) {
page2 = NULL;
}
else {
page2 = new ComputerPage(scroll_widget->zone, tr("WireLess NIC Info"));
page2->setMap(wireless_info_map, wireless_info_map.value("WlanVendor").toString().toUpper());
page2->initUI();
scroll_widget->addScrollWidget(page2);
}
}*/
// QMap<QString,QVariant>::iterator it;//遍历map
// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
// if(it.key().startsWith("Wlan"))
// {
// if (it.value().toString().length() > 0) {
// wireless_info_map.insert(it.key(), it.value());
// }
// }
// else
// {
// if (it.value().toString().length() > 0) {
// wire_info_map.insert(it.key(), it.value());
// }
// }
// }
// QMap<QString, QVariant>::iterator iter = tmpMap.find("NetNum");
// int netNum = 0;
// if (iter == tmpMap.end())
// {
// netNum = 0;
// }
// else {
// netNum = iter.value().toInt();
// }
// if(wire_info_map.count() == 1 && wire_info_map.contains("kylinkobe"))
// {
// }
// else {
// if(netNum == 1)
// {
// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
// wire_info_map.remove("NetNum");
// QMap<QString, QVariant> tmpMap;
// QMap<QString,QVariant>::iterator it;
// for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) {
// if (it.value().toString().length() > 0) {
// if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228
// tmpMap.insert(it.key(), it.value());
// }
// }
// page->setMap(wire_info_map, wire_info_map.value("NetVendor").toString().toUpper());
// page->initUI();
// scroll_widget->addScrollWidget(page);
// }
// else if(netNum > 1)
// {
// for(int i=0;i<netNum;i++)
// {
// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(i+1));
// tmp_info_map.clear();
// QMap<QString, QVariant>::iterator itbegin = wire_info_map.begin();
// QMap<QString, QVariant>::iterator itend = wire_info_map.end();
// for (;itbegin != itend; ++itbegin)
// {
// if(itbegin.key() != "NetNum" && itbegin.value().toString().contains("<1_1>")) {
// int len = itbegin.value().toString().split("<1_1>").length();
// if (len > i) {
// QString result = itbegin.value().toString().split("<1_1>").at(i);
// if (result.length() > 0) {
// if (QString::compare(result, "$", Qt::CaseInsensitive) != 0)//20161228
// tmp_info_map.insert(itbegin.key(), result);
// }
// }
// else {
// tmp_info_map.insert(itbegin.key(), "unknown");
// }
// }
// }
// page->setMap(tmp_info_map, tmp_info_map.value("NetVendor").toString().toUpper());
// page->initUI();
// scroll_widget->addScrollWidget(page);
// }
// }
// }
// if((wireless_info_map.count() == 0) || (wireless_info_map.count() == 1 && wireless_info_map.contains("kylinkobe")))
// {
// page2 = NULL;
// }
// else {
// page2 = new ComputerPage(scroll_widget->zone, tr("WireLess NIC Info"));
// page2->setMap(wireless_info_map, wireless_info_map.value("WlanVendor").toString().toUpper());
// page2->initUI();
// scroll_widget->addScrollWidget(page2);
// }
// dataOK = true;
// QMap<QString,QVariant>::iterator it; //遍历map
// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
// if(it.key().startsWith("Wlan"))
// {
// if (it.value().toString().length() > 0) {
// wireless_info_map.insert(it.key(), it.value());
// }
// }
// else
// {
// if (it.value().toString().length() > 0) {
// wire_info_map.insert(it.key(), it.value());
// }
// }
// }
// if((wire_info_map.count() == 0) || (wire_info_map.count() == 1 && wire_info_map.contains("kylinkobe")))
// {
// page = NULL;
// }
// else {
// page = new ComputerPage(scroll_widget->zone, tr("NIC Info"));
// page->setMap(wire_info_map, wire_info_map.value("NetVendor").toString().toUpper());
// page->initUI();
// scroll_widget->addScrollWidget(page);
// }
// if((wireless_info_map.count() == 0) || (wireless_info_map.count() == 1 && wireless_info_map.contains("kylinkobe")))
// {
// page2 = NULL;
// }
// else {
// page2 = new ComputerPage(scroll_widget->zone, tr("WireLess NIC Info"));
// page2->setMap(wireless_info_map, wireless_info_map.value("WlanVendor").toString().toUpper());
// page2->initUI();
// scroll_widget->addScrollWidget(page2);
// }
// dataOK = true;
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NICWIDGET_H
#define NICWIDGET_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
class QVariant;
class SystemDispatcher;
class NicWidget : public QWidget
{
Q_OBJECT
public:
explicit NicWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~NicWidget();
void initData();
bool getStatus();
void clear_page_list();
signals:
public slots:
void slot_network_info(QMap<QString, QVariant> info);
private:
ScrollWidget *scroll_widget;
// ComputerPage *page;
// ComputerPage *page2;
QMap<QString, QVariant> wire_info_map;
// QMap<QString, QVariant> wireless_info_map;
QMap<QString, QVariant> tmp_info_map;
SystemDispatcher *systemproxy;
bool dataOK;
QList<ComputerPage *> page_list;
};
#endif // NICWIDGET_H

View File

@ -1,128 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sensorwidget.h"
#include "computerpage.h"
SensorWieget::SensorWieget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
page = NULL;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeValue()));
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
this->initData();
}
SensorWieget::~SensorWieget()
{
if (timer != NULL) {
disconnect(timer,SIGNAL(timeout()),this,SLOT(updateTimeValue()));
if(timer->isActive()) {
timer->stop();
}
delete timer;
timer = NULL;
}
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void SensorWieget::clear_page_list()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget)
scroll_widget->resetWidget();
}
void SensorWieget::updateTimeValue()
{
QMap<QString, QVariant> tmpMap = systemproxy->get_sensor_info_qt();
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
}
else {
sensor_info_map.clear();
QMap<QString,QVariant>::iterator it;
for (it = tmpMap.begin(); it != tmpMap.end(); ++it) {
if (it.value().toString().length() > 0) {
sensor_info_map.insert(it.key(), it.value());
}
}
if (!sensor_info_map.isEmpty() && sensor_info_map.count() > 0) {
page->resetSensor(sensor_info_map);
}
}
}
void SensorWieget::initData()
{
QMap<QString, QVariant> tmpMap = systemproxy->get_sensor_info_qt();
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
page = NULL;
}
else {
QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
sensor_info_map.insert(it.key(), it.value());
}
}
if (sensor_info_map.isEmpty() || sensor_info_map.count() <= 0) {
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Hardware sensor information"));
page->setMap(sensor_info_map, "");
page->setsensor(true);
page->initUI(false);
scroll_widget->addScrollWidget(page);
timer->start(1000*4);
}
}
/*QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
sensor_info_map.insert(it.key(), it.value());
}
}
if(sensor_info_map.count() == 0)
{
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Hardware sensor information"));
page->setMap(sensor_info_map, "");
page->setsensor(true);
page->initUI();
scroll_widget->addScrollWidget(page);
timer->start(1000*4);
}*/
}

View File

@ -1,132 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "systemwidget.h"
#include <QScrollBar>
#include <QPushButton>
#include <QMap>
SystemWidget::SystemWidget(QWidget *parent, SystemDispatcher *proxy) :
QWidget(parent),
systemproxy(proxy)
{
this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}");
setFixedSize(750, 403);
page = NULL;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeValue()));
scroll_widget = new ScrollWidget(this);
scroll_widget->setGeometry(0, 0, 750, 403);
this->initData();
}
SystemWidget::~SystemWidget()
{
if (timer != NULL) {
disconnect(timer,SIGNAL(timeout()),this,SLOT(updateTimeValue()));
if(timer->isActive()) {
timer->stop();
}
delete timer;
timer = NULL;
}
this->clear_page_list();
if (scroll_widget != NULL) {
delete scroll_widget;
scroll_widget = NULL;
}
}
void SystemWidget::clear_page_list()
{
if (page != NULL) {
delete page;
page = NULL;
}
if (scroll_widget)
scroll_widget->resetWidget();
}
void SystemWidget::updateTimeValue()
{
QString result;
int time_value = systemproxy->get_time_value_qt().toInt();
int hour_value = time_value/60;
int minutes_value =time_value%60;
if(hour_value < 1)
{
result = QString::number(minutes_value) + tr(" Minutes");//分钟
}
else
{
result = QString::number(hour_value) + tr(" Hours ") + QString::number(minutes_value) + tr(" Minutes");//小时 分钟
}
page->resetTimeValue(result);
}
bool SystemWidget::displaySwitch()
{
return true; //系统信息的首页,一直为真
}
void SystemWidget::initData()
{
this->clear_page_list();
QMap<QString, QVariant> tmpMap = systemproxy->get_computer_info_qt();
if (tmpMap.isEmpty() || tmpMap.count() <= 0) {
page = NULL;
}
else {
QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
sys_info_map.insert(it.key(), it.value());
}
}
if(sys_info_map.isEmpty() || sys_info_map.count() <= 0) {
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Computer Base Info"));
page->setMap(sys_info_map, sys_info_map.value("ComVendor").toString().toUpper());
page->initUI(false);
scroll_widget->addScrollWidget(page);
timer->start(1000*4);
}
}
/*QMap<QString,QVariant>::iterator it;
for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) {
if (it.value().toString().length() > 0) {
sys_info_map.insert(it.key(), it.value());
}
}
if(sys_info_map.count() == 1 && sys_info_map.contains("kylinkobe"))
{
page = NULL;
}
else {
page = new ComputerPage(scroll_widget->zone, tr("Computer Base Info"));
page->setMap(sys_info_map, sys_info_map.value("ComVendor").toString().toUpper());
page->initUI();
scroll_widget->addScrollWidget(page);
timer->start(1000*4);
}*/
}

View File

@ -1,55 +0,0 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SYSTEMWIDGET_H
#define SYSTEMWIDGET_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
#include <QTimer>
class QVariant;
class SystemDispatcher;
class SystemWidget : public QWidget
{
Q_OBJECT
public:
explicit SystemWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0);
~SystemWidget();
void initData();
void clear_page_list();
bool displaySwitch();
signals:
public slots:
void updateTimeValue();
private:
ScrollWidget *scroll_widget;
ComputerPage *page;
QMap<QString, QVariant> sys_info_map;
SystemDispatcher *systemproxy;
QTimer *timer;
};
#endif // SYSTEMWIDGET_H

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,8 @@
#include <QPushButton>
#include <QComboBox>
#include <QDebug>
#include <QApplication>
#include <QScreen>
//ShredDialog::ShredDialog(ShredManager *plugin, QDialog *parent)
// :QDialog(parent)
@ -96,6 +98,8 @@ ShredDialog::ShredDialog(QWidget *parent) :
this->setLanguage();
this->initConnect();
this->moveCenter();
}
ShredDialog::~ShredDialog()
@ -260,3 +264,21 @@ void ShredDialog::closeEvent(QCloseEvent *event)
event->accept();
// emit SignalClose();
}
void ShredDialog::moveCenter()
{
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
this->move(primaryGeometry.x() + (primaryGeometry.width() - this->width())/2,
primaryGeometry.y() + (primaryGeometry.height() - this->height())/2);
}

View File

@ -44,6 +44,8 @@ public:
QString getCurrrentSkinName();
void resetSkin();
void moveCenter();
protected:
void closeEvent(QCloseEvent *event);

View File

@ -62,10 +62,10 @@ QString ShredManager::getPicture()
void ShredManager::doAction()
{
int windowWidth = QApplication::desktop()->width();
int windowHeight = QApplication::desktop()->height();
// int windowWidth = QApplication::desktop()->width();
// int windowHeight = QApplication::desktop()->height();
shred_dialog->resetSkin();
shred_dialog->move((windowWidth - 500) / 2,(windowHeight - 471) / 2);
// shred_dialog->move((windowWidth - 500) / 2,(windowHeight - 471) / 2);
shred_dialog->show();
shred_dialog->raise();
}

View File

@ -4,31 +4,23 @@
#
#-------------------------------------------------
#QT += core
QT += core
isEqual(QT_MAJOR_VERSION, 5) {
QT += widgets gui
}
#greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = shredmanager
TEMPLATE = lib
CONFIG += plugin c++11
#INCLUDEPATH += ../shredmanager
#DESTDIR = ../libs
DESTDIR = $$_PRO_FILE_PWD_/../
#UI_DIR += $$PWD/../tmp/shredmanager/
#RCC_DIR += $$PWD/../tmp/shredmanager/
#MOC_DIR += $$PWD/../tmp/shredmanager/
#OBJECTS_DIR = $$PWD/../obj/shredmanager
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
}
#target.source += $$TARGET
#target.path = /var/lib/kylin-assistant-daemon/libs/
target.path = $${PREFIX}/lib/kylin-assistant/plugins/
INSTALLS += target

View File

@ -0,0 +1,215 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cpuballwidget.h"
#include <QApplication>
#include <QDebug>
#include <QPainter>
#include <QImageReader>
#include <QGraphicsDropShadowEffect>
CpuBallWidget::CpuBallWidget(QWidget *parent) : QWidget(parent)
{
this->setFixedSize(100, 100);
m_frontImagePath = ":/res/wave-front.png";
m_backimagePath = ":/res/wave-back.png";
m_xFrontOffset = 0;
m_xBackOffset = this->width();
m_percentValue = 0.0;
m_progressText = QString("%1%").arg(QString::number(m_percentValue, 'f', 1));
m_shadowEffect = new QGraphicsDropShadowEffect(this);
m_shadowEffect->setOffset(0, 3);
m_shadowEffect->setColor(QColor(232, 232, 232, 127));
m_shadowEffect->setBlurRadius(10);
this->setGraphicsEffect(m_shadowEffect);
this->loadWaveImage();
m_waveTimer = new QTimer(this);
connect(m_waveTimer, SIGNAL(timeout()), this, SLOT(onRepaintWaveImage()));
m_waveTimer->setInterval(60);
}
CpuBallWidget::~CpuBallWidget()
{
delete m_shadowEffect;
if (m_waveTimer) {
disconnect(m_waveTimer, SIGNAL(timeout()), this, SLOT(onRepaintWaveImage()));
if(m_waveTimer->isActive()) {
m_waveTimer->stop();
}
delete m_waveTimer;
m_waveTimer = nullptr;
}
}
void CpuBallWidget::loadWaveImage()
{
QImageReader frontReader(m_frontImagePath);
int w = frontReader.size().width();
int h = frontReader.size().height();
// QImage image(w, h, QImage::Format_ARGB32);
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
image.load(m_frontImagePath);
/*QPainter painter(&image);
// painter.setCompositionMode(QPainter::CompositionMode_Source);
// painter.fillRect(image.rect(), Qt::transparent);
// painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.drawImage(QPoint(0,0), image);
painter.end();*/
m_frontImage = image;
QImageReader backReader(m_backimagePath);
w = backReader.size().width();
h = backReader.size().height();
// QImage image(w, h, QImage::Format_ARGB32);
QImage backImage(w, h, QImage::Format_ARGB32_Premultiplied);
backImage.fill(Qt::transparent);
backImage.load(m_backimagePath);
/*QPainter backPainter(&backImage);
// backPainter.setCompositionMode(QPainter::CompositionMode_Source);
// backPainter.fillRect(image.rect(), Qt::transparent);
// backPainter.setCompositionMode(QPainter::CompositionMode_SourceOver);
backPainter.drawImage(QPoint(0,0), backImage);
backPainter.end();*/
m_backImage = backImage;
}
void CpuBallWidget::onRepaintWaveImage()
{
m_xFrontOffset -= 1;
m_xBackOffset += 2;
if (m_xFrontOffset < - (m_frontImage.width() - this->width())) {//保留整个显示直径的大小不做处理,避免出现断层
m_xFrontOffset = 0;
}
if (m_xBackOffset > m_backImage.width()) {//保留整个显示直径的大小不做处理,避免出现断层
m_xBackOffset = this->width();
}
this->update();//this->repaint();
}
//value:0 ~ 100
void CpuBallWidget::updateCpuPercent(double value)
{
if (this->m_percentValue == value || value > 100 || value < 0) {
return;
}
m_percentValue = value;
m_progressText = QString("%1%").arg(QString::number(value, 'f', 1));
}
void CpuBallWidget::startTimer()
{
if (this->m_waveTimer && !this->m_waveTimer->isActive())
this->m_waveTimer->start();
}
void CpuBallWidget::stopTimer()
{
if (this->m_waveTimer && this->m_waveTimer->isActive())
this->m_waveTimer->stop();
}
//在不同的平台上得到一样的效果,但绘制的文字除外
void CpuBallWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);//设置反走样,避免锯齿
QRectF rect = QRectF(0, 0, this->width(), this->height());
QSize waveSize = this->size();
int currentPercent = static_cast<int>(m_percentValue);
//Step1:整个矩形背景
QImage waveRectImage = QImage(waveSize, QImage::Format_ARGB32_Premultiplied);//创建一个Format_ARGB32_Premultiplied 格式的QIamge大小和控件相同
QPainter wavePainter(&waveRectImage);//创建一个QPainter绘制waveRectImage这个图像
wavePainter.setRenderHint(QPainter::Antialiasing, true);//setRenderHint() 来设置反走样,要么绘制出来的线条会出现锯齿
wavePainter.initFrom(this);//用控件的设置初始化画笔,刷子和字体
wavePainter.setCompositionMode(QPainter::CompositionMode_Source);//输出源像素,避免整个矩形背景区域出现花屏现象
if (currentPercent > 88) {
wavePainter.fillRect(waveRectImage.rect(), QColor(255, 0, 0, 127));//OrangeRed
m_shadowEffect->setColor(QColor(255, 0, 0, 127));//红色
} else if (currentPercent > 55) {
wavePainter.fillRect(waveRectImage.rect(), QColor(255, 165, 255, 127));//Orange
m_shadowEffect->setColor(QColor(255, 193, 37, 127));//黄
} else {
wavePainter.fillRect(waveRectImage.rect(), QColor(135, 206, 250, 127));//LightSkyBlue
m_shadowEffect->setColor(QColor(232, 232, 232, 127));//灰
}
//Step2:波浪区域
//CompositionMode_SourceOver保证波浪出现的时候其背景为通明的
wavePainter.setCompositionMode(QPainter::CompositionMode_SourceOver);//混和模式QImage::CompositionMode_SourceOver 即原象素正在绘制的象素和目标象素已经存在的象素混和原象素的alpha分量定义为最终的透明度
wavePainter.drawImage(static_cast<int>(m_xBackOffset) - m_backImage.width(), 100 - currentPercent, m_backImage);
wavePainter.drawImage(static_cast<int>(m_xFrontOffset), 100 - currentPercent, m_frontImage);
//Step3:矩形区域中圆球的外径和内径
QRectF outRect = QRectF(0, 0, waveSize.width(), waveSize.height());
QPainterPath outBorderPath;
//QMargins定义了矩形的四个外边距量left,top,right和bottom描述围绕矩形的边框宽度
outBorderPath.addEllipse(outRect.marginsRemoved(QMarginsF(0.5, 0.5, 0.5, 0.5)));//marginsAdded:增长矩形的边距,扩大它
wavePainter.strokePath(outBorderPath, QPen(QColor(178, 34, 34, 127), 2));//外边框
QPainterPath inBorderPath;
inBorderPath.addEllipse(outRect.marginsRemoved(QMarginsF(2, 2, 2, 2)));//marginsRemoved:删除矩形的边距,缩小它
wavePainter.strokePath(inBorderPath, QPen(QColor(0, 0, 255, 127), 2));//内边框
//Step4:占用率文字描述
QFont font = wavePainter.font();
font.setPixelSize(waveSize.height() * 20 / 100);
wavePainter.setFont(font);
wavePainter.setPen(Qt::white);
wavePainter.drawText(rect, Qt::AlignCenter, m_progressText);
wavePainter.end();
QImage image = QImage(waveSize, QImage::Format_ARGB32_Premultiplied);
QPainter m_painter(&image);
//让矩形框中除掉圆形球以外的其他区域透明
m_painter.setCompositionMode(QPainter::CompositionMode_Source);//输出源像素,避免区域出现花屏现象
m_painter.fillRect(image.rect(), Qt::transparent);
//为圆形球绘制一个圆形的白色遮罩层,目的是让矩形除了圆形区域外,其他区域为透明的没有任何东西显示在上面,方便后面的圆球和波浪的显示
QPixmap maskPixmap(waveSize);
maskPixmap.fill(Qt::transparent);
QPainterPath path;
path.addEllipse(QRectF(0, 0, waveSize.width(), waveSize.height()));
QPainter maskPainter(&maskPixmap);
maskPainter.setRenderHint(QPainter::Antialiasing, true);
maskPainter.setPen(QPen(Qt::white, 1));
maskPainter.fillPath(path, QBrush(Qt::white));
m_painter.setCompositionMode(QPainter::CompositionMode_SourceOver);//默认模式,源的alpha将目标顶部的像素混合
m_painter.drawImage(0, 0, maskPixmap.toImage());
m_painter.setCompositionMode(QPainter::CompositionMode_SourceIn);//输出是源其中alpha被目标的值减少 设置画刷的组合模式CompositionMode_SourceIn这个模式为目标图像在下
m_painter.drawImage(0, 0, waveRectImage);
m_painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);//目标的alpha用于将其混合到源像素的顶部。这种模式是QPainter::CompositionMode_Source逆
m_painter.end();
painter.drawImage(this->rect(), image);//drawPixmap
}

View File

@ -0,0 +1,64 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CPUBALLWIDGET_H
#define CPUBALLWIDGET_H
#include <QWidget>
#include <QTimer>
class QGraphicsDropShadowEffect;
class CpuBallWidget : public QWidget
{
Q_OBJECT
public:
CpuBallWidget(QWidget *parent = 0);
~CpuBallWidget();
void loadWaveImage();
void updateCpuPercent(double value);
void startTimer();
void stopTimer();
public slots:
void onRepaintWaveImage();
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
QTimer *m_waveTimer = nullptr;
QGraphicsDropShadowEffect *m_shadowEffect = nullptr;
QString m_frontImagePath;
QString m_backimagePath;
QImage m_frontImage;
QImage m_backImage;
QString m_progressText;
double m_percentValue;
double m_xFrontOffset;
double m_xBackOffset;
};
#endif // CPUBALLWIDGET_H

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cpuoccupancyrate.h"
#include "cpuballwidget.h"
#include <QApplication>
#include <QDebug>
#include <QVBoxLayout>
CpuOccupancyRate::CpuOccupancyRate(QWidget *parent) : QWidget(parent)
{
this->setFixedSize(302, 160);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
m_title = new QLabel(tr("CPU"));
m_title->setAlignment(Qt::AlignLeft | Qt::AlignTop);
m_title->setStyleSheet("font-size: 22px; color:#303030");
QFont font = m_title->font();
font.setPointSize(22);
font.setWeight(QFont::Light);
m_title->setFont(font);
m_cpuBall = new CpuBallWidget;
m_cpuBall->setFixedSize(100, 100);
mainLayout->addWidget(m_title, 0, Qt::AlignLeft);
mainLayout->addSpacing(2);
mainLayout->addWidget(m_cpuBall, 0, Qt::AlignCenter);
mainLayout->addStretch();
m_cpuBall->startTimer();
}
CpuOccupancyRate::~CpuOccupancyRate()
{
delete m_title;
delete m_cpuBall;
}
void CpuOccupancyRate::onUpdateCpuPercent(double value)
{
m_cpuBall->updateCpuPercent(value);
}
void CpuOccupancyRate::startTimer()
{
m_cpuBall->startTimer();
}
void CpuOccupancyRate::stopTimer()
{
m_cpuBall->stopTimer();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -17,31 +17,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DRIVERWIDGET_H
#define DRIVERWIDGET_H
#ifndef CPUOCCUPANCYRATE_H
#define CPUOCCUPANCYRATE_H
#include <QWidget>
#include "computerpage.h"
#include "../component/scrollwidget.h"
#include <QMap>
class QVariant;
#include <QLabel>
class DriverWidget : public QWidget
class CpuBallWidget;
class CpuOccupancyRate : public QWidget
{
Q_OBJECT
public:
explicit DriverWidget(QWidget *parent = 0/*, SystemDispatcher *proxy = 0*/);
~DriverWidget();
void initData();
signals:
public:
CpuOccupancyRate(QWidget *parent = 0);
~CpuOccupancyRate();
void startTimer();
void stopTimer();
public slots:
void onUpdateCpuPercent(double value);
private:
ScrollWidget *scroll_widget;
ComputerPage *page;
QMap<QString, QVariant> driver_info_map;
QLabel *m_title = nullptr;
CpuBallWidget *m_cpuBall = nullptr;
};
#endif // DRIVERWIDGET_H
#endif // CPUOCCUPANCYRATE_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diskinfo.h"
#include <QDebug>

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DISKINFO_H
#define DISKINFO_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diskitem.h"
#include "myimagebutton.h"

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DISKITEM_H
#define DISKITEM_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diskitemlist.h"
#include "diskitem.h"

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DISKITEMLIST_H
#define DISKITEMLIST_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diskmodel.h"
#include <QDebug>

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DISKMODEL_H
#define DISKMODEL_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QWidget>
class DiskItemList;

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filesystemworker.h"
#include "diskinfo.h"

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FILESYSTEMWORKER_H
#define FILESYSTEMWORKER_H

View File

@ -15,6 +15,7 @@
MyDialog::MyDialog(const QString &title, const QString &message, QWidget *parent) :
QDialog(parent)
, mousePressed(false)
{
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);

View File

@ -0,0 +1,354 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "networkflow.h"
#include "smoothcurvegenerator.h"
#include "util.h"
#include <QDebug>
#include <QPainter>
#include <QApplication>
#include <QButtonGroup>
#include <QSvgRenderer>
#include <QGraphicsScene>
#include <QGraphicsSvgItem>
inline QString formatNetworkBrandWidth(guint64 size, bool isTotal)
{
enum {
K_INDEX,
M_INDEX,
G_INDEX,
T_INDEX
};
QList<guint64> factorList;
factorList.append(G_GUINT64_CONSTANT(1) << 10);//KiB
factorList.append(G_GUINT64_CONSTANT(1) << 20);//MiB
factorList.append(G_GUINT64_CONSTANT(1) << 30);//GiB
factorList.append(G_GUINT64_CONSTANT(1) << 40);//TiB
if (size < factorList.at(K_INDEX)) {
if ((guint) size > 1) {
if (isTotal)
return QString("%1 %2").arg((guint) size).arg(QObject::tr("bits"));
else
return QString("%1 %2").arg((guint) size).arg(QObject::tr("bits/s"));
}
else {
if (isTotal)
return QString("%1 %2").arg((guint) size).arg(QObject::tr("bit"));
else
return QString("%1 %2").arg((guint) size).arg(QObject::tr("bit/s"));
}
} else {
guint64 factor;
QString format;
if (size < factorList.at(M_INDEX)) {
factor = factorList.at(K_INDEX);
if (isTotal)
format = QObject::tr("KiB");
else
format = QObject::tr("KiB/s");
}else if (size < factorList.at(G_INDEX)) {
factor = factorList.at(M_INDEX);
if (isTotal)
format = QObject::tr("MiB");
else
format = QObject::tr("MiB/s");
} else if (size < factorList.at(T_INDEX)) {
factor = factorList.at(G_INDEX);
if (isTotal)
format = QObject::tr("GiB");
else
format = QObject::tr("GiB/s");
} else {
factor = factorList.at(T_INDEX);
if (isTotal)
format = QObject::tr("TiB");
else
format = QObject::tr("TiB/s");
}
std::string formatted_result(make_string(g_strdup_printf("%.1f", size / (double)factor)));
return QString::fromStdString(formatted_result) + format;
}
}
inline QString formatNetwork(guint64 rate)
{
return formatNetworkBrandWidth(rate, true);
}
inline QString formatNetworkRate(guint64 rate)
{
return formatNetworkBrandWidth(rate, false);
}
NetworkFlow::NetworkFlow(QWidget *parent) : QWidget(parent)
{
setFixedSize(302, 200);
m_netMaxHeight = 60;
m_pointSpace = 10;
// math1_radio = new QRadioButton();
// math2_radio = new QRadioButton();
// math1_radio->setFocusPolicy(Qt::NoFocus);
// math1_radio->setObjectName("math1");
// math2_radio->setFocusPolicy(Qt::NoFocus);
// math2_radio->setObjectName("math2");
// math1_radio->setChecked(false);
// math2_radio->setChecked(true);
// math1_radio->move(10,10);
// math2_radio->move(100,10);
// connect(math1_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
// connect(math2_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
m_pointsCount = int((this->width() -2) / m_pointSpace);
m_downloadSpeedList = new QList<long>();
for (int i = 0; i < m_pointsCount; i++) {
m_downloadSpeedList->append(0);
}
m_uploadSpeedList = new QList<long>();
for (int i = 0; i < m_pointsCount; i++) {
m_uploadSpeedList->append(0);
}
m_gridY = new QList<int>();
/*connect(ui->generateCurveButton, SIGNAL(clicked(bool)), this, SLOT(generateCurves()));
connect(ui->showKnotsCheckBox, SIGNAL(clicked(bool)), this, SLOT(update()));
connect(ui->showSmoothCurveCheckBox, SIGNAL(clicked(bool)), this, SLOT(update()));
connect(ui->smoothCurveGeneratorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(update()));
ui->generateCurveButton->click();*/
}
NetworkFlow::~NetworkFlow()
{
delete m_downloadSpeedList;
delete m_uploadSpeedList;
delete m_gridY;
}
void NetworkFlow::setRadioButtonRowStatus()
{
QObject *obj = sender(); //返回发出信号的对象用QObject类型接收
QRadioButton* pbtn = qobject_cast<QRadioButton*>(obj);
QString obj_name = pbtn->objectName();
if(obj_name == "math1")
{
}
else if(obj_name == "math2")
{
}
}
//http://www.qtdebug.com/qtbook-paint-smooth-curve/
void NetworkFlow::onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateBytes, long sentRateBytes)
{
m_recvTotalBytes = recvTotalBytes;
m_sentTotalBytes = sentTotalBytes;
m_recvRateBytes = recvRateBytes;
m_sentRateBytes = sentRateBytes;
//download
QList<QPointF> downloadPoints;
m_downloadSpeedList->append(m_recvRateBytes);
if (m_downloadSpeedList->size() > m_pointsCount) {
m_downloadSpeedList->pop_front();
}
//计算出下载速度中最大的值
long downloadMaxHeight = 0;
for (int i = 0; i < m_downloadSpeedList->size(); i++) {
if (m_downloadSpeedList->at(i) > downloadMaxHeight) {
downloadMaxHeight = m_downloadSpeedList->at(i);
}
}
for (int i = 0; i < m_downloadSpeedList->size(); i++) {
if (downloadMaxHeight < m_netMaxHeight) {
downloadPoints.append(QPointF(i * m_pointSpace, m_downloadSpeedList->at(i)));
}
else {
downloadPoints.append(QPointF(i * m_pointSpace, m_downloadSpeedList->at(i) * m_netMaxHeight / downloadMaxHeight));
}
}
m_downloadPath = SmoothCurveGenerator::generateSmoothCurve(downloadPoints);
/*// 根据曲线上的点创建平滑曲线
smoothCurve1 = SmoothCurveGenerator1::generateSmoothCurve(downloadPoints);
smoothCurve2 = SmoothCurveGenerator2::generateSmoothCurve(downloadPoints);
// 连接点创建非平滑曲线曲线
nonSmoothCurve = QPainterPath();
nonSmoothCurve.moveTo(downloadPoints[0]);
for (int i = 1; i < downloadPoints.size(); ++i) {
nonSmoothCurve.lineTo(downloadPoints[i]);
}*/
//upload
QList<QPointF> uploadPoints;
m_uploadSpeedList->append(m_sentRateBytes);
if (m_uploadSpeedList->size() > m_pointsCount) {
m_uploadSpeedList->pop_front();
}
//计算出上传速度中最大的值
long uploadMaxHeight = 0;
for (int i = 0; i < m_uploadSpeedList->size(); i++) {
if (m_uploadSpeedList->at(i) > uploadMaxHeight) {
uploadMaxHeight = m_uploadSpeedList->at(i);
}
}
for (int i = 0; i < m_uploadSpeedList->size(); i++) {
if (uploadMaxHeight < m_netMaxHeight) {
uploadPoints.append(QPointF(i * m_pointSpace, m_uploadSpeedList->at(i)));
}
else {
uploadPoints.append(QPointF(i * m_pointSpace, m_uploadSpeedList->at(i) * m_netMaxHeight / uploadMaxHeight));
}
}
m_uploadPath = SmoothCurveGenerator::generateSmoothCurve(uploadPoints);
repaint();
}
void NetworkFlow::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);//反走样,绘制出来的线条会出现锯齿
QFont font = painter.font() ;
font.setPointSize(22);
font.setWeight(QFont::Light);
painter.setFont(font);
painter.setPen(QPen(QColor("#303030")));
painter.drawText(QRect(rect().x() + 2, rect().y(), rect().width() - 4, rect().height()), Qt::AlignLeft | Qt::AlignTop, tr("Network"));//绘制文本
setFontSize(painter, 9);
QFontMetrics fm = painter.fontMetrics();
QString downloadTitle = QString("%1 %2").arg(tr("正在接收")).arg(formatNetworkRate(m_recvRateBytes));
QString downloadContent = QString("%1 %2").arg(tr("总计已接收")).arg(formatNetwork(m_recvTotalBytes));//接收
QString uploadTitle = QString("%1 %2").arg(tr("正在发送")).arg(formatNetworkRate(m_sentRateBytes));
QString uploadContent = QString("%1 %2").arg(tr("总计已发送")).arg(formatNetwork(m_sentTotalBytes));//发送
int rateW = std::max(fm.width(downloadTitle), fm.width(uploadTitle));
//download
painter.setOpacity(1);
QSvgRenderer uploadRender(QString(":/res/download.svg"));
QImage uploadimage(20, 20, QImage::Format_ARGB32);
uploadimage.fill(QColor("#1E90FF"));
QPainter uploadPainter(&uploadimage);
uploadPainter.setRenderHint(QPainter::Antialiasing, true);
// uploadPainter.setCompositionMode(QPainter::CompositionMode_SourceOver);//默认模式,源的alpha将目标顶部的像素混合
uploadRender.render(&uploadPainter);
painter.drawImage(rect().x() + 2, rect().y() + 40, uploadimage);
// uploadPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);//输出是源其中alpha被目标的值减少 设置画刷的组合模式CompositionMode_SourceIn这个模式为目标图像在下
// uploadPainter.end();
setFontSize(painter, 9);
painter.setPen(QPen(QColor("#1E90FF")));
painter.drawText(QRect(rect().x() + 20 + 5, rect().y() + 40, fm.width(downloadTitle), rect().height()), Qt::AlignLeft | Qt::AlignTop, downloadTitle);
painter.drawText(QRect(rect().x() + 20 + rateW + 14, rect().y() + 40, fm.width(downloadContent), rect().height()), Qt::AlignLeft | Qt::AlignTop, downloadContent);
//upload
QSvgRenderer downloadRender(QString(":/res/upload.svg"));
QImage downloadimage(20, 20, QImage::Format_ARGB32);
downloadimage.fill(QColor("#FF0000"));
QPainter downloadPainter(&downloadimage);
downloadPainter.setRenderHint(QPainter::Antialiasing, true);
// downloadPainter.setCompositionMode(QPainter::CompositionMode_SourceOver);//默认模式,源的alpha将目标顶部的像素混合
downloadRender.render(&downloadPainter);
painter.drawImage(rect().x() + 2, rect().y() + 70, downloadimage);
// downloadPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);//输出是源其中alpha被目标的值减少 设置画刷的组合模式CompositionMode_SourceIn这个模式为目标图像在下
// downloadPainter.end();
setFontSize(painter, 9);
painter.setPen(QPen(QColor("#FF0000")));
painter.drawText(QRect(rect().x() + 20 + 5, rect().y() + 70, fm.width(uploadTitle), rect().height()), Qt::AlignLeft | Qt::AlignTop, uploadTitle);
painter.drawText(QRect(rect().x() + 20 + rateW + 14, rect().y() + 70, fm.width(uploadContent), rect().height()), Qt::AlignLeft | Qt::AlignTop, uploadContent);
//网格背景
painter.setBrush(QBrush(QColor("#AFEEEE")));
painter.setRenderHint(QPainter::Antialiasing, false);
QPen framePen;
painter.setOpacity(0.1);
framePen.setColor(QColor("#303030"));
framePen.setWidth(0.5);
painter.setPen(framePen);
int penSize = 1;
int gridX = rect().x() + penSize;
int gridY = rect().y() + 95;
int gridWidth = rect().width() - penSize * 2;
int gridHeight = 100;
QPainterPath framePath;
framePath.addRect(QRect(gridX, gridY, gridWidth, gridHeight));
painter.drawPath(framePath);
//网格
QPen gridPen;
QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space << 27 << space << 9 << space;
painter.setOpacity(0.05);
gridPen.setColor(QColor("#303030"));
gridPen.setWidth(0.5);
gridPen.setDashPattern(dashes);
painter.setPen(gridPen);
int gridLineX = gridX;
while (gridLineX < gridX + gridWidth - 100) {
gridLineX += 100;
painter.drawLine(gridLineX, gridY + 1, gridLineX, gridY + gridHeight - 1);
}
painter.setPen(gridPen);
m_gridY->clear();
int gridLineY = gridY;
while (gridLineY < gridY + gridHeight - 20) {
gridLineY += 20;
painter.drawLine(gridX + 1, gridLineY, gridX + gridWidth - 1, gridLineY);
m_gridY->append(gridLineY);
}
painter.setOpacity(1);
painter.setRenderHint(QPainter::Antialiasing, true);
//利用translate()函数进行平移变换
painter.translate((rect().width() - m_pointsCount * m_pointSpace - 2) / 2 + 6, 175);//将坐标第原点移动到该点
//利用scale()函数进行比例变换,实现缩放效果
painter.scale(1, -1);//将横坐标扩大1倍,将纵坐标缩小1倍
//使用QPainterPath画贝塞尔曲线
painter.setPen(QPen(QColor("#1E90FF"), 1));
painter.setBrush(QBrush());
painter.drawPath(m_downloadPath);//绘制前面创建的path:m_downloadPath
painter.translate(0, -8);//将点0-8设为原点
// painter.translate(0, 2);
// painter.scale(1, -1);
painter.setPen(QPen(QColor("#FF0000"), 1));
painter.setBrush(QBrush());
painter.drawPath(m_uploadPath);
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NETWORKFLOW_H
#define NETWORKFLOW_H
#include <QWidget>
#include <QRadioButton>
class NetworkFlow : public QWidget
{
Q_OBJECT
public:
NetworkFlow(QWidget *parent = 0);
~NetworkFlow();
public slots:
void onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateKbs, long sentRateKbs);
void setRadioButtonRowStatus();
protected:
void paintEvent(QPaintEvent *event);
private:
QList<long> *m_downloadSpeedList;
QList<long> *m_uploadSpeedList;
QPainterPath m_downloadPath;
QPainterPath m_uploadPath;
int m_netMaxHeight;
int m_pointsCount;
long m_recvTotalBytes;
long m_sentTotalBytes;
long m_recvRateBytes;
long m_sentRateBytes;
QList<int> *m_gridY;
int m_pointSpace;
// QRadioButton *math1_radio;
// QRadioButton *math2_radio;
};
#endif // NETWORKFLOW_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processcategory.h"
#include "myimagebutton.h"

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROCESSCATEGORY_H
#define PROCESSCATEGORY_H

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROCESSDATA_H
#define PROCESSDATA_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -38,6 +38,7 @@
#include <QProcess>
#include <QStyleFactory>
#include <QToolTip>
#include <QProcess>
#include <unistd.h>
#include <systemd/sd-login.h>
@ -92,8 +93,8 @@ ProcessDialog::ProcessDialog(QList<bool> columnShowOrHideFlags, int sortIndex, b
,frequency(0U)
,proSettings(settings)
{
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred);
setAcceptDrops(true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
// setAcceptDrops(true);
setAttribute(Qt::WA_NoMousePropagation);
this->setObjectName("ProcessDialog");
@ -294,6 +295,17 @@ void ProcessDialog::clearOriginProcList()
ProcessWorker::all.clear();
}
QString rootCommand(QString command, int value, pid_t pid)
{
return QString("gksu \"%1 %1 %1\"").arg(command, value, pid);
}
void startRenice(QString command, int value, pid_t pid)
{
QProcess::startDetached(rootCommand(command, value, pid));
}
void ProcessDialog::changeProcPriority(int nice)
{
if (nice == 32) {
@ -328,6 +340,10 @@ void ProcessDialog::changeProcPriority(int nice)
//need to be root
if(errno == EPERM || errno == EACCES) {
qDebug() << "Change priority need to be root!!!";
//kobe test
//startRenice("renice", nice, cur_pid);
bool success = false;
QString command = QString("renice %1 %1").arg(nice).arg(cur_pid);
QFile file("/usr/bin/pkexec");

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processworker.h"
#include "../../component/utils.h"
#include "mydialog.h"

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processlistitem.h"
#include <QCollator>
#include <QDebug>

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROCESSLISTITEM_H
#define PROCESSLISTITEM_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processlistwidget.h"
#include <QTimer>
#include <QApplication>
@ -659,8 +678,9 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
}
//背景
QPen framePen;
framePen.setColor(QColor("#F5F5F5"));
// QPen framePen;
// framePen.setColor(QColor("#F5F5F5"));
// painter.setPen(framePen);
painter.setOpacity(0.2);
painter.drawPath(framePath);

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROCESSLISTWIDGET_H
#define PROCESSLISTWIDGET_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -60,13 +60,13 @@ QString ProcessManager::getPicture()
void ProcessManager::doAction()
{
int windowWidth = QApplication::desktop()->width();
int windowHeight = QApplication::desktop()->height();
// int windowWidth = QApplication::desktop()->width();
// int windowHeight = QApplication::desktop()->height();
// process_dialog->resetSkin();
process_dialog->move((windowWidth - 850) / 2,(windowHeight - 476) / 2);
// process_dialog->move((windowWidth - 850) / 2,(windowHeight - 476) / 2);
process_dialog->show();
process_dialog->raise();
process_dialog->setFocus();
}
QWidget *ProcessManager::centralWidget()

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QString>
#include "../../component/plugininterface.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROCESSWORKER_H
#define PROCESSWORKER_H

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "propertiesdialog.h"
#include "processworker.h"
#include "myimagebutton.h"
@ -15,6 +34,7 @@
#include <QIcon>
PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(parent)
, mousePressed(false)
{
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);

View File

@ -1,3 +1,23 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROPERTIESSDIALOG_H
#define PROPERTIESSDIALOG_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/">
<file>res/wave-front.png</file>
<file>res/wave-back.png</file>
<file>../../src/res/kylin-assistant.png</file>
<file>res/upload.svg</file>
<file>res/download.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="download.svg"
sodipodi:docbase="/home/klattimer/workspace/sexyhacks/GSMColorPicker"
inkscape:version="0.45.1"
sodipodi:version="0.32"
id="svg11300"
height="32"
width="32"
inkscape:export-filename="/home/jimmac/Desktop/wi-fi.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0">
<defs
id="defs3">
<linearGradient
id="linearGradient1442">
<stop
id="stop1444"
offset="0"
style="stop-color:#73d216" />
<stop
id="stop1446"
offset="1.0000000"
style="stop-color:#4e9a06" />
</linearGradient>
<linearGradient
id="linearGradient8662"
inkscape:collect="always">
<stop
id="stop8664"
offset="0"
style="stop-color:#000000;stop-opacity:1;" />
<stop
id="stop8666"
offset="1"
style="stop-color:#000000;stop-opacity:0;" />
</linearGradient>
<linearGradient
id="linearGradient8650"
inkscape:collect="always">
<stop
id="stop8652"
offset="0"
style="stop-color:#ffffff;stop-opacity:1;" />
<stop
id="stop8654"
offset="1"
style="stop-color:#ffffff;stop-opacity:0;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient8662"
id="radialGradient1444"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.9574038,0,0,0.2519481,-7.8008277,17.882096)"
cx="24.837126"
cy="36.421127"
fx="24.837126"
fy="36.421127"
r="15.644737" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1442"
id="radialGradient1469"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.843022,1.020168,0,0.606436,42.58614)"
cx="35.292667"
cy="20.494493"
fx="35.292667"
fy="20.494493"
r="16.9562" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient8650"
id="radialGradient1471"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-2.046729,-1.55761,0,44.11559,66.93275)"
cx="15.987216"
cy="1.5350308"
fx="15.987216"
fy="1.5350308"
r="17.171415" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient8650"
id="radialGradient2650"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,1.6135044,1.2279157,0,-0.3348922,-20.930097)"
cx="15.987216"
cy="1.5350308"
fx="15.987216"
fy="1.5350308"
r="17.171415" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1442"
id="radialGradient2653"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,0.6645822,-0.8042323,0,33.964818,-1.736856)"
cx="35.292667"
cy="20.494493"
fx="35.292667"
fy="20.494493"
r="16.9562" />
</defs>
<sodipodi:namedview
inkscape:window-y="26"
inkscape:window-x="0"
inkscape:window-height="1039"
inkscape:window-width="1475"
inkscape:showpageshadow="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
showgrid="true"
inkscape:current-layer="layer1"
inkscape:cy="21.82691"
inkscape:cx="17.692268"
inkscape:zoom="31.237859"
inkscape:pageshadow="2"
inkscape:pageopacity="0.4"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffb3"
id="base"
fill="#4e9a06"
stroke="#4e9a06"
width="32px"
height="32px"
borderlayer="true"
showguides="true"
inkscape:guide-bbox="true">
<sodipodi:guide
orientation="vertical"
position="16.003801"
id="guide2646" />
</sodipodi:namedview>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>Jakub Steiner</dc:title>
</cc:Agent>
</dc:creator>
<dc:source>http://jimmac.musichall.cz</dc:source>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
<dc:title>Go Down</dc:title>
<dc:subject>
<rdf:Bag>
<rdf:li>go</rdf:li>
<rdf:li>lower</rdf:li>
<rdf:li>down</rdf:li>
<rdf:li>arrow</rdf:li>
<rdf:li>pointer</rdf:li>
<rdf:li>&gt;</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:contributor>
<cc:Agent>
<dc:title>Andreas Nilsson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
<cc:permits
rdf:resource="http://web.resource.org/cc/Reproduction" />
<cc:permits
rdf:resource="http://web.resource.org/cc/Distribution" />
<cc:requires
rdf:resource="http://web.resource.org/cc/Notice" />
<cc:requires
rdf:resource="http://web.resource.org/cc/Attribution" />
<cc:permits
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
<cc:requires
rdf:resource="http://web.resource.org/cc/ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
inkscape:label="Layer 1"
id="layer1">
<path
style="opacity:0.20454544;color:#000000;fill:url(#radialGradient1444);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 11.59375 23.3125 C 5.4817822 23.80926 1 25.291665 1 27.0625 C 1 29.238298 7.7007116 31 15.96875 31 C 24.236789 31 30.968751 29.238298 30.96875 27.0625 C 30.96875 25.291666 26.486968 23.80926 20.375 23.3125 L 16.375 28.125 C 16.280109 28.243732 16.120742 28.312501 15.96875 28.3125 C 15.816758 28.3125 15.688641 28.243732 15.59375 28.125 L 11.59375 23.3125 z "
id="path8660" />
<path
sodipodi:nodetypes="cccccc"
id="path8645"
d="M 3.6079996,12.041487 L 8.9939796,12.032249 L 8.991866,2.0611985 L 21.319018,1.8873245 C 20.712063,16.346136 12.979179,10.508257 9.3063266,18.907006 L 3.6079996,12.041487 z "
style="opacity:0.5080214;color:#000000;fill:url(#radialGradient2650);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
<path
style="opacity:0.48128339;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.00000036;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 22.569585,2.479522 L 9.5024221,2.499079 L 9.4797859,12.515491 L 4.6265001,12.527809 L 16.008001,26.240989 L 27.397918,12.501738 L 22.52643,12.497601 L 22.569585,2.479522 z "
id="path8658"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="upload.svg"
sodipodi:docbase="/home/klattimer/workspace/sexyhacks/GSMColorPicker"
inkscape:version="0.45.1"
sodipodi:version="0.32"
id="svg11300"
height="32"
width="32"
inkscape:export-filename="/home/jimmac/Desktop/wi-fi.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0">
<defs
id="defs3">
<linearGradient
id="linearGradient2304">
<stop
id="stop2306"
offset="0"
style="stop-color:#73d216" />
<stop
id="stop2308"
offset="1.0000000"
style="stop-color:#4e9a06" />
</linearGradient>
<linearGradient
id="linearGradient1442">
<stop
id="stop1444"
offset="0"
style="stop-color:#73d216" />
<stop
id="stop1446"
offset="1.0000000"
style="stop-color:#4e9a06" />
</linearGradient>
<linearGradient
id="linearGradient8662"
inkscape:collect="always">
<stop
id="stop8664"
offset="0"
style="stop-color:#000000;stop-opacity:1;" />
<stop
id="stop8666"
offset="1"
style="stop-color:#000000;stop-opacity:0;" />
</linearGradient>
<linearGradient
id="linearGradient8650"
inkscape:collect="always">
<stop
id="stop8652"
offset="0"
style="stop-color:#ffffff;stop-opacity:1;" />
<stop
id="stop8654"
offset="1"
style="stop-color:#ffffff;stop-opacity:0;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient8662"
id="radialGradient1444"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.9574038,0,0,0.2519481,-7.8008277,17.882096)"
cx="24.837126"
cy="36.421127"
fx="24.837126"
fy="36.421127"
r="15.644737" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient8650"
id="radialGradient2916"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-1.639511,1.2477073,0,-0.7887167,50.520377)"
cx="24.53788"
cy="0.40010813"
fx="24.53788"
fy="0.40010813"
r="17.171415" />
</defs>
<sodipodi:namedview
inkscape:window-y="26"
inkscape:window-x="37"
inkscape:window-height="1039"
inkscape:window-width="1475"
inkscape:showpageshadow="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
showgrid="true"
inkscape:current-layer="layer1"
inkscape:cy="14.82149"
inkscape:cx="13.476992"
inkscape:zoom="44.177004"
inkscape:pageshadow="2"
inkscape:pageopacity="0.4"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffb3"
id="base"
fill="#4e9a06"
stroke="#4e9a06"
width="32px"
height="32px"
borderlayer="true"
showguides="true"
inkscape:guide-bbox="true">
<sodipodi:guide
orientation="vertical"
position="16.003801"
id="guide2646" />
</sodipodi:namedview>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>Jakub Steiner</dc:title>
</cc:Agent>
</dc:creator>
<dc:source>http://jimmac.musichall.cz</dc:source>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
<dc:title>Go Down</dc:title>
<dc:subject>
<rdf:Bag>
<rdf:li>go</rdf:li>
<rdf:li>lower</rdf:li>
<rdf:li>down</rdf:li>
<rdf:li>arrow</rdf:li>
<rdf:li>pointer</rdf:li>
<rdf:li>&gt;</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:contributor>
<cc:Agent>
<dc:title>Andreas Nilsson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
<cc:permits
rdf:resource="http://web.resource.org/cc/Reproduction" />
<cc:permits
rdf:resource="http://web.resource.org/cc/Distribution" />
<cc:requires
rdf:resource="http://web.resource.org/cc/Notice" />
<cc:requires
rdf:resource="http://web.resource.org/cc/Attribution" />
<cc:permits
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
<cc:requires
rdf:resource="http://web.resource.org/cc/ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
inkscape:label="Layer 1"
id="layer1">
<path
style="opacity:0.20454544;color:#000000;fill:url(#radialGradient1444);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 8 23.71875 C 3.8007462 24.417285 1 25.659396 1 27.0625 C 1 29.238298 7.7007116 31 15.96875 31 C 24.236789 31 30.968751 29.238298 30.96875 27.0625 C 30.96875 25.669209 28.181501 24.45105 24.03125 23.75 L 24.0625 27.5625 C 24.062472 27.838631 23.838631 28.062472 23.5625 28.0625 L 8.5 28.03125 C 8.2238691 28.031222 8.0000277 27.807381 8 27.53125 L 8 23.71875 z "
id="path8660" />
<path
style="opacity:0.48128339;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.00000036;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 22.569585,26.572772 L 9.5024221,26.553215 L 9.4797859,16.536803 L 4.6265001,16.524485 L 16.008001,2.8113028 L 27.397918,16.550556 L 22.52643,16.554693 L 22.569585,26.572772 z "
id="path8658"
sodipodi:nodetypes="cccccccc" />
<path
sodipodi:nodetypes="cccscc"
id="path2878"
d="M 3.5238289,17.001913 L 9.007046,16.956641 L 9.0603961,22.21291 C 13.590765,13.401105 21.871498,15.128187 22.353124,9.6945344 C 22.353124,9.6945344 15.984277,2.1846647 15.984277,2.1846647 L 3.5238289,17.001913 z "
style="opacity:0.5080214;color:#000000;fill:url(#radialGradient2916);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -18,6 +18,109 @@
*/
#include "resourcesdialog.h"
#include "cpuoccupancyrate.h"
#include "networkflow.h"
#include <glibtop/netload.h>
#include <glibtop/netlist.h>
#include <QDebug>
#include <QTimer>
typedef struct _net
{
guint64 last_in, last_out;
GTimeVal time;
} net;
net netinfo;
inline void getNetworkBytesData(unsigned long long int &receiveBytes, unsigned long long int &sendBytes, unsigned long long int &receiveRateBytes, unsigned long long int &sendRateBytes)
{
glibtop_netlist netlist;
char **ifnames;
guint32 i;
guint64 in = 0, out = 0;
GTimeVal time;
guint64 din, dout;
ifnames = glibtop_get_netlist(&netlist);
for (i = 0; i < netlist.number; ++i) {
glibtop_netload netload;
glibtop_get_netload(&netload, ifnames[i]);
if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
continue;
/* Skip interfaces without any IPv4/IPv6 address (or
those with only a LINK ipv6 addr) However we need to
be able to exclude these while still keeping the
value so when they get online (with NetworkManager
for example) we don't get a suddent peak. Once we're
able to get this, ignoring down interfaces will be
possible too. */
if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
continue;
/* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
to avoid spikes when they are brought up */
in += netload.bytes_in;
out += netload.bytes_out;
}
g_strfreev(ifnames);
g_get_current_time(&time);
if (in >= netinfo.last_in && out >= netinfo.last_out && netinfo.time.tv_sec != 0) {
float dtime;
dtime = time.tv_sec - netinfo.time.tv_sec +
(double) (time.tv_usec - netinfo.time.tv_usec) / G_USEC_PER_SEC;
din = static_cast<guint64>((in - netinfo.last_in) / dtime);
dout = static_cast<guint64>((out - netinfo.last_out) / dtime);
} else {
/* Don't calc anything if new data is less than old (interface
removed, counters reset, ...) or if it is the first time */
din = 0;
dout = 0;
}
netinfo.last_in = in;
netinfo.last_out = out;
netinfo.time = time;
receiveBytes = in;
sendBytes = out;
receiveRateBytes = din;
sendRateBytes = dout;
}
unsigned long long getCpuTimeData(unsigned long long &workTime)
{
FILE *file = fopen("/proc/stat", "r");
if (file == NULL) {
return 0;
}
char buffer[1024] = {0};
unsigned long long user = 0, nice = 0, system = 0, idle = 0;
unsigned long long iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guestnice = 0;
char* ret = fgets(buffer, sizeof(buffer) - 1, file);
if (ret == NULL) {
fclose(file);
return 0;
}
fclose(file);
sscanf(buffer,
"cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
&user, &nice, &system, &idle, &iowait, &irq, &softirq, &steal, &guest, &guestnice);
workTime = user + nice + system;
return user + nice + system + idle + iowait + irq + softirq + steal;
}
ResouresDialog::ResouresDialog(QWidget *parent)
:QWidget(parent)
@ -27,9 +130,69 @@ ResouresDialog::ResouresDialog(QWidget *parent)
setAttribute(Qt::WA_NoMousePropagation);
this->setObjectName("ResouresDialog");
//cpu
m_cpuTotalTime = 0;
m_cpuworkTime = 0;
m_prevCpuTotalTime = 0;
m_prevCpuWorkTime = 0;
m_vlayout = new QVBoxLayout(this);
m_cpuWidget = new CpuOccupancyRate();
m_networkWidget = new NetworkFlow();
m_vlayout->addSpacing(100);
m_vlayout->addWidget(m_cpuWidget, 0, Qt::AlignHCenter);
m_vlayout->addWidget(m_networkWidget, 0, Qt::AlignHCenter);
connect(this, SIGNAL(updateNetworkStatus(long,long,long,long)), m_networkWidget, SLOT(onUpdateNetworkStatus(long,long,long,long)), Qt::QueuedConnection);
connect(this, SIGNAL(updateCpuStatus(double)), m_cpuWidget, SLOT(onUpdateCpuPercent(double)), Qt::QueuedConnection);
updateStatusTimer = new QTimer(this);
connect(updateStatusTimer, SIGNAL(timeout()), this, SLOT(updateResourceStatus()));
updateStatusTimer->start(2000);
}
ResouresDialog::~ResouresDialog()
{
if (m_vlayout) {
foreach (QObject *child, m_vlayout->children()) {
QWidget *widget = static_cast<QWidget *>(child);
widget->deleteLater();
}
}
/*QLayoutItem *child;
while ((child = m_vlayout->takeAt(0)) != 0) {
if (child->widget())
child->widget()->deleteLater();
delete child;
}*/
}
void ResouresDialog::startCpuTimer()
{
m_cpuWidget->startTimer();
}
void ResouresDialog::stopCpuTimer()
{
m_cpuWidget->stopTimer();
}
void ResouresDialog::updateResourceStatus()
{
//cpu
m_prevCpuWorkTime = m_cpuworkTime;
m_prevCpuTotalTime = m_cpuTotalTime;
m_cpuTotalTime = getCpuTimeData(m_cpuworkTime);
if (m_prevCpuWorkTime != 0 && m_prevCpuTotalTime != 0) {
emit updateCpuStatus((m_cpuworkTime - m_prevCpuWorkTime) * 100.0 / (m_cpuTotalTime - m_prevCpuTotalTime));
}
else {
emit updateCpuStatus(0);
}
//network
getNetworkBytesData(totalRecvBytes, totalSentBytes, rateRecvBytes, rateSentBytes);
emit this->updateNetworkStatus(totalRecvBytes, totalSentBytes, rateRecvBytes, rateSentBytes);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -17,7 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QWidget>
#include <QVBoxLayout>
class CpuOccupancyRate;
class NetworkFlow;
class ResouresDialog : public QWidget
{
@ -26,4 +31,32 @@ class ResouresDialog : public QWidget
public:
explicit ResouresDialog(QWidget* parent = 0);
~ResouresDialog();
void startCpuTimer();
void stopCpuTimer();
public slots:
void updateResourceStatus();
signals:
void updateCpuStatus(double percent);
void updateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateBytes, long sentRateBytes);
private:
//cpu
unsigned long long m_prevCpuTotalTime;
unsigned long long m_prevCpuWorkTime;
unsigned long long m_cpuTotalTime;
unsigned long long m_cpuworkTime;
//network
unsigned long long int totalRecvBytes;
unsigned long long int totalSentBytes;
unsigned long long int rateRecvBytes;
unsigned long long int rateSentBytes;
QTimer *updateStatusTimer = nullptr;
QVBoxLayout *m_vlayout = nullptr;
CpuOccupancyRate *m_cpuWidget = nullptr;
NetworkFlow *m_networkWidget = nullptr;
};

Some files were not shown because too many files have changed in this diff Show More