Commit c2c387f1 authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #60 from eekkelund/master

Changes to existing Buttonrow & Slider, great fixes for maliit and requested Page orientation fix
parents e38bf17b 8f7070bd
...@@ -43,8 +43,10 @@ Page { ...@@ -43,8 +43,10 @@ Page {
Column { Column {
spacing: 40 spacing: 40
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width
ButtonRow { ButtonRow {
id: row id: row
anchors.horizontalCenter: parent.horizontalCenter
model: ListModel { model: ListModel {
id: buttonModel id: buttonModel
ListElement { ListElement {
...@@ -73,11 +75,14 @@ Page { ...@@ -73,11 +75,14 @@ Page {
Label { Label {
id: selector id: selector
anchors.horizontalCenter: parent.horizontalCenter
text: "Nothing selected" text: "Nothing selected"
} }
ButtonRow { ButtonRow {
id: row2 id: row2
enabled: false enabled: false
anchors.horizontalCenter: parent.horizontalCenter
fixedWidth: parent.width * .8
model: ListModel { model: ListModel {
ListElement { ListElement {
name: "swim" name: "swim"
......
...@@ -55,6 +55,16 @@ Page { ...@@ -55,6 +55,16 @@ Page {
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
value: 0 value: 0
useSpecSlider: false
}
Slider {
anchors.margins: 20
value: 50
showValue: true
minimumValue: 1
maximumValue: 100
stepSize: 1
alwaysUp: true
} }
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
......
...@@ -46,6 +46,7 @@ import QtQuick.Controls.Styles.Nemo 1.0 ...@@ -46,6 +46,7 @@ import QtQuick.Controls.Styles.Nemo 1.0
Page { Page {
id: root id: root
allowedOrientations:Qt.PortraitOrientation | Qt.LandscapeOrientation
property real progress: 0 property real progress: 0
SequentialAnimation on progress { SequentialAnimation on progress {
loops: Animation.Infinite loops: Animation.Infinite
......
...@@ -51,6 +51,7 @@ ApplicationWindow { ...@@ -51,6 +51,7 @@ ApplicationWindow {
id: appWindow id: appWindow
contentOrientation: Screen.orientation contentOrientation: Screen.orientation
allowedOrientations: Qt.PortraitOrientation | Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation | Qt.InvertedPortraitOrientation
// Implements back key navigation // Implements back key navigation
Keys.onReleased: { Keys.onReleased: {
......
...@@ -41,15 +41,25 @@ ...@@ -41,15 +41,25 @@
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QtQuick/QQuickView> #include <QtQuick/QQuickView>
#include <QScreen>
#include <glacierapp.h> #include <glacierapp.h>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
setenv("QT_QUICK_CONTROLS_STYLE", "Nemo", 1); setenv("QT_QUICK_CONTROLS_STYLE", "Nemo", 1);
QGuiApplication *app = GlacierApp::app(argc, argv); QGuiApplication *app = GlacierApp::app(argc, argv);
app->setOrganizationName("NemoMobile"); app->setOrganizationName("NemoMobile");
QScreen* sc = app->primaryScreen();
if(sc){
sc->setOrientationUpdateMask(Qt::LandscapeOrientation
| Qt::PortraitOrientation
| Qt::InvertedLandscapeOrientation
| Qt::InvertedPortraitOrientation);
}
QQuickWindow *window = GlacierApp::showWindow(); QQuickWindow *window = GlacierApp::showWindow();
window->setTitle(QObject::tr("Glacier components")); window->setTitle(QObject::tr("Glacier components"));
......
...@@ -26,7 +26,8 @@ QML_FILES += \ ...@@ -26,7 +26,8 @@ QML_FILES += \
qml/IconButton.qml \ qml/IconButton.qml \
qml/DatePicker.qml \ qml/DatePicker.qml \
qml/ScrollDecorator.qml \ qml/ScrollDecorator.qml \
qml/dialogs/QueryDialog.qml qml/dialogs/QueryDialog.qml \
qml/TextField.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES
...@@ -41,7 +42,9 @@ HEADERS += \ ...@@ -41,7 +42,9 @@ HEADERS += \
themedaemon/mlocalthemedaemonclient.h \ themedaemon/mlocalthemedaemonclient.h \
themedaemon/mabstractthemedaemonclient.h \ themedaemon/mabstractthemedaemonclient.h \
sizing.h \ sizing.h \
theme.h theme.h \
editfilter.h \
nemofocussingleton.h
SOURCES += \ SOURCES += \
qquicknemocontrolsextensionplugin.cpp \ qquicknemocontrolsextensionplugin.cpp \
...@@ -53,7 +56,9 @@ SOURCES += \ ...@@ -53,7 +56,9 @@ SOURCES += \
themedaemon/mlocalthemedaemonclient.cpp \ themedaemon/mlocalthemedaemonclient.cpp \
themedaemon/mabstractthemedaemonclient.cpp \ themedaemon/mabstractthemedaemonclient.cpp \
sizing.cpp \ sizing.cpp \
theme.cpp theme.cpp \
editfilter.cpp \
nemofocussingleton.cpp
target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
......
/*
* Copyright (C) 2017 Eetu Kahelin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "editfilter.h"
EditFilter::EditFilter(QObject *parent) : QObject(parent)
{
}
bool EditFilter::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::TouchBegin) {
NemoFocusSingleton *nemoFocus = NemoFocusSingleton::instance();
if(nemoFocus->edit() != NULL) {
nemoFocus->edit()->setProperty("focus",QVariant(false));
return false;
}
} else {
return QObject::eventFilter(obj, event);
}
}
/*
* Copyright (C) 2017 Eetu Kahelin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef EDITFILTER_H
#define EDITFILTER_H
#include <QObject>
#include <QEvent>
#include <QString>
#include <QVariant>
#include "nemofocussingleton.h"
class EditFilter : public QObject
{
Q_OBJECT
public:
explicit EditFilter(QObject *parent = 0);
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
#endif // EDITFILTER_H
/*
* Copyright (C) 2017 Eetu Kahelin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "nemofocussingleton.h"
void NemoFocusSingleton::nemoregister(QObject *edit)
{
m_edit = edit;
}
NemoFocusSingleton *NemoFocusSingleton::instance() {
static NemoFocusSingleton * _instance = 0;
if ( _instance == 0 ) {
_instance = new NemoFocusSingleton();
}
return _instance;
}
QObject *NemoFocusSingleton::edit() const
{
return m_edit;
}
/*
* Copyright (C) 2017 Eetu Kahelin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef NEMOFOCUSSINGLETON_H
#define NEMOFOCUSSINGLETON_H
#include <QObject>
class NemoFocusSingleton: public QObject
{
Q_OBJECT
Q_DISABLE_COPY(NemoFocusSingleton)
public:
Q_INVOKABLE void nemoregister(QObject *edit) ;
QObject *edit() const;
static NemoFocusSingleton* instance();
private:
QObject *m_edit = nullptr;
NemoFocusSingleton(QObject* parent = nullptr) {}
};
#endif // NEMOFOCUSSINGLETON_H
...@@ -26,6 +26,8 @@ NemoWindow::NemoWindow(QWindow *parent) : ...@@ -26,6 +26,8 @@ NemoWindow::NemoWindow(QWindow *parent) :
m_defaultAllowedOrientations(Qt::PortraitOrientation | Qt::LandscapeOrientation) m_defaultAllowedOrientations(Qt::PortraitOrientation | Qt::LandscapeOrientation)
{ {
m_allowedOrientations = m_defaultAllowedOrientations; m_allowedOrientations = m_defaultAllowedOrientations;
m_filter = new EditFilter();
this->installEventFilter(m_filter);
} }
Qt::ScreenOrientations NemoWindow::allowedOrientations() const Qt::ScreenOrientations NemoWindow::allowedOrientations() const
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <QQuickWindow> #include <QQuickWindow>
#include <QtCore/qnamespace.h> #include <QtCore/qnamespace.h>
#include "editfilter.h"
class NemoWindow : public QQuickWindow class NemoWindow : public QQuickWindow
{ {
Q_OBJECT Q_OBJECT
...@@ -48,6 +50,9 @@ private: ...@@ -48,6 +50,9 @@ private:
Qt::ScreenOrientations m_allowedOrientations; Qt::ScreenOrientations m_allowedOrientations;
Qt::ScreenOrientations m_defaultAllowedOrientations; Qt::ScreenOrientations m_defaultAllowedOrientations;
EditFilter *m_filter;
}; };
#endif // NEMOWINDOW_H #endif // NEMOWINDOW_H
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
import QtQuick.Window 2.0 import QtQuick.Window 2.2
import QtQuick 2.6 import QtQuick 2.6
import QtQuick.Controls 1.0 import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
...@@ -47,6 +47,12 @@ NemoWindow { ...@@ -47,6 +47,12 @@ NemoWindow {
readonly property var _bgColor: Theme.backgroundColor readonly property var _bgColor: Theme.backgroundColor
color: _bgColor color: _bgColor
//Handles orientation of keyboard, MInputMethodQuick.appOrientation.
contentOrientation: orientation
onOrientationChanged: {
contentOrientation=orientation
}
//README: allowedOrientations' default value is set in NemoWindow's c++ implementation //README: allowedOrientations' default value is set in NemoWindow's c++ implementation
//The app developer can overwrite it from QML //The app developer can overwrite it from QML
......
...@@ -35,12 +35,21 @@ import QtQuick.Controls.Styles.Nemo 1.0 ...@@ -35,12 +35,21 @@ import QtQuick.Controls.Styles.Nemo 1.0
Rectangle { Rectangle {
id: main id: main
width: childrenRect.width implicitWidth: fixedWidth ? fixedWidth : childrenRectWidth()
color: Theme.fillDarkColor color: Theme.fillDarkColor
height: Theme.itemHeightSmall height: Theme.itemHeightSmall
property ListModel model: ListModel {} property ListModel model: ListModel {}
property bool enabled: true property bool enabled: true
property int currentIndex: -1 property int currentIndex: -1
property int fixedWidth
function childrenRectWidth() {
var childWidth = 0
for(var i=0; i < rectangles.count; i++) {
childWidth = childWidth + rectangles.itemAt(i).width
}
return childWidth
}
Image { Image {
anchors.fill: parent anchors.fill: parent
...@@ -48,24 +57,51 @@ Rectangle { ...@@ -48,24 +57,51 @@ Rectangle {
source: "images/disabled-overlay.png" source: "images/disabled-overlay.png"
fillMode: Image.Tile fillMode: Image.Tile
} }
Rectangle{ Rectangle{
id: selecter id: selecter
x: rowElement.children[main.currentIndex].x || 0 //x: main.currentIndex > -1 ? rowElement.children[main.currentIndex].x : 0
anchors.verticalCenter: rowElement.verticalCenter anchors.verticalCenter: rowElement.verticalCenter
width: rowElement.children[main.currentIndex].width || 0
height: Theme.itemHeightMedium height: Theme.itemHeightMedium
color: Theme.accentColor color: Theme.accentColor
clip: true
visible: main.currentIndex > -1 visible: main.currentIndex > -1
Behavior on x { Behavior on x {
NumberAnimation { duration: 200 } NumberAnimation { duration: 200; easing.type: Easing.OutCubic}
} }
Behavior on width { Behavior on width {
NumberAnimation { duration: 200 } NumberAnimation { duration: 200; easing.type: Easing.OutCubic}
}
}
MouseArea {
id:dragArea
anchors.fill:parent
enabled: main.enabled
drag.target: main.enabled ? selecter.visible ? selecter : null : null
drag.axis: Drag.XAxis
drag.minimumX: x
drag.maximumX: main.width - selecter.width
property int inBoundsX
hoverEnabled: true
onReleased: {
if(inBoundsX > -1) {
if(mouseX < drag.minimumX)
rowElement.childAt(inBoundsX,y).changeIndex()
else if (mouseX > drag.maximumX+selecter.width)
rowElement.childAt(inBoundsX+selecter.width, y).changeIndex()
else rowElement.childAt(mouseX,y).changeIndex()
selecter.x = rowElement.children[main.currentIndex].x
selecter.width = main.currentIndex > -1 ? rowElement.children[main.currentIndex].width : 0
}
}
onClicked: {
inBoundsX = -1
rowElement.childAt(mouseX,y).changeIndex()
selecter.x = rowElement.children[main.currentIndex].x
selecter.width= main.currentIndex > -1 ? rowElement.children[main.currentIndex].width : 0
} }
onPositionChanged: if(mouseX>=drag.minimumX && mouseX <= drag.maximumX) inBoundsX = mouseX
} }
Row { Row {
...@@ -76,19 +112,9 @@ Rectangle { ...@@ -76,19 +112,9 @@ Rectangle {
delegate: Rectangle { delegate: Rectangle {
id: rowItem id: rowItem
height: Theme.itemHeightSmall height: Theme.itemHeightSmall
width: text.width+(text.width/name.length*2) width: main.fixedWidth ? (main.fixedWidth/main.model.count) : (text.width+(text.width/name.length*2))
color: "transparent" color: "transparent"
MouseArea { function changeIndex() { main.currentIndex = index}
width: parent.width
height: parent.height
enabled: main.enabled
onClicked: {
main.currentIndex = index
}
}
Label { Label {
id: text id: text
text: name text: name
......
...@@ -78,6 +78,16 @@ Item { ...@@ -78,6 +78,16 @@ Item {
snapMode: PathView.SnapToItem snapMode: PathView.SnapToItem
} }
InverseMouseArea {
width: parent.width
height: view.height
anchors.centerIn: view
enabled: activated
parent:glacierRoller
onPressed: {
if(activated) activated = false
}
}
Component.onCompleted: { Component.onCompleted: {
if(activated) if(activated)
...@@ -117,14 +127,14 @@ Item { ...@@ -117,14 +127,14 @@ Item {
id: activateAnimations id: activateAnimations
NumberAnimation{target: bottomLine; property: "opacity"; to: 1; duration: 150} NumberAnimation{target: bottomLine; property: "opacity"; to: 1; duration: 150}
NumberAnimation{target: topLine; property: "opacity"; to: 1; duration: 150} NumberAnimation{target: topLine; property: "opacity"; to: 1; duration: 150}
NumberAnimation{target: view; property: "height"; to: itemHeight*activateSize; duration: 150} NumberAnimation{target: view; property: "height"; to: itemHeight*activateSize; duration: 150; easing.type: Easing.InCubic}
} }
ParallelAnimation { ParallelAnimation {
id: deActivateAnimations id: deActivateAnimations
NumberAnimation{target: bottomLine; property: "opacity"; to: 0; duration: 150} NumberAnimation{target: bottomLine; property: "opacity"; to: 0; duration: 150}
NumberAnimation{target: topLine; property: "opacity"; to: 0; duration: 150} NumberAnimation{target: topLine; property: "opacity"; to: 0; duration: 150}
NumberAnimation{target: view; property: "height"; to: itemHeight; duration: 150} NumberAnimation{target: view; property: "height"; to: itemHeight; duration: 150; easing.type: Easing.OutCubic}
onStopped: { onStopped: {
view.showRow = true view.showRow = true
} }
......
...@@ -65,6 +65,8 @@ NemoPage { ...@@ -65,6 +65,8 @@ NemoPage {
readonly property bool isPortrait: (orientation === Qt.PortraitOrientation || orientation === Qt.InvertedPortraitOrientation) readonly property bool isPortrait: (orientation === Qt.PortraitOrientation || orientation === Qt.InvertedPortraitOrientation)
readonly property bool isLandscape: (orientation === Qt.LandscapeOrientation || orientation === Qt.InvertedLandscapeOrientation) readonly property bool isLandscape: (orientation === Qt.LandscapeOrientation || orientation === Qt.InvertedLandscapeOrientation)
allowedOrientations: Qt.PortraitOrientation | Qt.LandscapeOrientation | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation
property bool __isNemoPage property bool __isNemoPage
Rectangle { Rectangle {
...@@ -73,7 +75,7 @@ NemoPage { ...@@ -73,7 +75,7 @@ NemoPage {
color: Theme.backgroundColor color: Theme.backgroundColor
} }
Item { MouseArea {
id: content id: content
anchors.fill: parent anchors.fill: parent
} }
......
...@@ -8,6 +8,8 @@ Slider { ...@@ -8,6 +8,8 @@ Slider {
id: slider id: slider
property bool showValue: false property bool showValue: false
property int valueFontSize: Theme.fontSizeTiny property int valueFontSize: Theme.fontSizeTiny
property bool useSpecSlider: true
property bool alwaysUp: false
style: SliderStyle{} style: SliderStyle{}
} }
/****************************************************************************************
**
** Copyright (c) 2017, Eetu Kahelin
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
import QtQuick 2.6
import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
TextField {
onActiveFocusChanged: {
if(activeFocus) NemoFocus.nemoregister(this)
else NemoFocus.nemoregister(null)
}
style: TextFieldStyle { }
}
...@@ -27,6 +27,7 @@ InverseMouseArea 1.0 InverseMouseArea.qml ...@@ -27,6 +27,7 @@ InverseMouseArea 1.0 InverseMouseArea.qml
IconButton 1.0 IconButton.qml IconButton 1.0 IconButton.qml
DatePicker 1.0 DatePicker.qml DatePicker 1.0 DatePicker.qml
ScrollDecorator 1.0 ScrollDecorator.qml ScrollDecorator 1.0 ScrollDecorator.qml
TextField 1.0 TextField.qml
# MIRRORED CONTROLS: # MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC. # These are the controls that we take directly from official QQC.
...@@ -56,6 +57,5 @@ TabView 1.0 ../TabView.qml ...@@ -56,6 +57,5 @@ TabView 1.0 ../TabView.qml
TableView 1.0 ../TableView.qml TableView 1.0 ../TableView.qml
TableViewColumn 1.0 ../TableViewColumn.qml TableViewColumn 1.0 ../TableViewColumn.qml
TextArea 1.0 ../TextArea.qml TextArea 1.0 ../TextArea.qml
TextField 1.0 ../TextField.qml
ToolBar 1.0 ../ToolBar.qml ToolBar 1.0 ../ToolBar.qml
ToolButton 1.0 ../ToolButton.qml ToolButton 1.0 ../ToolButton.qml
/* /*
* Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com> * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
* Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com> * Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com>
* Copyright (C) 2017 Eetu Kahelin
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
#include "nemoimageprovider.h" #include "nemoimageprovider.h"
#include "sizing.h" #include "sizing.h"
#include "theme.h" #include "theme.h"
#include "nemofocussingleton.h"
QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) : QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent) QQmlExtensionPlugin(parent)
...@@ -38,10 +40,18 @@ static QObject *nemo_hacks_singletontype_provider(QQmlEngine *engine, QJSEngine ...@@ -38,10 +40,18 @@ static QObject *nemo_hacks_singletontype_provider(QQmlEngine *engine, QJSEngine
QObject *ret = new Hacks(engine); QObject *ret = new Hacks(engine);
return ret; return ret;
} }
QObject *getNemoFocus(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return NemoFocusSingleton::instance();
}
void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri) void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri)
{ {
Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Nemo")); Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Nemo"));
qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoFocus", getNemoFocus);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoHacks", nemo_hacks_singletontype_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoHacks", nemo_hacks_singletontype_provider);
qmlRegisterType<NemoWindow>(uri, 1, 0, "NemoWindow"); qmlRegisterType<NemoWindow>(uri, 1, 0, "NemoWindow");
qmlRegisterType<NemoPage>(uri, 1, 0, "NemoPage"); qmlRegisterType<NemoPage>(uri, 1, 0, "NemoPage");
......
...@@ -23,17 +23,26 @@ import QtQuick.Controls.Styles 1.0 ...@@ -23,17 +23,26 @@ import QtQuick.Controls.Styles 1.0
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
SliderStyle{ SliderStyle{
readonly property double handleValue: control.value / control.maximumValue
readonly property double _multiple: (handleValue > 0.8) ? (control.maximumValue/control.value-1) / 0.25 : 1
readonly property double _multiple2: (handleValue > 0.8) ? (handleValue - 0.8) / 0.2 : 1
property bool useSpecSlider: control.useSpecSlider
property bool alwaysUp: control.alwaysUp
handle: Rectangle { handle: Rectangle {
id: handle id: handle
anchors.centerIn: parent anchors.verticalCenter:useSpecSlider ? undefined : parent.verticalCenter
y: useSpecSlider ? (control.pressed ? alwaysUp ? parent.y - Theme.itemHeightLarge : ((handleValue > 0.8) ? parent.y - (Theme.itemHeightLarge*_multiple2) : parent.y ) : parent.y) : undefined
x: useSpecSlider ? (control.pressed ? alwaysUp ? Theme.itemHeightExtraSmall / 2 : (handleValue > 0.8) ? (_multiple*Theme.itemHeightHuge) : Theme.itemHeightHuge : 0) : undefined
color: Theme.backgroundColor color: Theme.backgroundColor
border.color: Theme.accentColor border.color: Theme.textColor
border.width: 2 border.width: size.ratio(2)
implicitWidth: Theme.itemHeightExtraSmall implicitWidth: Theme.itemHeightExtraSmall
implicitHeight: Theme.itemHeightExtraSmall implicitHeight: Theme.itemHeightExtraSmall
radius: implicitHeight / 2 radius: implicitHeight / 2
visible: control.enabled visible: control.enabled
scale: control.pressed ? 1.2 : 1
Text{ Text{
id: valueLabel id: valueLabel
anchors.centerIn: parent anchors.centerIn: parent
...@@ -58,6 +67,16 @@ SliderStyle{ ...@@ -58,6 +67,16 @@ SliderStyle{
color: Theme.accentColor color: Theme.accentColor
} }
Rectangle{
id: strecthLine
x: dataLine.width
width: left.x-x + (handleValue < 0.85 ? Theme.itemSpacingLarge : 0)
visible: useSpecSlider ? alwaysUp ? false : (control.pressed && handleValue > 0.80) : false
height: parent.height
color: Theme.accentColor
opacity:0.3
}
Image { Image {
id: disabledImg id: disabledImg
anchors.fill: parent anchors.fill: parent
...@@ -68,14 +87,15 @@ SliderStyle{ ...@@ -68,14 +87,15 @@ SliderStyle{
Image{ Image{
id: left id: left
x: (useSpecSlider && control.pressed ? alwaysUp ? dataLine.width+width : (handleValue > 0.80) ? dataLine.width +Theme.itemHeightExtraSmall/2 +_multiple*Theme.itemHeightHuge : dataLine.width + Theme.itemHeightHuge : dataLine.width) - width
anchors{ anchors{
right: dataLine.right bottom: useSpecSlider ? ((control.pressed && (handleValue > 0.80 || alwaysUp)) ? dataLine.bottom : undefined) : undefined
verticalCenter: dataLine.verticalCenter verticalCenter: useSpecSlider ? ((control.pressed && (handleValue > 0.80 || alwaysUp)) ? undefined : dataLine.verticalCenter) : dataLine.verticalCenter
} }
source: "images/slider-handle-left.svg" source: useSpecSlider && control.pressed ? (handleValue > 0.80) || alwaysUp ? "images/slider-trumpet-up.png" : "images/slider-trumpet-stretch.png" : "images/slider-trumpet.png"
height:Theme.itemHeightExtraSmall height: control.pressed && useSpecSlider ? alwaysUp ? Theme.itemHeightLarge : (handleValue > 0.80) ? (Theme.itemHeightLarge*_multiple2) : Theme.itemHeightExtraSmall : Theme.itemHeightExtraSmall
visible: control.enabled visible: control.enabled
width: (styleData.handlePosition > Theme.itemHeightHuge) ? Theme.itemHeightHuge : styleData.handlePosition width: control.pressed && useSpecSlider ? ((handleValue > 0.80) || alwaysUp ? Theme.itemHeightExtraSmall : Theme.itemHeightHuge) : (styleData.handlePosition > Theme.itemHeightHuge) ? Theme.itemHeightHuge : styleData.handlePosition
sourceSize.width: width sourceSize.width: width
sourceSize.height: height sourceSize.height: height
} }
......
...@@ -53,7 +53,10 @@ QML_FILES += \ ...@@ -53,7 +53,10 @@ QML_FILES += \
images/disabled-overlay.png \ images/disabled-overlay.png \
images/switch-ball.png \ images/switch-ball.png \
images/slider-ball.png \ images/slider-ball.png \
images/slider-handle-left.svg images/slider-handle-left.svg \
images/slider-trumpet-stretch.png \
images/slider-trumpet-up.png \
images/slider-trumpet.png
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
themes/Theme1.js \ themes/Theme1.js \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment