Simplify box, tabs and popups size handling
This commit is contained in:
parent
7235611d54
commit
956dc52174
@ -5,18 +5,13 @@ import "../utils.js" as Utils
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: interfaceBox
|
id: interfaceBox
|
||||||
color: theme.controls.box.background
|
color: theme.controls.box.background
|
||||||
implicitWidth: Math.min(
|
implicitWidth: theme.controls.box.defaultWidth
|
||||||
window.width, theme.minimumSupportedWidthPlusSpacing * multiplyWidth
|
|
||||||
)
|
|
||||||
implicitHeight: childrenRect.height
|
implicitHeight: childrenRect.height
|
||||||
|
|
||||||
Keys.onReturnPressed: if (clickButtonOnEnter) enterClickButton()
|
Keys.onReturnPressed: if (clickButtonOnEnter) enterClickButton()
|
||||||
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
||||||
|
|
||||||
|
|
||||||
property real multiplyWidth: 1.0
|
|
||||||
|
|
||||||
property alias title: interfaceTitle.text
|
|
||||||
property alias buttonModel: buttonRepeater.model
|
property alias buttonModel: buttonRepeater.model
|
||||||
property var buttonCallbacks: []
|
property var buttonCallbacks: []
|
||||||
property string focusButton: ""
|
property string focusButton: ""
|
||||||
@ -45,30 +40,11 @@ Rectangle {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: theme.spacing
|
spacing: theme.spacing
|
||||||
|
|
||||||
HLabel {
|
|
||||||
id: interfaceTitle
|
|
||||||
visible: Boolean(text)
|
|
||||||
font.pixelSize: theme.fontSize.bigger
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
|
|
||||||
Layout.preferredWidth: parent.width
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: theme.spacing
|
|
||||||
Layout.leftMargin: theme.spacing
|
|
||||||
Layout.rightMargin: theme.spacing
|
|
||||||
}
|
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
id: interfaceBody
|
id: interfaceBody
|
||||||
spacing: theme.spacing
|
spacing: parent.spacing
|
||||||
|
|
||||||
Layout.preferredWidth: parent.width
|
Layout.margins: spacing
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin:
|
|
||||||
interfaceTitle.visible ? 0 : theme.spacing
|
|
||||||
Layout.leftMargin: theme.spacing
|
|
||||||
Layout.rightMargin: theme.spacing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HGridLayout {
|
HGridLayout {
|
||||||
@ -77,8 +53,6 @@ Rectangle {
|
|||||||
flow: width >= buttonRepeater.childrenImplicitWidth ?
|
flow: width >= buttonRepeater.childrenImplicitWidth ?
|
||||||
GridLayout.LeftToRight : GridLayout.TopToBottom
|
GridLayout.LeftToRight : GridLayout.TopToBottom
|
||||||
|
|
||||||
Layout.preferredWidth: parent.width
|
|
||||||
|
|
||||||
HRepeater {
|
HRepeater {
|
||||||
id: buttonRepeater
|
id: buttonRepeater
|
||||||
model: []
|
model: []
|
||||||
|
@ -7,6 +7,7 @@ Popup {
|
|||||||
modal: true
|
modal: true
|
||||||
focus: true
|
focus: true
|
||||||
padding: 0
|
padding: 0
|
||||||
|
margins: theme.spacing
|
||||||
|
|
||||||
|
|
||||||
enter: Transition {
|
enter: Transition {
|
||||||
|
@ -13,7 +13,6 @@ TabButton {
|
|||||||
iconItem.svgName: loading ? "hourglass" : icon.name
|
iconItem.svgName: loading ? "hourglass" : icon.name
|
||||||
icon.color: theme.icons.colorize
|
icon.color: theme.icons.colorize
|
||||||
|
|
||||||
// Must be explicitely set to display correctly on KDE
|
|
||||||
implicitWidth: Math.max(
|
implicitWidth: Math.max(
|
||||||
implicitBackgroundWidth + leftInset + rightInset,
|
implicitBackgroundWidth + leftInset + rightInset,
|
||||||
// FIXME: why is *2 needed to not get ellided text in AddAccount page?
|
// FIXME: why is *2 needed to not get ellided text in AddAccount page?
|
||||||
|
@ -3,14 +3,10 @@ import QtQuick.Controls 2.12
|
|||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
implicitWidth: Math.min(
|
|
||||||
parent.width,
|
|
||||||
Math.max(tabBar.contentWidth, swipeView.contentWidth),
|
|
||||||
)
|
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
Layout.fillWidth: false
|
Layout.fillWidth: false
|
||||||
Layout.fillHeight: false
|
Layout.fillHeight: false
|
||||||
|
Layout.maximumWidth: parent.width
|
||||||
|
|
||||||
property alias tabIndex: tabBar.currentIndex
|
property alias tabIndex: tabBar.currentIndex
|
||||||
property alias tabModel: tabRepeater.model
|
property alias tabModel: tabRepeater.model
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import "../Base"
|
import "../Base"
|
||||||
|
import "../utils.js" as Utils
|
||||||
|
|
||||||
HPopup {
|
HPopup {
|
||||||
id: popup
|
id: popup
|
||||||
@ -22,9 +23,12 @@ HPopup {
|
|||||||
property bool okEnabled: true
|
property bool okEnabled: true
|
||||||
|
|
||||||
|
|
||||||
contentItem: HBox {
|
HBox {
|
||||||
id: box
|
id: box
|
||||||
clickButtonOnEnter: "ok"
|
clickButtonOnEnter: "ok"
|
||||||
|
implicitWidth: Math.min(
|
||||||
|
window.width - popup.margins, theme.controls.popup.defaultWidth,
|
||||||
|
)
|
||||||
|
|
||||||
buttonModel: [
|
buttonModel: [
|
||||||
{ name: "ok", text: okText, iconName: "ok", enabled: okEnabled},
|
{ name: "ok", text: okText, iconName: "ok", enabled: okEnabled},
|
||||||
|
@ -15,7 +15,6 @@ BoxPopup {
|
|||||||
"you sign in again, by importing this file in your account settings."
|
"you sign in again, by importing this file in your account settings."
|
||||||
)
|
)
|
||||||
|
|
||||||
box.multiplyWidth: 1.5
|
|
||||||
box.focusButton: "ok"
|
box.focusButton: "ok"
|
||||||
box.buttonModel: [
|
box.buttonModel: [
|
||||||
{ name: "ok", text: qsTr("Export keys"), iconName: "export-keys" },
|
{ name: "ok", text: qsTr("Export keys"), iconName: "export-keys" },
|
||||||
@ -23,6 +22,7 @@ BoxPopup {
|
|||||||
iconColor: theme.colors.middleBackground },
|
iconColor: theme.colors.middleBackground },
|
||||||
{ name: "cancel", text: qsTr("Cancel"), iconName: "cancel" },
|
{ name: "cancel", text: qsTr("Cancel"), iconName: "cancel" },
|
||||||
]
|
]
|
||||||
|
|
||||||
box.buttonCallbacks: ({
|
box.buttonCallbacks: ({
|
||||||
ok: button => {
|
ok: button => {
|
||||||
Utils.makeObject(
|
Utils.makeObject(
|
||||||
|
@ -57,7 +57,9 @@ BoxPopup {
|
|||||||
|
|
||||||
|
|
||||||
HRowLayout {
|
HRowLayout {
|
||||||
spacing: box.horizontalSpacing
|
spacing: theme.spacing
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
HTextField {
|
HTextField {
|
||||||
id: passwordField
|
id: passwordField
|
||||||
|
@ -98,10 +98,12 @@ icons:
|
|||||||
|
|
||||||
controls:
|
controls:
|
||||||
box:
|
box:
|
||||||
color background: colors.strongBackground
|
int defaultWidth: minimumSupportedWidthPlusSpacing
|
||||||
int radius: theme.radius
|
int radius: theme.radius
|
||||||
|
color background: colors.strongBackground
|
||||||
|
|
||||||
popup:
|
popup:
|
||||||
|
int defaultWidth: minimumSupportedWidthPlusSpacing * 2
|
||||||
color background: colors.strongBackground
|
color background: colors.strongBackground
|
||||||
|
|
||||||
header:
|
header:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user