Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2fa-dev branch into dev #96

Merged
merged 29 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
180cadc
Refs #95, begin work on WebLogin, not working yet.
doumdi Sep 18, 2024
13d6959
Refs #95, prototye weblogin, not working yet.
doumdi Sep 19, 2024
3d46479
Refs #95, prototye weblogin, working with local server.
doumdi Sep 19, 2024
c6280b0
Refs #95, weblogin now enables server selection.
doumdi Sep 23, 2024
fbf754e
Refs #95, weblogin now enables server selection.
doumdi Sep 23, 2024
44a42e7
Refs #95. Adjusted WebLoginDialog UI.
SBriere Sep 26, 2024
244e683
Refs #95. Work in progress on Web Login Dialog translation.
SBriere Sep 27, 2024
949f89d
Refs #95. Fixed translations and login sequence with WebLoginDialog
SBriere Sep 30, 2024
7951aef
Refs #95. Working 2FA setup flow on login
SBriere Sep 30, 2024
c40da13
Refs #95. Improved WebLoginDialog experience
SBriere Oct 1, 2024
e25f505
Refs #95. Updated translations
SBriere Oct 1, 2024
541b286
Refs #95, fix translations on Mac.
doumdi Oct 2, 2024
b16149a
Refs #95. Updated editors for 2FA authentication
SBriere Oct 2, 2024
93e261e
Merge branch '2fa-dev' of https://github.com/introlab/openteraplus in…
SBriere Oct 2, 2024
b40389c
Refs #95. Added support for password change on login
SBriere Oct 4, 2024
25b4c91
Refs #95. Bumped version to 1.3.0
SBriere Oct 7, 2024
572d2a7
Refs #95. Added warning when enabled 2FA in user editor
SBriere Oct 7, 2024
e090b5c
Refs #95. Updated translations
SBriere Oct 7, 2024
858803e
Refs #95. Fixed issues when only 1 server in config file
SBriere Oct 8, 2024
88c926d
Refs #95. Fixed bad display on Weblogin when not showing servers
SBriere Oct 8, 2024
0dd1335
Merge branch '2fa-dev' of https://github.com/introlab/openteraplus in…
SBriere Oct 8, 2024
05e2e07
Refs #95, Fixed translation. To be validated.
doumdi Oct 8, 2024
e57fc0e
Merge branch '2fa-dev' of github.com:introlab/openteraplus into 2fa-dev
doumdi Oct 8, 2024
f6c048d
Refs #95, Fixed translation. To be validated.
doumdi Oct 8, 2024
dd66a77
Refs #95. Revised app closing paths and fixed possible issues
SBriere Oct 9, 2024
c4d4051
Merge branch '2fa-dev' of https://github.com/introlab/openteraplus in…
SBriere Oct 9, 2024
2d6519a
Refs #95. Removed context menu from WebLoginDialog (and others).
SBriere Oct 9, 2024
14150be
Refs #95. Fixed crash on Mac OS on language change
SBriere Oct 10, 2024
76e1fed
Updated build action to Qt 6.7.3
SBriere Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Qt
uses: jurplel/[email protected]
with:
version: '6.5.3'
version: '6.7.3'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/client/resources/translations/*.qm
deploy
/build-*
/build
*.user

html
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#Look for minimum cmake version
cmake_minimum_required(VERSION 3.21)

if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum OS X deployment version")
endif(APPLE)
Expand All @@ -8,16 +11,14 @@ project(OpenTeraPlus)
#enable_testing()
#include(CheckFunctionExists)

#Look for minimum cmake version
cmake_minimum_required(VERSION 3.21)

#DEFINITIONS POLICY, NEW SINCE 3.0.2
cmake_policy(SET CMP0043 NEW)
cmake_policy(SET CMP0007 NEW)

# Software version
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "2")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
add_definitions(-DOPENTERAPLUS_VERSION="${CPACK_PACKAGE_VERSION}" )
add_definitions(-DOPENTERAPLUS_VERSION_MAJOR="${CPACK_PACKAGE_VERSION_MAJOR}" )
Expand Down
7 changes: 7 additions & 0 deletions client/resources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
set(TERACLIENT_RES_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "doc string")

set(translations
translations/openteraplus_en.ts
translations/openteraplus_fr.ts
)

add_custom_target(translation_files SOURCES ${translations})
5 changes: 3 additions & 2 deletions client/resources/stylesheet.qss
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,12 @@ QLabel#lblWarning, QLabel#lblWarning2, QLabel#lblDeviceRegisterKeyValue{
}


/* Customizations for LoginDialog */
/* Customizations for LoginDialog / WebLoginDialog */
QFrame#frameLogos{background-color:rgba(200,200,200,100%);}
QLabel#lblMessage{color:white;}
QFrame#frameMessage{background-color: transparent;}
QFrame#frameButtons{background-color:rgba(29,29,29,50%);}
QFrame#frameButtons,QFrame#frameLoginMessages{background-color:rgba(29,29,29,50%);}
QLabel#lblError{color: orange;}

/* Customizations for MainWindow */
QMainWindow{background-image: url(://TeRA_Background.png); background-color: #2c3338;}
Expand Down
2,218 changes: 1,287 additions & 931 deletions client/resources/translations/openteraplus_en.ts

Large diffs are not rendered by default.

2,184 changes: 1,251 additions & 933 deletions client/resources/translations/openteraplus_fr.ts

Large diffs are not rendered by default.

94 changes: 70 additions & 24 deletions client/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ endif (MSVC)

find_package(Qt6 REQUIRED COMPONENTS LinguistTools Multimedia WebSockets Network)

qt_standard_project_setup(
I18N_SOURCE_LANGUAGE fr
I18N_TRANSLATED_LANGUAGES en fr
)

# Drivers first
add_subdirectory(drivers)

Expand Down Expand Up @@ -119,6 +124,7 @@ if(NOT DEFINED OPENTERA_WEBASSEMBLY)
dialogs/JoinSessionDialog.h
dialogs/AboutDialog.h
dialogs/AboutDialogPage.h
dialogs/WebLoginDialog.h
# Widgets
widgets/InSessionWidget.h
# Services
Expand Down Expand Up @@ -238,6 +244,7 @@ if(NOT DEFINED OPENTERA_WEBASSEMBLY)
dialogs/JoinSessionDialog.cpp
dialogs/AboutDialog.cpp
dialogs/AboutDialogPage.cpp
dialogs/WebLoginDialog.cpp
# Widgets
widgets/InSessionWidget.cpp
# Services
Expand Down Expand Up @@ -280,6 +287,7 @@ SET(uis
dialogs/CleanUpDialog.ui
dialogs/FileUploaderDialog.ui
dialogs/QRCodeDialog.ui
dialogs/WebLoginDialog.ui
# Editors
editors/DataListWidget.ui
editors/DeviceSubTypeWidget.ui
Expand Down Expand Up @@ -337,43 +345,80 @@ QT6_WRAP_UI(moc_uis ${uis})
#This will generate moc_* for Qt
QT6_WRAP_CPP(moc_srcs ${headers})

# generate rules for building source files from the resources
QT6_ADD_RESOURCES(client_qrc ${qrcs})



set(translation_files_srcs
${TERACLIENT_RES_INCLUDES}/translations/openteraplus_fr.ts
${TERACLIENT_RES_INCLUDES}/translations/openteraplus_en.ts
)

# #set qm files output directory
set_source_files_properties(${translation_files_srcs} PROPERTIES OUTPUT_LOCATION ${TERACLIENT_RES_INCLUDES}/translations/)

qt_add_lupdate(
TS_FILES
${translation_files_srcs}

SOURCES
${srcs}
${headers}
${moc_uis}

#Translation files, this is done manually to avoid removing the file when doing make clean
# Add -noobsolete parameter to remove obsoleted translations
add_custom_target(openteraplus_en_ts
COMMAND ${Qt6_LUPDATE_EXECUTABLE} -target-language en ${srcs} ${OPENTERA_SHARED_INCLUDES} ${headers} ${moc_uis} -ts ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_en.ts
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${moc_uis}
SOURCE_TARGETS opentera_shared
)

add_custom_target(openteraplus_fr_ts
COMMAND ${Qt6_LUPDATE_EXECUTABLE} -target-language fr ${srcs} ${OPENTERA_SHARED_INCLUDES} ${headers} ${moc_uis} -ts ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_fr.ts
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${moc_uis}
qt_add_lrelease(
TS_FILES ${translation_files_srcs} QM_FILES_OUTPUT_VARIABLE qm_files
)

#set qm files output directory
set_source_files_properties(${translation_files_srcs} PROPERTIES OUTPUT_LOCATION ${TERACLIENT_RES_INCLUDES}/translations/)
message(STATUS "qm_files : ${qm_files}")


#Build this target to update translations
add_custom_target(translations DEPENDS openteraplus_en_ts openteraplus_fr_ts)
add_custom_target(translation_files SOURCES ${translation_files_srcs})
# generate rules for building source files from the resources
QT6_ADD_RESOURCES(client_qrc ${qrcs})

#Generate qm files from .ts files
qt6_add_translation(qm_files ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_en.ts ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_fr.ts)


message(STATUS "qm_files : ${qm_files}")
# Make client_qrc target depends on qm_files



# #Translation files, this is done manually to avoid removing the file when doing make clean
# # Add -noobsolete parameter to remove obsoleted translations
# add_custom_target(openteraplus_en_ts
# COMMAND ${Qt6_LUPDATE_EXECUTABLE} -target-language en ${srcs} ${OPENTERA_SHARED_INCLUDES} ${headers} ${moc_uis} -ts ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_en.ts
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# DEPENDS ${moc_uis}
# )

# add_custom_target(openteraplus_fr_ts
# COMMAND ${Qt6_LUPDATE_EXECUTABLE} -target-language fr ${srcs} ${OPENTERA_SHARED_INCLUDES} ${headers} ${moc_uis} -ts ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_fr.ts
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# DEPENDS ${moc_uis}
# )

# #Build this target to update translations
# add_custom_target(translations DEPENDS openteraplus_en_ts openteraplus_fr_ts)
# add_custom_target(translation_files SOURCES ${translation_files_srcs})

# #Generate qm files from .ts files
# qt6_add_translation(qm_files
# ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_en.ts
# ${TERACLIENT_RES_INCLUDES}/translations/openteraplus_fr.ts)

# Translations
# if (Qt6_VERSION VERSION_GREATER_EQUAL 6.7)
# qt_add_translations(TARGETS OpenTeraPlus
# SOURCE_TARGETS ${srcs} ${OPENTERA_SHARED_INCLUDES} ${headers} ${moc_uis}
# TS_FILES ${translation_files_srcs}

# )
# else()
# qt_add_translations(OpenTeraPlus
# TS_FILES
# ${translation_files_srcs}
# )
# endif()



include_directories(
${TERACLIENT_RES_INCLUDES}
Expand Down Expand Up @@ -417,7 +462,8 @@ set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${MACOSX_BUNDLE_ICON_FILE}")
# create an executable file named "OpenTeraPlus" from the source files
# Put qrc files after qm files
if(NOT DEFINED OPENTERA_WEBASSEMBLY)
add_executable(OpenTeraPlus MACOSX_BUNDLE WIN32 ${icon} ${srcs} ${headers} ${moc_srcs} ${moc_uis} ${ICON_PATH} ${qm_files} ${client_qrc})
add_executable(OpenTeraPlus MACOSX_BUNDLE WIN32 ${icon} ${srcs} ${headers} ${moc_srcs} ${moc_uis} ${ICON_PATH} ${qm_files} ${client_qrc}
dialogs/WebLoginDialog.ui)
else()
qt_add_executable(OpenTeraPlus ${icon} ${srcs} ${headers} ${moc_srcs} ${moc_uis} ${ICON_PATH} ${qm_files} ${client_qrc})
endif()
Expand Down
83 changes: 66 additions & 17 deletions client/src/ClientApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ClientApp::ClientApp(int &argc, char **argv)
m_mainKitWindow = nullptr;
#endif

m_translator = new QTranslator();
m_qt_translator = new QTranslator();
m_translator = new QTranslator(this);
m_qt_translator = new QTranslator(this);

// Translations
QString last_lang = TeraSettings::getGlobalSetting(SETTINGS_LASTLANGUAGE).toString();
Expand Down Expand Up @@ -59,12 +59,17 @@ ClientApp::~ClientApp()
delete m_loginDiag;

if (m_comMan){
m_comMan->disconnectFromServer();
m_comMan->deleteLater();
//m_comMan->disconnect();
//m_comMan->disconnectFromServer();
//m_comMan->deleteLater();
delete m_comMan;
}

delete m_translator;
delete m_qt_translator;
if (m_mainWindow){
delete m_mainWindow;
}
if (m_mainKitWindow)
delete m_mainKitWindow;

}

Expand Down Expand Up @@ -122,10 +127,16 @@ void ClientApp::showLogin()
m_comMan = nullptr;
}
if (m_loginDiag == nullptr){

#ifndef OPENTERA_WEBASSEMBLY
m_loginDiag = new WebLoginDialog(&m_config);
connect(m_loginDiag, &WebLoginDialog::loginSuccess, this, &ClientApp::onLoginSuccess, Qt::QueuedConnection);
connect(m_loginDiag, &WebLoginDialog::finished, this, &ClientApp::loginQuitRequested);
#else
m_loginDiag = new LoginDialog();
connect(m_loginDiag, &LoginDialog::loginRequest, this, &ClientApp::loginRequested);
connect(m_loginDiag, &LoginDialog::quitRequest, this, &ClientApp::loginQuitRequested);

#endif
// Set server names
m_loginDiag->setServerNames(m_config.getServerNames());

Expand Down Expand Up @@ -220,12 +231,12 @@ void ClientApp::setTranslation(QString language)
m_currentLocale = QLocale(); // Use system locale by default
lang_changed = true;
}
if (language.toLower() == "en" && m_currentLocale != QLocale::English){
if (language.toLower() == "en" && m_currentLocale.language() != QLocale::English){
m_currentLocale = QLocale(QLocale::English);
lang_changed = true;
}

if (language.toLower() == "fr" && m_currentLocale != QLocale::French){
if (language.toLower() == "fr" && m_currentLocale.language() != QLocale::French){
m_currentLocale = QLocale(QLocale::French);
lang_changed = true;
}
Expand All @@ -239,19 +250,27 @@ void ClientApp::setTranslation(QString language)
QLocale::setDefault(m_currentLocale);

// Install Qt translator for default widgets
if (m_qt_translator->load("qt_" + m_currentLocale.name(), QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
if (m_qt_translator->load(QLocale(m_currentLocale.language()), QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
{
this->installTranslator(m_qt_translator);
if(!this->installTranslator(m_qt_translator)){
qWarning() << "Unable to install Qt translator...";
}else{
qDebug() << "Installed Qt translator";
}
}

// Install app specific translator
if (m_translator->load(m_currentLocale, QLatin1String("openteraplus"), QLatin1String("_"), QLatin1String(":/translations"))) {
this->installTranslator(m_translator);
//qDebug() << "Installed translator";
// Install app specific translator
if (m_translator->load(QLocale(m_currentLocale.language()), QLatin1String("openteraplus"), QLatin1String("_"), QLatin1String(":/translations"))) {
qDebug() << m_translator->filePath() << m_translator->language() << m_translator->isEmpty();
if (!this->installTranslator(m_translator)){
qWarning() << "Unable to install translator...";
}else{
qDebug() << "Installed translator";
}
}

// Save last used language
TeraSettings::setGlobalSetting(SETTINGS_LASTLANGUAGE, language.toLower());
TeraSettings::setGlobalSetting(SETTINGS_LASTLANGUAGE, QLocale(m_currentLocale.language()).bcp47Name());
}

}
Expand Down Expand Up @@ -286,7 +305,7 @@ void ClientApp::loginRequested(QString username, QString password, QString serve
void ClientApp::logoutRequested()
{
m_comMan->disconnectFromServer();
showLogin();
//showLogin();
}

void ClientApp::on_loginResult(bool logged, QString log_msg)
Expand All @@ -306,6 +325,35 @@ void ClientApp::on_loginResult(bool logged, QString log_msg)
}
}

void ClientApp::onLoginSuccess(const QString &token, const QString websocket_url, const QString &user_uuid)
{
// Create ComManager for that server
if (m_comMan){
m_comMan->deleteLater();
}

// Find server url for that server
QUrl server;
if (m_loginDiag)
server = m_config.getServerUrl(m_loginDiag->currentServerName());

m_comMan = new ComManager(server);

connect(m_comMan, &ComManager::socketError, this, &ClientApp::on_serverError);
connect(m_comMan, &ComManager::serverDisconnected, this, &ClientApp::on_serverDisconnected);
connect(m_comMan, &ComManager::loginResult, this, &ClientApp::on_loginResult);
connect(m_comMan, &ComManager::networkError, this, &ClientApp::on_networkError);
connect(m_comMan, &ComManager::preferencesUpdated, this, &ClientApp::preferencesUpdated);
connect(m_comMan, &ComManager::newVersionAvailable, this, &ClientApp::on_newVersionAvailable);
connect(m_comMan, &ComManager::currentUserUpdated, this, &ClientApp::on_currentUserUpdated);

connect(m_comMan->getWebSocketManager(), &WebSocketManager::genericEventReceived, this, &ClientApp::ws_genericEventReceived);

m_comMan->connectToServer(token, websocket_url, user_uuid);

//showMainWindow();
}

void ClientApp::loginQuitRequested()
{
QApplication::quit();
Expand All @@ -315,6 +363,7 @@ void ClientApp::on_serverDisconnected()
{
LOG_DEBUG("Disconnected from server.", "ClientApp::on_serverDisconnected");
showLogin();

}

void ClientApp::on_serverError(QAbstractSocket::SocketError error, QString error_str)
Expand Down
Loading
Loading