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:
parent
c7932ea83a
commit
7aa94bede1
@ -230,9 +230,6 @@ void Layouts::initializeSelectedLayoutViews()
|
|||||||
m_model->setOriginalViewsForLayout(originalSelectedData);
|
m_model->setOriginalViewsForLayout(originalSelectedData);
|
||||||
m_model->setLayoutProperties(selectedCurrentData);
|
m_model->setLayoutProperties(selectedCurrentData);
|
||||||
|
|
||||||
qDebug() << "Views For Original Layout :: " << originalSelectedData.name;
|
|
||||||
selectedCurrentData.views.print();
|
|
||||||
|
|
||||||
if (!islayoutactive) {
|
if (!islayoutactive) {
|
||||||
central->deleteLater();
|
central->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,8 @@ Views::Views(Settings::Handler::ViewsHandler *parent)
|
|||||||
connect(m_model, &Model::Views::rowsInserted, this, &Views::dataChanged);
|
connect(m_model, &Model::Views::rowsInserted, this, &Views::dataChanged);
|
||||||
connect(m_model, &Model::Views::rowsRemoved, this, &Views::dataChanged);
|
connect(m_model, &Model::Views::rowsRemoved, this, &Views::dataChanged);
|
||||||
|
|
||||||
|
connect(m_handler, &Handler::ViewsHandler::currentLayoutChanged, this, &Views::onCurrentLayoutChanged);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +125,12 @@ void Views::selectRow(const QString &id)
|
|||||||
// m_view->selectRow(rowForId(id));
|
// m_view->selectRow(rowForId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Views::onCurrentLayoutChanged()
|
||||||
|
{
|
||||||
|
Data::Layout layout = m_handler->currentData();
|
||||||
|
m_model->setOriginalData(layout.views);
|
||||||
|
}
|
||||||
|
|
||||||
void Views::applyColumnWidths()
|
void Views::applyColumnWidths()
|
||||||
{
|
{
|
||||||
m_view->horizontalHeader()->setSectionResizeMode(Model::Views::NAMECOLUMN, QHeaderView::Stretch);
|
m_view->horizontalHeader()->setSectionResizeMode(Model::Views::NAMECOLUMN, QHeaderView::Stretch);
|
||||||
|
@ -89,6 +89,8 @@ private slots:
|
|||||||
void storeColumnWidths();
|
void storeColumnWidths();
|
||||||
void applyColumnWidths();
|
void applyColumnWidths();
|
||||||
|
|
||||||
|
void onCurrentLayoutChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings::Handler::ViewsHandler *m_handler{nullptr};
|
Settings::Handler::ViewsHandler *m_handler{nullptr};
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@ void ViewsHandler::init()
|
|||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
emit currentLayoutChanged();
|
||||||
|
|
||||||
//! connect layout combobox after the selected layout has been loaded
|
//! connect layout combobox after the selected layout has been loaded
|
||||||
connect(m_ui->layoutsCmb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ViewsHandler::onCurrentLayoutIndexChanged);
|
connect(m_ui->layoutsCmb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ViewsHandler::onCurrentLayoutIndexChanged);
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
#include "viewsmodel.h"
|
#include "viewsmodel.h"
|
||||||
|
|
||||||
|
// local
|
||||||
|
#include <coretypes.h>
|
||||||
|
|
||||||
// KDE
|
// KDE
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ QVariant Views::headerData(int section, Qt::Orientation orientation, int role) c
|
|||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return QString(i18n("Screen"));
|
return QString(i18n("Screen"));
|
||||||
}
|
}
|
||||||
/* } else if (role == Qt::DecorationRole) {
|
/* } else if (role == Qt::DecorationRole) {
|
||||||
return QIcon::fromTheme("desktop");
|
return QIcon::fromTheme("desktop");
|
||||||
}*/
|
}*/
|
||||||
break;
|
break;
|
||||||
@ -126,7 +129,7 @@ QVariant Views::headerData(int section, Qt::Orientation orientation, int role) c
|
|||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return QString(i18nc("screen edge", "Edge"));
|
return QString(i18nc("screen edge", "Edge"));
|
||||||
}
|
}
|
||||||
/* } else if (role == Qt::DecorationRole) {
|
/* } else if (role == Qt::DecorationRole) {
|
||||||
return QIcon::fromTheme("transform-move");
|
return QIcon::fromTheme("transform-move");
|
||||||
}*/
|
}*/
|
||||||
break;
|
break;
|
||||||
@ -138,6 +141,10 @@ QVariant Views::headerData(int section, Qt::Orientation orientation, int role) c
|
|||||||
return QIcon::fromTheme("format-justify-center");
|
return QIcon::fromTheme("format-justify-center");
|
||||||
}*/
|
}*/
|
||||||
break;
|
break;
|
||||||
|
case SUBCONTAINMENTSCOLUMN:
|
||||||
|
if (role == Qt::DisplayRole) {
|
||||||
|
return QString(i18n("Includes"));
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -156,6 +163,72 @@ QVariant Views::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant{};
|
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{};
|
return QVariant{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
SCREENCOLUMN,
|
SCREENCOLUMN,
|
||||||
EDGECOLUMN,
|
EDGECOLUMN,
|
||||||
ALIGNMENTCOLUMN,
|
ALIGNMENTCOLUMN,
|
||||||
|
SUBCONTAINMENTSCOLUMN,
|
||||||
LASTCOLUMN
|
LASTCOLUMN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user