first connections,Details window and Layouts Model

pull/14/head
Michail Vourlakos 5 years ago
parent c067764013
commit 5a1237fb6a

@ -358,6 +358,11 @@ void Layouts::selectRow(int index)
m_view->selectRow(index); m_view->selectRow(index);
} }
void Layouts::setLayoutProperties(const Data::Layout &layout)
{
m_model->setLayoutProperties(layout);
}
QString Layouts::layoutNameForFreeActivities() const QString Layouts::layoutNameForFreeActivities() const
{ {
return m_model->layoutNameForFreeActivities(); return m_model->layoutNameForFreeActivities();

@ -73,6 +73,7 @@ public:
const Data::Layout selectedLayoutOriginalData() const; const Data::Layout selectedLayoutOriginalData() const;
void selectRow(int index); void selectRow(int index);
void setLayoutProperties(const Data::Layout &layout);
//! actions //! actions
void reset(); void reset();

@ -40,6 +40,12 @@ DetailsDialog::DetailsDialog(SettingsDialog *parent, Controller::Layouts *contro
m_ui->setupUi(this); m_ui->setupUi(this);
//! we must create handlers after creating/adjusting the ui //! we must create handlers after creating/adjusting the ui
m_handler = new Handler::DetailsHandler(this); 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() DetailsDialog::~DetailsDialog()
@ -56,6 +62,23 @@ Ui::DetailsDialog *DetailsDialog::ui() const
return m_ui; 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; Ui::DetailsDialog *ui() const;
Controller::Layouts *layoutsController() const; Controller::Layouts *layoutsController() const;
private slots:
void accept() override;
void on_apply();
void on_reset();
private: private:
SettingsDialog *m_parentDlg{nullptr}; SettingsDialog *m_parentDlg{nullptr};
Ui::DetailsDialog *m_ui; Ui::DetailsDialog *m_ui;

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Details</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
@ -68,7 +68,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>160</width> <width>220</width>
<height>60</height> <height>60</height>
</size> </size>
</property> </property>
@ -317,7 +317,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>160</width> <width>220</width>
<height>60</height> <height>60</height>
</size> </size>
</property> </property>
@ -374,7 +374,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="mainButtonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -396,7 +396,7 @@
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>mainButtonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>DetailsDialog</receiver> <receiver>DetailsDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
@ -412,7 +412,7 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>mainButtonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>DetailsDialog</receiver> <receiver>DetailsDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>

@ -50,10 +50,6 @@
#include <KWindowSystem> #include <KWindowSystem>
#define TWINENABLED "Enabled"
#define TWINVISIBLE "Visible"
#define TWINCHECKED "Checked"
namespace Latte { namespace Latte {
namespace Settings { namespace Settings {
namespace Dialog { namespace Dialog {
@ -74,12 +70,12 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
loadConfig(); loadConfig();
connect(m_ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked connect(m_ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
, this, &SettingsDialog::apply); this, &SettingsDialog::apply);
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
, this, &SettingsDialog::reset); this, &SettingsDialog::reset);
connect(m_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked connect(m_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked,
, this, &SettingsDialog::restoreDefaults); this, &SettingsDialog::restoreDefaults);
//! Global Menu //! Global Menu
initGlobalMenu(); initGlobalMenu();

@ -85,6 +85,8 @@ bool DetailsHandler::inDefaultValues() const
void DetailsHandler::reset() void DetailsHandler::reset()
{ {
c_data = o_data;
emit currentLayoutChanged();
} }
void DetailsHandler::resetDefaults() void DetailsHandler::resetDefaults()
@ -103,6 +105,16 @@ void DetailsHandler::on_currentIndexChanged(int index)
emit currentLayoutChanged(); 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; Data::Layout currentData() const;
void setIsShownInMenu(bool inMenu);
void setHasDisabledBorders(bool disabled);
signals: signals:
void currentLayoutChanged(); 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); connect(m_parentHandler, &DetailsHandler::currentLayoutChanged, this, &DetailsInfoHandler::reload);
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) bool Layouts::removeRows(int row, int count, const QModelIndex &parent)
{ {
Q_UNUSED(parent) Q_UNUSED(parent)

@ -118,8 +118,9 @@ public:
//! all original data will become also current //! all original data will become also current
void resetData(); void resetData();
void appendLayout(const Settings::Data::Layout &layout); void appendLayout(const Data::Layout &layout);
void removeLayout(const QString &id); void removeLayout(const QString &id);
void setLayoutProperties(const Data::Layout &layout);
QString layoutNameForFreeActivities() const; QString layoutNameForFreeActivities() const;
void setCurrentLayoutForFreeActivities(const QString &id); void setCurrentLayoutForFreeActivities(const QString &id);

Loading…
Cancel
Save