Skip to content
GitLab
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
0743a81e
Commit
0743a81e
authored
Aug 03, 2022
by
Ingo Klöcker
Browse files
Create UI of Self Test dialog in code
GnuPG-bug-id: 6101
parent
e47dfe74
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
0743a81e
...
...
@@ -544,7 +544,6 @@ endif()
ki18n_wrap_ui
(
_kleopatra_SRCS
dialogs/ownertrustdialog.ui
dialogs/selectchecklevelwidget.ui
dialogs/selftestdialog.ui
dialogs/setinitialpindialog.ui
dialogs/trustchainwidget.ui
newcertificatewizard/listwidget.ui
...
...
src/dialogs/selftestdialog.cpp
View file @
0743a81e
...
...
@@ -11,9 +11,8 @@
#include
"selftestdialog.h"
#include
"ui_selftestdialog.h"
#include
<selftest/selftest.h>
#include
<utils/scrollarea.h>
#include
<Libkleo/SystemInfo>
...
...
@@ -21,9 +20,20 @@
#include
<KColorScheme>
#include
<QAbstractTableModel>
#include
<QApplication>
#include
<QCheckBox>
#include
<QDialog>
#include
<QDialogButtonBox>
#include
<QGroupBox>
#include
<QHBoxLayout>
#include
<QHeaderView>
#include
<QLabel>
#include
<QPushButton>
#include
<QSortFilterProxyModel>
#include
<QApplication>
#include
<QSplitter>
#include
<QTreeView>
#include
<QVBoxLayout>
#include
"kleopatra_debug.h"
...
...
@@ -234,6 +244,12 @@ public:
ui
.
detailsGB
->
hide
();
ui
.
proposedCorrectiveActionGB
->
hide
();
connect
(
ui
.
buttonBox
,
&
QDialogButtonBox
::
accepted
,
q
,
&
QDialog
::
accept
);
connect
(
ui
.
buttonBox
,
&
QDialogButtonBox
::
rejected
,
q
,
&
QDialog
::
reject
);
connect
(
ui
.
doItPB
,
&
QAbstractButton
::
clicked
,
q
,
[
this
]()
{
slotDoItClicked
();
});
connect
(
ui
.
rerunPB
,
&
QAbstractButton
::
clicked
,
q
,
&
SelfTestDialog
::
updateRequested
);
connect
(
ui
.
resultsTV
->
selectionModel
(),
SIGNAL
(
selectionChanged
(
QItemSelection
,
QItemSelection
)),
q
,
SLOT
(
slotSelectionChanged
()));
connect
(
ui
.
showAllCB
,
&
QAbstractButton
::
toggled
,
...
...
@@ -291,39 +307,145 @@ private:
Model
model
;
Proxy
proxy
;
struct
UI
:
public
Ui_SelfTestDialog
{
QPushButton
*
rerunPB
;
struct
UI
{
QTreeView
*
resultsTV
=
nullptr
;
QCheckBox
*
showAllCB
=
nullptr
;
QGroupBox
*
detailsGB
=
nullptr
;
QLabel
*
detailsLB
=
nullptr
;
QGroupBox
*
proposedCorrectiveActionGB
=
nullptr
;
QLabel
*
proposedCorrectiveActionLB
=
nullptr
;
QPushButton
*
doItPB
=
nullptr
;
QCheckBox
*
runAtStartUpCB
;
QDialogButtonBox
*
buttonBox
;
QPushButton
*
rerunPB
=
nullptr
;
explicit
UI
(
SelfTestDialog
*
qq
)
:
Ui_SelfTestDialog
(),
rerunPB
(
new
QPushButton
(
i18n
(
"Rerun Tests"
)))
{
setupUi
(
qq
);
auto
mainLayout
=
new
QVBoxLayout
{
qq
};
{
auto
label
=
new
QLabel
{
xi18n
(
"<para>These are the results of the Kleopatra self-test suite. Click on a test for details.</para>"
"<para>Note that all but the first failure might be due to prior tests failing.</para>"
),
qq
};
label
->
setWordWrap
(
true
);
mainLayout
->
addWidget
(
label
);
}
auto
splitter
=
new
QSplitter
{
qq
};
splitter
->
setOrientation
(
Qt
::
Vertical
);
{
auto
widget
=
new
QWidget
{
qq
};
auto
vbox
=
new
QVBoxLayout
{
widget
};
vbox
->
setContentsMargins
(
0
,
0
,
0
,
0
);
resultsTV
=
new
QTreeView
{
qq
};
QSizePolicy
sizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
);
sizePolicy
.
setHorizontalStretch
(
0
);
sizePolicy
.
setVerticalStretch
(
1
);
sizePolicy
.
setHeightForWidth
(
resultsTV
->
sizePolicy
().
hasHeightForWidth
());
resultsTV
->
setSizePolicy
(
sizePolicy
);
resultsTV
->
setMinimumHeight
(
100
);
resultsTV
->
setRootIsDecorated
(
false
);
resultsTV
->
setAllColumnsShowFocus
(
true
);
vbox
->
addWidget
(
resultsTV
);
showAllCB
=
new
QCheckBox
{
i18nc
(
"@option:check"
,
"Show all test results"
),
qq
};
showAllCB
->
setChecked
(
true
);
vbox
->
addWidget
(
showAllCB
);
splitter
->
addWidget
(
widget
);
}
{
detailsGB
=
new
QGroupBox
{
i18nc
(
"@title:group"
,
"Details"
),
qq
};
auto
groupBoxLayout
=
new
QVBoxLayout
{
detailsGB
};
auto
scrollArea
=
new
Kleo
::
ScrollArea
{
qq
};
scrollArea
->
setMinimumHeight
(
100
);
scrollArea
->
setFrameShape
(
QFrame
::
NoFrame
);
scrollArea
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
auto
scrollAreaLayout
=
qobject_cast
<
QBoxLayout
*>
(
scrollArea
->
widget
()
->
layout
());
scrollAreaLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
detailsLB
=
new
QLabel
{
qq
};
detailsLB
->
setTextFormat
(
Qt
::
RichText
);
detailsLB
->
setTextInteractionFlags
(
Qt
::
TextSelectableByMouse
);
detailsLB
->
setWordWrap
(
true
);
scrollAreaLayout
->
addWidget
(
detailsLB
);
groupBoxLayout
->
addWidget
(
scrollArea
);
splitter
->
addWidget
(
detailsGB
);
}
{
proposedCorrectiveActionGB
=
new
QGroupBox
{
i18nc
(
"@title:group"
,
"Proposed Corrective Action"
),
qq
};
auto
groupBoxLayout
=
new
QVBoxLayout
{
proposedCorrectiveActionGB
};
buttonBox
->
addButton
(
rerunPB
,
QDialogButtonBox
::
ActionRole
);
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setText
(
i18n
(
"Continue"
));
auto
scrollArea
=
new
Kleo
::
ScrollArea
{
qq
};
scrollArea
->
setMinimumHeight
(
100
);
scrollArea
->
setFrameShape
(
QFrame
::
NoFrame
);
scrollArea
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
auto
scrollAreaLayout
=
qobject_cast
<
QBoxLayout
*>
(
scrollArea
->
widget
()
->
layout
());
scrollAreaLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
connect
(
rerunPB
,
&
QAbstractButton
::
clicked
,
qq
,
&
SelfTestDialog
::
updateRequested
);
proposedCorrectiveActionLB
=
new
QLabel
{
qq
};
proposedCorrectiveActionLB
->
setTextFormat
(
Qt
::
RichText
);
proposedCorrectiveActionLB
->
setTextInteractionFlags
(
Qt
::
TextSelectableByMouse
);
proposedCorrectiveActionLB
->
setWordWrap
(
true
);
scrollAreaLayout
->
addWidget
(
proposedCorrectiveActionLB
);
groupBoxLayout
->
addWidget
(
scrollArea
);
{
auto
hbox
=
new
QHBoxLayout
;
hbox
->
addStretch
();
doItPB
=
new
QPushButton
{
i18nc
(
"@action:button"
,
"Do It"
),
qq
};
doItPB
->
setEnabled
(
false
);
hbox
->
addWidget
(
doItPB
);
groupBoxLayout
->
addLayout
(
hbox
);
}
splitter
->
addWidget
(
proposedCorrectiveActionGB
);
}
mainLayout
->
addWidget
(
splitter
);
runAtStartUpCB
=
new
QCheckBox
{
i18nc
(
"@option:check"
,
"Run these tests at startup"
),
qq
};
runAtStartUpCB
->
setChecked
(
true
);
mainLayout
->
addWidget
(
runAtStartUpCB
);
buttonBox
=
new
QDialogButtonBox
{
qq
};
buttonBox
->
setStandardButtons
(
QDialogButtonBox
::
Cancel
|
QDialogButtonBox
::
Close
|
QDialogButtonBox
::
Ok
);
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setText
(
i18nc
(
"@action:button"
,
"Continue"
));
rerunPB
=
buttonBox
->
addButton
(
i18nc
(
"@action:button"
,
"Rerun Tests"
),
QDialogButtonBox
::
ActionRole
);
mainLayout
->
addWidget
(
buttonBox
);
}
}
ui
;
};
SelfTestDialog
::
SelfTestDialog
(
QWidget
*
p
,
Qt
::
WindowFlags
f
)
:
QDialog
(
p
,
f
),
d
(
new
Private
(
this
))
:
SelfTestDialog
{{},
p
,
f
}
{
setAutomaticMode
(
false
);
}
SelfTestDialog
::
SelfTestDialog
(
const
std
::
vector
<
std
::
shared_ptr
<
SelfTest
>>
&
tests
,
QWidget
*
p
,
Qt
::
WindowFlags
f
)
:
QDialog
(
p
,
f
),
d
(
new
Private
(
this
))
{
setWindowTitle
(
i18nc
(
"@title:window"
,
"Self Test"
));
resize
(
448
,
610
);
addSelfTests
(
tests
);
setAutomaticMode
(
false
);
}
SelfTestDialog
::~
SelfTestDialog
()
{}
SelfTestDialog
::~
SelfTestDialog
()
=
default
;
void
SelfTestDialog
::
clear
()
{
...
...
src/dialogs/selftestdialog.h
View file @
0743a81e
...
...
@@ -51,7 +51,6 @@ private:
class
Private
;
kdtools
::
pimpl_ptr
<
Private
>
d
;
Q_PRIVATE_SLOT
(
d
,
void
slotSelectionChanged
())
Q_PRIVATE_SLOT
(
d
,
void
slotDoItClicked
())
};
}
...
...
src/dialogs/selftestdialog.ui
deleted
100644 → 0
View file @
e47dfe74
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
SelfTestDialog
</class>
<widget
class=
"QDialog"
name=
"SelfTestDialog"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
448
</width>
<height>
610
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Kleopatra Self-Test Results
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_6"
>
<property
name=
"sizeConstraint"
>
<enum>
QLayout::SetMinimumSize
</enum>
</property>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string
comment=
"@info"
>
<
p
>
These are the results of the Kleopatra self-test suite. Click on a test for details.
<
/p
><
p
>
Note that all but the first failure might be due to prior tests failing.
<
/p
>
</string>
</property>
<property
name=
"wordWrap"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QSplitter"
name=
"splitter"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<widget
class=
"QWidget"
name=
"layoutWidget"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_5"
>
<item>
<widget
class=
"QTreeView"
name=
"resultsTV"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Expanding"
>
<horstretch>
0
</horstretch>
<verstretch>
1
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
100
</height>
</size>
</property>
<property
name=
"rootIsDecorated"
>
<bool>
false
</bool>
</property>
<property
name=
"allColumnsShowFocus"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"showAllCB"
>
<property
name=
"text"
>
<string>
Show all test results
</string>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
<property
name=
"tristate"
>
<bool>
false
</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QGroupBox"
name=
"detailsGB"
>
<property
name=
"title"
>
<string>
Details
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
>
<item>
<widget
class=
"Kleo::ScrollArea"
name=
"scrollArea_2"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
100
</height>
</size>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<widget
class=
"QWidget"
name=
"scrollAreaWidgetContents_2"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
336
</width>
<height>
100
</height>
</rect>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_4"
>
<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=
"detailsLB"
>
<property
name=
"textFormat"
>
<enum>
Qt::RichText
</enum>
</property>
<property
name=
"textInteractionFlags"
>
<enum>
Qt::TextSelectableByMouse
</enum>
</property>
<property
name=
"wordWrap"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QGroupBox"
name=
"proposedCorrectiveActionGB"
>
<property
name=
"title"
>
<string>
Proposed Corrective Action
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<widget
class=
"Kleo::ScrollArea"
name=
"scrollArea"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
100
</height>
</size>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<widget
class=
"QWidget"
name=
"scrollAreaWidgetContents"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
336
</width>
<height>
100
</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=
"proposedCorrectiveActionLB"
>
<property
name=
"textFormat"
>
<enum>
Qt::RichText
</enum>
</property>
<property
name=
"wordWrap"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<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>
<item>
<widget
class=
"QPushButton"
name=
"doItPB"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string>
Do It
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"runAtStartUpCB"
>
<property
name=
"text"
>
<string>
Run these tests at startup
</string>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QDialogButtonBox"
name=
"buttonBox"
>
<property
name=
"standardButtons"
>
<set>
QDialogButtonBox::Cancel|QDialogButtonBox::Close|QDialogButtonBox::Ok
</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>
Kleo::ScrollArea
</class>
<extends>
QScrollArea
</extends>
<header>
utils/scrollarea.h
</header>
<container>
1
</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>
buttonBox
</sender>
<signal>
accepted()
</signal>
<receiver>
SelfTestDialog
</receiver>
<slot>
accept()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
236
</x>
<y>
490
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
157
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
buttonBox
</sender>
<signal>
rejected()
</signal>
<receiver>
SelfTestDialog
</receiver>
<slot>
reject()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
304
</x>
<y>
490
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
286
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
doItPB
</sender>
<signal>
clicked()
</signal>
<receiver>
SelfTestDialog
</receiver>
<slot>
slotDoItClicked()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
354
</x>
<y>
398
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
375
</x>
<y>
304
</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>
slotDoItClicked()
</slot>
</slots>
</ui>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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