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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

0.0
/ui/src/videoeditor.cpp
1
/*
2
  Q Light Controller Plus
3
  videoeditor.cpp
4

5
  Copyright (c) Massimo Callegari
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 <QInputDialog>
21
#include <QFileDialog>
22
#include <QLineEdit>
23
#include <QLabel>
24
#include <QDebug>
25

26
#include "videoeditor.h"
27
#include "video.h"
28
#include "doc.h"
29

30
VideoEditor::VideoEditor(QWidget* parent, Video *video, Doc* doc)
×
31
    : QWidget(parent)
32
    , m_doc(doc)
×
33
    , m_video(video)
×
34
{
35
    Q_ASSERT(doc != NULL);
36
    Q_ASSERT(video != NULL);
37

38
    setupUi(this);
×
39

40
    m_nameEdit->setText(m_video->name());
×
41
    m_nameEdit->setSelection(0, m_nameEdit->text().length());
×
42

43
    connect(m_video, SIGNAL(totalTimeChanged(qint64)),
×
44
            this, SLOT(slotDurationChanged(qint64)));
45
    connect(m_video, SIGNAL(metaDataChanged(QString,QVariant)),
×
46
            this, SLOT(slotMetaDataChanged(QString,QVariant)));
47

48
    connect(m_nameEdit, SIGNAL(textEdited(const QString&)),
×
49
            this, SLOT(slotNameEdited(const QString&)));
50
    connect(m_fileButton, SIGNAL(clicked()),
×
51
            this, SLOT(slotSourceFileClicked()));
52
    connect(m_urlButton, SIGNAL(clicked()),
×
53
            this, SLOT(slotSourceUrlClicked()));
54

55
    connect(m_previewButton, SIGNAL(toggled(bool)),
×
56
            this, SLOT(slotPreviewToggled(bool)));
57

58
    m_filenameLabel->setText(m_video->sourceUrl());
×
59
    m_durationLabel->setText(Function::speedToString(m_video->totalDuration()));
×
60
    QSize res = video->resolution();
×
61
    m_resolutionLabel->setText(QString("%1x%2").arg(res.width()).arg(res.height()));
×
62
    m_vcodecLabel->setText(video->videoCodec());
×
63
    m_acodecLabel->setText(video->audioCodec());
×
64

65
    int screenCount = QGuiApplication::screens().count();
×
66

67
    if (screenCount > 0)
×
68
    {
69
        for (int i = 0; i < screenCount; i++)
×
70
            m_screenCombo->addItem(QString("Screen %1").arg(i + 1));
×
71
    }
72

73
    m_screenCombo->setCurrentIndex(m_video->screen());
×
74

75
    if (m_video->fullscreen() == true)
×
76
        m_fullCheck->setChecked(true);
×
77
    else
78
        m_winCheck->setChecked(true);
×
79

80
    connect(m_screenCombo, SIGNAL(currentIndexChanged(int)),
×
81
            this, SLOT(slotScreenIndexChanged(int)));
82
    connect(m_winCheck, SIGNAL(clicked()),
×
83
            this, SLOT(slotWindowedCheckClicked()));
84
    connect(m_fullCheck, SIGNAL(clicked()),
×
85
            this, SLOT(slotFullscreenCheckClicked()));
86

87
    if (m_video->runOrder() == Video::Loop)
×
88
        m_loopCheck->setChecked(true);
×
89
    else
90
        m_singleCheck->setChecked(true);
×
91

92
    connect(m_loopCheck, SIGNAL(clicked()),
×
93
            this, SLOT(slotLoopCheckClicked()));
94
    connect(m_singleCheck, SIGNAL(clicked()),
×
95
            this, SLOT(slotSingleShotCheckClicked()));
96

97
    // Set focus to the editor
98
    m_nameEdit->setFocus();
×
99
}
×
100

101
VideoEditor::~VideoEditor()
×
102
{
103
    m_video->stopAndWait();
×
104
}
×
105

106
void VideoEditor::slotNameEdited(const QString& text)
×
107
{
108
    m_video->setName(text);
×
109
    m_doc->setModified();
×
110
}
×
111

112
void VideoEditor::slotSourceFileClicked()
×
113
{
114
    QString fn;
115

116
    /* Create a file open dialog */
117
    QFileDialog dialog(this);
×
118
    dialog.setWindowTitle(tr("Open Video File"));
×
119
    dialog.setAcceptMode(QFileDialog::AcceptOpen);
×
120

121
    /* Append file filters to the dialog */
122
    QStringList extList = Video::getVideoCapabilities();
×
123

124
    QStringList filters;
125
    qDebug() << Q_FUNC_INFO << "Extensions: " << extList.join(" ");
126
    filters << tr("Video Files (%1)").arg(extList.join(" "));
×
127
#if defined(WIN32) || defined(Q_OS_WIN)
128
    filters << tr("All Files (*.*)");
129
#else
130
    filters << tr("All Files (*)");
×
131
#endif
132
    dialog.setNameFilters(filters);
×
133

134
    /* Append useful URLs to the dialog */
135
    QList <QUrl> sidebar;
136
    sidebar.append(QUrl::fromLocalFile(QDir::homePath()));
×
137
    sidebar.append(QUrl::fromLocalFile(QDir::rootPath()));
×
138
    dialog.setSidebarUrls(sidebar);
×
139

140
    /* Get file name */
141
    if (dialog.exec() != QDialog::Accepted)
×
142
        return;
143

144
    fn = dialog.selectedFiles().first();
×
145
    if (fn.isEmpty() == true)
×
146
        return;
147

148
    m_video->stopAndWait();
×
149

150
    m_video->setSourceUrl(fn);
×
151
    m_filenameLabel->setText(m_video->sourceUrl());
×
152
    m_durationLabel->setText(Function::speedToString(m_video->totalDuration()));
×
153
}
×
154

155
void VideoEditor::slotSourceUrlClicked()
×
156
{
157
    bool ok;
158
    QString videoURL = QInputDialog::getText(this, tr("Video source URL"),
×
159
                                         tr("Enter a URL:"), QLineEdit::Normal,
×
160
                                         "http://", &ok);
×
161

162
    if (ok == true)
×
163
    {
164
        m_video->setSourceUrl(videoURL);
×
165
        m_filenameLabel->setText(m_video->sourceUrl());
×
166
    }
167
}
×
168

169
void VideoEditor::slotScreenIndexChanged(int idx)
×
170
{
171
    m_video->setScreen(idx);
×
172
}
×
173

174
void VideoEditor::slotWindowedCheckClicked()
×
175
{
176
    m_video->setFullscreen(false);
×
177
}
×
178

179
void VideoEditor::slotFullscreenCheckClicked()
×
180
{
181
    m_video->setFullscreen(true);
×
182
}
×
183

184
void VideoEditor::slotSingleShotCheckClicked()
×
185
{
186
    m_video->setRunOrder(Video::SingleShot);
×
187
}
×
188

189
void VideoEditor::slotLoopCheckClicked()
×
190
{
191
    m_video->setRunOrder(Video::Loop);
×
192
}
×
193

194
void VideoEditor::slotPreviewToggled(bool state)
×
195
{
196
    if (state == true)
×
197
    {
198
        m_video->start(m_doc->masterTimer(), functionParent());
×
199
        connect(m_video, SIGNAL(stopped(quint32)),
×
200
                this, SLOT(slotPreviewStopped(quint32)));
201
    }
202
    else
203
        m_video->stop(functionParent());
×
204
}
×
205

206
void VideoEditor::slotPreviewStopped(quint32 id)
×
207
{
208
    if (id == m_video->id())
×
209
    {
210
        m_previewButton->blockSignals(true);
×
211
        m_previewButton->setChecked(false);
×
212
        m_previewButton->blockSignals(false);
×
213
    }
214
}
×
215

216
void VideoEditor::slotDurationChanged(qint64 duration)
×
217
{
218
    m_durationLabel->setText(Function::speedToString(duration));
×
219
}
×
220

221
void VideoEditor::slotMetaDataChanged(QString key, QVariant data)
×
222
{
223
    qDebug() << "Got meta data:" << key;
224
    if (key == "Resolution")
×
225
    {
226
        QSize res = data.toSize();
×
227
        m_resolutionLabel->setText(QString("%1x%2").arg(res.width()).arg(res.height()));
×
228
    }
229
    else if (key == "VideoCodec")
×
230
        m_vcodecLabel->setText(data.toString());
×
231
    else if (key == "AudioCodec")
×
232
        m_acodecLabel->setText(data.toString());
×
233
}
×
234

235
FunctionParent VideoEditor::functionParent() const
×
236
{
237
    return FunctionParent::master();
×
238
}
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