From 9819e63fccd290f9804c660bdc0617c026eb2ec7 Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Thu, 16 Nov 2017 22:05:14 +0100 Subject: [PATCH] Singleton for future style definition. For now, put the fonts there --- components/MenuButton.qml | 14 +++----------- components/Style.qml | 10 ++++++++++ components/qmldir | 1 + qml.qrc | 2 ++ 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 components/Style.qml create mode 100644 components/qmldir diff --git a/components/MenuButton.qml b/components/MenuButton.qml index 928848a6..319170b4 100644 --- a/components/MenuButton.qml +++ b/components/MenuButton.qml @@ -26,8 +26,9 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import QtQuick 2.0 +import QtQuick 2.5 import QtGraphicalEffects 1.0 +import "." 1.0 Rectangle { id: button @@ -60,15 +61,6 @@ Rectangle { property bool present: !under || under.checked || checked || under.numSelectedChildren > 0 height: present ? ((appWindow.height >= 800) ? 44 * scaleRatio : 52 * scaleRatio ) : 0 - // Load custom fonts @TODO: should probably do this somewhere else - Text { - FontLoader { id: sfuid; source: "../fonts/SFUIDisplay-Bold.otf"; } - FontLoader { source: "../fonts/SFUIDisplay-Medium.otf"; } - FontLoader { source: "../fonts/SFUIDisplay-Light.otf"; } - FontLoader { source: "../fonts/SFUIDisplay-Regular.otf"; } - font.family: "SFUIDisplay"; - } - // Button gradient whilst checked // @TODO: replace by .png - gradient not available in 2d renderer LinearGradient { @@ -115,7 +107,7 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.right anchors.leftMargin: 8 * scaleRatio - font.family: "SFUIDisplay" + font.family: Style.fontMedium.name font.bold: true font.pixelSize: 16 * scaleRatio color: "#FFFFFF" diff --git a/components/Style.qml b/components/Style.qml new file mode 100644 index 00000000..cab0e062 --- /dev/null +++ b/components/Style.qml @@ -0,0 +1,10 @@ +pragma Singleton + +import QtQuick 2.5 + +QtObject { + property QtObject fontMedium: FontLoader { id: _fontMedium; source: "qrc:/fonts/SFUIDisplay-Medium.otf"; } + property QtObject fontBold: FontLoader { id: _fontBold; source: "qrc:/fonts/SFUIDisplay-Bold.otf"; } + property QtObject fontLight: FontLoader { id: _fontLight; source: "qrc:/fonts/SFUIDisplay-Light.otf"; } + property QtObject fontRegular: FontLoader { id: _fontRegular; source: "qrc:/fonts/SFUIDisplay-Regular.otf"; } +} diff --git a/components/qmldir b/components/qmldir new file mode 100644 index 00000000..81984227 --- /dev/null +++ b/components/qmldir @@ -0,0 +1 @@ +singleton Style 1.0 Style.qml diff --git a/qml.qrc b/qml.qrc index f8d739be..7f5b673c 100644 --- a/qml.qrc +++ b/qml.qrc @@ -182,5 +182,7 @@ fonts/SFUIDisplay-Regular.otf fonts/SFUIDisplay-Light.otf fonts/SFUIDisplay-Bold.otf + components/Style.qml + components/qmldir