GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_touch.cpp Lines: 45 45 100.0 %
Date: 2018-05-19 03:07:18 Branches: 77 152 50.7 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2018  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

4
        Separator_true);
80
81
    // TRANSLATORS: settings option
82


52
    new SetupItemCheckBox(_("Show onscreen keyboard icon"), "",
83
        "showScreenKeyboard", this, "showScreenKeyboardEvent",
84

4
        MainConfig_true);
85
86
    // TRANSLATORS: settings option
87


52
    new SetupActionDropDown(_("Keyboard icon action"), "",
88
        "screenActionKeyboard", this, "screenActionKeyboardEvent",
89

4
        mActionsList, 250, MainConfig_true);
90
91
92
    // TRANSLATORS: settings group
93

28
    new SetupItemLabel(_("Onscreen joystick"), "", this,
94

4
        Separator_true);
95
96
    // TRANSLATORS: settings option
97


52
    new SetupItemCheckBox(_("Show onscreen joystick"), "",
98
        "showScreenJoystick", this, "showScreenJoystickEvent",
99

4
        MainConfig_true);
100
101
    // TRANSLATORS: settings option
102


52
    new SetupItemDropDown(_("Joystick size"), "", "screenJoystickSize", this,
103
4
        "screenJoystickEvent", mSizeList, 100,
104

8
        MainConfig_true);
105
106
107
    // TRANSLATORS: settings group
108

28
    new SetupItemLabel(_("Onscreen buttons"), "", this,
109

4
        Separator_true);
110
111
    // TRANSLATORS: settings option
112


52
    new SetupItemCheckBox(_("Show onscreen buttons"), "",
113
        "showScreenButtons", this, "showScreenButtonsEvent",
114

4
        MainConfig_true);
115
116
    // TRANSLATORS: settings option
117


52
    new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this,
118
4
        "screenButtonsFormatEvent", mFormatList, 100,
119

8
        MainConfig_true);
120
121
    // TRANSLATORS: settings option
122


52
    new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this,
123
4
        "screenButtonsSizeEvent", mSizeList, 100,
124

8
        MainConfig_true);
125
126
52
    for (unsigned int f = 0; f < 12; f ++)
127
    {
128
96
        std::string key = strprintf("screenActionButton%u", f);
129
96
        std::string event = strprintf("screenActionButton%uEvent", f);
130
        // TRANSLATORS: settings option
131
192
        new SetupActionDropDown(strprintf(_("Button %u action"), f + 1), "",
132

48
            key, this, event, mActionsList, 250, MainConfig_true);
133
    }
134
135
8
    setDimension(Rect(0, 0, 550, 350));
136
4
}
137
138
12
Setup_Touch::~Setup_Touch()
139
{
140
4
    delete2(mSizeList);
141
4
    delete2(mFormatList);
142
8
    delete2(mActionsList);
143
8
}