mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Added visibilityChanged code
This commit is contained in:
parent
407af06a4a
commit
03bd4a4505
@ -317,6 +317,7 @@ void MainWindowPrivate::createContent()
|
|||||||
for (auto DockWidget : DockManager->dockWidgetsMap())
|
for (auto DockWidget : DockManager->dockWidgetsMap())
|
||||||
{
|
{
|
||||||
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
|
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
|
||||||
|
_this->connect(DockWidget, SIGNAL(visibilityChanged(bool)), SLOT(onViewVisibilityChanged(bool)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,6 +502,19 @@ void CMainWindow::onViewToggled(bool Open)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::onViewVisibilityChanged(bool Visible)
|
||||||
|
{
|
||||||
|
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
||||||
|
if (!DockWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << DockWidget->objectName() << " visibilityChanged(" << Visible << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CMainWindow::createEditor()
|
void CMainWindow::createEditor()
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,7 @@ private slots:
|
|||||||
void on_actionRestoreState_triggered(bool);
|
void on_actionRestoreState_triggered(bool);
|
||||||
void savePerspective();
|
void savePerspective();
|
||||||
void onViewToggled(bool Open);
|
void onViewToggled(bool Open);
|
||||||
|
void onViewVisibilityChanged(bool Visible);
|
||||||
void createEditor();
|
void createEditor();
|
||||||
void createTable();
|
void createTable();
|
||||||
void onEditorCloseRequested();
|
void onEditorCloseRequested();
|
||||||
|
@ -546,6 +546,11 @@ void CDockAreaWidget::internalSetCurrentDockWidget(CDockWidget* DockWidget)
|
|||||||
void CDockAreaWidget::setCurrentIndex(int index)
|
void CDockAreaWidget::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
auto TabBar = d->tabBar();
|
auto TabBar = d->tabBar();
|
||||||
|
/*if (TabBar->currentIndex() == index)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
|
||||||
if (index < 0 || index > (TabBar->count() - 1))
|
if (index < 0 || index > (TabBar->count() - 1))
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
|
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
|
||||||
|
@ -45,6 +45,10 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#include "DockContainerWidget.h"
|
#include "DockContainerWidget.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
@ -296,6 +300,7 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->Features = features;
|
d->Features = features;
|
||||||
|
emit featuresChanged(d->Features);
|
||||||
d->TabWidget->onDockWidgetFeaturesChanged();
|
d->TabWidget->onDockWidgetFeaturesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +522,28 @@ void CDockWidget::flagAsUnassigned()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidget::event(QEvent *e)
|
bool CDockWidget::event(QEvent *e)
|
||||||
{
|
{
|
||||||
if (e->type() == QEvent::WindowTitleChange)
|
switch (e->type())
|
||||||
|
{
|
||||||
|
case QEvent::Hide:
|
||||||
|
emit visibilityChanged(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QEvent::Show:
|
||||||
|
{
|
||||||
|
QPoint parentTopLeft(0, 0);
|
||||||
|
if (isWindow())
|
||||||
|
{
|
||||||
|
if (const QWindow *window = windowHandle())
|
||||||
|
parentTopLeft = window->screen()->availableVirtualGeometry().topLeft();
|
||||||
|
else
|
||||||
|
parentTopLeft = QGuiApplication::primaryScreen()->availableVirtualGeometry().topLeft();
|
||||||
|
std::cout << "QEvent::Show isWindow()" << std::endl;
|
||||||
|
}
|
||||||
|
emit visibilityChanged(geometry().right() >= parentTopLeft.x() && geometry().bottom() >= parentTopLeft.y());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QEvent::WindowTitleChange :
|
||||||
{
|
{
|
||||||
const auto title = windowTitle();
|
const auto title = windowTitle();
|
||||||
if (d->TabWidget)
|
if (d->TabWidget)
|
||||||
@ -534,6 +560,12 @@ bool CDockWidget::event(QEvent *e)
|
|||||||
}
|
}
|
||||||
emit titleChanged(title);
|
emit titleChanged(title);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return Super::event(e);
|
return Super::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,6 +468,19 @@ signals:
|
|||||||
* This signal is emitted, if close is requested
|
* This signal is emitted, if close is requested
|
||||||
*/
|
*/
|
||||||
void closeRequested();
|
void closeRequested();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted when the dock widget becomes visible (or invisible).
|
||||||
|
* This happens when the widget is hidden or shown, as well as when it is
|
||||||
|
* docked in a tabbed dock area and its tab becomes selected or unselected.
|
||||||
|
*/
|
||||||
|
void visibilityChanged(bool visible);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted when the features property changes.
|
||||||
|
* The features parameter gives the new value of the property.
|
||||||
|
*/
|
||||||
|
void featuresChanged(DockWidgetFeatures features);
|
||||||
}; // class DockWidget
|
}; // class DockWidget
|
||||||
}
|
}
|
||||||
// namespace ads
|
// namespace ads
|
||||||
|
Loading…
Reference in New Issue
Block a user