Commit 67886a3f authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Create UI of Subkeys widget in code

GnuPG-bug-id: 6104
parent 020b8ecd
......@@ -550,7 +550,6 @@ ki18n_wrap_ui(_kleopatra_SRCS
dialogs/selectchecklevelwidget.ui
dialogs/selftestdialog.ui
dialogs/setinitialpindialog.ui
dialogs/subkeyswidget.ui
dialogs/trustchainwidget.ui
newcertificatewizard/listwidget.ui
)
......
......@@ -14,7 +14,6 @@
#include <config-kleopatra.h>
#include "subkeyswidget.h"
#include "ui_subkeyswidget.h"
#include "commands/changeexpirycommand.h"
#ifdef QGPGME_SUPPORTS_SECRET_SUBKEY_EXPORT
......@@ -24,17 +23,22 @@
#include "commands/importpaperkeycommand.h"
#include "exportdialog.h"
#include <gpgme++/key.h>
#include <gpgme++/context.h>
#include <Libkleo/Formatting>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QPushButton>
#include <QTreeWidgetItem>
#include <QMenu>
#include <QVBoxLayout>
#include <Libkleo/Formatting>
#include <gpgme++/context.h>
#include <gpgme++/key.h>
Q_DECLARE_METATYPE(GpgME::Subkey)
......@@ -43,21 +47,68 @@ using namespace Kleo::Commands;
class SubKeysWidget::Private
{
SubKeysWidget *const q;
public:
Private(SubKeysWidget *q)
: q(q)
Private(SubKeysWidget *qq)
: q{qq}
, ui{qq}
{
ui.setupUi(q);
ui.subkeysTree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui.subkeysTree, &QAbstractItemView::customContextMenuRequested,
q, [this](const QPoint &p) { tableContextMenuRequested(p); });
}
GpgME::Key key;
Ui::SubKeysWidget ui;
void tableContextMenuRequested(const QPoint &p);
private:
SubKeysWidget *const q;
void tableContextMenuRequested(const QPoint &p);
public:
GpgME::Key key;
public:
struct UI {
QVBoxLayout *mainLayout;
QTreeWidget *subkeysTree;
QLabel *stored;
UI(QWidget *widget)
{
mainLayout = new QVBoxLayout{widget};
mainLayout->setContentsMargins(0, 0, 0, 0);
auto subkeysTreeLabel = new QLabel{i18nc("@label", "Subkeys:"), widget};
mainLayout->addWidget(subkeysTreeLabel);
subkeysTree = new QTreeWidget{widget};
subkeysTreeLabel->setBuddy(subkeysTree);
subkeysTree->setRootIsDecorated(false);
subkeysTree->setHeaderLabels({
i18nc("@title:column", "ID"),
i18nc("@title:column", "Type"),
i18nc("@title:column", "Valid From"),
i18nc("@title:column", "Valid Until"),
i18nc("@title:column", "Status"),
i18nc("@title:column", "Strength"),
i18nc("@title:column", "Usage"),
i18nc("@title:column", "Primary"),
});
mainLayout->addWidget(subkeysTree);
{
auto hbox = new QHBoxLayout;
auto label = new QLabel{i18nc("@label", "Stored:"), widget};
hbox->addWidget(label);
stored = new QLabel{i18nc("@", "unknown"), widget};
label->setBuddy(stored);
hbox->addWidget(stored);
hbox->addStretch();
mainLayout->addLayout(hbox);
}
}
} ui;
};
void SubKeysWidget::Private::tableContextMenuRequested(const QPoint &p)
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SubKeysWidget</class>
<widget class="QWidget" name="SubKeysWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>740</width>
<height>200</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Subkeys:</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="subkeysTree">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
<column>
<property name="text">
<string>Valid From</string>
</property>
</column>
<column>
<property name="text">
<string>Valid Until</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Strength</string>
</property>
</column>
<column>
<property name="text">
<string>Usage</string>
</property>
</column>
<column>
<property name="text">
<string>Primary</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="stored">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="storedLbl">
<property name="text">
<string>Stored:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Supports Markdown
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