diff --git a/install-i2p.cpp b/install-i2p.cpp index a7eb6c5..2f56e66 100644 --- a/install-i2p.cpp +++ b/install-i2p.cpp @@ -3,26 +3,55 @@ #include "network-downloader.h" #include "prog-constains.h" -void addI2PDconfig (QString i2pdConf, QString tunnelsConf) { - #if defined(Q_OS_WIN) - #elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS) - #else - #endif +void addI2PDconfig(QString i2pdConf, QString tunnelsConf) +{ + auto writeIfMissing = [](const QString &path, const QString &content) + { + 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 () { + #if defined(Q_OS_WIN) + #elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS) 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"); if ( !QFile(i2pdConf).exists() || !QFile(tunnelsConf).exists() - ) { + ) { qDebug() << "Configs not found. Creating new"; emptyFolder(configsFolder); addI2PDconfig(i2pdConf, tunnelsConf); } + #else + #endif } bool checkI2P () { diff --git a/install-i2p.h b/install-i2p.h index ca3325a..927a8a3 100644 --- a/install-i2p.h +++ b/install-i2p.h @@ -15,6 +15,7 @@ #include #include #include +#include bool installI2P(std::function logCallback); bool checkI2P (); diff --git a/locales.cpp b/locales.cpp index 769e6b2..9faa814 100644 --- a/locales.cpp +++ b/locales.cpp @@ -25,6 +25,7 @@ LocaleMap ru_RU = { {"welcome.showPassword", "Показать пароль"}, {"welcome.logIn", "Войти"}, {"welcome.register", "Зарегистрироваться"}, + {"welcome.version", "Версия"}, // I2PD {"i2pd.errorTitle", "Ошибка I2P"}, {"i2pd.errorDescription.p1", "I2P Завершилась с фатальной ошибкой:\n\n"}, @@ -54,6 +55,7 @@ LocaleMap en_US = { {"welcome.showPassword", "Show the password"}, {"welcome.logIn", "LogIn"}, {"welcome.register", "Registration"}, + {"welcome.version", "Version"}, // I2PD {"i2pd.errorTitle", "I2P Error"}, {"i2pd.errorDescription.p1", "A fatal error occurred while running i2pd:\n\n"}, diff --git a/main.cpp b/main.cpp index 9ad6251..1163faa 100644 --- a/main.cpp +++ b/main.cpp @@ -1,15 +1,18 @@ #include "loading.h" #include "locales.h" +#include "prog-constains.h" //#include "welcome.h" #include int main(int argc, char *argv[]) { + //qDebug() << QT_VERSION_STR; + //return 0; + //debugVariables(); initLocales(); QApplication a(argc, argv); Loading w; - //w.setWindowFlags(Qt::FramelessWindowHint); w.show(); return a.exec(); } diff --git a/welcome.cpp b/welcome.cpp index 6a42f4f..c98fc07 100644 --- a/welcome.cpp +++ b/welcome.cpp @@ -1,12 +1,14 @@ #include "welcome.h" #include "./ui_welcome.h" #include "locales.h" +#include "prog-constains.h" Welcome::Welcome(QWidget *parent) : QMainWindow(parent) , ui(new Ui::Welcome) { ui->setupUi(this); + ui->statusbar->addPermanentWidget(ui->progVersion, 1); } Welcome::~Welcome() @@ -29,5 +31,7 @@ void Welcome::setupWelcomeLocale(QString locale) { this->ui->loginBtn->setText(QString::fromStdString(localeMap->at("welcome.logIn"))); 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); } diff --git a/welcome.ui b/welcome.ui index 72ecc30..ed18cea 100644 --- a/welcome.ui +++ b/welcome.ui @@ -6,8 +6,8 @@ 0 0 - 800 - 600 + 803 + 596 @@ -68,7 +68,7 @@ - QLineEdit::Password + QLineEdit::EchoMode::Password @@ -103,13 +103,26 @@ + + + + 0 + 550 + 171 + 18 + + + + welcome.version + + 0 0 - 800 + 803 23