Skip to content

Commit

Permalink
Integrated feedback into the app
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLazarescu committed Mar 26, 2024
1 parent 0281f91 commit bc65990
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 51 deletions.
3 changes: 2 additions & 1 deletion app_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"website": "https://librumreader.com",
"newsWebsite": "https://librumreader.com/news",
"companyEmail": "[email protected]",
"githubLink": "https://github.com/Librum-Reader/Librum"
"githubLink": "https://github.com/Librum-Reader/Librum",
"feedbackLink": "https://forms.gle/bzmMgN4ucmtzAM1XA"
}
5 changes: 5 additions & 0 deletions src/adapters/controllers/app_info_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ QString AppInfoController::getGithubLink() const
return m_appInfoService->getInfo("githubLink");
}

QString AppInfoController::getFeedbackLink() const
{
return m_appInfoService->getInfo("feedbackLink");
}

QString AppInfoController::getCurrentQtVersion() const
{
return qVersion();
Expand Down
1 change: 1 addition & 0 deletions src/adapters/controllers/app_info_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ADAPTERS_EXPORT AppInfoController : public IAppInfoController
QString getNewsWebsite() const override;
QString getCompanyEmail() const override;
QString getGithubLink() const override;
QString getFeedbackLink() const override;
QString getCurrentQtVersion() const override;
QString getOperatingSystem() const override;
void updateApplication() override;
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/interfaces/controllers/i_app_info_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ADAPTERS_EXPORT IAppInfoController : public QObject
Q_PROPERTY(QString newsWebsite READ getNewsWebsite CONSTANT)
Q_PROPERTY(QString companyEmail READ getCompanyEmail CONSTANT)
Q_PROPERTY(QString githubLink READ getGithubLink CONSTANT)
Q_PROPERTY(QString feedbackLink READ getFeedbackLink CONSTANT)
Q_PROPERTY(QString currentQtVersion READ getCurrentQtVersion CONSTANT)
Q_PROPERTY(QString operatingSystem READ getOperatingSystem CONSTANT)
Q_PROPERTY(int systemFontSize READ getSystemFontSize CONSTANT)
Expand All @@ -48,6 +49,7 @@ class ADAPTERS_EXPORT IAppInfoController : public QObject
virtual QString getNewsWebsite() const = 0;
virtual QString getCompanyEmail() const = 0;
virtual QString getGithubLink() const = 0;
virtual QString getFeedbackLink() const = 0;
virtual QString getCurrentQtVersion() const = 0;
virtual QString getOperatingSystem() const = 0;
virtual double getSystemFontSize() const = 0;
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ int main(int argc, char* argv[])
qmlRegisterSingletonType(QUrl("qrc:/IconSheet.qml"), "Librum.icons", 1, 0, "Icons");
qmlRegisterSingletonType(QUrl("qrc:/FontSheet.qml"), "Librum.fonts", 1, 0, "Fonts");
qmlRegisterSingletonType(QUrl("qrc:/Globals.qml"), "Librum.globals", 1, 0, "Globals");
qmlRegisterSingletonType(QUrl("qrc:/GlobalSettings.qml"), "Librum.globalSettings", 1, 0, "GlobalSettings");
qmlRegisterSingletonType(QUrl("qrc:/TranslationsModel.qml"), "Librum.models", 1, 0, "TranslationsModel");
qmlRegisterSingletonType(QUrl("qrc:/modules/CustomComponents/MLanguageModel.qml"), "Librum.models", 1, 0, "MLanguageModel");
qmlRegisterType<adapters::data_models::LibraryProxyModel>("Librum.models", 1, 0, "LibraryProxyModel");
Expand Down
1 change: 1 addition & 0 deletions src/presentation/FontSheet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Item {
property real size16: systemSize + 7
property real size16dot5: systemSize + 7.5
property real size17: systemSize + 8
property real size18: systemSize + 9
property real size19: systemSize + 10
property real size20: systemSize + 11
property real size21: systemSize + 12
Expand Down
10 changes: 10 additions & 0 deletions src/presentation/GlobalSettings.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma Singleton

import QtCore

Settings {
location: "last_run_settings"

property string theme: "Dark"
property string lastFeedbackQuery: new Date().toString()
}
49 changes: 23 additions & 26 deletions src/presentation/PageNavigationLogic.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
function checkIfNewPageIsTheSameAsOld(sidebarItem)
{
return sidebar.currentItem === sidebarItem;
function checkIfNewPageIsTheSameAsOld(sidebarItem) {
return sidebar.currentItem === sidebarItem
}

function terminateActionOfCurrentPage(page, sidebarItem)
{
let currentPage = pageManager.currentItem;
if(currentPage instanceof MSettings)
{
if(!currentPage.saveSettingsPage(switchPage, page, sidebarItem))
return false;
function terminateActionOfCurrentPage(page, sidebarItem) {
let currentPage = pageManager.currentItem
if (currentPage instanceof MSettings) {
if (!currentPage.saveSettingsPage(switchPage, page, sidebarItem))
return false
}
return true;

return true
}

function switchPage(page, sidebarItem)
{
pageManager.replace(page);
function switchPage(page, sidebarItem) {
pageManager.prevPage = pageManager.currentItem
pageManager.replace(page)

// Set sidebar
pageManager.pageHasSidebar = sidebarItem !== undefined;
if(pageManager.pageHasSidebar)
sidebar.changeSelectedItem(sidebarItem);
pageManager.pageHasSidebar = sidebarItem !== undefined
if (pageManager.pageHasSidebar)
sidebar.changeSelectedItem(sidebarItem)

// The reading page can have a lower minimum width than the other pages
if(page === readingPage)
baseRoot.minimumWidth = baseRoot.readingPageMinWidth;
else if(sidebar.open)
baseRoot.minimumWidth = baseRoot.sidebarOpenedMinWidth;
if (page === readingPage)
baseRoot.minimumWidth = baseRoot.readingPageMinWidth
else if (sidebar.open)
baseRoot.minimumWidth = baseRoot.sidebarOpenedMinWidth
else
baseRoot.minimumWidth = baseRoot.defaultMinWidth;
}
baseRoot.minimumWidth = baseRoot.defaultMinWidth
}
14 changes: 3 additions & 11 deletions src/presentation/StyleSheet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QtQuick
import QtCore
import Librum.controllers
import Librum.icons
import Librum.globalSettings

Item {
id: styleSheet
Expand Down Expand Up @@ -99,7 +100,7 @@ Item {
property color colorFolderIconSelection

state: (SettingsController.appearanceSettings.Theme
=== undefined ? lastRunSettings.theme : SettingsController.appearanceSettings.Theme)
=== undefined ? GlobalSettings.theme : SettingsController.appearanceSettings.Theme)

states: [
State {
Expand Down Expand Up @@ -700,14 +701,5 @@ Item {

// Change icons
onStateChanged: Icons.setState(state)

// Settings which capture the application theme the last time the application ran.
// This way the correct theme is also chosen before the user is authenticated.
Settings {
id: lastRunSettings
location: "last_run_settings"

property string theme: "Dark"
}
Component.onDestruction: lastRunSettings.theme = styleSheet.state
Component.onDestruction: GlobalSettings.theme = styleSheet.state
}
53 changes: 52 additions & 1 deletion src/presentation/homePage/MHomePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import Librum.fonts
import Librum.controllers
import Librum.globals
import Librum.models
import Librum.globalSettings
import "toolbar"
import "manageTagsPopup"
import "folderSidebar"
import "../loginPage"

Page {
id: root
Expand All @@ -23,7 +25,25 @@ Page {
color: Style.colorPageBackground
}

Component.onCompleted: LibraryController.libraryModel.folder = "all"
Component.onCompleted: {
// We don't want to show the feedback popup when coming from the login page
// since that might be annoying to the user.
if (!(pageManager.prevPage instanceof MLoginPage)) {
feedbackTimer.start()
}

LibraryController.libraryModel.folder = "all"
}

// Add a slight delay to showing the feedback timer
Timer {
id: feedbackTimer
interval: 500
running: false
repeat: false

onTriggered: internal.showFeedbackPopupIfNeeded()
}

Shortcut {
sequence: SettingsController.shortcuts.AddBook
Expand Down Expand Up @@ -748,6 +768,15 @@ Page {
}
}

MFeedbackPopup {
id: feedbackPopup
x: Math.round(
root.width / 2 - implicitWidth / 2 - sidebar.width / 2 - root.horizontalPadding)
y: Math.round(
root.height / 2 - implicitHeight / 2 - root.topPadding - 50)
visible: false
}

FileDialog {
id: importFilesDialog
acceptLabel: qsTr("Import")
Expand Down Expand Up @@ -863,5 +892,27 @@ Page {

LibraryController.updateBook(uuid, operationsMap)
}

function showFeedbackPopupIfNeeded() {
var last = new Date(GlobalSettings.lastFeedbackQuery)
var now = new Date()

if (internal.addDays(last, 7) <= now) {
feedbackPopup.open()
feedbackPopup.giveFocus()
GlobalSettings.lastFeedbackQuery = now
}
}

function addDays(date, days) {
var result = new Date(date)
result.setDate(result.getDate() + days)
return result
}

function addSeconds(date, seconds) {
const milliseconds = seconds * 1000
return new Date(date.getTime() + milliseconds)
}
}
}
1 change: 1 addition & 0 deletions src/presentation/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ApplicationWindow {
StackView {
id: pageManager
property bool pageHasSidebar: false
property var prevPage: null

Layout.fillWidth: true
Layout.fillHeight: true
Expand Down
106 changes: 106 additions & 0 deletions src/presentation/modules/CustomComponents/MFeedbackPopup.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Librum.fonts
import Librum.style
import Librum.icons
import Librum.controllers
import CustomComponents
import Librum.globalSettings

Popup {
id: root
implicitWidth: 560
implicitHeight: layout.height + 32
horizontalPadding: 36
verticalPadding: 24
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
focus: true
background: Rectangle {
color: Style.colorPopupBackground
border.width: 1
border.color: Style.colorContainerBorder
radius: 6
antialiasing: true
}

ColumnLayout {
id: layout
width: parent.width
spacing: 0

LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

Label {
id: popupTitle
Layout.alignment: Qt.AlignLeft
Layout.topMargin: 12
Layout.fillWidth: true
text: qsTr("Got some feedback?")
elide: Text.ElideRight
font.weight: Font.Medium
font.pointSize: Fonts.size18
color: Style.colorTitle
}

Label {
id: infoText
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 16
font.pointSize: Fonts.size12dot25
Layout.fillWidth: true
wrapMode: Text.WordWrap
color: Style.colorText
text: qsTr("Your feedback is crucial for improving Librum. Would you mind sharing your experience by taking a quick survey?")
}

RowLayout {
Layout.fillWidth: true
Layout.topMargin: 36
Layout.bottomMargin: 18
height: cancelButton.height
spacing: 12

MButton {
id: cancelButton
Layout.fillWidth: true
Layout.preferredHeight: 40
borderWidth: 1
backgroundColor: "transparent"
fontSize: Fonts.size11
opacityOnPressed: 0.85
textColor: Style.colorText
text: qsTr("No, Thanks")

onClicked: root.close()
}

MButton {
id: acceptButton
Layout.fillWidth: true
Layout.preferredHeight: 40
borderWidth: 0
backgroundColor: Style.colorBasePurple
fontSize: Fonts.size11
opacityOnPressed: 0.85
textColor: Style.colorFocusedButtonText
text: qsTr("Let's do this!")

onClicked: {
Qt.openUrlExternally(AppInfoController.feedbackLink)

// Ask the user again in half a year after they've taken the survey
var date = new Date()
date.setDate((new Date()).getDate() + 183)
GlobalSettings.lastFeedbackQuery = date.toString()
root.close()
}
}
}
}

function giveFocus() {
root.forceActiveFocus()
}
}
3 changes: 2 additions & 1 deletion src/presentation/modules/CustomComponents/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ MSlider 1.0 MSlider.qml
MBookSelector 1.0 bookSelector/MBookSelector.qml
MAlertBox 1.0 MAlertBox.qml
MProgressArc 1.0 MProgressArc.qml
MSpinner 1.0 MSpinner.qml
MSpinner 1.0 MSpinner.qml
MFeedbackPopup 1.0 MFeedbackPopup.qml
2 changes: 2 additions & 0 deletions src/presentation/qmlSources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@
<file>toolsPage/MExtractPagesPopup.qml</file>
<file>toolsPage/MImageToPdfPopup.qml</file>
<file>toolsPage/MPdfToImagePopup.qml</file>
<file>GlobalSettings.qml</file>
<file>modules/CustomComponents/MFeedbackPopup.qml</file>
</qresource>
</RCC>
Loading

0 comments on commit bc65990

Please sign in to comment.