From a81cbe3d9ce5d74d4976cc230e93febbd8e7b974 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Wed, 9 Jul 2014 08:55:33 +0400 Subject: [PATCH] add interaction with craphical interface --- sources/desktop-panel/desktop-panel.cpp | 98 +++++++++++++++++++++++-- sources/desktop-panel/widget.ui | 6 +- 2 files changed, 95 insertions(+), 9 deletions(-) diff --git a/sources/desktop-panel/desktop-panel.cpp b/sources/desktop-panel/desktop-panel.cpp index 836cac9..acf95d3 100644 --- a/sources/desktop-panel/desktop-panel.cpp +++ b/sources/desktop-panel/desktop-panel.cpp @@ -112,6 +112,19 @@ void DesktopPanel::reinit() { if (debug) qDebug() << "[PTM-DP]" << "[reinit]"; + // clear + // labels + for (int i=0; iremoveItem(labels[i]); + delete labels[i]; + } + labels.clear(); + // layout + layout = new QGraphicsLinearLayout(); + layout->setContentsMargins(1, 1, 1, 1); + setLayout(layout); + + // add // layout if (configuration[QString("background")].toInt() == 0) setBackgroundHints(NoBackground); @@ -121,15 +134,17 @@ void DesktopPanel::reinit() layout->setOrientation(Qt::Horizontal); else layout->setOrientation(Qt::Horizontal); - + // left stretch + if (configuration[QString("leftStretch")].toInt() == 2) + layout->addStretch(1); // labels - for (int i=0; iaddItem(labels[i]); } + // right stretch + if (configuration[QString("rightStretch")].toInt() == 2) + layout->addStretch(1); updateText(); } @@ -204,7 +219,56 @@ void DesktopPanel::createConfigurationInterface(KConfigDialog *parent) QWidget *configWidget = new QWidget; uiWidConfig.setupUi(configWidget); - + if (configuration[QString("background")].toInt() == 0) + uiWidConfig.checkBox_background->setCheckState(Qt::Unchecked); + else + uiWidConfig.checkBox_background->setCheckState(Qt::Checked); + if (configuration[QString("layout")].toInt() == 0) + uiWidConfig.checkBox_layout->setCheckState(Qt::Unchecked); + else + uiWidConfig.checkBox_layout->setCheckState(Qt::Checked); + if (configuration[QString("leftStretch")].toInt() == 0) + uiWidConfig.checkBox_leftStretch->setCheckState(Qt::Unchecked); + else + uiWidConfig.checkBox_leftStretch->setCheckState(Qt::Checked); + if (configuration[QString("rightStretch")].toInt() == 0) + uiWidConfig.checkBox_rightStretch->setCheckState(Qt::Unchecked); + else + uiWidConfig.checkBox_rightStretch->setCheckState(Qt::Checked); + uiWidConfig.spinBox_interval->setValue(configuration[QString("interval")].toInt()); + uiWidConfig.lineEdit_mark->setText(configuration[QString("mark")]); + uiWidConfig.lineEdit_pattern->setText(configuration[QString("pattern")]); + + KConfigGroup cg = config(); + QString fontFamily = cg.readEntry("currentFontFamily", "Terminus"); + int fontSize = cg.readEntry("currentFontSize", 10); + QString fontColor = cg.readEntry("currentFontColor", "#ff0000"); + int fontWeight = cg.readEntry("currentFontWeight", 400); + QString fontStyle = cg.readEntry("currentFontStyle", "normal"); + QFont font = QFont(fontFamily, 12, 400, FALSE); + uiAppConfig.fontComboBox_fontActive->setCurrentFont(font); + uiAppConfig.spinBox_fontSizeActive->setValue(fontSize); + uiAppConfig.kcolorcombo_fontColorActive->setColor(fontColor); + uiAppConfig.spinBox_fontWeightActive->setValue(fontWeight); + if (fontStyle == "normal") + uiAppConfig.comboBox_fontStyleActive->setCurrentIndex(0); + else if (fontStyle == "italic") + uiAppConfig.comboBox_fontStyleActive->setCurrentIndex(1); + + fontFamily = cg.readEntry("fontFamily", "Terminus"); + fontSize = cg.readEntry("fontSize", 10); + fontColor = cg.readEntry("fontColor", "#000000"); + fontWeight = cg.readEntry("fontWeight", 400); + fontStyle = cg.readEntry("fontStyle", "normal"); + font = QFont(fontFamily, 12, 400, FALSE); + uiAppConfig.fontComboBox_fontInactive->setCurrentFont(font); + uiAppConfig.spinBox_fontSizeInactive->setValue(fontSize); + uiAppConfig.kcolorcombo_fontColorInactive->setColor(fontColor); + uiAppConfig.spinBox_fontWeightInactive->setValue(fontWeight); + if (fontStyle == "normal") + uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(0); + else if (fontStyle == "italic") + uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(1); parent->addPage(configWidget, i18n("Widget"), Applet::icon()); parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme")); @@ -220,7 +284,25 @@ void DesktopPanel::configAccepted() extsysmonEngine->disconnectSource(QString("desktop"), this); KConfigGroup cg = config(); -// cg.writeEntry("autoUpdateInterval", uiConfig.spinBox_autoUpdate->value()); + cg.writeEntry("background", QString::number(uiWidConfig.checkBox_background->checkState())); + cg.writeEntry("layout", QString::number(uiWidConfig.checkBox_layout->checkState())); + cg.writeEntry("leftStretch", QString::number(uiWidConfig.checkBox_leftStretch->checkState())); + cg.writeEntry("rightStretch", QString::number(uiWidConfig.checkBox_rightStretch->checkState())); + cg.writeEntry("interval", QString::number(uiWidConfig.spinBox_interval->value())); + cg.writeEntry("mark", uiWidConfig.lineEdit_mark->text()); + cg.writeEntry("pattern", uiWidConfig.lineEdit_pattern->text()); + + cg.writeEntry("currentFontFamily", uiAppConfig.fontComboBox_fontActive->currentFont().family()); + cg.writeEntry("currentFontSize", uiAppConfig.spinBox_fontSizeActive->value()); + cg.writeEntry("currentFontColor", uiAppConfig.kcolorcombo_fontColorActive->color().name()); + cg.writeEntry("currentFontWeight", uiAppConfig.spinBox_fontWeightActive->value()); + cg.writeEntry("currentFontStyle", uiAppConfig.comboBox_fontStyleActive->currentText()); + + cg.writeEntry("fontFamily", uiAppConfig.fontComboBox_fontInactive->currentFont().family()); + cg.writeEntry("fontSize", uiAppConfig.spinBox_fontSizeInactive->value()); + cg.writeEntry("fontColor", uiAppConfig.kcolorcombo_fontColorInactive->color().name()); + cg.writeEntry("fontWeight", uiAppConfig.spinBox_fontWeightInactive->value()); + cg.writeEntry("fontStyle", uiAppConfig.comboBox_fontStyleInactive->currentText()); } @@ -232,10 +314,10 @@ void DesktopPanel::configChanged() configuration[QString("background")] = cg.readEntry("background", "0"); configuration[QString("interval")] = cg.readEntry("interval", "1000"); configuration[QString("layout")] = cg.readEntry("layout", "0"); - configuration[QString("leftStretch")] = cg.readEntry("left_stretch", "2"); + configuration[QString("leftStretch")] = cg.readEntry("leftStretch", "2"); configuration[QString("mark")] = cg.readEntry("mark", "*"); configuration[QString("pattern")] = cg.readEntry("pattern", "[$mark$number/$total: $name]"); - configuration[QString("rightStretch")] = cg.readEntry("right_stretch", "2"); + configuration[QString("rightStretch")] = cg.readEntry("rightStretch", "2"); desktopNames = getDesktopNames(); diff --git a/sources/desktop-panel/widget.ui b/sources/desktop-panel/widget.ui index 8dfe17a..677c208 100644 --- a/sources/desktop-panel/widget.ui +++ b/sources/desktop-panel/widget.ui @@ -134,7 +134,11 @@ - + + + A mark which will be shown if this desktop is active + +