the desktop view exposes a way to be desktop win
the desktop shell will set the window as a "desktop" window, always behind. some other shells will have the desktop as a normal window the api can still expand
This commit is contained in:
parent
0c68fa35bc
commit
cb1064fd32
@ -19,11 +19,20 @@
|
||||
#include "desktopview.h"
|
||||
#include "shellcorona.h"
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QScreen>
|
||||
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include <Plasma/Package>
|
||||
|
||||
DesktopView::DesktopView(ShellCorona *corona, QWindow *parent)
|
||||
: PlasmaQuickView(corona, parent)
|
||||
: PlasmaQuickView(corona, parent),
|
||||
m_stayBehind(false),
|
||||
m_fillScreen(false)
|
||||
{
|
||||
engine()->rootContext()->setContextProperty("desktop", this);
|
||||
setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml")));
|
||||
}
|
||||
|
||||
@ -31,6 +40,46 @@ DesktopView::~DesktopView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DesktopView::stayBehind() const
|
||||
{
|
||||
return m_stayBehind;
|
||||
}
|
||||
|
||||
void DesktopView::setStayBehind(bool stayBehind)
|
||||
{
|
||||
if (stayBehind == m_stayBehind) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stayBehind) {
|
||||
KWindowSystem::setType(winId(), NET::Desktop);
|
||||
} else {
|
||||
KWindowSystem::setType(winId(), NET::Normal);
|
||||
}
|
||||
|
||||
m_stayBehind = stayBehind;
|
||||
emit stayBehindChanged();
|
||||
}
|
||||
|
||||
bool DesktopView::fillScreen() const
|
||||
{
|
||||
return m_fillScreen;
|
||||
}
|
||||
|
||||
void DesktopView::setFillScreen(bool fillScreen)
|
||||
{
|
||||
if (fillScreen == m_fillScreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
resize(screen()->geometry().width(), screen()->geometry().height());
|
||||
connect(screen(), &QScreen::geometryChanged, [=]{resize(screen()->geometry().width(), screen()->geometry().height());});
|
||||
|
||||
fillScreen = fillScreen;
|
||||
emit fillScreenChanged();
|
||||
}
|
||||
|
||||
/*
|
||||
void DesktopView::showConfigurationInterface(Plasma::Applet *applet)
|
||||
{
|
||||
|
@ -29,19 +29,34 @@ class ShellCorona;
|
||||
class DesktopView : public PlasmaQuickView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool stayBehind READ stayBehind WRITE setStayBehind NOTIFY stayBehindChanged)
|
||||
Q_PROPERTY(bool fillScreen READ fillScreen WRITE setFillScreen NOTIFY fillScreenChanged)
|
||||
|
||||
public:
|
||||
explicit DesktopView(ShellCorona *corona, QWindow *parent = 0);
|
||||
virtual ~DesktopView();
|
||||
|
||||
bool stayBehind() const;
|
||||
void setStayBehind(bool stayBehind);
|
||||
|
||||
bool fillScreen() const;
|
||||
void setFillScreen(bool fillScreen);
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* It will be called when the configuration is requested
|
||||
* FIXME: this should be moved here
|
||||
*/
|
||||
//virtual void showConfigurationInterface(Plasma::Applet *applet);
|
||||
|
||||
Q_SIGNALS:
|
||||
void stayBehindChanged();
|
||||
void fillScreenChanged();
|
||||
|
||||
private:
|
||||
QPointer<ConfigView> m_configView;
|
||||
bool m_stayBehind : 1;
|
||||
bool m_fillScreen : 1;
|
||||
};
|
||||
|
||||
#endif // DESKTOVIEW_H
|
||||
|
@ -38,6 +38,8 @@ Rectangle {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
desktop.stayBehind = true;
|
||||
desktop.fillScreen = true;
|
||||
print("View QML loaded")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user