summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-04 16:34:14 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-07 06:27:00 +0000
commit201b976824faba8a7d56b636c7d5b147a1cb2888 (patch)
treef90289f71d445a814e248721a93abaff58428d8d
parentbd2eb9b978804ff509498244e863b80b0e0851b0 (diff)
Fix issues with popup positioning
- Unified various showBrowser functions under CDialogs as showWidgetBrowser - Fixed showWidgetBrowser logic to correctly determine browser popup position in all screens - Fixed startup dialog position when editor is maximized and on a secondary screen - Removed a few superfluous global utility functions. Task-number: QT3DS-1545 Change-Id: Ia8c526d14d8b15b649600d71474f1ba29657c00e Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Application/StudioTutorialWidget.cpp8
-rw-r--r--src/Authoring/Studio/Palettes/Action/ActionView.cpp42
-rw-r--r--src/Authoring/Studio/Palettes/Action/ActionView.h1
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp38
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h1
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.cpp29
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.h1
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp32
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h1
-rw-r--r--src/Authoring/Studio/Utils/StudioUtils.cpp61
-rw-r--r--src/Authoring/Studio/Utils/StudioUtils.h6
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.h2
-rw-r--r--src/Authoring/Studio/_Win/UI/StartupDlg.cpp10
-rw-r--r--src/Authoring/Studio/_Win/Workspace/Dialogs.cpp46
14 files changed, 80 insertions, 198 deletions
diff --git a/src/Authoring/Studio/Application/StudioTutorialWidget.cpp b/src/Authoring/Studio/Application/StudioTutorialWidget.cpp
index c0f77161..3ebd016c 100644
--- a/src/Authoring/Studio/Application/StudioTutorialWidget.cpp
+++ b/src/Authoring/Studio/Application/StudioTutorialWidget.cpp
@@ -77,7 +77,8 @@ void StudioTutorialWidget::OnInitDialog(bool goToFileDialog)
// screen and buttons comfortably on display
m_displayScale = getDisplayScalingForImage(m_imgIter);
QSize picSize = getPicSize(m_imgIter);
- QRect screenRect = QApplication::desktop()->availableGeometry(getWidgetScreen(this));
+ QRect screenRect = QApplication::desktop()->availableGeometry(
+ QApplication::desktop()->screenNumber(this));
QSize windowSize = screenRect.size();
m_ui->verticalWidget->setFixedSize(picSize);
@@ -241,12 +242,13 @@ qreal StudioTutorialWidget::getDisplayScalingForImage(const QList<QString>::iter
QPixmap picOrig = QPixmap(*iter);
// Note that high DPI scaling has an effect on the display
- // resolution returned by GetAvailableDisplaySize().
+ // resolution returned by QApplication::desktop()->availableGeometry().
// DPI scaling factor is integer and taken from the primary screen.
// When running studio on secondary monitor with different DPI,
// or running it on primary with non-integer scaling, we might
// get different dialog size than intended.
- QSize displaySize = GetAvailableDisplaySize(getWidgetScreen(this));
+ QSize displaySize = QApplication::desktop()->availableGeometry(
+ QApplication::desktop()->screenNumber(this)).size();
// Scale down if images do not fit on screen, otherwise use
// 1:1 PNGs to avoid scaling artifacts. Scale to 90% of the display size if scaling is needed.
diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.cpp b/src/Authoring/Studio/Palettes/Action/ActionView.cpp
index f6b15ab0..e320339d 100644
--- a/src/Authoring/Studio/Palettes/Action/ActionView.cpp
+++ b/src/Authoring/Studio/Palettes/Action/ActionView.cpp
@@ -32,6 +32,7 @@
#include "CmdDataModelActionSetValue.h"
#include "ClientDataModelBridge.h"
#include "Core.h"
+#include "Dialogs.h"
#include "Dispatch.h"
#include "Doc.h"
#include "IDocumentEditor.h"
@@ -385,7 +386,8 @@ QObject *ActionView::showTriggerObjectBrowser(const QPoint &point)
actionInfo.m_TriggerObject);
m_triggerObjectBrowser->selectAndExpand(instanceHandle, actionInfo.m_Owner);
- showBrowser(m_triggerObjectBrowser, point);
+ m_triggerObjectBrowser->disconnect();
+ CDialogs::showWidgetBrowser(this, m_triggerObjectBrowser, point);
connect(m_triggerObjectBrowser, &ObjectBrowserView::selectionChanged,
this, &ActionView::OnTriggerSelectionChanged);
@@ -416,7 +418,8 @@ QObject *ActionView::showTargetObjectBrowser(const QPoint &point)
actionInfo.m_TargetObject);
m_targetObjectBrowser->selectAndExpand(instanceHandle, actionInfo.m_Owner);
- showBrowser(m_targetObjectBrowser, point);
+ m_targetObjectBrowser->disconnect();
+ CDialogs::showWidgetBrowser(this, m_targetObjectBrowser, point);
connect(m_targetObjectBrowser, &ObjectBrowserView::selectionChanged,
this, &ActionView::OnTargetSelectionChanged);
@@ -477,7 +480,8 @@ QObject *ActionView::showEventBrowser(const QPoint &point)
m_eventsBrowser->setModel(m_eventsModel);
m_eventsBrowser->selectAndExpand(QString::fromStdWString(actionInfo.m_Event));
- showBrowser(m_eventsBrowser, point);
+ m_eventsBrowser->disconnect();
+ CDialogs::showWidgetBrowser(this, m_eventsBrowser, point);
connect(m_eventsBrowser, &EventsBrowserView::selectionChanged,
this, [this] {
@@ -512,7 +516,8 @@ QObject *ActionView::showHandlerBrowser(const QPoint &point)
m_handlerBrowser->setModel(m_handlersModel);
m_handlerBrowser->selectAndExpand(QString::fromStdWString(actionInfo.m_Handler));
- showBrowser(m_handlerBrowser, point);
+ m_handlerBrowser->disconnect();
+ CDialogs::showWidgetBrowser(this, m_handlerBrowser, point);
connect(m_handlerBrowser, &EventsBrowserView::selectionChanged,
this, [this] {
@@ -559,7 +564,8 @@ QObject *ActionView::showEventBrowserForArgument(int handle, const QPoint &point
}
}
m_fireEventsBrowser->selectAndExpand(eventName);
- showBrowser(m_fireEventsBrowser, point);
+ m_fireEventsBrowser->disconnect();
+ CDialogs::showWidgetBrowser(this, m_fireEventsBrowser, point);
connect(m_fireEventsBrowser, &EventsBrowserView::selectionChanged,
this, [this, handle] {
@@ -570,32 +576,6 @@ QObject *ActionView::showEventBrowserForArgument(int handle, const QPoint &point
return m_fireEventsBrowser;
}
-void ActionView::showBrowser(QQuickWidget *browser, const QPoint &point)
-{
- QSize popupSize = CStudioPreferences::browserPopupSize();
- browser->disconnect();
- browser->resize(popupSize);
-
- // Make sure the popup doesn't go outside the screen
- QSize screenSize = QApplication::desktop()->availableGeometry(
- QApplication::desktop()->screenNumber(this)).size();
- QPoint newPos = point - QPoint(popupSize.width(), popupSize.height());
- if (newPos.y() < 0)
- newPos.setY(0);
- if (newPos.x() + popupSize.width() > screenSize.width())
- newPos.setX(screenSize.width() - popupSize.width());
- else if (newPos.x() < 0)
- newPos.setX(0);
- browser->move(newPos);
-
- // Show asynchronously to avoid flashing blank window on first show
- QTimer::singleShot(0, this, [browser] {
- browser->show();
- browser->activateWindow();
- browser->setFocus();
- });
-}
-
void ActionView::updateFiredEvent()
{
if (!m_itemHandle.Valid())
diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.h b/src/Authoring/Studio/Palettes/Action/ActionView.h
index a4b71789..42d2b3be 100644
--- a/src/Authoring/Studio/Palettes/Action/ActionView.h
+++ b/src/Authoring/Studio/Palettes/Action/ActionView.h
@@ -177,7 +177,6 @@ private:
void updateFiredEvent();
void resetFiredEvent();
void updateFiredEventFromHandle(int handle);
- void showBrowser(QQuickWidget *browser, const QPoint &point);
void updateActionStates();
static CDoc *GetDoc();
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index f292416e..f8f6e41e 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -53,6 +53,7 @@
#include "ClientDataModelBridge.h"
#include "MainFrm.h"
#include "DataInputDlg.h"
+#include "Dialogs.h"
#include <QtCore/qtimer.h>
#include <QtQml/qqmlcontext.h>
@@ -367,7 +368,7 @@ QObject *InspectorControlView::showImageChooser(int handle, int instance, const
m_imageChooserView->setHandle(handle);
m_imageChooserView->setInstance(instance);
- showBrowser(m_imageChooserView, point);
+ CDialogs::showWidgetBrowser(this, m_imageChooserView, point);
return m_imageChooserView;
}
@@ -386,7 +387,7 @@ QObject *InspectorControlView::showFilesChooser(int handle, int instance, const
m_fileChooserView->setHandle(handle);
m_fileChooserView->setInstance(instance);
- showBrowser(m_fileChooserView, point);
+ CDialogs::showWidgetBrowser(this, m_fileChooserView, point);
return m_fileChooserView;
}
@@ -409,7 +410,7 @@ QObject *InspectorControlView::showMeshChooser(int handle, int instance, const Q
m_meshChooserView->setHandle(handle);
m_meshChooserView->setInstance(instance);
- showBrowser(m_meshChooserView, point);
+ CDialogs::showWidgetBrowser(this, m_meshChooserView, point);
return m_meshChooserView;
}
@@ -428,7 +429,7 @@ QObject *InspectorControlView::showTextureChooser(int handle, int instance, cons
m_textureChooserView->setHandle(handle);
m_textureChooserView->setInstance(instance);
- showBrowser(m_textureChooserView, point);
+ CDialogs::showWidgetBrowser(this, m_textureChooserView, point);
return m_textureChooserView;
}
@@ -469,7 +470,7 @@ QObject *InspectorControlView::showObjectReference(int handle, int instance, con
m_objectReferenceView->selectAndExpand(refInstance, instance);
}
- showBrowser(m_objectReferenceView, point);
+ CDialogs::showWidgetBrowser(this, m_objectReferenceView, point);
connect(m_objectReferenceView, &ObjectBrowserView::selectionChanged,
this, [this, doc, handle, instance] {
@@ -517,36 +518,11 @@ QObject *InspectorControlView::showDataInputChooser(int handle, int instance, co
setData(dataInputList,
m_inspectorControlModel->currentControllerValue(instance, handle),
handle, instance);
- showBrowser(m_dataInputChooserView, point);
+ CDialogs::showWidgetBrowser(this, m_dataInputChooserView, point);
return m_dataInputChooserView;
}
-void InspectorControlView::showBrowser(QQuickWidget *browser, const QPoint &point)
-{
- QSize popupSize = CStudioPreferences::browserPopupSize();
- browser->resize(popupSize);
-
- // Make sure the popup doesn't go outside the screen
- QSize screenSize = QApplication::desktop()->availableGeometry(
- QApplication::desktop()->screenNumber(this)).size();
- QPoint newPos = point - QPoint(popupSize.width(), popupSize.height());
- if (newPos.y() < 0)
- newPos.setY(0);
- if (newPos.x() + popupSize.width() > screenSize.width())
- newPos.setX(screenSize.width() - popupSize.width());
- else if (newPos.x() < 0)
- newPos.setX(0);
- browser->move(newPos);
-
- // Show asynchronously to avoid flashing blank window on first show
- QTimer::singleShot(0, this, [browser] {
- browser->show();
- browser->activateWindow();
- browser->setFocus();
- });
-}
-
bool InspectorControlView::toolTipsEnabled()
{
return CStudioPreferences::ShouldShowTooltips();
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
index f51f2285..2ea02c2e 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
@@ -108,7 +108,6 @@ private:
void OnTimeChanged();
void filterMaterials(std::vector<Q3DStudio::CFilePath> &materials);
void setPropertyValueFromFilename(long instance, int handle, const QString &name);
- void showBrowser(QQuickWidget *browser, const QPoint &point);
bool canLinkProperty(int instance, int handle) const;
void onInstancePropertyValueChanged(qt3dsdm::Qt3DSDMPropertyHandle propertyHandle);
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
index 23372aaf..cb9178ee 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
@@ -40,10 +40,10 @@
#include "DataInputSelectView.h"
#include "DataInputDlg.h"
#include "IDocumentEditor.h"
-
#include "ClientDataModelBridge.h"
#include "Qt3DSDMStudioSystem.h"
#include "Qt3DSDMSlides.h"
+#include "Dialogs.h"
#include <QtCore/qcoreapplication.h>
#include <QtCore/qtimer.h>
@@ -127,7 +127,7 @@ void SlideView::showControllerDialog(const QPoint &point)
g_StudioApp.m_dataInputDialogItems[i]->type));
}
m_dataInputSelector->setData(dataInputList, currCtr);
- showBrowser(m_dataInputSelector, point);
+ CDialogs::showWidgetBrowser(this, m_dataInputSelector, point);
return;
}
@@ -137,31 +137,6 @@ bool SlideView::toolTipsEnabled()
return CStudioPreferences::ShouldShowTooltips();
}
-void SlideView::showBrowser(QQuickWidget *browser, const QPoint &point)
-{
- QSize popupSize = CStudioPreferences::browserPopupSize();
- browser->resize(popupSize);
-
- // Make sure the popup doesn't go outside the screen
- QSize screenSize = QApplication::desktop()->availableGeometry(
- QApplication::desktop()->screenNumber(this)).size();
- QPoint newPos = point - QPoint(popupSize.width(), popupSize.height());
- if (newPos.y() < 0)
- newPos.setY(0);
- if (newPos.x() + popupSize.width() > screenSize.width())
- newPos.setX(screenSize.width() - popupSize.width());
- else if (newPos.x() < 0)
- newPos.setX(0);
- browser->move(newPos);
-
- // Show asynchronously to avoid flashing blank window on first show
- QTimer::singleShot(0, this, [browser] {
- browser->show();
- browser->activateWindow();
- browser->setFocus();
- });
-}
-
QSize SlideView::sizeHint() const
{
return {150, 500};
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h
index ee93532f..9ceb42f8 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.h
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h
@@ -116,7 +116,6 @@ private:
long GetSlideIndex(const qt3dsdm::Qt3DSDMSlideHandle &inSlideHandle);
bool isMaster(const qt3dsdm::Qt3DSDMSlideHandle &inSlideHandle);
void rebuildSlideList(const qt3dsdm::Qt3DSDMSlideHandle &inActiveSlideHandle);
- void showBrowser(QQuickWidget *browser, const QPoint &point);
SlideModel *m_CurrentModel = nullptr;
SlideModel *m_MasterSlideModel = nullptr;
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
index 1aff0c96..e80d4b22 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
@@ -38,9 +38,9 @@
#include "ClientDataModelBridge.h"
#include "IDocumentEditor.h"
#include "DocumentEditorEnumerations.h"
+#include "Dialogs.h"
#include <QtWidgets/qslider.h>
-#include <QtWidgets/qdesktopwidget.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qtimer.h>
@@ -292,35 +292,7 @@ void TimelineToolbar::showDataInputChooser(const QPoint &point)
}
m_dataInputSelector->setData(dataInputList, currCtr);
- showBrowser(m_dataInputSelector, point);
-}
-
-void TimelineToolbar::showBrowser(QQuickWidget *browser, const QPoint &point)
-{
- QSize popupSize = CStudioPreferences::browserPopupSize();
- browser->resize(popupSize);
-
- // Make sure the popup doesn't go outside the screen
- QSize screenSize = QApplication::desktop()->availableGeometry(
- QApplication::desktop()->screenNumber(this)).size();
- QPoint newPos = point - QPoint(popupSize.width(), popupSize.height());
- if (newPos.y() < 0)
- newPos.setY(0);
- else if (newPos.y() - popupSize.height() < -screenSize.height())
- newPos.setY(-screenSize.height() + popupSize.height());
-
- if (newPos.x() + popupSize.width() > screenSize.width())
- newPos.setX(screenSize.width() - popupSize.width());
- else if (newPos.x() < 0)
- newPos.setX(0);
- browser->move(newPos);
-
- // Show asynchronously to avoid flashing blank window on first show
- QTimer::singleShot(0, this, [browser] {
- browser->show();
- browser->activateWindow();
- browser->setFocus();
- });
+ CDialogs::showWidgetBrowser(this, m_dataInputSelector, point);
}
void TimelineToolbar::onDataInputChange(int handle, int instance, const QString &dataInputName)
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h
index 50d862e7..f57bb8a7 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h
@@ -84,7 +84,6 @@ private:
void onSelectionChange(Q3DStudio::SSelectedValue inNewSelectable);
void onDataInputChange(int handle, int instance, const QString &dataInputName);
void showDataInputChooser(const QPoint &point);
- void showBrowser(QQuickWidget *browser, const QPoint &point);
void updateDataInputStatus(bool isViaDispatch);
void updateTimelineTitleColor(bool controlled);
diff --git a/src/Authoring/Studio/Utils/StudioUtils.cpp b/src/Authoring/Studio/Utils/StudioUtils.cpp
index 16eebd56..cb930fad 100644
--- a/src/Authoring/Studio/Utils/StudioUtils.cpp
+++ b/src/Authoring/Studio/Utils/StudioUtils.cpp
@@ -105,67 +105,6 @@ bool IsNumericString(const Q3DStudio::CString &inString)
return theNumericFlag;
}
-//=============================================================================
-/**
- * @return The available resolution in pixels of the display index "screen"
- * (minus the Dock/Taskbar, etc.). Default is current primary display.
- */
-QSize GetAvailableDisplaySize(int screen)
-{
- return QApplication::desktop()->availableGeometry(screen).size();
-}
-
-//=============================================================================
-/**
-* @return The total resolution in pixels of the display index "screen".
-* Default is the current primary display.
- */
-QSize GetDisplaySize(int screen)
-{
- return QApplication::desktop()->screenGeometry(screen).size();
-
-}
-
-//=============================================================================
-/**
-* @return The index of the screen containing "widget".
- */
-int getWidgetScreen(QWidget *widget)
-{
- return QApplication::desktop()->screenNumber(widget);
-}
-
-//=============================================================================
-/**
- * Helper function to adjust the point for the color popup dialog so that it
- * ends up in the right place. Adjust the given point if it is near the left
- * or bottom part of the screen.
- * @param ioPoint upper-left corner of the color popup dialog; will be adjust if necessary on return
- */
-void TranslatePoint(QPoint &ioPoint, const QPoint &inSize)
-{
- long theBuffer = 10; // Just because the taskbar seems to overlap the dialog by a little bit
- QPoint theDlgSize(150, 260); // Size of color popup dialog - note that it's hard-coded
- QSize theScreenSize = GetAvailableDisplaySize(-1);
- long theVertOffset = theDlgSize.y() - inSize.y();
- long theHorizOffset = theDlgSize.x();
-
- // If the point is too close to both the left side and the bottom of the screen, adjust both the
- // x and y values
- if ((ioPoint.y() > theScreenSize.height() - theVertOffset - theBuffer)
- && (ioPoint.x() >= theScreenSize.width() - theHorizOffset)) {
-
- ioPoint.setX(ioPoint.x() - (theHorizOffset + inSize.x()));
- ioPoint.setY(ioPoint.y() - theVertOffset);
- }
- // If the point is just too close to the bottom of the screen, adjust the y value
- else if (ioPoint.y() > theScreenSize.height() - theVertOffset - theBuffer)
- ioPoint.setY(ioPoint.y() - theVertOffset);
- // If the point is just too close to the left side of the screen, adjust the x value
- else if (ioPoint.x() >= theScreenSize.width() - theHorizOffset)
- ioPoint.setX(ioPoint.x() - (theHorizOffset + inSize.x()));
-}
-
long TimeToPos(long inTime, double inTimeRatio)
{
return ::dtol(inTime * inTimeRatio) + CStudioPreferences::GUTTER_SIZE;
diff --git a/src/Authoring/Studio/Utils/StudioUtils.h b/src/Authoring/Studio/Utils/StudioUtils.h
index a660ad0b..b174e240 100644
--- a/src/Authoring/Studio/Utils/StudioUtils.h
+++ b/src/Authoring/Studio/Utils/StudioUtils.h
@@ -45,10 +45,6 @@
Q3DStudio::CString FormatTimeString(long inTimeMS);
bool IsNumericString(Q3DStudio::CString inString);
-QSize GetAvailableDisplaySize(int screen = -1);
-QSize GetDisplaySize(int screen = -1);
-void TranslatePoint(QPoint &ioPoint, const QPoint &inSize);
-
long TimeToPos(long inTime, double inTimeRatio);
long TimeToPos(double inTime, double inTimeRatio);
long PosToTime(long inPos, double inTimeRatio);
@@ -64,6 +60,4 @@ QString qmlImportPath();
qreal devicePixelRatio();
-int getWidgetScreen(QWidget *widget);
-
#endif // INCLUDED_STUDIO_UTILS_H
diff --git a/src/Authoring/Studio/Workspace/Dialogs.h b/src/Authoring/Studio/Workspace/Dialogs.h
index 2789e201..885d9fde 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.h
+++ b/src/Authoring/Studio/Workspace/Dialogs.h
@@ -54,7 +54,6 @@ class IDoc;
class CStudioApp;
class CControl;
class CDialogControl;
-
class CProgressView;
class CDialogs
@@ -162,6 +161,7 @@ public:
const Q3DStudio::CString &inMinVersion);
static void DisplayGLVersionWarning(const Q3DStudio::CString &inGLVersion,
const Q3DStudio::CString &inRecommendedVersion);
+ static void showWidgetBrowser(QWidget *screenWidget, QWidget *browser, const QPoint &point);
protected:
QString CreateAllowedTypesString(Q3DStudio::DocumentEditorFileType::Enum fileTypeFilter,
diff --git a/src/Authoring/Studio/_Win/UI/StartupDlg.cpp b/src/Authoring/Studio/_Win/UI/StartupDlg.cpp
index 5d143563..59b29a1b 100644
--- a/src/Authoring/Studio/_Win/UI/StartupDlg.cpp
+++ b/src/Authoring/Studio/_Win/UI/StartupDlg.cpp
@@ -38,7 +38,6 @@
//==============================================================================
#include "StartupDlg.h"
-#include "StudioUtils.h"
#include "StudioPreferences.h"
#include "ui_StartupDlg.h"
@@ -46,6 +45,7 @@
#include <QtGui/qpalette.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qdir.h>
+#include <QtWidgets/qdesktopwidget.h>
// CStartupDlg dialog
@@ -90,10 +90,12 @@ void CStartupDlg::OnInitDialog()
QWidget *p = qobject_cast<QWidget *>(parent());
if (p) {
QRect pRect;
- if (p->isMaximized())
- pRect = QRect(QPoint(0, 0), GetAvailableDisplaySize(getWidgetScreen(p)));
- else
+ if (p->isMaximized()) {
+ pRect = QApplication::desktop()->availableGeometry(
+ QApplication::desktop()->screenNumber(p));
+ } else {
pRect = p->frameGeometry();
+ }
move(pRect.x() + pRect.width() / 2 - width() / 2,
pRect.y() + pRect.height() / 2 - height() / 2);
diff --git a/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp b/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp
index c6a47469..c99afb88 100644
--- a/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp
+++ b/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp
@@ -56,6 +56,8 @@
#include <QtWidgets/qfiledialog.h>
#include <QtWidgets/qmessagebox.h>
#include <QtCore/qstandardpaths.h>
+#include <QtWidgets/qdesktopwidget.h>
+#include <QtGui/qscreen.h>
#include <iostream>
@@ -1084,6 +1086,50 @@ void CDialogs::DisplayGLVersionWarning(const Q3DStudio::CString &inGLVersion,
DisplayGLVersionDialog(inGLVersion, inRecommendedVersion, false);
}
+void CDialogs::showWidgetBrowser(QWidget *screenWidget, QWidget *browser, const QPoint &point)
+{
+ QSize popupSize = CStudioPreferences::browserPopupSize();
+ browser->resize(popupSize);
+ QPoint newPos = point;
+
+ // Make sure the popup doesn't go outside the screen
+ int screenNum = QApplication::desktop()->screenNumber(screenWidget);
+ QScreen *screen = nullptr;
+
+ // If we are somehow not on any screen, just show the browser at upper left corner of the
+ // primary screen.
+ if (screenNum < 0) {
+ screen = QGuiApplication::primaryScreen();
+ newPos = QPoint(25, 25) + QPoint(popupSize.width(), popupSize.height());
+ } else {
+ screen = QGuiApplication::screens().at(screenNum);
+ }
+ QRect screenRect = screen->availableGeometry();
+ QSize screenSize = screenRect.size();
+ newPos -= QPoint(popupSize.width(), popupSize.height()) + screenRect.topLeft();
+
+ if (newPos.y() < 0)
+ newPos.setY(0);
+ else if (newPos.y() + popupSize.height() > screenSize.height())
+ newPos.setY(screenSize.height() - popupSize.height());
+
+ if (newPos.x() + popupSize.width() > screenSize.width())
+ newPos.setX(screenSize.width() - popupSize.width());
+ else if (newPos.x() < 0)
+ newPos.setX(0);
+
+ newPos += screenRect.topLeft();
+
+ browser->move(newPos);
+
+ // Show asynchronously to avoid flashing blank window on first show
+ QTimer::singleShot(0, screenWidget, [browser] {
+ browser->show();
+ browser->activateWindow();
+ browser->setFocus();
+ });
+}
+
//==============================================================================
/**
* Display the error dialog or warning dialog that OpenGL version is lower than what is