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

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
2
Setup_Touch::Setup_Touch(const Widget2 *const widget) :
63
    SetupTabScroll(widget),
64

2
    mSizeList(new NamesModel),
65

2
    mFormatList(new NamesModel),
66

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


12
        Separator_true);
80
81
    // TRANSLATORS: settings option
82
2
    new SetupItemCheckBox(_("Show onscreen keyboard icon"), "",
83
        "showScreenKeyboard", this, "showScreenKeyboardEvent",
84



24
        MainConfig_true);
85
86
    // TRANSLATORS: settings option
87
2
    new SetupActionDropDown(_("Keyboard icon action"), "",
88
        "screenActionKeyboard", this, "screenActionKeyboardEvent",
89



24
        mActionsList, 250, MainConfig_true);
90
91
92
    // TRANSLATORS: settings group
93
2
    new SetupItemLabel(_("Onscreen joystick"), "", this,
94


12
        Separator_true);
95
96
    // TRANSLATORS: settings option
97
2
    new SetupItemCheckBox(_("Show onscreen joystick"), "",
98
        "showScreenJoystick", this, "showScreenJoystickEvent",
99



24
        MainConfig_true);
100
101
    // TRANSLATORS: settings option
102
2
    new SetupItemDropDown(_("Joystick size"), "", "screenJoystickSize", this,
103
2
        "screenJoystickEvent", mSizeList, 100,
104



26
        MainConfig_true);
105
106
107
    // TRANSLATORS: settings group
108
2
    new SetupItemLabel(_("Onscreen buttons"), "", this,
109


12
        Separator_true);
110
111
    // TRANSLATORS: settings option
112
2
    new SetupItemCheckBox(_("Show onscreen buttons"), "",
113
        "showScreenButtons", this, "showScreenButtonsEvent",
114



24
        MainConfig_true);
115
116
    // TRANSLATORS: settings option
117
2
    new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this,
118
2
        "screenButtonsFormatEvent", mFormatList, 100,
119



26
        MainConfig_true);
120
121
    // TRANSLATORS: settings option
122
2
    new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this,
123
2
        "screenButtonsSizeEvent", mSizeList, 100,
124



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

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