1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-11 13:18:13 +03:00

expose views data through views dialog

This commit is contained in:
Michail Vourlakos 2021-04-01 12:12:08 +03:00
parent c7932ea83a
commit 7aa94bede1
6 changed files with 88 additions and 5 deletions

View File

@ -230,9 +230,6 @@ void Layouts::initializeSelectedLayoutViews()
m_model->setOriginalViewsForLayout(originalSelectedData);
m_model->setLayoutProperties(selectedCurrentData);
qDebug() << "Views For Original Layout :: " << originalSelectedData.name;
selectedCurrentData.views.print();
if (!islayoutactive) {
central->deleteLater();
}

View File

@ -55,6 +55,8 @@ Views::Views(Settings::Handler::ViewsHandler *parent)
connect(m_model, &Model::Views::rowsInserted, this, &Views::dataChanged);
connect(m_model, &Model::Views::rowsRemoved, this, &Views::dataChanged);
connect(m_handler, &Handler::ViewsHandler::currentLayoutChanged, this, &Views::onCurrentLayoutChanged);
init();
}
@ -123,6 +125,12 @@ void Views::selectRow(const QString &id)
// m_view->selectRow(rowForId(id));
}
void Views::onCurrentLayoutChanged()
{
Data::Layout layout = m_handler->currentData();
m_model->setOriginalData(layout.views);
}
void Views::applyColumnWidths()
{
m_view->horizontalHeader()->setSectionResizeMode(Model::Views::NAMECOLUMN, QHeaderView::Stretch);

View File

@ -89,6 +89,8 @@ private slots:
void storeColumnWidths();
void applyColumnWidths();
void onCurrentLayoutChanged();
private:
Settings::Handler::ViewsHandler *m_handler{nullptr};

View File

@ -76,6 +76,8 @@ void ViewsHandler::init()
reload();
emit currentLayoutChanged();
//! connect layout combobox after the selected layout has been loaded
connect(m_ui->layoutsCmb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ViewsHandler::onCurrentLayoutIndexChanged);

View File

@ -20,6 +20,9 @@
#include "viewsmodel.h"
// local
#include <coretypes.h>
// KDE
#include <KLocalizedString>
@ -118,7 +121,7 @@ QVariant Views::headerData(int section, Qt::Orientation orientation, int role) c
if (role == Qt::DisplayRole) {
return QString(i18n("Screen"));
}
/* } else if (role == Qt::DecorationRole) {
/* } else if (role == Qt::DecorationRole) {
return QIcon::fromTheme("desktop");
}*/
break;
@ -126,7 +129,7 @@ QVariant Views::headerData(int section, Qt::Orientation orientation, int role) c
if (role == Qt::DisplayRole) {
return QString(i18nc("screen edge", "Edge"));
}
/* } else if (role == Qt::DecorationRole) {
/* } else if (role == Qt::DecorationRole) {
return QIcon::fromTheme("transform-move");
}*/
break;
@ -138,6 +141,10 @@ QVariant Views::headerData(int section, Qt::Orientation orientation, int role) c
return QIcon::fromTheme("format-justify-center");
}*/
break;
case SUBCONTAINMENTSCOLUMN:
if (role == Qt::DisplayRole) {
return QString(i18n("Includes"));
}
default:
break;
};
@ -156,6 +163,72 @@ QVariant Views::data(const QModelIndex &index, int role) const
return QVariant{};
}
if (role == IDROLE) {
return m_viewsTable[row].id;
} else if (role == ISACTIVEROLE) {
return m_viewsTable[row].isActive;
}
if (role == Qt::TextAlignmentRole){
return static_cast<Qt::Alignment::Int>(Qt::AlignHCenter | Qt::AlignVCenter);
}
switch (column) {
case IDCOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
return m_viewsTable[row].id;
}
break;
case NAMECOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
return m_viewsTable[row].name;
}
break;
case SCREENCOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
return (m_viewsTable[row].onPrimary ? QString("Primary") : QString::number(m_viewsTable[row].screen));
}
break;
case EDGECOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
if (m_viewsTable[row].edge == Plasma::Types::BottomEdge) {
return QString("Bottom");
} else if (m_viewsTable[row].edge == Plasma::Types::TopEdge) {
return QString("Top");
} else if (m_viewsTable[row].edge == Plasma::Types::LeftEdge) {
return QString("Left");
} else if (m_viewsTable[row].edge == Plasma::Types::RightEdge) {
return QString("Right");
}
return QString("Unknown");
}
break;
case ALIGNMENTCOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
if (m_viewsTable[row].alignment == Latte::Types::Center) {
return QString("Center");
} else if (m_viewsTable[row].alignment == Latte::Types::Left) {
return QString("Left");
} else if (m_viewsTable[row].alignment == Latte::Types::Right) {
return QString("Right");
} else if (m_viewsTable[row].alignment == Latte::Types::Top) {
return QString("Top");
} else if (m_viewsTable[row].alignment == Latte::Types::Bottom) {
return QString("Bottom");
} else if (m_viewsTable[row].alignment == Latte::Types::Justify) {
return QString("Justify");
}
return QString("Unknown");
}
break;
case SUBCONTAINMENTSCOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
return m_viewsTable[row].subcontainments.rowCount()>0 ? QString("{" + m_viewsTable[row].subcontainments + "}") : QString();
}
};
return QVariant{};
}

View File

@ -46,6 +46,7 @@ public:
SCREENCOLUMN,
EDGECOLUMN,
ALIGNMENTCOLUMN,
SUBCONTAINMENTSCOLUMN,
LASTCOLUMN
};