QmlDesigner: Integrate upstream commits

- Integrate the newest commits from the base repository
  dec170ed24679fd49f9fb54af91f61146838f852
  34cb2ae91790fc65ca5c0f7b81bb928de22a32e5
- Cleanup a few if statements
- Cleanup a comment

Change-Id: I158bff610f701e7a30680cfb8383f64475199bbe
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2020-02-25 11:22:36 +01:00
committed by Henning Gründl
parent 3749979ba8
commit 9684a5f269
4 changed files with 68 additions and 99 deletions

View File

@@ -138,13 +138,13 @@ struct DockOverlayCrossPrivate;
* You can style the cross icon using the property system.
* \code
* ADS--DockOverlayCross
{
qproperty-iconFrameColor: palette(highlight);
qproperty-iconBackgroundColor: palette(base);
qproperty-iconOverlayColor: palette(highlight);
qproperty-iconArrowColor: rgb(227, 227, 227);
qproperty-iconShadowColor: rgb(0, 0, 0);
}
* {
* qproperty-iconFrameColor: palette(highlight);
* qproperty-iconBackgroundColor: palette(base);
* qproperty-iconOverlayColor: palette(highlight);
* qproperty-iconArrowColor: rgb(227, 227, 227);
* qproperty-iconShadowColor: rgb(0, 0, 0);
* }
* \endcode
* Or you can use the iconColors property to pass in AARRGGBB values as
* hex string like shown in the example below.

View File

@@ -154,16 +154,18 @@ namespace ADS
void DockWidgetPrivate::updateParentDockArea()
{
if (!m_dockArea) {
if (!m_dockArea)
return;
// we don't need to change the current tab if the current DockWidget is not the one being closed
if (m_dockArea->currentDockWidget() != q)
return;
}
auto nextDockWidget = m_dockArea->nextOpenDockWidget(q);
if (nextDockWidget) {
if (nextDockWidget)
m_dockArea->setCurrentDockWidget(nextDockWidget);
} else {
else
m_dockArea->hideAreaWithNoVisibleContent();
}
}
void DockWidgetPrivate::setupToolBar()
@@ -222,9 +224,8 @@ namespace ADS
QScrollArea *scrollAreaWidget = qobject_cast<QScrollArea *>(widget);
if (scrollAreaWidget || ForceNoScrollArea == insertMode) {
d->m_layout->addWidget(widget);
if (scrollAreaWidget && scrollAreaWidget->viewport()) {
if (scrollAreaWidget && scrollAreaWidget->viewport())
scrollAreaWidget->viewport()->setProperty("dockWidgetContent", true);
}
} else {
d->setupScrollArea();
d->m_scrollArea->setWidget(widget);
@@ -283,9 +284,8 @@ namespace ADS
bool DockWidget::isFloating() const
{
if (!isInFloatingContainer()) {
if (!isInFloatingContainer())
return false;
}
return dockContainer()->topLevelDockWidget() == this;
}
@@ -293,13 +293,11 @@ namespace ADS
bool DockWidget::isInFloatingContainer() const
{
auto container = dockContainer();
if (!container) {
if (!container)
return false;
}
if (!container->isFloating()) {
if (!container->isFloating())
return false;
}
return true;
}
@@ -324,17 +322,16 @@ namespace ADS
// If the toggle view action mode is ActionModeShow, then Open is always
// true if the sender is the toggle view action
QAction *action = qobject_cast<QAction *>(sender());
if (action == d->m_toggleViewAction && !d->m_toggleViewAction->isCheckable()) {
if (action == d->m_toggleViewAction && !d->m_toggleViewAction->isCheckable())
open = true;
}
// If the dock widget state is different, then we really need to toggle
// the state. If we are in the right state, then we simply make this
// dock widget the current dock widget
if (d->m_closed != !open) {
if (d->m_closed != !open)
toggleViewInternal(open);
} else if (open && d->m_dockArea) {
else if (open && d->m_dockArea)
d->m_dockArea->setCurrentDockWidget(this);
}
}
void DockWidget::toggleViewInternal(bool open)
@@ -353,13 +350,11 @@ namespace ADS
//d->m_toggleViewAction->blockSignals(true);
d->m_toggleViewAction->setChecked(open);
//d->m_toggleViewAction->blockSignals(false);
if (d->m_dockArea) {
if (d->m_dockArea)
d->m_dockArea->toggleDockWidgetView(this, open);
}
if (open && topLevelDockWidgetBefore) {
if (open && topLevelDockWidgetBefore)
DockWidget::emitTopLevelEventForWidget(topLevelDockWidgetBefore, false);
}
// Here we need to call the dockContainer() function again, because if
// this dock widget was unassigned before the call to showDockWidget() then
@@ -370,13 +365,12 @@ namespace ADS
: nullptr;
DockWidget::emitTopLevelEventForWidget(topLevelDockWidgetAfter, true);
FloatingDockContainer *floatingContainer = dockContainerWidget->floatingWidget();
if (floatingContainer) {
if (floatingContainer)
floatingContainer->updateWindowTitle();
}
if (!open) {
if (!open)
emit closed();
}
emit viewToggled(open);
}
@@ -440,24 +434,22 @@ namespace ADS
#ifndef QT_NO_TOOLTIP
void DockWidget::setTabToolTip(const QString &text)
{
if (d->m_tabWidget) {
if (d->m_tabWidget)
d->m_tabWidget->setToolTip(text);
}
if (d->m_toggleViewAction) {
if (d->m_toggleViewAction)
d->m_toggleViewAction->setToolTip(text);
}
if (d->m_dockArea) {
if (d->m_dockArea)
d->m_dockArea->markTitleBarMenuOutdated(); //update tabs menu
}
}
#endif
void DockWidget::setIcon(const QIcon &icon)
{
d->m_tabWidget->setIcon(icon);
if (!d->m_toggleViewAction->isCheckable()) {
if (!d->m_toggleViewAction->isCheckable())
d->m_toggleViewAction->setIcon(icon);
}
}
QIcon DockWidget::icon() const { return d->m_tabWidget->icon(); }
@@ -466,18 +458,16 @@ namespace ADS
QToolBar *DockWidget::createDefaultToolBar()
{
if (!d->m_toolBar) {
if (!d->m_toolBar)
d->setupToolBar();
}
return d->m_toolBar;
}
void DockWidget::setToolBar(QToolBar *toolBar)
{
if (d->m_toolBar) {
if (d->m_toolBar)
delete d->m_toolBar;
}
d->m_toolBar = toolBar;
d->m_layout->insertWidget(0, d->m_toolBar);
@@ -487,59 +477,52 @@ namespace ADS
void DockWidget::setToolBarStyle(Qt::ToolButtonStyle style, eState state)
{
if (StateFloating == state) {
if (StateFloating == state)
d->m_toolBarStyleFloating = style;
} else {
else
d->m_toolBarStyleDocked = style;
}
setToolbarFloatingStyle(isFloating());
}
Qt::ToolButtonStyle DockWidget::toolBarStyle(eState state) const
{
if (StateFloating == state) {
if (StateFloating == state)
return d->m_toolBarStyleFloating;
} else {
else
return d->m_toolBarStyleDocked;
}
}
void DockWidget::setToolBarIconSize(const QSize &iconSize, eState state)
{
if (StateFloating == state) {
if (StateFloating == state)
d->m_toolBarIconSizeFloating = iconSize;
} else {
else
d->m_toolBarIconSizeDocked = iconSize;
}
setToolbarFloatingStyle(isFloating());
}
QSize DockWidget::toolBarIconSize(eState state) const
{
if (StateFloating == state) {
if (StateFloating == state)
return d->m_toolBarIconSizeFloating;
} else {
else
return d->m_toolBarIconSizeDocked;
}
}
void DockWidget::setToolbarFloatingStyle(bool floating)
{
if (!d->m_toolBar) {
if (!d->m_toolBar)
return;
}
auto iconSize = floating ? d->m_toolBarIconSizeFloating : d->m_toolBarIconSizeDocked;
if (iconSize != d->m_toolBar->iconSize()) {
if (iconSize != d->m_toolBar->iconSize())
d->m_toolBar->setIconSize(iconSize);
}
auto buttonStyle = floating ? d->m_toolBarStyleFloating : d->m_toolBarStyleDocked;
if (buttonStyle != d->m_toolBar->toolButtonStyle()) {
if (buttonStyle != d->m_toolBar->toolButtonStyle())
d->m_toolBar->setToolButtonStyle(buttonStyle);
}
}
void DockWidget::emitTopLevelEventForWidget(DockWidget *topLevelDockWidget, bool floating)
@@ -564,9 +547,9 @@ namespace ADS
void DockWidget::setFloating()
{
if (isClosed()) {
if (isClosed())
return;
}
d->m_tabWidget->detachDockWidget();
}
@@ -584,13 +567,11 @@ namespace ADS
bool DockWidget::closeDockWidgetInternal(bool forceClose)
{
if (!forceClose) {
if (!forceClose)
emit closeRequested();
}
if (!forceClose && features().testFlag(DockWidget::CustomCloseHandling)) {
if (!forceClose && features().testFlag(DockWidget::CustomCloseHandling))
return false;
}
if (features().testFlag(DockWidget::DockWidgetDeleteOnClose)) {
// If the dock widget is floating, then we check if we also need to
@@ -598,11 +579,10 @@ namespace ADS
if (isFloating()) {
FloatingDockContainer* floatingWidget = internal::findParent<
FloatingDockContainer *>(this);
if (floatingWidget->dockWidgets().count() == 1) {
if (floatingWidget->dockWidgets().count() == 1)
floatingWidget->deleteLater();
} else {
else
floatingWidget->hide();
}
}
deleteDockWidget();
} else {

View File

@@ -112,7 +112,7 @@ namespace ADS
if (testConfigFlag(DockManager::FloatingContainerHasWidgetTitle)) {
setWindowTitle(currentWidget->windowTitle());
} else {
setWindowTitle(qApp->applicationDisplayName());
setWindowTitle(QApplication::applicationDisplayName());
}
// reflect CurrentWidget's icon if configured to do so, otherwise display application icon as window icon
@@ -495,7 +495,7 @@ namespace ADS
&FloatingDockContainer::onDockAreaCurrentChanged);
d->m_singleDockArea = nullptr;
}
d->setWindowTitle(qApp->applicationDisplayName());
d->setWindowTitle(QApplication::applicationDisplayName());
setWindowIcon(QApplication::windowIcon());
}
}
@@ -507,7 +507,7 @@ namespace ADS
DockWidget *currentWidget = topLevelDockArea->currentDockWidget();
d->reflectCurrentWidget(currentWidget);
} else {
d->setWindowTitle(qApp->applicationDisplayName());
d->setWindowTitle(QApplication::applicationDisplayName());
setWindowIcon(QApplication::windowIcon());
}
}

View File

@@ -96,22 +96,19 @@ namespace ADS
void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &globalPosition)
{
if (!q->isVisible() || !m_dockManager) {
if (!q->isVisible() || !m_dockManager)
return;
}
auto containers = m_dockManager->dockContainers();
DockContainerWidget *topContainer = nullptr;
for (auto containerWidget : containers) {
if (!containerWidget->isVisible()) {
if (!containerWidget->isVisible())
continue;
}
QPoint mappedPosition = containerWidget->mapFromGlobal(globalPosition);
if (containerWidget->rect().contains(mappedPosition)) {
if (!topContainer || containerWidget->isInFrontOf(topContainer)) {
if (!topContainer || containerWidget->isInFrontOf(topContainer))
topContainer = containerWidget;
}
}
}
@@ -124,9 +121,9 @@ namespace ADS
if (!topContainer) {
containerOverlay->hideOverlay();
dockAreaOverlay->hideOverlay();
if (DockManager::configFlags().testFlag(DockManager::DragPreviewIsDynamic)) {
if (DockManager::configFlags().testFlag(DockManager::DragPreviewIsDynamic))
setHidden(false);
}
return;
}
@@ -153,9 +150,8 @@ namespace ADS
}
} else {
dockAreaOverlay->hideOverlay();
if (dockArea == m_contentSourceArea && InvalidDockWidgetArea == containerDropArea) {
if (dockArea == m_contentSourceArea && InvalidDockWidgetArea == containerDropArea)
m_dropContainer = nullptr;
}
}
if (DockManager::configFlags().testFlag(DockManager::DragPreviewIsDynamic)) {
@@ -199,7 +195,10 @@ namespace ADS
connect(qApp,
&QApplication::applicationStateChanged,
this,
&FloatingDragPreview::onApplicationStateChanged); // TODO
&FloatingDragPreview::onApplicationStateChanged);
// The focused object will receive key press events and therefore we install
// the event filter on it to receive escape key press for drag canceling
QApplication::focusObject()->installEventFilter(this);
}
FloatingDragPreview::FloatingDragPreview(DockWidget *content)
@@ -212,9 +211,6 @@ namespace ADS
d->m_contenSourceContainer = content->dockContainer();
}
setWindowTitle(content->windowTitle());
// We need to install an event filter for the given content
// widget to receive the escape key press
content->dockAreaWidget()->installEventFilter(this);
}
FloatingDragPreview::FloatingDragPreview(DockAreaWidget *content)
@@ -225,10 +221,6 @@ namespace ADS
d->m_contentSourceArea = content;
d->m_contenSourceContainer = content->dockContainer();
setWindowTitle(content->currentDockWidget()->windowTitle());
// We need to install an event filter for the given Content
// widget to receive the escape key press
content->installEventFilter(this);
}
FloatingDragPreview::~FloatingDragPreview() { delete d; }
@@ -277,9 +269,8 @@ namespace ADS
floatingWidget = new FloatingDockContainer(dockWidget);
} else {
DockAreaWidget *dockArea = qobject_cast<DockAreaWidget *>(d->m_content);
if (dockArea->features().testFlag(DockWidget::DockWidgetFloatable)) {
if (dockArea->features().testFlag(DockWidget::DockWidgetFloatable))
floatingWidget = new FloatingDockContainer(dockArea);
}
}
if (floatingWidget) {
@@ -303,14 +294,12 @@ namespace ADS
void FloatingDragPreview::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
if (d->m_hidden) {
if (d->m_hidden)
return;
}
QPainter painter(this);
if (DockManager::configFlags().testFlag(DockManager::DragPreviewShowsContentPixmap)) {
if (DockManager::configFlags().testFlag(DockManager::DragPreviewShowsContentPixmap))
painter.drawPixmap(QPoint(0, 0), d->m_contentPreviewPixmap);
}
// If we do not have a window frame then we paint a QRubberBand like frameless window
if (!DockManager::configFlags().testFlag(DockManager::DragPreviewHasWindowFrame)) {