Skip to content

Commit

Permalink
Merge pull request #66 from direc85/master
Browse files Browse the repository at this point in the history
Settings.qml rewrite, lots of fixes
  • Loading branch information
condo4 authored Jul 26, 2021
2 parents 6895d65 + a43a936 commit 104030a
Show file tree
Hide file tree
Showing 23 changed files with 755 additions and 938 deletions.
11 changes: 8 additions & 3 deletions CarBudget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <sailfishapp.h>
#include <QSettings>
#include <QLocale>
#include "src/tank.h"
#include "src/cost.h"
#include "src/tire.h"
Expand Down Expand Up @@ -57,8 +58,10 @@ int main(int argc, char *argv[])
app->setApplicationName("harbour-carbudget");
QQuickView *view = SailfishApp::createView();

QLocale systemLocale;

QTranslator translator;
if(translator.load((QLocale::system().name() != "C")?(QLocale::system().name()):("en_GB"), "/usr/share/harbour-carbudget/translations/"))
if(translator.load((systemLocale.name() != "C")?(systemLocale.name()):("en_GB"), "/usr/share/harbour-carbudget/translations/"))
{
QGuiApplication::installTranslator(&translator);
}
Expand All @@ -78,18 +81,20 @@ int main(int argc, char *argv[])
qmlRegisterType<Car>( "harbour.carbudget",1,0,"Car");
qmlRegisterType<FileModel>( "harbour.carbudget",1,0,"FileModel");


CarManager manager;


view->engine()->addImportPath("/usr/share/harbour-carbudget/qmlModules");
view->rootContext()->setContextProperty("manager", &manager);
view->rootContext()->setContextProperty("downloadPath", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
view->rootContext()->setContextProperty("systemCurrencySymbol", systemLocale.currencySymbol());
view->rootContext()->setContextProperty("systemDistanceUnit", QString(systemLocale.measurementSystem() == 0 ? "km" : "mi"));
view->setSource(SailfishApp::pathTo("qml/Application.qml"));
view->showFullScreen();

int errorlevel = app->exec();
qDebug() << "CarBudget exited normally.";
delete view;
delete app;
return errorlevel;
}

6 changes: 5 additions & 1 deletion harbour-carbudget.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ QT += sql xml

DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"

CONFIG(release, debug|release) {
DEFINES += QT_NO_DEBUG
DEFINES += QT_NO_DEBUG_OUTPUT
}

HEADERS += \
src/tank.h \
src/car.h \
Expand Down Expand Up @@ -77,7 +82,6 @@ DISTFILES += \
qml/pages/StationEntry.qml \
qml/pages/SelectTankDate.qml \
qml/pages/Statistics.qml \
qml/pages/CarCreate.qml \
qml/pages/DirectoryPage.qml \
qml/pages/FueltypeEntry.qml \
qml/Application.qml \
Expand Down
2 changes: 1 addition & 1 deletion qml/cover/CoverPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CoverBackground {
iconSource: "image://theme/icon-cover-new"
onTriggered: {
app.activate()
pageStack.push(Qt.resolvedUrl("../pages/CarCreate.qml"))
pageStack.push(Qt.resolvedUrl("../pages/Settings.qml"), { newCarMode: true })
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/CarBudgetImport.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Page {
label: newName
placeholderText: label
text: label
validator: RegExpValidator { regExp: /^[0-9A-Za-z_-]{4,16}$/ }
validator: RegExpValidator { regExp: /^[0-9A-Za-z_\- ]{1,32}$/ }
EnterKey.enabled: text.length >= 4 && acceptableInput == true
onFocusChanged: if(focus) errorLabel.text = ""
}
Expand Down
122 changes: 0 additions & 122 deletions qml/pages/CarCreate.qml

This file was deleted.

2 changes: 1 addition & 1 deletion qml/pages/CarEntry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Page {

MenuItem {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml"))
onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml"), { newCarMode: false })
}

MenuItem {
Expand Down
4 changes: 2 additions & 2 deletions qml/pages/CarView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Page {
}
MenuItem {
text: qsTr("Create new car")
onClicked: pageStack.push(Qt.resolvedUrl("CarCreate.qml"))
onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml"), { newCarMode: true })
}
}
Label {
Expand Down Expand Up @@ -89,7 +89,7 @@ Page {
}
MenuItem {
text: qsTr("Create new car")
onClicked: pageStack.push(Qt.resolvedUrl("CarCreate.qml"))
onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml"), { newCarMode: true })
}
}

Expand Down
4 changes: 2 additions & 2 deletions qml/pages/CostEntry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Dialog {
label: manager.car.distanceUnit
placeholderText: label

validator: RegExpValidator { regExp: /^[0-9]{1,7}$/ }
validator: IntValidator { bottom: 0; top: 99999999 }
inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPrediction

EnterKey.enabled: text.length > 0 && acceptableInput == true
Expand Down Expand Up @@ -116,7 +116,7 @@ Dialog {
label: qsTr("Price")
placeholderText: label

validator: RegExpValidator { regExp: /^[0-9\.,]{1,7}$/ }
validator: DoubleValidator { bottom: 0; top: 99999999 }
inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPrediction
EnterKey.enabled: text.length > 0 && acceptableInput == true
EnterKey.onClicked: descinput.focus = true
Expand Down
Loading

0 comments on commit 104030a

Please sign in to comment.