Skip to content

Commit

Permalink
clean settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronson Mathews committed Jul 31, 2020
1 parent 9adbe59 commit 4a773cc
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
<file>qml/Style/TextField.qml</file>
<file>qml/Style/ListSeparator.qml</file>
<file>qml/DurationPicker.qml</file>
<file>qml/Style/Menu.qml</file>
<file>qml/Style/MenuItem.qml</file>
<file>qml/ListViewPicker.qml</file>
</qresource>
</RCC>
105 changes: 105 additions & 0 deletions src/qml/ListViewPicker.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import QtQuick 2.11
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.2
import 'Style'

Dialog {
property alias currentIndex: popup_list_view.currentIndex
property var model: []

Component.onCompleted: {
for (var i=0; i<model.length; i++) {
popup_list_model.append(model[i]);
}
}

id: control
padding: Style.app.margin
implicitWidth: 200
implicitHeight: 200
anchors.centerIn: parent

background: Rectangle {
color: Style.app.color
}

footer:
Item {
id: tool_bar
Layout.fillWidth: true
height: cancel_button.height

RowLayout {
id: tool_row
anchors.fill: parent

Button {
id: cancel_button
text: 'Cancel'
Layout.fillWidth: true
onClicked: {
reject();
}
}

Button {
id: okay_button
text: 'Okay'
Layout.fillWidth: true
onClicked: {
accept();
}
}
}
}


ListModel {
id: popup_list_model
}

Component {
id: popup_list_delegate

Rectangle {
id: background
color: ListView.isCurrentItem? Style.library.color_highlight : Style.library.color_background
radius: Style.library.radius_background
implicitHeight: title.height + Style.library.margin * 2
implicitWidth: popup_list_view.width


Label {
id: title
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.margins: Style.library.margin
text: model.label
font.pixelSize: Style.control.font_size_chapter
}

MouseArea {
anchors.fill: parent
onClicked: {
popup_list_view.currentIndex = index;
}
}
}
}

Item {
anchors.fill: parent

ListView {
id: popup_list_view
anchors.fill: parent
clip: true
currentIndex: -1
model: popup_list_model
delegate: popup_list_delegate
}
}

}


25 changes: 17 additions & 8 deletions src/qml/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,31 @@ Page {
anchors.margins: Style.settings.margin
}

SpinBox {
id: font_scale_spin
value: QSettings.value('font_scale', 100)
from: 50
to: 200
stepSize: 10
editable: true
Label {
id: font_scale_value
text: Style.font_scale * 100
Layout.alignment: Qt.AlignRight
anchors.right: parent.right
anchors.margins: Style.settings.margin
anchors.verticalCenter: parent.verticalCenter
onValueChanged: {
}

ListViewPicker {
id: lvp
model: [{label: "75"}, {label: "100"}, {label: "125"}, {label: "150"}, {label: "200"}]
onAccepted: {
var value = parseInt(model[currentIndex].label)
Style.font_scale = value / 100;
QSettings.setValue('font_scale', value);
}
}

MouseArea {
anchors.fill: parent
onClicked: {
lvp.open();
}
}
}

Separator {}
Expand Down
15 changes: 15 additions & 0 deletions src/qml/Style/Menu.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Templates 2.2 as T

Menu {
id: control

background: Rectangle {
id: menu_background
implicitWidth: 200
implicitHeight: 40
color: Style.menu.color_background
radius: 2
}
}
34 changes: 34 additions & 0 deletions src/qml/Style/MenuItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Templates 2.2 as T

MenuItem {
id: control

implicitWidth: 100
implicitHeight: 40

background:
Rectangle {
id: menu_background
implicitWidth: 100
implicitHeight: 40
opacity: enabled ? 1 : 0.3
color: control.highlighted ? Style.menu.color_highlight : 'transparent'
radius: 2
}

contentItem:
Text {
//leftPadding: control.indicator.width
//rightPadding: control.arrow.width
text: control.text
font: control.font
opacity: enabled ? 1.0 : 0.3
color: Style.app.font_color
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}

}
5 changes: 5 additions & 0 deletions src/qml/Style/Style.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ QtObject {
property color color_down: '#646464'
}

property QtObject menu: QtObject {
property color color_background: app.color
property color color_highlight: app.color_highlight
}

property QtObject slider: QtObject {
property color color_handle: '#ffffff'
property color color_handle_pressed: '#464646'
Expand Down

0 comments on commit 4a773cc

Please sign in to comment.