diff options
author | Ken Moore <ken@ixsystems.com> | 2018-03-20 15:37:35 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-03-20 15:37:35 -0400 |
commit | afcece7d649bf7fecb39c815d5b5603d31df00c9 (patch) | |
tree | 69c1b8d96d76bdc1cd48c954bd1d7038be837e1d /src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-afcece7d649bf7fecb39c815d5b5603d31df00c9.tar.gz lumina-afcece7d649bf7fecb39c815d5b5603d31df00c9.tar.bz2 lumina-afcece7d649bf7fecb39c815d5b5603d31df00c9.zip |
Some more work on the Widget-base NativeWindow.
While the frame itself looks nice, a number of key functionality changes are still in-progress
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp')
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp index e2cac852..c9dd97f8 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp @@ -26,6 +26,7 @@ NativeWindowObject::NativeWindowObject(WId id) : QObject(){ geomTimer->setSingleShot(true); geomTimer->setInterval(50); //1/20 second connect(geomTimer, SIGNAL(timeout()), this, SLOT(sendNewGeom()) ); + qRegisterMetaType<WId>("WId"); } NativeWindowObject::~NativeWindowObject(){ @@ -281,6 +282,33 @@ void NativeWindowObject::toggleVisibility(){ setProperty(NativeWindowObject::Visible, !property(NativeWindowObject::Visible).toBool() ); } +void NativeWindowObject::toggleMaximize(){ + //Find the screen containing this window (center of window) + QRect curgeom = frameGeometry(); + QPoint ctr = curgeom.center(); + QList<QScreen*> scrns = QApplication::screens(); + QRect max; + for(int i=0; i<scrns.length(); i++){ + if(scrns[i]->geometry().contains(ctr)){ + max = scrns[i]->availableGeometry(); + break; + } + } + //Now compare the current geometry to the screen geometry + if(curgeom!=max){ + setGeometryNow(max); //will set newgeom to max + newgeom = curgeom; //now reset newgeom + }else{ + //Already maximized, look at the old geometry and figure out how to restore it + if(newgeom.isNull()){ + //no old info available - center the window at half maximum size + newgeom = QRect(max.x()-max.width()/2, max.y()-max.height()/2, max.width()/2, max.height()/2); + } + setGeometryNow(newgeom); + } + emit geomChanged(); +} + void NativeWindowObject::requestClose(){ emit RequestClose(winid); } |