LibreOffice Module cui (master) 1
optdeepl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "optdeepl.hxx"
21#include <officecfg/Office/Linguistic.hxx>
22
24 const SfxItemSet& rSet)
25 : SfxTabPage(pPage, pController, "cui/ui/optdeeplpage.ui", "OptDeeplPage", &rSet)
26 , m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
27 , m_xAuthKey(m_xBuilder->weld_entry("authkey"))
28{
29}
30
32
34{
35 std::optional<OUString> oDeeplAPIUrl
36 = officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get();
37 if (oDeeplAPIUrl && !oDeeplAPIUrl->isEmpty())
38 m_xAPIUrl->set_text(*officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get());
39
40 std::optional<OUString> oDeeplAuthKey
41 = officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get();
42 if (oDeeplAuthKey && !oDeeplAuthKey->isEmpty())
43 m_xAuthKey->set_text(*officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get());
44}
45
47{
48 std::shared_ptr<comphelper::ConfigurationChanges> batch(
50 officecfg::Office::Linguistic::Translation::Deepl::ApiURL::set(m_xAPIUrl->get_text(), batch);
51 officecfg::Office::Linguistic::Translation::Deepl::AuthKey::set(m_xAuthKey->get_text(), batch);
52 batch->commit();
53 return false;
54}
55
56std::unique_ptr<SfxTabPage> OptDeeplTabPage::Create(weld::Container* pPage,
57 weld::DialogController* pController,
58 const SfxItemSet* rAttrSet)
59{
60 return std::make_unique<OptDeeplTabPage>(pPage, pController, *rAttrSet);
61}
virtual ~OptDeeplTabPage() override
Definition: optdeepl.cxx:31
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optdeepl.cxx:56
virtual void Reset(const SfxItemSet *rSet) override
Definition: optdeepl.cxx:33
std::unique_ptr< weld::Entry > m_xAPIUrl
Definition: optdeepl.hxx:35
OptDeeplTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optdeepl.cxx:23
std::unique_ptr< weld::Entry > m_xAuthKey
Definition: optdeepl.hxx:36
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optdeepl.cxx:46
static std::shared_ptr< ConfigurationChanges > create()
static SfxItemSet & rSet