Fluid
Loading...
Searching...
No Matches
picker.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
5 *
6 * $BEGIN_LICENSE:MPL2$
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 *
12 * $END_LICENSE$
13 */
14
15#pragma once
16
17#include <QLocale>
18#include <QQuickItem>
19
20class Picker : public QQuickItem
21{
22 Q_OBJECT
26 Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL)
39 Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
43 Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
47 Q_PROPERTY(QQuickItem *selector READ selector WRITE setSelector NOTIFY selectorChanged FINAL)
51 Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
52 Q_DISABLE_COPY(Picker)
53public:
58 Q_ENUM(Orientation)
59
60 explicit Picker(QQuickItem *parent = nullptr);
61
62 QLocale locale() const;
63 void setLocale(const QLocale &locale);
64
67 void resetOrientation();
68
69 QQuickItem *background() const;
70 void setBackground(QQuickItem *item);
71
72 QQuickItem *header() const;
73 void setHeader(QQuickItem *item);
74
75 QQuickItem *selector() const;
76 void setSelector(QQuickItem *item);
77
78 QQuickItem *footer() const;
79 void setFooter(QQuickItem *item);
80
81Q_SIGNALS:
88 void accepted(const QDate &date);
89 void rejected();
90
91protected:
92 void componentComplete() override;
93 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
94
95private:
96 QLocale m_locale;
97 bool m_hasOrientation = false;
98 Orientation m_orientation = Landscape;
99 QQuickItem *m_background = nullptr;
100 QQuickItem *m_header = nullptr;
101 QQuickItem *m_selector = nullptr;
102 QQuickItem *m_footer = nullptr;
103
104 bool updateOrientation();
105 void updateLayout();
106};
107
Definition picker.h:21
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
Definition picker.cpp:148
void accepted(const QDate &date)
void rejected()
void setSelector(QQuickItem *item)
Definition picker.cpp:107
Orientation orientation
Definition picker.h:35
void setFooter(QQuickItem *item)
Definition picker.cpp:127
Orientation
Definition picker.h:54
@ Portrait
Definition picker.h:56
@ Landscape
Definition picker.h:55
QLocale locale
Definition picker.h:26
QQuickItem * header
Definition picker.h:43
void setLocale(const QLocale &locale)
Definition picker.cpp:34
void orientationChanged()
void resetOrientation()
Definition picker.cpp:58
void setOrientation(Orientation orientation)
Definition picker.cpp:48
QQuickItem * background
Definition picker.h:39
void backgroundChanged()
QQuickItem * footer
Definition picker.h:51
void componentComplete() override
Definition picker.cpp:142
void setHeader(QQuickItem *item)
Definition picker.cpp:87
void headerChanged()
void localeChanged()
QQuickItem * selector
Definition picker.h:47
void footerChanged()
void selectorChanged()
void setBackground(QQuickItem *item)
Definition picker.cpp:69