WizardModeSelection: optional 'Portable mode' feature support

This commit is contained in:
xiphon 2020-07-28 17:46:52 +00:00
parent c137a6ea36
commit 4208b66baf
7 changed files with 76 additions and 13 deletions

View File

@ -109,6 +109,7 @@ Item {
color: MoneroComponents.Style.defaultFontColor color: MoneroComponents.Style.defaultFontColor
textFormat: Text.RichText textFormat: Text.RichText
wrapMode: Text.NoWrap wrapMode: Text.NoWrap
visible: text != ""
} }
} }

View File

@ -78,6 +78,8 @@
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include <QOpenGLContext> #include <QOpenGLContext>
#elif defined(Q_OS_MACOS)
#include "qt/macoshelper.h"
#endif #endif
#ifdef WITH_SCANNER #ifdef WITH_SCANNER
@ -323,6 +325,10 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
// start listening // start listening
QTimer::singleShot(0, ipc, SLOT(bind())); QTimer::singleShot(0, ipc, SLOT(bind()));
#if defined(Q_OS_MACOS)
QDir::setCurrent(QDir(MacOSHelper::bundlePath() + QDir::separator() + "..").canonicalPath());
#endif
// screen settings // screen settings
// Mobile is designed on 128dpi // Mobile is designed on 128dpi
qreal ref_dpi = 128; qreal ref_dpi = 128;

View File

@ -36,6 +36,7 @@ class MacOSHelper
public: public:
static bool isCapsLock(); static bool isCapsLock();
static bool openFolderAndSelectItem(const QUrl &path); static bool openFolderAndSelectItem(const QUrl &path);
static QString bundlePath();
}; };
#endif //MACOSHELPER_H #endif //MACOSHELPER_H

View File

@ -55,3 +55,18 @@ bool MacOSHelper::openFolderAndSelectItem(const QUrl &path)
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs]; [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];
return true; return true;
} }
QString MacOSHelper::bundlePath()
{
NSBundle *main = [NSBundle mainBundle];
if (!main)
{
return {};
}
NSString *bundlePathString = [main bundlePath];
if (!bundlePathString)
{
return {};
}
return QString::fromCFString(reinterpret_cast<const CFStringRef>(bundlePathString));
}

View File

@ -245,4 +245,8 @@ Rectangle {
Timer { Timer {
id: versionTimer id: versionTimer
} }
function onPageCompleted() {
persistentSettings.setWritable(false);
}
} }

View File

@ -39,6 +39,8 @@ RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.bottomMargin: 10 Layout.bottomMargin: 10
property alias imageIcon: icon.source property alias imageIcon: icon.source
property bool checkbox: false
property alias checked: checkboxItem.checked
property alias headerText: header.text property alias headerText: header.text
property alias bodyText: body.text property alias bodyText: body.text
signal menuClicked(); signal menuClicked();
@ -48,16 +50,24 @@ RowLayout {
Layout.preferredWidth: 70 Layout.preferredWidth: 70
Layout.preferredHeight: 70 Layout.preferredHeight: 70
MoneroComponents.CheckBox {
id: checkboxItem
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
toggleOnClick: false
visible: rowlayout.checkbox
}
Image { Image {
id: icon id: icon
visible: !isOpenGL || MoneroComponents.Style.blackTheme visible: !rowlayout.checkbox && (!isOpenGL || MoneroComponents.Style.blackTheme)
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
source: "" source: ""
} }
DropShadow { DropShadow {
visible: isOpenGL && !MoneroComponents.Style.blackTheme visible: !rowlayout.checkbox && (isOpenGL && !MoneroComponents.Style.blackTheme)
anchors.fill: icon anchors.fill: icon
horizontalOffset: 3 horizontalOffset: 3
verticalOffset: 3 verticalOffset: 3

View File

@ -40,6 +40,18 @@ Rectangle {
property alias pageHeight: pageRoot.height property alias pageHeight: pageRoot.height
property string viewName: "wizardModeSelection1" property string viewName: "wizardModeSelection1"
property bool portable: persistentSettings.portable
function applyWalletMode(mode, wizardState) {
if (!persistentSettings.setPortable(portable)) {
appWindow.showStatusMessage(qsTr("Failed to configure portable mode"), 3);
return;
}
appWindow.changeWalletMode(mode);
wizardController.wizardStackView.backTransition = false;
wizardController.wizardState = wizardState;
}
ColumnLayout { ColumnLayout {
id: pageRoot id: pageRoot
@ -78,9 +90,7 @@ Rectangle {
onMenuClicked: { onMenuClicked: {
if(appWindow.persistentSettings.nettype == 0){ if(appWindow.persistentSettings.nettype == 0){
appWindow.changeWalletMode(0); applyWalletMode(0, 'wizardModeRemoteNodeWarning');
wizardController.wizardStackView.backTransition = false;
wizardController.wizardState = 'wizardModeRemoteNodeWarning';
} }
} }
} }
@ -108,9 +118,7 @@ Rectangle {
onMenuClicked: { onMenuClicked: {
if(appWindow.persistentSettings.nettype == 0){ if(appWindow.persistentSettings.nettype == 0){
appWindow.changeWalletMode(1); applyWalletMode(1, 'wizardModeBootstrap');
wizardController.wizardStackView.backTransition = false;
wizardController.wizardState = 'wizardModeBootstrap';
} }
} }
} }
@ -130,12 +138,26 @@ Rectangle {
imageIcon: "qrc:///images/local-node-full.png" imageIcon: "qrc:///images/local-node-full.png"
onMenuClicked: { onMenuClicked: {
wizardController.wizardStackView.backTransition = false; applyWalletMode(2, 'wizardHome');
appWindow.changeWalletMode(2);
wizardController.wizardState = 'wizardHome';
} }
} }
WizardHeader {
Layout.topMargin: 20
title: qsTr("Optional features") + translationManager.emptyString
subtitle: qsTr("Select enhanced functionality you would like to enable.") + translationManager.emptyString
}
WizardMenuItem {
Layout.topMargin: 20
headerText: qsTr("Portable mode") + translationManager.emptyString
bodyText: qsTr("Create portable wallets and use them on any PC. Enable if you installed Monero on a USB stick, an external drive, or any other portable storage medium.") + translationManager.emptyString
checkbox: true
checked: wizardModeSelection1.portable
onMenuClicked: wizardModeSelection1.portable = !wizardModeSelection1.portable
}
WizardNav { WizardNav {
Layout.topMargin: 5 Layout.topMargin: 5
btnPrevText: qsTr("Back to menu") + translationManager.emptyString btnPrevText: qsTr("Back to menu") + translationManager.emptyString
@ -144,8 +166,12 @@ Rectangle {
autoTransition: false autoTransition: false
onPrevClicked: { onPrevClicked: {
wizardController.wizardStackView.backTransition = !wizardController.wizardStackView.backTransition; if (wizardController.wizardStackView.backTransition) {
wizardController.wizardState = wizardController.wizardStackView.backTransition ? 'wizardLanguage' : 'wizardHome'; applyWalletMode(persistentSettings.walletMode, 'wizardHome');
} else {
wizardController.wizardStackView.backTransition = true;
wizardController.wizardState = 'wizardLanguage';
}
} }
} }
} }