mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-11-03 22:33:42 +00:00 
			
		
		
		
	Merge branch 'master' of github.com:arcan1s/awesome-widgets
This commit is contained in:
		@ -418,7 +418,7 @@ void AwesomeWidget::getGraphicalItems()
 | 
			
		||||
 | 
			
		||||
    graphicalItems.clear();
 | 
			
		||||
    // create directory at $HOME
 | 
			
		||||
    QString localDir = KStandardDirs::locateLocal("data", "plasma_applet_awesome-widget/destkops");
 | 
			
		||||
    QString localDir = KStandardDirs::locateLocal("data", "plasma_applet_awesome-widget/desktops");
 | 
			
		||||
    if (KStandardDirs::makeDir(localDir))
 | 
			
		||||
        if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -735,13 +735,14 @@ void AwesomeWidget::addBar()
 | 
			
		||||
                                         i18n("File name"), QLineEdit::Normal,
 | 
			
		||||
                                         QString(""), &ok);
 | 
			
		||||
    if ((!ok) || (name.isEmpty())) return;
 | 
			
		||||
    if (!name.endsWith(QString(".desktop"))) name += QString(".desktop");
 | 
			
		||||
    QStringList bars;
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("cpu(?!cl).*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("gpu")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("mem")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("swap")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("hdd[0-9].*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("bat.*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^gpu$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^mem$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^swap$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^hdd[0-9].*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^bat.*")))));
 | 
			
		||||
 | 
			
		||||
    GraphicalItem *item = new GraphicalItem(0, name, dirs, debug);
 | 
			
		||||
    item->setName(QString("bar%1").arg(number));
 | 
			
		||||
@ -759,6 +760,7 @@ void AwesomeWidget::addCustomScript()
 | 
			
		||||
                                         i18n("File name"), QLineEdit::Normal,
 | 
			
		||||
                                         QString(""), &ok);
 | 
			
		||||
    if ((!ok) || (name.isEmpty())) return;
 | 
			
		||||
    if (!name.endsWith(QString(".desktop"))) name += QString(".desktop");
 | 
			
		||||
 | 
			
		||||
    ExtScript *script = new ExtScript(0, name, dirs, debug);
 | 
			
		||||
    script->showConfiguration();
 | 
			
		||||
@ -843,12 +845,12 @@ void AwesomeWidget::editBar(QListWidgetItem *item)
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
 | 
			
		||||
    QStringList bars;
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("cpu(?!cl).*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("gpu$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("mem$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("swap$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("hdd[0-9].*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("bat.*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^cpu(?!cl).*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^gpu$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^mem$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^swap$")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^hdd[0-9].*")))));
 | 
			
		||||
    bars.append(keys.filter((QRegExp(QString("^bat.*")))));
 | 
			
		||||
 | 
			
		||||
    for (int i=0; i<graphicalItems.count(); i++) {
 | 
			
		||||
        if (graphicalItems[i]->getFileName() != item->text()) continue;
 | 
			
		||||
 | 
			
		||||
@ -59,6 +59,8 @@ QString GraphicalItem::getImage(const float value)
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
 | 
			
		||||
    if (_bar == QString("none")) return QString("");
 | 
			
		||||
 | 
			
		||||
    QColor active = stringToColor(_activeColor);
 | 
			
		||||
    QColor inactive = stringToColor(_inactiveColor);
 | 
			
		||||
    float percent = value / 100.0;
 | 
			
		||||
    int scale[2] = {1, 1};
 | 
			
		||||
    QPen pen = QPen();
 | 
			
		||||
@ -67,6 +69,7 @@ QString GraphicalItem::getImage(const float value)
 | 
			
		||||
    QGraphicsView *view = new QGraphicsView(scene);
 | 
			
		||||
    view->setStyleSheet(QString("background: transparent"));
 | 
			
		||||
    view->setContentsMargins(0, 0, 0, 0);
 | 
			
		||||
    view->setFrameShape(QFrame::NoFrame);
 | 
			
		||||
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 | 
			
		||||
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 | 
			
		||||
    view->resize(_width + 5.0, _height + 5.0);
 | 
			
		||||
@ -76,40 +79,40 @@ QString GraphicalItem::getImage(const float value)
 | 
			
		||||
    case Vertical:
 | 
			
		||||
        pen.setWidth(_width);
 | 
			
		||||
        // inactive
 | 
			
		||||
        pen.setColor(_inactiveColor);
 | 
			
		||||
        scene->addLine(0.5 * _width, 0.0, 0.5 * _width, _height, pen);
 | 
			
		||||
        pen.setColor(inactive);
 | 
			
		||||
        scene->addLine(0.5 * _width, -0.5 * _width, 0.5 * _width, (1.0 - percent) * _height - 0.5 * _width, pen);
 | 
			
		||||
        // active
 | 
			
		||||
        pen.setColor(_activeColor);
 | 
			
		||||
        pen.setColor(active);
 | 
			
		||||
        scene->addLine(0.5 * _width, (1.0 - percent) * _height + 0.5 * _width, 0.5 * _width, _height + 0.5 * _width, pen);
 | 
			
		||||
        // scale
 | 
			
		||||
        scale[1] = (int)_direction;
 | 
			
		||||
        scale[1] = -2 * (int)_direction + 1;
 | 
			
		||||
        break;
 | 
			
		||||
    case Circle:
 | 
			
		||||
        QGraphicsEllipseItem *circle;
 | 
			
		||||
        pen.setWidth(1.0);
 | 
			
		||||
        // inactive
 | 
			
		||||
        pen.setColor(_inactiveColor);
 | 
			
		||||
        circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(_inactiveColor, Qt::SolidPattern));
 | 
			
		||||
        circle->setSpanAngle((1.0 - percent) * 360.0 * 16.0);
 | 
			
		||||
        circle->setStartAngle(180.0 * 16.0 - (1.0 - percent) * 360.0 * 16.0);
 | 
			
		||||
        pen.setColor(inactive);
 | 
			
		||||
        circle = scene->addEllipse(0.0, 0.0, _width, _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(_activeColor);
 | 
			
		||||
        circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(_activeColor, Qt::SolidPattern));
 | 
			
		||||
        circle->setSpanAngle(percent * 360.0 * 16.0);
 | 
			
		||||
        circle->setStartAngle(180.0 * 16.0);
 | 
			
		||||
        pen.setColor(active);
 | 
			
		||||
        circle = scene->addEllipse(0.0, 0.0, _width, _height, pen, QBrush(active, Qt::SolidPattern));
 | 
			
		||||
        circle->setSpanAngle(- percent * 360.0 * 16.0);
 | 
			
		||||
        circle->setStartAngle(90.0 * 16.0);
 | 
			
		||||
        // scale
 | 
			
		||||
        scale[0] = (int)_direction;
 | 
			
		||||
        scale[0] = -2 *(int)_direction + 1;
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        pen.setWidth(_height);
 | 
			
		||||
        // inactive
 | 
			
		||||
        pen.setColor(_inactiveColor);
 | 
			
		||||
        scene->addLine(0.0, 0.5 * _height, _width, 0.5 * _height, pen);
 | 
			
		||||
        pen.setColor(inactive);
 | 
			
		||||
        scene->addLine(percent * _width + 0.5 * _height, 0.5 * _height, _width + 0.5 * _height, 0.5 * _height, pen);
 | 
			
		||||
        // active
 | 
			
		||||
        pen.setColor(_activeColor);
 | 
			
		||||
        pen.setColor(active);
 | 
			
		||||
        scene->addLine(-0.5 * _height, 0.5 * _height, percent * _width - 0.5 * _height, 0.5 * _height, pen);
 | 
			
		||||
        // scale
 | 
			
		||||
        scale[0] = (int)_direction;
 | 
			
		||||
        scale[0] = -2 * (int)_direction + 1;
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -158,7 +161,7 @@ QString GraphicalItem::getBar()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QColor GraphicalItem::getActiveColor()
 | 
			
		||||
QString GraphicalItem::getActiveColor()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
 | 
			
		||||
@ -166,7 +169,7 @@ QColor GraphicalItem::getActiveColor()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QColor GraphicalItem::getInactiveColor()
 | 
			
		||||
QString GraphicalItem::getInactiveColor()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
 | 
			
		||||
@ -182,6 +185,27 @@ GraphicalItem::Type GraphicalItem::getType()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QString GraphicalItem::getStrType()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
 | 
			
		||||
    QString value;
 | 
			
		||||
    switch(_type) {
 | 
			
		||||
    case Vertical:
 | 
			
		||||
        value = QString("Vertical");
 | 
			
		||||
        break;
 | 
			
		||||
    case Circle:
 | 
			
		||||
        value = QString("Circle");
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        value = QString("Horizontal");
 | 
			
		||||
        break;
 | 
			
		||||
    }\
 | 
			
		||||
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
GraphicalItem::Direction GraphicalItem::getDirection()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
@ -190,6 +214,24 @@ GraphicalItem::Direction GraphicalItem::getDirection()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QString GraphicalItem::getStrDirection()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
 | 
			
		||||
    QString value;
 | 
			
		||||
    switch (_direction) {
 | 
			
		||||
    case RightToLeft:
 | 
			
		||||
        value = QString("RightToLeft");
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        value = QString("LeftToRight");
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int GraphicalItem::getHeight()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
@ -240,7 +282,7 @@ void GraphicalItem::setBar(const QString bar)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void GraphicalItem::setActiveColor(const QColor color)
 | 
			
		||||
void GraphicalItem::setActiveColor(const QString color)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
 | 
			
		||||
@ -249,7 +291,7 @@ void GraphicalItem::setActiveColor(const QColor color)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void GraphicalItem::setInactiveColor(const QColor color)
 | 
			
		||||
void GraphicalItem::setInactiveColor(const QString color)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
 | 
			
		||||
@ -312,30 +354,15 @@ void GraphicalItem::readConfiguration()
 | 
			
		||||
        if (!QDir(dirs[i]).entryList(QDir::Files).contains(fileName)) continue;
 | 
			
		||||
        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());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        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());
 | 
			
		||||
        settings.endGroup();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -350,35 +377,25 @@ void GraphicalItem::showConfiguration(const QStringList tags)
 | 
			
		||||
    ui->comboBox_value->addItems(tags);
 | 
			
		||||
    ui->comboBox_value->addItem(_bar);
 | 
			
		||||
    ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
 | 
			
		||||
    ui->pushButton_activeColor->setText(QString("%1,%2,%3,%4")
 | 
			
		||||
                                        .arg(_activeColor.red()).arg(_activeColor.green())
 | 
			
		||||
                                        .arg(_activeColor.blue()).arg(_activeColor.alpha()));
 | 
			
		||||
    ui->pushButton_inactiveColor->setText(QString("%1,%2,%3,%4")
 | 
			
		||||
                                          .arg(_inactiveColor.red()).arg(_inactiveColor.green())
 | 
			
		||||
                                          .arg(_inactiveColor.blue()).arg(_inactiveColor.alpha()));
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    int ret = exec();
 | 
			
		||||
    if (ret == 0) {
 | 
			
		||||
        QStringList colorText;
 | 
			
		||||
        setName(ui->label_nameValue->text());
 | 
			
		||||
        setComment(ui->lineEdit_comment->text());
 | 
			
		||||
        setBar(ui->comboBox_value->currentText());
 | 
			
		||||
        colorText = ui->pushButton_activeColor->text().split(QChar(','));
 | 
			
		||||
        setActiveColor(QColor(colorText[0].toInt(), colorText[1].toInt(),
 | 
			
		||||
                              colorText[2].toInt(), colorText[3].toInt()));
 | 
			
		||||
        colorText = ui->pushButton_inactiveColor->text().split(QChar(','));
 | 
			
		||||
        setInactiveColor(QColor(colorText[0].toInt(), colorText[1].toInt(),
 | 
			
		||||
                                colorText[2].toInt(), colorText[3].toInt()));
 | 
			
		||||
        setType(ui->comboBox_type->currentText());
 | 
			
		||||
        setDirection(ui->comboBox_direction->currentText());
 | 
			
		||||
        setHeight(ui->spinBox_height->value());
 | 
			
		||||
        setWidth(ui->spinBox_width->value());
 | 
			
		||||
        writeConfiguration();
 | 
			
		||||
    }
 | 
			
		||||
    if (ret != 1) return;
 | 
			
		||||
    setName(ui->label_nameValue->text());
 | 
			
		||||
    setComment(ui->lineEdit_comment->text());
 | 
			
		||||
    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());
 | 
			
		||||
    setHeight(ui->spinBox_height->value());
 | 
			
		||||
    setWidth(ui->spinBox_width->value());
 | 
			
		||||
    writeConfiguration();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -400,38 +417,14 @@ void GraphicalItem::writeConfiguration()
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
 | 
			
		||||
    settings.beginGroup(QString("Desktop Entry"));
 | 
			
		||||
 | 
			
		||||
    QString strValue;
 | 
			
		||||
    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"), 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:
 | 
			
		||||
        strValue = QString("Vertical");
 | 
			
		||||
        break;
 | 
			
		||||
    case Circle:
 | 
			
		||||
        strValue = QString("Circle");
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        strValue = QString("Horizontal");
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    settings.setValue(QString("X-AW-Type"), strValue);
 | 
			
		||||
    switch (_direction) {
 | 
			
		||||
    case RightToLeft:
 | 
			
		||||
        strValue = QString("RightToLeft");
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        strValue = QString("LeftToRight");
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    settings.setValue(QString("X-AW-Direction"), strValue);
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
@ -444,16 +437,33 @@ void GraphicalItem::changeColor()
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
 | 
			
		||||
    QStringList colorText = ((QPushButton *)sender())->text().split(QChar(','));
 | 
			
		||||
    QColor color = QColor(colorText[0].toInt(), colorText[1].toInt(),
 | 
			
		||||
                          colorText[2].toInt(), colorText[3].toInt());
 | 
			
		||||
    QColor color = stringToColor(((QPushButton *)sender())->text());
 | 
			
		||||
    QColor newColor = QColorDialog::getColor(color, 0, i18n("Select color"),
 | 
			
		||||
                                             QColorDialog::ShowAlphaChannel);
 | 
			
		||||
    if (!newColor.isValid()) return;
 | 
			
		||||
 | 
			
		||||
    colorText.clear();
 | 
			
		||||
    QStringList colorText;
 | 
			
		||||
    colorText.append(QString("%1").arg(newColor.red()));
 | 
			
		||||
    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(',')));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QColor GraphicalItem::stringToColor(const QString color)
 | 
			
		||||
{
 | 
			
		||||
    if (debug) qDebug() << PDEBUG;
 | 
			
		||||
    if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
 | 
			
		||||
 | 
			
		||||
    QColor qcolor;
 | 
			
		||||
    QStringList listColor = color.split(QChar(','));
 | 
			
		||||
    while (listColor.count() < 4)
 | 
			
		||||
        listColor.append(QString("0"));
 | 
			
		||||
    qcolor.setRed(listColor[0].toInt());
 | 
			
		||||
    qcolor.setGreen(listColor[1].toInt());
 | 
			
		||||
    qcolor.setBlue(listColor[2].toInt());
 | 
			
		||||
    qcolor.setAlpha(listColor[3].toInt());
 | 
			
		||||
 | 
			
		||||
    return qcolor;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -31,8 +31,8 @@ class GraphicalItem : public QDialog
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    enum Direction {
 | 
			
		||||
        RightToLeft = 0,
 | 
			
		||||
        LeftToRight = 1
 | 
			
		||||
        LeftToRight = 0,
 | 
			
		||||
        RightToLeft
 | 
			
		||||
    };
 | 
			
		||||
    enum Type {
 | 
			
		||||
        Horizontal = 0,
 | 
			
		||||
@ -49,18 +49,20 @@ public:
 | 
			
		||||
    QString getName();
 | 
			
		||||
    QString getComment();
 | 
			
		||||
    QString getBar();
 | 
			
		||||
    QColor getActiveColor();
 | 
			
		||||
    QColor getInactiveColor();
 | 
			
		||||
    QString getActiveColor();
 | 
			
		||||
    QString getInactiveColor();
 | 
			
		||||
    Type getType();
 | 
			
		||||
    QString getStrType();
 | 
			
		||||
    Direction getDirection();
 | 
			
		||||
    QString getStrDirection();
 | 
			
		||||
    int getHeight();
 | 
			
		||||
    int getWidth();
 | 
			
		||||
    // 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 QColor color = QColor(255, 255, 255, 0));
 | 
			
		||||
    void setInactiveColor(const QColor color = QColor(255, 255, 255, 255));
 | 
			
		||||
    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);
 | 
			
		||||
@ -76,6 +78,7 @@ private slots:
 | 
			
		||||
    void changeColor();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QColor stringToColor(const QString color);
 | 
			
		||||
    QString fileName;
 | 
			
		||||
    QStringList dirs;
 | 
			
		||||
    bool debug;
 | 
			
		||||
@ -84,8 +87,8 @@ private:
 | 
			
		||||
    QString _name = QString("none");
 | 
			
		||||
    QString _comment = QString("empty");
 | 
			
		||||
    QString _bar = QString("cpu");
 | 
			
		||||
    QColor _activeColor = QColor(255, 255, 255, 0);
 | 
			
		||||
    QColor _inactiveColor = QColor(255, 255, 255, 255);
 | 
			
		||||
    QString _activeColor = QString("0,0,0,130");
 | 
			
		||||
    QString _inactiveColor = QString("255,255,255,130");
 | 
			
		||||
    Type _type = Horizontal;
 | 
			
		||||
    Direction _direction = LeftToRight;
 | 
			
		||||
    int _height = 100;
 | 
			
		||||
 | 
			
		||||
@ -6,8 +6,8 @@
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>420</width>
 | 
			
		||||
    <height>329</height>
 | 
			
		||||
    <width>416</width>
 | 
			
		||||
    <height>325</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
@ -73,7 +73,7 @@
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QComboBox" name="comboBox_value">
 | 
			
		||||
       <property name="editable">
 | 
			
		||||
        <bool>true</bool>
 | 
			
		||||
        <bool>false</bool>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
@ -94,7 +94,7 @@
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QPushButton" name="pushButton_activeColor">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string/>
 | 
			
		||||
        <string notr="true"/>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
@ -115,7 +115,7 @@
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QPushButton" name="pushButton_inactiveColor">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string/>
 | 
			
		||||
        <string notr="true"/>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
 | 
			
		||||
@ -295,7 +295,7 @@ void ExtScript::showConfiguration()
 | 
			
		||||
    ui->spinBox_interval->setValue(_interval);
 | 
			
		||||
 | 
			
		||||
    int ret = exec();
 | 
			
		||||
    if (ret == 0) {
 | 
			
		||||
    if (ret == 1) {
 | 
			
		||||
        setName(ui->lineEdit_name->text());
 | 
			
		||||
        setComment(ui->lineEdit_comment->text());
 | 
			
		||||
        setExec(ui->lineEdit_command->text());
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user