diff --git a/app/data/generictable.cpp b/app/data/generictable.cpp index ce0a99090..d6c44160d 100644 --- a/app/data/generictable.cpp +++ b/app/data/generictable.cpp @@ -173,6 +173,21 @@ const T GenericTable::operator[](const uint &index) const return m_list[index]; } +template +GenericTable::operator QString() const +{ + QString result; + + for(int i=0; i bool GenericTable::containsId(const QString &id) const { diff --git a/app/data/generictable.h b/app/data/generictable.h index 4646b6bad..e92456df5 100644 --- a/app/data/generictable.h +++ b/app/data/generictable.h @@ -54,6 +54,7 @@ public: const T operator[](const QString &id) const; T &operator[](const uint &index); const T operator[](const uint &index) const; + operator QString() const; bool containsId(const QString &id) const; bool containsName(const QString &name) const; diff --git a/app/data/viewdata.cpp b/app/data/viewdata.cpp index b853eda64..23359f869 100644 --- a/app/data/viewdata.cpp +++ b/app/data/viewdata.cpp @@ -117,6 +117,53 @@ bool View::operator!=(const View &rhs) const return !(*this == rhs); } +View::operator QString() const +{ + QString result; + + result += id; + result +=" : "; + result += isActive ? "Active" : "Inactive"; + result += " : "; + result += onPrimary ? "Primary" : "Explicit"; + result += " : "; + result += QString::number(screen); + result += " : "; + if (edge == Plasma::Types::BottomEdge) { + result += "BottomEdge"; + } else if (edge == Plasma::Types::TopEdge) { + result += "TopEdge"; + } else if (edge == Plasma::Types::LeftEdge) { + result += "LeftEdge"; + } else if (edge == Plasma::Types::RightEdge) { + result += "RightEdge"; + } + + result += " : "; + + if (alignment == Latte::Types::Center) { + result += "CenterAlignment"; + } else if (alignment == Latte::Types::Left) { + result += "LeftAlignment"; + } else if (alignment == Latte::Types::Right) { + result += "RightAlignment"; + } else if (alignment == Latte::Types::Top) { + result += "TopAlignment"; + } else if (alignment == Latte::Types::Bottom) { + result += "BottomAlignment"; + } else if (alignment == Latte::Types::Justify) { + result += "JustifyAlignment"; + } + + result += " : "; + result += QString::number(maxLength); + + result += " || "; + result += subcontainments; + + return result; +} + bool View::isCreated() const { return m_state == IsCreated; diff --git a/app/data/viewdata.h b/app/data/viewdata.h index d1fbefdec..e8db9d64b 100644 --- a/app/data/viewdata.h +++ b/app/data/viewdata.h @@ -76,6 +76,7 @@ public: View &operator=(View &&rhs); bool operator==(const View &rhs) const; bool operator!=(const View &rhs) const; + operator QString() const; protected: View::State m_state{IsInvalid}; diff --git a/app/data/viewstable.cpp b/app/data/viewstable.cpp index 909b0e835..1eefe584e 100644 --- a/app/data/viewstable.cpp +++ b/app/data/viewstable.cpp @@ -71,6 +71,16 @@ bool ViewsTable::operator!=(const ViewsTable &rhs) const return !(*this == rhs); } +void ViewsTable::print() +{ + qDebug().noquote() << "Views initialized : " + (isInitialized ? QString("true") : QString("false")); + qDebug().noquote() << "aa | id | active | primary | screen | edge | alignment | maxlength | subcontainments"; + + for(int i=0; iisBroken(this, errors); } +Latte::Data::ViewsTable GenericLayout::viewsTable() const +{ + return Layouts::Storage::self()->views(this); +} + } } diff --git a/app/layout/genericlayout.h b/app/layout/genericlayout.h index 23466606e..cd21566d5 100644 --- a/app/layout/genericlayout.h +++ b/app/layout/genericlayout.h @@ -24,6 +24,7 @@ #include #include "abstractlayout.h" #include "../data/viewdata.h" +#include "../data/viewstable.h" // Qt #include @@ -135,6 +136,8 @@ public: QList viewsScreens(); + Latte::Data::ViewsTable viewsTable() const; + public slots: Q_INVOKABLE void newView(const QString &templateFile); Q_INVOKABLE int viewsWithTasks() const; diff --git a/app/settings/viewsdialog/viewshandler.cpp b/app/settings/viewsdialog/viewshandler.cpp index b7f7003cb..5109a8e97 100644 --- a/app/settings/viewsdialog/viewshandler.cpp +++ b/app/settings/viewsdialog/viewshandler.cpp @@ -28,6 +28,9 @@ #include "../settingsdialog/delegates/layoutcmbitemdelegate.h" #include "../../data/layoutstable.h" #include "../../layout/abstractlayout.h" +#include "../../layout/centrallayout.h" +#include "../../layouts/manager.h" +#include "../../layouts/synchronizer.h" // Qt #include @@ -77,11 +80,34 @@ void ViewsHandler::init() void ViewsHandler::reload() { o_data = m_dialog->layoutsController()->selectedLayoutCurrentData(); + + bool islayoutalreadyloaded{o_data == c_data}; + c_data = o_data; m_ui->layoutsCmb->setCurrentText(o_data.name); loadLayout(c_data); + + if (!islayoutalreadyloaded) { + //! Views + Data::Layout originalSelectedData = m_dialog->layoutsController()->selectedLayoutOriginalData(); + CentralLayout *central = m_dialog->corona()->layoutsManager()->synchronizer()->centralLayout(originalSelectedData.name); + + bool islayoutactive{true}; + + if (!central) { + islayoutactive = false; + central = new CentralLayout(this, originalSelectedData.id); + } + + qDebug() << "Views For Original Layout :: " << originalSelectedData.name; + central->viewsTable().print(); + + if (!islayoutactive) { + central->deleteLater(); + } + } } void ViewsHandler::loadLayout(const Latte::Data::Layout &data) @@ -143,6 +169,8 @@ void ViewsHandler::onCurrentLayoutIndexChanged(int row) m_dialog->layoutsController()->selectRow(layoutId); reload(); + + emit currentLayoutChanged(); } else { //! reset combobox index