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

mcallegari / qlcplus / 18357067171

08 Oct 2025 08:16PM UTC coverage: 34.26% (+2.2%) from 32.066%
18357067171

push

github

mcallegari
Merge branch 'master' into filedialog

1282 of 4424 new or added lines in 152 files covered. (28.98%)

1342 existing lines in 152 files now uncovered.

17704 of 51675 relevant lines covered (34.26%)

19430.31 hits per line

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

93.88
/engine/src/rgbscriptscache.cpp
1
/*
2
  Q Light Controller Plus
3
  rgbscriptscache.cpp
4

5
  Copyright (c) David Garyga
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 <QDebug>
21
#include <QDir>
22

23
#include "rgbscriptscache.h"
24
#ifdef QT_QML_LIB
25
  #include "rgbscriptv4.h"
26
#else
27
  #include "rgbscript.h"
28
#endif
29
#include "qlcconfig.h"
30
#include "qlcfile.h"
31

32
RGBScriptsCache::RGBScriptsCache(Doc* doc)
196✔
33
    : m_doc(doc)
196✔
34
{
35
}
196✔
36

37
QStringList RGBScriptsCache::names() const
4✔
38
{
39
    return m_scriptsMap.keys();
4✔
40
}
41

42
RGBScript* RGBScriptsCache::script(QString name) const
61✔
43
{
44
    RGBScript *mScript = new RGBScript(m_doc);
61✔
45
    QString filename = m_scriptsMap.value(name);
61✔
46
    if (filename.isEmpty())
61✔
47
    {
48
        return mScript;
3✔
49
    }
50
    else
51
    {
52
        mScript->load(filename);
58✔
53
        return mScript;
58✔
54
    }
55
}
61✔
56

57
bool RGBScriptsCache::load(const QDir& dir)
4✔
58
{
59
    qDebug() << "Loading RGB scripts in " << dir.path() << "...";
4✔
60

61
    if (dir.exists() == false || dir.isReadable() == false)
4✔
62
        return false;
×
63

64
    foreach (QString file, dir.entryList())
182✔
65
    {
66
        if (!file.endsWith(".js", Qt::CaseInsensitive))
174✔
67
        {
68
            qDebug() << "    " << file << " skipped (special file or does not end on *.js)";
18✔
69
            continue;
18✔
70
        }
71
        QFile absFile(dir.absoluteFilePath(file));
156✔
72
        QString absFilename = absFile.fileName();
156✔
73

74
        if (m_scriptsMap.value(absFilename).isEmpty())
156✔
75
        {
76
            if (!absFile.open(QIODevice::ReadOnly | QIODevice::Text))
156✔
NEW
77
                return false;
×
78

79
            QTextStream in(&absFile);
156✔
80
            QString line = in.readLine();
156✔
81
            while (!line.isNull())
4,436✔
82
            {
83
                QStringList tokens = line.split("=");
4,436✔
84
                if (tokens.length() == 2 && tokens[0].simplified() == "algo.name")
4,436✔
85
                {
86
                    QString algoName = tokens[1].simplified().remove('"');
156✔
87
                    algoName.remove(';');
156✔
88
                    m_scriptsMap.insert(algoName, absFilename);
156✔
89
                    qDebug() << "    " << algoName << "script loaded";
156✔
90
                    break;
156✔
91
                }
156✔
92
                line = in.readLine();
4,280✔
93
            }
4,436✔
94
            absFile.close();
156✔
95
        }
156✔
96
        else
97
        {
UNCOV
98
            qDebug() << "    " << file << " already known";
×
99
        }
100
    }
334✔
101
    return true;
4✔
102
}
103

104
QDir RGBScriptsCache::systemScriptsDirectory()
1✔
105
{
106
    return QLCFile::systemDirectory(QString(RGBSCRIPTDIR), QString(".js"));
2✔
107
}
108

109
QDir RGBScriptsCache::userScriptsDirectory()
1✔
110
{
111
    return QLCFile::userDirectory(QString(USERRGBSCRIPTDIR), QString(RGBSCRIPTDIR),
2✔
112
            QStringList() << QString("*%1").arg(".js"));
3✔
113
}
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

© 2026 Coveralls, Inc