summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-02 20:28:06 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-02 20:28:06 (GMT)
commit08b8197f1fd4c5a8f3b0ec5f292d06dc87c7255c (patch)
tree62bdcb65da64d7944157a7b30214d3b163c4962f
parent38d7b24d0e7eda0cd8fc35e02ed8fa36fce0a607 (diff)
Use an unique network config manager
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/network/networkmanager.cpp43
-rw-r--r--src/network/networkmanager.h41
-rw-r--r--src/translator/translatorwidget.cpp6
5 files changed, 102 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cde0964..2e147ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@ include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
include(ECMInstallIcons)
-set(PIM_VERSION "5.3.60")
+set(PIM_VERSION "5.3.61")
set(PIMCOMMON_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef84f9f..4529a75 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -196,8 +196,13 @@ set(libpimcommon_genericgrantlee_SRCS
genericgrantlee/genericgrantleeformatter.cpp
)
+set(libpimcommon_networkmanager_SRCS
+ network/networkmanager.cpp
+ )
+
set(libpimcommon_SRCS
settings/pimcommonsettings.cpp
+ ${libpimcommon_networkmanager_SRCS}
${libpimcommon_configure_plugins_SRCS}
${libpimcommon_job_SRCS}
${libpimcommon_genericgrantlee_SRCS}
@@ -341,6 +346,14 @@ ecm_generate_headers(PimCommon_CamelCasegenericgrantlee_HEADERS
RELATIVE genericgrantlee
)
+ecm_generate_headers(PimCommon_CamelCasenetworkmanager_HEADERS
+ HEADER_NAMES
+ NetworkManager
+ REQUIRED_HEADERS PimCommon_networkmanager_HEADERS
+ PREFIX PimCommon
+ RELATIVE network
+ )
+
ecm_generate_headers(PimCommon_CamelCasejob_HEADERS
HEADER_NAMES
FetchRecursiveCollectionsJob
@@ -571,6 +584,7 @@ ecm_generate_pri_file(BASE_NAME PimCommon
install(FILES
+ ${PimCommon_CamelCasenetworkmanager_HEADERS}
${PimCommon_CamelCase_HEADERS}
${PimCommon_CamelCasegenericgrantlee_HEADERS}
${PimCommon_CamelCasegenericplugins_HEADERS}
@@ -609,6 +623,7 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/pimcommon_export.h
${CMAKE_CURRENT_BINARY_DIR}/pimcommonsetting_base.h
${PimCommon_HEADERS}
+ ${PimCommon_networkmanager_HEADERS}
${PimCommon_acl_HEADERS}
${PimCommon_autocorrection_HEADERS}
${PimCommon_autocorrectionwidgets_HEADERS}
diff --git a/src/network/networkmanager.cpp b/src/network/networkmanager.cpp
new file mode 100644
index 0000000..98c7665
--- /dev/null
+++ b/src/network/networkmanager.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "networkmanager.h"
+#include <QNetworkConfigurationManager>
+using namespace PimCommon;
+
+Q_GLOBAL_STATIC(NetworkManager, s_pNetworkManagerSelf)
+
+NetworkManager::NetworkManager(QObject *parent)
+ : QObject(parent)
+{
+ mNetworkConfigureManager = new QNetworkConfigurationManager();
+}
+
+NetworkManager::~NetworkManager()
+{
+ delete mNetworkConfigureManager;
+}
+
+NetworkManager *NetworkManager::self()
+{
+ return s_pNetworkManagerSelf();
+}
+
+QNetworkConfigurationManager *NetworkManager::networkConfigureManager() const
+{
+ return mNetworkConfigureManager;
+}
diff --git a/src/network/networkmanager.h b/src/network/networkmanager.h
new file mode 100644
index 0000000..bbb537b
--- /dev/null
+++ b/src/network/networkmanager.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef NetworkManager_H
+#define NetworkManager_H
+
+#include <QObject>
+#include "pimcommon_export.h"
+class QNetworkConfigurationManager;
+namespace PimCommon
+{
+class PIMCOMMON_EXPORT NetworkManager : public QObject
+{
+ Q_OBJECT
+public:
+ explicit NetworkManager(QObject *parent = Q_NULLPTR);
+ ~NetworkManager();
+ static NetworkManager *self();
+
+ QNetworkConfigurationManager *networkConfigureManager() const;
+
+private:
+ QNetworkConfigurationManager *mNetworkConfigureManager;
+};
+}
+
+#endif // NetworkManager_H
diff --git a/src/translator/translatorwidget.cpp b/src/translator/translatorwidget.cpp
index 53f656e..e5ede86 100644
--- a/src/translator/translatorwidget.cpp
+++ b/src/translator/translatorwidget.cpp
@@ -22,6 +22,7 @@
#include "googletranslator.h"
#include "kpimtextedit/plaintexteditorwidget.h"
#include "Libkdepim/ProgressIndicatorWidget"
+#include <PimCommon/NetworkManager>
#include <QPushButton>
#include <KLocalizedString>
@@ -54,12 +55,10 @@ public:
languageSettingsChanged(false),
standalone(true)
{
- mNetworkConfigurationManager = new QNetworkConfigurationManager();
}
~TranslatorWidgetPrivate()
{
delete abstractTranslator;
- delete mNetworkConfigurationManager;
}
void initLanguage();
@@ -78,7 +77,6 @@ public:
KPIM::ProgressIndicatorWidget *progressIndictor;
QPushButton *invert;
QSplitter *splitter;
- QNetworkConfigurationManager *mNetworkConfigurationManager;
bool languageSettingsChanged;
bool standalone;
};
@@ -362,7 +360,7 @@ void TranslatorWidget::setTextToTranslate(const QString &text)
void TranslatorWidget::slotTranslate()
{
- if (!d->mNetworkConfigurationManager->isOnline()) {
+ if (!PimCommon::NetworkManager::self()->networkConfigureManager()->isOnline()) {
KMessageBox::information(this, i18n("No network connection detected, we cannot translate text."), i18n("No network"));
return;
}