remove unneeded code.

This commit is contained in:
2025-04-01 17:50:02 +03:00
parent f483c97935
commit e749c21a61
29 changed files with 1116 additions and 2122 deletions

118
main.cpp
View File

@@ -1,11 +1,10 @@
#include "mainwindow.h"
#include "net/net.h"
#include "settings/settings.h"
#include "utils/utils.h"
#include <mainwindow.h>
#include <net/net.h>
#include <settings/settings.h>
#include <utils/utils.h>
#include <QApplication>
#ifdef BUILD_OFD_MODE
# include <curl/curl.h>
# include <ofdscene.h>
#endif
#include <iostream>
#if __GNUC__ < 8 && __clang_major__ < 17
@@ -19,26 +18,14 @@
#include <QFile>
#include <QStackedLayout>
#include <QTextStream>
#include <QTranslator>
#ifdef BUILD_TRANSLATIONS
# include <QTranslator>
#endif
#include <settingsdialog.h>
#ifdef BUILD_EMAIL_TO_TEXT_MODE
# include <emailtextscene.h>
#ifdef BUILD_EMAIL_MODE
//placeholder
#endif
#ifdef BUILD_OCR_MODE
# include <ocrscene.h>
#endif
#include <qpushbutton.h>
#include <parser/parser.h>
#include <QtUiTools/quiloader.h>
static QWidget *loadUI(QWidget *parent, std::string filename) {
QUiLoader loader;
QFile file(QString::fromStdString(filename));
file.open(QIODevice::ReadOnly);
return loader.load(&file, parent);
}
#include <QPushButton>
int main(int argc, char *argv[]) {
curl_global_init(CURL_GLOBAL_ALL);
@@ -47,7 +34,6 @@ int main(int argc, char *argv[]) {
create_directories(program_data_path);
srand(time(0));
fetch_and_download_modules();
QApplication app(argc, argv);
@@ -56,9 +42,10 @@ int main(int argc, char *argv[]) {
Settings s(settings_file_path);
#ifdef BUILD_TRANSLATIONS
QTranslator translator;
QString lang = "en_US";
#ifdef BUILD_TRANSLATIONS
bool languageSettingPresent = false;
languageSettingPresent = s.get_all_settings().find("language") != s.get_all_settings().end();
@@ -75,81 +62,18 @@ int main(int argc, char *argv[]) {
translator.load(":/translation/" + lang + ".qm");
app.installTranslator(&translator);
#endif
MainWindow w;
QWidget *window = new QWidget();
QStackedLayout *sceneLayout = new QStackedLayout;
// Main Window setup
QWidget *mainwindowscene = loadUI(window, ":/scenes/scenes/mainwindow.ui");
sceneLayout->addWidget(mainwindowscene);
w.show();
// TODO: move to the window
//Settings button setup
QPushButton *settingsButton = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("settings_button");
QObject::connect(settingsButton, &QPushButton::clicked, [&]() {
SettingsDialog d;
d.show();
d.exec();
});
for (auto &btn : ((MainWindow *)mainwindowscene)->findChildren<QPushButton *>()) {
if (btn->objectName() == "settings_button") continue;
btn->hide();
}
// Main Window buttons setup
#ifdef BUILD_EMAIL_TO_TEXT_MODE
QPushButton *text_from_email_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("text_from_email_button");
text_from_email_button->show();
EmailTextScene *emailTextScene = new EmailTextScene();
sceneLayout->addWidget(emailTextScene);
QObject::connect(text_from_email_button, &QPushButton::clicked, [&]() {
// Text from email scene
int index = sceneLayout->indexOf(emailTextScene);
sceneLayout->setCurrentIndex(index);
sceneLayout->widget(index)->show();
});
#endif
#ifdef BUILD_OCR_MODE
QPushButton *ocr_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("ocr_button");
ocr_button->show();
OCRScene *ocrscene = new OCRScene();
sceneLayout->addWidget(ocrscene);
QObject::connect(ocr_button, &QPushButton::clicked, [&]() {
// OCR scene
int index = sceneLayout->indexOf(ocrscene);
sceneLayout->setCurrentIndex(index);
sceneLayout->widget(index)->show();
});
#endif
#ifdef BUILD_OFD_MODE
QPushButton *ofd_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("ofd_button");
ofd_button->show();
OFDScene *ofdscene = new OFDScene();
sceneLayout->addWidget(ofdscene);
QObject::connect(ofd_button, &QPushButton::clicked, [&]() {
// OFD scene
int index = sceneLayout->indexOf(ofdscene);
sceneLayout->setCurrentIndex(index);
sceneLayout->widget(index)->show();
});
#endif
//Setting all back buttons
for (uint32_t sceneIndex = 0; sceneIndex < sceneLayout->count(); sceneIndex ++) {
auto scene = sceneLayout->widget(sceneIndex);
QPushButton *back_button = scene->findChild<QPushButton *>("back_button");
if (back_button == nullptr) continue;
QObject::connect(back_button, &QPushButton::clicked, [&]() {
sceneLayout->setCurrentIndex(0);
});
}
window->setLayout(sceneLayout);
window->show();
// QPushButton *settingsButton = w.findChild<QPushButton *>("settings_button");
// QObject::connect(settingsButton, &QPushButton::clicked, [&]() {
// SettingsDialog d;
// d.show();
// d.exec();
// });
return app.exec();
}