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
Kleopatra
Commits
29a6e85e
Commit
29a6e85e
authored
Feb 02, 2021
by
Ingo Klöcker
Browse files
Add dialog showing the keys of a group of keys
GnuPG-bug-id: 5175
parent
fe8ea25f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
29a6e85e
...
...
@@ -149,6 +149,7 @@ set(_kleopatra_SRCS
dialogs/pivcardapplicationadministrationkeyinputdialog.cpp
dialogs/certificatedetailsinputwidget.cpp
dialogs/createcsrforcardkeydialog.cpp
dialogs/groupdetailsdialog.cpp
crypto/controller.cpp
crypto/certificateresolver.cpp
...
...
src/dialogs/groupdetailsdialog.cpp
0 → 100644
View file @
29a6e85e
/*
dialogs/groupdetailsdialog.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "groupdetailsdialog.h"
#include "commands/detailscommand.h"
#include "view/keytreeview.h"
#include <Libkleo/KeyGroup>
#include <Libkleo/KeyListModel>
#include <KConfigGroup>
#include <KGuiItem>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KStandardGuiItem>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QTreeView>
#include <QVBoxLayout>
#include "kleopatra_debug.h"
using
namespace
Kleo
;
using
namespace
Kleo
::
Commands
;
using
namespace
Kleo
::
Dialogs
;
Q_DECLARE_METATYPE
(
GpgME
::
Key
)
class
GroupDetailsDialog
::
Private
{
friend
class
::
Kleo
::
Dialogs
::
GroupDetailsDialog
;
GroupDetailsDialog
*
const
q
;
struct
{
QLabel
*
groupNameLabel
=
nullptr
;
KeyTreeView
*
treeView
=
nullptr
;
QDialogButtonBox
*
buttonBox
=
nullptr
;
}
ui
;
KeyGroup
group
;
public:
Private
(
GroupDetailsDialog
*
qq
)
:
q
(
qq
)
{
auto
mainLayout
=
new
QVBoxLayout
(
q
);
ui
.
groupNameLabel
=
new
QLabel
();
ui
.
groupNameLabel
->
setWordWrap
(
true
);
mainLayout
->
addWidget
(
ui
.
groupNameLabel
);
ui
.
treeView
=
new
KeyTreeView
(
q
);
ui
.
treeView
->
view
()
->
setRootIsDecorated
(
false
);
ui
.
treeView
->
view
()
->
setSelectionMode
(
QAbstractItemView
::
SingleSelection
);
ui
.
treeView
->
setFlatModel
(
AbstractKeyListModel
::
createFlatKeyListModel
(
ui
.
treeView
));
ui
.
treeView
->
setHierarchicalView
(
false
);
connect
(
ui
.
treeView
->
view
(),
&
QAbstractItemView
::
doubleClicked
,
q
,
[
this
]
(
const
QModelIndex
&
index
)
{
showKeyDetails
(
index
);
});
mainLayout
->
addWidget
(
ui
.
treeView
);
ui
.
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Close
);
KGuiItem
::
assign
(
ui
.
buttonBox
->
button
(
QDialogButtonBox
::
Close
),
KStandardGuiItem
::
close
());
connect
(
ui
.
buttonBox
,
&
QDialogButtonBox
::
clicked
,
q
,
&
QDialog
::
close
);
mainLayout
->
addWidget
(
ui
.
buttonBox
);
// calculate default size with enough space for the key list
const
auto
fm
=
ui
.
treeView
->
fontMetrics
();
const
QSize
sizeHint
=
q
->
sizeHint
();
const
QSize
defaultSize
=
QSize
(
qMax
(
sizeHint
.
width
(),
150
*
fm
.
horizontalAdvance
(
QLatin1Char
(
'x'
))),
sizeHint
.
height
()
-
ui
.
treeView
->
sizeHint
().
height
()
+
20
*
fm
.
lineSpacing
());
restoreLayout
(
defaultSize
);
}
~
Private
()
{
saveLayout
();
}
private:
void
saveLayout
()
{
KConfigGroup
configGroup
(
KSharedConfig
::
openConfig
(),
"GroupDetailsDialog"
);
ui
.
treeView
->
saveLayout
(
configGroup
);
configGroup
.
writeEntry
(
"Size"
,
q
->
size
());
configGroup
.
sync
();
}
void
restoreLayout
(
const
QSize
&
defaultSize
)
{
const
KConfigGroup
configGroup
(
KSharedConfig
::
openConfig
(),
"GroupDetailsDialog"
);
ui
.
treeView
->
restoreLayout
(
configGroup
);
const
QSize
size
=
configGroup
.
readEntry
(
"Size"
,
defaultSize
);
if
(
size
.
isValid
())
{
q
->
resize
(
size
);
}
}
void
showKeyDetails
(
const
QModelIndex
&
index
)
{
const
GpgME
::
Key
key
=
ui
.
treeView
->
view
()
->
model
()
->
data
(
index
,
KeyList
::
KeyRole
).
value
<
GpgME
::
Key
>
();
if
(
!
key
.
isNull
())
{
auto
cmd
=
new
DetailsCommand
(
key
,
nullptr
);
cmd
->
setParentWidget
(
q
);
cmd
->
start
();
}
}
};
GroupDetailsDialog
::
GroupDetailsDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
)
,
d
(
new
Private
(
this
))
{
setWindowTitle
(
i18nc
(
"@title:window"
,
"Group Details"
));
}
GroupDetailsDialog
::~
GroupDetailsDialog
()
{
}
void
GroupDetailsDialog
::
setGroup
(
const
KeyGroup
&
group
)
{
d
->
group
=
group
;
d
->
ui
.
groupNameLabel
->
setText
(
group
.
name
());
d
->
ui
.
treeView
->
setKeys
(
group
.
keys
());
}
src/dialogs/groupdetailsdialog.h
0 → 100644
View file @
29a6e85e
/*
dialogs/groupdetailsdialog.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __KLEOPATRA_DIALOGS_GROUPDETAILSDIALOG_H__
#define __KLEOPATRA_DIALOGS_GROUPDETAILSDIALOG_H__
#include <QDialog>
namespace
Kleo
{
class
KeyGroup
;
namespace
Dialogs
{
class
GroupDetailsDialog
:
public
QDialog
{
Q_OBJECT
public:
explicit
GroupDetailsDialog
(
QWidget
*
parent
=
nullptr
);
~
GroupDetailsDialog
()
override
;
void
setGroup
(
const
Kleo
::
KeyGroup
&
group
);
private:
class
Private
;
const
std
::
unique_ptr
<
Private
>
d
;
};
}
}
#endif // __KLEOPATRA_DIALOGS_GROUPDETAILSDIALOG_H__
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