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

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

2
    mSizeList(new NamesModel),
66

2
    mFormatList(new NamesModel),
67

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


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



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



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


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



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



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


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



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



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



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

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