Commit 08b8197f authored by Laurent Montel's avatar Laurent Montel 😁

Use an unique network config manager

parent 38d7b24d
......@@ -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")
......
......@@ -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}
......
/*
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;
}
/*
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
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment