ADS: Integrate newest base repository commits

* Activate new ADS feature focus highlight
* Remove resources.qrc and related *.svg files
* Clean up new and existing source

Base repository was merged until commit
3de877fe5635ff51a6d1205ca98aad85d204427f

Merged changes from base repository include the following:

* Fix wrong current index when removing a widget from DockAreaLayout
* Fix invisible TabWidget for DockWidgets that are not part of a
  restored state
* Enable ClickFocus for DockWidget to support focussing in case the
  content does not support it
* Move focus related functionality into DockFocusController class
* Add new DockManger config flag FocusStyling
* Add support for focus styling of FloatingWidgetTitleBar
* Improve focus handling when dropping a DockWidget
* Improve highlighting focused DockWidget
* Improve setting of DockWidgetTab focus
* Add styling of focused DockWidget
* Fix docking of floating widgets for macOS
* Fix setting of DockingStateReader file version - use internal file
  version instead of user file version
* Fix saveState() and restoreState() version handling to work like the
  function from QMainWindow
* Fix escape key handling in native window event function if event
  WM_EXITSIZEMOVE occurs
* Implement windows drag handling with native WM_ nonclient area
  messages
* Fix showing DockArea when inserting a DockWidget in a hidden DockArea
* Fix setting DockAreaTabBar index to prevent showing of tab 0 when
  inserting a DockWidget into an area with no current index tab
* Fix wrong insertion order of DockWidget when dropping a floating
  widget to the left or top container drop area
* Fix tab changes position when redocking it to the same position
* Add nullptr check to fix potential nullptr access when closing a
  FloatingDockContainer
* Fix single DockArea cannot be split
* Fix visibility issue when adding dock widget after all other dock
  widgets have ben closed
* Fix FloatingDragPreview flashing of hidden overlay when dragging the
  last visible DockWidget in non opaque docking mode
* Fix FloatingDragPreview preventing dock widget from floating when
  dragging over another dock widget
* Fix DockWidget::setWidget function to test for QAbstractScrollArea
  instead of QScrollArea. Now setWidget properly supports ItemViews like
  QTreeView or QTableView
* Fix wrong display of center drop area when dragging over invisible
  dock area title bar
* Fix bug that drop overlay sometimes was not visible when moving the
  drag preview over a floating window
* Fix dropping of FloatingDragPreview into center of dock container with
  only one single visible dock area. If this happens the dropped dock
  widget needs to get tabified
* Fix crash when trying to make a DockWidget floating in non-opaque mode
  if the DockWidget is not floatable
* Fix DockWidgetTab to provide the right size when starting floating
* Add DockWidget functions setAsCurrentTab, raise, isCurrentTab,
  isTabbed
* Add new config flag HideSingleCentralWidgetTitleBar to enable a
  central single dock widget in the main dock container (dock manager)
  without titlebar
* Fix DockContainerWidget::hasTopLevelDockWidget() and
  DockContainerWidget::topLevelDockArea() to work properly also for the
  main non floating dock container
* Fix ElidingLabel to properly support Qt::ElideNone
* Add setElideMode function to DockWidgetTab
* Add setFullScreen(), setNormal() and isFullScreen() function to
  DockWidget
* Fix takeWidget() function and fixed setWidget() function to handle
  case when there is already a content widget

Task-number: QDS-2180
Change-Id: Ie30648ba329016c91fd19e9b4e12e31e47614b18
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2020-06-22 16:46:25 +02:00
committed by Henning Gründl
parent e5d9cb3779
commit a98c254c59
31 changed files with 1704 additions and 876 deletions

View File

@@ -36,7 +36,9 @@
#include "dockmanager.h"
#include "ads_globals.h"
#include "dockareatitlebar.h"
#include "dockareawidget.h"
#include "dockfocuscontroller.h"
#include "dockingstatereader.h"
#include "dockoverlay.h"
#include "dockwidget.h"
@@ -72,6 +74,15 @@ static Q_LOGGING_CATEGORY(adsLog, "qtc.qmldesigner.advanceddockingsystem", QtWar
namespace ADS
{
/**
* Internal file version in case the structure changes internally
*/
enum eStateFileVersion {
InitialVersion = 0, //!< InitialVersion
Version1 = 1, //!< Version1
CurrentVersion = Version1 //!< CurrentVersion
};
static DockManager::ConfigFlags g_staticConfigFlags = DockManager::DefaultNonOpaqueConfig;
/**
@@ -88,6 +99,7 @@ namespace ADS
QMap<QString, DockWidget *> m_dockWidgetsMap;
bool m_restoringState = false;
QVector<FloatingDockContainer *> m_uninitializedFloatingWidgets;
DockFocusController *m_focusController = nullptr;
QString m_workspaceName;
bool m_workspaceListDirty = true;
@@ -159,11 +171,10 @@ namespace ADS
} else {
qCInfo(adsLog) << "d->m_containers[i]->restoreState ";
auto container = m_containers[index];
if (container->isFloating()) {
if (container->isFloating())
result = container->floatingWidget()->restoreState(stream, testing);
} else {
else
result = container->restoreState(stream, testing);
}
}
return result;
@@ -190,6 +201,17 @@ namespace ADS
return false;
stateReader.setFileVersion(v);
qCInfo(adsLog) << stateReader.attributes().value("userVersion");
// Older files do not support UserVersion but we still want to load them so
// we first test if the attribute exists
if (!stateReader.attributes().value("userVersion").isEmpty())
{
v = stateReader.attributes().value("userVersion").toInt(&ok);
if (!ok || v != version)
return false;
}
bool result = true;
#ifdef ADS_DEBUG_PRINT
int dockContainers = stateReader.attributes().value("containers").toInt();
@@ -248,9 +270,8 @@ namespace ADS
DockAreaWidget *dockArea = dockContainer->dockArea(i);
QString dockWidgetName = dockArea->property("currentDockWidget").toString();
DockWidget *dockWidget = nullptr;
if (!dockWidgetName.isEmpty()) {
if (!dockWidgetName.isEmpty())
dockWidget = q->findDockWidget(dockWidgetName);
}
if (!dockWidget || dockWidget->isClosed()) {
int index = dockArea->indexOfFirstOpenDockWidget();
@@ -276,9 +297,8 @@ namespace ADS
} else {
for (int i = 0; i < dockContainer->dockAreaCount(); ++i) {
auto dockArea = dockContainer->dockArea(i);
for (auto dockWidget : dockArea->dockWidgets()) {
for (auto dockWidget : dockArea->dockWidgets())
dockWidget->emitTopLevelChanged(false);
}
}
}
}
@@ -326,6 +346,9 @@ namespace ADS
d->m_dockAreaOverlay = new DockOverlay(this, DockOverlay::ModeDockAreaOverlay);
d->m_containerOverlay = new DockOverlay(this, DockOverlay::ModeContainerOverlay);
d->m_containers.append(this);
if (DockManager::configFlags().testFlag(DockManager::FocusHighlighting))
d->m_focusController = new DockFocusController(this);
}
DockManager::~DockManager()
@@ -398,13 +421,12 @@ namespace ADS
DockAreaWidget *DockManager::addDockWidgetTab(DockWidgetArea area, DockWidget *dockWidget)
{
DockAreaWidget *areaWidget = lastAddedDockAreaWidget(area);
if (areaWidget) {
if (areaWidget)
return addDockWidget(ADS::CenterDockWidgetArea, dockWidget, areaWidget);
} else if (!openedDockAreas().isEmpty()) {
else if (!openedDockAreas().isEmpty())
return addDockWidget(area, dockWidget, openedDockAreas().last());
} else {
else
return addDockWidget(area, dockWidget, nullptr);
}
}
DockAreaWidget *DockManager::addDockWidgetTabToArea(DockWidget *dockWidget,
@@ -423,11 +445,11 @@ namespace ADS
dockWidget->setDockManager(this);
FloatingDockContainer *floatingWidget = new FloatingDockContainer(dockWidget);
floatingWidget->resize(dockWidget->size());
if (isVisible()) {
if (isVisible())
floatingWidget->show();
} else {
else
d->m_uninitializedFloatingWidgets.append(floatingWidget);
}
return floatingWidget;
}
@@ -450,9 +472,8 @@ namespace ADS
void DockManager::removeDockContainer(DockContainerWidget *dockContainer)
{
if (this != dockContainer) {
if (this != dockContainer)
d->m_containers.removeAll(dockContainer);
}
}
DockOverlay *DockManager::containerOverlay() const { return d->m_containerOverlay; }
@@ -479,7 +500,8 @@ namespace ADS
stream.setAutoFormatting(configFlags.testFlag(XmlAutoFormattingEnabled));
stream.writeStartDocument();
stream.writeStartElement("QtAdvancedDockingSystem");
stream.writeAttribute("version", QString::number(version));
stream.writeAttribute("version", QString::number(CurrentVersion));
stream.writeAttribute("userVersion", QString::number(version));
stream.writeAttribute("containers", QString::number(d->m_containers.count()));
for (auto container : d->m_containers)
container->saveState(stream);
@@ -512,10 +534,10 @@ namespace ADS
emit restoringState();
bool result = d->restoreState(state, version);
d->m_restoringState = false;
emit stateRestored();
if (!isHidden)
show();
emit stateRestored();
return result;
}
@@ -574,15 +596,14 @@ namespace ADS
emit aboutToSaveWorkspace();
bool result = write(activeWorkspace(), saveState(), parentWidget());
if (result) {
if (result)
d->m_workspaceDateTimes.insert(activeWorkspace(), QDateTime::currentDateTime());
} else {
else
QMessageBox::warning(parentWidget(),
tr("Cannot Save Workspace"),
tr("Could not save workspace to file %1")
.arg(workspaceNameToFilePath(d->m_workspaceName)
.toUserOutput()));
}
return result;
}
@@ -638,9 +659,8 @@ namespace ADS
= workspacePresetsDir.entryInfoList(QStringList() << QLatin1Char('*') + m_fileExt,
QDir::NoFilter,
QDir::Time);
for (const QFileInfo &fileInfo : workspacePresetsFiles) {
for (const QFileInfo &fileInfo : workspacePresetsFiles)
d->m_workspacePresets.insert(fileNameToWorkspaceName(fileInfo.completeBaseName()));
}
}
return d->m_workspacePresets;
}
@@ -819,8 +839,10 @@ namespace ADS
{
if (!cloneWorkspace(original, newName))
return false;
if (original == activeWorkspace())
openWorkspace(newName);
return deleteWorkspace(original);
}
@@ -1002,10 +1024,10 @@ namespace ADS
QFile file(filePath);
if (file.exists()) {
if (!file.copy(workspaceDir.filePath(fileName))) {
if (!file.copy(workspaceDir.filePath(fileName)))
qCInfo(adsLog) << QString("Could not copy '%1' to '%2' error: %3").arg(
filePath, workspaceDir.filePath(fileName), file.errorString());
}
d->m_workspaceListDirty = true;
}
}
@@ -1020,4 +1042,22 @@ namespace ADS
d->m_settings->setValue(Constants::STARTUP_WORKSPACE_SETTINGS_KEY, activeWorkspace());
}
void DockManager::notifyWidgetOrAreaRelocation(QWidget *droppedWidget)
{
if (d->m_focusController)
d->m_focusController->notifyWidgetOrAreaRelocation(droppedWidget);
}
void DockManager::notifyFloatingWidgetDrop(FloatingDockContainer *floatingWidget)
{
if (d->m_focusController)
d->m_focusController->notifyFloatingWidgetDrop(floatingWidget);
}
void DockManager::setDockWidgetFocused(DockWidget *dockWidget)
{
if (d->m_focusController)
d->m_focusController->setDockWidgetFocused(dockWidget);
}
} // namespace ADS