Skip to content

Commit

Permalink
Add some extra headers
Browse files Browse the repository at this point in the history
  • Loading branch information
realbardia committed Dec 17, 2020
1 parent e43f472 commit 4d296ec
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cpp/cpp.pri
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ CONFIG += c++11

qtHaveModule(webview): QT += webview

DEFINES += MEIKADE_VERSION='\\"$${VERSION}\\"'
DEFINES += \
MEIKADE_VERSION='\\"$${VERSION}\\"' \
UNLOCK_PASSWORD='\\"$${UNLOCK_PASSWORD}\\"'

disable-subscription: DEFINES += DISABLE_SUBSCRIPTION

Expand Down
1 change: 1 addition & 0 deletions cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ int main(int argc, char *argv[])
engine.addImportPath(":/qml/imports/");
engine.rootContext()->setContextProperty("isAndroidStyle", androidStyle);
engine.rootContext()->setContextProperty("appVersion", MEIKADE_VERSION);
engine.rootContext()->setContextProperty("unlockPassword", UNLOCK_PASSWORD);
engine.rootContext()->setContextProperty("qVersion", qVersion());
engine.rootContext()->setContextProperty("activeSubscription", activeSubscription);
const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
Expand Down
2 changes: 2 additions & 0 deletions qml/imports/globals/AsemanGlobals.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ AsemanObject {
property alias syncViews: _sync.syncViews
property alias syncTopPoets: _sync.syncTopPoets

property int lastPremiumDays: -1

Component.onCompleted: {
Tools.mkDir(cachePath);
}
Expand Down
8 changes: 8 additions & 0 deletions qml/imports/logics/SearchPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ SearchView {
Bootstrap.subscription = true;
GlobalSignals.snackbarRequest(":)");
}
else
if (unlockPassword.length && keywordField.text == unlockPassword) {
Bootstrap.fullyUnlocked = true;
Bootstrap.initialized = true;
Bootstrap.payment = true;
Bootstrap.subscription = true;
GlobalSignals.snackbarRequest(":)");
}
}

onPoetIdChanged: loadPoetId()
Expand Down
1 change: 1 addition & 0 deletions qml/imports/requests/BaseRequest.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NetworkRequest {
"App-Build-OS": (Devices.isAndroid? "android" : Devices.isIOS? "ios" : Devices.isLinux? "linux" : Devices.isWindows? "windows" : Devices.isMacX? "osx" : "other"),
"Theme-Dark": Colors.darkMode? "true" : "false",
"Content-Type": "application/json",
"Premium-Days": AsemanGlobals.lastPremiumDays + "",
"User-token": accessToken,
"Accept-Language": GTranslations.localeName
}
Expand Down
4 changes: 4 additions & 0 deletions qml/imports/requests/Bootstrap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ AsemanObject {
property bool subscription: false
property bool payment: false
property bool aseman: false
property bool fullyUnlocked: false

readonly property string paymentUnlockCode: try { return req.response.result.paymentUnlockCode; } catch (e) { return ""; }

onInitializedChanged: write("initialized", initialized);
onSubscriptionChanged: write("subscription", subscription);
onPaymentChanged: write("payment", payment);
onAsemanChanged: write("aseman", aseman);
onFullyUnlockedChanged: write("fullyUnlocked", fullyUnlocked);

Component.onCompleted: {
read("initialized");
read("subscription");
read("payment");
read("aseman");
read("fullyUnlocked");
}

BootstrapRequest {
Expand All @@ -35,6 +38,7 @@ AsemanObject {
try { bstrap.subscription = response.result.subscription } catch (e) {}
try { bstrap.payment = response.result.payment } catch (e) {}
try { bstrap.aseman = response.result.aseman } catch (e) {}
try { bstrap.fullyUnlocked = response.result.fullyUnlocked } catch (e) {}
}
}

Expand Down
6 changes: 5 additions & 1 deletion qml/imports/requests/Subscription.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ pragma Singleton

import QtQuick 2.0
import AsemanQml.Base 2.0
import globals 1.0

AsemanObject {

onPremiumDaysChanged: AsemanGlobals.lastPremiumDays = premiumDays

readonly property int notesLimits: activeSubscription && Bootstrap.subscription? currentPackage.package.extra.notes_limits : -1
readonly property int listsLimits: activeSubscription && Bootstrap.subscription? currentPackage.package.extra.lists_limits : -1
readonly property int offlineLimits: activeSubscription && Bootstrap.subscription? currentPackage.package.extra.offline_limits : -1

readonly property int premium: premiumDays > 0
readonly property int premiumDays: {
if (!activeSubscription || !Bootstrap.subscription)
if (!activeSubscription || !Bootstrap.subscription || Bootstrap.fullyUnlocked)
return 1000;

try {
Expand Down Expand Up @@ -64,6 +67,7 @@ AsemanObject {
}

function init() {
AsemanGlobals.lastPremiumDays = premiumDays;
refresh()
}
}
2 changes: 1 addition & 1 deletion qml/imports/views/general/SettingsForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Item {
spacing: 4 * Devices.density

RowLayout {
visible: Bootstrap.initialized && AsemanGlobals.accessToken.length && activeSubscription && Bootstrap.subscription && Bootstrap.payment
visible: Bootstrap.initialized && AsemanGlobals.accessToken.length && activeSubscription && !Bootstrap.fullyUnlocked && Bootstrap.subscription && Bootstrap.payment
Layout.topMargin: 10 * Devices.density
Layout.bottomMargin: 30 * Devices.density

Expand Down

0 comments on commit 4d296ec

Please sign in to comment.