diff options
author | Janne Kangas <janne.kangas@qt.io> | 2018-03-01 14:50:12 +0200 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2018-03-07 08:57:19 +0000 |
commit | 61da4ed73475395563a949d72e4bcc3cdefebdf9 (patch) | |
tree | 3c5df5fb12dd9c4bd34ab0189fc4b0b4e6f7e084 /src/Authoring/Studio/Palettes/Slide | |
parent | 506e3bf8343920e0227e1120cfcec617ac1af27a (diff) |
Change Datainput selector to match other object selectors
Fixes selection window stealing focus. UX changes. Code repartitioning in
InspectorControlView/Model.
Change-Id: I28bcaec1825c4e375955eeffe191a89de7b6cfe2
Task-id: QT3DS-1249
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Slide')
-rw-r--r-- | src/Authoring/Studio/Palettes/Slide/SlideView.cpp | 47 | ||||
-rw-r--r-- | src/Authoring/Studio/Palettes/Slide/SlideView.h | 5 |
2 files changed, 37 insertions, 15 deletions
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp index 12f88643..b4577d0b 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp @@ -37,7 +37,7 @@ #include "StudioApp.h" #include "StudioUtils.h" #include "SlideContextMenu.h" -#include "DataInputSelectDlg.h" +#include "DataInputSelectView.h" #include "DataInputDlg.h" #include "IDocumentEditor.h" @@ -49,6 +49,7 @@ #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlengine.h> +#include <QtWidgets/qdesktopwidget.h> SlideView::SlideView(QWidget *parent) : QQuickWidget(parent) , m_MasterSlideModel(new SlideModel(1, this)) @@ -117,20 +118,44 @@ void SlideView::setShowMasterSlide(bool show) void SlideView::showControllerDialog(const QPoint &point) { + QString currCtr = m_currentController.size() ? + m_currentController : m_dataInputSelector->getNoneString(); QStringList dataInputList; - dataInputList.append(tr("[No control]")); for (int i = 0; i < g_StudioApp.m_dataInputDialogItems.size(); i++) { if (g_StudioApp.m_dataInputDialogItems[i]->type == EDataType::DataTypeString) dataInputList.append(g_StudioApp.m_dataInputDialogItems[i]->name); } - QString currCtr = m_currentController.size() ? - m_currentController : tr("[No control]"); m_dataInputSelector->setData(dataInputList, currCtr); - m_dataInputSelector->showDialog(point); + showBrowser(m_dataInputSelector, point); return; } +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}; @@ -255,17 +280,15 @@ void SlideView::onDataInputChange(int handle, int instance, const QString &dataI Q_UNUSED(handle) Q_UNUSED(instance) - if (dataInputName == m_currentController || - (dataInputName == tr("[No Control]") && !m_currentController.size())) { + if (dataInputName == m_currentController) return; - } CDoc *doc = g_StudioApp.GetCore()->GetDoc(); CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); qt3dsdm::Qt3DSDMInstanceHandle slideRoot = doc->GetActiveRootInstance(); QString fullSlideControlStr; - if (dataInputName != tr("[No control]")) { + if (dataInputName != m_dataInputSelector->getNoneString()) { fullSlideControlStr = dataInputName + " @slide"; m_controlled = true; m_currentController = dataInputName; @@ -372,11 +395,9 @@ void SlideView::initialize() engine()->addImportPath(qmlImportPath()); setSource(QUrl("qrc:/Palettes/Slide/SlideView.qml"_L1)); - m_dataInputSelector = new DataInputSelectDlg(parentWidget()); - connect(m_dataInputSelector, &DataInputSelectDlg::dataInputChanged, + m_dataInputSelector = new DataInputSelectView(this); + connect(m_dataInputSelector, &DataInputSelectView::dataInputChanged, this, &SlideView::onDataInputChange); - m_dataInputSelector->hide(); - m_dataInputSelector->setWindowTitle(tr("Select slide controller")); } void SlideView::clearSlideList() diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h index 61b3b870..ee7e7090 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.h +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h @@ -33,7 +33,7 @@ #include "DispatchListeners.h" #include "SlideModel.h" -#include "DataInputSelectDlg.h" +#include "DataInputSelectView.h" #include "Qt3DSDMHandles.h" #include "Qt3DSDMSignals.h" #include "DispatchListeners.h" @@ -115,11 +115,12 @@ 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; SlideModel *m_SlidesModel = nullptr; - DataInputSelectDlg *m_dataInputSelector = nullptr; + DataInputSelectView *m_dataInputSelector = nullptr; QColor m_BaseColor = QColor::fromRgb(75, 75, 75); std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>> m_Connections; /// connections to the DataModel |