From a3e7a84b92598ff3e2824b175db652b249015de6 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 12 Apr 2016 14:22:19 +0300 Subject: [PATCH 1/9] drop another part of pornography in gi more intuinitve configuration interface in graphicalitem. Improve code for the future references (in case if new color type will be added). Change X-AW-*Color values to ones with prefixes (added autoconversion from old-version api) --- .../awesome-widget/plugin/awupdatehelper.cpp | 8 +- .../desktops/aw-bat-bar.desktop | 6 +- .../desktops/aw-cpu-bar.desktop | 6 +- .../desktops/aw-mem-bar.desktop | 6 +- .../desktops/aw-swap-bar.desktop | 6 +- sources/awesomewidgets/graphicalitem.cpp | 97 +++++---- sources/awesomewidgets/graphicalitem.h | 9 +- sources/awesomewidgets/graphicalitem.ui | 189 +++++------------- .../awesomewidgets/graphicalitemhelper.cpp | 25 ++- sources/awesomewidgets/graphicalitemhelper.h | 1 + sources/version.h.in | 2 +- 11 files changed, 157 insertions(+), 198 deletions(-) diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp index eecb557..b43001b 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.cpp +++ b/sources/awesome-widget/plugin/awupdatehelper.cpp @@ -74,14 +74,18 @@ bool AWUpdateHelper::checkVersion() // update version settings.setValue(QString("Version"), QString(VERSION)); settings.sync(); + qCInfo(LOG_AW) << "Found version" << version << "actual one is" + << m_foundVersion; - qCInfo(LOG_AW) << "Found version" << version << "actual one is" << VERSION; - if (version != QVersionNumber::fromString(VERSION)) { + if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) { genMessageBox(i18n("Changelog of %1", QString(VERSION)), QString(CHANGELOG).replace(QChar('@'), QChar('\n')), QMessageBox::Ok) ->open(); return true; + } else if (version != m_foundVersion) { + qCWarning(LOG_AW) << "No changelog information provided"; + return true; } else { qCInfo(LOG_AW) << "No need to update version"; } diff --git a/sources/awesomewidgets/desktops/aw-bat-bar.desktop b/sources/awesomewidgets/desktops/aw-bat-bar.desktop index 5dac5d4..cb0d109 100644 --- a/sources/awesomewidgets/desktops/aw-bat-bar.desktop +++ b/sources/awesomewidgets/desktops/aw-bat-bar.desktop @@ -6,11 +6,11 @@ X-AW-Value=bat X-AW-Custom=false X-AW-Max=100.0 X-AW-Min=0.0 -X-AW-ActiveColor="0,0,0,255" -X-AW-InactiveColor="255,255,255,255" +X-AW-ActiveColor="color://0,0,0,255" +X-AW-InactiveColor="color://255,255,255,255" X-AW-Type=Horizontal X-AW-Direction=LeftToRight X-AW-Height=25 X-AW-Width=100 -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Number=3 diff --git a/sources/awesomewidgets/desktops/aw-cpu-bar.desktop b/sources/awesomewidgets/desktops/aw-cpu-bar.desktop index 224f58b..df164f4 100644 --- a/sources/awesomewidgets/desktops/aw-cpu-bar.desktop +++ b/sources/awesomewidgets/desktops/aw-cpu-bar.desktop @@ -6,11 +6,11 @@ X-AW-Value=cpu X-AW-Custom=false X-AW-Max=100.0 X-AW-Min=0.0 -X-AW-ActiveColor="0,0,0,255" -X-AW-InactiveColor="255,255,255,255" +X-AW-ActiveColor="color://0,0,0,255" +X-AW-InactiveColor="color://255,255,255,255" X-AW-Type=Horizontal X-AW-Direction=LeftToRight X-AW-Height=25 X-AW-Width=100 -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Number=0 diff --git a/sources/awesomewidgets/desktops/aw-mem-bar.desktop b/sources/awesomewidgets/desktops/aw-mem-bar.desktop index d76fa22..4749a0c 100644 --- a/sources/awesomewidgets/desktops/aw-mem-bar.desktop +++ b/sources/awesomewidgets/desktops/aw-mem-bar.desktop @@ -6,11 +6,11 @@ X-AW-Value=mem X-AW-Custom=false X-AW-Max=100.0 X-AW-Min=0.0 -X-AW-ActiveColor="0,0,0,255" -X-AW-InactiveColor="255,255,255,255" +X-AW-ActiveColor="color://0,0,0,255" +X-AW-InactiveColor="color://255,255,255,255" X-AW-Type=Horizontal X-AW-Direction=LeftToRight X-AW-Height=25 X-AW-Width=100 -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Number=1 diff --git a/sources/awesomewidgets/desktops/aw-swap-bar.desktop b/sources/awesomewidgets/desktops/aw-swap-bar.desktop index ee957ee..ba90548 100644 --- a/sources/awesomewidgets/desktops/aw-swap-bar.desktop +++ b/sources/awesomewidgets/desktops/aw-swap-bar.desktop @@ -6,11 +6,11 @@ X-AW-Value=swap X-AW-Custom=false X-AW-Max=100.0 X-AW-Min=0.0 -X-AW-ActiveColor="0,0,0,255" -X-AW-InactiveColor="255,255,255,255" +X-AW-ActiveColor="color://0,0,0,255" +X-AW-InactiveColor="color://255,255,255,255" X-AW-Type=Horizontal X-AW-Direction=LeftToRight X-AW-Height=25 X-AW-Width=100 -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Number=2 diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 9c523be..57c228c 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -50,9 +50,9 @@ GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, SLOT(changeValue(int))); connect(ui->comboBox_type, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCountState(int))); - connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, + connect(ui->toolButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor())); - connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, + connect(ui->toolButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor())); } @@ -415,9 +415,18 @@ void GraphicalItem::readConfiguration() .toString()); setHeight(settings.value(QString("X-AW-Height"), m_height).toInt()); setWidth(settings.value(QString("X-AW-Width"), m_width).toInt()); - // api == 2 - if (apiVersion() < 2) - setNumber(bar().remove(QString("bar")).toInt()); + // api == 5 + if (apiVersion() < 5) { + QString prefix; + prefix = m_activeColor.startsWith(QString("/")) + ? QString("file://%1") + : QString("color://%1"); + m_activeColor = prefix.arg(m_activeColor); + prefix = m_inactiveColor.startsWith(QString("/")) + ? QString("file://%1") + : QString("color://%1"); + m_inactiveColor = prefix.arg(m_inactiveColor); + } settings.endGroup(); } @@ -449,12 +458,16 @@ int GraphicalItem::showConfiguration(const QVariant args) ui->doubleSpinBox_max->setValue(m_maxValue); ui->doubleSpinBox_min->setValue(m_minValue); ui->spinBox_count->setValue(m_count); - ui->checkBox_activeCheck->setChecked( - m_activeColor.startsWith(QString("/"))); - ui->pushButton_activeColor->setText(m_activeColor); - ui->checkBox_inactiveCheck->setChecked( - m_inactiveColor.startsWith(QString("/"))); - ui->pushButton_inactiveColor->setText(m_inactiveColor); + if (m_helper->isColor(m_activeColor)) + ui->comboBox_activeImageType->setCurrentIndex(0); + else + ui->comboBox_activeImageType->setCurrentIndex(1); + ui->lineEdit_activeColor->setText(m_activeColor); + if (m_helper->isColor(m_inactiveColor)) + ui->comboBox_inactiveImageType->setCurrentIndex(0); + else + ui->comboBox_inactiveImageType->setCurrentIndex(1); + ui->lineEdit_inactiveColor->setText(m_inactiveColor); ui->comboBox_type->setCurrentIndex(static_cast(m_type)); ui->comboBox_direction->setCurrentIndex(static_cast(m_direction)); ui->spinBox_height->setValue(m_height); @@ -477,8 +490,8 @@ int GraphicalItem::showConfiguration(const QVariant args) : ui->comboBox_value->currentText()); setMaxValue(ui->doubleSpinBox_max->value()); setMinValue(ui->doubleSpinBox_min->value()); - setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&'))); - setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&'))); + setActiveColor(ui->lineEdit_activeColor->text()); + setInactiveColor(ui->lineEdit_inactiveColor->text()); setStrType(ui->comboBox_type->currentText()); setStrDirection(ui->comboBox_direction->currentText()); setHeight(ui->spinBox_height->value()); @@ -518,22 +531,20 @@ void GraphicalItem::writeConfiguration() const void GraphicalItem::changeColor() { - QString outputColor; - bool imageRequired = sender() == ui->pushButton_activeColor - ? ui->checkBox_activeCheck->isChecked() - : ui->checkBox_inactiveCheck->isChecked(); - - if (imageRequired) { - QString path = static_cast(sender())->text(); - QString directory = QFileInfo(path).absolutePath(); - outputColor = QFileDialog::getOpenFileName( - this, tr("Select path"), directory, - tr("Images (*.png *.bpm *.jpg);;All files (*.*)")); - - qCInfo(LOG_LIB) << "Selected path" << outputColor; + QLineEdit *lineEdit; + int state; + if (sender() == ui->toolButton_activeColor) { + lineEdit = ui->lineEdit_activeColor; + state = ui->comboBox_activeImageType->currentIndex(); } else { - QColor color = m_helper->stringToColor( - (static_cast(sender()))->text()); + lineEdit = ui->lineEdit_inactiveColor; + state = ui->comboBox_inactiveImageType->currentIndex(); + } + qCInfo(LOG_LIB) << "Using state" << state << "and lineEdit" << lineEdit; + + QString outputColor; + if (state == 0) { + QColor color = m_helper->stringToColor(lineEdit->text()); QColor newColor = QColorDialog::getColor( color, this, tr("Select color"), QColorDialog::ShowAlphaChannel); if (!newColor.isValid()) @@ -546,10 +557,23 @@ void GraphicalItem::changeColor() colorText.append(QString("%1").arg(newColor.blue())); colorText.append(QString("%1").arg(newColor.alpha())); - outputColor = colorText.join(QChar(',')); + outputColor = QString("color://%1").arg(colorText.join(QChar(','))); + } else if (state == 1) { + QString path = lineEdit->text(); + QString directory = QFileInfo(path).absolutePath(); + outputColor = QFileDialog::getOpenFileUrl( + this, tr("Select path"), directory, + tr("Images (*.png *.bpm *.jpg);;All files (*.*)")) + .toString(); + + qCInfo(LOG_LIB) << "Selected path" << outputColor; } - return static_cast(sender())->setText(outputColor); + if (outputColor.isEmpty()) { + qCWarning(LOG_LIB) << "Empty color selected, skipping"; + return; + } + return lineEdit->setText(outputColor); } @@ -602,12 +626,17 @@ void GraphicalItem::translate() ui->label_customValue->setText(i18n("Value")); ui->label_max->setText(i18n("Max value")); ui->label_min->setText(i18n("Min value")); - ui->checkBox_activeCheck->setText(i18n("Use image for active")); - ui->label_activeColor->setText(i18n("Active color")); - ui->checkBox_inactiveCheck->setText(i18n("Use image for inactive")); - ui->label_inactiveColor->setText(i18n("Inactive color")); + ui->label_activeImageType->setText(i18n("Active image type")); + ui->label_inactiveImageType->setText(i18n("Inctive image type")); ui->label_type->setText(i18n("Type")); ui->label_direction->setText(i18n("Direction")); ui->label_height->setText(i18n("Height")); ui->label_width->setText(i18n("Width")); + + ui->comboBox_activeImageType->clear(); + ui->comboBox_activeImageType->addItem(i18n("color")); + ui->comboBox_activeImageType->addItem(i18n("image")); + ui->comboBox_inactiveImageType->clear(); + ui->comboBox_inactiveImageType->addItem(i18n("color")); + ui->comboBox_inactiveImageType->addItem(i18n("image")); } diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index 5555847..9ccd67f 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -76,10 +76,11 @@ public: QString uniq() const; // set methods void setBar(const QString _bar = QString("cpu")); - void setActiveColor(const QString _color = QString("0,0,0,130")); + void setActiveColor(const QString _color = QString("color://0,0,0,130")); void setCount(const int _count = 100); void setCustom(const bool _custom = false); - void setInactiveColor(const QString _color = QString("255,255,255,130")); + void setInactiveColor(const QString _color + = QString("color://255,255,255,130")); void setMinValue(const float _value = 0.0); void setMaxValue(const float _value = 100.0); void setType(const Type _type = Horizontal); @@ -112,8 +113,8 @@ private: QString m_bar = QString("cpu"); int m_count = 100; bool m_custom = false; - QString m_activeColor; - QString m_inactiveColor; + QString m_activeColor = QString("color://0,0,0,130"); + QString m_inactiveColor = QString("color://255,255,255,130"); float m_minValue = 0.0f; float m_maxValue = 100.0f; Type m_type = Horizontal; diff --git a/sources/awesomewidgets/graphicalitem.ui b/sources/awesomewidgets/graphicalitem.ui index 212c0a4..45ad29d 100644 --- a/sources/awesomewidgets/graphicalitem.ui +++ b/sources/awesomewidgets/graphicalitem.ui @@ -7,7 +7,7 @@ 0 0 416 - 537 + 540 @@ -100,16 +100,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -135,16 +126,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -219,134 +201,74 @@ - + - - - Qt::Horizontal + + + Active image type - - - 40 - 20 - + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + - - - - 0 - 0 - + + + + + + + + + + true + + + + - Use image for active + ... - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Active color - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - + - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - + - Use image for inactive + Inactive image type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Inactive color - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - + + + + + true + + + + + + + ... + + + + @@ -417,16 +339,7 @@ - - 0 - - - 0 - - - 0 - - + 0 diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index 6442f23..c781ba4 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -50,7 +50,9 @@ void GraphicalItemHelper::setParameters(const QString active, // put images to pens if any otherwise set pen colors // Images resize to content here as well - if (active.startsWith(QString("/"))) { + if (isColor(active)) { + m_activePen.setColor(stringToColor(active)); + } else { qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << active; QPixmap pixmap = QPixmap(active); if (pixmap.isNull()) { @@ -59,10 +61,10 @@ void GraphicalItemHelper::setParameters(const QString active, } else { m_activePen.setBrush(QBrush(pixmap.scaled(width, height))); } - } else { - m_activePen.setColor(stringToColor(active)); } - if (inactive.startsWith(QString("/"))) { + if (isColor(inactive)) { + m_inactivePen.setColor(stringToColor(inactive)); + } else { qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << inactive; QPixmap pixmap = QPixmap(inactive); if (pixmap.isNull()) { @@ -71,8 +73,6 @@ void GraphicalItemHelper::setParameters(const QString active, } else { m_inactivePen.setBrush(QBrush(pixmap.scaled(width, height))); } - } else { - m_inactivePen.setColor(stringToColor(inactive)); } m_width = width; m_height = height; @@ -171,14 +171,25 @@ float GraphicalItemHelper::getPercents(const float &value, const float &min, } +bool GraphicalItemHelper::isColor(const QString &input) +{ + qCDebug(LOG_LIB) << "Define input type in" << input; + + return input.startsWith(QString("color://")); +} + + QColor GraphicalItemHelper::stringToColor(const QString &color) { qCDebug(LOG_LIB) << "Color" << color; - QColor qColor; QStringList listColor = color.split(QChar(',')); while (listColor.count() < 4) listColor.append(QString("0")); + // remove prefix + listColor[0].remove(QString("color://")); + // init color + QColor qColor; qColor.setRed(listColor.at(0).toInt()); qColor.setGreen(listColor.at(1).toInt()); qColor.setBlue(listColor.at(2).toInt()); diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index 96ac999..f4cd6e1 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -41,6 +41,7 @@ public: void paintVertical(const float &percent); // additional conversion methods float getPercents(const float &value, const float &min, const float &max); + bool isColor(const QString &input); QColor stringToColor(const QString &color); private: diff --git a/sources/version.h.in b/sources/version.h.in index aa4f886..b3f6ab9 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -24,7 +24,7 @@ // configuraion // graphical items api version -#define AWGIAPI 4 +#define AWGIAPI 5 // extquotes api version #define AWEQAPI 3 // extscript api version From f7a6b86cae791f00f072e1190bb66d5e06c8839b Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 14 Apr 2016 16:14:26 +0300 Subject: [PATCH 2/9] GI improvements * add tag information to GI configuration * change tag identification to avoid keys reorderding --- sources/awesome-widget/plugin/awkeys.cpp | 14 ++++++-------- sources/awesomewidgets/graphicalitem.cpp | 18 +++++++++++++----- sources/awesomewidgets/graphicalitem.ui | 23 ++++++++++++++++++++++- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 71b4e6e..033d850 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -312,14 +312,12 @@ QString AWKeys::parsePattern(QString pattern) const // bars for (auto bar : m_foundBars) { GraphicalItem *item = keyOperator->giByKey(bar); - if (item->isCustom()) - pattern.replace( - QString("$%1").arg(bar), - item->image(AWPatternFunctions::expandLambdas( - item->bar(), aggregator, values, item->usedKeys()))); - else - pattern.replace(QString("$%1").arg(bar), - item->image(values[item->bar()])); + QString image + = item->isCustom() + ? item->image(AWPatternFunctions::expandLambdas( + item->bar(), aggregator, values, item->usedKeys())) + : item->image(values[item->bar()]); + pattern.replace(QString("$%1").arg(bar), image); } // prepare strings diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 57c228c..da393d2 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -370,7 +370,13 @@ void GraphicalItem::setUsedKeys(const QStringList _usedKeys) qCDebug(LOG_LIB) << "Used keys" << _usedKeys; // remove dubs - m_usedKeys = QSet::fromList(_usedKeys).toList(); + // HACK converting to set may break order + m_usedKeys.clear(); + for (auto key : _usedKeys) { + if (m_usedKeys.contains(key)) + continue; + m_usedKeys.append(key); + } } @@ -447,6 +453,7 @@ int GraphicalItem::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); + ui->label_numberValue->setText(QString("%1").arg(number())); ui->checkBox_custom->setChecked(m_custom); ui->comboBox_value->addItems(tags); if (m_custom) { @@ -562,9 +569,9 @@ void GraphicalItem::changeColor() QString path = lineEdit->text(); QString directory = QFileInfo(path).absolutePath(); outputColor = QFileDialog::getOpenFileUrl( - this, tr("Select path"), directory, - tr("Images (*.png *.bpm *.jpg);;All files (*.*)")) - .toString(); + this, tr("Select path"), directory, + tr("Images (*.png *.bpm *.jpg);;All files (*.*)")) + .toString(); qCInfo(LOG_LIB) << "Selected path" << outputColor; } @@ -620,7 +627,7 @@ void GraphicalItem::translate() { ui->label_name->setText(i18n("Name")); ui->label_comment->setText(i18n("Comment")); - ui->label_count->setText(i18n("Points count")); + ui->label_number->setText(i18n("Tag")); ui->checkBox_custom->setText(i18n("Use custom formula")); ui->label_value->setText(i18n("Value")); ui->label_customValue->setText(i18n("Value")); @@ -629,6 +636,7 @@ void GraphicalItem::translate() ui->label_activeImageType->setText(i18n("Active image type")); ui->label_inactiveImageType->setText(i18n("Inctive image type")); ui->label_type->setText(i18n("Type")); + ui->label_count->setText(i18n("Points count")); ui->label_direction->setText(i18n("Direction")); ui->label_height->setText(i18n("Height")); ui->label_width->setText(i18n("Width")); diff --git a/sources/awesomewidgets/graphicalitem.ui b/sources/awesomewidgets/graphicalitem.ui index 45ad29d..a97f8d3 100644 --- a/sources/awesomewidgets/graphicalitem.ui +++ b/sources/awesomewidgets/graphicalitem.ui @@ -7,7 +7,7 @@ 0 0 416 - 540 + 569 @@ -60,6 +60,27 @@ + + + + + + Tag + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + From d30df9dafc6087ab8bd3191f73a167ae7d2b59bd Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 15 Apr 2016 15:02:35 +0300 Subject: [PATCH 3/9] fix configuration ui In some cases text is removed, but no new text is pasted. --- .../package/contents/ui/widget.qml | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/sources/awesome-widget/package/contents/ui/widget.qml b/sources/awesome-widget/package/contents/ui/widget.qml index 640617e..d9c7c30 100644 --- a/sources/awesome-widget/package/contents/ui/widget.qml +++ b/sources/awesome-widget/package/contents/ui/widget.qml @@ -73,13 +73,13 @@ Item { "size": plasmoid.configuration.fontSize } var font = awActions.getFont(defaultFont) - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + - selected + "") + textPattern.insert(textPattern.cursorPosition, + "" + + selected + "") } } QtControls.Button { @@ -88,10 +88,9 @@ Item { onClicked: { if (debug) console.debug("Indent button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, selected + "
\n") + textPattern.insert(textPattern.cursorPosition, selected + "
\n") } } @@ -101,10 +100,9 @@ Item { onClicked: { if (debug) console.debug("Bold button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "") + textPattern.insert(textPattern.cursorPosition, "" + selected + "") } } QtControls.Button { @@ -113,10 +111,9 @@ Item { onClicked: { if (debug) console.debug("Italic button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "") + textPattern.insert(textPattern.cursorPosition, "" + selected + "") } } QtControls.Button { @@ -125,10 +122,9 @@ Item { onClicked: { if (debug) console.debug("Underline button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "") + textPattern.insert(textPattern.cursorPosition, "" + selected + "") } } QtControls.Button { @@ -137,10 +133,9 @@ Item { onClicked: { if (debug) console.debug("Strike button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "") + textPattern.insert(textPattern.cursorPosition, "" + selected + "") } } @@ -150,10 +145,9 @@ Item { onClicked: { if (debug) console.debug("Left button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "

" + selected + "

") + textPattern.insert(textPattern.cursorPosition, "

" + selected + "

") } } QtControls.Button { @@ -162,10 +156,9 @@ Item { onClicked: { if (debug) console.debug("Center button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "

" + selected + "

") + textPattern.insert(textPattern.cursorPosition, "

" + selected + "

") } } QtControls.Button { @@ -174,10 +167,9 @@ Item { onClicked: { if (debug) console.debug("Right button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "

" + selected + "

") + textPattern.insert(textPattern.cursorPosition, "

" + selected + "

") } } QtControls.Button { @@ -186,10 +178,9 @@ Item { onClicked: { if (debug) console.debug("Justify button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "

" + selected + "

") + textPattern.insert(textPattern.cursorPosition, "

" + selected + "

") } } } From 0e3f83f36145a32b4871eeac0395d70f2fd4a12a Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 16 Apr 2016 03:23:28 +0300 Subject: [PATCH 4/9] add bars support to gi same as graphs but also provides solid background under lines --- sources/awesomewidgets/graphicalitem.cpp | 10 ++++++ sources/awesomewidgets/graphicalitem.h | 2 +- sources/awesomewidgets/graphicalitem.ui | 5 +++ .../awesomewidgets/graphicalitemhelper.cpp | 36 +++++++++++++++---- sources/awesomewidgets/graphicalitemhelper.h | 1 + 5 files changed, 47 insertions(+), 7 deletions(-) diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index da393d2..73c771b 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -116,6 +116,11 @@ QString GraphicalItem::image(const QVariant &value) m_helper->paintGraph(converted); // direction option is not recognized by this GI type break; + case Bars: + m_helper->paintBars(converted); + // direction option is not recognized by this GI type + scale[1] = -1; + break; case Horizontal: default: m_helper->paintHorizontal(converted); @@ -198,6 +203,9 @@ QString GraphicalItem::strType() const case Graph: value = QString("Graph"); break; + case Bars: + value = QString("Bars"); + break; case Horizontal: default: value = QString("Horizontal"); @@ -331,6 +339,8 @@ void GraphicalItem::setStrType(const QString _type) setType(Circle); else if (_type == QString("Graph")) setType(Graph); + else if (_type == QString("Bars")) + setType(Bars); else setType(Horizontal); } diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index 9ccd67f..50f4ed5 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -50,7 +50,7 @@ class GraphicalItem : public AbstractExtItem public: enum Direction { LeftToRight = 0, RightToLeft }; - enum Type { Horizontal = 0, Vertical, Circle, Graph }; + enum Type { Horizontal = 0, Vertical, Circle, Graph, Bars }; explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(), diff --git a/sources/awesomewidgets/graphicalitem.ui b/sources/awesomewidgets/graphicalitem.ui index a97f8d3..3d80311 100644 --- a/sources/awesomewidgets/graphicalitem.ui +++ b/sources/awesomewidgets/graphicalitem.ui @@ -325,6 +325,11 @@ Graph
+ + + Bars + + diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index c781ba4..bf274bd 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -51,25 +51,25 @@ void GraphicalItemHelper::setParameters(const QString active, // put images to pens if any otherwise set pen colors // Images resize to content here as well if (isColor(active)) { - m_activePen.setColor(stringToColor(active)); + m_activePen.setBrush(QBrush(stringToColor(active))); } else { qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << active; QPixmap pixmap = QPixmap(active); if (pixmap.isNull()) { qCInfo(LOG_LIB) << "Invalid pixmap found" << active; - m_activePen.setColor(QColor(0, 0, 0, 130)); + m_activePen.setBrush(QBrush(QColor(0, 0, 0, 130))); } else { m_activePen.setBrush(QBrush(pixmap.scaled(width, height))); } } if (isColor(inactive)) { - m_inactivePen.setColor(stringToColor(inactive)); + m_inactivePen.setBrush(QBrush(stringToColor(inactive))); } else { qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << inactive; QPixmap pixmap = QPixmap(inactive); if (pixmap.isNull()) { qCInfo(LOG_LIB) << "Invalid pixmap found" << inactive; - m_inactivePen.setColor(QColor(255, 255, 255, 130)); + m_inactivePen.setBrush(QBrush(QColor(255, 255, 255, 130))); } else { m_inactivePen.setBrush(QBrush(pixmap.scaled(width, height))); } @@ -80,6 +80,30 @@ void GraphicalItemHelper::setParameters(const QString active, } +void GraphicalItemHelper::paintBars(const float &value) +{ + qCDebug(LOG_LIB) << "Paint with value" << value; + + // refresh background image + m_scene->setBackgroundBrush(m_inactivePen.brush()); + + storeValue(value); + + // default norms + float normX + = static_cast(m_width) / static_cast(m_values.count()); + float normY = static_cast(m_height - 1); + // paint graph + for (int i = 0; i < m_values.count(); i++) { + float x = i * normX; + float y = 0.5f; + float width = normX; + float height = m_values.at(i) * normY + 0.5f; + m_scene->addRect(x, y, width, height, m_activePen, m_activePen.brush()); + } +} + + void GraphicalItemHelper::paintCircle(const float &percent) { qCDebug(LOG_LIB) << "Paint with percent" << percent; @@ -120,9 +144,9 @@ void GraphicalItemHelper::paintGraph(const float &value) for (int i = 0; i < m_values.count() - 1; i++) { // some magic here float x1 = i * normX; - float y1 = -fabs(m_values.at(i)) * normY + 0.5f; + float y1 = -m_values.at(i) * normY + 0.5f; float x2 = (i + 1) * normX; - float y2 = -fabs(m_values.at(i + 1)) * normY + 0.5f; + float y2 = -m_values.at(i + 1) * normY + 0.5f; m_scene->addLine(x1, y1, x2, y2, m_activePen); } } diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index f4cd6e1..ee83e7e 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -35,6 +35,7 @@ public: void setParameters(const QString active, const QString inactive, const int width, const int height, const int count); // paint methods + void paintBars(const float &value); void paintCircle(const float &percent); void paintGraph(const float &value); void paintHorizontal(const float &percent); From 27a80274ac0298d8ff8b8a8f6683a2ce3b8a825c Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 16 Apr 2016 18:29:11 +0300 Subject: [PATCH 5/9] add total memory fix patch --- patches/total-memory-fix.patch | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 patches/total-memory-fix.patch diff --git a/patches/total-memory-fix.patch b/patches/total-memory-fix.patch new file mode 100644 index 0000000..60f02f1 --- /dev/null +++ b/patches/total-memory-fix.patch @@ -0,0 +1,37 @@ +diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp +index 7a1887b..9f39e2f 100644 +--- a/sources/awesome-widget/plugin/awkeysaggregator.cpp ++++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp +@@ -34,8 +34,8 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) + // default formaters + // memory + m_formater[QString("mem")] = Float; +- m_formater[QString("memtotmb")] = IntegerFive; +- m_formater[QString("memtotgb")] = Float; ++ m_formater[QString("memtotmb")] = MemMBFormat; ++ m_formater[QString("memtotgb")] = MemGBFormat; + // network + m_formater[QString("down")] = NetSmartFormat; + m_formater[QString("downkb")] = Integer; +@@ -45,8 +45,8 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) + m_formater[QString("upunits")] = NetSmartUnits; + // swap + m_formater[QString("swap")] = Float; +- m_formater[QString("swaptotmb")] = IntegerFive; +- m_formater[QString("swaptotgb")] = Float; ++ m_formater[QString("swaptotmb")] = MemMBFormat; ++ m_formater[QString("swaptotgb")] = MemGBFormat; + } + + +@@ -338,8 +338,8 @@ QStringList AWKeysAggregator::registerSource(const QString &source, + m_map[source] = key; + m_formater[key] = Float; + // additional keys +- m_formater[QString("hddtotmb%1").arg(index)] = IntegerFive; +- m_formater[QString("hddtotgb%1").arg(index)] = Float; ++ m_formater[QString("hddtotmb%1").arg(index)] = MemMBFormat; ++ m_formater[QString("hddtotgb%1").arg(index)] = MemGBFormat; + } + } else if (source.contains(mountFreeRegExp)) { + // free space From aef1a736c8b5a10d2b81ad0682f6233a055502e5 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sun, 17 Apr 2016 16:18:13 +0300 Subject: [PATCH 6/9] code improvements * drop c++14 requirements since it is not used * move from enum to enum classes * more intuitive graph building in GI * allow X-AW-Direction property works with graphs and bars --- sources/CMakeLists.txt | 4 +- .../package/contents/ui/main.qml | 2 +- .../plugin/awkeysaggregator.cpp | 183 +++++++++--------- .../awesome-widget/plugin/awkeysaggregator.h | 2 +- sources/awesomewidgets/extscript.cpp | 28 ++- sources/awesomewidgets/extscript.h | 6 +- sources/awesomewidgets/graphicalitem.cpp | 54 +++--- sources/awesomewidgets/graphicalitem.h | 12 +- .../awesomewidgets/graphicalitemhelper.cpp | 4 +- 9 files changed, 145 insertions(+), 150 deletions(-) diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index ca46b81..5540997 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -42,14 +42,14 @@ include(changelog.cmake) # flags if (CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++14") + set(CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") # avoid newer gcc warnings add_definitions(-D_DEFAULT_SOURCE) elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -std=c++14 -stdlib=libc++") + set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") diff --git a/sources/awesome-widget/package/contents/ui/main.qml b/sources/awesome-widget/package/contents/ui/main.qml index 0e20bc9..5e1f77c 100644 --- a/sources/awesome-widget/package/contents/ui/main.qml +++ b/sources/awesome-widget/package/contents/ui/main.qml @@ -84,7 +84,7 @@ Item { // ui Text { id: text - anchors.fill: parent + anchors.fill: Layout renderType: Text.NativeRendering textFormat: Text.RichText wrapMode: plasmoid.configuration.wrapText ? Text.WordWrap : Text.NoWrap diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 7a1887b..d5b651a 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -33,20 +33,20 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) // default formaters // memory - m_formater[QString("mem")] = Float; - m_formater[QString("memtotmb")] = IntegerFive; - m_formater[QString("memtotgb")] = Float; + m_formater[QString("mem")] = FormaterType::Float; + m_formater[QString("memtotmb")] = FormaterType::IntegerFive; + m_formater[QString("memtotgb")] = FormaterType::Float; // network - m_formater[QString("down")] = NetSmartFormat; - m_formater[QString("downkb")] = Integer; - m_formater[QString("downunits")] = NetSmartUnits; - m_formater[QString("up")] = NetSmartFormat; - m_formater[QString("upkb")] = Integer; - m_formater[QString("upunits")] = NetSmartUnits; + m_formater[QString("down")] = FormaterType::NetSmartFormat; + m_formater[QString("downkb")] = FormaterType::Integer; + m_formater[QString("downunits")] = FormaterType::NetSmartUnits; + m_formater[QString("up")] = FormaterType::NetSmartFormat; + m_formater[QString("upkb")] = FormaterType::Integer; + m_formater[QString("upunits")] = FormaterType::NetSmartUnits; // swap - m_formater[QString("swap")] = Float; - m_formater[QString("swaptotmb")] = IntegerFive; - m_formater[QString("swaptotgb")] = Float; + m_formater[QString("swap")] = FormaterType::Float; + m_formater[QString("swaptotmb")] = FormaterType::IntegerFive; + m_formater[QString("swaptotgb")] = FormaterType::Float; } @@ -65,35 +65,35 @@ QString AWKeysAggregator::formater(const QVariant &data, QLocale loc = m_translate ? QLocale::system() : QLocale::c(); // case block switch (m_formater[key]) { - case Float: + case FormaterType::Float: output = QString("%1").arg(data.toFloat(), 5, 'f', 1); break; - case FloatTwoSymbols: + case FormaterType::FloatTwoSymbols: output = QString("%1").arg(data.toFloat(), 5, 'f', 2); break; - case Integer: + case FormaterType::Integer: output = QString("%1").arg(data.toFloat(), 4, 'f', 0); break; - case IntegerFive: + case FormaterType::IntegerFive: output = QString("%1").arg(data.toFloat(), 5, 'f', 0); break; - case IntegerThree: + case FormaterType::IntegerThree: output = QString("%1").arg(data.toFloat(), 3, 'f', 0); break; - case List: + case FormaterType::List: output = data.toStringList().join(QChar(',')); break; - case ACFormat: + case FormaterType::ACFormat: output = data.toBool() ? m_acOnline : m_acOffline; break; - case MemGBFormat: + case FormaterType::MemGBFormat: output = QString("%1").arg(data.toFloat() / (1024.0 * 1024.0), 5, 'f', 1); break; - case MemMBFormat: + case FormaterType::MemMBFormat: output = QString("%1").arg(data.toFloat() / 1024.0, 5, 'f', 0); break; - case NetSmartFormat: + case FormaterType::NetSmartFormat: output = [](const float value) { if (value > 1024.0) return QString("%1").arg(value / 1024.0, 4, 'f', 1); @@ -101,41 +101,41 @@ QString AWKeysAggregator::formater(const QVariant &data, return QString("%1").arg(value, 4, 'f', 0); }(data.toFloat()); break; - case NetSmartUnits: + case FormaterType::NetSmartUnits: if (data.toFloat() > 1024.0) output = m_translate ? i18n("MB/s") : QString("MB/s"); else output = m_translate ? i18n("KB/s") : QString("KB/s"); break; - case Quotes: + case FormaterType::Quotes: // first cast output = QString("%1").arg(data.toDouble(), 0, 'f'); output = output.rightJustified(8, QLatin1Char(' '), true); break; - case Temperature: + case FormaterType::Temperature: output = QString("%1").arg(temperature(data.toFloat()), 5, 'f', 1); break; - case Time: + case FormaterType::Time: output = data.toDateTime().toString(); break; - case TimeCustom: + case FormaterType::TimeCustom: output = m_customTime; [&output, loc, this](const QDateTime dt) { for (auto key : timeKeys) output.replace(QString("$%1").arg(key), loc.toString(dt, key)); }(data.toDateTime()); break; - case TimeISO: + case FormaterType::TimeISO: output = data.toDateTime().toString(Qt::ISODate); break; - case TimeLong: + case FormaterType::TimeLong: output = loc.toString(data.toDateTime(), QLocale::LongFormat); break; - case TimeShort: + case FormaterType::TimeShort: output = loc.toString(data.toDateTime(), QLocale::ShortFormat); break; - case Uptime: - case UptimeCustom: + case FormaterType::Uptime: + case FormaterType::UptimeCustom: output = [](QString source, const int uptime) { int seconds = uptime - uptime % 60; @@ -152,16 +152,13 @@ QString AWKeysAggregator::formater(const QVariant &data, QString("%1").arg(minutes, 2, 10, QChar('0'))); source.replace(QString("$m"), QString("%1").arg(minutes)); return source; - }(m_formater[key] == Uptime ? QString("$ddd$hhh$mmm") - : m_customUptime, + }(m_formater[key] == FormaterType::Uptime ? QString("$ddd$hhh$mmm") + : m_customUptime, static_cast(data.toFloat())); break; - case NoFormat: + case FormaterType::NoFormat: output = data.toString(); break; - default: - output = QString(); - break; } return output; @@ -254,52 +251,52 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (source == QString("battery/ac")) { // AC m_map[source] = QString("ac"); - m_formater[QString("ac")] = ACFormat; + m_formater[QString("ac")] = FormaterType::ACFormat; } else if (source.startsWith(QString("battery/"))) { // battery stats QString key = source; key.remove(QString("battery/")); m_map[source] = key; - m_formater[key] = IntegerThree; + m_formater[key] = FormaterType::IntegerThree; } else if (source == QString("cpu/system/TotalLoad")) { // cpu m_map[source] = QString("cpu"); - m_formater[QString("cpu")] = Float; + m_formater[QString("cpu")] = FormaterType::Float; } else if (source.contains(cpuRegExp)) { // cpus QString key = source; key.remove(QString("cpu/")).remove(QString("/TotalLoad")); m_map[source] = key; - m_formater[key] = Float; + m_formater[key] = FormaterType::Float; } else if (source == QString("cpu/system/AverageClock")) { // cpucl m_map[source] = QString("cpucl"); - m_formater[QString("cpucl")] = Integer; + m_formater[QString("cpucl")] = FormaterType::Integer; } else if (source.contains(cpuclRegExp)) { // cpucls QString key = source; key.remove(QString("cpu/cpu")).remove(QString("/clock")); key = QString("cpucl%1").arg(key); m_map[source] = key; - m_formater[key] = Integer; + m_formater[key] = FormaterType::Integer; } else if (source.startsWith(QString("custom"))) { // custom QString key = source; key.remove(QString("custom/")); m_map[source] = key; - m_formater[key] = NoFormat; + m_formater[key] = FormaterType::NoFormat; } else if (source == QString("desktop/current/name")) { // current desktop name m_map[source] = QString("desktop"); - m_formater[QString("desktop")] = NoFormat; + m_formater[QString("desktop")] = FormaterType::NoFormat; } else if (source == QString("desktop/current/number")) { // current desktop number m_map[source] = QString("ndesktop"); - m_formater[QString("ndesktop")] = NoFormat; + m_formater[QString("ndesktop")] = FormaterType::NoFormat; } else if (source == QString("desktop/total/number")) { // desktop count m_map[source] = QString("tdesktops"); - m_formater[QString("tdesktops")] = NoFormat; + m_formater[QString("tdesktops")] = FormaterType::NoFormat; } else if (source.contains(hddrRegExp)) { // read speed QString device = source; @@ -308,7 +305,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hddr%1").arg(index); m_map[source] = key; - m_formater[key] = Integer; + m_formater[key] = FormaterType::Integer; } } else if (source.contains(hddwRegExp)) { // write speed @@ -318,16 +315,16 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hddw%1").arg(index); m_map[source] = key; - m_formater[key] = Integer; + m_formater[key] = FormaterType::Integer; } } else if (source == QString("gpu/load")) { // gpu load m_map[source] = QString("gpu"); - m_formater[QString("gpu")] = Float; + m_formater[QString("gpu")] = FormaterType::Float; } else if (source == QString("gpu/temperature")) { // gpu temperature m_map[source] = QString("gputemp"); - m_formater[QString("gputemp")] = Temperature; + m_formater[QString("gputemp")] = FormaterType::Temperature; } else if (source.contains(mountFillRegExp)) { // fill level QString device = source; @@ -336,10 +333,11 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hdd%1").arg(index); m_map[source] = key; - m_formater[key] = Float; + m_formater[key] = FormaterType::Float; // additional keys - m_formater[QString("hddtotmb%1").arg(index)] = IntegerFive; - m_formater[QString("hddtotgb%1").arg(index)] = Float; + m_formater[QString("hddtotmb%1").arg(index)] + = FormaterType::IntegerFive; + m_formater[QString("hddtotgb%1").arg(index)] = FormaterType::Float; } } else if (source.contains(mountFreeRegExp)) { // free space @@ -350,11 +348,11 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // mb QString key = QString("hddfreemb%1").arg(index); m_map[source] = key; - m_formater[key] = MemMBFormat; + m_formater[key] = FormaterType::MemMBFormat; // gb key = QString("hddfreegb%1").arg(index); m_map.insertMulti(source, key); - m_formater[key] = MemGBFormat; + m_formater[key] = FormaterType::MemGBFormat; } } else if (source.contains(mountUsedRegExp)) { // used @@ -365,11 +363,11 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // mb QString key = QString("hddmb%1").arg(index); m_map[source] = key; - m_formater[key] = MemMBFormat; + m_formater[key] = FormaterType::MemMBFormat; // gb key = QString("hddgb%1").arg(index); m_map.insertMulti(source, key); - m_formater[key] = MemGBFormat; + m_formater[key] = FormaterType::MemGBFormat; } } else if (source.startsWith(QString("hdd/temperature"))) { // hdd temperature @@ -379,7 +377,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hddtemp%1").arg(index); m_map[source] = key; - m_formater[key] = Temperature; + m_formater[key] = FormaterType::Temperature; } } else if (source.startsWith(QString("cpu/system/loadavg"))) { // load average @@ -387,35 +385,35 @@ QStringList AWKeysAggregator::registerSource(const QString &source, time.remove(QString("cpu/system/loadavg")); QString key = QString("la%1").arg(time); m_map[source] = key; - m_formater[key] = FloatTwoSymbols; + m_formater[key] = FormaterType::FloatTwoSymbols; } else if (source == QString("mem/physical/application")) { // app memory // mb m_map[source] = QString("memmb"); - m_formater[QString("memmb")] = MemMBFormat; + m_formater[QString("memmb")] = FormaterType::MemMBFormat; // gb m_map.insertMulti(source, QString("memgb")); - m_formater[QString("memgb")] = MemGBFormat; + m_formater[QString("memgb")] = FormaterType::MemGBFormat; } else if (source == QString("mem/physical/free")) { // free memory // mb m_map[source] = QString("memfreemb"); - m_formater[QString("memfreemb")] = MemMBFormat; + m_formater[QString("memfreemb")] = FormaterType::MemMBFormat; // gb m_map.insertMulti(source, QString("memfreegb")); - m_formater[QString("memfreegb")] = MemGBFormat; + m_formater[QString("memfreegb")] = FormaterType::MemGBFormat; } else if (source == QString("mem/physical/used")) { // used memory // mb m_map[source] = QString("memusedmb"); - m_formater[QString("memusedmb")] = MemMBFormat; + m_formater[QString("memusedmb")] = FormaterType::MemMBFormat; // gb m_map.insertMulti(source, QString("memusedgb")); - m_formater[QString("memusedgb")] = MemGBFormat; + m_formater[QString("memusedgb")] = FormaterType::MemGBFormat; } else if (source == QString("network/current/name")) { // network device m_map[source] = QString("netdev"); - m_formater[QString("netdev")] = NoFormat; + m_formater[QString("netdev")] = FormaterType::NoFormat; } else if (source.contains(netRegExp)) { // network speed QString type = source.contains(QString("receiver")) ? QString("down") @@ -426,62 +424,62 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // kb QString key = QString("%1kb%2").arg(type).arg(index); m_map[source] = key; - m_formater[key] = Integer; + m_formater[key] = FormaterType::Integer; // smart key = QString("%1%2").arg(type).arg(index); m_map.insertMulti(source, key); - m_formater[key] = NetSmartFormat; + m_formater[key] = FormaterType::NetSmartFormat; // units key = QString("%1units%2").arg(type).arg(index); m_map.insertMulti(source, key); - m_formater[key] = NetSmartUnits; + m_formater[key] = FormaterType::NetSmartUnits; } } else if (source.startsWith(QString("upgrade"))) { // package manager QString key = source; key.remove(QString("upgrade/")); m_map[source] = key; - m_formater[key] = IntegerThree; + m_formater[key] = FormaterType::IntegerThree; } else if (source.startsWith(QString("player"))) { // player QString key = source; key.remove(QString("player/")); m_map[source] = key; - m_formater[key] = NoFormat; + m_formater[key] = FormaterType::NoFormat; } else if (source == QString("ps/running/count")) { // running processes count m_map[source] = QString("pscount"); - m_formater[QString("pscount")] = NoFormat; + m_formater[QString("pscount")] = FormaterType::NoFormat; } else if (source == QString("ps/running/list")) { // list of running processes m_map[source] = QString("ps"); - m_formater[QString("ps")] = List; + m_formater[QString("ps")] = FormaterType::List; } else if (source == QString("ps/total/count")) { // total processes count m_map[source] = QString("pstotal"); - m_formater[QString("pstotal")] = NoFormat; + m_formater[QString("pstotal")] = FormaterType::NoFormat; } else if (source.startsWith(QString("quotes"))) { // quotes QString key = source; key.remove(QString("quotes/")); m_map[source] = key; - m_formater[key] = Quotes; + m_formater[key] = FormaterType::Quotes; } else if (source == QString("mem/swap/free")) { // free swap // mb m_map[source] = QString("swapfreemb"); - m_formater[QString("swapfreemb")] = MemMBFormat; + m_formater[QString("swapfreemb")] = FormaterType::MemMBFormat; // gb m_map.insertMulti(source, QString("swapfreegb")); - m_formater[QString("swapfreegb")] = MemGBFormat; + m_formater[QString("swapfreegb")] = FormaterType::MemGBFormat; } else if (source == QString("mem/swap/used")) { // used swap // mb m_map[source] = QString("swapmb"); - m_formater[QString("swapmb")] = MemMBFormat; + m_formater[QString("swapmb")] = FormaterType::MemMBFormat; // gb m_map.insertMulti(source, QString("swapgb")); - m_formater[QString("swapgb")] = MemGBFormat; + m_formater[QString("swapgb")] = FormaterType::MemGBFormat; } else if (source.startsWith(QString("lmsensors/"))) { // temperature int index = m_devices[QString("temp")].indexOf(source); @@ -491,49 +489,50 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("temp%1").arg(index); m_map[source] = key; - m_formater[key] = units == QString("°C") ? Temperature : Integer; + m_formater[key] = units == QString("°C") ? FormaterType::Temperature + : FormaterType::Integer; } } else if (source == QString("Local")) { // time m_map[source] = QString("time"); - m_formater[QString("time")] = Time; + m_formater[QString("time")] = FormaterType::Time; // custom time m_map.insertMulti(source, QString("ctime")); - m_formater[QString("ctime")] = TimeCustom; + m_formater[QString("ctime")] = FormaterType::TimeCustom; // ISO time m_map.insertMulti(source, QString("isotime")); - m_formater[QString("isotime")] = TimeISO; + m_formater[QString("isotime")] = FormaterType::TimeISO; // long time m_map.insertMulti(source, QString("longtime")); - m_formater[QString("longtime")] = TimeLong; + m_formater[QString("longtime")] = FormaterType::TimeLong; // short time m_map.insertMulti(source, QString("shorttime")); - m_formater[QString("shorttime")] = TimeShort; + m_formater[QString("shorttime")] = FormaterType::TimeShort; } else if (source == QString("system/uptime")) { // uptime m_map[source] = QString("uptime"); - m_formater[QString("uptime")] = Uptime; + m_formater[QString("uptime")] = FormaterType::Uptime; // custom uptime m_map.insertMulti(source, QString("cuptime")); - m_formater[QString("cuptime")] = UptimeCustom; + m_formater[QString("cuptime")] = FormaterType::UptimeCustom; } else if (source.startsWith(QString("weather/temperature"))) { // temperature QString key = source; key.remove(QString("weather/")); m_map[source] = key; - m_formater[key] = Temperature; + m_formater[key] = FormaterType::Temperature; } else if (source.startsWith(QString("weather/"))) { // other weather QString key = source; key.remove(QString("weather/")); m_map[source] = key; - m_formater[key] = NoFormat; + m_formater[key] = FormaterType::NoFormat; } else if (source.startsWith(QString("load/load"))) { // load source QString key = source; key.remove(QString("load/")); m_map[source] = key; - m_formater[key] = Temperature; + m_formater[key] = FormaterType::Temperature; } // drop key from dictionary if no one user requested key required it diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index 1e2ef6c..a7087c4 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -36,7 +36,7 @@ class AWKeysAggregator : public QObject Q_PROPERTY(QString tempUnits MEMBER m_tempUnits WRITE setTempUnits); Q_PROPERTY(bool translate MEMBER m_translate WRITE setTranslate); - enum FormaterType { + enum class FormaterType { // general formaters NoFormat = 0, Float, diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index 90c61d1..a859d26 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -112,17 +112,16 @@ QString ExtScript::strRedirect() const { QString value; switch (m_redirect) { - case stdout2stderr: + case Redirect::stdout2stderr: value = QString("stdout2stderr"); break; - case stderr2stdout: + case Redirect::stderr2stdout: value = QString("stderr2stdout"); break; - case swap: + case Redirect::swap: value = QString("swap"); break; - case nothing: - default: + case Redirect::nothing: value = QString("nothing"); break; } @@ -158,7 +157,7 @@ void ExtScript::setPrefix(const QString _prefix) void ExtScript::setRedirect(const Redirect _redirect) { - qCDebug(LOG_LIB) << "Redirect" << _redirect; + qCDebug(LOG_LIB) << "Redirect" << static_cast(_redirect); m_redirect = _redirect; } @@ -169,13 +168,13 @@ void ExtScript::setStrRedirect(const QString _redirect) qCDebug(LOG_LIB) << "Redirect" << _redirect; if (_redirect == QString("stdout2sdterr")) - m_redirect = stdout2stderr; + m_redirect = Redirect::stdout2stderr; else if (_redirect == QString("stderr2sdtout")) - m_redirect = stderr2stdout; + m_redirect = Redirect::stderr2stdout; else if (_redirect == QString("swap")) - m_redirect = swap; + m_redirect = Redirect::swap; else - m_redirect = nothing; + m_redirect = Redirect::nothing; } @@ -376,16 +375,15 @@ void ExtScript::updateValue() QString strValue; switch (m_redirect) { - case stdout2stderr: + case Redirect::stdout2stderr: break; - case stderr2stdout: + case Redirect::stderr2stdout: strValue = QString("%1\n%2").arg(qdebug).arg(qoutput); break; - case swap: + case Redirect::swap: strValue = qdebug; break; - case nothing: - default: + case Redirect::nothing: strValue = qoutput; break; } diff --git a/sources/awesomewidgets/extscript.h b/sources/awesomewidgets/extscript.h index 511c032..5d099af 100644 --- a/sources/awesomewidgets/extscript.h +++ b/sources/awesomewidgets/extscript.h @@ -37,7 +37,7 @@ class ExtScript : public AbstractExtItem Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect) public: - enum Redirect { stdout2stderr = 0, nothing, stderr2stdout, swap }; + enum class Redirect { stdout2stderr = 0, nothing, stderr2stdout, swap }; explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(), @@ -56,7 +56,7 @@ public: void setExecutable(const QString _executable = QString("/usr/bin/true")); void setFilters(const QStringList _filters = QStringList()); void setPrefix(const QString _prefix = QString("")); - void setRedirect(const Redirect _redirect = nothing); + void setRedirect(const Redirect _redirect = Redirect::nothing); void setStrRedirect(const QString _redirect = QString("nothing")); // filters QString applyFilters(QString _value) const; @@ -80,7 +80,7 @@ private: QString m_executable = QString("/usr/bin/true"); QStringList m_filters = QStringList(); QString m_prefix = QString(""); - Redirect m_redirect = nothing; + Redirect m_redirect = Redirect::nothing; // internal properties QVariantMap jsonFilters = QVariantMap(); int times = 0; diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 73c771b..7d033b2 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -102,27 +102,27 @@ QString GraphicalItem::image(const QVariant &value) // paint switch (m_type) { - case Vertical: + case Type::Vertical: m_helper->paintVertical(converted); // scale scale[1] = -2 * static_cast(m_direction) + 1; break; - case Circle: + case Type::Circle: m_helper->paintCircle(converted); // scale scale[0] = -2 * static_cast(m_direction) + 1; break; - case Graph: + case Type::Graph: m_helper->paintGraph(converted); - // direction option is not recognized by this GI type - break; - case Bars: - m_helper->paintBars(converted); - // direction option is not recognized by this GI type + scale[0] = -2 * static_cast(m_direction) + 1; scale[1] = -1; break; - case Horizontal: - default: + case Type::Bars: + m_helper->paintBars(converted); + scale[0] = -2 * static_cast(m_direction) + 1; + scale[1] = -1; + break; + case Type::Horizontal: m_helper->paintHorizontal(converted); // scale scale[0] = -2 * static_cast(m_direction) + 1; @@ -194,20 +194,19 @@ QString GraphicalItem::strType() const { QString value; switch (m_type) { - case Vertical: + case Type::Vertical: value = QString("Vertical"); break; - case Circle: + case Type::Circle: value = QString("Circle"); break; - case Graph: + case Type::Graph: value = QString("Graph"); break; - case Bars: + case Type::Bars: value = QString("Bars"); break; - case Horizontal: - default: + case Type::Horizontal: value = QString("Horizontal"); break; } @@ -226,11 +225,10 @@ QString GraphicalItem::strDirection() const { QString value; switch (m_direction) { - case RightToLeft: + case Direction::RightToLeft: value = QString("RightToLeft"); break; - case LeftToRight: - default: + case Direction::LeftToRight: value = QString("LeftToRight"); break; } @@ -323,7 +321,7 @@ void GraphicalItem::setMinValue(const float _value) void GraphicalItem::setType(const Type _type) { - qCDebug(LOG_LIB) << "Type" << _type; + qCDebug(LOG_LIB) << "Type" << static_cast(_type); m_type = _type; } @@ -334,21 +332,21 @@ void GraphicalItem::setStrType(const QString _type) qCDebug(LOG_LIB) << "Type" << _type; if (_type == QString("Vertical")) - setType(Vertical); + setType(Type::Vertical); else if (_type == QString("Circle")) - setType(Circle); + setType(Type::Circle); else if (_type == QString("Graph")) - setType(Graph); + setType(Type::Graph); else if (_type == QString("Bars")) - setType(Bars); + setType(Type::Bars); else - setType(Horizontal); + setType(Type::Horizontal); } void GraphicalItem::setDirection(const Direction _direction) { - qCDebug(LOG_LIB) << "Direction" << _direction; + qCDebug(LOG_LIB) << "Direction" << static_cast(_direction); m_direction = _direction; } @@ -359,9 +357,9 @@ void GraphicalItem::setStrDirection(const QString _direction) qCDebug(LOG_LIB) << "Direction" << _direction; if (_direction == QString("RightToLeft")) - setDirection(RightToLeft); + setDirection(Direction::RightToLeft); else - setDirection(LeftToRight); + setDirection(Direction::LeftToRight); } diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index 50f4ed5..18d2630 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -49,8 +49,8 @@ class GraphicalItem : public AbstractExtItem Q_PROPERTY(int width READ width WRITE setWidth) public: - enum Direction { LeftToRight = 0, RightToLeft }; - enum Type { Horizontal = 0, Vertical, Circle, Graph, Bars }; + enum class Direction { LeftToRight = 0, RightToLeft = 1 }; + enum class Type { Horizontal = 0, Vertical, Circle, Graph, Bars }; explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(), @@ -83,9 +83,9 @@ public: = QString("color://255,255,255,130")); void setMinValue(const float _value = 0.0); void setMaxValue(const float _value = 100.0); - void setType(const Type _type = Horizontal); + void setType(const Type _type = Type::Horizontal); void setStrType(const QString _type = QString("Horizontal")); - void setDirection(const Direction _direction = LeftToRight); + void setDirection(const Direction _direction = Direction::LeftToRight); void setStrDirection(const QString _direction = QString("LeftToRight")); void setHeight(const int _height = 100); void setUsedKeys(const QStringList _usedKeys = QStringList()); @@ -117,8 +117,8 @@ private: QString m_inactiveColor = QString("color://255,255,255,130"); float m_minValue = 0.0f; float m_maxValue = 100.0f; - Type m_type = Horizontal; - Direction m_direction = LeftToRight; + Type m_type = Type::Horizontal; + Direction m_direction = Direction::LeftToRight; int m_height = 100; QStringList m_usedKeys; int m_width = 100; diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index bf274bd..7aea398 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -144,9 +144,9 @@ void GraphicalItemHelper::paintGraph(const float &value) for (int i = 0; i < m_values.count() - 1; i++) { // some magic here float x1 = i * normX; - float y1 = -m_values.at(i) * normY + 0.5f; + float y1 = m_values.at(i) * normY + 0.5f; float x2 = (i + 1) * normX; - float y2 = -m_values.at(i + 1) * normY + 0.5f; + float y2 = m_values.at(i + 1) * normY + 0.5f; m_scene->addLine(x1, y1, x2, y2, m_activePen); } } From 139554578c38ad5cc5ea8c0508d53357f565092d Mon Sep 17 00:00:00 2001 From: arcan1s Date: Mon, 18 Apr 2016 09:33:35 +0300 Subject: [PATCH 7/9] fix bug introduced by 5c474e822bdb3a603fb322aca75e8a5f612da1b8 No conversion has been applied for total memory values --- sources/awesome-widget/plugin/awkeysaggregator.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index d5b651a..791968f 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -34,8 +34,8 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) // default formaters // memory m_formater[QString("mem")] = FormaterType::Float; - m_formater[QString("memtotmb")] = FormaterType::IntegerFive; - m_formater[QString("memtotgb")] = FormaterType::Float; + m_formater[QString("memtotmb")] = FormaterType::MemMBFormat; + m_formater[QString("memtotgb")] = FormaterType::MemGBFormat; // network m_formater[QString("down")] = FormaterType::NetSmartFormat; m_formater[QString("downkb")] = FormaterType::Integer; @@ -45,8 +45,8 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) m_formater[QString("upunits")] = FormaterType::NetSmartUnits; // swap m_formater[QString("swap")] = FormaterType::Float; - m_formater[QString("swaptotmb")] = FormaterType::IntegerFive; - m_formater[QString("swaptotgb")] = FormaterType::Float; + m_formater[QString("swaptotmb")] = FormaterType::MemMBFormat; + m_formater[QString("swaptotgb")] = FormaterType::MemGBFormat; } @@ -336,8 +336,9 @@ QStringList AWKeysAggregator::registerSource(const QString &source, m_formater[key] = FormaterType::Float; // additional keys m_formater[QString("hddtotmb%1").arg(index)] - = FormaterType::IntegerFive; - m_formater[QString("hddtotgb%1").arg(index)] = FormaterType::Float; + = FormaterType::MemMBFormat; + m_formater[QString("hddtotgb%1").arg(index)] + = FormaterType::MemGBFormat; } } else if (source.contains(mountFreeRegExp)) { // free space From f8e9945bc45746c418def6d07156b56579b85c07 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Wed, 20 Apr 2016 15:50:45 +0300 Subject: [PATCH 8/9] fix configuration dialog error even if user selects Cancel in font dialog html codes pasted --- sources/3rdparty/fontdialog | 2 +- sources/awesome-widget/package/contents/ui/widget.qml | 5 +++++ sources/awesome-widget/plugin/awactions.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sources/3rdparty/fontdialog b/sources/3rdparty/fontdialog index ef47b11..e7bcf8e 160000 --- a/sources/3rdparty/fontdialog +++ b/sources/3rdparty/fontdialog @@ -1 +1 @@ -Subproject commit ef47b1146e88caaa9be4f68d5b42919f36ab051c +Subproject commit e7bcf8ee858e7be3012168e12c7b14ccc28535b4 diff --git a/sources/awesome-widget/package/contents/ui/widget.qml b/sources/awesome-widget/package/contents/ui/widget.qml index d9c7c30..a5ce79b 100644 --- a/sources/awesome-widget/package/contents/ui/widget.qml +++ b/sources/awesome-widget/package/contents/ui/widget.qml @@ -73,6 +73,11 @@ Item { "size": plasmoid.configuration.fontSize } var font = awActions.getFont(defaultFont) + if (font.applied != 1) { + if (debug) console.debug("No font selected") + return + } + var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) textPattern.insert(textPattern.cursorPosition, diff --git a/sources/awesome-widget/plugin/awactions.cpp b/sources/awesome-widget/plugin/awactions.cpp index 93efb56..d0281ca 100644 --- a/sources/awesome-widget/plugin/awactions.cpp +++ b/sources/awesome-widget/plugin/awactions.cpp @@ -154,11 +154,14 @@ QVariantMap AWActions::getFont(const QVariantMap defaultFont) const qCDebug(LOG_AW) << "Default font is" << defaultFont; QVariantMap fontMap; + int ret = 0; CFont defaultCFont = CFont(defaultFont[QString("family")].toString(), defaultFont[QString("size")].toInt(), 400, false, defaultFont[QString("color")].toString()); - CFont font - = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false); + CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, + false, &ret); + + fontMap[QString("applied")] = ret; fontMap[QString("color")] = font.color().name(); fontMap[QString("family")] = font.family(); fontMap[QString("size")] = font.pointSize(); From 82dda14260571db251d0e146decb2b7b14b03ee2 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 21 Apr 2016 16:44:21 +0300 Subject: [PATCH 9/9] add background configuration dialog --- .../package/contents/ui/widget.qml | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/sources/awesome-widget/package/contents/ui/widget.qml b/sources/awesome-widget/package/contents/ui/widget.qml index a5ce79b..cadc9e7 100644 --- a/sources/awesome-widget/package/contents/ui/widget.qml +++ b/sources/awesome-widget/package/contents/ui/widget.qml @@ -61,7 +61,22 @@ Item { height: implicitHeight width: parent.width QtControls.Button { - width: parent.width * 3 / 12 + width: parent.width * 3 / 15 + text: i18n("Bgcolor") + + onClicked: backgroundDialog.visible = true + + QtDialogs.ColorDialog { + id: backgroundDialog + title: i18n("Select a color") + onAccepted: { + var text = textPattern.text + textPattern.text = "" + text + "" + } + } + } + QtControls.Button { + width: parent.width * 3 / 15 text: i18n("Font") iconName: "font" @@ -88,7 +103,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-indent-more" onClicked: { @@ -100,7 +115,7 @@ Item { } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-text-bold" onClicked: { @@ -111,7 +126,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-text-italic" onClicked: { @@ -122,7 +137,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-text-underline" onClicked: { @@ -133,7 +148,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-text-strikethrough" onClicked: { @@ -145,7 +160,7 @@ Item { } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-left" onClicked: { @@ -156,7 +171,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-center" onClicked: { @@ -167,7 +182,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-right" onClicked: { @@ -178,7 +193,7 @@ Item { } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-fill" onClicked: {