mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
details:add backgound settings functionality
This commit is contained in:
parent
d8b339ac7b
commit
72a70c7da7
@ -28,6 +28,7 @@
|
||||
#include "../dialogs/detailsdialog.h"
|
||||
#include "../models/colorsmodel.h"
|
||||
#include "../models/layoutsmodel.h"
|
||||
#include "../widgets/patternwidget.h"
|
||||
|
||||
// Qt
|
||||
#include <QColorDialog>
|
||||
@ -75,7 +76,7 @@ void DetailsHandler::init()
|
||||
[ = ](int id, bool checked) {
|
||||
|
||||
if (checked) {
|
||||
//m_layoutsController->setInMultipleMode(id == Latte::Types::MultipleLayouts);
|
||||
setBackgroundStyle(static_cast<Latte::Layout::BackgroundStyle>(id));
|
||||
}
|
||||
});
|
||||
|
||||
@ -101,6 +102,17 @@ void DetailsHandler::init()
|
||||
//! connect colors combobox after the selected layout has been loaded
|
||||
connect(m_ui->colorsCmb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DetailsHandler::on_currentColorIndexChanged);
|
||||
|
||||
|
||||
//! pattern widgets
|
||||
connect(m_ui->backPatternWidget, &Widget::PatternWidget::mouseReleased, this, [&]() {
|
||||
setBackgroundStyle(Latte::Layout::PatternBackgroundStyle);
|
||||
});
|
||||
connect(m_ui->colorPatternWidget, &Widget::PatternWidget::mouseReleased, this, [&]() {
|
||||
setBackgroundStyle(Latte::Layout::ColorBackgroundStyle);
|
||||
});
|
||||
|
||||
|
||||
//! data were changed
|
||||
connect(this, &DetailsHandler::dataChanged, this, [&]() {
|
||||
loadLayout(c_data);
|
||||
});
|
||||
@ -121,9 +133,17 @@ void DetailsHandler::loadLayout(const Data::Layout &data)
|
||||
if (data.backgroundStyle == Latte::Layout::ColorBackgroundStyle) {
|
||||
m_ui->colorRadioBtn->setChecked(true);
|
||||
m_ui->backRadioBtn->setChecked(false);
|
||||
|
||||
m_ui->colorsCmb->setVisible(true);
|
||||
m_ui->backgroundBtn->setVisible(false);
|
||||
m_ui->textColorBtn->setVisible(false);
|
||||
} else {
|
||||
m_ui->colorRadioBtn->setChecked(false);
|
||||
m_ui->backRadioBtn->setChecked(true);
|
||||
|
||||
m_ui->colorsCmb->setVisible(false);
|
||||
m_ui->backgroundBtn->setVisible(true);
|
||||
m_ui->textColorBtn->setVisible(true);
|
||||
}
|
||||
|
||||
m_ui->colorPatternWidget->setBackground(m_colorsModel->colorPath(data.color));
|
||||
@ -234,6 +254,16 @@ void DetailsHandler::setHasDisabledBorders(bool disabled)
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void DetailsHandler::setBackgroundStyle(const Latte::Layout::BackgroundStyle &style)
|
||||
{
|
||||
if (c_data.backgroundStyle == style) {
|
||||
return;
|
||||
}
|
||||
|
||||
c_data.backgroundStyle = style;
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void DetailsHandler::selectBackground()
|
||||
{
|
||||
QStringList mimeTypeFilters;
|
||||
|
@ -24,6 +24,7 @@
|
||||
// local
|
||||
#include "generichandler.h"
|
||||
#include "../data/layoutdata.h"
|
||||
#include "../../layout/abstractlayout.h"
|
||||
|
||||
// Qt
|
||||
#include <QButtonGroup>
|
||||
@ -94,6 +95,8 @@ private:
|
||||
void setTextColor(const QString &textColor);
|
||||
void setColor(const QString &color);
|
||||
|
||||
void setBackgroundStyle(const Latte::Layout::BackgroundStyle &style);
|
||||
|
||||
void loadLayout(const Data::Layout &data);
|
||||
|
||||
private:
|
||||
|
@ -146,6 +146,12 @@ void PatternWidget::mouseMoveEvent(QMouseEvent *event )
|
||||
QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void PatternWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
emit mouseReleased();
|
||||
QWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void PatternWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
//! it is needed from Qt, otherwise QWidget is not updated
|
||||
|
@ -49,10 +49,12 @@ public:
|
||||
signals:
|
||||
void backgroundChanged();
|
||||
void textColorChanged();
|
||||
void mouseReleased();
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event ) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private slots:
|
||||
|
Loading…
Reference in New Issue
Block a user