1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <vcl/svapp.hxx>
21 #include <vcl/weld.hxx>
22 #include <opencl/openclconfig.hxx>
23 #include <opencl/openclwrapper.hxx>
24 #include <officecfg/Office/Common.hxx>
25 #include <svtools/restartdialog.hxx>
27 #include "optopencl.hxx"
29 SvxOpenCLTabPage::SvxOpenCLTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
30 : SfxTabPage(pPage
, pController
, "cui/ui/optopenclpage.ui", "OptOpenCLPage", &rSet
)
31 , maConfig(OpenCLConfig::get())
32 , mxUseOpenCL(m_xBuilder
->weld_check_button("useopencl"))
33 , mxOclUsed(m_xBuilder
->weld_label("openclused"))
34 , mxOclNotUsed(m_xBuilder
->weld_label("openclnotused"))
36 mxUseOpenCL
->set_active(maConfig
.mbUseOpenCL
);
37 mxUseOpenCL
->set_sensitive(!officecfg::Office::Common::Misc::UseOpenCL::isReadOnly());
39 bool bCLUsed
= openclwrapper::GPUEnv::isOpenCLEnabled();
40 mxOclUsed
->set_visible(bCLUsed
);
41 mxOclNotUsed
->set_visible(!bCLUsed
);
44 SvxOpenCLTabPage::~SvxOpenCLTabPage()
48 std::unique_ptr
<SfxTabPage
> SvxOpenCLTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrSet
)
50 return std::make_unique
<SvxOpenCLTabPage
>(pPage
, pController
, *rAttrSet
);
53 bool SvxOpenCLTabPage::FillItemSet( SfxItemSet
* )
55 bool bModified
= false;
56 std::shared_ptr
<comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
58 if (mxUseOpenCL
->get_state_changed_from_saved())
59 maConfig
.mbUseOpenCL
= mxUseOpenCL
->get_active();
61 if (maConfig
!= OpenCLConfig::get())
70 SolarMutexGuard aGuard
;
71 if (svtools::executeRestartDialog(comphelper::getProcessComponentContext(), nullptr,
72 svtools::RESTART_REASON_OPENCL
))
73 GetDialogController()->response(RET_OK
);
79 void SvxOpenCLTabPage::Reset( const SfxItemSet
* )
81 maConfig
= OpenCLConfig::get();
83 mxUseOpenCL
->set_active(maConfig
.mbUseOpenCL
);
84 mxUseOpenCL
->save_state();
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */