viewsdialog:show active screens with bold

work/spdx
Michail Vourlakos 4 years ago
parent 6351d4e892
commit 8ba60ea89a

@ -28,6 +28,7 @@ namespace Data {
Screen::Screen() Screen::Screen()
: Generic(), : Generic(),
hasExplicitViews(false), hasExplicitViews(false),
isActive(false),
geometry(QRect(0, 0, 1920, 1080)) geometry(QRect(0, 0, 1920, 1080))
{ {
} }
@ -35,6 +36,7 @@ Screen::Screen()
Screen::Screen(Screen &&o) Screen::Screen(Screen &&o)
: Generic(o), : Generic(o),
hasExplicitViews(o.hasExplicitViews), hasExplicitViews(o.hasExplicitViews),
isActive(o.isActive),
geometry(o.geometry) geometry(o.geometry)
{ {
} }
@ -42,6 +44,7 @@ Screen::Screen(Screen &&o)
Screen::Screen(const Screen &o) Screen::Screen(const Screen &o)
: Generic(o), : Generic(o),
hasExplicitViews(o.hasExplicitViews), hasExplicitViews(o.hasExplicitViews),
isActive(o.isActive),
geometry(o.geometry) geometry(o.geometry)
{ {
} }
@ -57,6 +60,7 @@ Screen &Screen::operator=(const Screen &rhs)
id = rhs.id; id = rhs.id;
name = rhs.name; name = rhs.name;
hasExplicitViews = rhs.hasExplicitViews; hasExplicitViews = rhs.hasExplicitViews;
isActive = rhs.isActive;
geometry = rhs.geometry; geometry = rhs.geometry;
return (*this); return (*this);
@ -67,6 +71,7 @@ Screen &Screen::operator=(Screen &&rhs)
id = rhs.id; id = rhs.id;
name = rhs.name; name = rhs.name;
hasExplicitViews = rhs.hasExplicitViews; hasExplicitViews = rhs.hasExplicitViews;
isActive = rhs.isActive;
geometry = rhs.geometry; geometry = rhs.geometry;
return (*this); return (*this);
@ -77,6 +82,7 @@ bool Screen::operator==(const Screen &rhs) const
return (id == rhs.id) return (id == rhs.id)
&& (name == rhs.name) && (name == rhs.name)
&& (hasExplicitViews == rhs.hasExplicitViews) && (hasExplicitViews == rhs.hasExplicitViews)
//&& (isActive == rhs.isActive) /*Disabled because this is not a data but a screen state*/
&& (geometry == rhs.geometry); && (geometry == rhs.geometry);
} }
@ -91,6 +97,7 @@ void Screen::init(const QString &screenId, const QString &serialized)
id = screenId; id = screenId;
name = parts[0]; name = parts[0];
isActive = false;
if (parts.count() > 1) { if (parts.count() > 1) {
geometry = Latte::stringToRect(parts[1]); geometry = Latte::stringToRect(parts[1]);

@ -46,6 +46,7 @@ public:
//! Screen data //! Screen data
bool hasExplicitViews{false}; bool hasExplicitViews{false};
bool isActive{false};
QRect geometry; QRect geometry;
//! Operators //! Operators

@ -146,7 +146,7 @@ void ScreenPool::updateScreenGeometry(const int &screenId, const QRect &screenGe
Latte::Data::ScreensTable ScreenPool::screensTable() Latte::Data::ScreensTable ScreenPool::screensTable()
{ {
return m_screensTable; return m_screensTable;
} }

@ -59,12 +59,17 @@ QWidget *SingleOption::createEditor(QWidget *parent, const QStyleOptionViewItem
QString currentChoice = index.data(Qt::UserRole).toString(); QString currentChoice = index.data(Qt::UserRole).toString();
Latte::Data::GenericBasicTable choices; Latte::Data::GenericBasicTable choices;
QStringList activeChoices;
if (column == Model::Views::SCREENCOLUMN) { if (column == Model::Views::SCREENCOLUMN) {
Latte::Data::ScreensTable screens = index.data(Model::Views::CHOICESROLE).value<Latte::Data::ScreensTable>(); Latte::Data::ScreensTable screens = index.data(Model::Views::CHOICESROLE).value<Latte::Data::ScreensTable>();
for (int i=0; i<screens.rowCount(); ++i) { for (int i=0; i<screens.rowCount(); ++i) {
choices << Latte::Data::Generic(screens[i].id, screens[i].name); choices << Latte::Data::Generic(screens[i].id, screens[i].name);
if (screens[i].isActive) {
activeChoices << screens[i].id;
}
} }
} else { } else {
choices << index.data(Model::Views::CHOICESROLE).value<Latte::Data::GenericBasicTable>(); choices << index.data(Model::Views::CHOICESROLE).value<Latte::Data::GenericBasicTable>();
@ -78,6 +83,12 @@ QWidget *SingleOption::createEditor(QWidget *parent, const QStyleOptionViewItem
action->setIcon(QIcon::fromTheme("dialog-yes")); action->setIcon(QIcon::fromTheme("dialog-yes"));
} }
if (activeChoices.contains(choices[i].id)) {
QFont font = action->font();
font.setBold(true);
action->setFont(font);
}
connect(action, &QAction::triggered, this, [this, button, menu, action](bool checked) { connect(action, &QAction::triggered, this, [this, button, menu, action](bool checked) {
menu->setProperty(PRESSEDPROPERTY, action->data()); menu->setProperty(PRESSEDPROPERTY, action->data());
button->clearFocus(); button->clearFocus();

@ -214,8 +214,13 @@ void Views::populateScreens()
Data::Screen primary(QString::number(Data::Screen::ONPRIMARYID), Data::Screen primary(QString::number(Data::Screen::ONPRIMARYID),
i18nc("primary screen", " - Follow Primary Screen - ")); i18nc("primary screen", " - Follow Primary Screen - "));
primary.isActive = true;
s_screens << primary; s_screens << primary;
s_screens << m_corona->screenPool()->screensTable(); s_screens << m_corona->screenPool()->screensTable();
for (int i=1; i<s_screens.rowCount(); ++i) {
s_screens[i].isActive = m_corona->screenPool()->isScreenActive(s_screens[i].id.toInt());
}
} }
void Views::setOriginalData(Latte::Data::ViewsTable &data) void Views::setOriginalData(Latte::Data::ViewsTable &data)

Loading…
Cancel
Save