mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:48:56 +02:00
Added screenshot format selection with PNG, JPEG and WEBM support
This commit is contained in:
parent
ecf54a60be
commit
eed83ac85a
3 changed files with 112 additions and 3 deletions
|
@ -258,6 +258,28 @@ void setupPreferences() {
|
||||||
preferences->addPreference(new CheckPreference(SNAPSHOTS, "Display snapshot notifications", getter, setter));
|
preferences->addPreference(new CheckPreference(SNAPSHOTS, "Display snapshot notifications", getter, setter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto getter = []()->int { return DependencyManager::get<Snapshot>()->getAvailableSnapshotFormats().indexOf(DependencyManager::get<Snapshot>()->getSnapshotFormat()); };
|
||||||
|
auto setter = [](int value) { DependencyManager::get<Snapshot>()->setSnapshotFormat(DependencyManager::get<Snapshot>()->getAvailableSnapshotFormats()[value]); };
|
||||||
|
auto preference = new RadioButtonsPreference(SNAPSHOTS, "Snapshot format", getter, setter);
|
||||||
|
QStringList items;
|
||||||
|
items << DependencyManager::get<Snapshot>()->getAvailableSnapshotFormats();
|
||||||
|
preference->setHeading("Snapshot format");
|
||||||
|
preference->setItems(items);
|
||||||
|
preferences->addPreference(preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto getter = []()->int { return DependencyManager::get<Snapshot>()->getAvailableAnimatedSnapshotFormats().indexOf(DependencyManager::get<Snapshot>()->getAnimatedSnapshotFormat()); };
|
||||||
|
auto setter = [](int value) { DependencyManager::get<Snapshot>()->setAnimatedSnapshotFormat(DependencyManager::get<Snapshot>()->getAvailableAnimatedSnapshotFormats()[value]); };
|
||||||
|
auto preference = new RadioButtonsPreference(SNAPSHOTS, "Animated snapshot format", getter, setter);
|
||||||
|
QStringList items;
|
||||||
|
items << DependencyManager::get<Snapshot>()->getAvailableAnimatedSnapshotFormats();
|
||||||
|
preference->setHeading("Animated snapshot format");
|
||||||
|
preference->setItems(items);
|
||||||
|
preferences->addPreference(preference);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto getter = []()->bool { return !Menu::getInstance()->isOptionChecked(MenuOption::DisableActivityLogger); };
|
auto getter = []()->bool { return !Menu::getInstance()->isOptionChecked(MenuOption::DisableActivityLogger); };
|
||||||
auto setter = [](bool value) { Menu::getInstance()->setIsOptionChecked(MenuOption::DisableActivityLogger, !value); };
|
auto setter = [](bool value) { Menu::getInstance()->setIsOptionChecked(MenuOption::DisableActivityLogger, !value); };
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Stojce Slavkovski on 1/26/14.
|
// Created by Stojce Slavkovski on 1/26/14.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
// Copyright 2022 Overte e.V.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -44,12 +45,13 @@
|
||||||
|
|
||||||
// filename format: overte-snap-by-%username%-on-%date%_%time%_@-%location%.png
|
// filename format: overte-snap-by-%username%-on-%date%_%time%_@-%location%.png
|
||||||
// %1 <= username, %2 <= date and time, %3 <= current location
|
// %1 <= username, %2 <= date and time, %3 <= current location
|
||||||
const QString FILENAME_PATH_FORMAT = "overte-snap-by-%1-on-%2.png";
|
const QString FILENAME_PATH_FORMAT = "overte-snap-by-%1-on-%2";
|
||||||
|
const QString DEFAULT_FORMAT = "png";
|
||||||
const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss";
|
const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss";
|
||||||
const QString SNAPSHOTS_DIRECTORY = "Snapshots";
|
const QString SNAPSHOTS_DIRECTORY = "Snapshots";
|
||||||
const QString URL = "overte_url";
|
const QString URL = "overte_url";
|
||||||
static const int SNAPSHOT_360_TIMER_INTERVAL = 350;
|
static const int SNAPSHOT_360_TIMER_INTERVAL = 350;
|
||||||
static const QList<QString> SUPPORTED_IMAGE_FORMATS = { "jpg", "jpeg", "png" };
|
static const QList<QString> SUPPORTED_IMAGE_FORMATS = { "jpg", "jpeg", "png", "webp" };
|
||||||
|
|
||||||
Snapshot::Snapshot() {
|
Snapshot::Snapshot() {
|
||||||
_snapshotTimer.setSingleShot(false);
|
_snapshotTimer.setSingleShot(false);
|
||||||
|
@ -110,6 +112,7 @@ QString Snapshot::saveSnapshot(QImage image, const QString& filename, const QStr
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const float CUBEMAP_SIDE_PIXEL_DIMENSION = 2048.0f;
|
static const float CUBEMAP_SIDE_PIXEL_DIMENSION = 2048.0f;
|
||||||
static const float SNAPSHOT_360_FOV = 90.0f;
|
static const float SNAPSHOT_360_FOV = 90.0f;
|
||||||
static const float SNAPSHOT_360_NEARCLIP = 0.3f;
|
static const float SNAPSHOT_360_NEARCLIP = 0.3f;
|
||||||
|
@ -389,7 +392,11 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot,
|
||||||
imageQuality = 50;
|
imageQuality = 50;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT));
|
QString selectedFormat(DEFAULT_FORMAT);
|
||||||
|
if (_snapshotFormat.get() != "") {
|
||||||
|
selectedFormat = _snapshotFormat.get();
|
||||||
|
}
|
||||||
|
filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT)) + "." + selectedFormat;
|
||||||
QFileInfo snapshotFileInfo(filename);
|
QFileInfo snapshotFileInfo(filename);
|
||||||
QString filenameSuffix = snapshotFileInfo.suffix();
|
QString filenameSuffix = snapshotFileInfo.suffix();
|
||||||
filenameSuffix = filenameSuffix.toLower();
|
filenameSuffix = filenameSuffix.toLower();
|
||||||
|
@ -516,3 +523,37 @@ QString Snapshot::getSnapshotsLocation() {
|
||||||
void Snapshot::setSnapshotsLocation(const QString& location) {
|
void Snapshot::setSnapshotsLocation(const QString& location) {
|
||||||
_snapshotsLocation.set(location);
|
_snapshotsLocation.set(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Snapshot::getSnapshotFormat(){
|
||||||
|
return _snapshotFormat.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Snapshot::setSnapshotFormat(const QString& format){
|
||||||
|
if (getAvailableSnapshotFormats().contains(format)) {
|
||||||
|
_snapshotFormat.set(format);
|
||||||
|
qDebug() << "Snapshot format set: " << format;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Snapshot format not supported: " << format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Snapshot::getAnimatedSnapshotFormat(){
|
||||||
|
return _animatedSnapshotFormat.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Snapshot::setAnimatedSnapshotFormat(const QString& format){
|
||||||
|
if (getAvailableAnimatedSnapshotFormats().contains(format)) {
|
||||||
|
_animatedSnapshotFormat.set(format);
|
||||||
|
qDebug() << "Snapshot format set: " << format;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Snapshot format not supported: " << format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Snapshot::getAvailableSnapshotFormats() {
|
||||||
|
return QStringList({"png", "jpg", "webp"});
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Snapshot::getAvailableAnimatedSnapshotFormats() {
|
||||||
|
return QStringList({"gif"});
|
||||||
|
}
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
|
|
||||||
Setting::Handle<QString> _snapshotsLocation{ "snapshotsLocation" };
|
Setting::Handle<QString> _snapshotsLocation{ "snapshotsLocation" };
|
||||||
Setting::Handle<bool> _snapshotNotifications{ "snapshotNotifications", true };
|
Setting::Handle<bool> _snapshotNotifications{ "snapshotNotifications", true };
|
||||||
|
Setting::Handle<QString> _snapshotFormat{ "snapshotFormat" };
|
||||||
|
Setting::Handle<QString> _animatedSnapshotFormat{ "animatedSnapshotFormat" };
|
||||||
void uploadSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
void uploadSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -98,6 +100,50 @@ public slots:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Gets the currently selected snapshot format.
|
||||||
|
* @function Snapshot.getSnapshotFormat
|
||||||
|
* @returns {string} Currently selected snapshot format.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QString getSnapshotFormat();
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Sets the snapshot format.
|
||||||
|
* @function Snapshot.setSnapshotFormat
|
||||||
|
* @param {String} format - one of the format names returned by Snapshot.getAvailableSnapshotFormats().
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void setSnapshotFormat(const QString& format);
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Gets the currently selected animated snapshot format.
|
||||||
|
* @function Snapshot.getAnimatedSnapshotFormat
|
||||||
|
* @returns {Array.<string>} Currently selected snapshot format.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QString getAnimatedSnapshotFormat();
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Sets the snapshot format.
|
||||||
|
* @function Snapshot.setAnimatedSnapshotFormat
|
||||||
|
* @param {String} format - one of the format names returned by Snapshot.getAvailableSnapshotFormats().
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void setAnimatedSnapshotFormat(const QString& format);
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Returns a list of supported snapshot formats.
|
||||||
|
* @function Snapshot.getAvailableSnapshotFormats
|
||||||
|
* @returns {Array.<string>} List of supported snapshot formats.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QStringList getAvailableSnapshotFormats();
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Returns a list of supported animated snapshot formats.
|
||||||
|
* @function Snapshot.getAvailableAnimatedSnapshotFormats
|
||||||
|
* @returns {Array.<string>} List of supported animated snapshot formats.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QStringList getAvailableAnimatedSnapshotFormats();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void takeNextSnapshot();
|
void takeNextSnapshot();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue