mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:36:45 +02:00
Added option to set snapshot location (for this execution only) from the command line.
This commit is contained in:
parent
3ebfe9efff
commit
cf9b089a3c
4 changed files with 25 additions and 8 deletions
|
@ -986,13 +986,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
|
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
|
||||||
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
||||||
{
|
{
|
||||||
const QString TEST_SCRIPT = "--testScript";
|
const QString TEST_SCRIPT { "--testScript" };
|
||||||
|
const QString TEST_SNAPSHOT_LOCATION { "--testSnapshotLocation" };
|
||||||
|
|
||||||
const QStringList args = arguments();
|
const QStringList args = arguments();
|
||||||
for (int i = 0; i < args.size() - 1; ++i) {
|
for (int i = 0; i < args.size() - 1; ++i) {
|
||||||
if (args.at(i) == TEST_SCRIPT) {
|
if (args.at(i) == TEST_SCRIPT) {
|
||||||
QString testScriptPath = args.at(i + 1);
|
QString testScriptPath = args.at(i + 1);
|
||||||
if (QFileInfo(testScriptPath).exists()) {
|
if (QFileInfo(testScriptPath).exists()) {
|
||||||
setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));
|
setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));
|
||||||
|
}
|
||||||
|
} else if (args.at(i) == TEST_SNAPSHOT_LOCATION) {
|
||||||
|
// Set test snapshot location only if it is a writeable directory
|
||||||
|
QString pathname(args.at(i + 1));
|
||||||
|
QFileInfo fileInfo(pathname);
|
||||||
|
if (fileInfo.isDir() && fileInfo.isWritable()) {
|
||||||
|
testSnapshotLocation = pathname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7259,7 +7268,7 @@ void Application::loadAvatarBrowser() const {
|
||||||
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
|
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
|
||||||
postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {
|
postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {
|
||||||
// Get a screenshot and save it
|
// Get a screenshot and save it
|
||||||
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename);
|
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, QString());
|
||||||
// If we're not doing an animated snapshot as well...
|
// If we're not doing an animated snapshot as well...
|
||||||
if (!includeAnimated) {
|
if (!includeAnimated) {
|
||||||
// Tell the dependency manager that the capture of the still snapshot has taken place.
|
// Tell the dependency manager that the capture of the still snapshot has taken place.
|
||||||
|
@ -7273,7 +7282,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
|
||||||
|
|
||||||
void Application::takeSecondaryCameraSnapshot(const QString& filename) {
|
void Application::takeSecondaryCameraSnapshot(const QString& filename) {
|
||||||
postLambdaEvent([filename, this] {
|
postLambdaEvent([filename, this] {
|
||||||
QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename);
|
QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testSnapshotLocation);
|
||||||
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
|
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -719,5 +719,7 @@ private:
|
||||||
|
|
||||||
std::atomic<bool> _pendingIdleEvent { true };
|
std::atomic<bool> _pendingIdleEvent { true };
|
||||||
std::atomic<bool> _pendingRenderEvent { true };
|
std::atomic<bool> _pendingRenderEvent { true };
|
||||||
|
|
||||||
|
QString testSnapshotLocation { QString() };
|
||||||
};
|
};
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -89,10 +89,10 @@ QString Snapshot::saveSnapshot(QImage image, const QString& filename) {
|
||||||
|
|
||||||
QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) {
|
QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) {
|
||||||
// return whatever we get back from saved file for snapshot
|
// return whatever we get back from saved file for snapshot
|
||||||
return static_cast<QTemporaryFile*>(savedFileForSnapshot(image, true));
|
return static_cast<QTemporaryFile*>(savedFileForSnapshot(image, true, QString(), QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename) {
|
QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, QString userSelectedPathname) {
|
||||||
|
|
||||||
// adding URL to snapshot
|
// adding URL to snapshot
|
||||||
QUrl currentURL = DependencyManager::get<AddressManager>()->currentPublicAddress();
|
QUrl currentURL = DependencyManager::get<AddressManager>()->currentPublicAddress();
|
||||||
|
@ -117,7 +117,13 @@ QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QSt
|
||||||
const int IMAGE_QUALITY = 100;
|
const int IMAGE_QUALITY = 100;
|
||||||
|
|
||||||
if (!isTemporary) {
|
if (!isTemporary) {
|
||||||
QString snapshotFullPath = snapshotsLocation.get();
|
// If user has requested specific path then use it, else use the application value
|
||||||
|
QString snapshotFullPath;
|
||||||
|
if (!userSelectedPathname.isNull()) {
|
||||||
|
snapshotFullPath = userSelectedPathname;
|
||||||
|
} else {
|
||||||
|
snapshotFullPath = snapshotsLocation.get();
|
||||||
|
}
|
||||||
|
|
||||||
if (snapshotFullPath.isEmpty()) {
|
if (snapshotFullPath.isEmpty()) {
|
||||||
snapshotFullPath = OffscreenUi::getExistingDirectory(nullptr, "Choose Snapshots Directory", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
snapshotFullPath = OffscreenUi::getExistingDirectory(nullptr, "Choose Snapshots Directory", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Snapshot : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
public:
|
public:
|
||||||
static QString saveSnapshot(QImage image, const QString& filename);
|
static QString saveSnapshot(QImage image, const QString& filename, const QString& pathname);
|
||||||
static QTemporaryFile* saveTempSnapshot(QImage image);
|
static QTemporaryFile* saveTempSnapshot(QImage image);
|
||||||
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public slots:
|
||||||
Q_INVOKABLE QString getSnapshotsLocation();
|
Q_INVOKABLE QString getSnapshotsLocation();
|
||||||
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
||||||
private:
|
private:
|
||||||
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename = QString());
|
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename, QString userSelectedPathname);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Snapshot_h
|
#endif // hifi_Snapshot_h
|
||||||
|
|
Loading…
Reference in a new issue