2020-06-06 03:03:47 +08:00
|
|
|
#ifndef DockFocusControllerH
|
|
|
|
#define DockFocusControllerH
|
|
|
|
//============================================================================
|
|
|
|
/// \file DockFocusController.h
|
|
|
|
/// \author Uwe Kindler
|
|
|
|
/// \date 05.06.2020
|
|
|
|
/// \brief Declaration of CDockFocusController class
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
|
|
|
#include <QObject>
|
|
|
|
#include "ads_globals.h"
|
|
|
|
#include "DockManager.h"
|
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
|
|
|
struct DockFocusControllerPrivate;
|
|
|
|
class CDockManager;
|
|
|
|
class CFloatingDockContainer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manages focus styling of dock widgets and handling of focus changes
|
|
|
|
*/
|
|
|
|
class ADS_EXPORT CDockFocusController : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
DockFocusControllerPrivate* d; ///< private data (pimpl)
|
2020-06-07 21:20:08 +08:00
|
|
|
friend struct DockFocusControllerPrivate;
|
2020-06-06 03:03:47 +08:00
|
|
|
|
2021-01-22 13:18:34 +08:00
|
|
|
private Q_SLOTS:
|
2020-06-06 03:03:47 +08:00
|
|
|
void onApplicationFocusChanged(QWidget *old, QWidget *now);
|
|
|
|
void onFocusedDockAreaViewToggled(bool Open);
|
|
|
|
void onStateRestored();
|
2020-07-04 05:24:20 +08:00
|
|
|
void onDockWidgetVisibilityChanged(bool Visible);
|
2020-06-06 03:03:47 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
using Super = QObject;
|
|
|
|
/**
|
|
|
|
* Default Constructor
|
|
|
|
*/
|
|
|
|
CDockFocusController(CDockManager* DockManager);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual Destructor
|
|
|
|
*/
|
|
|
|
virtual ~CDockFocusController();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to set focus depending on the configuration of the
|
|
|
|
* FocusStyling flag
|
|
|
|
*/
|
|
|
|
template <class QWidgetPtr>
|
|
|
|
static void setWidgetFocus(QWidgetPtr widget)
|
|
|
|
{
|
2020-06-11 14:06:37 +08:00
|
|
|
if (!CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
|
2020-06-06 03:03:47 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
widget->setFocus(Qt::OtherFocusReason);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A container needs to call this function if a widget has been dropped
|
|
|
|
* into it
|
|
|
|
*/
|
|
|
|
void notifyWidgetOrAreaRelocation(QWidget* RelocatedWidget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is called, if a floating widget has been dropped into
|
|
|
|
* an new position.
|
|
|
|
* When this function is called, all dock widgets of the FloatingWidget
|
|
|
|
* are already inserted into its new position
|
|
|
|
*/
|
|
|
|
void notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget);
|
2020-06-06 20:59:03 +08:00
|
|
|
|
2020-09-07 14:17:07 +08:00
|
|
|
/**
|
|
|
|
* Returns the dock widget that has focus style in the ui or a nullptr if
|
|
|
|
* not dock widget is painted focused.
|
|
|
|
*/
|
|
|
|
CDockWidget* focusedDockWidget() const;
|
|
|
|
|
2021-01-22 13:18:34 +08:00
|
|
|
public Q_SLOTS:
|
2020-06-06 20:59:03 +08:00
|
|
|
/**
|
|
|
|
* Request a focus change to the given dock widget
|
|
|
|
*/
|
|
|
|
void setDockWidgetFocused(CDockWidget* focusedNow);
|
2020-06-06 03:03:47 +08:00
|
|
|
}; // class DockFocusController
|
|
|
|
}
|
|
|
|
// namespace ads
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#endif // DockFocusControllerH
|
|
|
|
|