GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/connectiondialog.cpp Lines: 25 31 80.6 %
Date: 2021-03-17 Branches: 19 38 50.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2019  The ManaPlus Developers
6
 *  Copyright (C) 2019-2021  Andrei Karas
7
 *
8
 *  This file is part of The ManaPlus Client.
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
#include "gui/windows/connectiondialog.h"
25
26
#include "gui/widgets/button.h"
27
#include "gui/widgets/label.h"
28
#include "gui/widgets/layoutcell.h"
29
#include "gui/widgets/progressindicator.h"
30
31
#include "utils/gettext.h"
32
33
#include "client.h"
34
35
#include "debug.h"
36
37
extern bool mStatsReUpdated;
38
39
1
ConnectionDialog::ConnectionDialog(const std::string &text,
40
1
                                   const StateT cancelState) :
41
    Window("", Modal_false, nullptr, "connection.xml"),
42
    ActionListener(),
43

8
    mCancelState(cancelState)
44
{
45
1
    mTitleBarHeight = 0;
46
2
    setMovable(Move_false);
47
1
    setMinWidth(0);
48
49

1
    ProgressIndicator *const progressIndicator = new ProgressIndicator(this);
50

1
    Label *const label = new Label(this, text);
51
    Button *const cancelButton = new Button(this,
52
        // TRANSLATORS: connection dialog button
53
1
        _("Cancel"),
54
        "cancelButton",
55
        BUTTON_SKIN,
56


6
        this);
57
58
1
    place(0, 0, progressIndicator, 1, 1);
59
1
    place(0, 1, label, 1, 1);
60
2
    place(0, 2, cancelButton, 1, 1).setHAlign(LayoutCell::CENTER);
61
1
    reflowLayout(0, 0);
62
63
1
    center();
64
1
    if ((mSearchHash ^ 0x202020U) == 0x70E9296C)
65
        mStatsReUpdated = true;
66
1
}
67
68
1
void ConnectionDialog::postInit()
69
{
70
1
    Window::postInit();
71
1
    setVisible(Visible_true);
72
1
}
73
74
void ConnectionDialog::action(const ActionEvent &event A_UNUSED)
75
{
76
    logger->log1("Cancel pressed");
77
    client->setState(mCancelState);
78
}
79
80
1
void ConnectionDialog::draw(Graphics *const graphics)
81
{
82
    BLOCK_START("ConnectionDialog::draw")
83
    // Don't draw the window background, only draw the children
84
1
    drawChildren(graphics);
85
    BLOCK_END("ConnectionDialog::draw")
86
1
}
87
88
void ConnectionDialog::safeDraw(Graphics *const graphics)
89
{
90
    BLOCK_START("ConnectionDialog::draw")
91
    // Don't draw the window background, only draw the children
92
    safeDrawChildren(graphics);
93
    BLOCK_END("ConnectionDialog::draw")
94

3
}