fix locale warning

This commit is contained in:
Kevin Yue 2021-09-20 16:15:10 +08:00
parent 197fd585ca
commit 6151892046
11 changed files with 63 additions and 10 deletions

14
3rdparty/qt-unix-signals/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.1.0)
project(QtSignals LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
find_package(Qt5 REQUIRED COMPONENTS Core)
add_library(QtSignals sigwatch.cpp)
target_include_directories(QtSignals INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(QtSignals Qt5::Core)

21
3rdparty/qt-unix-signals/LICENCE vendored Normal file
View File

@ -0,0 +1,21 @@
Unix signal watcher for Qt.
Copyright (C) 2014 Simon Knopp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -22,5 +22,7 @@ find_package(Qt5 REQUIRED COMPONENTS
DBus DBus
) )
add_subdirectory(3rdparty/qt-unix-signals)
add_subdirectory(GPService) add_subdirectory(GPService)
add_subdirectory(GPClient) add_subdirectory(GPClient)
add_dependencies(gpclient gpservice)

View File

@ -4,7 +4,11 @@ project(GPClient)
set(gpclient_GENERATED_SOURCES) set(gpclient_GENERATED_SOURCES)
qt5_add_dbus_interface(gpclient_GENERATED_SOURCES ${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml gpserviceinterface) qt5_add_dbus_interface(
gpclient_GENERATED_SOURCES
${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml
gpserviceinterface
)
add_executable(gpclient add_executable(gpclient
cdpcommand.cpp cdpcommand.cpp
@ -75,6 +79,7 @@ target_link_libraries(gpclient
Qt5::WebEngine Qt5::WebEngine
Qt5::WebEngineWidgets Qt5::WebEngineWidgets
Qt5::DBus Qt5::DBus
QtSignals
) )
target_compile_definitions(gpclient PUBLIC QAPPLICATION_CLASS=QApplication) target_compile_definitions(gpclient PUBLIC QAPPLICATION_CLASS=QApplication)

View File

@ -23,6 +23,7 @@ public:
~GPClient(); ~GPClient();
void activate(); void activate();
void quit();
private slots: private slots:
void onSettingsButtonClicked(); void onSettingsButtonClicked();
@ -97,6 +98,5 @@ private:
void setCurrentGateway(const GPGateway gateway); void setCurrentGateway(const GPGateway gateway);
void clearSettings(); void clearSettings();
void quit();
}; };
#endif // GPCLIENT_H #endif // GPCLIENT_H

View File

@ -8,6 +8,7 @@
#include "singleapplication.h" #include "singleapplication.h"
#include "gpclient.h" #include "gpclient.h"
#include "enhancedwebview.h" #include "enhancedwebview.h"
#include "sigwatch.h"
#include "version.h" #include "version.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -40,5 +41,12 @@ int main(int argc, char *argv[])
QObject::connect(&app, &SingleApplication::instanceStarted, &w, &GPClient::activate); QObject::connect(&app, &SingleApplication::instanceStarted, &w, &GPClient::activate);
UnixSignalWatcher sigwatch;
sigwatch.watchForSignal(SIGINT);
sigwatch.watchForSignal(SIGTERM);
sigwatch.watchForSignal(SIGQUIT);
sigwatch.watchForSignal(SIGHUP);
QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &w, &GPClient::quit);
return app.exec(); return app.exec();
} }

View File

@ -5,7 +5,10 @@ project(GPService)
set(gpservice_GENERATED_SOURCES) set(gpservice_GENERATED_SOURCES)
# generate the dbus xml definition # generate the dbus xml definition
qt5_generate_dbus_interface(gpservice.h ${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml) qt5_generate_dbus_interface(
gpservice.h
${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml
)
# generate dbus adaptor # generate dbus adaptor
qt5_add_dbus_adaptor( qt5_add_dbus_adaptor(
@ -18,7 +21,6 @@ qt5_add_dbus_adaptor(
add_executable(gpservice add_executable(gpservice
gpservice.cpp gpservice.cpp
main.cpp main.cpp
sigwatch.cpp
${gpservice_GENERATED_SOURCES} ${gpservice_GENERATED_SOURCES}
) )
@ -53,6 +55,7 @@ target_link_libraries(gpservice
Qt5::Core Qt5::Core
Qt5::Network Qt5::Network
Qt5::DBus Qt5::DBus
QtSignals
) )
target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication) target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication)

View File

@ -4,7 +4,6 @@
#include <QtCore/QRegularExpression> #include <QtCore/QRegularExpression>
#include <QtCore/QRegularExpressionMatch> #include <QtCore/QRegularExpressionMatch>
#include <QtDBus/QtDBus> #include <QtDBus/QtDBus>
#include <QtCore/QProcessEnvironment>
#include "gpservice.h" #include "gpservice.h"
#include "gpserviceadaptor.h" #include "gpserviceadaptor.h"
@ -123,8 +122,6 @@ void GPService::connect(QString server, QString username, QString passwd, QStrin
log("Start process with arugments: " + args.join(" ")); log("Start process with arugments: " + args.join(" "));
log("ENV for OC: " + openconnect->environment().join("\n"));
log("ENV for gpservice: " + QProcessEnvironment::systemEnvironment().toStringList().join("\n"));
openconnect->start(bin, args); openconnect->start(bin, args);
} }

View File

@ -13,10 +13,12 @@ package-repositories:
ppa: dwmw2/openconnect ppa: dwmw2/openconnect
layout: layout:
/usr/share/vpnc-scripts:
bind: $SNAP/usr/share/vpnc-scripts
/usr/local/sbin: /usr/local/sbin:
bind: $SNAP/usr/sbin bind: $SNAP/usr/sbin
/usr/share/vpnc-scripts:
bind: $SNAP/usr/share/vpnc-scripts
/usr/share/locale:
bind: $SNAP/usr/share/locale
slots: slots:
gpservice-slot: gpservice-slot:
@ -37,7 +39,8 @@ apps:
command-chain: command-chain:
- snap/command-chain/desktop-launch - snap/command-chain/desktop-launch
environment: environment:
LANG: en_US.utf8 LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
plugs: plugs:
- network - network
slots: slots: