mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 19:42:45 +01:00
Remove WallpaperType and WidgetType to merge into InstalledType
This is needed because we have one type enum inside the projectfile struct. Also we now use qmlRegisterUncreatableMetaObject with a namespace for every enum to "enumalte" enum classes in QML
This commit is contained in:
parent
cb6b438feb
commit
2b1ba81c94
@ -86,13 +86,11 @@ App::App()
|
||||
qRegisterMetaType<InstalledListFilter*>();
|
||||
qRegisterMetaType<MonitorListModel*>();
|
||||
qRegisterMetaType<ProfileListModel*>();
|
||||
qRegisterMetaType<Enums::FillMode>();
|
||||
qRegisterMetaType<Enums::WallpaperType>();
|
||||
qRegisterMetaType<Enums::WidgetType>();
|
||||
|
||||
// Registers the enums from globalvariables.
|
||||
// Apparently this is the only way for qml to work
|
||||
// https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/
|
||||
qRegisterMetaType<Enums::FillMode>();
|
||||
qmlRegisterUncreatableMetaObject(ScreenPlay::Enums::staticMetaObject,
|
||||
"ScreenPlayEnums",
|
||||
1, 0,
|
||||
|
@ -26,8 +26,9 @@ Item {
|
||||
txtHeadline.text = ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenTitle
|
||||
|
||||
if (ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenPreviewGIF === undefined) {
|
||||
const hasPreviewGif = ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenPreviewGIF !== undefined
|
||||
if (!hasPreviewGif) {
|
||||
image.source = Qt.resolvedUrl(
|
||||
ScreenPlay.globalVariables.localStoragePath + "/"
|
||||
+ root.contentFolderName + "/" + ScreenPlay.installedListModel.get(
|
||||
@ -42,7 +43,7 @@ Item {
|
||||
image.playing = true
|
||||
}
|
||||
|
||||
if (isWidget() || monitorSelection.activeMonitors.length > 0) {
|
||||
if (isWidget() || (monitorSelection.activeMonitors.length > 0)) {
|
||||
btnSetWallpaper.enabled = true
|
||||
return
|
||||
}
|
||||
@ -338,7 +339,10 @@ Item {
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
print(root.type, root.isWidget(),root.isWallpaper())
|
||||
const absoluteStoragePath = ScreenPlay.globalVariables.localStoragePath
|
||||
+ "/" + root.contentFolderName
|
||||
const previewImage = ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenPreview
|
||||
if (root.isWallpaper()) {
|
||||
let activeMonitors = monitorSelection.getActiveMonitors(
|
||||
)
|
||||
@ -347,23 +351,22 @@ Item {
|
||||
if (activeMonitors.length === 0)
|
||||
return
|
||||
|
||||
const volume = Math.round(
|
||||
sliderVolume.value * 100) / 100
|
||||
const screenFile = ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenFile
|
||||
|
||||
ScreenPlay.screenPlayManager.createWallpaper(
|
||||
root.type, cbVideoFillMode.currentValue,
|
||||
ScreenPlay.globalVariables.localStoragePath + "/"
|
||||
+ root.contentFolderName, ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenPreview, ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenFile, activeMonitors,
|
||||
(Math.round(sliderVolume.value * 100) / 100),
|
||||
true)
|
||||
} else if (root.isWidget()) {
|
||||
print("widget")
|
||||
ScreenPlay.screenPlayManager.createWidget(
|
||||
ScreenPlay.globalVariables.localStoragePath
|
||||
+ "/" + root.contentFolderName,
|
||||
ScreenPlay.installedListModel.get(
|
||||
root.contentFolderName).screenPreview,
|
||||
type)
|
||||
absoluteStoragePath, previewImage,
|
||||
screenFile, activeMonitors, volume, true)
|
||||
}
|
||||
|
||||
if (root.isWidget()) {
|
||||
ScreenPlay.screenPlayManager.createWidget(
|
||||
type, absoluteStoragePath, previewImage)
|
||||
}
|
||||
|
||||
root.state = "inactive"
|
||||
monitorSelection.deselectAll()
|
||||
}
|
||||
|
@ -80,19 +80,6 @@ namespace Enums {
|
||||
};
|
||||
Q_ENUM_NS(FillMode)
|
||||
|
||||
enum class WallpaperType {
|
||||
VideoWallpaper,
|
||||
QMLWallpaper,
|
||||
HTMLWallpaper
|
||||
};
|
||||
Q_ENUM_NS(WallpaperType)
|
||||
|
||||
enum class WidgetType {
|
||||
QMLWidget,
|
||||
HTMLWidget
|
||||
};
|
||||
Q_ENUM_NS(WidgetType)
|
||||
|
||||
}
|
||||
|
||||
class GlobalVariables : public QObject {
|
||||
|
@ -88,7 +88,6 @@ struct ProjectFile {
|
||||
for (const auto& tag : tagArray) {
|
||||
m_tags.append(tag.toString());
|
||||
}
|
||||
qInfo() << m_tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ ScreenPlayManager::ScreenPlayManager(
|
||||
if we call the method when using via the settings on startup to skip a unnecessary save.
|
||||
*/
|
||||
void ScreenPlayManager::createWallpaper(
|
||||
const Enums::WallpaperType type,
|
||||
const InstalledType::InstalledType type,
|
||||
const Enums::FillMode fillMode,
|
||||
const QString& absoluteStoragePath,
|
||||
const QString& previewImage,
|
||||
@ -56,8 +56,8 @@ void ScreenPlayManager::createWallpaper(
|
||||
monitors.append(index);
|
||||
}
|
||||
|
||||
QString path = QUrl::fromUserInput(absoluteStoragePath).toLocalFile();
|
||||
QString appID = Util::generateRandomString();
|
||||
const QString path = QUrl::fromUserInput(absoluteStoragePath).toLocalFile();
|
||||
const QString appID = Util::generateRandomString();
|
||||
|
||||
std::shared_ptr<ScreenPlayWallpaper> wallpaper;
|
||||
wallpaper = std::make_shared<ScreenPlayWallpaper>(
|
||||
@ -101,23 +101,20 @@ void ScreenPlayManager::createWallpaper(
|
||||
\brief Creates a ScreenPlayWidget object via a \a absoluteStoragePath and a \a preview image (relative path).
|
||||
*/
|
||||
void ScreenPlayManager::createWidget(
|
||||
const Enums::WidgetType type,
|
||||
const QUrl& absoluteStoragePath,
|
||||
const InstalledType::InstalledType type,
|
||||
const QString& absoluteStoragePath,
|
||||
const QString& previewImage)
|
||||
{
|
||||
if (m_telemetry) {
|
||||
m_telemetry->sendEvent("widget", "start");
|
||||
}
|
||||
increaseActiveWidgetsCounter();
|
||||
const QString appID = Util::generateRandomString();
|
||||
const QString path = QUrl::fromUserInput(absoluteStoragePath).toLocalFile();
|
||||
|
||||
m_screenPlayWidgets.append(
|
||||
std::make_unique<ScreenPlayWidget>(
|
||||
Util::generateRandomString(),
|
||||
m_globalVariables,
|
||||
absoluteStoragePath.toLocalFile(),
|
||||
previewImage,
|
||||
absoluteStoragePath.toString(),
|
||||
type));
|
||||
if (path.isEmpty()) {
|
||||
qInfo() << "Path is empty, Abort! String: " << absoluteStoragePath;
|
||||
return;
|
||||
}
|
||||
|
||||
increaseActiveWidgetsCounter();
|
||||
m_screenPlayWidgets.append(std::make_unique<ScreenPlayWidget>(appID, m_globalVariables, path, previewImage, type));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -368,7 +365,7 @@ void ScreenPlayManager::loadProfiles()
|
||||
QString file = wallpaperObj.value("file").toString();
|
||||
QString typeString = wallpaperObj.value("type").toString();
|
||||
|
||||
auto type = QStringToEnum<Enums::WallpaperType>(typeString, Enums::WallpaperType::VideoWallpaper);
|
||||
auto type = QStringToEnum<InstalledType::InstalledType>(typeString, InstalledType::InstalledType::VideoWallpaper);
|
||||
auto fillMode = QStringToEnum<Enums::FillMode>(fillModeString, Enums::FillMode::Cover);
|
||||
|
||||
createWallpaper(type, fillMode, absolutePath, previewImage, file, monitors, volume, false);
|
||||
|
@ -83,14 +83,17 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
void projectSettingsListModelResult(const bool found, ProjectSettingsListModel* li = nullptr, const ScreenPlay::Enums::WallpaperType type = ScreenPlay::Enums::WallpaperType::VideoWallpaper);
|
||||
void projectSettingsListModelResult(
|
||||
const bool found,
|
||||
ProjectSettingsListModel* li = nullptr,
|
||||
const ScreenPlay::InstalledType::InstalledType type = ScreenPlay::InstalledType::InstalledType::VideoWallpaper);
|
||||
void activeWallpaperCounterChanged(int activeWallpaperCounter);
|
||||
void activeWidgetsCounterChanged(int activeWidgetsCounter);
|
||||
|
||||
public slots:
|
||||
// moc needs full enum namespace info see QTBUG-58454
|
||||
void createWallpaper(
|
||||
const ScreenPlay::Enums::WallpaperType type,
|
||||
const ScreenPlay::InstalledType::InstalledType type,
|
||||
const ScreenPlay::Enums::FillMode fillMode,
|
||||
const QString& absoluteStoragePath,
|
||||
const QString& previewImage,
|
||||
@ -100,8 +103,8 @@ public slots:
|
||||
const bool saveToProfilesConfigFile);
|
||||
|
||||
void createWidget(
|
||||
const ScreenPlay::Enums::WidgetType type,
|
||||
const QUrl& absoluteStoragePath,
|
||||
const ScreenPlay::InstalledType::InstalledType type,
|
||||
const QString& absoluteStoragePath,
|
||||
const QString& previewImage);
|
||||
|
||||
void removeAllWallpapers();
|
||||
|
@ -22,11 +22,11 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
|
||||
const QString& file,
|
||||
const float volume,
|
||||
const Enums::FillMode fillMode,
|
||||
const Enums::WallpaperType type,
|
||||
const InstalledType::InstalledType type,
|
||||
const bool checkWallpaperVisible,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_projectSettingsListModel { absolutePath + "/project.json"}
|
||||
, m_projectSettingsListModel { absolutePath + "/project.json" }
|
||||
, m_globalVariables { globalVariables }
|
||||
, m_screenNumber { screenNumber }
|
||||
, m_previewImage { previewImage }
|
||||
@ -72,7 +72,6 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
|
||||
m_process.startDetached();
|
||||
}
|
||||
|
||||
|
||||
QJsonObject ScreenPlayWallpaper::getActiveSettingsJson()
|
||||
{
|
||||
QJsonArray screenNumber;
|
||||
|
@ -61,7 +61,7 @@ class ScreenPlayWallpaper : public QObject {
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
|
||||
Q_PROPERTY(Enums::FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
||||
Q_PROPERTY(Enums::WallpaperType type READ type WRITE setType NOTIFY typeChanged)
|
||||
Q_PROPERTY(InstalledType::InstalledType type READ type WRITE setType NOTIFY typeChanged)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayWallpaper(
|
||||
@ -73,7 +73,7 @@ public:
|
||||
const QString& file,
|
||||
const float volume,
|
||||
const Enums::FillMode fillMode,
|
||||
const Enums::WallpaperType type,
|
||||
const InstalledType::InstalledType type,
|
||||
const bool checkWallpaperVisible,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
@ -94,7 +94,7 @@ public:
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
Enums::WallpaperType type() const
|
||||
InstalledType::InstalledType type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
@ -130,7 +130,7 @@ signals:
|
||||
void screenNumberChanged(QVector<int> screenNumber);
|
||||
void previewImageChanged(QString previewImage);
|
||||
void appIDChanged(QString appID);
|
||||
void typeChanged(Enums::WallpaperType type);
|
||||
void typeChanged(InstalledType::InstalledType type);
|
||||
void fileChanged(QString file);
|
||||
void fillModeChanged(Enums::FillMode fillMode);
|
||||
void absolutePathChanged(QString absolutePath);
|
||||
@ -169,7 +169,7 @@ public slots:
|
||||
emit appIDChanged(m_appID);
|
||||
}
|
||||
|
||||
void setType(Enums::WallpaperType type)
|
||||
void setType(InstalledType::InstalledType type)
|
||||
{
|
||||
if (m_type == type)
|
||||
return;
|
||||
@ -235,7 +235,7 @@ private:
|
||||
QVector<int> m_screenNumber;
|
||||
|
||||
QString m_previewImage;
|
||||
Enums::WallpaperType m_type;
|
||||
InstalledType::InstalledType m_type;
|
||||
Enums::FillMode m_fillMode;
|
||||
QString m_appID;
|
||||
QString m_absolutePath;
|
||||
|
@ -13,12 +13,12 @@ namespace ScreenPlay {
|
||||
/*!
|
||||
\brief Constructor.
|
||||
*/
|
||||
ScreenPlayWidget::ScreenPlayWidget(const QString& appID,
|
||||
ScreenPlayWidget::ScreenPlayWidget(
|
||||
const QString& appID,
|
||||
const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||
const QString& projectPath,
|
||||
const QString& previewImage,
|
||||
const QString& fullPath,
|
||||
const Enums::WidgetType type)
|
||||
const InstalledType::InstalledType type)
|
||||
: QObject { nullptr }
|
||||
, m_globalVariables { globalVariables }
|
||||
, m_projectPath { projectPath }
|
||||
@ -32,15 +32,11 @@ ScreenPlayWidget::ScreenPlayWidget(const QString& appID,
|
||||
QString { "appID=" + m_appID },
|
||||
QVariant::fromValue(m_type).toString()
|
||||
};
|
||||
|
||||
m_process.setArguments(proArgs);
|
||||
m_process.setProgram(m_globalVariables->widgetExecutablePath().path());
|
||||
|
||||
if (fullPath.endsWith(".exe")) {
|
||||
m_process.setProgram(fullPath);
|
||||
} else {
|
||||
m_process.setProgram(m_globalVariables->widgetExecutablePath().path());
|
||||
}
|
||||
|
||||
qDebug() << m_process.program();
|
||||
qDebug() << proArgs;
|
||||
|
||||
QObject::connect(&m_process, &QProcess::errorOccurred, this, [](QProcess::ProcessError error) {
|
||||
qDebug() << "error: " << error;
|
||||
|
@ -53,16 +53,14 @@ class ScreenPlayWidget : public QObject {
|
||||
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
||||
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
Q_PROPERTY(Enums::WidgetType type READ type WRITE setType NOTIFY typeChanged)
|
||||
Q_PROPERTY(InstalledType::InstalledType type READ type WRITE setType NOTIFY typeChanged)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayWidget(
|
||||
const QString& appID,
|
||||
explicit ScreenPlayWidget(const QString& appID,
|
||||
const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||
const QString& projectPath,
|
||||
const QString& previewImage,
|
||||
const QString& fullPath,
|
||||
const Enums::WidgetType type);
|
||||
const InstalledType::InstalledType type);
|
||||
|
||||
~ScreenPlayWidget() { }
|
||||
|
||||
@ -86,7 +84,7 @@ public:
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
Enums::WidgetType type() const
|
||||
InstalledType::InstalledType type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
@ -128,7 +126,7 @@ public slots:
|
||||
emit appIDChanged(m_appID);
|
||||
}
|
||||
|
||||
void setType(Enums::WidgetType type)
|
||||
void setType(InstalledType::InstalledType type)
|
||||
{
|
||||
if (m_type == type)
|
||||
return;
|
||||
@ -142,7 +140,7 @@ signals:
|
||||
void previewImageChanged(QString previewImage);
|
||||
void positionChanged(QPoint position);
|
||||
void appIDChanged(QString appID);
|
||||
void typeChanged(Enums::WidgetType type);
|
||||
void typeChanged(InstalledType::InstalledType type);
|
||||
|
||||
private:
|
||||
QProcess m_process;
|
||||
@ -152,6 +150,6 @@ private:
|
||||
QString m_previewImage;
|
||||
QString m_appID;
|
||||
QPoint m_position;
|
||||
Enums::WidgetType m_type;
|
||||
InstalledType::InstalledType m_type;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user