GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/connectiondialog.cpp Lines: 24 30 80.0 %
Date: 2017-11-29 Branches: 20 40 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-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "gui/windows/connectiondialog.h"
24
25
#include "gui/widgets/button.h"
26
#include "gui/widgets/label.h"
27
#include "gui/widgets/layoutcell.h"
28
#include "gui/widgets/progressindicator.h"
29
30
#include "utils/gettext.h"
31
32
#include "client.h"
33
34
#include "debug.h"
35
36
extern bool mStatsReUpdated;
37
38
2
ConnectionDialog::ConnectionDialog(const std::string &text,
39
2
                                   const StateT cancelState) :
40
    Window("", Modal_false, nullptr, "connection.xml"),
41
    ActionListener(),
42

16
    mCancelState(cancelState)
43
{
44
2
    mTitleBarHeight = 0;
45
4
    setMovable(Move_false);
46
2
    setMinWidth(0);
47
48

2
    ProgressIndicator *const progressIndicator = new ProgressIndicator(this);
49

2
    Label *const label = new Label(this, text);
50
    Button *const cancelButton = new Button(
51
        // TRANSLATORS: connection dialog button
52


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

6
}