1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Add create of empty widgets

This commit is contained in:
kelteseth 2018-03-20 14:42:22 +01:00
parent a5af50b31c
commit 3b4494c485
10 changed files with 122 additions and 23 deletions

9
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "QtAV"] [submodule "ScreenPlay/examples"]
path = ScreenPlay/ThirdParty/QtAV path = ScreenPlay/examples
url = https://github.com/wang-bin/QtAV.git url = https://github.com/Aimber/ScreenPlay-examples.git
[submodule "stomt-qt-sdk"]
path = ScreenPlay/ThirdParty/stomt-qt-sdk
url = https://github.com/Aimber/stomt-qt-sdk.git

View File

@ -21,7 +21,8 @@ SOURCES += main.cpp \
src/projectsettingslistmodel.cpp \ src/projectsettingslistmodel.cpp \
src/startuperror.cpp \ src/startuperror.cpp \
src/screenplay.cpp \ src/screenplay.cpp \
src/qmlutilities.cpp src/qmlutilities.cpp \
src/create.cpp
RESOURCES += \ RESOURCES += \
Resources.qrc \ Resources.qrc \
@ -44,7 +45,8 @@ HEADERS += \
src/projectsettingslistmodel.h \ src/projectsettingslistmodel.h \
src/startuperror.h \ src/startuperror.h \
src/screenplay.h \ src/screenplay.h \
src/qmlutilities.h src/qmlutilities.h \
src/create.h
INCLUDEPATH += \ INCLUDEPATH += \
$$PWD/ThirdParty/ \ $$PWD/ThirdParty/ \

1
ScreenPlay/examples Submodule

@ -0,0 +1 @@
Subproject commit 66091ad14daa9122d0357fc7a98f29139f526fc6

View File

@ -264,7 +264,7 @@ Rectangle {
spacing: 20 spacing: 20
Button { Button {
text: qsTr("QML Quickstart Guide") text: qsTr("QML Quickstart Guide")
Material.background: Material.Blue Material.background: Material.Orange
Material.foreground: "white" Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_info.svg" icon.source: "qrc:/assets/icons/icon_info.svg"
icon.color:"white" icon.color:"white"
@ -280,25 +280,29 @@ Rectangle {
icon.color:"white" icon.color:"white"
icon.width: 16 icon.width: 16
icon.height: 16 icon.height: 16
onClicked: Qt.openUrlExternally("https://qmlbook.github.io/index.html")
} }
// Button {
// text: qsTr("Lore Ipsum")
// Material.background: Material.Orange
// Material.foreground: "white"
// icon.source: "qrc:/assets/icons/icon_plus.svg"
// icon.color:"white"
// icon.width: 16
// icon.height: 16
// }
Button { Button {
text: qsTr("Community") text: qsTr("Forums")
Material.background: Material.Orange Material.background: Material.Blue
Material.foreground: "white" Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_people.svg" icon.source: "qrc:/assets/icons/icon_people.svg"
icon.color:"white" icon.color:"white"
icon.width: 16 icon.width: 16
icon.height: 16 icon.height: 16
onClicked: Qt.openUrlExternally("http://forum.screen-play.rocks:4567/")
}
Button {
text: qsTr("Workshop")
Material.background: Material.Red
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_steam.svg"
icon.color: "white"
icon.width: 16
icon.height: 16
onClicked: Qt.openUrlExternally(
"steam://url/SteamWorkshopPage/672870")
} }
} }
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.9 import QtQuick 2.9
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import Qt.labs.platform 1.0
Item { Item {
state: "out" state: "out"
@ -27,8 +28,15 @@ Item {
anchors.topMargin: 20 anchors.topMargin: 20
imgSource: "qrc:/assets/icons/icon_emptyWidget.svg" imgSource: "qrc:/assets/icons/icon_emptyWidget.svg"
onClicked: { onClicked: {
folderDialog.open()
} }
FolderDialog {
id: folderDialog
onAccepted: {
screenPlayCreate.copyProject("/examples/scenes/empty", folderDialog.currentFolder)
}
}
} }
Text { Text {
id: txtExamples id: txtExamples
@ -77,6 +85,7 @@ Item {
buttonActive: true buttonActive: true
onClicked: { onClicked: {
} }
} }
} }

View File

@ -85,7 +85,7 @@ Item {
enabled: buttonActive enabled: buttonActive
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
btnEmpty.clicked()
} }
} }
} }

44
ScreenPlay/src/create.cpp Normal file
View File

@ -0,0 +1,44 @@
#include "create.h"
Create::Create(Settings *st, QMLUtilities *util, QObject *parent) : QObject(parent)
{
m_settings = st;
m_utils = util;
}
void Create::copyProject(QString relativeProjectPath, QString toPath)
{
if(toPath.contains("file:///")){
toPath.remove("file:///");
}
QString srcFilePath = m_settings->getScreenPlayBasePath().toString() + relativeProjectPath ;
// Todo: UI Error handling
if(copyRecursively(srcFilePath, toPath)){
emit m_utils->openFolderInExplorer(toPath);
}
}
bool Create::copyRecursively(const QString &srcFilePath, const QString &tgtFilePath)
{
QFileInfo srcFileInfo(srcFilePath);
if (srcFileInfo.isDir()) {
QDir targetDir(tgtFilePath);
targetDir.cdUp();
QDir sourceDir(srcFilePath);
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
foreach (const QString &fileName, fileNames) {
const QString newSrcFilePath
= srcFilePath + QLatin1Char('/') + fileName;
const QString newTgtFilePath
= tgtFilePath + QLatin1Char('/') + fileName;
if (!copyRecursively(newSrcFilePath, newTgtFilePath))
return false;
}
} else {
if (!QFile::copy(srcFilePath, tgtFilePath))
return false;
}
return true;
}

28
ScreenPlay/src/create.h Normal file
View File

@ -0,0 +1,28 @@
#pragma once
#include <QObject>
#include <QDir>
#include <QFileInfo>
#include <QStringList>
#include <QString>
#include <QFile>
#include "qmlutilities.h"
#include "settings.h"
class Create : public QObject
{
Q_OBJECT
public:
explicit Create(Settings* st, QMLUtilities* util,QObject *parent = nullptr);
signals:
public slots:
void copyProject(QString relativeProjectPath, QString toPath);
bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath);
private:
Settings* m_settings;
QMLUtilities* m_utils;
};

View File

@ -222,6 +222,16 @@ void Settings::createDefaultConfig()
defaultSettings.close(); defaultSettings.close();
} }
QUrl Settings::getScreenPlayBasePath() const
{
return m_screenPlayBasePath;
}
void Settings::setScreenPlayBasePath(QUrl screenPlayBasePath)
{
m_screenPlayBasePath = screenPlayBasePath;
}
QUrl Settings::getScreenPlayWindowPath() const QUrl Settings::getScreenPlayWindowPath() const
{ {
return m_screenPlayWindowPath; return m_screenPlayWindowPath;

View File

@ -118,6 +118,9 @@ public:
return m_offlineMode; return m_offlineMode;
} }
QUrl getScreenPlayBasePath() const;
void setScreenPlayBasePath(QUrl screenPlayBasePath);
signals: signals:
void autostartChanged(bool autostart); void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart); void highPriorityStartChanged(bool highPriorityStart);
@ -296,6 +299,7 @@ private:
QUrl m_localStoragePath; QUrl m_localStoragePath;
QUrl m_localSettingsPath; QUrl m_localSettingsPath;
QUrl m_screenPlayWindowPath; QUrl m_screenPlayWindowPath;
QUrl m_screenPlayBasePath;
bool m_hasWorkshopBannerSeen = false; bool m_hasWorkshopBannerSeen = false;
bool m_pauseWallpaperWhenIngame = true; bool m_pauseWallpaperWhenIngame = true;