-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.qml
73 lines (64 loc) · 1.71 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import me.mnafees 1.0
Window {
visible: true
width: 300
height: 300
Twitter {
id: twitter
// Callbacks
onLoginSuccess: {
twitter.fetchUserProfile()
tweetButton.visible = true
loginButton.text = "Logout"
console.log("Login successful")
}
onLoginFailed: {
console.log("Login failed")
}
onUserProfileFetched: {
console.log("User profile fetched")
console.log(id)
console.log(name)
console.log(url)
console.log(profileImageUrl)
}
}
Button {
id: tweetButton
anchors.bottom: loginButton.top
anchors.horizontalCenter: parent.horizontalCenter
text: "Tweet"
visible: false
onClicked: {
if (twitter.isLoggedIn()) {
twitter.tweet("Test", "https://github.com/mnafees")
}
}
}
Button {
id: loginButton
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: "Login with Twitter"
onClicked: {
if (twitter.isLoggedIn()) {
twitter.logout()
tweetButton.visible = false
loginButton.text = "Login with Twitter"
} else {
twitter.login()
}
}
}
Component.onCompleted: {
if (twitter.isLoggedIn()) {
tweetButton.visible = true
loginButton.text = "Logout"
twitter.fetchUserProfile()
}
}
}