Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KDE PIM Runtime
Commits
d3bb0249
Commit
d3bb0249
authored
Jun 09, 2020
by
Shashwat Jolly
Browse files
Fix config dialog bug
Fix bug where resource was not able to get updated settings in the current instance
parent
45ec9d3c
Changes
6
Hide whitespace changes
Inline
Side-by-side
resources/etesync/CMakeLists.txt
View file @
d3bb0249
...
...
@@ -64,7 +64,6 @@ install(FILES etesyncresource.desktop
################################### Config plugin ############################
set
(
etesyncconfig_SRCS
configwidget.cpp
etesyncconfig.cpp
${
etesyncresource_common_SRCS
}
)
...
...
@@ -77,7 +76,7 @@ ecm_qt_declare_logging_category(etesyncconfig_SRCS
EXPORT KDEPIMRUNTIME
)
ki18n_wrap_ui
(
etesyncconfig_SRCS configwidget.ui
)
ki18n_wrap_ui
(
etesyncconfig_SRCS
etesync
configwidget.ui
)
kcoreaddons_add_plugin
(
etesyncconfig
SOURCES
${
etesyncconfig_SRCS
}
...
...
resources/etesync/configwidget.cpp
deleted
100644 → 0
View file @
45ec9d3c
/*
* Copyright (C) 2020 by Shashwat Jolly <shashwat.jolly@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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, see <https://www.gnu.org/licenses/>.
*/
#include "configwidget.h"
#include <KConfigDialogManager>
#include <KLocalizedString>
#include <KMessageBox>
#include <QPushButton>
#include "etesyncconfig_debug.h"
#include "settings.h"
#include "ui_configwidget.h"
ConfigWidget
::
ConfigWidget
(
Settings
*
settings
,
QWidget
*
parent
)
:
QWidget
(
parent
)
{
Ui
::
ConfigWidget
ui
;
ui
.
setupUi
(
this
);
ui
.
kcfg_BaseUrl
->
setWhatsThis
(
i18n
(
"Enter the http or https URL of your EteSync server here."
));
ui
.
kcfg_Username
->
setWhatsThis
(
i18n
(
"Enter the username of your EteSync account here."
));
ui
.
kcfg_Password
->
setWhatsThis
(
i18n
(
"Enter the password of your EteSync account here."
));
ui
.
kcfg_EncryptionPassword
->
setWhatsThis
(
i18n
(
"Enter the encryption password for your EteSync account here."
));
ui
.
kcfg_BaseUrl
->
setText
(
QStringLiteral
(
"https://api.etesync.com"
));
mServerEdit
=
ui
.
kcfg_BaseUrl
;
mUserEdit
=
ui
.
kcfg_Username
;
mPasswordEdit
=
ui
.
kcfg_Password
;
mEncryptionPasswordEdit
=
ui
.
kcfg_EncryptionPassword
;
mManager
=
new
KConfigDialogManager
(
this
,
settings
);
setMinimumSize
(
QSize
(
380
,
180
));
}
void
ConfigWidget
::
load
()
{
mManager
->
updateWidgets
();
}
void
ConfigWidget
::
save
()
const
{
mManager
->
updateSettings
();
}
\ No newline at end of file
resources/etesync/etesyncconfig.cpp
View file @
d3bb0249
...
...
@@ -15,40 +15,45 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <AkonadiCore/AgentConfigurationBase>
#include "etesyncconfig.h"
#include <KConfigDialogManager>
#include <KSharedConfig>
#include "configwidget.h"
#include "etesyncconfig_debug.h"
#include "settings.h"
class
EteSyncConfig
:
public
Akonadi
::
AgentConfigurationBase
namespace
{
static
const
char
myConfigGroupName
[]
=
"EteSyncConfigDialog"
;
}
EteSyncConfig
::
EteSyncConfig
(
const
KSharedConfigPtr
&
config
,
QWidget
*
parent
,
const
QVariantList
&
args
)
:
Akonadi
::
AgentConfigurationBase
(
config
,
parent
,
args
)
{
Settings
::
instance
(
config
);
QWidget
*
mainWidget
=
new
QWidget
(
parent
);
ui
.
setupUi
(
mainWidget
);
parent
->
layout
()
->
addWidget
(
mainWidget
);
mManager
=
new
KConfigDialogManager
(
mainWidget
,
Settings
::
self
());
mManager
->
updateWidgets
();
}
bool
EteSyncConfig
::
save
()
const
{
mManager
->
updateSettings
();
return
Akonadi
::
AgentConfigurationBase
::
save
();
}
QSize
EteSyncConfig
::
restoreDialogSize
()
const
{
auto
group
=
config
()
->
group
(
myConfigGroupName
);
const
QSize
size
=
group
.
readEntry
(
"Size"
,
QSize
(
380
,
180
));
return
size
;
}
void
EteSyncConfig
::
saveDialogSize
(
const
QSize
&
size
)
{
Q_OBJECT
public:
EteSyncConfig
(
const
KSharedConfigPtr
&
config
,
QWidget
*
parent
,
const
QVariantList
&
args
)
:
Akonadi
::
AgentConfigurationBase
(
config
,
parent
,
args
)
{
Settings
::
instance
(
config
);
mSettings
.
reset
(
Settings
::
self
());
mWidget
.
reset
(
new
ConfigWidget
(
mSettings
.
data
(),
parent
));
}
void
load
()
override
{
Akonadi
::
AgentConfigurationBase
::
load
();
mWidget
->
load
();
}
bool
save
()
const
override
{
mWidget
->
save
();
return
Akonadi
::
AgentConfigurationBase
::
save
();
}
QScopedPointer
<
Settings
>
mSettings
;
QScopedPointer
<
ConfigWidget
>
mWidget
;
};
AKONADI_AGENTCONFIG_FACTORY
(
EteSyncConfigFactory
,
"etesyncconfig.json"
,
EteSyncConfig
)
#include "etesyncconfig.moc"
auto
group
=
config
()
->
group
(
myConfigGroupName
);
group
.
writeEntry
(
"Size"
,
size
);
}
resources/etesync/config
widget
.h
→
resources/etesync/
etesync
config.h
View file @
d3bb0249
...
...
@@ -15,31 +15,29 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CONFIG
WIDGET
_H
#define CONFIG
WIDGET
_H
#ifndef
ETESYNC
CONFIG_H
#define
ETESYNC
CONFIG_H
#include <QWidget>
#include <AkonadiCore/AgentConfigurationBase>
#include "ui_etesyncconfigwidget.h"
class
KConfigDialogManager
;
class
QLineEdit
;
class
QPushButton
;
class
Settings
;
class
ConfigWidget
:
public
QWidget
class
EteSyncConfig
:
public
Akonadi
::
AgentConfigurationBase
{
Q_OBJECT
public:
explicit
ConfigWidget
(
Settings
*
settings
,
QWidget
*
parent
);
explicit
EteSyncConfig
(
const
KSharedConfigPtr
&
config
,
QWidget
*
parent
,
const
QVariantList
&
args
);
void
load
();
void
save
()
const
;
bool
save
()
const
override
;
QSize
restoreDialogSize
()
const
override
;
void
saveDialogSize
(
const
QSize
&
size
)
override
;
private:
Ui
::
EteSyncConfigWidget
ui
;
KConfigDialogManager
*
mManager
=
nullptr
;
QLineEdit
*
mServerEdit
=
nullptr
;
QLineEdit
*
mUserEdit
=
nullptr
;
QLineEdit
*
mPasswordEdit
=
nullptr
;
QLineEdit
*
mEncryptionPasswordEdit
=
nullptr
;
};
AKONADI_AGENTCONFIG_FACTORY
(
EteSyncConfigFactory
,
"etesyncconfig.json"
,
EteSyncConfig
)
#endif
resources/etesync/configwidget.ui
→
resources/etesync/
etesync
configwidget.ui
View file @
d3bb0249
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
ConfigWidget
</class>
<class>
EteSync
ConfigWidget
</class>
<widget
class=
"QWidget"
name=
"ConfigWidget"
>
<property
name=
"geometry"
>
<rect>
...
...
resources/etesync/etesyncresource.cpp
View file @
d3bb0249
...
...
@@ -17,6 +17,7 @@
#include "etesyncresource.h"
#include <KLocalizedString>
#include <QDBusConnection>
#include "etesync_debug.h"
...
...
@@ -36,14 +37,7 @@ etesyncResource::etesyncResource(const QString &id)
Settings
::
self
(),
QDBusConnection
::
ExportAdaptors
);
serverUrl
=
Settings
::
self
()
->
baseUrl
();
username
=
Settings
::
self
()
->
username
();
password
=
Settings
::
self
()
->
password
();
encryptionPassword
=
Settings
::
self
()
->
encryptionPassword
();
/// TODO: Fix hack
QString
emptyStr
=
QStringLiteral
(
""
);
if
(
serverUrl
!=
emptyStr
&&
username
!=
emptyStr
&&
password
!=
emptyStr
&&
encryptionPassword
!=
emptyStr
)
initialise
();
setName
(
i18n
(
"EteSync Resource"
));
setNeedsNetwork
(
true
);
...
...
@@ -121,8 +115,8 @@ void etesyncResource::retrieveItems(const Akonadi::Collection &collection)
const
KContacts
::
Addressee
contact
=
converter
.
parseVCard
(
content
);
if
(
action
==
QStringLiteral
(
ETESYNC_SYNC_ENTRY_ACTION_ADD
)
||
action
==
QStringLiteral
(
ETESYNC_SYNC_ENTRY_ACTION_CHANGE
))
{
qCDebug
(
ETESYNC_LOG
)
<<
action
;
qCDebug
(
ETESYNC_LOG
)
<<
contact
.
uid
();
//
qCDebug(ETESYNC_LOG) << action;
//
qCDebug(ETESYNC_LOG) << contact.uid();
contacts
[
contact
.
uid
()]
=
contact
;
remoteIDs
[
contact
.
uid
()]
=
QStringFromCharArr
(
etesync_entry_get_uid
(
entry
));
}
else
if
(
action
==
QStringLiteral
(
ETESYNC_SYNC_ENTRY_ACTION_DELETE
))
{
...
...
@@ -166,6 +160,7 @@ void etesyncResource::aboutToQuit()
void
etesyncResource
::
onReloadConfiguration
()
{
Settings
::
self
()
->
load
();
serverUrl
=
Settings
::
self
()
->
baseUrl
();
username
=
Settings
::
self
()
->
username
();
password
=
Settings
::
self
()
->
password
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment