代码拉取完成,页面将自动刷新
同步操作将从 juju/dde-sys-monitor-plugin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "pluginsettingdialog.h"
#include "ui_pluginsettingdialog.h"
pluginSettingDialog::pluginSettingDialog(Settings *settings,QWidget *parent) :
QDialog(parent),
ui(new Ui::pluginSettingDialog)
{
ui->setupUi(this);
if(settings->value("chartModeCheckBox").toInt()){
ui->tabWidget->setCurrentIndex(1);
}
else {
ui->tabWidget->setCurrentIndex(0);
}
pal=QPalette();//首先初始化画板
QMapIterator<QString,QVariant> i(*settings);
while(i.hasNext())
{
i.next();
//找到以key为名字的widget
QWidget *obj=findChild<QWidget*>(i.key());
if(obj==0){qDebug()<<"不能找到对象名为:"<<i.key();continue;}
if(obj->metaObject()->className()==QStringLiteral("QComboBox"))
{
QComboBox *cb=(QComboBox*)obj;
cb->setCurrentIndex(i.value().toInt());
}
else if(obj->metaObject()->className()==QStringLiteral("QCheckBox"))
{
QCheckBox *cb=(QCheckBox*)obj;
cb->setChecked(i.value().toInt());
}
else if(obj->metaObject()->className()==QStringLiteral("QSpinBox"))
{
QSpinBox *sb=(QSpinBox*)obj;
sb->setValue(i.value().toInt());
}
else if(obj->metaObject()->className()==QStringLiteral("QWidget"))
{
QWidget *wg=(QWidget*)obj;
pal.setColor(QPalette::Background,i.value().value<QColor>());
wg->setAutoFillBackground(true);
wg->setPalette(pal);
//qDebug()<<"颜色是:"<<i.value().value<QColor>();
}
else if(obj->metaObject()->className()==QStringLiteral("QLineEdit"))
{
QLineEdit *le=(QLineEdit*)obj;
le->setText(i.value().value<QString>());
}
}
foreach(QPushButton* btn,findChildren<QPushButton*>(QRegExp("\\w*ColorPushButton")))
{
connect(btn,SIGNAL(clicked(bool)),this,SLOT(selectColor(void)));
}
}
pluginSettingDialog::~pluginSettingDialog()
{
delete ui;
}
void pluginSettingDialog::getDisplayContentSetting(Settings *settings)
{
QMapIterator<QString,QVariant> i(*settings);
while(i.hasNext())
{
i.next();
//找到以key为名字的widget
QWidget *obj=findChild<QWidget*>(i.key());
if(obj==0){qDebug()<<"不能找到对象名为:"<<i.key();continue;}
if(obj->metaObject()->className()==QStringLiteral("QComboBox"))
{
QComboBox *cb=(QComboBox*)obj;
settings->insert(cb->objectName(),cb->currentIndex());
}
else if(obj->metaObject()->className()==QStringLiteral("QCheckBox"))
{
QCheckBox *cb=(QCheckBox*)obj;
settings->insert(cb->objectName(),cb->isChecked());
}
else if(obj->metaObject()->className()==QStringLiteral("QSpinBox"))
{
QSpinBox *sb=(QSpinBox*)obj;
settings->insert(sb->objectName(),sb->value());
}
else if(obj->metaObject()->className()==QStringLiteral("QWidget"))
{
QWidget *wg=(QWidget*)obj;
settings->insert(wg->objectName(),wg->palette().background().color());
}
else if(obj->metaObject()->className()==QStringLiteral("QLineEdit"))
{
QLineEdit *le=(QLineEdit*)obj;
settings->insert(le->objectName(),le->text());
}
}
}
void pluginSettingDialog::selectColor()
{
QWidget *colorWidget;
//"netUpColorPushButton"-->"netUpWidget"
colorWidget=findChild<QWidget*>(sender()->objectName().replace("ColorPushButton","Widget"));
QColor color = QColorDialog::getColor(colorWidget->palette().background().color(),
this,tr("颜色对话框"),QColorDialog::ShowAlphaChannel);
if(color!=QColor::Invalid)
{
pal.setColor(QPalette::Background,color);
colorWidget->setAutoFillBackground(true);
colorWidget->setPalette(pal);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。