mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-10-30 21:03:41 +00:00 
			
		
		
		
	update gi to use desktop conf files
This commit is contained in:
		| @ -27,6 +27,7 @@ file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp | |||||||
| set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h) | set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h) | ||||||
| file (GLOB SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui) | file (GLOB SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui) | ||||||
| file (GLOB SUBPROJECT_NOTIFY *.notifyrc) | file (GLOB SUBPROJECT_NOTIFY *.notifyrc) | ||||||
|  | set (SUBPROJECT_DESKTOPS ${CMAKE_CURRENT_SOURCE_DIR}/desktops) | ||||||
|  |  | ||||||
| # prepare | # prepare | ||||||
| configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP}) | configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP}) | ||||||
| @ -41,3 +42,4 @@ target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${K | |||||||
| install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}) | install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}) | ||||||
| install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR}) | install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR}) | ||||||
| install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME}) | install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME}) | ||||||
|  | install (DIRECTORY ${SUBPROJECT_DESKTOPS} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME}) | ||||||
|  | |||||||
| @ -59,8 +59,8 @@ AwesomeWidget::AwesomeWidget(QObject *parent, const QVariantList &args) | |||||||
|     // text format init |     // text format init | ||||||
|     formatLine.append(QString("")); |     formatLine.append(QString("")); | ||||||
|     formatLine.append(QString("")); |     formatLine.append(QString("")); | ||||||
|     GraphicalItem *item = new GraphicalItem(this, QString("test"), QString("${cpu;255,0,0,255;0,255,0,255;2;-1;300;500}"), true); | //    GraphicalItem *item = new GraphicalItem(this, QString("test"), QString("${cpu;255,0,0,255;0,255,0,255;2;-1;300;500}"), true); | ||||||
|     qDebug() << item->getImage(75.0); | //    qDebug() << item->getImage(75.0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								sources/awesome-widget/desktops/aw-bat-bar.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								sources/awesome-widget/desktops/aw-bat-bar.desktop
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | [Desktop Entry] | ||||||
|  | Encoding=UTF-8 | ||||||
|  | Name=bar3 | ||||||
|  | Comment=Simple bat bar | ||||||
|  | X-AW-Value=bat | ||||||
|  | X-AW-ActiveColor="255,255,255,0" | ||||||
|  | X-AW-InactiveColor="255,255,255,255" | ||||||
|  | X-AW-Type=Horizontal | ||||||
|  | X-AW-Direction=LeftToRight | ||||||
|  | X-AW-Height=25 | ||||||
|  | X-AW-Width=100 | ||||||
							
								
								
									
										11
									
								
								sources/awesome-widget/desktops/aw-cpu-bar.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								sources/awesome-widget/desktops/aw-cpu-bar.desktop
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | [Desktop Entry] | ||||||
|  | Encoding=UTF-8 | ||||||
|  | Name=bar0 | ||||||
|  | Comment=Simple cpu bar | ||||||
|  | X-AW-Value=cpu | ||||||
|  | X-AW-ActiveColor="255,255,255,0" | ||||||
|  | X-AW-InactiveColor="255,255,255,255" | ||||||
|  | X-AW-Type=Horizontal | ||||||
|  | X-AW-Direction=LeftToRight | ||||||
|  | X-AW-Height=25 | ||||||
|  | X-AW-Width=100 | ||||||
							
								
								
									
										11
									
								
								sources/awesome-widget/desktops/aw-mem-bar.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								sources/awesome-widget/desktops/aw-mem-bar.desktop
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | [Desktop Entry] | ||||||
|  | Encoding=UTF-8 | ||||||
|  | Name=bar1 | ||||||
|  | Comment=Simple mem bar | ||||||
|  | X-AW-Value=mem | ||||||
|  | X-AW-ActiveColor="255,255,255,0" | ||||||
|  | X-AW-InactiveColor="255,255,255,255" | ||||||
|  | X-AW-Type=Horizontal | ||||||
|  | X-AW-Direction=LeftToRight | ||||||
|  | X-AW-Height=25 | ||||||
|  | X-AW-Width=100 | ||||||
							
								
								
									
										11
									
								
								sources/awesome-widget/desktops/aw-swap-bar.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								sources/awesome-widget/desktops/aw-swap-bar.desktop
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | [Desktop Entry] | ||||||
|  | Encoding=UTF-8 | ||||||
|  | Name=bar2 | ||||||
|  | Comment=Simple swap bar | ||||||
|  | X-AW-Value=swap | ||||||
|  | X-AW-ActiveColor="255,255,255,0" | ||||||
|  | X-AW-InactiveColor="255,255,255,255" | ||||||
|  | X-AW-Type=Horizontal | ||||||
|  | X-AW-Direction=LeftToRight | ||||||
|  | X-AW-Height=25 | ||||||
|  | X-AW-Width=100 | ||||||
| @ -19,21 +19,22 @@ | |||||||
|  |  | ||||||
| #include <QBuffer> | #include <QBuffer> | ||||||
| #include <QDebug> | #include <QDebug> | ||||||
|  | #include <QDir> | ||||||
| #include <QGraphicsEllipseItem> | #include <QGraphicsEllipseItem> | ||||||
| #include <QGraphicsScene> | #include <QGraphicsScene> | ||||||
| #include <QGraphicsView> | #include <QGraphicsView> | ||||||
|  | #include <QSettings> | ||||||
|  |  | ||||||
| #include <pdebug/pdebug.h> | #include <pdebug/pdebug.h> | ||||||
|  |  | ||||||
|  |  | ||||||
| GraphicalItem::GraphicalItem(QObject *wid, const QString assignName, const QString tag, const bool debugCmd) | GraphicalItem::GraphicalItem(QObject *wid, const QString desktopName, const QStringList directories, const bool debugCmd) | ||||||
|     : QObject(wid), |     : QObject(wid), | ||||||
|       name(assignName), |       fileName(desktopName), | ||||||
|  |       dirs(directories), | ||||||
|       debug(debugCmd) |       debug(debugCmd) | ||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Name" << name; |     readConfiguration(); | ||||||
|     parseTag(tag); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -47,7 +48,7 @@ QString GraphicalItem::getImage(const float value) | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Value" << value; |     if (debug) qDebug() << PDEBUG << ":" << "Value" << value; | ||||||
|     if (bar == QString("none")) return QString(""); |     if (_bar == QString("none")) return QString(""); | ||||||
|  |  | ||||||
|     float percent = value / 100.0; |     float percent = value / 100.0; | ||||||
|     int scale[2] = {1, 1}; |     int scale[2] = {1, 1}; | ||||||
| @ -59,47 +60,47 @@ QString GraphicalItem::getImage(const float value) | |||||||
|     view->setContentsMargins(0, 0, 0, 0); |     view->setContentsMargins(0, 0, 0, 0); | ||||||
|     view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |     view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||||||
|     view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |     view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||||||
|     view->resize(width + 5.0, height + 5.0); |     view->resize(_width + 5.0, _height + 5.0); | ||||||
|  |  | ||||||
|     // paint |     // paint | ||||||
|     switch(type) { |     switch(_type) { | ||||||
|     case Vertical: |     case Vertical: | ||||||
|         pen.setWidth(width); |         pen.setWidth(_width); | ||||||
|         // inactive |         // inactive | ||||||
|         pen.setColor(inactiveColor); |         pen.setColor(_inactiveColor); | ||||||
|         scene->addLine(0.5 * width, 0.0, 0.5 * width, height, pen); |         scene->addLine(0.5 * _width, 0.0, 0.5 * _width, _height, pen); | ||||||
|         // active |         // active | ||||||
|         pen.setColor(activeColor); |         pen.setColor(_activeColor); | ||||||
|         scene->addLine(0.5 * width, (1.0 - percent) * height + 0.5 * width, 0.5 * width, height + 0.5 * width, pen); |         scene->addLine(0.5 * _width, (1.0 - percent) * _height + 0.5 * _width, 0.5 * _width, _height + 0.5 * _width, pen); | ||||||
|         // scale |         // scale | ||||||
|         scale[1] = (int)direction; |         scale[1] = (int)_direction; | ||||||
|         break; |         break; | ||||||
|     case Circle: |     case Circle: | ||||||
|         QGraphicsEllipseItem *circle; |         QGraphicsEllipseItem *circle; | ||||||
|         pen.setWidth(1.0); |         pen.setWidth(1.0); | ||||||
|         // inactive |         // inactive | ||||||
|         pen.setColor(inactiveColor); |         pen.setColor(_inactiveColor); | ||||||
|         circle = scene->addEllipse(0.0, 0.0, width, height, pen, QBrush(inactiveColor, Qt::SolidPattern)); |         circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(_inactiveColor, Qt::SolidPattern)); | ||||||
|         circle->setSpanAngle((1.0 - percent) * 360.0 * 16.0); |         circle->setSpanAngle((1.0 - percent) * 360.0 * 16.0); | ||||||
|         circle->setStartAngle(180.0 * 16.0 - (1.0 - percent) * 360.0 * 16.0); |         circle->setStartAngle(180.0 * 16.0 - (1.0 - percent) * 360.0 * 16.0); | ||||||
|         // active |         // active | ||||||
|         pen.setColor(activeColor); |         pen.setColor(_activeColor); | ||||||
|         circle = scene->addEllipse(0.0, 0.0, width, height, pen, QBrush(activeColor, Qt::SolidPattern)); |         circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(_activeColor, Qt::SolidPattern)); | ||||||
|         circle->setSpanAngle(percent * 360.0 * 16.0); |         circle->setSpanAngle(percent * 360.0 * 16.0); | ||||||
|         circle->setStartAngle(180.0 * 16.0); |         circle->setStartAngle(180.0 * 16.0); | ||||||
|         // scale |         // scale | ||||||
|         scale[0] = (int)direction; |         scale[0] = (int)_direction; | ||||||
|         break; |         break; | ||||||
|     default: |     default: | ||||||
|         pen.setWidth(height); |         pen.setWidth(_height); | ||||||
|         // inactive |         // inactive | ||||||
|         pen.setColor(inactiveColor); |         pen.setColor(_inactiveColor); | ||||||
|         scene->addLine(0.0, 0.5 * height, width, 0.5 * height, pen); |         scene->addLine(0.0, 0.5 * _height, _width, 0.5 * _height, pen); | ||||||
|         // active |         // active | ||||||
|         pen.setColor(activeColor); |         pen.setColor(_activeColor); | ||||||
|         scene->addLine(-0.5 * height, 0.5 * height, percent * width - 0.5 * height, 0.5 * height, pen); |         scene->addLine(-0.5 * _height, 0.5 * _height, percent * _width - 0.5 * _height, 0.5 * _height, pen); | ||||||
|         // scale |         // scale | ||||||
|         scale[0] = (int)direction; |         scale[0] = (int)_direction; | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -120,7 +121,15 @@ QString GraphicalItem::getName() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return name; |     return _name; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | QString GraphicalItem::getComment() | ||||||
|  | { | ||||||
|  |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|  |     return _comment; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -128,7 +137,7 @@ QString GraphicalItem::getBar() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return bar; |     return _bar; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -136,7 +145,7 @@ QColor GraphicalItem::getActiveColor() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return activeColor; |     return _activeColor; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -144,7 +153,7 @@ QColor GraphicalItem::getInactiveColor() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return inactiveColor; |     return _inactiveColor; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -152,7 +161,7 @@ GraphicalItem::Type GraphicalItem::getType() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return type; |     return _type; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -160,7 +169,7 @@ GraphicalItem::Direction GraphicalItem::getDirection() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return direction; |     return _direction; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -168,7 +177,7 @@ int GraphicalItem::getHeight() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return height; |     return _height; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -176,86 +185,186 @@ int GraphicalItem::getWidth() | |||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     return width; |     return _width; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| QList<int> GraphicalItem::parseColor(const QString stringColor) | void GraphicalItem::setName(const QString name) | ||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |     if (debug) qDebug() << PDEBUG << ":" << "Name" << name; | ||||||
|  |  | ||||||
|     QList<int> color; |     _name = name; | ||||||
|     color.append(0); |  | ||||||
|     color.append(0); |  | ||||||
|     color.append(0); |  | ||||||
|     color.append(0); |  | ||||||
|  |  | ||||||
|     QStringList colors = stringColor.split(QChar(',')); |  | ||||||
|     for (int i=0; i<colors.count(); i++) { |  | ||||||
|         if (i == 4) break; |  | ||||||
|         color[i] = colors[i].toInt(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return color; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void GraphicalItem::parseTag(const QString tag) | void GraphicalItem::setComment(const QString comment) | ||||||
|  | { | ||||||
|  |     if (debug) qDebug() << PDEBUG; | ||||||
|  |     if (debug) qDebug() << PDEBUG << ":" << "Comment" << comment; | ||||||
|  |  | ||||||
|  |     _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 QColor color) | ||||||
|  | { | ||||||
|  |     if (debug) qDebug() << PDEBUG; | ||||||
|  |     if (debug) qDebug() << PDEBUG << ":" << "Color" << color; | ||||||
|  |  | ||||||
|  |     _activeColor = color; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | void GraphicalItem::setInactiveColor(const QColor 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; | ||||||
|  |     else | ||||||
|  |         _type = Horizontal; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | void GraphicalItem::setDirection(const QString direction) | ||||||
|  | { | ||||||
|  |     if (debug) qDebug() << PDEBUG; | ||||||
|  |     if (debug) qDebug() << PDEBUG << ":" << "Direction" << direction; | ||||||
|  |  | ||||||
|  |     if (direction == QString("RightToLeft")) | ||||||
|  |         _direction = RightToLeft; | ||||||
|  |     else | ||||||
|  |         _direction = LeftToRight; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | void GraphicalItem::setHeight(const int height) | ||||||
|  | { | ||||||
|  |     if (debug) qDebug() << PDEBUG; | ||||||
|  |     if (debug) qDebug() << PDEBUG << ":" << "Height" << height; | ||||||
|  |  | ||||||
|  |     _height = height; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | void GraphicalItem::setWidth(const int width) | ||||||
|  | { | ||||||
|  |     if (debug) qDebug() << PDEBUG; | ||||||
|  |     if (debug) qDebug() << PDEBUG << ":" << "Width" << width; | ||||||
|  |  | ||||||
|  |     _width = width; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | void GraphicalItem::readConfiguration() | ||||||
| { | { | ||||||
|     if (debug) qDebug() << PDEBUG; |     if (debug) qDebug() << PDEBUG; | ||||||
|  |  | ||||||
|     QStringList parsedTag = tag.split(QChar(';')); |     for (int i=dirs.count()-1; i>=0; i--) { | ||||||
|     for (int i=0; i<parsedTag.count(); i++) |         if (!QDir(dirs[i]).entryList(QDir::Files).contains(fileName)) continue; | ||||||
|         parsedTag[i].remove(QChar('$')).remove(QChar('{')).remove(QChar('}')); |         QSettings settings(dirs[i] + QDir::separator() + fileName, QSettings::IniFormat); | ||||||
|  |         settings.beginGroup(QString("Desktop Entry")); | ||||||
|  |         QStringList childKeys = settings.childKeys(); | ||||||
|  |         for (int i=0; i<childKeys.count(); i++) { | ||||||
|  |             if (childKeys[i] == QString("Name")) { | ||||||
|  |                 setName(settings.value(childKeys[i]).toString()); | ||||||
|  |             } else if (childKeys[i] == QString("Comment")) { | ||||||
|  |                 setComment(settings.value(childKeys[i]).toString()); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-Value")) { | ||||||
|  |                 setBar(settings.value(childKeys[i]).toString()); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-ActiveColor")) { | ||||||
|  |                 QStringList color = settings.value(childKeys[i]).toString().split(QChar(',')); | ||||||
|  |                 setActiveColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt())); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-InactiveColor")) { | ||||||
|  |                 QStringList color = settings.value(childKeys[i]).toString().split(QChar(',')); | ||||||
|  |                 setInactiveColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt())); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-Type")) { | ||||||
|  |                 setType(settings.value(childKeys[i]).toString()); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-Direction")) { | ||||||
|  |                 setDirection(settings.value(childKeys[i]).toString()); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-Height")) { | ||||||
|  |                 setHeight(settings.value(childKeys[i]).toInt()); | ||||||
|  |             } else if (childKeys[i] == QString("X-AW-Width")) { | ||||||
|  |                 setWidth(settings.value(childKeys[i]).toInt()); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         settings.endGroup(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|     if (parsedTag.count() > 0) |  | ||||||
|         bar = parsedTag[0]; | void GraphicalItem::writeConfiguration() | ||||||
|     if (parsedTag.count() > 1) { | { | ||||||
|         QList<int> color = parseColor(parsedTag[1]); |     if (debug) qDebug() << PDEBUG; | ||||||
|         activeColor = QColor(color[0], color[1], color[2], color[3]); |  | ||||||
|     } |     QSettings settings(dirs[0] + QDir::separator() + fileName, QSettings::IniFormat); | ||||||
|     if (parsedTag.count() > 2) { |     if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName(); | ||||||
|         QList<int> color = parseColor(parsedTag[2]); |     settings.beginGroup(QString("Desktop Entry")); | ||||||
|         inactiveColor = QColor(color[0], color[1], color[2], color[3]); |  | ||||||
|     } |     QString strValue; | ||||||
|     if (parsedTag.count() > 3) |     settings.setValue(QString("Encoding"), QString("UTF-8")); | ||||||
|         switch(parsedTag[3].toInt()) { |     settings.setValue(QString("Name"), _name); | ||||||
|  |     settings.setValue(QString("Comment"), _comment); | ||||||
|  |     settings.setValue(QString("X-AW-Value"), _bar); | ||||||
|  |     settings.setValue(QString("X-AW-ActiveColor"), QString("%1,%2,%3,%4") | ||||||
|  |                       .arg(_activeColor.red()).arg(_activeColor.green()) | ||||||
|  |                       .arg(_activeColor.blue()).arg(_activeColor.alpha())); | ||||||
|  |     settings.setValue(QString("X-AW-InactiveColor"), QString("%1,%2,%3,%4") | ||||||
|  |                       .arg(_inactiveColor.red()).arg(_inactiveColor.green()) | ||||||
|  |                       .arg(_inactiveColor.blue()).arg(_inactiveColor.alpha())); | ||||||
|  |     switch(_type) { | ||||||
|     case Vertical: |     case Vertical: | ||||||
|             type = Vertical; |         strValue = QString("Vertical"); | ||||||
|         break; |         break; | ||||||
|     case Circle: |     case Circle: | ||||||
|             type = Circle; |         strValue = QString("Circle"); | ||||||
|         break; |         break; | ||||||
|     default: |     default: | ||||||
|             type = Horizontal; |         strValue = QString("Horizontal"); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     if (parsedTag.count() > 4) |     settings.setValue(QString("X-AW-Type"), strValue); | ||||||
|         switch (parsedTag[4].toInt()) { |     switch (_direction) { | ||||||
|     case RightToLeft: |     case RightToLeft: | ||||||
|             direction = RightToLeft; |         strValue = QString("RightToLeft"); | ||||||
|         break; |         break; | ||||||
|     default: |     default: | ||||||
|             direction = LeftToRight; |         strValue = QString("LeftToRight"); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     if (parsedTag.count() > 5) |     settings.setValue(QString("X-AW-Direction"), strValue); | ||||||
|         height = parsedTag[5].toInt(); |     settings.setValue(QString("X-AW-Height"), _height); | ||||||
|     if (parsedTag.count() > 6) |     settings.setValue(QString("X-AW-Width"), _width); | ||||||
|         width = parsedTag[6].toInt(); |  | ||||||
|  |  | ||||||
|     if ((!bar.contains(QRegExp(QString("cpu(?!cl).*")))) && |     settings.endGroup(); | ||||||
|         (!bar.contains(QRegExp(QString("gpu")))) && |     settings.sync(); | ||||||
|         (!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"); |  | ||||||
|  |  | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Bar" << bar; |  | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Active color" << activeColor; |  | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Inactive color" << inactiveColor; |  | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Type" << type; |  | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Direction" << direction; |  | ||||||
|     if (debug) qDebug() << PDEBUG << ":" << "Size" << height << width; |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -37,10 +37,12 @@ public: | |||||||
|         Circle |         Circle | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     GraphicalItem(QObject *wid, const QString assignName, const QString tag, const bool debugCmd = false); |     GraphicalItem(QObject *wid, const QString desktopName, const QStringList directories, const bool debugCmd = false); | ||||||
|     ~GraphicalItem(); |     ~GraphicalItem(); | ||||||
|     QString getImage(const float value); |     QString getImage(const float value); | ||||||
|  |     // get methods | ||||||
|     QString getName(); |     QString getName(); | ||||||
|  |     QString getComment(); | ||||||
|     QString getBar(); |     QString getBar(); | ||||||
|     QColor getActiveColor(); |     QColor getActiveColor(); | ||||||
|     QColor getInactiveColor(); |     QColor getInactiveColor(); | ||||||
| @ -48,22 +50,35 @@ public: | |||||||
|     Direction getDirection(); |     Direction getDirection(); | ||||||
|     int getHeight(); |     int getHeight(); | ||||||
|     int getWidth(); |     int getWidth(); | ||||||
|  |     // set methods | ||||||
|  |     void setName(const QString name); | ||||||
|  |     void setComment(const QString comment); | ||||||
|  |     void setBar(const QString bar); | ||||||
|  |     void setActiveColor(const QColor color); | ||||||
|  |     void setInactiveColor(const QColor color); | ||||||
|  |     void setType(const QString type); | ||||||
|  |     void setDirection(const QString direction); | ||||||
|  |     void setHeight(const int height); | ||||||
|  |     void setWidth(const int width); | ||||||
|  |  | ||||||
| public slots: | public slots: | ||||||
|     void parseTag(const QString tag); |     void readConfiguration(); | ||||||
|  |     void writeConfiguration(); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     QList<int> parseColor(const QString stringColor); |     QString fileName; | ||||||
|     QString name; |     QStringList dirs; | ||||||
|     bool debug; |     bool debug; | ||||||
|     // properties |     // properties | ||||||
|     QString bar = QString("cpu"); |     QString _name = QString("none"); | ||||||
|     QColor activeColor = QColor(QString("#ffffff")); |     QString _comment = QString("empty"); | ||||||
|     QColor inactiveColor = QColor(QString("#000000")); |     QString _bar = QString("cpu"); | ||||||
|     Type type = Horizontal; |     QColor _activeColor = QColor(255, 255, 255, 0); | ||||||
|     Direction direction; |     QColor _inactiveColor = QColor(255, 255, 255, 255); | ||||||
|     int height = 100; |     Type _type = Horizontal; | ||||||
|     int width = 100; |     Direction _direction = LeftToRight; | ||||||
|  |     int _height = 100; | ||||||
|  |     int _width = 100; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user