Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Plasma applet for NetworkManager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
Plasma applet for NetworkManager
Commits
003ce1d5
Commit
003ce1d5
authored
Oct 03, 2017
by
Jan Grulich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ask to save modified connection when selecting another one
BUG:381158
parent
559693ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
24 deletions
+64
-24
kcm/kcm.cpp
kcm/kcm.cpp
+43
-16
kcm/kcm.h
kcm/kcm.h
+3
-1
kcm/qml/ConnectionItem.qml
kcm/qml/ConnectionItem.qml
+2
-3
kcm/qml/main.qml
kcm/qml/main.qml
+16
-4
No files found.
kcm/kcm.cpp
View file @
003ce1d5
...
...
@@ -27,6 +27,7 @@
#include "vpnuiplugin.h"
// KDE
#include <KMessageBox>
#include <KPluginFactory>
#include <KSharedConfig>
#include <kdeclarative/kdeclarative.h>
...
...
@@ -83,6 +84,7 @@ KCMNetworkmanagement::KCMNetworkmanagement(QWidget *parent, const QVariantList &
m_quickView
->
rootContext
()
->
setContextProperty
(
"baseColor"
,
mainWidget
->
palette
().
color
(
QPalette
::
Active
,
QPalette
::
Base
));
m_quickView
->
rootContext
()
->
setContextProperty
(
"highlightColor"
,
mainWidget
->
palette
().
color
(
QPalette
::
Active
,
QPalette
::
Highlight
));
m_quickView
->
rootContext
()
->
setContextProperty
(
"textColor"
,
mainWidget
->
palette
().
color
(
QPalette
::
Active
,
QPalette
::
Text
));
m_quickView
->
rootContext
()
->
setContextProperty
(
"connectionModified"
,
false
);
m_quickView
->
setResizeMode
(
QQuickView
::
SizeRootObjectToView
);
m_quickView
->
setSource
(
QUrl
::
fromLocalFile
(
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"kcm_networkmanagement/qml/main.qml"
))));
...
...
@@ -90,6 +92,7 @@ KCMNetworkmanagement::KCMNetworkmanagement(QWidget *parent, const QVariantList &
connect
(
rootItem
,
SIGNAL
(
selectedConnectionChanged
(
QString
)),
this
,
SLOT
(
onSelectedConnectionChanged
(
QString
)));
connect
(
rootItem
,
SIGNAL
(
requestCreateConnection
(
int
,
QString
,
QString
,
bool
)),
this
,
SLOT
(
onRequestCreateConnection
(
int
,
QString
,
QString
,
bool
)));
connect
(
rootItem
,
SIGNAL
(
requestExportConnection
(
QString
)),
this
,
SLOT
(
onRequestExportConnection
(
QString
)));
connect
(
rootItem
,
SIGNAL
(
requestToChangeConnection
(
QString
,
QString
)),
this
,
SLOT
(
onRequestToChangeConnection
(
QString
,
QString
)));
QVBoxLayout
*
l
=
new
QVBoxLayout
(
this
);
l
->
addWidget
(
mainWidget
);
...
...
@@ -204,6 +207,8 @@ void KCMNetworkmanagement::save()
m_handler
->
updateConnection
(
connection
,
m_tabWidget
->
setting
());
}
kcmChanged
(
false
);
KCModule
::
save
();
}
...
...
@@ -369,6 +374,21 @@ void KCMNetworkmanagement::onRequestExportConnection(const QString &connectionPa
}
}
void
KCMNetworkmanagement
::
onRequestToChangeConnection
(
const
QString
&
connectionName
,
const
QString
&
connectionPath
)
{
NetworkManager
::
Connection
::
Ptr
connection
=
NetworkManager
::
findConnection
(
m_currentConnectionPath
);
if
(
connection
)
{
if
(
KMessageBox
::
questionYesNo
(
this
,
i18n
(
"Do you want to save changes made to the connection '%1'?"
,
connection
->
name
()),
i18n
(
"Save changes"
),
KStandardGuiItem
::
save
(),
KStandardGuiItem
::
discard
(),
QString
(),
KMessageBox
::
Notify
)
==
KMessageBox
::
Yes
)
{
save
();
}
}
QObject
*
rootItem
=
m_quickView
->
rootObject
();
QMetaObject
::
invokeMethod
(
rootItem
,
"selectConnection"
,
Q_ARG
(
QVariant
,
connectionName
),
Q_ARG
(
QVariant
,
connectionPath
));
}
void
KCMNetworkmanagement
::
onSelectedConnectionChanged
(
const
QString
&
connectionPath
)
{
if
(
connectionPath
.
isEmpty
())
{
...
...
@@ -404,6 +424,12 @@ void KCMNetworkmanagement::addConnection(const NetworkManager::ConnectionSetting
editor
->
show
();
}
void
KCMNetworkmanagement
::
kcmChanged
(
bool
kcmChanged
)
{
m_quickView
->
rootContext
()
->
setContextProperty
(
"connectionModified"
,
kcmChanged
);
Q_EMIT
changed
(
kcmChanged
);
}
void
KCMNetworkmanagement
::
loadConnectionSettings
(
const
NetworkManager
::
ConnectionSettings
::
Ptr
&
connectionSettings
)
{
if
(
m_tabWidget
)
{
...
...
@@ -413,33 +439,20 @@ void KCMNetworkmanagement::loadConnectionSettings(const NetworkManager::Connecti
connect
(
m_tabWidget
,
&
ConnectionEditorTabWidget
::
settingChanged
,
[
this
]
()
{
if
(
m_tabWidget
->
isInitialized
()
&&
m_tabWidget
->
isValid
())
{
Q_EMIT
c
hanged
(
true
);
kcmC
hanged
(
true
);
}
});
connect
(
m_tabWidget
,
&
ConnectionEditorTabWidget
::
validityChanged
,
[
this
]
(
bool
valid
)
{
if
(
m_tabWidget
->
isInitialized
())
{
Q_EMIT
c
hanged
(
valid
);
kcmC
hanged
(
valid
);
}
});
QVBoxLayout
*
layout
=
new
QVBoxLayout
(
m_ui
->
connectionConfiguration
);
layout
->
addWidget
(
m_tabWidget
);
}
Q_EMIT
changed
(
false
);
}
void
KCMNetworkmanagement
::
resetSelection
()
{
// Reset selected connections
m_currentConnectionPath
.
clear
();
QObject
*
rootItem
=
m_quickView
->
rootObject
();
QMetaObject
::
invokeMethod
(
rootItem
,
"deselectConnections"
);
if
(
m_tabWidget
)
{
delete
m_ui
->
connectionConfiguration
->
layout
();
delete
m_tabWidget
;
m_tabWidget
=
nullptr
;
}
Q_EMIT
changed
(
false
);
kcmChanged
(
false
);
}
void
KCMNetworkmanagement
::
importVpn
()
...
...
@@ -495,4 +508,18 @@ void KCMNetworkmanagement::importVpn()
}
}
void
KCMNetworkmanagement
::
resetSelection
()
{
// Reset selected connections
m_currentConnectionPath
.
clear
();
QObject
*
rootItem
=
m_quickView
->
rootObject
();
QMetaObject
::
invokeMethod
(
rootItem
,
"deselectConnections"
);
if
(
m_tabWidget
)
{
delete
m_ui
->
connectionConfiguration
->
layout
();
delete
m_tabWidget
;
m_tabWidget
=
nullptr
;
}
Q_EMIT
changed
(
false
);
}
#include "kcm.moc"
kcm/kcm.h
View file @
003ce1d5
...
...
@@ -46,12 +46,14 @@ private Q_SLOTS:
void
onSelectedConnectionChanged
(
const
QString
&
connectionPath
);
void
onRequestCreateConnection
(
int
connectionType
,
const
QString
&
vpnType
,
const
QString
&
specificType
,
bool
shared
);
void
onRequestExportConnection
(
const
QString
&
connectionPath
);
void
onRequestToChangeConnection
(
const
QString
&
connectionName
,
const
QString
&
connectionPath
);
private:
void
addConnection
(
const
NetworkManager
::
ConnectionSettings
::
Ptr
&
connectionSettings
);
void
importVpn
();
void
kcmChanged
(
bool
kcmChanged
);
void
loadConnectionSettings
(
const
NetworkManager
::
ConnectionSettings
::
Ptr
&
connectionSettings
);
void
resetSelection
();
void
importVpn
();
QString
m_currentConnectionPath
;
QString
m_createdConnectionUuid
;
...
...
kcm/qml/ConnectionItem.qml
View file @
003ce1d5
...
...
@@ -30,6 +30,7 @@ ListItem {
checked
:
mouseArea
.
containsMouse
||
ConnectionPath
===
connectionView
.
currentConnectionPath
height
:
connectionItemBase
.
height
signal
aboutToChangeConnection
(
bool
exportable
,
string
name
,
string
path
)
signal
aboutToExportConnection
(
string
path
)
signal
aboutToRemoveConnection
(
string
name
,
string
path
)
...
...
@@ -146,9 +147,7 @@ ListItem {
onClicked
:
{
if
(
mouse
.
button
===
Qt
.
LeftButton
)
{
connectionView
.
currentConnectionExportable
=
KcmVpnConnectionExportable
connectionView
.
currentConnectionName
=
Name
connectionView
.
currentConnectionPath
=
ConnectionPath
aboutToChangeConnection
(
KcmVpnConnectionExportable
,
Name
,
ConnectionPath
)
}
else
if
(
mouse
.
button
==
Qt
.
RightButton
)
{
connectionItemMenu
.
open
(
mouse
.
x
,
mouse
.
y
)
}
...
...
kcm/qml/main.qml
View file @
003ce1d5
...
...
@@ -34,6 +34,7 @@ Item {
signal
selectedConnectionChanged
(
string
connection
)
signal
requestCreateConnection
(
int
type
,
string
vpnType
,
string
specificType
,
bool
shared
)
signal
requestExportConnection
(
string
connection
)
signal
requestToChangeConnection
(
string
name
,
string
path
)
Rectangle
{
id
:
background
...
...
@@ -98,15 +99,26 @@ Item {
section.property
:
"
KcmConnectionType
"
section.delegate
:
Header
{
text
:
section
}
delegate
:
ConnectionItem
{
onAboutToRemoveConnection
:
{
deleteConfirmationDialog
.
connectionName
=
name
deleteConfirmationDialog
.
connectionPath
=
path
deleteConfirmationDialog
.
open
()
onAboutToChangeConnection
:
{
// Shouldn't be problem to set this in advance
connectionView
.
currentConnectionExportable
=
exportable
if
(
connectionModified
)
{
requestToChangeConnection
(
name
,
path
)
}
else
{
connectionView
.
currentConnectionName
=
name
connectionView
.
currentConnectionPath
=
path
}
}
onAboutToExportConnection
:
{
requestExportConnection
(
path
)
}
onAboutToRemoveConnection
:
{
deleteConfirmationDialog
.
connectionName
=
name
deleteConfirmationDialog
.
connectionPath
=
path
deleteConfirmationDialog
.
open
()
}
}
onCurrentConnectionPathChanged
:
{
...
...
Write
Preview
Markdown
is supported
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