diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 26 | ||||
-rw-r--r-- | src/gpg/GpgContext.cpp | 30 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/ui/CMakeLists.txt | 16 | ||||
-rwxr-xr-x | src/ui/SettingsDialog.cpp | 6 |
5 files changed, 57 insertions, 25 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37807770..a6c7ba05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,5 @@ +set(ALL_SOURCE_FILE) + add_subdirectory(gpg) add_subdirectory(ui) @@ -10,15 +12,19 @@ set_property(SOURCE gpgfrontend.rc APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_SOURCE file(GLOB_RECURSE GPGFRONTEND_HEADER_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/include/*.h) qt5_wrap_cpp(QT5_MOCS ${GPGFRONTEND_HEADER_FILES} TARGET gpgfrontend) +# Get ALL SOURCE FILES +file(GLOB_RECURSE ALL_SOURCE_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/src/*.cpp) + # Set Translation Files -file(GLOB_RECURSE QT_TS_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/resource/ts/*.ts) +set(QT_TS_FILES gpgfrontend_en_us.ts gpgfrontend_zh_chs.ts gpgfrontend_zh_cht.ts gpg_frontend_fr.ts gpg_frontend_ru.ts) +list(TRANSFORM QT_TS_FILES PREPEND ${CMAKE_SOURCE_DIR}/resource/ts/) +message(STATUS "QT_TS_FILES ${QT_TS_FILES}") set(QT_QM_FILES_OUTPUT_DIR ${CMAKE_BINARY_DIR}/src/ts) set_source_files_properties(${QT_TS_FILES} PROPERTIES OUTPUT_LOCATION ${QT_QM_FILES_OUTPUT_DIR}) -QT5_create_translation(QON_QM_FILES ${BASE_SOURCE} ${QT_TS_FILES}) -message(STATUS ${QON_QM_FILES}) +QT5_create_translation(QON_QM_FILES ${CMAKE_SOURCE_DIR} ${QT_TS_FILES}) +message(STATUS "QON_QM_FILES ${QON_QM_FILES}") add_custom_target(translations DEPENDS ${QON_QM_FILES}) - # Set Build Information configure_file(${CMAKE_SOURCE_DIR}/include/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/include/GpgFrontend.h @ONLY) @@ -27,6 +33,8 @@ file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${EXECUTABLE_OUTPUT_PATH} file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${EXECUTABLE_OUTPUT_PATH}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/help DESTINATION ${EXECUTABLE_OUTPUT_PATH}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/conf DESTINATION ${EXECUTABLE_OUTPUT_PATH}/ FOLLOW_SYMLINK_CHAIN) + +# Copy Utils Files if(MINGW) message(STATUS "Copying Dependent DLL For Windows Runtime Env") file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/lib/ DESTINATION ${EXECUTABLE_OUTPUT_PATH}/ FOLLOW_SYMLINK_CHAIN) @@ -42,19 +50,23 @@ set(RESOURCE_FILES ${CMAKE_SOURCE_DIR}/gpgfrontend.qrc ${APP_ICON_RESOURCE_WINDO add_custom_target(resources ALL DEPENDS ${RESOURCE_FILES}) add_dependencies(resources translations) -add_executable(gpgfrontend ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS}) +if((${CMAKE_BUILD_TYPE} STREQUAL "Release") AND (MINGW)) + add_executable(gpgfrontend WIN32 ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS}) +else() + add_executable(gpgfrontend ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS}) +endif() IF (MINGW) message(STATUS "Link Application Static Library For MINGW") target_link_libraries(gpgfrontend - qtui gpg + gpgfrontend-ui gpg Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) else() message(STATUS "Link Application Static Library For UNIX") target_link_libraries(gpgfrontend - qtui gpg + gpgfrontend-ui gpg Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) endif() diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index 962ebaf4..62d7a246 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -28,7 +28,9 @@ #include <Mime.h> #ifdef _WIN32 + #include <windows.h> + #endif #define INT2VOIDP(i) (void*)(uintptr_t)(i) @@ -47,14 +49,9 @@ namespace GpgME { * subsystem in GPGME. (from the info page) */ gpgme_check_version(nullptr); - // TODO: Set gpgme_language to config - /*QSettings qSettings; - qDebug() << " - " << qSettings.value("int/lang").toLocale().name(); - qDebug() << " - " << QLocale(qSettings.value("int/lang").toString()).name();*/ - // the locale set here is used for the other setlocale calls which have nullptr // -> nullptr means use default, which is configured here - setlocale(LC_ALL, ""); + setlocale(LC_ALL, settings.value("int/lang").toLocale().name().toUtf8().constData()); /** set locale, because tests do also */ gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr)); @@ -69,12 +66,33 @@ namespace GpgME { gpgme_engine_info_t engineInfo; engineInfo = gpgme_ctx_get_engine_info(mCtx); + // Check ENV before running + bool check_pass = false, find_openpgp = false, find_gpgconf = false, find_assuan = false, find_cms = false; while (engineInfo != nullptr) { qDebug() << gpgme_get_protocol_name(engineInfo->protocol) << engineInfo->file_name << engineInfo->protocol << engineInfo->home_dir << engineInfo->version; + if (engineInfo->protocol == GPGME_PROTOCOL_GPGCONF && strcmp(engineInfo->version, "1.0.0") != 0) + find_gpgconf = true; + if (engineInfo->protocol == GPGME_PROTOCOL_OpenPGP && strcmp(engineInfo->version, "1.0.0") != 0) + find_openpgp = true; + if (engineInfo->protocol == GPGME_PROTOCOL_CMS && strcmp(engineInfo->version, "1.0.0") != 0) + find_cms = true; + if (engineInfo->protocol == GPGME_PROTOCOL_ASSUAN) + find_assuan = true; + engineInfo = engineInfo->next; } + if (find_gpgconf && find_openpgp && find_cms && find_assuan) + check_pass = true; + + if (!check_pass) { + QMessageBox::critical(nullptr, tr("ENV Loading Failed"), + tr("Gnupg is not installed correctly, please follow the ReadME instructions to install gnupg and then open GPGFrontend.")); + QCoreApplication::quit(); + exit(0); + } + /** Setting the output type must be done at the beginning */ /** think this means ascii-armor --> ? */ gpgme_set_armor(mCtx, 1); diff --git a/src/main.cpp b/src/main.cpp index b2aca517..7d6a71a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { QString appPath = qApp->applicationDirPath(); QApplication::setApplicationVersion(BUILD_VERSION); - QApplication::setApplicationName("GPGFrontend"); + QApplication::setApplicationName(PROJECT_NAME); // dont show icons in menus QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) { lang = QLocale::system().name(); } qDebug() << "Language set" << lang; - translator.load( appPath + "/ts/" + "gpg4usb_" + lang); + translator.load( appPath + "/ts/" + "gpgfrontend_" + lang); qDebug() << "Translator" << translator.filePath(); QApplication::installTranslator(&translator); diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 2527da46..d92a63ed 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,9 +1,11 @@ -aux_source_directory(. QTUI_SOURCE) -aux_source_directory(./keypair_details QTUI_SOURCE) -aux_source_directory(./widgets QTUI_SOURCE) -aux_source_directory(./keygen QTUI_SOURCE) +aux_source_directory(. UI_SOURCE) +aux_source_directory(./keypair_details UI_SOURCE) +aux_source_directory(./widgets UI_SOURCE) +aux_source_directory(./keygen UI_SOURCE) -add_library(qtui STATIC ${QTUI_SOURCE} ${QTUI_KEYPAIR_DETAILS_SOURCE}) +add_library(gpgfrontend-ui STATIC ${UI_SOURCE}) -target_link_libraries(qtui - Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
\ No newline at end of file +target_link_libraries(gpgfrontend-ui + Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) + +message(STATUS "UI SOURCE ${UI_SOURCE}")
\ No newline at end of file diff --git a/src/ui/SettingsDialog.cpp b/src/ui/SettingsDialog.cpp index 5501dedd..2c130497 100755 --- a/src/ui/SettingsDialog.cpp +++ b/src/ui/SettingsDialog.cpp @@ -99,7 +99,7 @@ QHash<QString, QString> SettingsDialog::listLanguages() { QString appPath = qApp->applicationDirPath(); QDir qmDir = QDir(appPath + "/ts/"); QStringList fileNames = - qmDir.entryList(QStringList("gpg4usb_*.qm")); + qmDir.entryList(QStringList("gpgfrontend_*.qm")); for (int i = 0; i < fileNames.size(); ++i) { QString locale = fileNames[i]; @@ -112,7 +112,7 @@ QHash<QString, QString> SettingsDialog::listLanguages() { QString language = QLocale::languageToString(qloc.language()) +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; #else QString language = qloc.nativeLanguageName() + " (" + locale + - ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; + ")"; #endif languages.insert(locale, language); } @@ -167,7 +167,7 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx, QWidget *parent) langBoxLayout->addWidget(langSelectBox); langBoxLayout->addWidget( - new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the language!"))); + new QLabel(tr("<b>NOTE: </b> GpgFrontend will restart automatically if you change the language!"))); langBox->setLayout(langBoxLayout); connect(langSelectBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLanguageChanged())); |