Language settings
This commit is contained in:
parent
28f0b40da8
commit
b35fbd53b9
9 changed files with 139 additions and 56 deletions
|
|
@ -100,8 +100,8 @@ Item {
|
|||
id: titleBar
|
||||
height: icon.height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: icon.right; anchors.right: closeButton.right
|
||||
anchors.leftMargin: Theme.paddingMedium
|
||||
anchors.left: icon.right; anchors.right: closeButton.left
|
||||
anchors.leftMargin: Theme.paddingMedium; anchors.rightMargin: Theme.paddingMedium
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: Theme.fontFamily
|
||||
text: root.text
|
||||
|
|
@ -109,20 +109,6 @@ Item {
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
/*Image {
|
||||
id: closeButton
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
source: "icon-m-close.png"
|
||||
source: "image://icon-m-common-dialog-close"
|
||||
visible: root.cancelable
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.closeClicked()
|
||||
}
|
||||
}*/
|
||||
|
||||
ToolIcon {
|
||||
id: closeButton
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
|
|||
|
|
@ -139,6 +139,50 @@ Page {
|
|||
text: qsTr("UI")
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
label: qsTr("Language")
|
||||
currentIndex: {
|
||||
if (settings.locale === "")
|
||||
return 0;
|
||||
if (settings.locale === "en")
|
||||
return 1;
|
||||
if (settings.locale === "fa")
|
||||
return 2;
|
||||
if (settings.locale === "pl")
|
||||
return 3;
|
||||
}
|
||||
|
||||
menu: ListModel {
|
||||
Component.onCompleted: {
|
||||
append({text: qsTr("Default")});
|
||||
append({text: "English"});
|
||||
append({text: "فارسی"});
|
||||
append({text: "Polski"});
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
switch (currentIndex) {
|
||||
case 0:
|
||||
settings.locale = "";
|
||||
break;
|
||||
case 1:
|
||||
settings.locale = "en";
|
||||
break;
|
||||
case 2:
|
||||
settings.locale = "fa";
|
||||
break;
|
||||
case 3:
|
||||
settings.locale = "pl";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
notification.show(qsTr("Changes will take effect after you restart Kaktus."));
|
||||
}
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
label: qsTr("View mode")
|
||||
currentIndex: {
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ Item {
|
|||
id: titleBar
|
||||
height: icon.height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: icon.right; anchors.right: closeButton.right
|
||||
anchors.leftMargin: Theme.paddingMedium
|
||||
anchors.left: icon.right; anchors.right: closeButton.left
|
||||
anchors.leftMargin: Theme.paddingMedium; anchors.rightMargin: Theme.paddingMedium
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: Theme.fontFamily
|
||||
text: root.text
|
||||
|
|
|
|||
|
|
@ -207,6 +207,50 @@ Page {
|
|||
text: qsTr("UI")
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: locale
|
||||
width: root.width
|
||||
label: qsTr("Language")
|
||||
currentIndex: {
|
||||
if (settings.locale === "")
|
||||
return 0;
|
||||
if (settings.locale === "en")
|
||||
return 1;
|
||||
if (settings.locale === "fa")
|
||||
return 2;
|
||||
if (settings.locale === "pl")
|
||||
return 3;
|
||||
}
|
||||
|
||||
menu: ContextMenu {
|
||||
MenuItem { text: qsTr("Default"); onClicked: locale.showMessage() }
|
||||
MenuItem { text: "English"; onClicked: locale.showMessage() }
|
||||
MenuItem { text: "فارسی"; onClicked: locale.showMessage() }
|
||||
MenuItem { text: "Polski"; onClicked: locale.showMessage() }
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
switch (currentIndex) {
|
||||
case 0:
|
||||
settings.locale = "";
|
||||
break;
|
||||
case 1:
|
||||
settings.locale = "en";
|
||||
break;
|
||||
case 2:
|
||||
settings.locale = "fa";
|
||||
break;
|
||||
case 3:
|
||||
settings.locale = "pl";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage() {
|
||||
notification.show(qsTr("Changes will take effect after you restart Kaktus."));
|
||||
}
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
width: root.width
|
||||
label: qsTr("View mode")
|
||||
|
|
@ -281,16 +325,6 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
/*TextSwitch {
|
||||
text: qsTr("Auto mark as read")
|
||||
description: qsTr("All opened articles will be marked as read.")
|
||||
checked: settings.getAutoMarkAsRead();
|
||||
|
||||
onCheckedChanged: {
|
||||
settings.setAutoMarkAsRead(checked);
|
||||
}
|
||||
}*/
|
||||
|
||||
ComboBox {
|
||||
width: root.width
|
||||
label: qsTr("Orientation")
|
||||
|
|
|
|||
|
|
@ -412,8 +412,6 @@ bool DatabaseManager::createStreamsStructure()
|
|||
|
||||
bool DatabaseManager::createModulesStructure()
|
||||
{
|
||||
qDebug() << "createModulesTable";
|
||||
|
||||
bool ret = true;
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
|
@ -2966,8 +2964,10 @@ void DatabaseManager::checkError(const QSqlError &error)
|
|||
// The database disk image is malformed
|
||||
if (error.number() == 11) {
|
||||
Settings *s = Settings::instance();
|
||||
s->setReinitDB(true);
|
||||
emit this->error(511);
|
||||
if (!s->getReinitDB()) {
|
||||
s->setReinitDB(true);
|
||||
emit this->error(511);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -270,7 +270,6 @@ void DownloadManager::downloadFinished(QNetworkReply *reply)
|
|||
item.finalUrl = url.resolved(reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl()).toString();
|
||||
//qDebug() << "RedirectionTarget: " << url.toString() << "entryId" << item.entryId;
|
||||
downloads.removeOne(reply);
|
||||
//replyToCachedItemMap.remove(reply);
|
||||
addDownload(item);
|
||||
reply->deleteLater();
|
||||
return;
|
||||
|
|
@ -446,7 +445,7 @@ Checker::~Checker()
|
|||
|
||||
void Checker::timeout()
|
||||
{
|
||||
qDebug() << "timeout";
|
||||
//qDebug() << "timeout";
|
||||
reply->close();
|
||||
}
|
||||
|
||||
|
|
|
|||
18
src/main.cpp
18
src/main.cpp
|
|
@ -30,6 +30,7 @@
|
|||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <sailfishapp.h>
|
||||
#include "iconprovider.h"
|
||||
#endif
|
||||
|
||||
#include <QtDebug>
|
||||
|
|
@ -41,12 +42,11 @@
|
|||
#include "netvibesfetcher.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
static const char *APP_NAME = "Kaktus";
|
||||
static const char *AUTHOR = "Michal Kosciesza <michal@mkiol.net>";
|
||||
static const char *PAGE = "https://github/mkiol/kaktus";
|
||||
static const char *VERSION = "1.2.0";
|
||||
static const char *VERSION = "1.2.1";
|
||||
|
||||
Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||
NetvibesFetcher fetcher; settings->fetcher = &fetcher;
|
||||
Utils utils;
|
||||
|
||||
QObject::connect(&fetcher, SIGNAL(ready()), &utils, SLOT(updateModels()));
|
||||
//QObject::connect(&fetcher, SIGNAL(ready()), &utils, SLOT(updateModels()));
|
||||
QObject::connect(view.engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
|
||||
|
||||
view.rootContext()->setContextProperty("db", &db);
|
||||
|
|
@ -114,16 +114,18 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||
|
||||
qRegisterMetaType<DatabaseManager::CacheItem>("CacheItem");
|
||||
|
||||
Settings* settings = Settings::instance();
|
||||
|
||||
QTranslator *appTranslator = new QTranslator;
|
||||
appTranslator->load(":/i18n/kaktus_" + QLocale::system().name() + ".qm");
|
||||
if (settings->getLocale() == "")
|
||||
appTranslator->load(":/i18n/kaktus_" + QLocale::system().name() + ".qm");
|
||||
else
|
||||
appTranslator->load(":/i18n/kaktus_" + settings->getLocale() + ".qm");
|
||||
app->installTranslator(appTranslator);
|
||||
|
||||
Settings* settings = Settings::instance();
|
||||
settings->view = view.data();
|
||||
DatabaseManager db; settings->db = &db;
|
||||
DownloadManager dm;
|
||||
settings->dm = &dm;
|
||||
|
||||
DownloadManager dm; settings->dm = &dm;
|
||||
CacheServer cache(&db); settings->cache = &cache;
|
||||
NetvibesFetcher fetcher; settings->fetcher = &fetcher;
|
||||
Utils utils;
|
||||
|
|
|
|||
|
|
@ -106,17 +106,6 @@ bool Settings::getOfflineMode()
|
|||
return settings.value("offlinemode", false).toBool();
|
||||
}
|
||||
|
||||
void Settings::setAutoMarkAsRead(bool value)
|
||||
{
|
||||
settings.setValue("automarkasread", value);
|
||||
}
|
||||
|
||||
bool Settings::getAutoMarkAsRead()
|
||||
{
|
||||
return settings.value("automarkasread", true).toBool();
|
||||
}
|
||||
|
||||
|
||||
void Settings::setShowTabIcons(bool value)
|
||||
{
|
||||
if (getShowTabIcons() != value) {
|
||||
|
|
@ -214,6 +203,19 @@ QString Settings::getDashboardInUse()
|
|||
return settings.value("dafaultdashboard", "").toString();
|
||||
}
|
||||
|
||||
void Settings::setLocale(const QString &value)
|
||||
{
|
||||
if (getLocale() != value) {
|
||||
settings.setValue("locale", value);
|
||||
emit localeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString Settings::getLocale()
|
||||
{
|
||||
return settings.value("locale", "").toString();
|
||||
}
|
||||
|
||||
void Settings::setLastUpdateDate(int value)
|
||||
{
|
||||
if (getLastUpdateDate() != value) {
|
||||
|
|
@ -395,6 +397,16 @@ int Settings::getViewMode()
|
|||
return settings.value("viewmode", 0).toInt();
|
||||
}
|
||||
|
||||
void Settings::setReinitDB(bool value)
|
||||
{
|
||||
settings.setValue("reinitdb", value);
|
||||
}
|
||||
|
||||
bool Settings::getReinitDB()
|
||||
{
|
||||
return settings.value("reinitdb", false).toBool();
|
||||
}
|
||||
|
||||
void Settings::reset()
|
||||
{
|
||||
setNetvibesPassword("");
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ class Settings: public QObject
|
|||
Q_PROPERTY (int offsetLimit READ getOffsetLimit WRITE setOffsetLimit NOTIFY offsetLimitChanged)
|
||||
Q_PROPERTY (int viewMode READ getViewMode WRITE setViewMode NOTIFY viewModeChanged)
|
||||
Q_PROPERTY (bool helpDone READ getHelpDone WRITE setHelpDone NOTIFY helpDoneChanged)
|
||||
Q_PROPERTY (bool reinitDB READ getReinitDB WRITE setReinitDB)
|
||||
Q_PROPERTY (QString locale READ getLocale WRITE setLocale NOTIFY localeChanged)
|
||||
|
||||
public:
|
||||
static Settings* instance();
|
||||
|
|
@ -88,6 +90,9 @@ public:
|
|||
void setDashboardInUse(const QString &value);
|
||||
QString getDashboardInUse();
|
||||
|
||||
void setLocale(const QString &value);
|
||||
QString getLocale();
|
||||
|
||||
void setLastUpdateDate(int value);
|
||||
int getLastUpdateDate();
|
||||
|
||||
|
|
@ -99,6 +104,9 @@ public:
|
|||
|
||||
void setViewMode(int value);
|
||||
int getViewMode();
|
||||
|
||||
void setReinitDB(bool value);
|
||||
bool getReinitDB();
|
||||
// ---
|
||||
|
||||
bool getShowOnlyUnread();
|
||||
|
|
@ -113,9 +121,6 @@ public:
|
|||
Q_INVOKABLE void setAutoDownloadOnUpdate(bool value);
|
||||
Q_INVOKABLE bool getAutoDownloadOnUpdate();
|
||||
|
||||
Q_INVOKABLE bool getAutoMarkAsRead();
|
||||
Q_INVOKABLE void setAutoMarkAsRead(bool value);
|
||||
|
||||
Q_INVOKABLE void setNetvibesUsername(const QString &value);
|
||||
Q_INVOKABLE QString getNetvibesUsername();
|
||||
|
||||
|
|
@ -156,6 +161,7 @@ signals:
|
|||
void offsetLimitChanged();
|
||||
void viewModeChanged();
|
||||
void helpDoneChanged();
|
||||
void localeChanged();
|
||||
|
||||
/*
|
||||
501 - Unable create settings dir
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue