demos/declarative/twitter/twitter.qml
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    44 
    44 
    45 Item {
    45 Item {
    46     id: screen; width: 320; height: 480
    46     id: screen; width: 320; height: 480
    47     property bool userView : false
    47     property bool userView : false
    48     property variant tmpStr
    48     property variant tmpStr
    49     function setMode(m){
       
    50         screen.userView = m;
       
    51         if(m == false){
       
    52             rssModel.tags='my timeline';
       
    53             rssModel.reload();
       
    54             toolBar.button2Label = "View others";
       
    55         } else {
       
    56             toolBar.button2Label = "Return home";
       
    57         }
       
    58     }
       
    59     function setUser(str){hack.running = true; tmpStr = str}
    49     function setUser(str){hack.running = true; tmpStr = str}
    60     function reallySetUser(){rssModel.tags = tmpStr;}
    50     function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
    61 
    51     state:"searchquery"
    62     //Workaround for bug 260266
    52     //Workaround for bug 260266
    63     Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
    53     Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
    64 
    54     Keys.onEscapePressed: screen.state="searchquery"
    65     //TODO: better way to return to the auth screen
    55     Keys.onBacktabPressed: screen.state="searchquery"
    66     Keys.onEscapePressed: rssModel.authName=''
       
    67     Rectangle {
    56     Rectangle {
    68         id: background
    57         id: background
    69         anchors.fill: parent; color: "#343434";
    58         anchors.fill: parent; color: "#343434";
    70 
    59 
       
    60         state:"searchquery"
    71         Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
    61         Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
    72 
    62 
    73         MouseArea {
    63         MouseArea {
    74             anchors.fill: parent
    64             anchors.fill: parent
    75             onClicked: screen.focus = false;
    65             onClicked: screen.focus = false;
    88             id: views
    78             id: views
    89             x: 2; width: parent.width - 4
    79             x: 2; width: parent.width - 4
    90             y:60 //Below the title bars
    80             y:60 //Below the title bars
    91             height: 380
    81             height: 380
    92 
    82 
    93             Twitter.AuthView{
    83             Text {
    94                 id: authView
    84                 id:title
       
    85                 text: "Search Twitter"
       
    86                 anchors.horizontalCenter: parent.horizontalCenter
       
    87                 font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
       
    88                 opacity:0
       
    89             }
       
    90 
       
    91             Twitter.SearchView{
       
    92                 id: searchView
    95                 anchors.verticalCenter: parent.verticalCenter
    93                 anchors.verticalCenter: parent.verticalCenter
    96                 width: parent.width; height: parent.height-60;
    94                 width: parent.width; height: parent.height-60;
    97                 x: -(screen.width * 1.5)
    95                 x: -(screen.width * 1.5)
    98             }
    96             }
    99 
    97 
   108         Twitter.ToolBar { id: toolBar; height: 40;
   106         Twitter.ToolBar { id: toolBar; height: 40;
   109             //anchors.bottom: parent.bottom;
   107             //anchors.bottom: parent.bottom;
   110             //TODO: Use anchor changes instead of hard coding
   108             //TODO: Use anchor changes instead of hard coding
   111             y: screen.height - 40
   109             y: screen.height - 40
   112             width: parent.width; opacity: 0.9
   110             width: parent.width; opacity: 0.9
   113             button1Label: "Update"
   111             button1Label: "New Search"
   114             button2Label: "View others"
   112             button2Label: "Update"
   115             onButton1Clicked: rssModel.reload();
   113             onButton1Clicked:
   116             onButton2Clicked:
       
   117             {
   114             {
   118                 if(screen.userView == true){
   115                 screen.state="searchquery"
   119                     screen.setMode(false);
       
   120                 }else{
       
   121                     rssModel.tags='';
       
   122                     screen.setMode(true);
       
   123                 }
       
   124             }
   116             }
       
   117             onButton2Clicked: rssModel.reload();
   125         }
   118         }
   126 
       
   127         states: [
       
   128             State {
       
   129                 name: "unauthed"; when: rssModel.authName==""
       
   130                 PropertyChanges { target: authView; x: 0 }
       
   131                 PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
       
   132                 PropertyChanges { target: titleBar; y: -80 }
       
   133                 PropertyChanges { target: toolBar; y: screen.height }
       
   134             }
       
   135         ]
       
   136         transitions: [
       
   137             Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
       
   138         ]
       
   139     }
   119     }
       
   120     states: [
       
   121         State {
       
   122             name: "searchquery";
       
   123             PropertyChanges { target: searchView; x: 0; focus:true}
       
   124             PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
       
   125             PropertyChanges { target: titleBar; y: -80 }
       
   126             PropertyChanges { target: toolBar; y: screen.height }
       
   127             PropertyChanges { target: toolBar }
       
   128             PropertyChanges { target: title; opacity:1}
       
   129         }
       
   130     ]
       
   131     transitions: [
       
   132         Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
       
   133     ]
   140 }
   134 }