Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions demo/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ApplicationWindow {
id: demo

title: "Material for QtQuick Demo"
clientSideDecorations : true
Copy link
Member

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


// Necessary when loading the window from C++
visible: true
Expand Down
89 changes: 89 additions & 0 deletions modules/Material/Resizer.qml
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
Copy link
Member

Choose a reason for hiding this comment

The 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
}
}
40 changes: 40 additions & 0 deletions modules/Material/Storage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The 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
}