GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_touch.cpp Lines: 39 39 100.0 %
Date: 2017-11-29 Branches: 78 154 50.6 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "gui/widgets/tabs/setup_touch.h"
22
23
#include "gui/models/touchactionmodel.h"
24
25
#include "gui/widgets/containerplacer.h"
26
#include "gui/widgets/layouthelper.h"
27
#include "gui/widgets/setuptouchitem.h"
28
#include "gui/widgets/scrollarea.h"
29
30
#include "utils/delete2.h"
31
#include "utils/gettext.h"
32
#include "utils/stringutils.h"
33
34
#include "debug.h"
35
36
static const int sizeListSize = 4;
37
38
static const char *const sizeList[] =
39
{
40
    // TRANSLATORS: onscreen button size
41
    N_("Small"),
42
    // TRANSLATORS: onscreen button size
43
    N_("Normal"),
44
    // TRANSLATORS: onscreen button size
45
    N_("Medium"),
46
    // TRANSLATORS: onscreen button size
47
    N_("Large")
48
};
49
50
static const int formatListSize = 6;
51
52
static const char *const formatList[] =
53
{
54
    "2x1",
55
    "2x2",
56
    "3x3",
57
    "4x2",
58
    "4x3",
59
    "3x2"
60
};
61
62
4
Setup_Touch::Setup_Touch(const Widget2 *const widget) :
63
    SetupTabScroll(widget),
64

4
    mSizeList(new NamesModel),
65

4
    mFormatList(new NamesModel),
66

12
    mActionsList(new TouchActionsModel)
67
{
68
    // TRANSLATORS: touch settings tab
69
20
    setName(_("Touch"));
70
71
8
    LayoutHelper h(this);
72
4
    ContainerPlacer place = h.getPlacer(0, 0);
73
4
    place(0, 0, mScroll, 10, 10);
74
4
    mSizeList->fillFromArray(&sizeList[0], sizeListSize);
75
4
    mFormatList->fillFromArray(&formatList[0], formatListSize);
76
77
    // TRANSLATORS: settings option
78


28
    new SetupItemLabel(_("Onscreen keyboard"), "", this);
79
80
    // TRANSLATORS: settings option
81


52
    new SetupItemCheckBox(_("Show onscreen keyboard icon"), "",
82

4
        "showScreenKeyboard", this, "showScreenKeyboardEvent");
83
84
    // TRANSLATORS: settings option
85


52
    new SetupActionDropDown(_("Keyboard icon action"), "",
86
        "screenActionKeyboard", this, "screenActionKeyboardEvent",
87

4
        mActionsList, 250);
88
89
90
    // TRANSLATORS: settings group
91


28
    new SetupItemLabel(_("Onscreen joystick"), "", this);
92
93
    // TRANSLATORS: settings option
94


52
    new SetupItemCheckBox(_("Show onscreen joystick"), "",
95

4
        "showScreenJoystick", this, "showScreenJoystickEvent");
96
97
    // TRANSLATORS: settings option
98


52
    new SetupItemDropDown(_("Joystick size"), "", "screenJoystickSize", this,
99

4
        "screenJoystickEvent", mSizeList, 100);
100
101
102
    // TRANSLATORS: settings group
103


28
    new SetupItemLabel(_("Onscreen buttons"), "", this);
104
105
    // TRANSLATORS: settings option
106


52
    new SetupItemCheckBox(_("Show onscreen buttons"), "",
107

4
        "showScreenButtons", this, "showScreenButtonsEvent");
108
109
    // TRANSLATORS: settings option
110


52
    new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this,
111

4
        "screenButtonsFormatEvent", mFormatList, 100);
112
113
    // TRANSLATORS: settings option
114


52
    new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this,
115

4
        "screenButtonsSizeEvent", mSizeList, 100);
116
117
52
    for (unsigned int f = 0; f < 12; f ++)
118
    {
119
96
        std::string key = strprintf("screenActionButton%u", f);
120
96
        std::string event = strprintf("screenActionButton%uEvent", f);
121
        // TRANSLATORS: settings option
122

240
        new SetupActionDropDown(strprintf(_("Button %u action"), f + 1), "",
123

48
            key, this, event, mActionsList, 250);
124
    }
125
126
8
    setDimension(Rect(0, 0, 550, 350));
127
4
}
128
129
12
Setup_Touch::~Setup_Touch()
130
{
131
4
    delete2(mSizeList);
132
4
    delete2(mFormatList);
133
8
    delete2(mActionsList);
134
8
}