mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
more pretty configuration interface
implement quotes changes
This commit is contained in:
parent
fce098cb5c
commit
8dc3510a30
@ -1,7 +1,9 @@
|
||||
+ implement fitlers support to ExtScripts (ApiVer = 3) (#53)
|
||||
+ implement ability to wrap `\n` as new lines (#53)
|
||||
+ implement key sorting in comboboxes
|
||||
+ implement (perc)(bid|ask|price)chg tag support
|
||||
- fix bug with invalid html parsing
|
||||
* more pretty configuration UI
|
||||
* some part of refactoring
|
||||
|
||||
Ver.2.2.2:
|
||||
|
@ -48,6 +48,12 @@ Item {
|
||||
text: AWActions.getAboutText("header")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: AWActions.getAboutText("version")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
@ -62,9 +68,11 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
font.capitalization: Font.SmallCaps
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignBottom
|
||||
textFormat: Text.RichText
|
||||
text: AWActions.getAboutText("copy")
|
||||
}
|
||||
@ -83,8 +91,10 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
verticalAlignment: Text.AlignTop
|
||||
textFormat: Text.RichText
|
||||
text: AWActions.getAboutText("3rdparty")
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ Item {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Button {
|
||||
width: parent.width * 3 / 12
|
||||
text: i18n("Font")
|
||||
iconName: "font"
|
||||
|
||||
@ -98,6 +99,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
@ -111,6 +113,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
@ -123,6 +126,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
@ -135,6 +139,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
@ -147,6 +152,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
@ -160,6 +166,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
@ -172,6 +179,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
@ -184,6 +192,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
@ -196,6 +205,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
|
@ -101,6 +101,8 @@ QString AWActions::getAboutText(const QString type)
|
||||
QString text;
|
||||
if (type == QString("header"))
|
||||
text = QString(NAME);
|
||||
else if (type == QString("version"))
|
||||
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
|
||||
else if (type == QString("description"))
|
||||
text = i18n("A set of minimalistic plasmoid widgets");
|
||||
else if (type == QString("links"))
|
||||
|
@ -315,8 +315,14 @@ QStringList AWKeys::dictKeys(const bool sorted)
|
||||
// quotes
|
||||
for (int i=extQuotes.count()-1; i>=0; i--) {
|
||||
allKeys.append(extQuotes[i]->tag(QString("ask")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("askchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("percaskchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("bid")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("bidchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("percbidchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("price")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("pricechg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("percpricechg")));
|
||||
}
|
||||
// custom
|
||||
for (int i=extScripts.count()-1; i>=0; i--)
|
||||
@ -560,7 +566,7 @@ bool AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
values[QString("down%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
break;
|
||||
}
|
||||
if (device == networkDevice()) {
|
||||
if (device == values[QString("netdev")]) {
|
||||
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if (toolTip != nullptr) toolTip->setData(QString("downTooltip"),
|
||||
data[QString("value")].toFloat());
|
||||
@ -575,7 +581,7 @@ bool AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
break;
|
||||
}
|
||||
if (device == networkDevice()) {
|
||||
if (device == values[QString("netdev")]) {
|
||||
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if (toolTip != nullptr) toolTip->setData(QString("upTooltip"),
|
||||
data[QString("value")].toFloat());
|
||||
@ -716,11 +722,9 @@ QString AWKeys::infoByKey(QString key)
|
||||
if (extUpgrade[i]->tag() != key) continue;
|
||||
return extUpgrade[i]->executable();
|
||||
}
|
||||
else if ((key.startsWith(QString("ask"))) ||
|
||||
(key.startsWith(QString("bid"))) ||
|
||||
(key.startsWith(QString("price"))))
|
||||
else if (key.contains(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))))
|
||||
for (int i=0; i<extQuotes.count(); i++) {
|
||||
if (extQuotes[i]->number() != key.remove(QRegExp(QString("^(ask|bid|price)"))).toInt()) continue;
|
||||
if (extQuotes[i]->number() != key.remove(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))).toInt()) continue;
|
||||
return extQuotes[i]->ticker();
|
||||
}
|
||||
else if (key.startsWith(QString("temp")))
|
||||
@ -1300,25 +1304,6 @@ QString AWKeys::htmlValue(QString key)
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString device = QString("lo");
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint))) {
|
||||
device = rawInterfaceList[i].name();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
int AWKeys::numberCpus()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -87,7 +87,6 @@ private:
|
||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||
bool checkKeys(const QVariantMap data);
|
||||
QString htmlValue(QString key);
|
||||
QString networkDevice();
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units);
|
||||
// find methods
|
||||
|
@ -48,6 +48,12 @@ Item {
|
||||
text: DPAdds.getAboutText("header")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: DPAdds.getAboutText("version")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
@ -62,9 +68,11 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
font.capitalization: Font.SmallCaps
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignBottom
|
||||
textFormat: Text.RichText
|
||||
text: DPAdds.getAboutText("copy")
|
||||
}
|
||||
@ -83,8 +91,10 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
verticalAlignment: Text.AlignTop
|
||||
textFormat: Text.RichText
|
||||
text: DPAdds.getAboutText("3rdparty")
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ Item {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Button {
|
||||
width: parent.width * 3 / 12
|
||||
text: i18n("Font")
|
||||
iconName: "font"
|
||||
|
||||
@ -70,6 +71,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
@ -83,6 +85,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
@ -95,6 +98,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
@ -107,6 +111,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
@ -119,6 +124,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
@ -132,6 +138,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
@ -144,6 +151,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
@ -156,6 +164,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
@ -168,6 +177,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
|
@ -310,6 +310,8 @@ QString DPAdds::getAboutText(const QString type)
|
||||
QString text;
|
||||
if (type == QString("header"))
|
||||
text = QString(NAME);
|
||||
else if (type == QString("version"))
|
||||
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
|
||||
else if (type == QString("description"))
|
||||
text = i18n("A set of minimalistic plasmoid widgets");
|
||||
else if (type == QString("links"))
|
||||
|
@ -45,8 +45,14 @@ ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName, const QStringLis
|
||||
ui->setupUi(this);
|
||||
|
||||
values[QString("ask")] = 0.0;
|
||||
values[QString("askchg")] = 0.0;
|
||||
values[QString("percaskchg")] = 0.0;
|
||||
values[QString("bid")] = 0.0;
|
||||
values[QString("bidchg")] = 0.0;
|
||||
values[QString("percbidchg")] = 0.0;
|
||||
values[QString("price")] = 0.0;
|
||||
values[QString("pricechg")] = 0.0;
|
||||
values[QString("percpricechg")] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
@ -331,22 +337,31 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
||||
// ask
|
||||
fields = doc.elementsByTagName(QString("Ask"));
|
||||
for (int i=0; i<fields.size(); i++) {
|
||||
values[QString("ask")] = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found ask" << values[QString("ask")];
|
||||
float value = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found ask" << value;
|
||||
values[QString("askchg")] = values[QString("ask")] == 0 ? 0.0 : value - values[QString("ask")];
|
||||
values[QString("percaskchg")] = 100 * values[QString("askchg")] / values[QString("ask")];
|
||||
values[QString("ask")] = value;
|
||||
}
|
||||
|
||||
// bid
|
||||
fields = doc.elementsByTagName(QString("Bid"));
|
||||
for (int i=0; i<fields.size(); i++) {
|
||||
values[QString("bid")] = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found bid" << values[QString("bid")];
|
||||
float value = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found bid" << value;
|
||||
values[QString("bidchg")] = values[QString("bid")] == 0 ? 0.0 : value - values[QString("bid")];
|
||||
values[QString("percbidchg")] = 100 * values[QString("bidchg")] / values[QString("bid")];
|
||||
values[QString("bid")] = value;
|
||||
}
|
||||
|
||||
// last trade
|
||||
fields = doc.elementsByTagName(QString("LastTradePriceOnly"));
|
||||
for (int i=0; i<fields.size(); i++) {
|
||||
values[QString("price")] = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found last trade" << values[QString("price")];
|
||||
float value = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found last trade" << value;
|
||||
values[QString("pricechg")] = values[QString("price")] == 0 ? 0.0 : value - values[QString("price")];
|
||||
values[QString("percpricechg")] = 100 * values[QString("pricechg")] / values[QString("price")];
|
||||
values[QString("price")] = value;
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
|
@ -708,8 +708,14 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
for (int i=0; i<externalQuotes.count(); i++) {
|
||||
QMap<QString, float> data = externalQuotes[i]->run();
|
||||
setData(source, externalQuotes[i]->tag(QString("ask")), data[QString("ask")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("askchg")), data[QString("askchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("percaskchg")), data[QString("percaskchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("bid")), data[QString("bid")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("bidchg")), data[QString("bidchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("percbidchg")), data[QString("percbidchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("price")), data[QString("price")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("pricechg")), data[QString("pricechg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("percpricechg")), data[QString("percpricechg")]);
|
||||
}
|
||||
} else if (source == QString("update")) {
|
||||
setData(source, QString("value"), true);
|
||||
|
@ -12,7 +12,7 @@
|
||||
// graphical items api version
|
||||
#define AWGIAPI 1
|
||||
// extquotes api version
|
||||
#define AWEQAPI 1
|
||||
#define AWEQAPI 2
|
||||
// extscript api version
|
||||
#define AWESAPI 3
|
||||
// extupgrade api version
|
||||
|
Loading…
Reference in New Issue
Block a user