aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols/attachedstyleproperties/MyStyle/ToolBar.qml
blob: 3f1944d980aa1f80ae167df3bcacc3c32d7f3540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Templates as T

import MyStyle

T.ToolBar {
    id: control

    implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
                            implicitContentWidth + leftPadding + rightPadding)
    implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
                             implicitContentHeight + topPadding + bottomPadding)

    topPadding: SafeArea.margins.top
    leftPadding: SafeArea.margins.left
    rightPadding: SafeArea.margins.right
    bottomPadding: SafeArea.margins.bottom

    background: Rectangle {
        implicitHeight: 40
        // Ensure that we use Control's attached MyStyle object by qualifying
        // the binding with its id. If we don't do this, an extra, unnecessary
        // attached MyStyle object will be created for the Rectangle.
        color: control.MyStyle.toolBarColor
    }
}