Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
62 lines (52 loc) · 1.94 KB
/
Copy pathmain.cpp
File metadata and controls
62 lines (52 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/***********************************************************************
* File Name: main.cpp
* Author(s): Blake Azuela
* Date Created: 2024-05-06
* Description: This file sets up the QApplication for the MetaMover project,
* loads language translations, and initializes the main GUI
* window and scanner functionality on separate threads to
* enhance UI responsiveness.
* License: MIT License
***********************************************************************/
#include "metamovermainwindow.h"
#include "scanner.h"
#include "transfermanager.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QThread>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "MetaMover_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
// Set up the Scanner in its own thread
QThread scannerThread;
Scanner* scanner = new Scanner(); // Configure with desired thread pool size
scanner->moveToThread(&scannerThread);
scannerThread.start();
// Set up the transfer manager on its own thread
QThread transferManagerThread;
TransferManager *transferManager = new TransferManager(); // Configure with desired thread pool size
transferManager->moveToThread(&transferManagerThread);
transferManagerThread.start();
// Pass the scanner to the main window
MetaMoverMainWindow w(scanner, transferManager);
w.show();
int execResult = a.exec();
// Clean up the threads
scannerThread.quit();
scannerThread.wait();
delete scanner;
transferManagerThread.quit();
transferManagerThread.wait();
delete transferManager;
return execResult;
}