provide screens options in views dialog

work/spdx
Michail Vourlakos 4 years ago
parent c27727c9e7
commit b29a8fa9b3

@ -145,6 +145,11 @@ void ScreenPool::updateScreenGeometry(const int &screenId, const QRect &screenGe
}
Latte::Data::ScreensTable ScreenPool::screensTable()
{
return m_screensTable;
}
QString ScreenPool::reportHtml(const QList<int> &assignedScreens) const
{
QString report;

@ -63,6 +63,8 @@ public:
QScreen *screenForId(int id);
Latte::Data::ScreensTable screensTable();
signals:
void primaryPoolChanged();

@ -22,6 +22,7 @@
// local
#include "../viewsmodel.h"
#include "../../../data/genericbasictable.h"
#include "../../../data/screendata.h"
// Qt
#include <QMenu>
@ -39,6 +40,9 @@ SingleOption::SingleOption(QObject *parent)
QWidget *SingleOption::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
const int row = index.row();
const int column = index.column();
QPushButton *button = new QPushButton(parent);
QMenu *menu = new QMenu(button);
@ -48,7 +52,18 @@ QWidget *SingleOption::createEditor(QWidget *parent, const QStyleOptionViewItem
bool isViewActive = index.data(Model::Views::ISACTIVEROLE).toBool();
QString currentChoice = index.data(Qt::UserRole).toString();
Latte::Data::GenericBasicTable choices = index.data(Model::Views::CHOICESROLE).value<Latte::Data::GenericBasicTable>();
Latte::Data::GenericBasicTable choices;
if (column == Model::Views::SCREENCOLUMN) {
Latte::Data::ScreensTable screens = index.data(Model::Views::CHOICESROLE).value<Latte::Data::ScreensTable>();
for (int i=0; i<screens.rowCount(); ++i) {
choices << Latte::Data::Generic(screens[i].id, screens[i].name);
}
} else {
choices << index.data(Model::Views::CHOICESROLE).value<Latte::Data::GenericBasicTable>();
}
for (int i=0; i<choices.rowCount(); ++i) {
QAction *action = new QAction(choices[i].name);
@ -79,7 +94,7 @@ void SingleOption::setEditorData(QWidget *editor, const QModelIndex &index) cons
}
bool SingleOption::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
const QModelIndex &index)
const QModelIndex &index)
{
Q_ASSERT(event);
Q_ASSERT(model);

@ -22,6 +22,7 @@
// local
#include <coretypes.h>
#include "../../screenpool.h"
#include "../../data/genericdata.h"
#include "../../data/screendata.h"
@ -121,6 +122,11 @@ void Views::initAlignments()
void Views::populateScreens()
{
s_screens.clear();
Data::Screen primary("0", i18nc("primary screen", " - Follow Primary Screen - "));
s_screens << primary;
s_screens << m_corona->screenPool()->screensTable();
}
void Views::setOriginalData(Latte::Data::ViewsTable &data)
@ -225,7 +231,20 @@ QVariant Views::data(const QModelIndex &index, int role) const
} else if (role == ISACTIVEROLE) {
return m_viewsTable[row].isActive;
} else if (role == CHOICESROLE) {
if (column == EDGECOLUMN) {
if (column == SCREENCOLUMN) {
QVariant screensVariant;
Latte::Data::ScreensTable currentScreens = s_screens;
if (!m_viewsTable[row].onPrimary && !currentScreens.containsId(QString::number(m_viewsTable[row].screen))) {
Data::Screen explicitScr(QString::number(m_viewsTable[row].screen),
i18nc("unknown screen", "Unknown : [%0]").arg(explicitScr.id));
currentScreens.insertBasedOnId(explicitScr);
}
screensVariant.setValue<Latte::Data::ScreensTable>(currentScreens);
return screensVariant;
} else if (column == EDGECOLUMN) {
return s_edges;
} else if (column == ALIGNMENTCOLUMN) {
bool isVertical = (m_viewsTable[row].edge == Plasma::Types::LeftEdge || m_viewsTable[row].edge == Plasma::Types::RightEdge);

@ -24,6 +24,7 @@
// local
#include "../../lattecorona.h"
#include "../../data/genericbasictable.h"
#include "../../data/screendata.h"
#include "../../data/viewdata.h"
#include "../../data/viewstable.h"
@ -106,7 +107,7 @@ private:
QVariant s_edges;
QVariant s_horizontalAlignments;
QVariant s_verticalAlignments;
Latte::Data::GenericBasicTable s_screens;
Latte::Data::ScreensTable s_screens;
};
}

Loading…
Cancel
Save