forked from KomodoPlatform/komodo-wallet
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request KomodoPlatform#1780 from KomodoPlatform/calendar
Change Calendar style
- Loading branch information
Showing
5 changed files
with
279 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import QtQuick 2.12 | ||
import QtQuick.Layouts 1.12 | ||
|
||
import Qaterial 1.0 as Qaterial | ||
|
||
import Dex.Themes 1.0 as Dex | ||
import "../Constants" | ||
|
||
DefaultMouseArea | ||
{ | ||
id: control | ||
|
||
property alias titleText: title.text | ||
property alias minimumDate: calendar.minimumDate | ||
property alias maximumDate: calendar.maximumDate | ||
property alias selectedDate: calendar.selectedDate | ||
|
||
signal accepted() | ||
|
||
width: 100 | ||
height: column.height | ||
|
||
onClicked: modal.open() | ||
|
||
Column | ||
{ | ||
id: column | ||
width: parent.width | ||
|
||
DefaultText | ||
{ | ||
id: title | ||
text: qsTr("Date") | ||
font: DexTypo.overLine | ||
color: Dex.CurrentTheme.foregroundColor2 | ||
} | ||
|
||
RowLayout | ||
{ | ||
width: parent.width | ||
|
||
DefaultText | ||
{ | ||
id: label | ||
text: selectedDate.toLocaleDateString(Locale.ShortFormat, "yyyy-MM-dd") | ||
font: DexTypo.caption | ||
} | ||
Item { Layout.fillWidth: true } | ||
DefaultImage | ||
{ | ||
Layout.preferredWidth: 25 | ||
Layout.preferredHeight: 25 | ||
source: Qaterial.Icons.calendarBlank | ||
|
||
DefaultColorOverlay | ||
{ | ||
source: parent | ||
anchors.fill: parent | ||
color: Dex.CurrentTheme.foregroundColor2 | ||
} | ||
} | ||
} | ||
} | ||
|
||
DefaultModal | ||
{ | ||
id: modal | ||
width: 300 | ||
height: 450 | ||
verticalPadding: 0 | ||
horizontalPadding: 0 | ||
|
||
DefaultCalendar | ||
{ | ||
id: calendar | ||
anchors.fill: parent | ||
onSelectedDateChanged: {modal.close(); control.accepted()} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import QtQuick 2.0 | ||
import QtQuick.Controls 1.4 | ||
import QtQuick.Controls.Styles 1.4 | ||
|
||
import Qaterial 1.0 as Qaterial | ||
|
||
import Dex.Themes 1.0 as Dex | ||
|
||
Calendar | ||
{ | ||
width: 300 | ||
height: 450 | ||
style: CalendarStyle | ||
{ | ||
gridColor: "transparent" | ||
gridVisible: false | ||
|
||
background: DefaultRectangle | ||
{ | ||
color: Dex.CurrentTheme.floatingBackgroundColor | ||
radius: 18 | ||
} | ||
|
||
navigationBar: DefaultRectangle | ||
{ | ||
height: 50 | ||
color: Dex.CurrentTheme.floatingBackgroundColor | ||
radius: 18 | ||
|
||
DefaultButton | ||
{ | ||
id: previousYear | ||
width: previousMonth.width | ||
height: width | ||
anchors.left: parent.left | ||
anchors.leftMargin: 5 | ||
anchors.verticalCenter: parent.verticalCenter | ||
iconSource: Qaterial.Icons.arrowLeft | ||
onClicked: control.showPreviousYear() | ||
} | ||
|
||
DefaultButton | ||
{ | ||
id: previousMonth | ||
width: parent.height - 14 | ||
height: width | ||
anchors.left: previousYear.right | ||
anchors.leftMargin: 2 | ||
anchors.verticalCenter: parent.verticalCenter | ||
iconSource: Qaterial.Icons.arrowLeft | ||
onClicked: control.showPreviousMonth() | ||
} | ||
|
||
DefaultText | ||
{ | ||
id: dateText | ||
text: styleData.title | ||
elide: Text.ElideRight | ||
horizontalAlignment: Text.AlignHCenter | ||
anchors.verticalCenter: parent.verticalCenter | ||
anchors.left: previousMonth.right | ||
anchors.leftMargin: 2 | ||
anchors.right: nextMonth.left | ||
anchors.rightMargin: 2 | ||
} | ||
|
||
DefaultButton | ||
{ | ||
id: nextYear | ||
width: nextMonth.width | ||
height: width | ||
anchors.right: parent.right | ||
anchors.rightMargin: 5 | ||
anchors.verticalCenter: parent.verticalCenter | ||
iconSource: Qaterial.Icons.arrowRight | ||
onClicked: control.showNextYear() | ||
} | ||
|
||
DefaultButton | ||
{ | ||
id: nextMonth | ||
width: parent.height - 14 | ||
height: width | ||
anchors.verticalCenter: parent.verticalCenter | ||
anchors.right: nextYear.left | ||
anchors.rightMargin: 2 | ||
iconSource: Qaterial.Icons.arrowRight | ||
onClicked: control.showNextMonth() | ||
} | ||
} | ||
|
||
dayOfWeekDelegate: DefaultRectangle | ||
{ | ||
color: "transparent" | ||
implicitHeight: 20 | ||
Label | ||
{ | ||
text: control.locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat) | ||
anchors.centerIn: parent | ||
color: Dex.CurrentTheme.foregroundColor | ||
} | ||
} | ||
|
||
dayDelegate: DefaultRectangle | ||
{ | ||
anchors.fill: parent | ||
color: styleData.date !== undefined && styleData.selected ? selectedDateColor : styleData.hovered ? hoveredDateColor : "transparent" | ||
|
||
readonly property bool addExtraMargin: control.frameVisible && styleData.selected | ||
readonly property color sameMonthDateTextColor: Dex.CurrentTheme.foregroundColor | ||
readonly property color hoveredDateColor: Dex.CurrentTheme.buttonColorHovered | ||
readonly property color selectedDateColor: Dex.CurrentTheme.buttonColorPressed | ||
readonly property color selectedDateTextColor: Dex.CurrentTheme.foregroundColor | ||
readonly property color differentMonthDateTextColor: Dex.CurrentTheme.foregroundColor3 | ||
readonly property color invalidDateColor: Dex.CurrentTheme.textDisabledColor | ||
DefaultText | ||
{ | ||
id: dayDelegateText | ||
text: styleData.date.getDate() | ||
anchors.centerIn: parent | ||
horizontalAlignment: Text.AlignRight | ||
font.pixelSize: Math.min(parent.height/3, parent.width/3) | ||
color: { | ||
var theColor = invalidDateColor; | ||
if (styleData.valid) { | ||
// Date is within the valid range. | ||
theColor = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor; | ||
if (styleData.selected) | ||
theColor = selectedDateTextColor; | ||
} | ||
theColor; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.