Index: lxqt-panel-0.8.0/panel/lxqtpanel.cpp =================================================================== --- lxqt-panel-0.8.0/panel/lxqtpanel.cpp +++ lxqt-panel-0.8.0/panel/lxqtpanel.cpp 2015-01-12 13:16:16.042896979 +0100 @@ -62,6 +62,8 @@ #define CFG_KEY_LINECNT "lineCount" #define CFG_KEY_LENGTH "width" #define CFG_KEY_PERCENT "width-percent" +#define CFG_KEY_BACKGROUNDCOLOR "background-color" +#define CFG_KEY_BACKGROUNDIMAGE "background-image" #define CFG_KEY_ALIGNMENT "alignment" #define CFG_KEY_PLUGINS "plugins" @@ -171,17 +173,28 @@ mSettings->beginGroup(mConfigGroup); // By default we are using size & count from theme. - setPanelSize(mSettings->value(CFG_KEY_PANELSIZE, PANEL_DEFAULT_SIZE).toInt()); - setIconSize(mSettings->value(CFG_KEY_ICONSIZE, PANEL_DEFAULT_ICON_SIZE).toInt()); - setLineCount(mSettings->value(CFG_KEY_LINECNT, PANEL_DEFAULT_LINE_COUNT).toInt()); + setPanelSize(mSettings->value(CFG_KEY_PANELSIZE, PANEL_DEFAULT_SIZE).toInt(), false); + setIconSize(mSettings->value(CFG_KEY_ICONSIZE, PANEL_DEFAULT_ICON_SIZE).toInt(), false); + setLineCount(mSettings->value(CFG_KEY_LINECNT, PANEL_DEFAULT_LINE_COUNT).toInt(), false); setLength(mSettings->value(CFG_KEY_LENGTH, 100).toInt(), - mSettings->value(CFG_KEY_PERCENT, true).toBool()); + mSettings->value(CFG_KEY_PERCENT, true).toBool(), + false); setPosition(mSettings->value(CFG_KEY_SCREENNUM, QApplication::desktop()->primaryScreen()).toInt(), - strToPosition(mSettings->value(CFG_KEY_POSITION).toString(), PositionBottom)); + strToPosition(mSettings->value(CFG_KEY_POSITION).toString(), PositionBottom), + false); + + setAlignment(Alignment(mSettings->value(CFG_KEY_ALIGNMENT, mAlignment).toInt()), false); + + QColor color = mSettings->value(CFG_KEY_BACKGROUNDCOLOR, "").value(); + if (color.isValid()) + setBackgroundColor(color, true); + + QString image = mSettings->value(CFG_KEY_BACKGROUNDIMAGE, "").toString(); + if (!image.isEmpty()) + setBackgroundImage(image, false); - setAlignment(LxQtPanel::Alignment(mSettings->value(CFG_KEY_ALIGNMENT, mAlignment).toInt())); mSettings->endGroup(); } @@ -228,6 +241,9 @@ mSettings->setValue(CFG_KEY_ALIGNMENT, mAlignment); + mSettings->setValue(CFG_KEY_BACKGROUNDCOLOR, mBackgroundColor.isValid() ? mBackgroundColor : QColor()); + mSettings->setValue(CFG_KEY_BACKGROUNDIMAGE, QFileInfo(mBackgroundImage).exists() ? mBackgroundImage : QString()); + mSettings->endGroup(); } @@ -238,7 +254,8 @@ void LxQtPanel::ensureVisible() { if (! canPlacedOn(mScreenNum, mPosition)) - setPosition(findAvailableScreen(mPosition), mPosition); + setPosition(findAvailableScreen(mPosition), mPosition, true); + // the screen size might be changed, let's update the reserved screen space. updateWmStrut(); } @@ -639,6 +656,21 @@ sheet << QString("Plugin > * { qproperty-iconSize: %1px %1px; }").arg(mIconSize); sheet << QString("Plugin > * > * { qproperty-iconSize: %1px %1px; }").arg(mIconSize); + QString object = LxQtPanelWidget->objectName(); + if (mBackgroundColor.isValid()) + { + QString color = QString("%1, %2, %3, %5") + .arg(mBackgroundColor.red()) + .arg(mBackgroundColor.green()) + .arg(mBackgroundColor.blue()) + .arg((float) mBackgroundColor.alpha() / 255); + + sheet << QString("LxQtPanel #" + object + " { background-color: rgba(" + color + "); }"); + } + + if (QFileInfo(mBackgroundImage).exists()) + sheet << QString("LxQtPanel #" + object + " { background-image: url('" + mBackgroundImage + "');}"); + setStyleSheet(sheet.join("\n")); } @@ -647,14 +679,16 @@ /************************************************ ************************************************/ -void LxQtPanel::setPanelSize(int value) +void LxQtPanel::setPanelSize(int value, bool save) { if (mPanelSize != value) { mPanelSize = value; realign(); emit realigned(); - saveSettings(true); + + if (save) + saveSettings(true); } } @@ -663,14 +697,16 @@ /************************************************ ************************************************/ -void LxQtPanel::setIconSize(int value) +void LxQtPanel::setIconSize(int value, bool save) { if (mIconSize != value) { mIconSize = value; updateStyleSheet(); mLayout->setLineSize(mIconSize); - saveSettings(true); + + if (save) + saveSettings(true); realign(); emit realigned(); @@ -681,7 +717,7 @@ /************************************************ ************************************************/ -void LxQtPanel::setLineCount(int value) +void LxQtPanel::setLineCount(int value, bool save) { if (mLineCount != value) { @@ -689,7 +725,9 @@ mLayout->setEnabled(false); mLayout->setLineCount(mLineCount); mLayout->setEnabled(true); - saveSettings(true); + + if (save) + saveSettings(true); realign(); emit realigned(); @@ -700,7 +738,7 @@ /************************************************ ************************************************/ -void LxQtPanel::setLength(int length, bool inPercents) +void LxQtPanel::setLength(int length, bool inPercents, bool save) { if (mLength == length && mLengthInPercents == inPercents) @@ -708,7 +746,9 @@ mLength = length; mLengthInPercents = inPercents; - saveSettings(true); + + if (save) + saveSettings(true); realign(); emit realigned(); @@ -718,7 +758,7 @@ /************************************************ ************************************************/ -void LxQtPanel::setPosition(int screen, ILxQtPanel::Position position) +void LxQtPanel::setPosition(int screen, ILxQtPanel::Position position, bool save) { if (mScreenNum == screen && mPosition == position) @@ -727,7 +767,9 @@ mScreenNum = screen; mPosition = position; mLayout->setPosition(mPosition); - saveSettings(true); + + if (save) + saveSettings(true); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // Qt 5 adds a new class QScreen and add API for setting the screen of a QWindow. @@ -757,17 +799,42 @@ emit realigned(); } +/************************************************ + + ************************************************/ +void LxQtPanel::setBackgroundColor(QColor color, bool save) +{ + mBackgroundColor = color; + updateStyleSheet(); + + if (save) + saveSettings(true); +} /************************************************ ************************************************/ -void LxQtPanel::setAlignment(LxQtPanel::Alignment value) +void LxQtPanel::setBackgroundImage(QString path, bool save) +{ + mBackgroundImage = path; + updateStyleSheet(); + + if (save) + saveSettings(true); +} + +/************************************************ + + ************************************************/ +void LxQtPanel::setAlignment(Alignment value, bool save) { if (mAlignment == value) return; mAlignment = value; - saveSettings(true); + + if (save) + saveSettings(true); realign(); emit realigned(); Index: lxqt-panel-0.8.0/panel/lxqtpanel.h =================================================================== --- lxqt-panel-0.8.0/panel/lxqtpanel.h +++ lxqt-panel-0.8.0/panel/lxqtpanel.h 2015-01-12 13:14:01.973301570 +0100 @@ -81,7 +81,6 @@ static QString positionToStr(ILxQtPanel::Position position); static ILxQtPanel::Position strToPosition(const QString &str, ILxQtPanel::Position defaultValue); - // Settings int panelSize() const { return mPanelSize; } int iconSize() const { return mIconSize; } @@ -90,6 +89,8 @@ bool lengthInPercents() const { return mLengthInPercents; } LxQtPanel::Alignment alignment() const { return mAlignment; } int screenNum() const { return mScreenNum; } + QColor backgroundColor() const { return mBackgroundColor; }; + QString backgroundImage() const { return mBackgroundImage; }; LxQt::Settings *settings() const { return mSettings; } @@ -97,12 +98,14 @@ void show(); // Settings - void setPanelSize(int value); - void setIconSize(int value); - void setLineCount(int value); - void setLength(int length, bool inPercents); - void setPosition(int screen, ILxQtPanel::Position position); - void setAlignment(LxQtPanel::Alignment value); + void setPanelSize(int value, bool save); + void setIconSize(int value, bool save); + void setLineCount(int value, bool save); + void setLength(int length, bool inPercents, bool save); + void setPosition(int screen, ILxQtPanel::Position position, bool save); + void setBackgroundColor(QColor color, bool save); + void setBackgroundImage(QString path, bool save); + void setAlignment(LxQtPanel::Alignment value, bool save); void saveSettings(bool later=false); void ensureVisible(); @@ -150,12 +153,15 @@ int mLength; bool mLengthInPercents; - LxQtPanel::Alignment mAlignment; + Alignment mAlignment; ILxQtPanel::Position mPosition; int mScreenNum; QTimer mDelaySave; + QColor mBackgroundColor; + QString mBackgroundImage; + void updateStyleSheet(); }; Index: lxqt-panel-0.8.0/panel/lxqtpanellimits.h =================================================================== --- lxqt-panel-0.8.0/panel/lxqtpanellimits.h +++ lxqt-panel-0.8.0/panel/lxqtpanellimits.h 2015-01-12 13:14:01.973301570 +0100 @@ -35,5 +35,7 @@ #define PANEL_DEFAULT_ICON_SIZE 22 #define PANEL_DEFAULT_LINE_COUNT 1 +#define PANEL_DEFAULT_BACKGROUND_COLOR "#CCCCCC" + #define SETTINGS_SAVE_DELAY 3000 #endif // LXQTPANELLIMITS_H Index: lxqt-panel-0.8.0/panel/config/configpaneldialog.cpp =================================================================== --- lxqt-panel-0.8.0/panel/config/configpaneldialog.cpp +++ lxqt-panel-0.8.0/panel/config/configpaneldialog.cpp 2015-01-12 13:14:01.972301583 +0100 @@ -34,6 +34,9 @@ #include #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#include +#include +#include #include #endif @@ -102,12 +105,13 @@ mPanel(panel) { ui->setupUi(this); + fillComboBox_position(); fillComboBox_alignment(); mOldPanelSize = mPanel->panelSize(); - mOldIconSize = mPanel->iconSize(); - mOldLineCount = mPanel->lineCount(); + mOldIconSize = mPanel->iconSize(); + mOldLineCount = mPanel->lineCount(); mOldLength = mPanel->length(); mOldLengthInPercents = mPanel->lengthInPercents(); @@ -123,17 +127,28 @@ ui->spinBox_panelSize->setMinimum(PANEL_MINIMUM_SIZE); ui->spinBox_panelSize->setMaximum(PANEL_MAXIMUM_SIZE); - reset(); - - connect(ui->spinBox_panelSize, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); - connect(ui->spinBox_iconSize, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); - connect(ui->spinBox_lineCount, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); + mOldBackgroundColor = mPanel->backgroundColor(); + mOldBackgroundImage = mPanel->backgroundImage(); - connect(ui->spinBox_length, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); - connect(ui->comboBox_lenghtType, SIGNAL(activated(int)), this, SLOT(widthTypeChanged())); + reset(); - connect(ui->comboBox_alignment, SIGNAL(activated(int)), this, SLOT(editChanged())); - connect(ui->comboBox_position, SIGNAL(activated(int)), this, SLOT(positionChanged())); + connect(ui->spinBox_panelSize, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); + connect(ui->spinBox_iconSize, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); + connect(ui->spinBox_lineCount, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); + + connect(ui->spinBox_length, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); + connect(ui->comboBox_lenghtType, SIGNAL(activated(int)), this, SLOT(widthTypeChanged())); + + connect(ui->comboBox_alignment, SIGNAL(activated(int)), this, SLOT(editChanged())); + connect(ui->comboBox_position, SIGNAL(activated(int)), this, SLOT(positionChanged())); + + connect(ui->checkBox_customColor, SIGNAL(toggled(bool)), this, SLOT(editChanged())); + connect(ui->pushButton_customColor, SIGNAL(clicked(bool)), this, SLOT(pickBackgroundColor())); + connect(ui->lineEdit_customColor, SIGNAL(textChanged(QString)), this, SLOT(editChanged())); + connect(ui->slider_opacity, SIGNAL(valueChanged(int)), this, SLOT(editChanged())); + connect(ui->checkBox_customImage, SIGNAL(toggled(bool)), this, SLOT(editChanged())); + connect(ui->lineEdit_customImage, SIGNAL(textChanged(QString)), this, SLOT(editChanged())); + connect(ui->pushButton_customImage, SIGNAL(clicked(bool)), this, SLOT(pickBackgroundImage())); } @@ -155,6 +170,13 @@ widthTypeChanged(); ui->spinBox_length->setValue(mOldLength); + ui->slider_opacity->setValue(mOldBackgroundColor.alpha() * 100 / 255); + ui->lineEdit_customColor->setText(mOldBackgroundColor.name().toUpper()); + ui->lineEdit_customImage->setText(mOldBackgroundImage); + + ui->checkBox_customColor->setChecked(mOldBackgroundColor.isValid()); + ui->checkBox_customImage->setChecked(QFileInfo(mOldBackgroundImage).exists()); + // update position positionChanged(); } @@ -254,21 +276,33 @@ ************************************************/ void ConfigPanelWidget::editChanged() { - mPanel->setPanelSize(ui->spinBox_panelSize->value()); - mPanel->setIconSize(ui->spinBox_iconSize->value()); - mPanel->setLineCount(ui->spinBox_lineCount->value()); + mPanel->setPanelSize(ui->spinBox_panelSize->value(), true); + mPanel->setIconSize(ui->spinBox_iconSize->value(), true); + mPanel->setLineCount(ui->spinBox_lineCount->value(), true); mPanel->setLength(ui->spinBox_length->value(), - ui->comboBox_lenghtType->currentIndex() == 0); + ui->comboBox_lenghtType->currentIndex() == 0, + true); LxQtPanel::Alignment align = LxQtPanel::Alignment( ui->comboBox_alignment->itemData( ui->comboBox_alignment->currentIndex() ).toInt()); - mPanel->setAlignment(align); + mPanel->setAlignment(align, true); + mPanel->setPosition(mScreenNum, mPosition, true); - mPanel->setPosition(mScreenNum, mPosition); + if (ui->checkBox_customColor->isChecked()) + { + QColor color = QColor(ui->lineEdit_customColor->text()); + color.setAlpha(ui->slider_opacity->value() * 255 / 100); + mPanel->setBackgroundColor(color, true); + } + else + mPanel->setBackgroundColor(QColor(), true); + + mPanel->setBackgroundImage(ui->checkBox_customImage->isChecked() ? ui->lineEdit_customImage->text() : QString(), + true); } @@ -347,3 +381,28 @@ editChanged(); } + +/************************************************ + + ************************************************/ +void ConfigPanelWidget::pickBackgroundColor() +{ + QColor newColor = QColorDialog::getColor(QColor(ui->lineEdit_customColor->text()), this, tr("Pick color")); + if (newColor.isValid()) + ui->lineEdit_customColor->setText(newColor.name()); +} + +/************************************************ + + ************************************************/ +void ConfigPanelWidget::pickBackgroundImage() +{ + QString picturesLocation; + picturesLocation = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); + + QString file = QFileDialog::getOpenFileName(this, + "Pick image", + picturesLocation, + tr("Images (*.png *.gif *.jpg)")); + ui->lineEdit_customImage->setText(file); +} Index: lxqt-panel-0.8.0/panel/config/configpaneldialog.h =================================================================== --- lxqt-panel-0.8.0/panel/config/configpaneldialog.h +++ lxqt-panel-0.8.0/panel/config/configpaneldialog.h 2015-01-12 13:14:01.972301583 +0100 @@ -67,11 +67,12 @@ public slots: void reset(); - private slots: void editChanged(); void widthTypeChanged(); void positionChanged(); + void pickBackgroundColor(); + void pickBackgroundImage(); private: Ui::ConfigPanelWidget *ui; @@ -94,6 +95,8 @@ LxQtPanel::Alignment mOldAlignment; ILxQtPanel::Position mOldPosition; int mOldScreenNum; + QColor mOldBackgroundColor; + QString mOldBackgroundImage; }; #endif // CONFIGPANELDIALOG_H Index: lxqt-panel-0.8.0/panel/config/configpaneldialog.ui =================================================================== --- lxqt-panel-0.8.0/panel/config/configpaneldialog.ui +++ lxqt-panel-0.8.0/panel/config/configpaneldialog.ui 2015-01-12 13:14:01.972301583 +0100 @@ -6,16 +6,28 @@ 0 0 - 300 - 309 + 317 + 509 + + + 0 + 0 + + Configure panel + + + 0 + 0 + + Panel size @@ -96,6 +108,12 @@ + + + 0 + 0 + + Panel length && position @@ -163,6 +181,9 @@ + + + @@ -170,27 +191,212 @@ - - - - - - Qt::Vertical - - - - 20 - 40 - + + + + 0 + 0 + + + + Styling - + + + + + Custom background color + + + + + + + Custom background image + + + + + + + false + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + false + + + Opacity: + + + + + + + false + + + 100 + + + Qt::Horizontal + + + + + + + + + + false + + + Pick + + + + + + + false + + + Browse + + + + + + + false + + + + + - + + + checkBox_customColor + toggled(bool) + lineEdit_customColor + setEnabled(bool) + + + 68 + 354 + + + 71 + 377 + + + + + checkBox_customColor + toggled(bool) + pushButton_customColor + setEnabled(bool) + + + 116 + 353 + + + 266 + 386 + + + + + checkBox_customImage + toggled(bool) + lineEdit_customImage + setEnabled(bool) + + + 95 + 447 + + + 107 + 473 + + + + + checkBox_customImage + toggled(bool) + pushButton_customImage + setEnabled(bool) + + + 83 + 442 + + + 240 + 464 + + + + + checkBox_customColor + toggled(bool) + slider_opacity + setEnabled(bool) + + + 25 + 356 + + + 150 + 412 + + + + + checkBox_customColor + toggled(bool) + label_4 + setEnabled(bool) + + + 26 + 355 + + + 33 + 414 + + + +