summaryrefslogtreecommitdiff
path: root/vcl/qt5/QtInstanceDialog.cxx
blob: 36f7e75c4fc8b91b20a34f55a0c186ec8a4ee79a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <QtInstanceDialog.hxx>

QtInstanceDialog::QtInstanceDialog(QDialog* pDialog)
    : QtInstanceWindow(pDialog)
    , m_pDialog(pDialog)
{
}

QtInstanceDialog::~QtInstanceDialog()
{
    SolarMutexGuard g;
    QtInstance* pQtInstance = GetQtInstance();
    pQtInstance->RunInMainThread([&] { m_pDialog.reset(); });
}

bool QtInstanceDialog::runAsync(std::shared_ptr<Dialog> const&,
                                const std::function<void(sal_Int32)>&)
{
    return true;
}

bool QtInstanceDialog::runAsync(const std::shared_ptr<weld::DialogController>&,
                                const std::function<void(sal_Int32)>&)
{
    return true;
}

void QtInstanceDialog::collapse(weld::Widget*, weld::Widget*) {}

void QtInstanceDialog::undo_collapse() {}

void QtInstanceDialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&)
{
}

int QtInstanceDialog::run()
{
    SolarMutexGuard g;
    QtInstance* pQtInstance = GetQtInstance();
    if (!pQtInstance->IsMainThread())
    {
        int nResult = 0;
        pQtInstance->RunInMainThread([&] { nResult = run(); });
        return nResult;
    }

    return qtResponseTypeToVclResponseType(m_pDialog->exec());
}

void QtInstanceDialog::response(int) {}

void QtInstanceDialog::add_button(const OUString&, int, const OUString&) {}

void QtInstanceDialog::set_modal(bool bModal)
{
    SolarMutexGuard g;
    QtInstance* pQtInstance = GetQtInstance();
    if (!pQtInstance->IsMainThread())
    {
        pQtInstance->RunInMainThread([&] { set_modal(bModal); });
        return;
    }

    m_pDialog->setModal(bModal);
}

bool QtInstanceDialog::get_modal() const
{
    SolarMutexGuard g;
    QtInstance* pQtInstance = GetQtInstance();
    if (!pQtInstance->IsMainThread())
    {
        bool bModal = false;
        pQtInstance->RunInMainThread([&] { bModal = get_modal(); });
        return bModal;
    }

    return m_pDialog->isModal();
}

weld::Button* QtInstanceDialog::weld_widget_for_response(int) { return nullptr; }

void QtInstanceDialog::set_default_response(int) {}

weld::Container* QtInstanceDialog::weld_content_area() { return nullptr; }

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */