diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index 3893c26f3c..91e05d020d 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -22,6 +22,7 @@ Item { property int animationDuration: hifi.effects.fadeInDuration property bool destroyOnInvisible: false + property real scale: 1.25 // Make this dialog a little larger than normal implicitWidth: addressBarDialog.implicitWidth implicitHeight: addressBarDialog.implicitHeight @@ -41,9 +42,9 @@ Item { id: backgroundImage source: "../images/address-bar.svg" - width: 576 - height: 80 - property int inputAreaHeight: 56 // Height of the background's input area + width: 576 * root.scale + height: 80 * root.scale + property int inputAreaHeight: 56.0 * root.scale // Height of the background's input area property int inputAreaStep: (height - inputAreaHeight) / 2 TextInput { @@ -58,7 +59,8 @@ Item { } - font.pointSize: 15 + font.pixelSize: hifi.fonts.pixelSize * root.scale + helperText: "Go to: place, @user, /path, network address" onAccepted: { diff --git a/interface/resources/qml/controls/SpinBox.qml b/interface/resources/qml/controls/SpinBox.qml index 7e44b9e4a3..1acba57409 100644 --- a/interface/resources/qml/controls/SpinBox.qml +++ b/interface/resources/qml/controls/SpinBox.qml @@ -9,7 +9,7 @@ Original.SpinBox { style: SpinBoxStyle { HifiConstants { id: hifi } font.family: hifi.fonts.fontFamily - font.pointSize: hifi.fonts.fontSize + font.pixelSize: hifi.fonts.pixelSize } } diff --git a/interface/resources/qml/controls/Text.qml b/interface/resources/qml/controls/Text.qml index 4f82f2d9e4..b7bd90d257 100644 --- a/interface/resources/qml/controls/Text.qml +++ b/interface/resources/qml/controls/Text.qml @@ -4,6 +4,6 @@ import "../styles" Original.Text { HifiConstants { id: hifi } font.family: hifi.fonts.fontFamily - font.pointSize: hifi.fonts.fontSize + font.pixelSize: hifi.fonts.pixelSize } diff --git a/interface/resources/qml/controls/TextArea.qml b/interface/resources/qml/controls/TextArea.qml index a86e76620a..6d8978c210 100644 --- a/interface/resources/qml/controls/TextArea.qml +++ b/interface/resources/qml/controls/TextArea.qml @@ -4,6 +4,6 @@ import "../styles" Original.TextArea { HifiConstants { id: hifi } font.family: hifi.fonts.fontFamily - font.pointSize: hifi.fonts.fontSize + font.pixelSize: hifi.fonts.pixelSize } diff --git a/interface/resources/qml/controls/TextEdit.qml b/interface/resources/qml/controls/TextEdit.qml index b59b20a3d6..4999c2bf5b 100644 --- a/interface/resources/qml/controls/TextEdit.qml +++ b/interface/resources/qml/controls/TextEdit.qml @@ -4,6 +4,6 @@ import "../styles" Original.TextEdit { HifiConstants { id: hifi } font.family: hifi.fonts.fontFamily - font.pointSize: hifi.fonts.fontSize + font.pixelSize: hifi.fonts.pixelSize } diff --git a/interface/resources/qml/controls/TextHeader.qml b/interface/resources/qml/controls/TextHeader.qml index 9ce1da4ac2..c52553331b 100644 --- a/interface/resources/qml/controls/TextHeader.qml +++ b/interface/resources/qml/controls/TextHeader.qml @@ -4,6 +4,6 @@ import "../styles" Text { HifiConstants { id: hifi } color: hifi.colors.hifiBlue - font.pointSize: hifi.fonts.headerPointSize + font.pixelSize: hifi.fonts.headerPixelSize font.bold: true } diff --git a/interface/resources/qml/controls/TextInput.qml b/interface/resources/qml/controls/TextInput.qml index d533c67bd6..b7ca6d2c1b 100644 --- a/interface/resources/qml/controls/TextInput.qml +++ b/interface/resources/qml/controls/TextInput.qml @@ -11,7 +11,7 @@ Original.TextInput { color: hifi.colors.text verticalAlignment: Original.TextInput.AlignVCenter font.family: hifi.fonts.fontFamily - font.pointSize: hifi.fonts.fontSize + font.pixelSize: hifi.fonts.pixelSize /* Original.Rectangle { @@ -23,7 +23,7 @@ Original.TextInput { */ Text { anchors.fill: parent - font.pointSize: parent.font.pointSize + font.pixelSize: parent.font.pixelSize font.family: parent.font.family verticalAlignment: parent.verticalAlignment horizontalAlignment: parent.horizontalAlignment diff --git a/interface/resources/qml/styles/HifiConstants.qml b/interface/resources/qml/styles/HifiConstants.qml index 702a396afb..fa556f2083 100644 --- a/interface/resources/qml/styles/HifiConstants.qml +++ b/interface/resources/qml/styles/HifiConstants.qml @@ -18,7 +18,7 @@ Item { readonly property color background: sysPalette.dark readonly property color text: sysPalette.text readonly property color disabledText: "gray" - readonly property color hintText: sysPalette.dark + readonly property color hintText: "gray" // A bit darker than sysPalette.dark so that it is visible on the DK2 readonly property color light: sysPalette.light readonly property alias activeWindow: activeWindow readonly property alias inactiveWindow: inactiveWindow @@ -36,9 +36,9 @@ Item { QtObject { id: fonts - readonly property real headerPointSize: 24 - readonly property string fontFamily: "Helvetica" - readonly property real fontSize: 18 + readonly property string fontFamily: "Arial" // Available on both Windows and OSX + readonly property real pixelSize: 22 // Logical pixel size; works on Windows and OSX at varying physical DPIs + readonly property real headerPixelSize: 32 } QtObject { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 798e698f69..111b893d15 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1701,12 +1701,9 @@ bool Application::acceptSnapshot(const QString& urlString) { SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); if (snapshotData) { - if (!snapshotData->getDomain().isEmpty()) { - DependencyManager::get()->getDomainHandler().setHostnameAndPort(snapshotData->getDomain()); + if (!snapshotData->getURL().toString().isEmpty()) { + DependencyManager::get()->handleLookupString(snapshotData->getURL().toString()); } - - _myAvatar->setPosition(snapshotData->getLocation()); - _myAvatar->setOrientation(snapshotData->getOrientation()); } else { QMessageBox msgBox; msgBox.setText("No location details were found in the file " @@ -3457,6 +3454,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, bool billb Glower glower; // Sets alpha to 1.0 _overlays.renderWorld(true); } + activeRenderingThread = nullptr; } diff --git a/interface/src/MainWindow.cpp b/interface/src/MainWindow.cpp index f60716dc48..e30de96890 100644 --- a/interface/src/MainWindow.cpp +++ b/interface/src/MainWindow.cpp @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include #include "MainWindow.h" #include "Menu.h" @@ -27,6 +30,7 @@ MainWindow::MainWindow(QWidget* parent) : _windowGeometry("WindowGeometry"), _windowState("WindowState", 0) { + setAcceptDrops(true); } void MainWindow::restoreGeometry() { @@ -87,13 +91,13 @@ void MainWindow::changeEvent(QEvent* event) { if (event->type() == QEvent::WindowStateChange) { QWindowStateChangeEvent* stateChangeEvent = static_cast(event); if ((stateChangeEvent->oldState() == Qt::WindowNoState || - stateChangeEvent->oldState() == Qt::WindowMaximized) && - windowState() == Qt::WindowMinimized) { + stateChangeEvent->oldState() == Qt::WindowMaximized) && + windowState() == Qt::WindowMinimized) { emit windowShown(false); } else { emit windowShown(true); } - + if (isFullScreen() != Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen)) { Menu::getInstance()->setIsOptionChecked(MenuOption::Fullscreen, isFullScreen()); } @@ -106,3 +110,13 @@ void MainWindow::changeEvent(QEvent* event) { } QMainWindow::changeEvent(event); } + +void MainWindow::dragEnterEvent(QDragEnterEvent* event) { + if (event->mimeData()) { + event->acceptProposedAction(); + } +} + +void MainWindow::dropEvent(QDropEvent* event) { + QCoreApplication::sendEvent(QCoreApplication::instance(), event); +} diff --git a/interface/src/MainWindow.h b/interface/src/MainWindow.h index c6faf8e01a..eb262e0f97 100644 --- a/interface/src/MainWindow.h +++ b/interface/src/MainWindow.h @@ -36,6 +36,8 @@ protected: virtual void showEvent(QShowEvent* event); virtual void hideEvent(QHideEvent* event); virtual void changeEvent(QEvent* event); + virtual void dragEnterEvent(QDragEnterEvent *e); + virtual void dropEvent(QDropEvent *e); private: Setting::Handle _windowGeometry; diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 0d91f4e7ba..2bfe92a504 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -15,8 +15,10 @@ #include #include #include +#include #include +#include #include #include #include @@ -28,131 +30,101 @@ // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg // %1 <= username, %2 <= date and time, %3 <= current location -const QString FILENAME_PATH_FORMAT = "hifi-snap-by-%1-on-%2@%3.jpg"; +const QString FILENAME_PATH_FORMAT = "hifi-snap-by-%1-on-%2.jpg"; const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss"; const QString SNAPSHOTS_DIRECTORY = "Snapshots"; -const QString LOCATION_X = "location-x"; -const QString LOCATION_Y = "location-y"; -const QString LOCATION_Z = "location-z"; - -const QString ORIENTATION_X = "orientation-x"; -const QString ORIENTATION_Y = "orientation-y"; -const QString ORIENTATION_Z = "orientation-z"; -const QString ORIENTATION_W = "orientation-w"; - -const QString DOMAIN_KEY = "domain"; +const QString URL = "highfidelity_url"; Setting::Handle Snapshot::snapshotsLocation("snapshotsLocation", - QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { - + if (!QFile(snapshotPath).exists()) { return NULL; } - + QImage shot(snapshotPath); - + // no location data stored - if (shot.text(LOCATION_X).isEmpty() || shot.text(LOCATION_Y).isEmpty() || shot.text(LOCATION_Z).isEmpty()) { + if (shot.text(URL).isEmpty()) { return NULL; } - + + // parsing URL + QUrl url = QUrl(shot.text(URL), QUrl::ParsingMode::StrictMode); + SnapshotMetaData* data = new SnapshotMetaData(); - data->setLocation(glm::vec3(shot.text(LOCATION_X).toFloat(), - shot.text(LOCATION_Y).toFloat(), - shot.text(LOCATION_Z).toFloat())); - - data->setOrientation(glm::quat(shot.text(ORIENTATION_W).toFloat(), - shot.text(ORIENTATION_X).toFloat(), - shot.text(ORIENTATION_Y).toFloat(), - shot.text(ORIENTATION_Z).toFloat())); - - data->setDomain(shot.text(DOMAIN_KEY)); - + data->setURL(url); + return data; } QString Snapshot::saveSnapshot(QImage image) { + QFile* snapshotFile = savedFileForSnapshot(image, false); - + // we don't need the snapshot file, so close it, grab its filename and delete it snapshotFile->close(); - + QString snapshotPath = QFileInfo(*snapshotFile).absoluteFilePath(); - + delete snapshotFile; - + return snapshotPath; } QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) { // return whatever we get back from saved file for snapshot - return static_cast(savedFileForSnapshot(image, true));; + return static_cast(savedFileForSnapshot(image, true)); } QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary) { - - Avatar* avatar = DependencyManager::get()->getMyAvatar(); - - glm::vec3 location = avatar->getPosition(); - glm::quat orientation = avatar->getHead()->getOrientation(); - - // add metadata - shot.setText(LOCATION_X, QString::number(location.x)); - shot.setText(LOCATION_Y, QString::number(location.y)); - shot.setText(LOCATION_Z, QString::number(location.z)); - - shot.setText(ORIENTATION_X, QString::number(orientation.x)); - shot.setText(ORIENTATION_Y, QString::number(orientation.y)); - shot.setText(ORIENTATION_Z, QString::number(orientation.z)); - shot.setText(ORIENTATION_W, QString::number(orientation.w)); - - shot.setText(DOMAIN_KEY, DependencyManager::get()->getDomainHandler().getHostname()); - QString formattedLocation = QString("%1_%2_%3").arg(location.x).arg(location.y).arg(location.z); - // replace decimal . with '-' - formattedLocation.replace('.', '-'); - + // adding URL to snapshot + QUrl currentURL = DependencyManager::get()->currentAddress(); + shot.setText(URL, currentURL.toString()); + QString username = AccountManager::getInstance().getAccountInfo().getUsername(); // normalize username, replace all non alphanumeric with '-' username.replace(QRegExp("[^A-Za-z0-9_]"), "-"); - + QDateTime now = QDateTime::currentDateTime(); - - QString filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT), formattedLocation); - + + QString filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT)); + const int IMAGE_QUALITY = 100; - + if (!isTemporary) { QString snapshotFullPath = snapshotsLocation.get(); - + if (!snapshotFullPath.endsWith(QDir::separator())) { snapshotFullPath.append(QDir::separator()); } - + snapshotFullPath.append(filename); - + QFile* imageFile = new QFile(snapshotFullPath); imageFile->open(QIODevice::WriteOnly); - + shot.save(imageFile, 0, IMAGE_QUALITY); imageFile->close(); - + return imageFile; + } else { QTemporaryFile* imageTempFile = new QTemporaryFile(QDir::tempPath() + "/XXXXXX-" + filename); - + if (!imageTempFile->open()) { qDebug() << "Unable to open QTemporaryFile for temp snapshot. Will not save."; return NULL; } - + shot.save(imageTempFile, 0, IMAGE_QUALITY); imageTempFile->close(); - + return imageTempFile; } } diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index e83f8b3ec4..5856743141 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -24,20 +24,12 @@ class QTemporaryFile; class SnapshotMetaData { public: - - QString getDomain() { return _domain; } - void setDomain(QString domain) { _domain = domain; } - - glm::vec3 getLocation() { return _location; } - void setLocation(glm::vec3 location) { _location = location; } - - glm::quat getOrientation() { return _orientation; } - void setOrientation(glm::quat orientation) { _orientation = orientation; } - + + QUrl getURL() { return _URL; } + void setURL(QUrl URL) { _URL = URL; } + private: - QString _domain; - glm::vec3 _location; - glm::quat _orientation;; + QUrl _URL; }; class Snapshot { @@ -45,7 +37,7 @@ public: static QString saveSnapshot(QImage image); static QTemporaryFile* saveTempSnapshot(QImage image); static SnapshotMetaData* parseSnapshotData(QString snapshotPath); - + static Setting::Handle snapshotsLocation; private: static QFile* savedFileForSnapshot(QImage & image, bool isTemporary); diff --git a/libraries/render-utils/src/OffscreenGlCanvas.cpp b/libraries/render-utils/src/OffscreenGlCanvas.cpp index a3025bc3f6..e41209a40c 100644 --- a/libraries/render-utils/src/OffscreenGlCanvas.cpp +++ b/libraries/render-utils/src/OffscreenGlCanvas.cpp @@ -16,6 +16,17 @@ OffscreenGlCanvas::OffscreenGlCanvas() { } +OffscreenGlCanvas::~OffscreenGlCanvas() { +#ifdef DEBUG + if (_logger) { + makeCurrent(); + delete _logger; + _logger = nullptr; + } +#endif + _context.doneCurrent(); +} + void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) { if (nullptr != sharedContext) { sharedContext->doneCurrent(); diff --git a/libraries/render-utils/src/OffscreenGlCanvas.h b/libraries/render-utils/src/OffscreenGlCanvas.h index 399737ddb8..7a69e276e4 100644 --- a/libraries/render-utils/src/OffscreenGlCanvas.h +++ b/libraries/render-utils/src/OffscreenGlCanvas.h @@ -20,6 +20,7 @@ class QOpenGLDebugLogger; class OffscreenGlCanvas : public QObject { public: OffscreenGlCanvas(); + ~OffscreenGlCanvas(); void create(QOpenGLContext* sharedContext = nullptr); bool makeCurrent(); void doneCurrent();