mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Replace button with icon and text
This commit is contained in:
parent
9c9bca546c
commit
6c5335cfa7
2 changed files with 83 additions and 9 deletions
67
interface/resources/qml/controls-uit/TextAction.qml
Normal file
67
interface/resources/qml/controls-uit/TextAction.qml
Normal file
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// TextField.qml
|
||||
//
|
||||
// Created by David Rowe on 21 Apr 2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import "../styles-uit"
|
||||
import "../controls-uit" as HifiControls
|
||||
|
||||
Item {
|
||||
property string icon: ""
|
||||
property int iconSize: 30
|
||||
property string text: ""
|
||||
|
||||
property int colorScheme: hifi.colorSchemes.light
|
||||
readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light
|
||||
|
||||
signal clicked()
|
||||
|
||||
height: Math.max(glyph.visible ? glyph.height - 4 : 0, string.visible ? string.height : 0)
|
||||
width: glyph.width + string.anchors.leftMargin + string.width
|
||||
|
||||
HiFiGlyphs {
|
||||
id: glyph
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: -2
|
||||
text: parent.icon
|
||||
size: parent.iconSize
|
||||
color: isLightColorScheme
|
||||
? (mouseArea.containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.lightGray)
|
||||
: (mouseArea.containsMouse ? hifi.colors.faintGray : hifi.colors.lightGrayText)
|
||||
visible: text !== ""
|
||||
width: visible ? implicitWidth : 0
|
||||
}
|
||||
|
||||
RalewaySemiBold {
|
||||
id: string
|
||||
anchors {
|
||||
left: glyph.visible ? glyph.right : parent.left
|
||||
leftMargin: visible && glyph.visible ? hifi.dimensions.contentSpacing.x : 0
|
||||
verticalCenter: glyph.visible ? glyph.verticalCenter : undefined
|
||||
}
|
||||
text: parent.text
|
||||
size: hifi.fontSizes.inputLabel
|
||||
color: isLightColorScheme
|
||||
? (mouseArea.containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.lightGray)
|
||||
: (mouseArea.containsMouse ? hifi.colors.faintGray : hifi.colors.lightGrayText)
|
||||
font.underline: true;
|
||||
visible: text !== ""
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: parent.clicked()
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ Window {
|
|||
resizable: true
|
||||
destroyOnInvisible: true
|
||||
x: 40; y: 40
|
||||
implicitWidth: 400; implicitHeight: 742
|
||||
implicitWidth: 400; implicitHeight: 728
|
||||
minSize: Qt.vector2d(200, 300)
|
||||
|
||||
HifiConstants { id: hifi }
|
||||
|
@ -236,16 +236,23 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
HifiControls.VerticalSpacer { }
|
||||
|
||||
HifiControls.Button {
|
||||
id: directoryButton
|
||||
text: "Reveal Scripts Folder"
|
||||
width: 200
|
||||
onClicked: fileDialogHelper.openScriptsDirectory()
|
||||
HifiControls.VerticalSpacer {
|
||||
height: hifi.dimensions.controlInterlineHeight - 3
|
||||
}
|
||||
|
||||
HifiControls.VerticalSpacer { }
|
||||
HifiControls.TextAction {
|
||||
id: directoryButton
|
||||
icon: hifi.glyphs.script
|
||||
iconSize: 24
|
||||
text: "Reveal Scripts Folder"
|
||||
onClicked: fileDialogHelper.openScriptsDirectory()
|
||||
colorScheme: hifi.colorSchemes.dark
|
||||
anchors.left: parent.left
|
||||
}
|
||||
|
||||
HifiControls.VerticalSpacer {
|
||||
height: hifi.dimensions.controlInterlineHeight - 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue