tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / optdlg / opredlin.cxx
blob650e5b78fb12104e44c29a9e0784c9ca5f06921d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #undef SC_DLLIMPLEMENTATION
22 #include <svx/colorbox.hxx>
24 #include <appoptio.hxx>
25 #include <scmod.hxx>
26 #include <docsh.hxx>
27 #include <svx/svxids.hrc>
28 #include <officecfg/Office/Calc.hxx>
30 #include <opredlin.hxx>
32 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
33 : SfxTabPage(pPage, pController, u"modules/scalc/ui/optchangespage.ui"_ustr, u"OptChangesPage"_ustr, &rSet)
34 , m_xContentColorLB(new ColorListBox(m_xBuilder->weld_menu_button(u"changes"_ustr),
35 [this]{ return GetDialogController()->getDialog(); }))
36 , m_xContentColorImg(m_xBuilder->weld_widget(u"lockchanges"_ustr))
37 , m_xRemoveColorLB(new ColorListBox(m_xBuilder->weld_menu_button(u"deletions"_ustr),
38 [this]{ return GetDialogController()->getDialog(); }))
39 , m_xRemoveColorImg(m_xBuilder->weld_widget(u"lockdeletions"_ustr))
40 , m_xInsertColorLB(new ColorListBox(m_xBuilder->weld_menu_button(u"entries"_ustr),
41 [this]{ return GetDialogController()->getDialog(); }))
42 , m_xInsertColorImg(m_xBuilder->weld_widget(u"lockentries"_ustr))
43 , m_xMoveColorLB(new ColorListBox(m_xBuilder->weld_menu_button(u"insertions"_ustr),
44 [this]{ return GetDialogController()->getDialog(); }))
45 , m_xMoveColorImg(m_xBuilder->weld_widget(u"lockinsertions"_ustr))
47 m_xContentColorLB->SetSlotId(SID_AUTHOR_COLOR);
48 m_xRemoveColorLB->SetSlotId(SID_AUTHOR_COLOR);
49 m_xInsertColorLB->SetSlotId(SID_AUTHOR_COLOR);
50 m_xMoveColorLB->SetSlotId(SID_AUTHOR_COLOR);
53 ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
55 m_xContentColorLB.reset();
56 m_xRemoveColorLB.reset();
57 m_xInsertColorLB.reset();
58 m_xMoveColorLB.reset();
61 std::unique_ptr<SfxTabPage> ScRedlineOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
63 return std::make_unique<ScRedlineOptionsTabPage>( pPage, pController, *rSet );
66 OUString ScRedlineOptionsTabPage::GetAllStrings()
68 OUString sAllStrings;
69 OUString labels[] = { u"label1"_ustr, u"label2"_ustr, u"label3"_ustr, u"label4"_ustr, u"label5"_ustr };
71 for (const auto& label : labels)
73 if (const auto pString = m_xBuilder->weld_label(label))
74 sAllStrings += pString->get_label() + " ";
77 return sAllStrings.replaceAll("_", "");
80 bool ScRedlineOptionsTabPage::FillItemSet( SfxItemSet* /* rSet */ )
82 ScModule* mod = ScModule::get();
83 ScAppOptions aAppOptions = mod->GetAppOptions();
85 Color nNew = m_xContentColorLB->GetSelectEntryColor();
86 aAppOptions.SetTrackContentColor(nNew);
88 nNew = m_xMoveColorLB->GetSelectEntryColor();
89 aAppOptions.SetTrackMoveColor(nNew);
91 nNew = m_xInsertColorLB->GetSelectEntryColor();
92 aAppOptions.SetTrackInsertColor(nNew);
94 nNew = m_xRemoveColorLB->GetSelectEntryColor();
95 aAppOptions.SetTrackDeleteColor(nNew);
97 mod->SetAppOptions(aAppOptions);
99 // repaint (if everything would be done by Items (how it should be),
100 // this wouldn't be necessary)
101 ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
102 if (pDocSh)
103 pDocSh->PostPaintGridAll();
105 return false;
108 void ScRedlineOptionsTabPage::Reset( const SfxItemSet* /* rSet */ )
110 ScAppOptions aAppOptions = ScModule::get()->GetAppOptions();
112 Color nColor = aAppOptions.GetTrackContentColor();
113 m_xContentColorLB->SelectEntry(nColor);
114 m_xContentColorLB->set_sensitive(!officecfg::Office::Calc::Revision::Color::Change::isReadOnly());
115 m_xContentColorImg->set_visible(officecfg::Office::Calc::Revision::Color::Change::isReadOnly());
117 nColor = aAppOptions.GetTrackMoveColor();
118 m_xMoveColorLB->SelectEntry(nColor);
119 m_xMoveColorLB->set_sensitive(!officecfg::Office::Calc::Revision::Color::Insertion::isReadOnly());
120 m_xMoveColorImg->set_visible(officecfg::Office::Calc::Revision::Color::Insertion::isReadOnly());
122 nColor = aAppOptions.GetTrackInsertColor();
123 m_xInsertColorLB->SelectEntry(nColor);
124 m_xInsertColorLB->set_sensitive(!officecfg::Office::Calc::Revision::Color::MovedEntry::isReadOnly());
125 m_xInsertColorImg->set_visible(officecfg::Office::Calc::Revision::Color::MovedEntry::isReadOnly());
127 nColor = aAppOptions.GetTrackDeleteColor();
128 m_xRemoveColorLB->SelectEntry(nColor);
129 m_xRemoveColorLB->set_sensitive(!officecfg::Office::Calc::Revision::Color::Deletion::isReadOnly());
130 m_xRemoveColorImg->set_visible(officecfg::Office::Calc::Revision::Color::Deletion::isReadOnly());
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */