Mark some Calc slots as inactive in readonly mode
[LibreOffice.git] / vcl / qt5 / QtInstanceCheckButton.cxx
blob1a5e63408de7b5a7ba06cada0fe8925267a0c891
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
8 */
10 #include <QtInstanceCheckButton.hxx>
11 #include <QtInstanceCheckButton.moc>
13 #include <vcl/qt/QtUtils.hxx>
15 QtInstanceCheckButton::QtInstanceCheckButton(QCheckBox* pCheckBox)
16 : QtInstanceWidget(pCheckBox)
17 , m_pCheckBox(pCheckBox)
19 assert(m_pCheckBox);
20 connect(m_pCheckBox, &QCheckBox::toggled, this, &QtInstanceCheckButton::handleToggled);
23 void QtInstanceCheckButton::set_active(bool bActive)
25 SolarMutexGuard g;
26 GetQtInstance().RunInMainThread([&] {
27 m_pCheckBox->setTristate(false);
28 m_pCheckBox->setChecked(bActive);
29 });
32 bool QtInstanceCheckButton::get_active() const
34 SolarMutexGuard g;
35 bool bActive;
36 GetQtInstance().RunInMainThread([&] { bActive = m_pCheckBox->isChecked(); });
37 return bActive;
40 void QtInstanceCheckButton::set_inconsistent(bool bInconsistent)
42 SolarMutexGuard g;
43 GetQtInstance().RunInMainThread([&] {
44 m_pCheckBox->setTristate(true);
45 m_pCheckBox->setCheckState(bInconsistent ? Qt::PartiallyChecked : Qt::Unchecked);
46 });
49 bool QtInstanceCheckButton::get_inconsistent() const
51 SolarMutexGuard g;
52 bool bInconsistent;
53 GetQtInstance().RunInMainThread(
54 [&] { bInconsistent = m_pCheckBox->checkState() == Qt::PartiallyChecked; });
55 return bInconsistent;
58 void QtInstanceCheckButton::set_label(const OUString& rText)
60 SolarMutexGuard g;
61 GetQtInstance().RunInMainThread([&] { m_pCheckBox->setText(toQString(rText)); });
63 OUString QtInstanceCheckButton::get_label() const
65 SolarMutexGuard g;
66 OUString sLabel;
67 GetQtInstance().RunInMainThread([&] { sLabel = toOUString(m_pCheckBox->text()); });
68 return sLabel;
71 void QtInstanceCheckButton::QtInstanceCheckButton::set_label_wrap(bool /*bWrap*/)
73 assert(false && "Not implemented yet");
76 void QtInstanceCheckButton::handleToggled()
78 SolarMutexGuard g;
79 signal_toggled();
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */