Compare commits
5 Commits
b11e5ce852
...
bf171dc3bb
| Author | SHA1 | Date | |
|---|---|---|---|
| bf171dc3bb | |||
| 82910c480a | |||
| ff44110b77 | |||
| 42f9643874 | |||
| e5740c383f |
@ -9,7 +9,9 @@ set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
|
||||
# sudo apt install qt6-base-dev qt6-base-dev-tools
|
||||
find_package(Qt6 REQUIRED)
|
||||
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Network)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
@ -23,6 +25,23 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
qt_add_executable(ConanCraft-Launcher
|
||||
MANUAL_FINALIZATION
|
||||
${PROJECT_SOURCES}
|
||||
loading.h loading.cpp loading.ui
|
||||
source.qrc
|
||||
loading-worker.h loading-worker.cpp
|
||||
locales.h
|
||||
locales.cpp
|
||||
install-java.h
|
||||
install-java.cpp
|
||||
network-downloader.h
|
||||
network-downloader.cpp
|
||||
fs-tools.cpp
|
||||
fs-tools.h
|
||||
prog-constains.h
|
||||
prog-constains.cpp
|
||||
install-i2p.h
|
||||
install-i2p.cpp
|
||||
i2p-controller.h i2p-controller.cpp
|
||||
personal-account.h personal-account.cpp personal-account.ui
|
||||
)
|
||||
# Define target properties for Android with Qt 6 as:
|
||||
# set_property(TARGET ConanCraft-Launcher APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
|
||||
@ -36,26 +55,7 @@ else()
|
||||
# Define properties for Android with Qt 5 after find_package() calls as:
|
||||
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
|
||||
else()
|
||||
add_executable(ConanCraft-Launcher
|
||||
${PROJECT_SOURCES}
|
||||
loading.h loading.cpp loading.ui
|
||||
source.qrc
|
||||
loading-worker.h loading-worker.cpp
|
||||
locales.h
|
||||
locales.cpp
|
||||
install-java.h
|
||||
install-java.cpp
|
||||
network-downloader.h
|
||||
network-downloader.cpp
|
||||
fs-tools.cpp
|
||||
fs-tools.h
|
||||
prog-constains.h
|
||||
prog-constains.cpp
|
||||
install-i2p.h
|
||||
install-i2p.cpp
|
||||
i2p-controller.h i2p-controller.cpp
|
||||
personal-account.h personal-account.cpp personal-account.ui
|
||||
)
|
||||
# Qt5 is tool for sons of whole
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@ -2,9 +2,15 @@
|
||||
#include "prog-constains.h"
|
||||
#include "locales.h"
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <sys/prctl.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
I2PController::I2PController(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
i2p.setWorkingDirectory(I2P_INSTALL_PATH);
|
||||
this->isFatalErrored = false;
|
||||
|
||||
connect(&i2p, &QProcess::errorOccurred,
|
||||
@ -14,7 +20,8 @@ I2PController::I2PController(QObject *parent)
|
||||
this, &I2PController::onProcessFinished);
|
||||
|
||||
connect(&i2p, &QProcess::readyReadStandardOutput, this, [this]() {
|
||||
qDebug() << "[i2pd]" << i2p.readAllStandardOutput();
|
||||
// Logging I2P
|
||||
//qDebug() << "[i2pd]" << i2p.readAllStandardOutput();
|
||||
});
|
||||
|
||||
connect(&i2p, &QProcess::readyReadStandardError, this, [this]() {
|
||||
@ -42,6 +49,18 @@ I2PController::I2PController(QObject *parent)
|
||||
});
|
||||
}
|
||||
|
||||
I2PController::~I2PController()
|
||||
{
|
||||
if (i2p.state() != QProcess::NotRunning)
|
||||
{
|
||||
i2p.terminate();
|
||||
i2p.waitForFinished(3000);
|
||||
|
||||
if (i2p.state() != QProcess::NotRunning)
|
||||
i2p.kill();
|
||||
}
|
||||
}
|
||||
|
||||
void I2PController::start() {
|
||||
if (i2p.state() != QProcess::NotRunning)
|
||||
{
|
||||
@ -49,6 +68,13 @@ void I2PController::start() {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
// If SIGKILL on Linux
|
||||
i2p.setChildProcessModifier([]() {
|
||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||
});
|
||||
#endif
|
||||
|
||||
QStringList args;
|
||||
#if defined(Q_OS_WIN)
|
||||
this->i2p.start(QDir(I2P_INSTALL_PATH).filePath("i2pd.exe"), args);
|
||||
@ -61,6 +87,7 @@ void I2PController::start() {
|
||||
<< "--tunconf" << QDir(configsFolder).filePath("tunnels.conf")
|
||||
<< "--log" << QDir(logsFolder).filePath("i2pd.log");
|
||||
|
||||
//qDebug() << "i2pd args:" << args;
|
||||
this->i2p.start(QDir(I2P_INSTALL_PATH).filePath("i2pd"), args);
|
||||
#else
|
||||
#endif
|
||||
|
||||
@ -12,6 +12,7 @@ class I2PController : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
I2PController(QObject *parent = nullptr);
|
||||
~I2PController();
|
||||
void start();
|
||||
private:
|
||||
QProcess i2p;
|
||||
|
||||
@ -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 ();
|
||||
|
||||
@ -65,13 +65,18 @@ void LoadingWorker::process() {
|
||||
configCheckAndMake();
|
||||
emit startI2P();
|
||||
|
||||
// Checking: Is minecraft installed
|
||||
emit changeStep(QString::fromStdString(localeMap->at("loading.isMinecraftInst")));
|
||||
// Ping the website
|
||||
emit changeStep(QString::fromStdString(localeMap->at("loading.pingWebsite")));
|
||||
// TODO: Add it later
|
||||
|
||||
// Getting endpoint API
|
||||
emit changeStep(QString::fromStdString(localeMap->at("loading.gettingEndpoint")));
|
||||
std::string endpointAPI = "TODO: Add it later";
|
||||
|
||||
// Checking: Is minecraft installed
|
||||
emit changeStep(QString::fromStdString(localeMap->at("loading.isMinecraftInst")));
|
||||
// TODO: Add it later
|
||||
|
||||
// Handle data
|
||||
emit changeStep(QString::fromStdString(localeMap->at("loading.logging")));
|
||||
// TODO: Add it later
|
||||
|
||||
@ -18,6 +18,7 @@ LocaleMap ru_RU = {
|
||||
{"loading.end", "Закончили. Приятной игры"},
|
||||
{"loading.installI2P", "Установка I2P"},
|
||||
{"loading.isMinecraftInst", "Проверим установлен ли Майнкрафт"},
|
||||
{"loading.pingWebsite", "Пытаемся достучаться до сайта"},
|
||||
// Welcome
|
||||
{"welcome.main", "Главная"},
|
||||
{"welcome.settings", "Настройки"},
|
||||
@ -25,6 +26,7 @@ LocaleMap ru_RU = {
|
||||
{"welcome.showPassword", "Показать пароль"},
|
||||
{"welcome.logIn", "Войти"},
|
||||
{"welcome.register", "Зарегистрироваться"},
|
||||
{"welcome.version", "Версия"},
|
||||
// I2PD
|
||||
{"i2pd.errorTitle", "Ошибка I2P"},
|
||||
{"i2pd.errorDescription.p1", "I2P Завершилась с фатальной ошибкой:\n\n"},
|
||||
@ -47,6 +49,7 @@ LocaleMap en_US = {
|
||||
{"loading.end", "Finished. Let's start"},
|
||||
{"loading.installI2P", "Installing I2P"},
|
||||
{"loading.isMinecraftInst", "Checking Is Minecraft installed"},
|
||||
{"loading.pingWebsite", "Trying to connect to the website"},
|
||||
// Welcome
|
||||
{"welcome.main", "Home"},
|
||||
{"welcome.settings", "Settings"},
|
||||
@ -54,6 +57,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();
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -5,10 +5,17 @@
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
|
||||
extern const QString VERSION;
|
||||
|
||||
extern const QString __dirname;
|
||||
extern const QString JAVA_INSTALL_PATH;
|
||||
extern const QString TEMP_PATH;
|
||||
extern const QString I2P_INSTALL_PATH;
|
||||
extern const QString WIKI_URL;
|
||||
|
||||
extern const QString DEFAULT_I2PD_CONF;
|
||||
extern const QString DEFAULT_TUNNELS_CONF;
|
||||
|
||||
void debugVariables();
|
||||
|
||||
#endif // PROG_CONSTAINS_H
|
||||
|
||||
@ -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