Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / uui / source / masterpasscrtdlg.cxx
blob8505e2cf7bfd31b6be8fef009617b0708c889784
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 #include <sal/macros.h>
21 #include <unotools/resmgr.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/weld.hxx>
24 #include <strings.hrc>
25 #include "masterpasscrtdlg.hxx"
27 // MasterPasswordCreateDialog---------------------------------------------------
30 IMPL_LINK_NOARG(MasterPasswordCreateDialog, EditHdl_Impl, weld::Entry&, void)
32 m_xOKBtn->set_sensitive(m_xEDMasterPasswordCrt->get_text().getLength() >= 1);
35 IMPL_LINK_NOARG(MasterPasswordCreateDialog, OKHdl_Impl, weld::Button&, void)
37 // compare both passwords and show message box if there are not equal!!
38 if (m_xEDMasterPasswordCrt->get_text() == m_xEDMasterPasswordRepeat->get_text())
39 m_xDialog->response(RET_OK);
40 else
42 OUString aErrorMsg(Translate::get(STR_ERROR_PASSWORDS_NOT_IDENTICAL, rResLocale));
43 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
44 VclMessageType::Warning, VclButtonsType::Ok,
45 aErrorMsg));
46 xErrorBox->run();
47 m_xEDMasterPasswordCrt->set_text( OUString() );
48 m_xEDMasterPasswordRepeat->set_text( OUString() );
49 m_xEDMasterPasswordCrt->grab_focus();
53 MasterPasswordCreateDialog::MasterPasswordCreateDialog(weld::Window* pParent, const std::locale& rLocale)
54 : GenericDialogController(pParent, "uui/ui/setmasterpassworddlg.ui", "SetMasterPasswordDialog")
55 , rResLocale(rLocale)
56 , m_xEDMasterPasswordCrt(m_xBuilder->weld_entry("password1"))
57 , m_xEDMasterPasswordRepeat(m_xBuilder->weld_entry("password2"))
58 , m_xOKBtn(m_xBuilder->weld_button("ok"))
60 m_xOKBtn->set_sensitive(false);
61 m_xOKBtn->connect_clicked( LINK( this, MasterPasswordCreateDialog, OKHdl_Impl ) );
62 m_xEDMasterPasswordCrt->connect_changed( LINK( this, MasterPasswordCreateDialog, EditHdl_Impl ) );
65 MasterPasswordCreateDialog::~MasterPasswordCreateDialog()
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */