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
|
/* -*- 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/dialog/ThemeDialog.hxx>
#include <docmodel/theme/ThemeColor.hxx>
#include <docmodel/theme/ColorSet.hxx>
#include <docmodel/theme/Theme.hxx>
#include <svx/ColorSets.hxx>
#include <vcl/svapp.hxx>
namespace svx
{
ThemeDialog::ThemeDialog(weld::Window* pParent, model::Theme* pTheme,
std::shared_ptr<IThemeColorChanger> const& pChanger)
: GenericDialogController(pParent, "svx/ui/themedialog.ui", "ThemeDialog")
, mpTheme(pTheme)
, mpChanger(pChanger)
, mxValueSetThemeColors(new svx::ThemeColorValueSet)
, mxValueSetThemeColorsWindow(
new weld::CustomWeld(*m_xBuilder, "valueset_theme_colors", *mxValueSetThemeColors))
{
mxValueSetThemeColors->SetColCount(2);
mxValueSetThemeColors->SetLineCount(6);
mxValueSetThemeColors->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor());
mxValueSetThemeColors->SetDoubleClickHdl(LINK(this, ThemeDialog, DoubleClickValueSetHdl));
if (mpTheme)
maColorSets.push_back(*mpTheme->GetColorSet());
auto const& rColorSetVector = ColorSets::get().getColorSetVector();
maColorSets.insert(maColorSets.end(), rColorSetVector.begin(), rColorSetVector.end());
for (auto const& rColorSet : maColorSets)
{
mxValueSetThemeColors->insert(rColorSet);
}
mxValueSetThemeColors->SetOptimalSize();
if (!rColorSetVector.empty())
mxValueSetThemeColors->SelectItem(1); // ItemId 1, position 0
}
ThemeDialog::~ThemeDialog() = default;
IMPL_LINK_NOARG(ThemeDialog, DoubleClickValueSetHdl, ValueSet*, void) { DoubleClickHdl(); }
void ThemeDialog::DoubleClickHdl()
{
sal_uInt32 nItemId = mxValueSetThemeColors->GetSelectedItemId();
if (!nItemId)
return;
sal_uInt32 nIndex = nItemId - 1;
if (nIndex < maColorSets.size())
{
model::ColorSet const& rColorSet = maColorSets[nIndex];
mpChanger->apply(rColorSet);
}
}
} // end svx namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|