Fix bugs, add displayed version info
This commit is contained in:
parent
ff44110b77
commit
82910c480a
@ -3,17 +3,44 @@
|
|||||||
#include "network-downloader.h"
|
#include "network-downloader.h"
|
||||||
#include "prog-constains.h"
|
#include "prog-constains.h"
|
||||||
|
|
||||||
void addI2PDconfig (QString i2pdConf, QString tunnelsConf) {
|
void addI2PDconfig(QString i2pdConf, QString tunnelsConf)
|
||||||
#if defined(Q_OS_WIN)
|
{
|
||||||
#elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
auto writeIfMissing = [](const QString &path, const QString &content)
|
||||||
#else
|
{
|
||||||
#endif
|
QFileInfo info(path);
|
||||||
|
|
||||||
|
// create directory if missing
|
||||||
|
QDir dir = info.dir();
|
||||||
|
if (!dir.exists())
|
||||||
|
dir.mkpath(".");
|
||||||
|
|
||||||
|
// create file only if it doesn't exist
|
||||||
|
if (!QFile::exists(path))
|
||||||
|
{
|
||||||
|
QFile file(path);
|
||||||
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
QTextStream out(&file);
|
||||||
|
out << content;
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "Failed to create config:" << path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
writeIfMissing(i2pdConf, DEFAULT_I2PD_CONF);
|
||||||
|
writeIfMissing(tunnelsConf, DEFAULT_TUNNELS_CONF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void configCheckAndMake () {
|
void configCheckAndMake () {
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
||||||
QString configsFolder = QDir(I2P_INSTALL_PATH).filePath("configs");
|
QString configsFolder = QDir(I2P_INSTALL_PATH).filePath("configs");
|
||||||
|
|
||||||
QString i2pdConf = QDir(configsFolder).filePath("i2pd.confconf");
|
QString i2pdConf = QDir(configsFolder).filePath("i2pd.conf");
|
||||||
QString tunnelsConf = QDir(configsFolder).filePath("tunnels.conf");
|
QString tunnelsConf = QDir(configsFolder).filePath("tunnels.conf");
|
||||||
if (
|
if (
|
||||||
!QFile(i2pdConf).exists() ||
|
!QFile(i2pdConf).exists() ||
|
||||||
@ -23,6 +50,8 @@ void configCheckAndMake () {
|
|||||||
emptyFolder(configsFolder);
|
emptyFolder(configsFolder);
|
||||||
addI2PDconfig(i2pdConf, tunnelsConf);
|
addI2PDconfig(i2pdConf, tunnelsConf);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkI2P () {
|
bool checkI2P () {
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
bool installI2P(std::function<void(QString, unsigned int, unsigned int)> logCallback);
|
bool installI2P(std::function<void(QString, unsigned int, unsigned int)> logCallback);
|
||||||
bool checkI2P ();
|
bool checkI2P ();
|
||||||
|
|||||||
@ -25,6 +25,7 @@ LocaleMap ru_RU = {
|
|||||||
{"welcome.showPassword", "Показать пароль"},
|
{"welcome.showPassword", "Показать пароль"},
|
||||||
{"welcome.logIn", "Войти"},
|
{"welcome.logIn", "Войти"},
|
||||||
{"welcome.register", "Зарегистрироваться"},
|
{"welcome.register", "Зарегистрироваться"},
|
||||||
|
{"welcome.version", "Версия"},
|
||||||
// I2PD
|
// I2PD
|
||||||
{"i2pd.errorTitle", "Ошибка I2P"},
|
{"i2pd.errorTitle", "Ошибка I2P"},
|
||||||
{"i2pd.errorDescription.p1", "I2P Завершилась с фатальной ошибкой:\n\n"},
|
{"i2pd.errorDescription.p1", "I2P Завершилась с фатальной ошибкой:\n\n"},
|
||||||
@ -54,6 +55,7 @@ LocaleMap en_US = {
|
|||||||
{"welcome.showPassword", "Show the password"},
|
{"welcome.showPassword", "Show the password"},
|
||||||
{"welcome.logIn", "LogIn"},
|
{"welcome.logIn", "LogIn"},
|
||||||
{"welcome.register", "Registration"},
|
{"welcome.register", "Registration"},
|
||||||
|
{"welcome.version", "Version"},
|
||||||
// I2PD
|
// I2PD
|
||||||
{"i2pd.errorTitle", "I2P Error"},
|
{"i2pd.errorTitle", "I2P Error"},
|
||||||
{"i2pd.errorDescription.p1", "A fatal error occurred while running i2pd:\n\n"},
|
{"i2pd.errorDescription.p1", "A fatal error occurred while running i2pd:\n\n"},
|
||||||
|
|||||||
5
main.cpp
5
main.cpp
@ -1,15 +1,18 @@
|
|||||||
#include "loading.h"
|
#include "loading.h"
|
||||||
#include "locales.h"
|
#include "locales.h"
|
||||||
|
#include "prog-constains.h"
|
||||||
//#include "welcome.h"
|
//#include "welcome.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
//qDebug() << QT_VERSION_STR;
|
||||||
|
//return 0;
|
||||||
|
//debugVariables();
|
||||||
initLocales();
|
initLocales();
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
Loading w;
|
Loading w;
|
||||||
//w.setWindowFlags(Qt::FramelessWindowHint);
|
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
#include "welcome.h"
|
#include "welcome.h"
|
||||||
#include "./ui_welcome.h"
|
#include "./ui_welcome.h"
|
||||||
#include "locales.h"
|
#include "locales.h"
|
||||||
|
#include "prog-constains.h"
|
||||||
|
|
||||||
Welcome::Welcome(QWidget *parent)
|
Welcome::Welcome(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::Welcome)
|
, ui(new Ui::Welcome)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->statusbar->addPermanentWidget(ui->progVersion, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Welcome::~Welcome()
|
Welcome::~Welcome()
|
||||||
@ -29,5 +31,7 @@ void Welcome::setupWelcomeLocale(QString locale) {
|
|||||||
this->ui->loginBtn->setText(QString::fromStdString(localeMap->at("welcome.logIn")));
|
this->ui->loginBtn->setText(QString::fromStdString(localeMap->at("welcome.logIn")));
|
||||||
this->ui->registerBtn->setText(QString::fromStdString(localeMap->at("welcome.register")));
|
this->ui->registerBtn->setText(QString::fromStdString(localeMap->at("welcome.register")));
|
||||||
|
|
||||||
|
this->ui->progVersion->setText(QString::fromStdString(localeMap->at("welcome.version")) + ": " + VERSION);
|
||||||
|
|
||||||
this->ui->tabWidget->setCurrentIndex(0);
|
this->ui->tabWidget->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|||||||
21
welcome.ui
21
welcome.ui
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>803</width>
|
||||||
<height>600</height>
|
<height>596</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -68,7 +68,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="password">
|
<widget class="QLineEdit" name="password">
|
||||||
<property name="echoMode">
|
<property name="echoMode">
|
||||||
<enum>QLineEdit::Password</enum>
|
<enum>QLineEdit::EchoMode::Password</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -103,13 +103,26 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QLabel" name="progVersion">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>550</y>
|
||||||
|
<width>171</width>
|
||||||
|
<height>18</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>welcome.version</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>803</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user