-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature for window handling in freamless mode #376
base: develop
Are you sure you want to change the base?
Changes from 5 commits
3d08c78
de4ce18
b558d0f
ba07447
fa72767
e6b0de4
e8316c4
5d4ff10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
import QtQuick 2.4 | ||
import QtQuick.Layouts 1.1 | ||
import QtQuick.Window 2.2 | ||
import Material 0.2 | ||
import Material.Extras 0.1 | ||
import Material.ListItems 0.1 as ListItem | ||
|
@@ -203,6 +204,43 @@ Item { | |
overflowMenu.close(); | ||
} | ||
|
||
/*! | ||
\internal | ||
|
||
put mousearea under everything blow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typos |
||
*/ | ||
MouseArea { | ||
anchors.fill: parent | ||
|
||
property var previousPosition | ||
property var enable : Storage.target.clientSideDecorations | ||
|
||
onPressed: { | ||
previousPosition = Qt.point(mouseX, mouseY) | ||
} | ||
|
||
onDoubleClicked: { | ||
if( enable ){ | ||
if( Storage.target.visibility != Window.FullScreen ){ | ||
Storage.target.visibility = Window.FullScreen | ||
}else{ | ||
Storage.target.visibility = Window.Windowed | ||
} | ||
} | ||
} | ||
|
||
onPositionChanged: { | ||
if (pressedButtons == Qt.LeftButton | ||
&& Storage.target.visibility != Window.FullScreen | ||
&& enable ) { | ||
var dx = mouseX - previousPosition.x | ||
var dy = mouseY - previousPosition.y | ||
Storage.target.x = Storage.target.x + dx | ||
Storage.target.y = Storage.target.y + dy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me this makes the window bounce a lot when dragging in X11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a race condition, works fine on windows for some reason. It can be fixed by exposing QCursor::pos() from c++ to get the screen position of the mouse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On X11 moving the window should be done using the _NET_WM_MOVERESIZE message of the EWMH (i.e. it should be done by the window manager and not by the app itself). In GDK there is the function |
||
} | ||
} | ||
} | ||
|
||
QtObject { | ||
id: __internal | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* QML Material - An application framework implementing Material Design. | ||
* Copyright (C) 2016 hunt978([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import Material 0.2 | ||
import QtQuick 2.4 | ||
import QtQuick.Window 2.2 | ||
|
||
/*! | ||
\qmltype Reziser | ||
\inqmlmodule Material | ||
|
||
\brief Reziser allow Material apps resize window size under frameless mode | ||
the app will show a litter icon in right-bottom corner when the mouse hover | ||
the area. then user can resize the window by draging the window. | ||
*/ | ||
Icon | ||
{ | ||
id : __resizer | ||
|
||
anchors.bottom: parent.bottom | ||
anchors.right : parent.right | ||
|
||
colorize : true | ||
color : Theme.primaryColor | ||
opacity : (Storage.target.visibility != Window.FullScreen) ? __resizer.opacity : 0 | ||
|
||
name : "device/signal_cellular_0_bar" | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
hoverEnabled: true | ||
|
||
property var previousPosition | ||
property var enable : (Storage.target.visibility != Window.FullScreen) | ||
&& Storage.target.clientSideDecorations | ||
|
||
onPressed: { | ||
if( enable ){ | ||
previousPosition = Qt.point(mouseX, mouseY) | ||
} | ||
} | ||
|
||
onPositionChanged: { | ||
if (pressedButtons == Qt.LeftButton && enable) { | ||
var width = (mouseX - previousPosition.x) + Storage.target.width | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Read comment in Storage.qml first. But here you can create a property named target and set it in application window. |
||
var height = (mouseY - previousPosition.y) + Storage.target.height | ||
if( width > 0 ){ | ||
Storage.target.width = width | ||
} | ||
if( height > 0 ){ | ||
Storage.target.height = height | ||
} | ||
} | ||
} | ||
|
||
onEntered : { | ||
if( enable ){ | ||
cursorShape = Qt.SizeFDiagCursor | ||
__resizer.opacity = 1 | ||
} | ||
} | ||
|
||
onExited : { | ||
if( enable ){ | ||
cursorShape = Qt.ArrowCursor | ||
__resizer.opacity = 0 | ||
} | ||
} | ||
} | ||
|
||
Component.onCompleted: { | ||
__resizer.opacity = 0 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There has to be another way to do this without adding a new component, even if you need to create new properties in the existing components, creating global variables is not the solution. |
||
* QML Material - An application framework implementing Material Design. | ||
* Copyright (C) 2016 hunt978([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import QtQuick 2.4 | ||
|
||
pragma Singleton | ||
|
||
/*! | ||
\qmltype Storage | ||
\inqmlmodule Material | ||
|
||
\brief Storage allow Material apps share setting over all sessions | ||
*/ | ||
Object | ||
{ | ||
/*! | ||
Top Window Object. | ||
*/ | ||
property var target: null | ||
|
||
/*! | ||
Custom data storage | ||
*/ | ||
property var customData : null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this should be the default behavior and the indentation is wrong use 4 spaces instead of tabs