Skip to content

Commit

Permalink
Help tips.
Browse files Browse the repository at this point in the history
Quite a few users have posted questions on our Discord channel or have
sent emails about things we already have a video explainer for. Going
forward, we will identify places in Scrite where users may need to know
about such videos the most and suggest them to watch it.
  • Loading branch information
pnudupa committed Jun 29, 2022
1 parent 6aa81f9 commit c009972
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 45 deletions.
57 changes: 57 additions & 0 deletions qml/HelpTipNotification.qml
@@ -0,0 +1,57 @@
/****************************************************************************
**
** Copyright (C) TERIFLIX Entertainment Spaces Pvt. Ltd. Bengaluru
** Author: Prashanth N Udupa (prashanth.udupa@teriflix.com)
**
** This code is distributed under GPL v3. Complete text of the license
** can be found here: https://www.gnu.org/licenses/gpl-3.0.txt
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

import QtQuick 2.15
import io.scrite.components 1.0

QtObject {
property string tipName
property var helpTip: Scrite.user.helpTips[tipName]
property bool tipShown: helpNotificationSettings.isTipShown(tipName)
property bool enabled: true

Notification.title: helpTip ? helpTip.title : ""
Notification.image: helpTip ? helpTip.image.url : ""
Notification.active: enabled && helpTip && !tipShown
Notification.text: helpTip ? helpTip.text : ""
Notification.autoClose: false
Notification.buttons: {
var ret = []
if(helpTip)
helpTip.buttons.forEach( (item) => {
ret.push(item.text)
})
return ret
}
Notification.onImageClicked: {
if(helpTip) {
if(helpTip.image.action !== "$dismiss")
Qt.openUrlExternally(helpTip.image.action)
markTipAsShown()
}
}

Notification.onButtonClicked: (buttonIndex) => {
if(helpTip) {
const button = helpTip.buttons[buttonIndex]
if(button.action !== "$dismiss")
Qt.openUrlExternally(button.action)
}

markTipAsShown()
}

function markTipAsShown() {
helpNotificationSettings.markTipAsShown(tipName)
}
}
4 changes: 4 additions & 0 deletions qml/NotebookView.qml
Expand Up @@ -3134,4 +3134,8 @@ Rectangle {
Component.onCompleted: Qt.callLater(generateStatsReport)
}
}

HelpTipNotification {
tipName: "notebook"
}
}
117 changes: 74 additions & 43 deletions qml/NotificationsView.qml
Expand Up @@ -12,6 +12,7 @@
****************************************************************************/

import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import io.scrite.components 1.0
Expand All @@ -32,51 +33,84 @@ Flickable {
model: Scrite.notifications.count

Rectangle {
required property int index
property Notification notification: Scrite.notifications.notificationAt(index)

width: notificationsView.width-1
height: Math.max(100, ntextLayout.implicitHeight+20)
height: Math.max(100, nLayout.implicitHeight+44)
color: notification.color
border { width: 1; color: primaryColors.borderColor }
property Notification notification: Scrite.notifications.notificationAt(index)

Column {
id: ntextLayout
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: notification.autoClose ? parent.right : dismissButton.left
anchors.margins: 20
spacing: 10

Text {
width: parent.width
text: notification.title
wrapMode: Text.WordWrap
font.pixelSize: 20
font.bold: true
visible: text !== ""
color: notification.textColor
}
RowLayout {
id: nLayout
width: parent.width-44
anchors.centerIn: parent
spacing: 30

Rectangle {
visible: notification.hasImage
Layout.preferredWidth: parent.width*0.25
Layout.preferredHeight: {
if(nimage.status === Image.Ready)
return nimage.sourceSize.height * (Layout.preferredWidth/nimage.sourceSize.width)
return Layout.preferredWidth*9/16
}
border.width: 1
border.color: primaryColors.borderColor

Image {
id: nimage
source: notification.image
fillMode: Image.PreserveAspectFit
anchors.fill: parent
anchors.margins: 1
mipmap: true

MouseArea {
anchors.fill: parent
onClicked: notification.notifyImageClick()
}
}

Text {
width: parent.width
text: notification.text
wrapMode: Text.WordWrap
font.pixelSize: 16
color: notification.textColor
BusyIndicator {
anchors.centerIn: parent
running: nimage.status !== Image.Ready
}
}

Row {
spacing: parent.spacing * 3
anchors.left: parent.left
anchors.leftMargin: 40
ColumnLayout {
Layout.fillWidth: true
spacing: 20

Repeater {
model: notification.buttons
Label {
Layout.fillWidth: true
text: notification.title
wrapMode: Text.WordWrap
font.pointSize: Scrite.app.idealFontPointSize + 4
font.bold: true
visible: text !== ""
color: notification.textColor
}

Label {
Layout.fillWidth: true
font.pointSize: Scrite.app.idealFontPointSize
text: notification.text
wrapMode: Text.WordWrap
color: notification.textColor
}

Item {
width: button.width
height: button.height * 2
RowLayout {
Layout.fillWidth: true
spacing: 20

Repeater {
model: notification.buttons

Button2 {
required property string modelData
required property int index

id: button
anchors.verticalCenter: parent.verticalCenter
width: Math.max(75, implicitWidth)
Expand All @@ -86,16 +120,13 @@ Flickable {
}
}
}
}

Button2 {
id: dismissButton
visible: notification.autoClose === false
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 20
text: "Dismiss"
onClicked: Scrite.notifications.dismissNotification(index)
Button2 {
id: dismissButton
visible: !notification.autoClose && !notification.hasButtons
text: "Dismiss"
onClicked: Scrite.notifications.dismissNotification(index)
}
}
}
}
Expand Down
62 changes: 61 additions & 1 deletion qml/ScriteDocumentView.qml
Expand Up @@ -162,6 +162,32 @@ Item {
property bool showAllFormQuestions: true
}

Settings {
id: helpNotificationSettings
fileName: Scrite.app.settingsFilePath
category: "Help"

property string dayZero
function daysSinceZero() {
const today = new Date()
const dzero = dayZero === "" ? today : new Date(dayZero + "Z")
const days = Math.floor((today.getTime() - dzero.getTime()) / (24*60*60*1000))
return days
}

property string tipsShown: ""
function isTipShown(val) {
const ts = tipsShown.split(",")
return ts.indexOf(val) >= 0
}
function markTipAsShown(val) {
var ts = tipsShown.length > 0 ? tipsShown.split(",") : []
if(ts.indexOf(val) < 0)
ts.push(val)
tipsShown = ts.join(",")
}
}

Shortcut {
context: Qt.ApplicationShortcut
sequence: "Ctrl+P"
Expand Down Expand Up @@ -1215,6 +1241,11 @@ Item {
ShortcutsModelItem.shortcut: "F10"
}
}

HelpTipNotification {
tipName: Scrite.app.isWindowsPlatform ? "language_windows" : (Scrite.app.isMacOSPlatform ? "language_macos" : "language_linux")
enabled: Scrite.app.transliterationEngine.language !== TransliterationEngine.English
}
}

ToolButton3 {
Expand Down Expand Up @@ -1931,6 +1962,10 @@ Item {
id: screenplayEditorComponent

ScreenplayEditor {
HelpTipNotification {
tipName: "screenplay"
}

// zoomLevelModifier: mainTabBar.currentIndex > 0 ? -3 : 0
Component.onCompleted: {
const evalZoomLevelModifierFn = () => {
Expand Down Expand Up @@ -2132,7 +2167,12 @@ Item {
anchors.bottom: parent.bottom
visible: !showNotebookInStructure || structureEditorTabs.currentTabIndex === 0
active: structureAppFeature.enabled
sourceComponent: StructureView { }
sourceComponent: StructureView {
HelpTipNotification {
tipName: "structure"
enabled: structureViewLoader.visible
}
}

DisabledFeatureNotice {
anchors.fill: parent
Expand Down Expand Up @@ -2766,4 +2806,24 @@ Item {
visible: refCount > 0
property int refCount: 0
}

HelpTipNotification {
id: htNotification
enabled: tipName !== ""

Component.onCompleted: {
Qt.callLater( () => {
if(helpNotificationSettings.dayZero === "")
helpNotificationSettings.dayZero = new Date()

const days = helpNotificationSettings.daysSinceZero()
if(days >= 2) {
if(!helpNotificationSettings.isTipShown("discord"))
htNotification.tipName = "discord"
else if(!helpNotificationSettings.isTipShown("subscription") && days >= 5)
htNotification.tipName = "subscription"
}
})
}
}
}
8 changes: 8 additions & 0 deletions qml/StructureGroupsMenu.qml
Expand Up @@ -21,13 +21,21 @@ Menu2 {

property SceneGroup sceneGroup: null
signal toggled(int row, string name)
closePolicy: htn.Notification.active ? Popup.NoAutoClose : Popup.CloseOnEscape|Popup.CloseOnPressOutside
enabled: false

title: "Tag Groups"
property string innerTitle: ""

width: 450
height: 500

HelpTipNotification {
id: htn
tipName: "story_beat_tagging"
enabled: structureGroupsMenu.opened
}

MenuItem2 {
width: structureGroupsMenu.width
height: structureGroupsMenu.height
Expand Down
2 changes: 1 addition & 1 deletion qml/UserLogin.qml
Expand Up @@ -541,7 +541,7 @@ Item {
TabSequenceItem.sequence: 1
maximumLength: 128
onTextEdited: allowHighlightSaveAnimation = true
completionStrings: ["Novice", "Learning", "Written Few, None Made", "Hobby Writer", "Working Writer", "Actively Pursuing a Writing Career", "Have Produced Credits", "Experienced"]
completionStrings: ["Hobby Writer", "Actively Pursuing a Writing Career", "Working Writer", "Have Produced Credits"]
minimumCompletionPrefixLength: 0
maxCompletionItems: -1
maxVisibleItems: 6
Expand Down
1 change: 1 addition & 0 deletions scrite_ui.qrc
Expand Up @@ -88,5 +88,6 @@
<file>qml/DocumentVault.qml</file>
<file>qml/SceneFeaturedImage.qml</file>
<file>qml/RichTextEdit.qml</file>
<file>qml/HelpTipNotification.qml</file>
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions src/core/application.h
Expand Up @@ -54,6 +54,8 @@ class Application : public QtApplicationClass

QString installationId() const;
QDateTime installationTimestamp() const;

Q_PROPERTY(int launchCounter READ launchCounter CONSTANT)
int launchCounter() const;

Q_PROPERTY(QString buildTimestamp READ buildTimestamp CONSTANT)
Expand Down
1 change: 1 addition & 0 deletions src/network/jsonhttprequest.cpp
Expand Up @@ -358,6 +358,7 @@ bool JsonHttpRequest::call()
+ JsonHttpRequest::platformType() + space + JsonHttpRequest::clientId();
return ret;
}();

if (!userAgentString.isEmpty())
req.setHeader(QNetworkRequest::UserAgentHeader, userAgentString);

Expand Down

0 comments on commit c009972

Please sign in to comment.