details:add clear pattern button

pull/19/head
Michail Vourlakos 5 years ago
parent 0286966cab
commit c3fd137032

@ -345,7 +345,7 @@ void AbstractLayout::loadConfig()
m_color = m_layoutGroup.readEntry("color", QString("blue")); m_color = m_layoutGroup.readEntry("color", QString("blue"));
m_backgroundStyle = static_cast<BackgroundStyle>(m_layoutGroup.readEntry("backgroundStyle", (int)ColorBackgroundStyle)); m_backgroundStyle = static_cast<BackgroundStyle>(m_layoutGroup.readEntry("backgroundStyle", (int)ColorBackgroundStyle));
QString deprecatedTextColor = m_layoutGroup.readEntry("textColor", QString("fcfcfc")); QString deprecatedTextColor = m_layoutGroup.readEntry("textColor", QString());
QString deprecatedBackground = m_layoutGroup.readEntry("background", QString()); QString deprecatedBackground = m_layoutGroup.readEntry("background", QString());
if (deprecatedBackground.startsWith("/")) { if (deprecatedBackground.startsWith("/")) {
@ -359,7 +359,7 @@ void AbstractLayout::loadConfig()
saveConfig(); saveConfig();
} else { } else {
m_customBackground = m_layoutGroup.readEntry("customBackground", QString("")); m_customBackground = m_layoutGroup.readEntry("customBackground", QString(""));
m_customTextColor = m_layoutGroup.readEntry("customTextColor", QString("fcfcfc")); m_customTextColor = m_layoutGroup.readEntry("customTextColor", QString(""));
} }
} }

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>550</width> <width>569</width>
<height>615</height> <height>615</height>
</rect> </rect>
</property> </property>
@ -79,7 +79,7 @@
<widget class="Latte::Settings::Widget::PatternWidget" name="backPatternWidget" native="true"> <widget class="Latte::Settings::Widget::PatternWidget" name="backPatternWidget" native="true">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>320</width> <width>358</width>
<height>60</height> <height>60</height>
</size> </size>
</property> </property>
@ -147,7 +147,7 @@
<widget class="QComboBox" name="colorsCmb"> <widget class="QComboBox" name="colorsCmb">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>320</width> <width>358</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -286,6 +286,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="patternClearBtn">
<property name="minimumSize">
<size>
<width>30</width>
<height>5</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="edit-clear">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -325,7 +348,7 @@
<widget class="Latte::Settings::Widget::PatternWidget" name="colorPatternWidget" native="true"> <widget class="Latte::Settings::Widget::PatternWidget" name="colorPatternWidget" native="true">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>320</width> <width>358</width>
<height>60</height> <height>60</height>
</size> </size>
</property> </property>
@ -487,7 +510,7 @@
<widget class="QComboBox" name="layoutsCmb"> <widget class="QComboBox" name="layoutsCmb">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>320</width> <width>358</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>

@ -72,6 +72,8 @@ void DetailsHandler::init()
m_ui->colorsCmb->setItemDelegate(new Details::Delegate::ColorCmbBoxItem(this)); m_ui->colorsCmb->setItemDelegate(new Details::Delegate::ColorCmbBoxItem(this));
m_ui->colorsCmb->setModel(m_colorsModel); m_ui->colorsCmb->setModel(m_colorsModel);
m_ui->patternClearBtn->setFixedHeight(m_ui->backgroundBtn->height()+2);
connect(m_backButtonsGroup, static_cast<void(QButtonGroup::*)(int, bool)>(&QButtonGroup::buttonToggled), connect(m_backButtonsGroup, static_cast<void(QButtonGroup::*)(int, bool)>(&QButtonGroup::buttonToggled),
[ = ](int id, bool checked) { [ = ](int id, bool checked) {
@ -82,6 +84,8 @@ void DetailsHandler::init()
connect(m_ui->backgroundBtn, &QPushButton::pressed, this, &DetailsHandler::selectBackground); connect(m_ui->backgroundBtn, &QPushButton::pressed, this, &DetailsHandler::selectBackground);
connect(m_ui->textColorBtn, &QPushButton::pressed, this, &DetailsHandler::selectTextColor); connect(m_ui->textColorBtn, &QPushButton::pressed, this, &DetailsHandler::selectTextColor);
connect(m_ui->patternClearBtn, &QPushButton::pressed, this, &DetailsHandler::on_clearPattern);
//! Options //! Options
connect(m_ui->inMenuChk, &QCheckBox::stateChanged, this, [&]() { connect(m_ui->inMenuChk, &QCheckBox::stateChanged, this, [&]() {
@ -137,6 +141,7 @@ void DetailsHandler::loadLayout(const Data::Layout &data)
m_ui->colorsCmb->setVisible(true); m_ui->colorsCmb->setVisible(true);
m_ui->backgroundBtn->setVisible(false); m_ui->backgroundBtn->setVisible(false);
m_ui->textColorBtn->setVisible(false); m_ui->textColorBtn->setVisible(false);
m_ui->patternClearBtn->setVisible(false);
} else { } else {
m_ui->colorRadioBtn->setChecked(false); m_ui->colorRadioBtn->setChecked(false);
m_ui->backRadioBtn->setChecked(true); m_ui->backRadioBtn->setChecked(true);
@ -144,6 +149,7 @@ void DetailsHandler::loadLayout(const Data::Layout &data)
m_ui->colorsCmb->setVisible(false); m_ui->colorsCmb->setVisible(false);
m_ui->backgroundBtn->setVisible(true); m_ui->backgroundBtn->setVisible(true);
m_ui->textColorBtn->setVisible(true); m_ui->textColorBtn->setVisible(true);
m_ui->patternClearBtn->setVisible(true);
} }
m_ui->colorPatternWidget->setBackground(m_colorsModel->colorPath(data.color)); m_ui->colorPatternWidget->setBackground(m_colorsModel->colorPath(data.color));
@ -159,6 +165,13 @@ void DetailsHandler::loadLayout(const Data::Layout &data)
m_ui->backPatternWidget->setTextColor(data.textColor); m_ui->backPatternWidget->setTextColor(data.textColor);
} }
qDebug() << " VALUES : " << data.background << "_" << data.textColor;
if (!data.background.isEmpty() || !data.textColor.isEmpty()) {
m_ui->patternClearBtn->setEnabled(true);
} else {
m_ui->patternClearBtn->setEnabled(false);
}
m_ui->inMenuChk->setChecked(data.isShownInMenu); m_ui->inMenuChk->setChecked(data.isShownInMenu);
m_ui->borderlessChk->setChecked(data.hasDisabledBorders); m_ui->borderlessChk->setChecked(data.hasDisabledBorders);
} }
@ -195,6 +208,12 @@ void DetailsHandler::save()
{ {
} }
void DetailsHandler::on_clearPattern()
{
setBackground("");
setTextColor("");
}
void DetailsHandler::on_currentColorIndexChanged(int row) void DetailsHandler::on_currentColorIndexChanged(int row)
{ {
QString selectedColor = m_ui->colorsCmb->itemData(row, Model::Colors::IDROLE).toString(); QString selectedColor = m_ui->colorsCmb->itemData(row, Model::Colors::IDROLE).toString();

@ -78,9 +78,10 @@ public:
signals: signals:
void currentLayoutChanged(); void currentLayoutChanged();
private: private slots:
void on_currentLayoutIndexChanged(int row); void on_currentLayoutIndexChanged(int row);
void on_currentColorIndexChanged(int row); void on_currentColorIndexChanged(int row);
void on_clearPattern();
private: private:
void init(); void init();

Loading…
Cancel
Save