mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-13 16:58:17 +03:00
first connections,Details window and Layouts Model
This commit is contained in:
parent
c067764013
commit
5a1237fb6a
@ -358,6 +358,11 @@ void Layouts::selectRow(int index)
|
||||
m_view->selectRow(index);
|
||||
}
|
||||
|
||||
void Layouts::setLayoutProperties(const Data::Layout &layout)
|
||||
{
|
||||
m_model->setLayoutProperties(layout);
|
||||
}
|
||||
|
||||
QString Layouts::layoutNameForFreeActivities() const
|
||||
{
|
||||
return m_model->layoutNameForFreeActivities();
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
const Data::Layout selectedLayoutOriginalData() const;
|
||||
|
||||
void selectRow(int index);
|
||||
void setLayoutProperties(const Data::Layout &layout);
|
||||
|
||||
//! actions
|
||||
void reset();
|
||||
|
@ -40,6 +40,12 @@ DetailsDialog::DetailsDialog(SettingsDialog *parent, Controller::Layouts *contro
|
||||
m_ui->setupUi(this);
|
||||
//! we must create handlers after creating/adjusting the ui
|
||||
m_handler = new Handler::DetailsHandler(this);
|
||||
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
this, &DetailsDialog::on_apply);
|
||||
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
|
||||
this, &DetailsDialog::on_reset);
|
||||
}
|
||||
|
||||
DetailsDialog::~DetailsDialog()
|
||||
@ -56,6 +62,23 @@ Ui::DetailsDialog *DetailsDialog::ui() const
|
||||
return m_ui;
|
||||
}
|
||||
|
||||
void DetailsDialog::accept()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void DetailsDialog::on_apply()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_layoutsController->setLayoutProperties(m_handler->currentData());
|
||||
}
|
||||
|
||||
void DetailsDialog::on_reset()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_handler->reset();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,12 @@ public:
|
||||
Ui::DetailsDialog *ui() const;
|
||||
Controller::Layouts *layoutsController() const;
|
||||
|
||||
private slots:
|
||||
void accept() override;
|
||||
|
||||
void on_apply();
|
||||
void on_reset();
|
||||
|
||||
private:
|
||||
SettingsDialog *m_parentDlg{nullptr};
|
||||
Ui::DetailsDialog *m_ui;
|
||||
|
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Details</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@ -68,7 +68,7 @@
|
||||
<widget class="Latte::Settings::Widget::PatternWidget" name="backPatternWidget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<width>220</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -317,7 +317,7 @@
|
||||
<widget class="Latte::Settings::Widget::PatternWidget" name="colorPatternWidget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<width>220</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -374,7 +374,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="mainButtonBox">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -396,7 +396,7 @@
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>mainButtonBox</sender>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DetailsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
@ -412,7 +412,7 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>mainButtonBox</sender>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DetailsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
|
@ -50,10 +50,6 @@
|
||||
#include <KWindowSystem>
|
||||
|
||||
|
||||
#define TWINENABLED "Enabled"
|
||||
#define TWINVISIBLE "Visible"
|
||||
#define TWINCHECKED "Checked"
|
||||
|
||||
namespace Latte {
|
||||
namespace Settings {
|
||||
namespace Dialog {
|
||||
@ -74,12 +70,12 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
|
||||
loadConfig();
|
||||
|
||||
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked
|
||||
, this, &SettingsDialog::apply);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked
|
||||
, this, &SettingsDialog::reset);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked
|
||||
, this, &SettingsDialog::restoreDefaults);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
this, &SettingsDialog::apply);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
|
||||
this, &SettingsDialog::reset);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked,
|
||||
this, &SettingsDialog::restoreDefaults);
|
||||
|
||||
//! Global Menu
|
||||
initGlobalMenu();
|
||||
|
@ -85,6 +85,8 @@ bool DetailsHandler::inDefaultValues() const
|
||||
|
||||
void DetailsHandler::reset()
|
||||
{
|
||||
c_data = o_data;
|
||||
emit currentLayoutChanged();
|
||||
}
|
||||
|
||||
void DetailsHandler::resetDefaults()
|
||||
@ -103,6 +105,16 @@ void DetailsHandler::on_currentIndexChanged(int index)
|
||||
emit currentLayoutChanged();
|
||||
}
|
||||
|
||||
void DetailsHandler::setIsShownInMenu(bool inMenu)
|
||||
{
|
||||
c_data.isShownInMenu = inMenu;
|
||||
}
|
||||
|
||||
void DetailsHandler::setHasDisabledBorders(bool disabled)
|
||||
{
|
||||
c_data.hasDisabledBorders = disabled;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
|
||||
Data::Layout currentData() const;
|
||||
|
||||
void setIsShownInMenu(bool inMenu);
|
||||
void setHasDisabledBorders(bool disabled);
|
||||
|
||||
signals:
|
||||
void currentLayoutChanged();
|
||||
|
||||
|
@ -60,6 +60,14 @@ void DetailsInfoHandler::init()
|
||||
}
|
||||
});
|
||||
|
||||
connect(m_ui->inMenuChk, &QCheckBox::stateChanged, this, [&]() {
|
||||
m_parentHandler->setIsShownInMenu(m_ui->inMenuChk->isChecked());
|
||||
});
|
||||
|
||||
connect(m_ui->borderlessChk, &QCheckBox::stateChanged, this, [&]() {
|
||||
m_parentHandler->setHasDisabledBorders(m_ui->borderlessChk->isChecked());
|
||||
});
|
||||
|
||||
connect(m_parentHandler, &DetailsHandler::currentLayoutChanged, this, &DetailsInfoHandler::reload);
|
||||
|
||||
reload();
|
||||
|
@ -165,6 +165,19 @@ void Layouts::removeLayout(const QString &id)
|
||||
}
|
||||
}
|
||||
|
||||
void Layouts::setLayoutProperties(const Data::Layout &layout)
|
||||
{
|
||||
if (m_layoutsTable.containsId(layout.id) && m_layoutsTable[layout.id] != layout) {
|
||||
m_layoutsTable[layout.id] = layout;
|
||||
int dataRow = m_layoutsTable.indexOf(layout.id);
|
||||
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole;
|
||||
roles << Qt::UserRole;
|
||||
emit dataChanged(index(dataRow, IDCOLUMN), index(dataRow, SHAREDCOLUMN), roles);
|
||||
}
|
||||
}
|
||||
|
||||
bool Layouts::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
@ -118,8 +118,9 @@ public:
|
||||
//! all original data will become also current
|
||||
void resetData();
|
||||
|
||||
void appendLayout(const Settings::Data::Layout &layout);
|
||||
void appendLayout(const Data::Layout &layout);
|
||||
void removeLayout(const QString &id);
|
||||
void setLayoutProperties(const Data::Layout &layout);
|
||||
|
||||
QString layoutNameForFreeActivities() const;
|
||||
void setCurrentLayoutForFreeActivities(const QString &id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user