mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
udpate aw-kde4
This commit is contained in:
parent
bb88892125
commit
862d14dc0e
@ -409,7 +409,7 @@ QStringList AwesomeWidget::findGraphicalItems()
|
||||
|
||||
QStringList orderedKeys;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
orderedKeys.append(graphicalItems[i]->getName() + graphicalItems[i]->getBar());
|
||||
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||
orderedKeys.sort();
|
||||
QStringList selectedKeys;
|
||||
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||
@ -453,7 +453,7 @@ GraphicalItem *AwesomeWidget::getItemByTag(const QString tag)
|
||||
|
||||
GraphicalItem *item = nullptr;
|
||||
for (int i=0; i< graphicalItems.count(); i++) {
|
||||
if ((graphicalItems[i]->getName() + graphicalItems[i]->getBar()) != tag) continue;
|
||||
if ((graphicalItems[i]->name() + graphicalItems[i]->bar()) != tag) continue;
|
||||
item = graphicalItems[i];
|
||||
break;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ QMap<QString, QString> AwesomeWidget::readDataEngineConfiguration()
|
||||
rawConfig[QString("PKGNULL")] = QString("0");
|
||||
rawConfig[QString("PLAYER")] = QString("mpris");
|
||||
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "extsysmon.conf");
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-extsysmon.conf");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile configFile(fileName);
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
@ -82,7 +82,7 @@ void AwesomeWidget::writeDataEngineConfiguration(const QMap<QString, QString> se
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> config = updateDataEngineConfiguration(settings);
|
||||
QString fileName = KGlobal::dirs()->locateLocal("config", "extsysmon.conf");
|
||||
QString fileName = KGlobal::dirs()->locateLocal("config", "plasma-dataengine-extsysmon.conf");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile configFile(fileName);
|
||||
if (!configFile.open(QIODevice::WriteOnly)) return;
|
||||
@ -148,7 +148,7 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent)
|
||||
uiWidConfig.comboBox_tags->clear();
|
||||
uiWidConfig.comboBox_tags->addItems(getKeys());
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
uiWidConfig.comboBox_tags->addItem(graphicalItems[i]->getName() + graphicalItems[i]->getBar());
|
||||
uiWidConfig.comboBox_tags->addItem(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||
|
||||
// advanced
|
||||
if (configuration[QString("background")].toInt() == 0)
|
||||
@ -302,10 +302,10 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent)
|
||||
uiAdvancedConfig.lineEdit_acOffline->setText(configuration[QString("acOffline")]);
|
||||
uiAdvancedConfig.listWidget_bars->clear();
|
||||
for (int i=0; i<graphicalItems.count(); i++) {
|
||||
QListWidgetItem *item = new QListWidgetItem(graphicalItems[i]->getFileName());
|
||||
QListWidgetItem *item = new QListWidgetItem(graphicalItems[i]->fileName());
|
||||
QStringList tooltip;
|
||||
tooltip.append(i18n("Tag: %1", graphicalItems[i]->getName() + graphicalItems[i]->getBar()));
|
||||
tooltip.append(i18n("Comment: %1", graphicalItems[i]->getComment()));
|
||||
tooltip.append(i18n("Tag: %1", graphicalItems[i]->name() + graphicalItems[i]->bar()));
|
||||
tooltip.append(i18n("Comment: %1", graphicalItems[i]->comment()));
|
||||
item->setToolTip(tooltip.join(QChar('\n')));
|
||||
uiAdvancedConfig.listWidget_bars->addItem(item);
|
||||
}
|
||||
@ -377,11 +377,11 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent)
|
||||
QList<ExtScript *> externalScripts = initScripts();
|
||||
uiDEConfig.listWidget_custom->clear();
|
||||
for (int i=0; i<externalScripts.count(); i++) {
|
||||
QListWidgetItem *item = new QListWidgetItem(externalScripts[i]->getFileName());
|
||||
QListWidgetItem *item = new QListWidgetItem(externalScripts[i]->fileName());
|
||||
QStringList tooltip;
|
||||
tooltip.append(i18n("Name: %1", externalScripts[i]->getName()));
|
||||
tooltip.append(i18n("Comment: %1", externalScripts[i]->getComment()));
|
||||
tooltip.append(i18n("Exec: %1", externalScripts[i]->getExec()));
|
||||
tooltip.append(i18n("Name: %1", externalScripts[i]->name()));
|
||||
tooltip.append(i18n("Comment: %1", externalScripts[i]->comment()));
|
||||
tooltip.append(i18n("Exec: %1", externalScripts[i]->exec()));
|
||||
item->setToolTip(tooltip.join(QChar('\n')));
|
||||
uiDEConfig.listWidget_custom->addItem(item);
|
||||
}
|
||||
@ -722,7 +722,7 @@ void AwesomeWidget::addBar()
|
||||
while (true) {
|
||||
bool exit = true;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
if (graphicalItems[i]->getName() == QString("bar%1").arg(number)) {
|
||||
if (graphicalItems[i]->name() == QString("bar%1").arg(number)) {
|
||||
number++;
|
||||
exit = false;
|
||||
break;
|
||||
@ -800,7 +800,7 @@ void AwesomeWidget::contextMenuBars(const QPoint pos)
|
||||
copyBar(uiAdvancedConfig.listWidget_bars->currentItem()->text());
|
||||
else if (action == remove)
|
||||
for (int i=0; i<graphicalItems.count(); i++) {
|
||||
if (graphicalItems[i]->getFileName() != uiAdvancedConfig.listWidget_bars->currentItem()->text())
|
||||
if (graphicalItems[i]->fileName() != uiAdvancedConfig.listWidget_bars->currentItem()->text())
|
||||
continue;
|
||||
graphicalItems[i]->tryDelete();
|
||||
graphicalItems.takeAt(i);
|
||||
@ -856,7 +856,7 @@ void AwesomeWidget::copyBar(const QString original)
|
||||
while (true) {
|
||||
bool exit = true;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
if (graphicalItems[i]->getName() == QString("bar%1").arg(number)) {
|
||||
if (graphicalItems[i]->name() == QString("bar%1").arg(number)) {
|
||||
number++;
|
||||
exit = false;
|
||||
break;
|
||||
@ -880,20 +880,20 @@ void AwesomeWidget::copyBar(const QString original)
|
||||
|
||||
GraphicalItem *originalItem = nullptr;
|
||||
for (int i=0; i<graphicalItems.count(); i++) {
|
||||
if (graphicalItems[i]->getFileName() != original) continue;
|
||||
if (graphicalItems[i]->fileName() != original) continue;
|
||||
originalItem = graphicalItems[i];
|
||||
break;
|
||||
}
|
||||
GraphicalItem *item = new GraphicalItem(0, name, dirs, debug);
|
||||
item->setName(QString("bar%1").arg(number));
|
||||
item->setComment(originalItem->getComment());
|
||||
item->setBar(originalItem->getBar());
|
||||
item->setActiveColor(originalItem->getActiveColor());
|
||||
item->setInactiveColor(originalItem->getInactiveColor());
|
||||
item->setType(originalItem->getStrType());
|
||||
item->setDirection(originalItem->getStrDirection());
|
||||
item->setHeight(originalItem->getHeight());
|
||||
item->setWidth(originalItem->getWidth());
|
||||
item->setComment(originalItem->comment());
|
||||
item->setBar(originalItem->bar());
|
||||
item->setActiveColor(originalItem->activeColor());
|
||||
item->setInactiveColor(originalItem->inactiveColor());
|
||||
item->setType(originalItem->type());
|
||||
item->setDirection(originalItem->direction());
|
||||
item->setHeight(originalItem->height());
|
||||
item->setWidth(originalItem->width());
|
||||
delete originalItem;
|
||||
|
||||
item->showConfiguration(bars);
|
||||
@ -916,13 +916,13 @@ void AwesomeWidget::copyCustomCommand(const QString original)
|
||||
ExtScript *originalScript = new ExtScript(0, original, dirs, debug);
|
||||
ExtScript *script = new ExtScript(0, name, dirs, debug);
|
||||
script->setActive(originalScript->isActive());
|
||||
script->setComment(originalScript->getComment());
|
||||
script->setExec(originalScript->getExec());
|
||||
script->setComment(originalScript->comment());
|
||||
script->setExecutable(originalScript->executable());
|
||||
script->setHasOutput(originalScript->hasOutput());
|
||||
script->setInterval(originalScript->getInterval());
|
||||
script->setName(originalScript->getName());
|
||||
script->setPrefix(originalScript->getPrefix());
|
||||
script->setRedirect(originalScript->getStrRedirect());
|
||||
script->setInterval(originalScript->interval());
|
||||
script->setName(originalScript->name());
|
||||
script->setPrefix(originalScript->prefix());
|
||||
script->setRedirect(originalScript->redirect());
|
||||
delete originalScript;
|
||||
|
||||
script->showConfiguration();
|
||||
@ -943,7 +943,7 @@ void AwesomeWidget::editBar(QListWidgetItem *item)
|
||||
bars.append(keys.filter((QRegExp(QString("^bat.*")))));
|
||||
|
||||
for (int i=0; i<graphicalItems.count(); i++) {
|
||||
if (graphicalItems[i]->getFileName() != item->text()) continue;
|
||||
if (graphicalItems[i]->fileName() != item->text()) continue;
|
||||
graphicalItems[i]->showConfiguration(bars);
|
||||
break;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*bat"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != data.keys()[i]) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != data.keys()[i]) continue;
|
||||
values[foundBars[j]] = values[data.keys()[i]];
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != QString("cpu")) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("cpu")) continue;
|
||||
values[foundBars[j]] = QString("%1").arg(data[QString("value")].toFloat());
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
values[QString("cpu") + number] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != (QString("cpu") + number)) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != (QString("cpu") + number)) continue;
|
||||
values[foundBars[j]] = values[QString("cpu") + number];
|
||||
}
|
||||
}
|
||||
@ -285,7 +285,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
values[QString("gpu")] = QString("%1").arg(data[QString("GPU")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*gpu"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != QString("gpu")) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("gpu")) continue;
|
||||
values[foundBars[j]] = values[QString("gpu")];
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*hdd([0-9].*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != (QString("hdd") + QString::number(i))) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != (QString("hdd") + QString::number(i))) continue;
|
||||
values[foundBars[j]] = values[QString("hdd") + QString::number(i)];
|
||||
}
|
||||
}
|
||||
@ -370,7 +370,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
}
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*mem"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != QString("mem")) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("mem")) continue;
|
||||
values[foundBars[j]] = values[QString("mem")];
|
||||
}
|
||||
}
|
||||
@ -438,7 +438,7 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng
|
||||
}
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*swap"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->getBar() != QString("swap")) continue;
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("swap")) continue;
|
||||
values[foundBars[j]] = values[QString("swap")];
|
||||
}
|
||||
}
|
||||
|
@ -29,11 +29,13 @@
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
fileName(desktopName),
|
||||
dirs(directories),
|
||||
m_fileName(desktopName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::GraphicalItem)
|
||||
{
|
||||
@ -53,14 +55,14 @@ GraphicalItem::~GraphicalItem()
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getImage(const float value)
|
||||
QString GraphicalItem::image(const float value)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
|
||||
if (_bar == QString("none")) return QString("");
|
||||
if (m_bar == QString("none")) return QString("");
|
||||
|
||||
QColor active = stringToColor(_activeColor);
|
||||
QColor inactive = stringToColor(_inactiveColor);
|
||||
QColor active = stringToColor(m_activeColor);
|
||||
QColor inactive = stringToColor(m_inactiveColor);
|
||||
float percent = value / 100.0;
|
||||
int scale[2] = {1, 1};
|
||||
QPen pen = QPen();
|
||||
@ -72,47 +74,51 @@ QString GraphicalItem::getImage(const float value)
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->resize(_width + 5.0, _height + 5.0);
|
||||
view->resize(m_width + 5.0, m_height + 5.0);
|
||||
|
||||
// paint
|
||||
switch(_type) {
|
||||
switch(m_type) {
|
||||
case Vertical:
|
||||
pen.setWidth(_width);
|
||||
pen.setWidth(m_width);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(0.5 * _width, -0.5 * _width, 0.5 * _width, (1.0 - percent) * _height - 0.5 * _width, pen);
|
||||
scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width,
|
||||
(1.0 - percent) * m_height - 0.5 * m_width, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(0.5 * _width, (1.0 - percent) * _height + 0.5 * _width, 0.5 * _width, _height + 0.5 * _width, pen);
|
||||
scene->addLine(0.5 * m_width, (1.0 - percent) * m_height + 0.5 * m_width,
|
||||
0.5 * m_width, m_height + 0.5 * m_width, pen);
|
||||
// scale
|
||||
scale[1] = -2 * (int)_direction + 1;
|
||||
scale[1] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
case Circle:
|
||||
QGraphicsEllipseItem *circle;
|
||||
pen.setWidth(1.0);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(inactive, Qt::SolidPattern));
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(inactive, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- (1.0 - percent) * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0 - percent * 360.0 * 16.0);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(active, Qt::SolidPattern));
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(active, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- percent * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0);
|
||||
// scale
|
||||
scale[0] = -2 *(int)_direction + 1;
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
default:
|
||||
pen.setWidth(_height);
|
||||
pen.setWidth(m_height);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(percent * _width + 0.5 * _height, 0.5 * _height, _width + 0.5 * _height, 0.5 * _height, pen);
|
||||
scene->addLine(percent * m_width + 0.5 * m_height, 0.5 * m_height,
|
||||
m_width + 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(-0.5 * _height, 0.5 * _height, percent * _width - 0.5 * _height, 0.5 * _height, pen);
|
||||
scene->addLine(-0.5 * m_height, 0.5 * m_height,
|
||||
percent * m_width - 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// scale
|
||||
scale[0] = -2 * (int)_direction + 1;
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -129,68 +135,76 @@ QString GraphicalItem::getImage(const float value)
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getFileName()
|
||||
QString GraphicalItem::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return fileName;
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getName()
|
||||
int GraphicalItem::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _name;
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getComment()
|
||||
QString GraphicalItem::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _comment;
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getBar()
|
||||
QString GraphicalItem::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _bar;
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getActiveColor()
|
||||
QString GraphicalItem::bar()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _activeColor;
|
||||
return m_bar;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getInactiveColor()
|
||||
QString GraphicalItem::activeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _inactiveColor;
|
||||
return m_activeColor;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Type GraphicalItem::getType()
|
||||
QString GraphicalItem::inactiveColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _type;
|
||||
return m_inactiveColor;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getStrType()
|
||||
GraphicalItem::Type GraphicalItem::type()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strType()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch(_type) {
|
||||
switch(m_type) {
|
||||
case Vertical:
|
||||
value = QString("Vertical");
|
||||
break;
|
||||
@ -206,20 +220,20 @@ QString GraphicalItem::getStrType()
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Direction GraphicalItem::getDirection()
|
||||
GraphicalItem::Direction GraphicalItem::direction()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _direction;
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::getStrDirection()
|
||||
QString GraphicalItem::strDirection()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch (_direction) {
|
||||
switch (m_direction) {
|
||||
case RightToLeft:
|
||||
value = QString("RightToLeft");
|
||||
break;
|
||||
@ -232,117 +246,145 @@ QString GraphicalItem::getStrDirection()
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::getHeight()
|
||||
int GraphicalItem::height()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _height;
|
||||
return m_height;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::getWidth()
|
||||
int GraphicalItem::width()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return _width;
|
||||
return m_width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setName(const QString name)
|
||||
void GraphicalItem::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << name;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
_name = name;
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setComment(const QString comment)
|
||||
void GraphicalItem::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << comment;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
_comment = comment;
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setBar(const QString bar)
|
||||
void GraphicalItem::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Bar" << bar;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setBar(const QString _bar)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
|
||||
|
||||
_bar = bar;
|
||||
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("gpu")))) &&
|
||||
(!_bar.contains(QRegExp(QString("mem")))) &&
|
||||
(!_bar.contains(QRegExp(QString("swap")))) &&
|
||||
(!_bar.contains(QRegExp(QString("hdd[0-9].*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("bat.*")))))
|
||||
_bar = QString("none");
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setActiveColor(const QString color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
|
||||
|
||||
_activeColor = color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setInactiveColor(const QString color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
|
||||
|
||||
_inactiveColor = color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setType(const QString type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
||||
|
||||
if (type == QString("Vertical"))
|
||||
_type = Vertical;
|
||||
else if (type == QString("Circle"))
|
||||
_type = Circle;
|
||||
m_bar = QString("none");
|
||||
else
|
||||
_type = Horizontal;
|
||||
m_bar = _bar;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setDirection(const QString direction)
|
||||
void GraphicalItem::setActiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << direction;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
if (direction == QString("RightToLeft"))
|
||||
_direction = RightToLeft;
|
||||
m_activeColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setInactiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_inactiveColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setType(const Type _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
m_type = _type;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrType(const QString _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
if (_type == QString("Vertical"))
|
||||
setType(Vertical);
|
||||
else if (_type == QString("Circle"))
|
||||
setType(Circle);
|
||||
else
|
||||
_direction = LeftToRight;
|
||||
setType(Horizontal);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setHeight(const int height)
|
||||
void GraphicalItem::setDirection(const Direction _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Height" << height;
|
||||
if (height <= 0) return;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
_height = height;
|
||||
m_direction = _direction;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setWidth(const int width)
|
||||
void GraphicalItem::setStrDirection(const QString _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Width" << width;
|
||||
if (width <= 0) return;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
_width = width;
|
||||
if (_direction == QString("RightToLeft"))
|
||||
setDirection(RightToLeft);
|
||||
else
|
||||
setDirection(LeftToRight);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setHeight(const int _height)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
|
||||
if (_height <= 0) return;
|
||||
|
||||
m_height = _height;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setWidth(const int _width)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
|
||||
if (_width <= 0) return;
|
||||
|
||||
m_width = _width;
|
||||
}
|
||||
|
||||
|
||||
@ -350,19 +392,21 @@ void GraphicalItem::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(dirs[i]).entryList(QDir::Files).contains(fileName)) continue;
|
||||
QSettings settings(dirs[i] + QDir::separator() + fileName, QSettings::IniFormat);
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), _name).toString());
|
||||
setComment(settings.value(QString("Comment"), _comment).toString());
|
||||
setBar(settings.value(QString("X-AW-Value"), _bar).toString());
|
||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), _activeColor).toString());
|
||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), _inactiveColor).toString());
|
||||
setType(settings.value(QString("X-AW-Type"), getStrType()).toString());
|
||||
setDirection(settings.value(QString("X-AW-Direction"), getStrDirection()).toString());
|
||||
setHeight(settings.value(QString("X-AW-Height"), QString::number(_height)).toInt());
|
||||
setWidth(settings.value(QString("X-AW-Width"), QString::number(_width)).toInt());
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWGIAPI).toInt());
|
||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||
setStrType(settings.value(QString("X-AW-Type"), strType()).toString());
|
||||
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
|
||||
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
||||
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
@ -372,27 +416,29 @@ void GraphicalItem::showConfiguration(const QStringList tags)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->label_nameValue->setText(_name);
|
||||
ui->lineEdit_comment->setText(_comment);
|
||||
ui->label_nameValue->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->comboBox_value->addItems(tags);
|
||||
ui->comboBox_value->addItem(_bar);
|
||||
ui->comboBox_value->addItem(m_bar);
|
||||
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
|
||||
ui->pushButton_activeColor->setText(_activeColor);
|
||||
ui->pushButton_inactiveColor->setText(_inactiveColor);
|
||||
ui->comboBox_type->setCurrentIndex((int)_type);
|
||||
ui->comboBox_direction->setCurrentIndex((int)_direction);
|
||||
ui->spinBox_height->setValue(_height);
|
||||
ui->spinBox_width->setValue(_width);
|
||||
ui->pushButton_activeColor->setText(m_activeColor);
|
||||
ui->pushButton_inactiveColor->setText(m_inactiveColor);
|
||||
ui->comboBox_type->setCurrentIndex(static_cast<int>(m_type));
|
||||
ui->comboBox_direction->setCurrentIndex(static_cast<int>(m_direction));
|
||||
ui->spinBox_height->setValue(m_height);
|
||||
ui->spinBox_width->setValue(m_width);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return;
|
||||
|
||||
setName(ui->label_nameValue->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWGIAPI);
|
||||
setBar(ui->comboBox_value->currentText());
|
||||
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
|
||||
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
|
||||
setType(ui->comboBox_type->currentText());
|
||||
setDirection(ui->comboBox_direction->currentText());
|
||||
setStrType(ui->comboBox_type->currentText());
|
||||
setStrDirection(ui->comboBox_direction->currentText());
|
||||
setHeight(ui->spinBox_height->value());
|
||||
setWidth(ui->spinBox_width->value());
|
||||
|
||||
@ -404,9 +450,9 @@ void GraphicalItem::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << dirs[i] + QDir::separator() + fileName <<
|
||||
QFile::remove(dirs[i] + QDir::separator() + fileName);
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
}
|
||||
|
||||
|
||||
@ -414,22 +460,23 @@ void GraphicalItem::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(dirs[0] + QDir::separator() + fileName, QSettings::IniFormat);
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), _name);
|
||||
settings.setValue(QString("Comment"), _comment);
|
||||
settings.setValue(QString("X-AW-Value"), _bar);
|
||||
settings.setValue(QString("X-AW-ActiveColor"), _activeColor);
|
||||
settings.setValue(QString("X-AW-InactiveColor"), _inactiveColor);
|
||||
settings.setValue(QString("X-AW-Type"), getStrType());
|
||||
settings.setValue(QString("X-AW-Direction"), getStrDirection());
|
||||
settings.setValue(QString("X-AW-Height"), _height);
|
||||
settings.setValue(QString("X-AW-Width"), _width);
|
||||
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||
settings.setValue(QString("X-AW-Type"), strType());
|
||||
settings.setValue(QString("X-AW-Direction"), strDirection());
|
||||
settings.setValue(QString("X-AW-Height"), m_height);
|
||||
settings.setValue(QString("X-AW-Width"), m_width);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
@ -448,17 +495,17 @@ void GraphicalItem::changeColor()
|
||||
colorText.append(QString("%1").arg(newColor.green()));
|
||||
colorText.append(QString("%1").arg(newColor.blue()));
|
||||
colorText.append(QString("%1").arg(newColor.alpha()));
|
||||
((QPushButton *)sender())->setText(colorText.join(QChar(',')));
|
||||
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
||||
}
|
||||
|
||||
|
||||
QColor GraphicalItem::stringToColor(const QString color)
|
||||
QColor GraphicalItem::stringToColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
QColor qcolor;
|
||||
QStringList listColor = color.split(QChar(','));
|
||||
QStringList listColor = _color.split(QChar(','));
|
||||
while (listColor.count() < 4)
|
||||
listColor.append(QString("0"));
|
||||
qcolor.setRed(listColor[0].toInt());
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QColor>
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GraphicalItem;
|
||||
}
|
||||
@ -28,6 +29,16 @@ class GraphicalItem;
|
||||
class GraphicalItem : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||
Q_PROPERTY(Type type READ type WRITE setType)
|
||||
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
|
||||
Q_PROPERTY(int height READ height WRITE setHeight)
|
||||
Q_PROPERTY(int width READ width WRITE setWidth)
|
||||
|
||||
public:
|
||||
enum Direction {
|
||||
@ -43,30 +54,34 @@ public:
|
||||
explicit GraphicalItem(QWidget *parent = 0, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~GraphicalItem();
|
||||
QString getImage(const float value);
|
||||
QString fileName();
|
||||
QString image(const float value);
|
||||
// get methods
|
||||
QString getFileName();
|
||||
QString getName();
|
||||
QString getComment();
|
||||
QString getBar();
|
||||
QString getActiveColor();
|
||||
QString getInactiveColor();
|
||||
Type getType();
|
||||
QString getStrType();
|
||||
Direction getDirection();
|
||||
QString getStrDirection();
|
||||
int getHeight();
|
||||
int getWidth();
|
||||
int apiVersion();
|
||||
QString name();
|
||||
QString comment();
|
||||
QString bar();
|
||||
QString activeColor();
|
||||
QString inactiveColor();
|
||||
Type type();
|
||||
QString strType();
|
||||
Direction direction();
|
||||
QString strDirection();
|
||||
int height();
|
||||
int width();
|
||||
// set methods
|
||||
void setName(const QString name = QString("none"));
|
||||
void setComment(const QString comment = QString("empty"));
|
||||
void setBar(const QString bar = QString("cpu"));
|
||||
void setActiveColor(const QString color = QString("0,0,0,130"));
|
||||
void setInactiveColor(const QString color = QString("255,255,255,130"));
|
||||
void setType(const QString type = QString("Horizontal"));
|
||||
void setDirection(const QString direction = QString("LeftToRight"));
|
||||
void setHeight(const int height = 100);
|
||||
void setWidth(const int width = 100);
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setBar(const QString _bar = QString("cpu"));
|
||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
||||
void setType(const Type _type = Horizontal);
|
||||
void setStrType(const QString _type = QString("Horizontal"));
|
||||
void setDirection(const Direction _direction = LeftToRight);
|
||||
void setStrDirection(const QString _direction = QString("LeftToRight"));
|
||||
void setHeight(const int _height = 100);
|
||||
void setWidth(const int _width = 100);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
@ -78,21 +93,23 @@ private slots:
|
||||
void changeColor();
|
||||
|
||||
private:
|
||||
QColor stringToColor(const QString color);
|
||||
QString fileName;
|
||||
QStringList dirs;
|
||||
QColor stringToColor(const QString _color);
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::GraphicalItem *ui;
|
||||
// properties
|
||||
QString _name = QString("none");
|
||||
QString _comment = QString("empty");
|
||||
QString _bar = QString("cpu");
|
||||
QString _activeColor = QString("0,0,0,130");
|
||||
QString _inactiveColor = QString("255,255,255,130");
|
||||
Type _type = Horizontal;
|
||||
Direction _direction = LeftToRight;
|
||||
int _height = 100;
|
||||
int _width = 100;
|
||||
int m_apiVersion = 0;
|
||||
QString m_name = QString("none");
|
||||
QString m_comment = QString("empty");
|
||||
QString m_bar = QString("cpu");
|
||||
QString m_activeColor = QString("0,0,0,130");
|
||||
QString m_inactiveColor = QString("255,255,255,130");
|
||||
Type m_type = Horizontal;
|
||||
Direction m_direction = LeftToRight;
|
||||
int m_height = 100;
|
||||
int m_width = 100;
|
||||
};
|
||||
|
||||
|
||||
#endif /* GRAPHICALITEM_H */
|
||||
|
@ -85,7 +85,7 @@ void AwesomeWidget::updateText(const bool clear)
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
text.replace(QString("$") + foundKeys[i], values[foundKeys[i]]);
|
||||
for (int i=0; i<foundBars.count(); i++)
|
||||
text.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->getImage(values[foundBars[i]].toFloat()));
|
||||
text.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->image(values[foundBars[i]].toFloat()));
|
||||
text.replace(QString("$\\$\\"), QString("$$"));
|
||||
}
|
||||
textLabel->setText(formatLine[0] + text + formatLine[1]);
|
||||
|
@ -6,8 +6,6 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
find_package (KDE4 REQUIRED)
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
|
||||
add_subdirectory (po)
|
||||
|
||||
include (KDE4Defaults)
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
|
@ -52,7 +52,7 @@ if (BUILD_KDE4)
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
|
||||
else ()
|
||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||
|
Loading…
Reference in New Issue
Block a user