From 622cc6988c68d556bdea0914ff9e974216caa851 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos <mvourlakos@gmail.com> Date: Sun, 21 Mar 2021 16:54:58 +0200 Subject: [PATCH] provide debug messages for ViewsTable --- app/data/generictable.cpp | 15 ++++++++ app/data/generictable.h | 1 + app/data/viewdata.cpp | 47 +++++++++++++++++++++++ app/data/viewdata.h | 1 + app/data/viewstable.cpp | 10 +++++ app/data/viewstable.h | 2 + app/layout/genericlayout.cpp | 5 +++ app/layout/genericlayout.h | 3 ++ app/settings/viewsdialog/viewshandler.cpp | 28 ++++++++++++++ 9 files changed, 112 insertions(+) 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<T>::operator[](const uint &index) const return m_list[index]; } +template <class T> +GenericTable<T>::operator QString() const +{ + QString result; + + for(int i=0; i<m_list.count(); ++i) { + result += m_list[i].id; + if (i<(m_list.count()-1)) { + result += ", "; + } + } + + return result; +} + template <class T> bool GenericTable<T>::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; i<rowCount(); ++i) { + qDebug().noquote() << QString::number(i+1) << " | " << m_list[i]; + } +} + } } diff --git a/app/data/viewstable.h b/app/data/viewstable.h index d2c9a874f..83992008e 100644 --- a/app/data/viewstable.h +++ b/app/data/viewstable.h @@ -41,6 +41,8 @@ public: bool isInitialized{false}; + void print(); + //! Operators ViewsTable &operator=(const ViewsTable &rhs); ViewsTable &operator=(ViewsTable &&rhs); diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp index 722a6a412..9edd01d1c 100644 --- a/app/layout/genericlayout.cpp +++ b/app/layout/genericlayout.cpp @@ -1489,5 +1489,10 @@ bool GenericLayout::isBroken() const return Layouts::Storage::self()->isBroken(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 <coretypes.h> #include "abstractlayout.h" #include "../data/viewdata.h" +#include "../data/viewstable.h" // Qt #include <QObject> @@ -135,6 +136,8 @@ public: QList<int> 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 <QMessageBox> @@ -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