mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Use code also for other unix systems like BSD (#507)
This commit is contained in:
parent
c6595563af
commit
a940fc29c6
@ -27,7 +27,7 @@
|
||||
#include "DockManager.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include "linux/FloatingWidgetTitleBar.h"
|
||||
#endif
|
||||
|
||||
@ -44,7 +44,7 @@ struct DockFocusControllerPrivate
|
||||
QPointer<CDockWidget> FocusedDockWidget = nullptr;
|
||||
QPointer<CDockAreaWidget> FocusedArea = nullptr;
|
||||
QPointer<CDockWidget> OldFocusedDockWidget = nullptr;
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
QPointer<CFloatingDockContainer> FloatingWidget = nullptr;
|
||||
#endif
|
||||
CDockManager* DockManager;
|
||||
@ -84,7 +84,7 @@ static void updateDockAreaFocusStyle(CDockAreaWidget* DockArea, bool Focused)
|
||||
|
||||
|
||||
//===========================================================================
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
static void updateFloatingWidgetFocusStyle(CFloatingDockContainer* FloatingWidget, bool Focused)
|
||||
{
|
||||
if (FloatingWidget->hasNativeTitleBar())
|
||||
@ -168,7 +168,7 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
||||
}
|
||||
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
// This code is required for styling the floating widget titlebar for linux
|
||||
// depending on the current focus state
|
||||
if (FloatingWidget != NewFloatingWidget)
|
||||
@ -285,7 +285,7 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
|
||||
DockWidget = internal::findParent<CDockWidget*>(focusedNow);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if (!DockWidget)
|
||||
{
|
||||
return;
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "DockFocusController.h"
|
||||
#include "DockSplitter.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include "linux/FloatingWidgetTitleBar.h"
|
||||
#endif
|
||||
|
||||
@ -192,7 +192,7 @@ void DockManagerPrivate::loadStylesheet()
|
||||
QString FileName = ":ads/stylesheets/";
|
||||
FileName += CDockManager::testConfigFlag(CDockManager::FocusHighlighting)
|
||||
? "focus_highlighting" : "default";
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
FileName += "_linux";
|
||||
#endif
|
||||
FileName += ".css";
|
||||
@ -510,7 +510,7 @@ CDockManager::CDockManager(QWidget *parent) :
|
||||
d->FocusController = new CDockFocusController(this);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
window()->installEventFilter(this);
|
||||
|
||||
connect(qApp, &QApplication::focusWindowChanged, [](QWindow* focusWindow)
|
||||
@ -552,7 +552,7 @@ CDockManager::~CDockManager()
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
bool CDockManager::eventFilter(QObject *obj, QEvent *e)
|
||||
{
|
||||
// Emulate Qt:Tool behaviour.
|
||||
|
@ -560,7 +560,7 @@ public:
|
||||
widget->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||
#endif
|
||||
|
||||
|
@ -139,7 +139,7 @@ struct DockOverlayCrossPrivate
|
||||
*/
|
||||
qreal dropIndicatiorWidth(QLabel* l) const
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
Q_UNUSED(l)
|
||||
return 40;
|
||||
#else
|
||||
@ -333,7 +333,7 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) :
|
||||
{
|
||||
d->Mode = Mode;
|
||||
d->Cross = new CDockOverlayCross(this);
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||
#else
|
||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||
@ -595,7 +595,7 @@ CDockOverlayCross::CDockOverlayCross(CDockOverlay* overlay) :
|
||||
d(new DockOverlayCrossPrivate(this))
|
||||
{
|
||||
d->DockOverlay = overlay;
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||
#else
|
||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||
|
@ -52,7 +52,7 @@
|
||||
#pragma comment(lib, "User32.lib")
|
||||
#endif
|
||||
#endif
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include "linux/FloatingWidgetTitleBar.h"
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
@ -374,7 +374,7 @@ struct FloatingDockContainerPrivate
|
||||
QPoint DragStartPos;
|
||||
bool Hiding = false;
|
||||
bool AutoHideChildren = true;
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
QWidget* MouseEventHandler = nullptr;
|
||||
CFloatingWidgetTitleBar* TitleBar = nullptr;
|
||||
bool IsResizing = false;
|
||||
@ -424,7 +424,7 @@ struct FloatingDockContainerPrivate
|
||||
|
||||
void setWindowTitle(const QString &Text)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if (TitleBar)
|
||||
{
|
||||
TitleBar->setTitle(Text);
|
||||
@ -540,7 +540,7 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
// Prevent display of drop overlays and docking as long as a model dialog
|
||||
// is active
|
||||
if (qApp->activeModalWidget())
|
||||
@ -641,7 +641,7 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
|
||||
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this,
|
||||
SLOT(onDockAreasAddedOrRemoved()));
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
QDockWidget::setWidget(d->DockContainer);
|
||||
QDockWidget::setFloating(true);
|
||||
QDockWidget::setFeatures(QDockWidget::DockWidgetClosable
|
||||
@ -768,7 +768,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
|
||||
ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange ");
|
||||
d->zOrderIndex = ++zOrderCounter;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if (d->DraggingState == DraggingFloatingWidget)
|
||||
{
|
||||
d->titleMouseReleaseEvent();
|
||||
@ -920,7 +920,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||
void CFloatingDockContainer::showEvent(QShowEvent *event)
|
||||
{
|
||||
Super::showEvent(event);
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
|
||||
{
|
||||
this->window()->activateWindow();
|
||||
@ -933,7 +933,7 @@ void CFloatingDockContainer::showEvent(QShowEvent *event)
|
||||
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
|
||||
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if (!isMaximized())
|
||||
{
|
||||
resize(Size);
|
||||
@ -1070,7 +1070,7 @@ bool CFloatingDockContainer::restoreState(CDockingStateReader &Stream,
|
||||
return false;
|
||||
}
|
||||
onDockAreasAddedOrRemoved();
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if(d->TitleBar)
|
||||
{
|
||||
d->TitleBar->setMaximizedIcon(windowState() == Qt::WindowMaximized);
|
||||
@ -1114,7 +1114,7 @@ void CFloatingDockContainer::hideAndDeleteLater()
|
||||
void CFloatingDockContainer::finishDragging()
|
||||
{
|
||||
ADS_PRINT("CFloatingDockContainer::finishDragging");
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
setWindowOpacity(1);
|
||||
activateWindow();
|
||||
if (d->MouseEventHandler)
|
||||
@ -1229,7 +1229,7 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::onMaximizeRequest()
|
||||
{
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include <QRubberBand>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include <QDockWidget>
|
||||
#define tFloatingWidgetBase QDockWidget
|
||||
#else
|
||||
@ -182,10 +182,8 @@ protected: // reimplements QWidget
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
virtual bool event(QEvent *e) override;
|
||||
virtual void moveEvent(QMoveEvent *event) override;
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
virtual void moveEvent(QMoveEvent *event) override;
|
||||
#elif defined(Q_OS_UNIX)
|
||||
virtual void moveEvent(QMoveEvent *event) override;
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
virtual bool event(QEvent *e) override;
|
||||
@ -264,7 +262,7 @@ public:
|
||||
*/
|
||||
void hideAndDeleteLater();
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
/**
|
||||
* This is a function that responds to FloatingWidgetTitleBar::maximizeRequest()
|
||||
* Maximize or normalize the container size.
|
||||
|
@ -262,7 +262,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
auto Flags = windowFlags();
|
||||
Flags |= Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
|
||||
setWindowFlags(Flags);
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "IconProvider.h"
|
||||
#include "ads_globals.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include <QSettings>
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
@ -52,7 +52,7 @@ namespace internal
|
||||
{
|
||||
const int FloatingWidgetDragStartEvent = QEvent::registerEventType();
|
||||
const int DockedWidgetDragStartEvent = QEvent::registerEventType();
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
static QString _window_manager;
|
||||
static QHash<QString, xcb_atom_t> _xcb_atom_cache;
|
||||
|
||||
@ -371,7 +371,7 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
Button->setIcon(Button->style()->standardIcon(StandarPixmap));
|
||||
#else
|
||||
// The standard icons does not look good on high DPI screens so we create
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
@ -156,7 +156,7 @@ static const char* const DirtyProperty = "dirty";
|
||||
extern const int FloatingWidgetDragStartEvent;
|
||||
extern const int DockedWidgetDragStartEvent;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
// Utils to directly communicate with the X server
|
||||
/**
|
||||
* Get atom from cache or request it from the XServer.
|
||||
|
Loading…
Reference in New Issue
Block a user