fix text edit dp configuration interface

This commit is contained in:
arcan1s 2014-09-14 00:01:23 +04:00
parent 43daae5529
commit 4907496a2e
6 changed files with 26 additions and 55 deletions

View File

@ -4,6 +4,7 @@ Ver.2.0.2:
- remove ps stats from notification - remove ps stats from notification
* yet another fix cpu* and cpucl* * yet another fix cpu* and cpucl*
* rewrite DP configuration interface * rewrite DP configuration interface
* fix non-standard temp units
Ver.2.0.1: Ver.2.0.1:
+ add support of custom interfaces + add support of custom interfaces

View File

@ -4,6 +4,7 @@
- удалено ps stats из уведомлений - удалено ps stats из уведомлений
* еще один фикс тегов cpu* и cpucl * еще один фикс тегов cpu* и cpucl
* переписан конфигурационный интерфейс DP * переписан конфигурационный интерфейс DP
* исправлены нестандартные единицы температуры
Вер.2.0.1: Вер.2.0.1:
+ добавлена поддержка кастомных интерфейсов + добавлена поддержка кастомных интерфейсов

View File

@ -768,9 +768,9 @@ void AwesomeWidget::setFontFormating()
false, false); false, false);
if (font != defaultFont) { if (font != defaultFont) {
QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText(); QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText();
uiWidConfig.textEdit_elements->insertPlainText(QString("<font color=\"%1\" face=\"%2\" size=\"%3\">") uiWidConfig.textEdit_elements->insertPlainText(QString("<span style=\"color:%1; font-family:'%2'; font-size:%3pt;\">")
.arg(font.color().name()).arg(font.family()).arg(font.pointSize()) + .arg(font.color().name()).arg(font.family()).arg(font.pointSize()) +
selectedText + QString("</font>")); selectedText + QString("</span>"));
} }
} }

View File

@ -26,7 +26,7 @@
#include <Plasma/Theme> #include <Plasma/Theme>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QGraphicsLinearLayout> #include <QGraphicsGridLayout>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGraphicsView> #include <QGraphicsView>
#include <QProcessEnvironment> #include <QProcessEnvironment>
@ -106,7 +106,7 @@ void DesktopPanel::init()
extsysmonEngine = dataEngine(QString("ext-sysmon")); extsysmonEngine = dataEngine(QString("ext-sysmon"));
layout = new QGraphicsLinearLayout(); layout = new QGraphicsGridLayout();
layout->setContentsMargins(1, 1, 1, 1); layout->setContentsMargins(1, 1, 1, 1);
setLayout(layout); setLayout(layout);
@ -192,7 +192,7 @@ void DesktopPanel::reinit()
} }
labels.clear(); labels.clear();
// layout // layout
layout = new QGraphicsLinearLayout(); layout = new QGraphicsGridLayout();
layout->setContentsMargins(1, 1, 1, 1); layout->setContentsMargins(1, 1, 1, 1);
setLayout(layout); setLayout(layout);
@ -200,25 +200,18 @@ void DesktopPanel::reinit()
// layout // layout
if (configuration[QString("background")].toInt() == 0) if (configuration[QString("background")].toInt() == 0)
setBackgroundHints(NoBackground); setBackgroundHints(NoBackground);
if (configuration[QString("layout")].toInt() == 0)
layout->setOrientation(Qt::Horizontal);
else
layout->setOrientation(Qt::Vertical);
// left stretch
if (configuration[QString("leftStretch")].toInt() == 2)
layout->addStretch(1);
// labels // labels
for (int i=0; i<desktopNames.count(); i++) { for (int i=0; i<desktopNames.count(); i++) {
labels.append(new CustomPlasmaLabel(this, i)); labels.append(new CustomPlasmaLabel(this, i));
labels[i]->setWordWrap(false); labels[i]->setWordWrap(false);
qDebug() << labels[i]->styleSheet(); if (configuration[QString("layout")].toInt() == 0)
layout->addItem(labels[i]); layout->addItem(labels[i], 0, i);
else
layout->addItem(labels[i], i, 0);
} }
// right stretch
if (configuration[QString("rightStretch")].toInt() == 2)
layout->addStretch(1);
updateText(); updateText(true);
// layout->updateGeometry();
resize(10, 10); resize(10, 10);
} }
@ -264,15 +257,17 @@ void DesktopPanel::setCurrentDesktop(const int number)
} }
void DesktopPanel::updateText() void DesktopPanel::updateText(const bool first)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (labels.isEmpty()) return;
QString line, text; QString line, text;
for (int i=0; i<labels.count(); i++) { for (int i=0; i<labels.count(); i++) {
if (debug) qDebug() << PDEBUG << ":" << "Label" << i; if (debug) qDebug() << PDEBUG << ":" << "Label" << i;
line = parsePattern(configuration[QString("pattern")], i); if (first)
line = configuration[QString("pattern")];
else
line = parsePattern(configuration[QString("pattern")], i);
if (currentDesktop == i + 1) if (currentDesktop == i + 1)
text = currentFormatLine[0] + line + currentFormatLine[1]; text = currentFormatLine[0] + line + currentFormatLine[1];
else else
@ -322,14 +317,6 @@ void DesktopPanel::createConfigurationInterface(KConfigDialog *parent)
uiWidConfig.checkBox_layout->setCheckState(Qt::Unchecked); uiWidConfig.checkBox_layout->setCheckState(Qt::Unchecked);
else else
uiWidConfig.checkBox_layout->setCheckState(Qt::Checked); 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.spinBox_interval->setValue(configuration[QString("interval")].toInt());
uiWidConfig.comboBox_mark->setItemText(uiWidConfig.comboBox_mark->count()-1, configuration[QString("mark")]); uiWidConfig.comboBox_mark->setItemText(uiWidConfig.comboBox_mark->count()-1, configuration[QString("mark")]);
uiWidConfig.comboBox_mark->setCurrentIndex(uiWidConfig.comboBox_mark->count()-1); uiWidConfig.comboBox_mark->setCurrentIndex(uiWidConfig.comboBox_mark->count()-1);
@ -408,8 +395,6 @@ void DesktopPanel::configAccepted()
cg.writeEntry("pattern", uiWidConfig.textEdit_elements->toPlainText()); cg.writeEntry("pattern", uiWidConfig.textEdit_elements->toPlainText());
cg.writeEntry("background", QString::number(uiWidConfig.checkBox_background->checkState())); cg.writeEntry("background", QString::number(uiWidConfig.checkBox_background->checkState()));
cg.writeEntry("layout", QString::number(uiWidConfig.checkBox_layout->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("interval", QString::number(uiWidConfig.spinBox_interval->value()));
cg.writeEntry("mark", uiWidConfig.comboBox_mark->currentText()); cg.writeEntry("mark", uiWidConfig.comboBox_mark->currentText());
cg.writeEntry("desktopcmd", uiWidConfig.lineEdit_desktopcmd->text()); cg.writeEntry("desktopcmd", uiWidConfig.lineEdit_desktopcmd->text());
@ -448,10 +433,8 @@ void DesktopPanel::configChanged()
configuration[QString("desktopcmd")] = cg.readEntry("desktopcmd", "qdbus org.kde.kwin /KWin setCurrentDesktop $number"); configuration[QString("desktopcmd")] = cg.readEntry("desktopcmd", "qdbus org.kde.kwin /KWin setCurrentDesktop $number");
configuration[QString("interval")] = cg.readEntry("interval", "1000"); configuration[QString("interval")] = cg.readEntry("interval", "1000");
configuration[QString("layout")] = cg.readEntry("layout", "0"); configuration[QString("layout")] = cg.readEntry("layout", "0");
configuration[QString("leftStretch")] = cg.readEntry("leftStretch", "2");
configuration[QString("mark")] = cg.readEntry("mark", "¤"); configuration[QString("mark")] = cg.readEntry("mark", "¤");
configuration[QString("panels")] = cg.readEntry("panels", "-1"); configuration[QString("panels")] = cg.readEntry("panels", "-1");
configuration[QString("rightStretch")] = cg.readEntry("rightStretch", "2");
extsysmonEngine->connectSource(QString("desktop"), this, configuration[QString("interval")].toInt()); extsysmonEngine->connectSource(QString("desktop"), this, configuration[QString("interval")].toInt());
@ -506,9 +489,9 @@ void DesktopPanel::setFontFormating()
CFont font = CFontDialog::getFont(i18n("Select font"), defaultFont, CFont font = CFontDialog::getFont(i18n("Select font"), defaultFont,
false, false); false, false);
QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText(); QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText();
uiWidConfig.textEdit_elements->insertPlainText(QString("<font color=\"%1\" face=\"%2\" size=\"%3\">") uiWidConfig.textEdit_elements->insertPlainText(QString("<span style=\"color:%1; font-family:'%2'; font-size:%3pt;\">")
.arg(font.color().name()).arg(font.family()).arg(font.pointSize()) + .arg(font.color().name()).arg(font.family()).arg(font.pointSize()) +
selectedText + QString("</font>")); selectedText + QString("</span>"));
} }

View File

@ -28,7 +28,7 @@
#include <ui_widget.h> #include <ui_widget.h>
class QGraphicsLinearLayout; class QGraphicsGridLayout;
class DesktopPanel; class DesktopPanel;
@ -86,9 +86,9 @@ private:
// functions // functions
QList<Plasma::Containment *> getPanels(); QList<Plasma::Containment *> getPanels();
QString panelLocationToStr(Plasma::Location loc); QString panelLocationToStr(Plasma::Location loc);
void updateText(); void updateText(const bool first = false);
// ui // ui
QGraphicsLinearLayout *layout; QGraphicsGridLayout *layout;
QList<CustomPlasmaLabel *> labels; QList<CustomPlasmaLabel *> labels;
// debug // debug
bool debug; bool debug;

View File

@ -20,7 +20,7 @@
<string notr="true">Widget</string> <string notr="true">Widget</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="6" column="0"> <item row="4" column="0">
<layout class="QHBoxLayout" name="layout_interval"> <layout class="QHBoxLayout" name="layout_interval">
<item> <item>
<widget class="QLabel" name="label_interval"> <widget class="QLabel" name="label_interval">
@ -75,13 +75,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_leftStretch">
<property name="text">
<string>Add stretch to left/top of the layout</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="checkBox_background"> <widget class="QCheckBox" name="checkBox_background">
<property name="text"> <property name="text">
@ -89,7 +82,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="5" column="0">
<layout class="QHBoxLayout" name="layout_mark"> <layout class="QHBoxLayout" name="layout_mark">
<item> <item>
<widget class="QLabel" name="label_mark"> <widget class="QLabel" name="label_mark">
@ -186,13 +179,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_rightStretch">
<property name="text">
<string>Add stretch to right/bottom of the layout</string>
</property>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="checkBox_layout"> <widget class="QCheckBox" name="checkBox_layout">
<property name="text"> <property name="text">
@ -200,7 +186,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="6" column="0">
<layout class="QHBoxLayout" name="layout_desktopcmd"> <layout class="QHBoxLayout" name="layout_desktopcmd">
<item> <item>
<widget class="QLabel" name="label_desktopcmd"> <widget class="QLabel" name="label_desktopcmd">