mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
Merge pull request #7 from Opostol/master
DockWidgetMovable implemented, some signals introduced
This commit is contained in:
commit
9d00a278e6
@ -535,6 +535,8 @@ void CDockAreaWidget::setCurrentIndex(int index)
|
||||
return;
|
||||
}
|
||||
|
||||
emit currentChanging(index);
|
||||
|
||||
// Set active TAB and update all other tabs to be inactive
|
||||
for (int i = 0; i < d->TabsLayout->count(); ++i)
|
||||
{
|
||||
|
@ -187,6 +187,13 @@ signals:
|
||||
*/
|
||||
void tabBarClicked(int index);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the tab bar's current tab is about to be changed. The new
|
||||
* current has the given index, or -1 if there isn't a new one.
|
||||
* @param index
|
||||
*/
|
||||
void currentChanging(int index);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the tab bar's current tab changes. The new
|
||||
* current has the given index, or -1 if there isn't a new one
|
||||
|
@ -369,6 +369,8 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
|
||||
}
|
||||
}
|
||||
|
||||
emit stateChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -187,6 +187,11 @@ signals:
|
||||
* This signal is emitted if the list of perspectives changed
|
||||
*/
|
||||
void perspectiveListChanged();
|
||||
|
||||
/**
|
||||
* This signal is emitted if the state changed in restoreState
|
||||
*/
|
||||
void stateChanged();
|
||||
}; // class DockManager
|
||||
} // namespace ads
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -240,6 +240,7 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
||||
// End of tab moving, change order now
|
||||
if (d->isDraggingState(DraggingTab) && d->DockArea)
|
||||
{
|
||||
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||
// Find tab under mouse
|
||||
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
|
||||
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
|
||||
@ -252,6 +253,8 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
||||
d->DockArea->reorderDockWidget(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!d->DragStartMousePosition.isNull())
|
||||
{
|
||||
emit clicked();
|
||||
@ -275,7 +278,9 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||
d->FloatingWidget->moveFloating();
|
||||
}
|
||||
QFrame::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
@ -283,19 +288,25 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
// move tab
|
||||
if (d->isDraggingState(DraggingTab))
|
||||
{
|
||||
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||
d->moveTab(ev);
|
||||
}
|
||||
}
|
||||
|
||||
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
|
||||
if (!MouseInsideTitleArea)
|
||||
{
|
||||
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||
d->startFloating();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (d->DockArea->count() > 1
|
||||
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
|
||||
{
|
||||
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||
d->DragState = DraggingTab;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user