fixed logout
This commit is contained in:
parent
ba5f901a78
commit
d02b713341
10 changed files with 90 additions and 25 deletions
|
@ -38,6 +38,10 @@ ScrollView {
|
|||
}
|
||||
}
|
||||
|
||||
function loggedOut() {
|
||||
post = null
|
||||
}
|
||||
|
||||
Label { id: fontLabel }
|
||||
|
||||
WebView {
|
||||
|
@ -52,6 +56,8 @@ ScrollView {
|
|||
function setPost() {
|
||||
if(post) {
|
||||
experimental.evaluateJavaScript("setArticle(" + post.jsonString + ")")
|
||||
} else {
|
||||
experimental.evaluateJavaScript("setArticle('logout')")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import QtQuick 2.0
|
|||
import QtQuick.Controls 1.2
|
||||
|
||||
Rectangle {
|
||||
color: "white"
|
||||
color: "transparent"
|
||||
anchors.fill: parent
|
||||
|
||||
property string serverUrl: serverUrl.text
|
||||
|
@ -10,7 +10,8 @@ Rectangle {
|
|||
property string password: password.text
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
anchors.centerIn: parent
|
||||
width: parent.width / 2
|
||||
anchors.margins: parent.width / 4
|
||||
spacing: 10
|
||||
|
||||
|
@ -20,6 +21,7 @@ Rectangle {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: 20
|
||||
font.pointSize: 20
|
||||
}
|
||||
|
||||
TextField {
|
||||
|
|
|
@ -5,6 +5,7 @@ import TTRSS 1.0
|
|||
MenuBar {
|
||||
id: menuBar
|
||||
property bool loggedIn: false
|
||||
property ServerLogin serverLogin
|
||||
property Server server
|
||||
property Sidebar sidebar
|
||||
property Content content
|
||||
|
@ -20,7 +21,8 @@ MenuBar {
|
|||
}
|
||||
MenuItem {
|
||||
text: qsTr("Log Out")
|
||||
enabled: false
|
||||
enabled: loggedIn
|
||||
onTriggered: serverLogin.logout()
|
||||
}
|
||||
MenuSeparator { }
|
||||
MenuItem {
|
||||
|
@ -36,7 +38,7 @@ MenuBar {
|
|||
MenuItem {
|
||||
text: qsTr("Reload")
|
||||
shortcut: "R"
|
||||
enabled: true
|
||||
enabled: loggedIn
|
||||
onTriggered: server.reload()
|
||||
}
|
||||
MenuItem {
|
||||
|
@ -52,7 +54,7 @@ MenuBar {
|
|||
MenuItem {
|
||||
text: qsTr("Set &Unread")
|
||||
shortcut: "U"
|
||||
enabled: true
|
||||
enabled: loggedIn
|
||||
onTriggered: {
|
||||
content.post.dontChangeRead = true
|
||||
content.post.read = false
|
||||
|
@ -73,7 +75,7 @@ MenuBar {
|
|||
MenuItem {
|
||||
text: qsTr("Open in Browser")
|
||||
shortcut: "N"
|
||||
enabled: true
|
||||
enabled: loggedIn
|
||||
onTriggered: Qt.openUrlExternally(content.post.link)
|
||||
}
|
||||
}
|
||||
|
@ -84,19 +86,19 @@ MenuBar {
|
|||
MenuItem {
|
||||
text: qsTr("Zoom In")
|
||||
shortcut: "Ctrl++"
|
||||
enabled: true
|
||||
enabled: loggedIn
|
||||
onTriggered: app.zoomIn()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Zoom Out")
|
||||
shortcut: "Ctrl+-"
|
||||
enabled: true
|
||||
enabled: loggedIn
|
||||
onTriggered: app.zoomOut()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Reset")
|
||||
shortcut: "Ctrl+0"
|
||||
enabled: true
|
||||
enabled: loggedIn
|
||||
onTriggered: app.zoomReset()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ body {
|
|||
font-family: sans-serif;
|
||||
padding: 1em 1.5em;
|
||||
font-weight: lighter;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
|
@ -27,7 +26,8 @@ h1 {
|
|||
header p {
|
||||
color: #aaa;
|
||||
margin: 0;
|
||||
padding: 0
|
||||
padding: 0;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
a {
|
||||
|
@ -42,4 +42,5 @@ img {
|
|||
|
||||
article {
|
||||
line-height: 1.6;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
|
4
main.cpp
4
main.cpp
|
@ -12,8 +12,8 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
app.setOrganizationName("Jabs Nu");
|
||||
app.setOrganizationDomain("jabs.nu");
|
||||
app.setOrganizationName("Jeena");
|
||||
app.setOrganizationDomain("jeena.net");
|
||||
app.setApplicationName("FeedMonkey");
|
||||
|
||||
qmlRegisterType<TinyTinyRSSLogin>("TTRSS", 1, 0, "ServerLogin");
|
||||
|
|
37
main.qml
37
main.qml
|
@ -10,6 +10,9 @@ ApplicationWindow {
|
|||
title: "FeedMonkey"
|
||||
visible: true
|
||||
|
||||
minimumWidth: 480
|
||||
minimumHeight: 320
|
||||
|
||||
width: 800
|
||||
height: 640
|
||||
x: 200
|
||||
|
@ -19,42 +22,60 @@ ApplicationWindow {
|
|||
property Sidebar sidebar: sidebar
|
||||
property Content content: content
|
||||
|
||||
property int defaultTextFontSize: 13
|
||||
property int textFontSize: defaultTextFontSize
|
||||
property variant fontSizes: [7,9,11,13,15,17,19,21,23,25,27,29,31]
|
||||
property int defaultTextFontSizeIndex: 4
|
||||
property int textFontSizeIndex: defaultTextFontSizeIndex
|
||||
property int textFontSize: fontSizes[textFontSizeIndex]
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
category: "window"
|
||||
property alias x: app.x
|
||||
property alias y: app.y
|
||||
property alias width: app.width
|
||||
property alias height: app.height
|
||||
property alias sidebarWidth: sidebar.width
|
||||
//property alias textFontSize: app.textFontSize
|
||||
property alias textFontSizeIndex: app.textFontSizeIndex
|
||||
}
|
||||
|
||||
property TheMenuBar menu: TheMenuBar {
|
||||
id: menu
|
||||
serverLogin: serverLogin
|
||||
server: server
|
||||
sidebar: sidebar
|
||||
content: content
|
||||
}
|
||||
|
||||
function loggedIn() {
|
||||
if(serverLogin.loggedIn()) {
|
||||
menu.loggedIn = true;
|
||||
contentView.visible = true
|
||||
login.visible = false;
|
||||
server.initialize(serverLogin.serverUrl, serverLogin.sessionId);
|
||||
} else {
|
||||
menu.loggedIn = false
|
||||
contentView.visible = false
|
||||
login.visible = true
|
||||
server.loggedOut()
|
||||
content.loggedOut()
|
||||
}
|
||||
}
|
||||
|
||||
function zoomIn() {
|
||||
textFontSize *= 1.2
|
||||
if(textFontSizeIndex + 1 < fontSizes.length) {
|
||||
textFontSize = fontSizes[++textFontSizeIndex]
|
||||
}
|
||||
}
|
||||
|
||||
function zoomOut() {
|
||||
textFontSize *= 0.8
|
||||
if(textFontSizeIndex - 1 > 0) {
|
||||
textFontSize = fontSizes[--textFontSizeIndex]
|
||||
}
|
||||
}
|
||||
|
||||
function zoomReset() {
|
||||
textFontSize = defaultTextFontSize
|
||||
textFontSizeIndex = defaultTextFontSizeIndex
|
||||
textFontSize = fontSizes[textFontSizeIndex]
|
||||
}
|
||||
|
||||
function keyPressed(event) {
|
||||
|
@ -98,6 +119,7 @@ ApplicationWindow {
|
|||
}
|
||||
|
||||
SplitView {
|
||||
id: contentView
|
||||
anchors.fill: parent
|
||||
orientation: Qt.Horizontal
|
||||
visible: serverLogin.loggedIn()
|
||||
|
@ -140,13 +162,14 @@ ApplicationWindow {
|
|||
visible: !serverLogin.loggedIn()
|
||||
|
||||
function login() {
|
||||
console.log("FOO")
|
||||
serverLogin.login(serverUrl, userName, password)
|
||||
}
|
||||
}
|
||||
|
||||
ServerLogin {
|
||||
id: serverLogin
|
||||
onSessionIdChanged: loggedIn()
|
||||
onSessionIdChanged: app.loggedIn()
|
||||
}
|
||||
|
||||
Server {
|
||||
|
|
|
@ -52,6 +52,14 @@ void TinyTinyRSS::reload()
|
|||
});
|
||||
}
|
||||
|
||||
void TinyTinyRSS::loggedOut()
|
||||
{
|
||||
mServerUrl = nullptr;
|
||||
mSessionId = nullptr;
|
||||
mPosts.clear();
|
||||
emit postsChanged(mPosts);
|
||||
}
|
||||
|
||||
void TinyTinyRSS::doOperation(QString operation, QVariantMap opts, std::function<void (const QJsonObject &json)> callback)
|
||||
{
|
||||
QVariantMap options;
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
|
||||
Q_INVOKABLE void initialize(const QString serverUrl, const QString sessionId);
|
||||
Q_INVOKABLE void reload();
|
||||
Q_INVOKABLE void loggedOut();
|
||||
|
||||
|
||||
QQmlListProperty<Post> posts();
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QSettings>
|
||||
|
||||
#define APP_URL "net.jeena"
|
||||
#define APP_NAME "FeedMonkey"
|
||||
|
||||
TinyTinyRSSLogin::TinyTinyRSSLogin(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
mNetworkManager = new QNetworkAccessManager(this);
|
||||
|
||||
QSettings settings("net.jeena", "feedmonkey");
|
||||
QSettings settings;
|
||||
mSessionId = settings.value("sessionId").toString();
|
||||
mServerUrl = settings.value("serverUrl").toString();
|
||||
}
|
||||
|
@ -43,6 +46,24 @@ void TinyTinyRSSLogin::login(const QString serverUrl, const QString user, const
|
|||
connect(reply, SIGNAL(finished()), this, SLOT(reply()));
|
||||
}
|
||||
|
||||
void TinyTinyRSSLogin::logout()
|
||||
{
|
||||
if(mSessionId.length() > 0 && mServerUrl.toString().length() > 0) {
|
||||
QVariantMap options;
|
||||
options.insert("op", "logout");
|
||||
options.insert("sid", mSessionId);
|
||||
|
||||
QJsonObject jsonobj = QJsonObject::fromVariantMap(options);
|
||||
QJsonDocument json = QJsonDocument(jsonobj);
|
||||
|
||||
QNetworkRequest request(mServerUrl);
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QNetworkReply *reply = mNetworkManager->post(request, json.toJson());
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(reply()));
|
||||
}
|
||||
}
|
||||
|
||||
void TinyTinyRSSLogin::reply()
|
||||
{
|
||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||
|
@ -56,7 +77,7 @@ void TinyTinyRSSLogin::reply()
|
|||
|
||||
emit sessionIdChanged(mSessionId);
|
||||
|
||||
QSettings settings("net.jeena", "feedmonkey");
|
||||
QSettings settings;
|
||||
settings.setValue("sessionId", mSessionId);
|
||||
settings.setValue("serverUrl", mServerUrl);
|
||||
settings.sync();
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
Q_INVOKABLE bool loggedIn();
|
||||
Q_INVOKABLE void login(const QString serverUrl, const QString user, const QString password);
|
||||
Q_INVOKABLE void logout();
|
||||
|
||||
signals:
|
||||
void sessionIdChanged(QString);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue