mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 13:32:06 +08:00
Merge pull request #7 from Opostol/master
DockWidgetMovable implemented, some signals introduced
This commit is contained in:
commit
9d00a278e6
@ -533,7 +533,9 @@ void CDockAreaWidget::setCurrentIndex(int index)
|
|||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
|
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit currentChanging(index);
|
||||||
|
|
||||||
// Set active TAB and update all other tabs to be inactive
|
// Set active TAB and update all other tabs to be inactive
|
||||||
for (int i = 0; i < d->TabsLayout->count(); ++i)
|
for (int i = 0; i < d->TabsLayout->count(); ++i)
|
||||||
|
@ -187,6 +187,13 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void tabBarClicked(int index);
|
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
|
* 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
|
* 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +187,11 @@ signals:
|
|||||||
* This signal is emitted if the list of perspectives changed
|
* This signal is emitted if the list of perspectives changed
|
||||||
*/
|
*/
|
||||||
void perspectiveListChanged();
|
void perspectiveListChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted if the state changed in restoreState
|
||||||
|
*/
|
||||||
|
void stateChanged();
|
||||||
}; // class DockManager
|
}; // class DockManager
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -240,16 +240,19 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
// End of tab moving, change order now
|
// End of tab moving, change order now
|
||||||
if (d->isDraggingState(DraggingTab) && d->DockArea)
|
if (d->isDraggingState(DraggingTab) && d->DockArea)
|
||||||
{
|
{
|
||||||
// Find tab under mouse
|
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||||
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
|
// Find tab under mouse
|
||||||
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
|
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
|
||||||
int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this);
|
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
|
||||||
if (-1 == toIndex)
|
int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this);
|
||||||
{
|
if (-1 == toIndex)
|
||||||
toIndex = d->DockArea->count() - 1;
|
{
|
||||||
|
toIndex = d->DockArea->count() - 1;
|
||||||
|
}
|
||||||
|
qDebug() << "Move tab from " << fromIndex << " to " << toIndex;
|
||||||
|
d->DockArea->reorderDockWidget(fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
qDebug() << "Move tab from " << fromIndex << " to " << toIndex;
|
|
||||||
d->DockArea->reorderDockWidget(fromIndex, toIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->DragStartMousePosition.isNull())
|
if (!d->DragStartMousePosition.isNull())
|
||||||
@ -275,7 +278,9 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
if (d->isDraggingState(DraggingFloatingWidget))
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
{
|
{
|
||||||
d->FloatingWidget->moveFloating();
|
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||||
|
d->FloatingWidget->moveFloating();
|
||||||
|
}
|
||||||
QFrame::mouseMoveEvent(ev);
|
QFrame::mouseMoveEvent(ev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -283,19 +288,25 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
// move tab
|
// move tab
|
||||||
if (d->isDraggingState(DraggingTab))
|
if (d->isDraggingState(DraggingTab))
|
||||||
{
|
{
|
||||||
d->moveTab(ev);
|
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||||
|
d->moveTab(ev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
|
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
|
||||||
if (!MouseInsideTitleArea)
|
if (!MouseInsideTitleArea)
|
||||||
{
|
{
|
||||||
d->startFloating();
|
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||||
|
d->startFloating();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (d->DockArea->count() > 1
|
else if (d->DockArea->count() > 1
|
||||||
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
|
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
|
||||||
{
|
{
|
||||||
d->DragState = DraggingTab;
|
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
|
||||||
|
d->DragState = DraggingTab;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user