Fix bugs, add displayed version info
This commit is contained in:
parent
ff44110b77
commit
82910c480a
@ -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 () {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <QDirIterator>
|
||||
#include <QThread>
|
||||
#include <QProcess>
|
||||
#include <QTextStream>
|
||||
|
||||
bool installI2P(std::function<void(QString, unsigned int, unsigned int)> logCallback);
|
||||
bool checkI2P ();
|
||||
|
||||
@ -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"},
|
||||
|
||||
5
main.cpp
5
main.cpp
@ -1,15 +1,18 @@
|
||||
#include "loading.h"
|
||||
#include "locales.h"
|
||||
#include "prog-constains.h"
|
||||
//#include "welcome.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
21
welcome.ui
21
welcome.ui
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
<width>803</width>
|
||||
<height>596</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -68,7 +68,7 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
<enum>QLineEdit::EchoMode::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -103,13 +103,26 @@
|
||||
</attribute>
|
||||
</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 class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>803</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user