From c1d4a62fbb9991a829d8d2975363c893f6dcca16 Mon Sep 17 00:00:00 2001 From: akashihi Date: Sun, 14 Mar 2010 20:53:15 +0000 Subject: [PATCH] Add:gui/qml:Added display settings page git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3012 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/gui/qml/gui_qml.cpp | 13 ++++- navit/navit/gui/qml/skins/navit/PageSettings.qml | 2 +- .../gui/qml/skins/navit/PageSettingsDisplay.qml | 61 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 navit/navit/gui/qml/skins/navit/PageSettingsDisplay.qml diff --git a/navit/navit/gui/qml/gui_qml.cpp b/navit/navit/gui/qml/gui_qml.cpp index 81299eb..ef1def8 100644 --- a/navit/navit/gui/qml/gui_qml.cpp +++ b/navit/navit/gui/qml/gui_qml.cpp @@ -35,6 +35,7 @@ struct gui_priv { char *skin; char* icon_src; int radius; + int pitch; //Interface stuff struct callback_list *cbl; @@ -283,6 +284,10 @@ gui_qml_get_attr(struct gui_priv *this_, enum attr_type type, struct attr *attr) break; case attr_skin: attr->u.str=this_->skin; + break; + case attr_pitch: + attr->u.num=this_->pitch; + break; default: return 0; } @@ -303,8 +308,11 @@ gui_qml_set_attr(struct gui_priv *this_, struct attr *attr) } this_->fullscreen=attr->u.num; return 1; + case attr_pitch: + this_->pitch=attr->u.num; + return 1; default: - dbg(0,"%s\n",attr_to_name(attr->type)); + dbg(0,"unknown attr: %s\n",attr_to_name(attr->type)); return 1; } } @@ -348,6 +356,9 @@ static struct gui_priv * gui_qml_new(struct navit *nav, struct gui_methods *meth this_->radius = 10; //Default value if( (attr=attr_search(attrs,NULL,attr_radius))) this_->radius=attr->u.num; + this_->pitch = 20; //Default value + if( (attr=attr_search(attrs,NULL,attr_pitch))) + this_->pitch=attr->u.num; if( (attr=attr_search(attrs,NULL,attr_width))) this_->w=attr->u.num; if( (attr=attr_search(attrs,NULL,attr_height))) diff --git a/navit/navit/gui/qml/skins/navit/PageSettings.qml b/navit/navit/gui/qml/skins/navit/PageSettings.qml index fb74291..e737df4 100644 --- a/navit/navit/gui/qml/skins/navit/PageSettings.qml +++ b/navit/navit/gui/qml/skins/navit/PageSettings.qml @@ -24,7 +24,7 @@ Rectangle { anchors.bottom: parent.verticalCenter; anchors.bottomMargin: 48; spacing: 64 ButtonIcon { - id: btnDisplay; text: "Display"; icon: "gui_display.svg"; onClicked: console.log("Implement me!"); + id: btnDisplay; text: "Display"; icon: "gui_display.svg"; onClicked: { gui.returnSource="PageSettings.qml"; gui.setPage("PageSettingsDisplay.qml") } } ButtonIcon { id: btnMap; text: "Map"; icon: "gui_maps.svg"; onClicked: console.log("Implement me!"); diff --git a/navit/navit/gui/qml/skins/navit/PageSettingsDisplay.qml b/navit/navit/gui/qml/skins/navit/PageSettingsDisplay.qml new file mode 100644 index 0000000..b0f6050 --- /dev/null +++ b/navit/navit/gui/qml/skins/navit/PageSettingsDisplay.qml @@ -0,0 +1,61 @@ +import Qt 4.6 + +Rectangle { + id: page + + width: 800; height: 424 + border.width: 1 + color: "Black" + opacity: 0 + + function setTripleD(flag) { + if ( flag=="true" ) { + navit.setAttr("pitch",gui.getAttr("pitch")); + pitchSlider.value = navit.getAttr("pitch"); + pitchSlider.startup(); + pitchSlider.opacity = 1 + } else { + navit.setAttr("pitch","0"); + pitchSlider.opacity = 0 + } + } + + function isTripleD() { + if ( navit.getAttr("pitch") == "0" ) + return "0"; + else + return "1"; + } + + function pageOpen() { + if ( isTripleD() == "1" ) { + pitchSlider.opacity = 1 + } + page.opacity = 1; + } + + Component.onCompleted: pageOpen(); + + opacity: Behavior { + NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true } + } + + Grid { + columns: 1; rows: 3 + anchors.horizontalCenter: parent.horizontalCenter; + anchors.verticalCenter: parent.verticalCenter; + spacing: 64 + ToggleSwitch { + id: fullscreenSw; on: gui.getAttr("fullscreen"); text: "Fullscreen"; onChanged: gui.setAttr("fullscreen",fullscreenSw.on) + } + ToggleSwitch { + id: tripledSw; on: page.isTripleD(); text: "2D/3D"; onChanged: setTripleD(tripledSw.on) + } + Slider { + id: pitchSlider; minValue: 5; maxValue: 90; value: navit.getAttr("pitch"); text: "Pitch"; onChanged: { navit.setAttr("pitch",pitchSlider.value); gui.setAttr("pitch",pitchSlider.value) } + opacity: 0 + } + } + + Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width } +} -- 2.7.4