GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/connectiondialog.cpp Lines: 25 31 80.6 %
Date: 2018-05-19 03:07:18 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-2018  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(this,
51
        // TRANSLATORS: connection dialog button
52
2
        _("Cancel"),
53
        "cancelButton",
54
        BUTTON_SKIN,
55


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

6
}