Compare commits
5 Commits
pre-commit
...
a6e0de9db9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6e0de9db9 | ||
|
|
0ad83ea1b4 | ||
|
|
fdcdaae1f1 | ||
|
|
af455bb37e | ||
|
|
57aded2a67 |
@@ -1,5 +1,9 @@
|
|||||||
# See https://pre-commit.com for more information
|
# See https://pre-commit.com for more information
|
||||||
# See https://pre-commit.com/hooks.html for more hooks
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
ci:
|
||||||
|
skip: [pylint]
|
||||||
|
autoupdate_schedule: monthly
|
||||||
|
|
||||||
exclude: ^(cmake/ECM|cmake/KDAB/)
|
exclude: ^(cmake/ECM|cmake/KDAB/)
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowO
|
|||||||
if (options & KDDockWidgets::MainWindowOption_HasCentralWidget) {
|
if (options & KDDockWidgets::MainWindowOption_HasCentralWidget) {
|
||||||
setPersistentCentralWidget(new MyWidget1());
|
setPersistentCentralWidget(new MyWidget1());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional, just for demo purposes regarding pressing Ctrl key to hide drop indicators
|
||||||
|
qApp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyMainWindow::~MyMainWindow()
|
MyMainWindow::~MyMainWindow()
|
||||||
@@ -210,3 +213,26 @@ KDDockWidgets::DockWidgetBase *MyMainWindow::newDockWidget()
|
|||||||
count++;
|
count++;
|
||||||
return dock;
|
return dock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MyMainWindow::eventFilter(QObject *obj, QEvent *ev)
|
||||||
|
{
|
||||||
|
// This event filter is just for examplify how to use the KDDW API to hide
|
||||||
|
// the drag indicators when ctrl is pressed
|
||||||
|
|
||||||
|
switch (ev->type()) {
|
||||||
|
case QEvent::KeyPress:
|
||||||
|
case QEvent::KeyRelease: {
|
||||||
|
auto kev = static_cast<QKeyEvent *>(ev);
|
||||||
|
if (kev->key() == Qt::Key_Control && qobject_cast<QWindow *>(obj)) {
|
||||||
|
const bool hideIndicators = ev->type() == QEvent::KeyPress;
|
||||||
|
KDDockWidgets::Config::self().setDropIndicatorsInhibited(hideIndicators);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void createDockWidgets();
|
void createDockWidgets();
|
||||||
|
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||||
KDDockWidgets::DockWidgetBase *newDockWidget();
|
KDDockWidgets::DockWidgetBase *newDockWidget();
|
||||||
QMenu *m_toggleMenu = nullptr;
|
QMenu *m_toggleMenu = nullptr;
|
||||||
const bool m_dockWidget0IsNonClosable;
|
const bool m_dockWidget0IsNonClosable;
|
||||||
|
|||||||
@@ -182,8 +182,9 @@ private:
|
|||||||
|
|
||||||
enum RestoreOption {
|
enum RestoreOption {
|
||||||
RestoreOption_None = 0,
|
RestoreOption_None = 0,
|
||||||
RestoreOption_RelativeToMainWindow = 1, ///< Skips restoring the main window geometry and the restored dock widgets will use relative sizing.
|
RestoreOption_RelativeToMainWindow = 1 << 0, ///< Skips restoring the main window geometry and the restored dock widgets will use relative sizing.
|
||||||
///< Loading layouts won't change the main window geometry and just use whatever the user has at the moment.
|
///< Loading layouts won't change the main window geometry and just use whatever the user has at the moment.
|
||||||
|
RestoreOption_AbsoluteFloatingDockWindows = 1 << 1, ///< Skips scaling of floating dock windows relative to the main window.
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
|
Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
|
||||||
Q_ENUM_NS(RestoreOptions)
|
Q_ENUM_NS(RestoreOptions)
|
||||||
|
|||||||
@@ -66,15 +66,22 @@ LayoutSaver::Layout *LayoutSaver::Layout::s_currentLayoutBeingRestored = nullptr
|
|||||||
|
|
||||||
inline InternalRestoreOptions internalRestoreOptions(RestoreOptions options)
|
inline InternalRestoreOptions internalRestoreOptions(RestoreOptions options)
|
||||||
{
|
{
|
||||||
if (options == RestoreOption_None) {
|
InternalRestoreOptions ret = {};
|
||||||
return InternalRestoreOption::None;
|
if (options.testFlag(RestoreOption_RelativeToMainWindow)) {
|
||||||
} else if (options == RestoreOption_RelativeToMainWindow) {
|
ret.setFlag(InternalRestoreOption::SkipMainWindowGeometry);
|
||||||
return InternalRestoreOptions(InternalRestoreOption::SkipMainWindowGeometry)
|
ret.setFlag(InternalRestoreOption::RelativeFloatingWindowGeometry);
|
||||||
| InternalRestoreOption::RelativeFloatingWindowGeometry;
|
options.setFlag(RestoreOption_RelativeToMainWindow, false);
|
||||||
} else {
|
|
||||||
qWarning() << Q_FUNC_INFO << "Unknown options" << options;
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
if (options.testFlag(RestoreOption_AbsoluteFloatingDockWindows)) {
|
||||||
|
ret.setFlag(InternalRestoreOption::RelativeFloatingWindowGeometry, false);
|
||||||
|
options.setFlag(RestoreOption_AbsoluteFloatingDockWindows, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options != RestoreOption_None) {
|
||||||
|
qWarning() << Q_FUNC_INFO << "Unknown options" << options;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayoutSaver::Private::s_restoreInProgress = false;
|
bool LayoutSaver::Private::s_restoreInProgress = false;
|
||||||
|
|||||||
@@ -553,8 +553,8 @@ void MainWindowBase::overlayOnSideBar(DockWidgetBase *dw)
|
|||||||
d->m_overlayedDockWidget = dw;
|
d->m_overlayedDockWidget = dw;
|
||||||
frame->addWidget(dw);
|
frame->addWidget(dw);
|
||||||
d->updateOverlayGeometry(dw->d->lastPosition()->lastOverlayedGeometry(sb->location()).size());
|
d->updateOverlayGeometry(dw->d->lastPosition()->lastOverlayedGeometry(sb->location()).size());
|
||||||
connect(frame, &QWidgetAdapter::widgetGeometryChanged, this, [dw, loc = sb->location(), frame] {
|
connect(frame, &QWidgetAdapter::widgetGeometryChanged, this, [dw, sb, frame] {
|
||||||
dw->d->lastPosition()->setLastOverlayedGeometry(loc, frame->QWidgetAdapter::geometry());
|
dw->d->lastPosition()->setLastOverlayedGeometry(sb->location(), frame->QWidgetAdapter::geometry());
|
||||||
});
|
});
|
||||||
|
|
||||||
frame->setAllowedResizeSides(d->allowedResizeSides(sb->location()));
|
frame->setAllowedResizeSides(d->allowedResizeSides(sb->location()));
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ public:
|
|||||||
/// Experimental, internal, not for general use.
|
/// Experimental, internal, not for general use.
|
||||||
void enableFallbackMouseGrabber();
|
void enableFallbackMouseGrabber();
|
||||||
|
|
||||||
|
// Returns the active state
|
||||||
|
StateBase *activeState() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void mousePressed();
|
void mousePressed();
|
||||||
void manhattanLengthMove();
|
void manhattanLengthMove();
|
||||||
@@ -128,7 +131,6 @@ private:
|
|||||||
friend class StateDraggingWayland;
|
friend class StateDraggingWayland;
|
||||||
|
|
||||||
DragController(QObject * = nullptr);
|
DragController(QObject * = nullptr);
|
||||||
StateBase *activeState() const;
|
|
||||||
WidgetType *qtTopLevelUnderCursor() const;
|
WidgetType *qtTopLevelUnderCursor() const;
|
||||||
Draggable *draggableForQObject(QObject *o) const;
|
Draggable *draggableForQObject(QObject *o) const;
|
||||||
QPoint m_pressPos;
|
QPoint m_pressPos;
|
||||||
|
|||||||
@@ -31,10 +31,14 @@ DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(DropArea *dropArea)
|
|||||||
|
|
||||||
connect(DockRegistry::self(), &DockRegistry::dropIndicatorsInhibitedChanged, this,
|
connect(DockRegistry::self(), &DockRegistry::dropIndicatorsInhibitedChanged, this,
|
||||||
[this](bool inhibited) {
|
[this](bool inhibited) {
|
||||||
if (inhibited)
|
if (inhibited) {
|
||||||
removeHover();
|
removeHover();
|
||||||
|
} else {
|
||||||
// if false then simply moving the mouse will make the drop indicators appear again
|
// Re-add hover. Fastest way is simply faking a mouse move
|
||||||
|
if (auto state = qobject_cast<StateDragging *>(DragController::instance()->activeState())) {
|
||||||
|
state->handleMouseMove(QCursor::pos());
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user