summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-10-18 11:46:03 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-10-19 10:19:16 +0000
commit576ef3232e9ada7ba4c397cff3fb4056af1d77e4 (patch)
tree8067bf8f3321ebbebda13aece1465caa9adb7de5
parent3cbc990590ac915d73454addc1be06dbefe7e109 (diff)
Fix datainput chooser popup alignment
Introduced new options for CDialogs::showWidgetBrowser alignment: Combobox, ToolButton, or Center. Combobox is the default and positions the popup as it has before, which is suitable for comboboxes. ToolButton alignment positions the corner of the popup over the toolbutton and prefers to open the popup above rather than below. Center alignment simply centers the popup on given point. Task-number: QT3DS-2504 Change-Id: Ibca6895010baec19508259eb6b3976b6082740e9 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Application/DataInputListDlg.cpp7
-rw-r--r--src/Authoring/Studio/Application/DataInputListDlg.h1
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp4
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.cpp3
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp10
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.cpp24
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.h7
7 files changed, 42 insertions, 14 deletions
diff --git a/src/Authoring/Studio/Application/DataInputListDlg.cpp b/src/Authoring/Studio/Application/DataInputListDlg.cpp
index 86d5645a..71904037 100644
--- a/src/Authoring/Studio/Application/DataInputListDlg.cpp
+++ b/src/Authoring/Studio/Application/DataInputListDlg.cpp
@@ -502,7 +502,8 @@ void CDataInputListDlg::onReplaceSelected()
setUniqueAcceptedDITypes(selBoundTypes);
- CDialogs::showWidgetBrowser(this, m_dataInputChooserView, mapToGlobal(pos()));
+ CDialogs::showWidgetBrowser(this, m_dataInputChooserView, geometry().center(),
+ CDialogs::WidgetBrowserAlign::Center);
}
void CDataInputListDlg::onReplaceAll()
@@ -529,7 +530,9 @@ void CDataInputListDlg::onReplaceAll()
setUniqueAcceptedDITypes(
m_dataInputs[m_currentDataInputName]->boundTypes);
- CDialogs::showWidgetBrowser(this, m_dataInputChooserView, mapToGlobal(pos()));
+
+ CDialogs::showWidgetBrowser(this, m_dataInputChooserView, geometry().center(),
+ CDialogs::WidgetBrowserAlign::Center);
}
void CDataInputListDlg::onElementSelectionChanged()
diff --git a/src/Authoring/Studio/Application/DataInputListDlg.h b/src/Authoring/Studio/Application/DataInputListDlg.h
index 7456387d..c31fd933 100644
--- a/src/Authoring/Studio/Application/DataInputListDlg.h
+++ b/src/Authoring/Studio/Application/DataInputListDlg.h
@@ -75,6 +75,7 @@ protected:
// work as controller for all of listed datatypes.
void setUniqueAcceptedDITypes(
const QVector<QPair<qt3dsdm::DataModelDataType::Value, bool>> &boundTypes);
+
private Q_SLOTS:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index abde42ea..43242083 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -578,6 +578,7 @@ QObject *InspectorControlView::showMaterialReference(int handle, int instance, c
const int popupHeight = qMin(numMats, 10) * CStudioPreferences::controlBaseHeight();
CDialogs::showWidgetBrowser(this, m_matRefListWidget, point,
+ CDialogs::WidgetBrowserAlign::ComboBox,
QSize(CStudioPreferences::valueWidth(), popupHeight));
connect(m_matRefListWidget, &QListWidget::itemClicked, this, [=](QListWidgetItem *item) {
@@ -626,7 +627,8 @@ void InspectorControlView::showDataInputChooser(int handle, int instance, const
setData(dataInputList,
m_inspectorControlModel->currentControllerValue(instance, handle),
handle, instance);
- CDialogs::showWidgetBrowser(this, m_dataInputChooserView, point);
+ CDialogs::showWidgetBrowser(this, m_dataInputChooserView, point,
+ CDialogs::WidgetBrowserAlign::ToolButton);
}
QColor InspectorControlView::showColorDialog(const QColor &color)
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
index be3e36a3..e68eaaa6 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
@@ -123,7 +123,8 @@ void SlideView::showControllerDialog(const QPoint &point)
dataInputList.append(QPair<QString, int>(it->name, it->type));
}
m_dataInputSelector->setData(dataInputList, currCtr);
- CDialogs::showWidgetBrowser(this, m_dataInputSelector, point);
+ CDialogs::showWidgetBrowser(this, m_dataInputSelector, point,
+ CDialogs::WidgetBrowserAlign::ToolButton);
return;
}
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
index 0fa1e28b..4219e0d0 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
@@ -245,7 +245,12 @@ void TimelineToolbar::onZoomOutButtonClicked()
void TimelineToolbar::onDiButtonClicked()
{
- showDataInputChooser(mapToGlobal(pos()));
+ QWidget *diButton = widgetForAction(m_actionDataInput);
+ if (diButton) {
+ QPoint chooserPos = diButton->pos() + QPoint(diButton->size().width(),
+ diButton->size().height());
+ showDataInputChooser(mapToGlobal(chooserPos));
+ }
}
// Update datainput button state according to this timecontext control state.
@@ -308,7 +313,8 @@ void TimelineToolbar::showDataInputChooser(const QPoint &point)
m_dataInputSelector->setData(dataInputList, currCtr);
- CDialogs::showWidgetBrowser(this, m_dataInputSelector, point);
+ CDialogs::showWidgetBrowser(this, m_dataInputSelector, point,
+ CDialogs::WidgetBrowserAlign::ToolButton);
}
void TimelineToolbar::onDataInputChange(int handle, int instance, const QString &dataInputName)
diff --git a/src/Authoring/Studio/Workspace/Dialogs.cpp b/src/Authoring/Studio/Workspace/Dialogs.cpp
index 291a44e4..a804c779 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.cpp
+++ b/src/Authoring/Studio/Workspace/Dialogs.cpp
@@ -1298,7 +1298,7 @@ void CDialogs::DisplayGLVersionWarning(const Q3DStudio::CString &inGLVersion,
}
void CDialogs::showWidgetBrowser(QWidget *screenWidget, QWidget *browser, const QPoint &point,
- QSize customSize)
+ WidgetBrowserAlign align, QSize customSize)
{
QSize popupSize = customSize.isEmpty() ? CStudioPreferences::browserPopupSize() : customSize;
browser->resize(popupSize);
@@ -1317,14 +1317,22 @@ void CDialogs::showWidgetBrowser(QWidget *screenWidget, QWidget *browser, const
screen = QGuiApplication::screens().at(screenNum);
}
QRect screenRect = screen->availableGeometry();
- const int COMBOBOX_H = 22;
- // position the popup below the combobox
- newPos -= QPoint(popupSize.width(), -COMBOBOX_H) + screenRect.topLeft();
-
- // if no space below the combobox, move it above it
- if (newPos.y() + popupSize.height() > screenRect.height())
- newPos.setY(newPos.y() - popupSize.height() - COMBOBOX_H);
+ const int CONTROL_H = 22;
+ if (align == WidgetBrowserAlign::ComboBox) {
+ // position the popup below the combobox
+ newPos -= QPoint(popupSize.width(), -CONTROL_H) + screenRect.topLeft();
+ // if no space below the combobox, move it above it
+ if (newPos.y() + popupSize.height() > screenRect.height())
+ newPos.setY(newPos.y() - popupSize.height() - CONTROL_H);
+ } else if (align == WidgetBrowserAlign::ToolButton){
+ // The point is assumed to be the lower right corner of the button
+ newPos -= QPoint(popupSize.width(), popupSize.height()) + screenRect.topLeft();
+ if (newPos.y() < 0)
+ newPos.setY(newPos.y() + popupSize.height() - CONTROL_H);
+ } else { // WidgetBrowserAlign::Center
+ newPos -= QPoint(popupSize.width() / 2, popupSize.height() / 2) + screenRect.topLeft();
+ }
if (newPos.y() < 0)
newPos.setY(0);
diff --git a/src/Authoring/Studio/Workspace/Dialogs.h b/src/Authoring/Studio/Workspace/Dialogs.h
index f1e93ef6..eea0af1c 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.h
+++ b/src/Authoring/Studio/Workspace/Dialogs.h
@@ -173,7 +173,14 @@ public:
const Q3DStudio::CString &inMinVersion);
static void DisplayGLVersionWarning(const Q3DStudio::CString &inGLVersion,
const Q3DStudio::CString &inRecommendedVersion);
+
+ enum class WidgetBrowserAlign {
+ ComboBox,
+ ToolButton,
+ Center
+ };
static void showWidgetBrowser(QWidget *screenWidget, QWidget *browser, const QPoint &point,
+ WidgetBrowserAlign align = WidgetBrowserAlign::ComboBox,
QSize customSize = {});
Q_SIGNALS: