1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include <svx/AccessibilityCheckDialog.hxx>
#include <sfx2/AccessibilityIssue.hxx>
#include <utility>
#include <vcl/svapp.hxx>
namespace svx
{
AccessibilityCheckEntry::AccessibilityCheckEntry(
weld::Container* pParent, std::shared_ptr<sfx::AccessibilityIssue> const& rAccessibilityIssue)
: m_xBuilder(Application::CreateBuilder(pParent, "svx/ui/accessibilitycheckentry.ui"))
, m_xContainer(m_xBuilder->weld_container("accessibilityCheckEntryBox"))
, m_xLabel(m_xBuilder->weld_label("accessibilityCheckEntryLabel"))
, m_xGotoButton(m_xBuilder->weld_button("accessibilityCheckEntryGotoButton"))
, m_pAccessibilityIssue(rAccessibilityIssue)
{
m_xLabel->set_label(m_pAccessibilityIssue->m_aIssueText);
m_xGotoButton->set_visible(m_pAccessibilityIssue->canGotoIssue());
m_xGotoButton->connect_clicked(LINK(this, AccessibilityCheckEntry, GotoButtonClicked));
m_xContainer->show();
}
IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::Button&, void)
{
m_pAccessibilityIssue->gotoIssue();
}
AccessibilityCheckDialog::AccessibilityCheckDialog(
weld::Window* pParent, sfx::AccessibilityIssueCollection aIssueCollection,
std::function<sfx::AccessibilityIssueCollection()> getIssueCollection)
: GenericDialogController(pParent, "svx/ui/accessibilitycheckdialog.ui",
"AccessibilityCheckDialog")
, m_aIssueCollection(std::move(aIssueCollection))
, m_getIssueCollection(getIssueCollection)
, m_xAccessibilityCheckBox(m_xBuilder->weld_box("accessibilityCheckBox"))
, m_xRescanBtn(m_xBuilder->weld_button("rescan"))
{
m_xRescanBtn->connect_clicked(LINK(this, AccessibilityCheckDialog, RescanButtonClicked));
populateIssues();
}
AccessibilityCheckDialog::~AccessibilityCheckDialog() {}
void AccessibilityCheckDialog::populateIssues()
{
sal_Int32 i = 0;
for (std::shared_ptr<sfx::AccessibilityIssue> const& pIssue : m_aIssueCollection.getIssues())
{
auto xEntry
= std::make_unique<AccessibilityCheckEntry>(m_xAccessibilityCheckBox.get(), pIssue);
m_xAccessibilityCheckBox->reorder_child(xEntry->get_widget(), i++);
m_aAccessibilityCheckEntries.push_back(std::move(xEntry));
}
}
IMPL_LINK_NOARG(AccessibilityCheckDialog, RescanButtonClicked, weld::Button&, void)
{
// Remove old issue widgets
for (auto const& xEntry : m_aAccessibilityCheckEntries)
m_xAccessibilityCheckBox->move(xEntry->get_widget(), nullptr);
m_aIssueCollection = m_getIssueCollection();
populateIssues();
}
} // end svx namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|