• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 8961243534

05 May 2024 09:23PM UTC coverage: 32.068% (+4.0%) from 28.094%
8961243534

push

github

mcallegari
Merge branch 'master' into qmltoqt6

902 of 2557 new or added lines in 140 files covered. (35.28%)

166 existing lines in 76 files now uncovered.

15395 of 48008 relevant lines covered (32.07%)

22949.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.5
/ui/src/virtualconsole/vcframeproperties.cpp
1
/*
2
  Q Light Controller
3
  vcframeproperties.cpp
4

5
  Copyright (c) Heikki Junnila
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QCheckBox>
21
#include <QComboBox>
22
#include <QDebug>
23
#include <algorithm>
24
#include <QSettings>
25

26
#include "inputselectionwidget.h"
27
#include "vcframepageshortcut.h"
28
#include "vcframeproperties.h"
29
#include "vcframe.h"
30
#include "doc.h"
31

32
#define SETTINGS_GEOMETRY "vcframeproperties/geometry"
33

34
VCFrameProperties::VCFrameProperties(QWidget* parent, VCFrame* frame, Doc *doc)
1✔
35
    : QDialog(parent)
36
    , m_frame(frame)
37
    , m_doc(doc)
1✔
38
{
39
    Q_ASSERT(frame != NULL);
1✔
40
    Q_ASSERT(doc != NULL);
1✔
41

42
    setupUi(this);
1✔
43

44
    m_frameName->setText(frame->caption());
1✔
45
    m_allowChildrenCheck->setChecked(frame->allowChildren());
1✔
46
    m_allowResizeCheck->setChecked(frame->allowResize());
1✔
47
    m_showHeaderCheck->setChecked(frame->isHeaderVisible());
1✔
48
    m_showEnableButtonCheck->setChecked(frame->isEnableButtonVisible());
1✔
49
    m_enablePaging->setChecked(frame->multipageMode());
1✔
50
    m_pagesLoopCheck->setChecked(frame->pagesLoop());
1✔
51
    if (frame->multipageMode() == true)
1✔
52
        m_showHeaderCheck->setEnabled(false);
×
53
    m_totalPagesSpin->setValue(frame->totalPagesNumber());
1✔
54
    if (frame->totalPagesNumber() != 1)
1✔
55
        m_cloneFirstPageCheck->setEnabled(false);
×
56

57
    QSettings settings;
2✔
58
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
3✔
59
    if (geometrySettings.isValid() == true)
1✔
NEW
60
        restoreGeometry(geometrySettings.toByteArray());
×
61

62
    connect(m_enablePaging, SIGNAL(toggled(bool)),
1✔
63
            this, SLOT(slotMultipageChecked(bool)));
64

65
    /************************************************************************
66
     * Enable frame
67
     ************************************************************************/
68

69
    m_inputEnableWidget = new InputSelectionWidget(m_doc, this);
1✔
70
    m_inputEnableWidget->setTitle(tr("External Input - Enable"));
1✔
71
    m_inputEnableWidget->setCustomFeedbackVisibility(true);
1✔
72
    m_inputEnableWidget->setKeySequence(m_frame->enableKeySequence());
1✔
73
    m_inputEnableWidget->setInputSource(m_frame->inputSource(VCFrame::enableInputSourceId));
1✔
74
    m_inputEnableWidget->setWidgetPage(m_frame->page());
1✔
75
    m_inputEnableWidget->show();
1✔
76
    m_extEnableLayout->addWidget(m_inputEnableWidget);
1✔
77

78
    /************************************************************************
79
     * Previous page
80
     ************************************************************************/
81

82
    m_inputPrevPageWidget = new InputSelectionWidget(m_doc, this);
1✔
83
    m_inputPrevPageWidget->setTitle(tr("External Input - Previous Page"));
1✔
84
    m_inputPrevPageWidget->setCustomFeedbackVisibility(true);
1✔
85
    m_inputPrevPageWidget->setKeySequence(m_frame->previousPageKeySequence());
1✔
86
    m_inputPrevPageWidget->setInputSource(m_frame->inputSource(VCFrame::previousPageInputSourceId));
1✔
87
    m_inputPrevPageWidget->setWidgetPage(m_frame->page());
1✔
88
    m_inputPrevPageWidget->show();
1✔
89
    m_extInputPages->addWidget(m_inputPrevPageWidget);
1✔
90

91
    /************************************************************************
92
     * Next page
93
     ************************************************************************/
94

95
    m_inputNextPageWidget = new InputSelectionWidget(m_doc, this);
1✔
96
    m_inputNextPageWidget->setTitle(tr("External Input - Next Page"));
1✔
97
    m_inputNextPageWidget->setCustomFeedbackVisibility(true);
1✔
98
    m_inputNextPageWidget->setKeySequence(m_frame->nextPageKeySequence());
1✔
99
    m_inputNextPageWidget->setInputSource(m_frame->inputSource(VCFrame::nextPageInputSourceId));
1✔
100
    m_inputNextPageWidget->setWidgetPage(m_frame->page());
1✔
101
    m_inputNextPageWidget->show();
1✔
102
    m_extInputPages->addWidget(m_inputNextPageWidget);
1✔
103

104
    /************************************************************************
105
     * Page shortcuts
106
     ************************************************************************/
107
    foreach (VCFramePageShortcut const* shortcut, m_frame->shortcuts())
2✔
108
    {
109
        m_shortcuts.append(new VCFramePageShortcut(*shortcut));
×
110
        m_pageCombo->addItem(shortcut->name());
×
111
    }
112

113
    m_shortcutInputWidget = new InputSelectionWidget(m_doc, this);
1✔
114
    m_shortcutInputWidget->setCustomFeedbackVisibility(true);
1✔
115
    m_shortcutInputWidget->setWidgetPage(m_frame->page());
1✔
116
    m_shortcutInputWidget->show();
1✔
117
    m_pageShortcuts->addWidget(m_shortcutInputWidget);
1✔
118

119
    connect(m_totalPagesSpin, SIGNAL(valueChanged(int)),
1✔
120
            this, SLOT(slotTotalPagesNumberChanged(int)));
121

122
    connect(m_shortcutInputWidget, SIGNAL(inputValueChanged(quint32,quint32)),
1✔
123
            this, SLOT(slotInputValueChanged(quint32,quint32)));
124

125
    connect(m_shortcutInputWidget, SIGNAL(keySequenceChanged(QKeySequence)),
1✔
126
            this, SLOT(slotKeySequenceChanged(QKeySequence)));
127

128
    connect(m_pageName, SIGNAL(editingFinished()),
1✔
129
            this, SLOT(slotPageNameEditingFinished()));
130

131
    connect(m_pageCombo, SIGNAL(currentIndexChanged(int)),
1✔
132
            this, SLOT(slotPageComboChanged(int)));
133

134
    if (m_pageCombo->count())
1✔
135
        slotPageComboChanged(0);
×
136
}
1✔
137

138
VCFrameProperties::~VCFrameProperties()
1✔
139
{
140
    QSettings settings;
2✔
141
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
1✔
142

143
    foreach (VCFramePageShortcut* shortcut, m_shortcuts)
1✔
144
    {
145
        delete shortcut;
×
146
    }
147
}
1✔
148

149
bool VCFrameProperties::allowChildren() const
1✔
150
{
151
    return m_allowChildrenCheck->isChecked();
1✔
152
}
153

154
bool VCFrameProperties::allowResize() const
1✔
155
{
156
    return m_allowResizeCheck->isChecked();
1✔
157
}
158

159
bool VCFrameProperties::showHeader() const
×
160
{
161
    return m_showHeaderCheck->isChecked();
×
162
}
163

164
QString VCFrameProperties::frameName() const
×
165
{
166
    return m_frameName->text();
×
167
}
168

169
bool VCFrameProperties::multipageEnabled() const
×
170
{
171
    return m_enablePaging->isChecked();
×
172
}
173

174
bool VCFrameProperties::cloneWidgets() const
×
175
{
176
    return m_cloneFirstPageCheck->isChecked();
×
177
}
178

179
bool VCFrameProperties::pagesLoop() const
×
180
{
181
    return m_pagesLoopCheck->isChecked();
×
182
}
183

184
void VCFrameProperties::slotMultipageChecked(bool enable)
×
185
{
186
    if (enable == true)
×
187
    {
188
        m_showHeaderCheck->setChecked(true);
×
189
        m_showHeaderCheck->setEnabled(false);
×
190
        slotTotalPagesNumberChanged(m_totalPagesSpin->value());
×
191
    }
192
}
×
193

194
void VCFrameProperties::slotPageComboChanged(int index)
×
195
{
196
    if (index >= 0 && index < m_shortcuts.count() && m_shortcuts[index] != NULL)
×
197
    {
198
        m_shortcutInputWidget->setInputSource(m_shortcuts[index]->m_inputSource);
×
199
        m_shortcutInputWidget->setKeySequence(m_shortcuts[index]->m_keySequence.toString(QKeySequence::NativeText));
×
200
        m_pageName->setText(m_shortcuts[index]->name());
×
201
    }
202
}
×
203

204
void VCFrameProperties::slotPageNameEditingFinished()
×
205
{
206
    // Store current page to restore it afterwards
207
    int index = m_pageCombo->currentIndex();
×
208
    m_shortcuts[index]->setName(m_pageName->text());
×
209
    m_pageCombo->setItemText(index, m_shortcuts[index]->name());
×
210
    //m_pageCombo->setItemText(index, tr("Page %1").arg(index + 1) + (m_pageName->text() != "" ? (" - " + m_pageName->text()) : ""));
211
}
×
212

213
void VCFrameProperties::slotTotalPagesNumberChanged(int number)
×
214
{
215
    if (m_enablePaging->isChecked() == false || number == m_shortcuts.count())
×
216
        return;
×
217

218
    if (number < m_shortcuts.count())
×
219
    {
220
        m_pageCombo->removeItem(m_shortcuts.count() - 1);
×
221
        VCFramePageShortcut *sc = m_shortcuts.takeLast();
×
222
        delete sc;
×
223
    }
224
    else
225
    {
226
        int newIndex = m_shortcuts.count();
×
227
        m_shortcuts.append(new VCFramePageShortcut(newIndex, VCFrame::shortcutsBaseInputSourceId + newIndex));
×
228
        m_pageCombo->addItem(m_shortcuts.last()->name());
×
229
    }
230
}
231

232
void VCFrameProperties::slotInputValueChanged(quint32 universe, quint32 channel)
×
233
{
234
    Q_UNUSED(universe);
235
    Q_UNUSED(channel);
236

237
    VCFramePageShortcut *shortcut = m_shortcuts[m_pageCombo->currentIndex()];
×
238

239
    if (shortcut != NULL)
×
240
        shortcut->m_inputSource = m_shortcutInputWidget->inputSource();
×
241
}
×
242

243
void VCFrameProperties::slotKeySequenceChanged(QKeySequence key)
×
244
{
245
    VCFramePageShortcut *shortcut = m_shortcuts[m_pageCombo->currentIndex()];
×
246

247
    if (shortcut != NULL)
×
248
        shortcut->m_keySequence = key;
×
249
}
×
250

251

252
void VCFrameProperties::accept()
1✔
253
{
254
    bool hasHeader = m_frame->isHeaderVisible();
1✔
255

256
    m_frame->setCaption(m_frameName->text());
1✔
257
    m_frame->setAllowChildren(m_allowChildrenCheck->isChecked());
1✔
258
    m_frame->setAllowResize(m_allowResizeCheck->isChecked());
1✔
259

260
    /* If the frame is coming from a headerless state,
261
     * all the children widgets must be moved down */
262
    if (m_showHeaderCheck->isChecked() && hasHeader == false)
1✔
263
    {
264
        QListIterator <VCWidget*> it(m_frame->findChildren<VCWidget*>());
×
265

266
        // resize the frame too if it contains children
267
        if (it.hasNext())
×
268
            m_frame->resize(QSize(m_frame->width(), m_frame->height() + 40));
×
269

270
        while (it.hasNext() == true)
×
271
        {
272
            VCWidget* child = it.next();
×
273

274
            // move only first level children
275
            if (child->parentWidget() == m_frame)
×
276
                child->move(QPoint(child->x(), child->y() + 40));
×
277
        }
278
    }
279
    m_frame->setHeaderVisible(m_showHeaderCheck->isChecked());
1✔
280
    m_frame->setEnableButtonVisible(m_showEnableButtonCheck->isChecked());
1✔
281
    m_frame->setMultipageMode(m_enablePaging->isChecked());
1✔
282
    m_frame->setTotalPagesNumber(m_totalPagesSpin->value());
1✔
283
    m_frame->setPagesLoop(m_pagesLoopCheck->isChecked());
1✔
284

285
    /* Key sequences */
286
    m_frame->setEnableKeySequence(m_inputEnableWidget->keySequence());
1✔
287
    m_frame->setNextPageKeySequence(m_inputNextPageWidget->keySequence());
1✔
288
    m_frame->setPreviousPageKeySequence(m_inputPrevPageWidget->keySequence());
1✔
289

290
    /* Input sources */
291
    m_frame->setInputSource(m_inputEnableWidget->inputSource(), VCFrame::enableInputSourceId);
1✔
292
    m_frame->setInputSource(m_inputNextPageWidget->inputSource(), VCFrame::nextPageInputSourceId);
1✔
293
    m_frame->setInputSource(m_inputPrevPageWidget->inputSource(), VCFrame::previousPageInputSourceId);
1✔
294

295
    /* Shortcuts */
296
    m_frame->setShortcuts(m_shortcuts);
1✔
297

298
    m_frame->slotSetPage(m_frame->currentPage());
1✔
299

300
    QDialog::accept();
1✔
301
}
1✔
302

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc