mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:57:46 +00:00
CertificateSettings: Update to be more consistent with other settings
This commit is contained in:
parent
0060b8c4e5
commit
ef5cca71dc
5 changed files with 8 additions and 9 deletions
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Fabian Dellwing <fabian@dellwing.net>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/Model.h>
|
||||
#include <LibGUI/SettingsWindow.h>
|
||||
#include <LibGUI/SortingProxyModel.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
#include <LibTLS/Certificate.h>
|
||||
|
||||
namespace CertificateSettings {
|
||||
|
||||
class CertificateStoreProxyModel : public GUI::SortingProxyModel {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<CertificateStoreProxyModel>> create(NonnullRefPtr<Model> source, NonnullRefPtr<GUI::TableView> view)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) CertificateStoreProxyModel(move(source), move(view)));
|
||||
}
|
||||
virtual void sort(int column, GUI::SortOrder) override;
|
||||
|
||||
private:
|
||||
CertificateStoreProxyModel(NonnullRefPtr<Model> source, NonnullRefPtr<GUI::TableView> view)
|
||||
: SortingProxyModel(move(source))
|
||||
, m_parent_table_view(move(view)) {};
|
||||
|
||||
NonnullRefPtr<GUI::TableView> m_parent_table_view;
|
||||
};
|
||||
|
||||
class CertificateStoreModel : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
IssuedTo,
|
||||
IssuedBy,
|
||||
Expire,
|
||||
__Count
|
||||
};
|
||||
|
||||
static NonnullRefPtr<CertificateStoreModel> create();
|
||||
virtual ~CertificateStoreModel() override = default;
|
||||
|
||||
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return m_certificates.size(); }
|
||||
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
virtual DeprecatedString column_name(int) const override;
|
||||
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
|
||||
virtual ErrorOr<void> load();
|
||||
virtual ErrorOr<size_t> add(Vector<Certificate> const&);
|
||||
virtual Certificate get(int index);
|
||||
|
||||
private:
|
||||
Vector<Certificate> m_certificates;
|
||||
};
|
||||
|
||||
class CertificateStoreWidget : public GUI::SettingsWindow::Tab {
|
||||
C_OBJECT_ABSTRACT(CertStoreWidget)
|
||||
public:
|
||||
virtual ~CertificateStoreWidget() override = default;
|
||||
static ErrorOr<NonnullRefPtr<CertificateStoreWidget>> try_create();
|
||||
virtual void apply_settings() override {};
|
||||
|
||||
private:
|
||||
CertificateStoreWidget() = default;
|
||||
ErrorOr<void> initialize();
|
||||
ErrorOr<void> import_pem();
|
||||
ErrorOr<void> export_pem();
|
||||
|
||||
RefPtr<CertificateStoreModel> m_root_ca_model;
|
||||
RefPtr<CertificateStoreProxyModel> m_root_ca_proxy_model;
|
||||
RefPtr<GUI::TableView> m_root_ca_tableview;
|
||||
RefPtr<GUI::Button> m_import_ca_button;
|
||||
RefPtr<GUI::Button> m_export_ca_button;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue