viewsdialog:apply live screen edges changes

work/spdx
Michail Vourlakos 4 years ago
parent 9a37926348
commit 195a24b33c

@ -1478,6 +1478,21 @@ void GenericLayout::newView(const QString &templateFile)
emit viewEdgeChanged();
}
void GenericLayout::updateView(const Latte::Data::View &viewData)
{
if (!isActive()) {
return;
}
auto view = viewForContainment(viewData.id.toUInt());
if (view) {
//const QString layoutName, const QString screenId, int edge, int alignment
view->positioner()->setNextLocation("", "", viewData.edge, Latte::Types::NoneAlignment);
}
}
void GenericLayout::importToCorona()
{
Layouts::Storage::self()->importToCorona(this);

@ -120,6 +120,8 @@ public:
void recreateView(Plasma::Containment *containment, bool delayed = true);
bool latteViewExists(Plasma::Containment *containment);
void updateView(const Latte::Data::View &viewData);
//! Available edges for specific view in that screen
virtual QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const;
//! All free edges in that screen

@ -189,6 +189,17 @@ bool Layouts::hasSelectedLayout() const
return (selectedRow >= 0);
}
bool Layouts::isSelectedLayoutOriginal() const
{
if (!hasSelectedLayout()) {
return false;
}
Data::Layout currentData = selectedLayoutCurrentData();
return m_model->originalLayoutsData().containsId(currentData.id);
}
QString Layouts::colorPath(const QString color) const
{
QString path = m_iconsPath + color + "print.jpg";

@ -73,6 +73,7 @@ public:
void sortByColumn(int column, Qt::SortOrder order);
bool hasSelectedLayout() const;
bool isSelectedLayoutOriginal() const;
const Latte::Data::Layout selectedLayoutCurrentData() const;
const Latte::Data::Layout selectedLayoutOriginalData() const;
const Latte::Data::LayoutIcon selectedLayoutIcon() const;

@ -29,6 +29,9 @@
#include "delegates/singleoptiondelegate.h"
#include "delegates/singletextdelegate.h"
#include "../generic/generictools.h"
#include "../../layout/centrallayout.h"
#include "../../layouts/manager.h"
#include "../../layouts/synchronizer.h"
// Qt
#include <QHeaderView>
@ -195,6 +198,27 @@ void Views::onCurrentLayoutChanged()
m_model->setOriginalData(layout.views);
}
void Views::save()
{
Latte::Data::Layout originallayout = m_handler->originalData();
Latte::CentralLayout *centralActive = m_handler->isSelectedLayoutOriginal() ? m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originallayout.name) : nullptr;
if (!centralActive) {
return;
}
Latte::Data::ViewsTable alteredViews = m_model->alteredViews();
for (int i=0; i<alteredViews.rowCount(); ++i) {
if (alteredViews[i].state() == Data::View::IsCreated) {
qDebug() << "org.kde.latte updating altered view :: " << alteredViews[i];
centralActive->updateView(alteredViews[i]);
}
}
Latte::Data::ViewsTable currentViews = m_model->currentViewsData();
m_model->setOriginalData(currentViews);
}
QString Views::uniqueViewName(QString name)
{

@ -76,7 +76,7 @@ public:
//! actions
void reset();
// void save();
void save();
void removeSelected();
signals:

@ -58,6 +58,8 @@ ViewsDialog::ViewsDialog(SettingsDialog *parent, Controller::Layouts *controller
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
this, &ViewsDialog::onReset);
connect(m_applyNowBtn, &QPushButton::clicked, this, &ViewsDialog::onApply);
resize(m_windowSize);
updateApplyButtonsState();
}
@ -102,6 +104,12 @@ void ViewsDialog::onOk()
close();
}
void ViewsDialog::onApply()
{
qDebug() << Q_FUNC_INFO;
m_handler->save();
}
void ViewsDialog::onCancel()
{
qDebug() << Q_FUNC_INFO;

@ -70,6 +70,7 @@ private slots:
void saveConfig();
void onOk();
void onApply();
void onCancel();
void onReset();

@ -119,8 +119,6 @@ void ViewsHandler::init()
void ViewsHandler::initViewTemplatesSubMenu()
{
if (!m_viewTemplatesSubMenu) {
m_viewTemplatesSubMenu = new QMenu(m_ui->newBtn);
m_viewTemplatesSubMenu->setMinimumWidth(m_ui->newBtn->width() * 2);
@ -194,6 +192,11 @@ Latte::Data::Layout ViewsHandler::currentData() const
return o_data;
}
Latte::Data::Layout ViewsHandler::originalData() const
{
return m_dialog->layoutsController()->selectedLayoutOriginalData();
}
bool ViewsHandler::hasChangedData() const
{
return m_viewsController->hasChangedData();
@ -205,6 +208,10 @@ bool ViewsHandler::inDefaultValues() const
return true;
}
bool ViewsHandler::isSelectedLayoutOriginal() const
{
return m_dialog->layoutsController()->isSelectedLayoutOriginal();
}
void ViewsHandler::reset()
{
@ -218,6 +225,7 @@ void ViewsHandler::resetDefaults()
void ViewsHandler::save()
{
m_viewsController->save();
// m_dialog->layoutsController()->setLayoutProperties(currentData());
}

@ -67,7 +67,10 @@ public:
bool hasChangedData() const override;
bool inDefaultValues() const override;
bool isSelectedLayoutOriginal() const;
Latte::Data::Layout currentData() const;
Latte::Data::Layout originalData() const;
Ui::ViewsDialog *ui() const;
Latte::Corona *corona() const;

@ -228,6 +228,21 @@ Latte::Data::Screen Views::screenData(const QString &viewId) const
return Latte::Data::Screen();
}
Latte::Data::ViewsTable Views::alteredViews() const
{
Latte::Data::ViewsTable views;
for(int i=0; i<rowCount(); ++i) {
QString currentId = m_viewsTable[i].id;
if (!o_viewsTable.containsId(currentId)
|| m_viewsTable[currentId] != o_viewsTable[currentId]) {
views << m_viewsTable[i];
}
}
return views;
}
void Views::populateScreens()
{

@ -107,6 +107,8 @@ public:
void setOriginalData(Latte::Data::ViewsTable &data);
Latte::Data::ViewsTable alteredViews() const;
signals:
void rowsInserted();
void rowsRemoved();

Loading…
Cancel
Save