Commit c5478fa8 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(dialog): use style file

parent fe236ca4
...@@ -33,8 +33,9 @@ ...@@ -33,8 +33,9 @@
<file>ui/components/form/DarkButton.qml</file> <file>ui/components/form/DarkButton.qml</file>
<file>ui/components/invertedMouseArea/InvertedMouseArea.qml</file> <file>ui/components/invertedMouseArea/InvertedMouseArea.qml</file>
<file>ui/scripts/utils.js</file> <file>ui/scripts/utils.js</file>
<file>ui/style/components/Dialog.qml</file>
<file>ui/style/components/Collapse.qml</file>
<file>ui/style/qmldir</file> <file>ui/style/qmldir</file>
<file>ui/style/collapse/Style.qml</file>
<file>ui/style/Constants.qml</file> <file>ui/style/Constants.qml</file>
<file>ui/views/newCall.qml</file> <file>ui/views/newCall.qml</file>
<file>ui/views/manageAccounts.qml</file> <file>ui/views/manageAccounts.qml</file>
......
import QtQuick 2.7 import QtQuick 2.7
import 'qrc:/ui/components/form' import 'qrc:/ui/components/form'
import 'qrc:/ui/style'
// ===================================================================
// A simple dialog with OK/Cancel buttons.
// =================================================================== // ===================================================================
DialogPlus { DialogPlus {
id: dialog
buttons: [ buttons: [
DarkButton { DarkButton {
onClicked: exit(0)
text: qsTr('cancel') text: qsTr('cancel')
onClicked: exit(0)
}, },
DarkButton { DarkButton {
onClicked: exit(1)
text: qsTr('confirm') text: qsTr('confirm')
onClicked: exit(1)
} }
] ]
centeredButtons: true centeredButtons: true
id: dialog maximumHeight: DialogStyle.confirm.height
maximumWidth: 370 maximumWidth: DialogStyle.confirm.width
maximumHeight: 150 minimumHeight: DialogStyle.confirm.height
minimumWidth: 370 minimumWidth: DialogStyle.confirm.width
minimumHeight: 150
} }
import QtQuick 2.7 import QtQuick 2.7
import 'qrc:/ui/style'
// =================================================================== // ===================================================================
// Description content used by dialogs. // Description content used by dialogs.
// =================================================================== // ===================================================================
...@@ -7,14 +9,15 @@ import QtQuick 2.7 ...@@ -7,14 +9,15 @@ import QtQuick 2.7
Item { Item {
property alias text: description.text property alias text: description.text
height: text ? 90 : 25 height: text ? DialogStyle.description.height : DialogStyle.description.minHeight
Text { Text {
anchors.fill: parent
anchors.leftMargin: 50
anchors.rightMargin: 50
font.pointSize: 12
id: description id: description
anchors.fill: parent
anchors.leftMargin: DialogStyle.leftMargin
anchors.rightMargin: DialogStyle.rightMargin
font.pointSize: DialogStyle.description.fontSize
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
......
...@@ -2,63 +2,68 @@ import QtQuick 2.7 ...@@ -2,63 +2,68 @@ import QtQuick 2.7
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import 'qrc:/ui/style'
// =================================================================== // ===================================================================
// Helper to build quickly dialogs. // Helper to build quickly dialogs.
// =================================================================== // ===================================================================
Window { Window {
default property alias content: content.data // Required. default property alias content: content.data // Required.
property alias buttons: buttons.data // Required. property alias buttons: buttons.data // Optionnal.
property alias descriptionText: description.text // Optionnal. property alias descriptionText: description.text // Optionnal.
property bool centeredButtons // Optionnal. property bool centeredButtons: false
property bool disableExitStatus // Internal property. property bool _disableExitStatus
signal exitStatus (int status) signal exitStatus (int status)
modality: Qt.WindowModal
// Handle normal windows close.
onClosing: !disableExitStatus && exitStatus(0)
// Derived class must use this function instead of close. // Derived class must use this function instead of close.
function exit (status) { function exit (status) {
if (!disableExitStatus) { if (!_disableExitStatus) {
disableExitStatus = true _disableExitStatus = true
exitStatus(status) exitStatus(status)
close() close()
} }
} }
modality: Qt.WindowModal
// Handle normal windows close.
onClosing: !_disableExitStatus && exitStatus(0)
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
// Description. // Description.
DialogDescription { DialogDescription {
Layout.fillWidth: true
id: description id: description
Layout.fillWidth: true
} }
// Content. // Content.
Item { Item {
id: content
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
id: content
} }
// Buttons. // Buttons.
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
height: 60 Layout.preferredHeight: DialogStyle.buttonsAreaHeight
Row { Row {
id: buttons
anchors.left: (!centeredButtons && parent.left) || undefined anchors.left: (!centeredButtons && parent.left) || undefined
anchors.centerIn: centeredButtons ? parent : undefined anchors.centerIn: centeredButtons ? parent : undefined
anchors.leftMargin: 50 anchors.leftMargin: DialogStyle.leftMargin
height: 30 anchors.verticalCenter: (!centeredButtons && parent.verticalCenter) || undefined
id: buttons spacing: DialogStyle.buttonsSpacing
spacing: 20
} }
} }
} }
......
pragma Singleton
import QtQuick 2.7
QtObject {
property int zPopup: 999
property int zMax: 999999
}
...@@ -2,11 +2,11 @@ pragma Singleton ...@@ -2,11 +2,11 @@ pragma Singleton
import QtQuick 2.7 import QtQuick 2.7
QtObject { QtObject {
property var background: Rectangle {
color: 'transparent'
}
property int animationDuration: 200 property int animationDuration: 200
property int iconSize: 32 property int iconSize: 32
property string icon: 'collapse' property string icon: 'collapse'
property var background: Rectangle {
color: 'transparent'
}
} }
pragma Singleton
import QtQuick 2.7
QtObject {
property int buttonsAreaHeight: 60
property int buttonsSpacing: 20
property int leftMargin: 50
property int rightMargin: 50
property QtObject description: QtObject {
property int fontSize: 12
property int height: 90
property int minHeight: 25
}
property QtObject confirm: QtObject {
property int height: 150
property int width: 370
}
}
# See: https://wiki.qt.io/Qml_Styling
module Style module Style
singleton Constants 1.0 Constants.qml singleton Constants 1.0 Constants.qml
singleton CollapseStyle 1.0 collapse/Style.qml singleton CollapseStyle 1.0 components/Collapse.qml
singleton DialogStyle 1.0 components/Dialog.qml
...@@ -130,7 +130,7 @@ ApplicationWindow { ...@@ -130,7 +130,7 @@ ApplicationWindow {
Loader { Loader {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
source: 'qrc:/ui/views/mainWindow/conversation.qml' source: 'qrc:/ui/views/mainWindow/contacts.qml'
} }
} }
......
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