refactor:screens from dock to universalSettings

pull/3/head
Michail Vourlakos 6 years ago
parent 642b524cc7
commit 24c383d98a

@ -306,23 +306,6 @@ void DockView::removeDock()
}
}
QQmlListProperty<QScreen> DockView::screens()
{
return QQmlListProperty<QScreen>(this, nullptr, &countScreens, &atScreens);
}
int DockView::countScreens(QQmlListProperty<QScreen> *property)
{
Q_UNUSED(property)
return qGuiApp->screens().count();
}
QScreen *DockView::atScreens(QQmlListProperty<QScreen> *property, int index)
{
Q_UNUSED(property)
return qGuiApp->screens().at(index);
}
bool DockView::settingsWindowIsShown()
{
auto configView = qobject_cast<DockConfigView *>(m_configView);

@ -33,7 +33,6 @@
#include <array>
#include <QQuickView>
#include <QQmlListProperty>
#include <QMenu>
#include <QMimeData>
#include <QScreen>
@ -91,8 +90,6 @@ class DockView : public PlasmaQuick::ContainmentView
Q_PROPERTY(Latte::View::Positioner *positioner READ positioner NOTIFY positionerChanged)
Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged)
Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens)
Q_PROPERTY(QRect absoluteGeometry READ absGeometry NOTIFY absGeometryChanged)
Q_PROPERTY(QRect localGeometry READ localGeometry WRITE setLocalGeometry NOTIFY localGeometryChanged)
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
@ -167,11 +164,6 @@ public:
KWayland::Client::PlasmaShellSurface *surface();
void reconsiderScreen();
QQmlListProperty<QScreen> screens();
//! is needed by screens()
static int countScreens(QQmlListProperty<QScreen> *property);
//! is needed by screens()
static QScreen *atScreens(QQmlListProperty<QScreen> *property, int index);
//! these are signals that create crashes, such a example is the availableScreenRectChanged from corona
//! when its containment is destroyed

@ -550,4 +550,21 @@ float UniversalSettings::luminasFromFile(QString imageFile, int edge)
return m_runningActivitiesModel->luminasFromFile(imageFile, edge);
}
QQmlListProperty<QScreen> UniversalSettings::screens()
{
return QQmlListProperty<QScreen>(this, nullptr, &countScreens, &atScreens);
}
int UniversalSettings::countScreens(QQmlListProperty<QScreen> *property)
{
Q_UNUSED(property)
return qGuiApp->screens().count();
}
QScreen *UniversalSettings::atScreens(QQmlListProperty<QScreen> *property, int index)
{
Q_UNUSED(property)
return qGuiApp->screens().at(index);
}
}

@ -26,6 +26,8 @@
#include <QObject>
#include <QAbstractItemModel>
#include <QPointer>
#include <QQmlListProperty>
#include <QScreen>
#include <KConfigGroup>
#include <KSharedConfig>
@ -54,6 +56,9 @@ class UniversalSettings : public QObject
Q_PROPERTY(Latte::Dock::MouseSensitivity mouseSensitivity READ mouseSensitivity WRITE setMouseSensitivity NOTIFY mouseSensitivityChanged)
Q_PROPERTY(QAbstractItemModel *runningActivitiesModel READ runningActivitiesModel NOTIFY runningActivitiesModelChanged)
Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens)
public:
UniversalSettings(KSharedConfig::Ptr config, QObject *parent = nullptr);
~UniversalSettings() override;
@ -104,6 +109,10 @@ public:
QAbstractItemModel *runningActivitiesModel() const;
void setRunningActivitiesModel(SortedActivitiesModel *model);
QQmlListProperty<QScreen> screens();
static int countScreens(QQmlListProperty<QScreen> *property); //! is needed by screens()
static QScreen *atScreens(QQmlListProperty<QScreen> *property, int index); //! is needed by screens()
public slots:
Q_INVOKABLE QString splitterIconPath();
Q_INVOKABLE QString trademarkIconPath();

@ -85,7 +85,7 @@ PlasmaComponents.Page {
visible: true
function updateScreens() {
if (dock.screens.length > 1)
if (universalSettings.screens.length > 1)
screenRow.visible = true;
else
screenRow.visible = false;
@ -99,16 +99,16 @@ PlasmaComponents.Page {
//the dock automatically to primaryScreen in order for the user
//to has always a dock with tasks shown
var screenExists = false
for (var i = 0; i < dock.screens.length; i++) {
if (dock.screens[i].name === dock.positioner.currentScreenName)
for (var i = 0; i < universalSettings.screens.length; i++) {
if (universalSettings.screens[i].name === dock.positioner.currentScreenName)
screenExists = true;
}
if (!screenExists && !dock.onPrimary)
screens.push(rtlSpace + dock.positioner.currentScreenName);
for (var i = 0; i < dock.screens.length; i++) {
screens.push(rtlSpace + dock.screens[i].name)
for (var i = 0; i < universalSettings.screens.length; i++) {
screens.push(rtlSpace + universalSettings.screens[i].name)
}
screenCmb.model = screens;

Loading…
Cancel
Save