Skip to content

Commit a940fc2

Browse files
authored
Use code also for other unix systems like BSD (#507)
1 parent c659556 commit a940fc2

9 files changed

+34
-36
lines changed

src/DockFocusController.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "DockManager.h"
2828
#include "DockAreaTitleBar.h"
2929

30-
#ifdef Q_OS_LINUX
30+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
3131
#include "linux/FloatingWidgetTitleBar.h"
3232
#endif
3333

@@ -44,7 +44,7 @@ struct DockFocusControllerPrivate
4444
QPointer<CDockWidget> FocusedDockWidget = nullptr;
4545
QPointer<CDockAreaWidget> FocusedArea = nullptr;
4646
QPointer<CDockWidget> OldFocusedDockWidget = nullptr;
47-
#ifdef Q_OS_LINUX
47+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
4848
QPointer<CFloatingDockContainer> FloatingWidget = nullptr;
4949
#endif
5050
CDockManager* DockManager;
@@ -84,7 +84,7 @@ static void updateDockAreaFocusStyle(CDockAreaWidget* DockArea, bool Focused)
8484

8585

8686
//===========================================================================
87-
#ifdef Q_OS_LINUX
87+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
8888
static void updateFloatingWidgetFocusStyle(CFloatingDockContainer* FloatingWidget, bool Focused)
8989
{
9090
if (FloatingWidget->hasNativeTitleBar())
@@ -168,7 +168,7 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
168168
}
169169

170170

171-
#ifdef Q_OS_LINUX
171+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
172172
// This code is required for styling the floating widget titlebar for linux
173173
// depending on the current focus state
174174
if (FloatingWidget != NewFloatingWidget)
@@ -285,7 +285,7 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
285285
DockWidget = internal::findParent<CDockWidget*>(focusedNow);
286286
}
287287

288-
#ifdef Q_OS_LINUX
288+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
289289
if (!DockWidget)
290290
{
291291
return;

src/DockManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include "DockFocusController.h"
6060
#include "DockSplitter.h"
6161

62-
#ifdef Q_OS_LINUX
62+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
6363
#include "linux/FloatingWidgetTitleBar.h"
6464
#endif
6565

@@ -192,7 +192,7 @@ void DockManagerPrivate::loadStylesheet()
192192
QString FileName = ":ads/stylesheets/";
193193
FileName += CDockManager::testConfigFlag(CDockManager::FocusHighlighting)
194194
? "focus_highlighting" : "default";
195-
#ifdef Q_OS_LINUX
195+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
196196
FileName += "_linux";
197197
#endif
198198
FileName += ".css";
@@ -510,7 +510,7 @@ CDockManager::CDockManager(QWidget *parent) :
510510
d->FocusController = new CDockFocusController(this);
511511
}
512512

513-
#ifdef Q_OS_LINUX
513+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
514514
window()->installEventFilter(this);
515515

516516
connect(qApp, &QApplication::focusWindowChanged, [](QWindow* focusWindow)
@@ -552,7 +552,7 @@ CDockManager::~CDockManager()
552552
}
553553

554554
//============================================================================
555-
#ifdef Q_OS_LINUX
555+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
556556
bool CDockManager::eventFilter(QObject *obj, QEvent *e)
557557
{
558558
// Emulate Qt:Tool behaviour.

src/DockManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
560560
widget->setFocus(Qt::OtherFocusReason);
561561
}
562562

563-
#ifdef Q_OS_LINUX
563+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
564564
bool eventFilter(QObject *obj, QEvent *e) override;
565565
#endif
566566

src/DockOverlay.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ struct DockOverlayCrossPrivate
139139
*/
140140
qreal dropIndicatiorWidth(QLabel* l) const
141141
{
142-
#ifdef Q_OS_LINUX
142+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
143143
Q_UNUSED(l)
144144
return 40;
145145
#else
@@ -333,7 +333,7 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) :
333333
{
334334
d->Mode = Mode;
335335
d->Cross = new CDockOverlayCross(this);
336-
#ifdef Q_OS_LINUX
336+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
337337
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
338338
#else
339339
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
@@ -595,7 +595,7 @@ CDockOverlayCross::CDockOverlayCross(CDockOverlay* overlay) :
595595
d(new DockOverlayCrossPrivate(this))
596596
{
597597
d->DockOverlay = overlay;
598-
#ifdef Q_OS_LINUX
598+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
599599
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
600600
#else
601601
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);

src/FloatingDockContainer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#pragma comment(lib, "User32.lib")
5353
#endif
5454
#endif
55-
#ifdef Q_OS_LINUX
55+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
5656
#include "linux/FloatingWidgetTitleBar.h"
5757
#include <xcb/xcb.h>
5858
#endif
@@ -374,7 +374,7 @@ struct FloatingDockContainerPrivate
374374
QPoint DragStartPos;
375375
bool Hiding = false;
376376
bool AutoHideChildren = true;
377-
#ifdef Q_OS_LINUX
377+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
378378
QWidget* MouseEventHandler = nullptr;
379379
CFloatingWidgetTitleBar* TitleBar = nullptr;
380380
bool IsResizing = false;
@@ -424,7 +424,7 @@ struct FloatingDockContainerPrivate
424424

425425
void setWindowTitle(const QString &Text)
426426
{
427-
#ifdef Q_OS_LINUX
427+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
428428
if (TitleBar)
429429
{
430430
TitleBar->setTitle(Text);
@@ -540,7 +540,7 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
540540
return;
541541
}
542542

543-
#ifdef Q_OS_LINUX
543+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
544544
// Prevent display of drop overlays and docking as long as a model dialog
545545
// is active
546546
if (qApp->activeModalWidget())
@@ -641,7 +641,7 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
641641
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this,
642642
SLOT(onDockAreasAddedOrRemoved()));
643643

644-
#ifdef Q_OS_LINUX
644+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
645645
QDockWidget::setWidget(d->DockContainer);
646646
QDockWidget::setFloating(true);
647647
QDockWidget::setFeatures(QDockWidget::DockWidgetClosable
@@ -768,7 +768,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
768768
ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange ");
769769
d->zOrderIndex = ++zOrderCounter;
770770

771-
#ifdef Q_OS_LINUX
771+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
772772
if (d->DraggingState == DraggingFloatingWidget)
773773
{
774774
d->titleMouseReleaseEvent();
@@ -920,7 +920,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
920920
void CFloatingDockContainer::showEvent(QShowEvent *event)
921921
{
922922
Super::showEvent(event);
923-
#ifdef Q_OS_LINUX
923+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
924924
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
925925
{
926926
this->window()->activateWindow();
@@ -933,7 +933,7 @@ void CFloatingDockContainer::showEvent(QShowEvent *event)
933933
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
934934
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
935935
{
936-
#ifdef Q_OS_LINUX
936+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
937937
if (!isMaximized())
938938
{
939939
resize(Size);
@@ -1070,7 +1070,7 @@ bool CFloatingDockContainer::restoreState(CDockingStateReader &Stream,
10701070
return false;
10711071
}
10721072
onDockAreasAddedOrRemoved();
1073-
#ifdef Q_OS_LINUX
1073+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
10741074
if(d->TitleBar)
10751075
{
10761076
d->TitleBar->setMaximizedIcon(windowState() == Qt::WindowMaximized);
@@ -1114,7 +1114,7 @@ void CFloatingDockContainer::hideAndDeleteLater()
11141114
void CFloatingDockContainer::finishDragging()
11151115
{
11161116
ADS_PRINT("CFloatingDockContainer::finishDragging");
1117-
#ifdef Q_OS_LINUX
1117+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
11181118
setWindowOpacity(1);
11191119
activateWindow();
11201120
if (d->MouseEventHandler)
@@ -1229,7 +1229,7 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
12291229
#endif
12301230

12311231

1232-
#ifdef Q_OS_LINUX
1232+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
12331233
//============================================================================
12341234
void CFloatingDockContainer::onMaximizeRequest()
12351235
{

src/FloatingDockContainer.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include <QRubberBand>
3535

36-
#ifdef Q_OS_LINUX
36+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
3737
#include <QDockWidget>
3838
#define tFloatingWidgetBase QDockWidget
3939
#else
@@ -182,10 +182,8 @@ private Q_SLOTS:
182182

183183
#ifdef Q_OS_MACOS
184184
virtual bool event(QEvent *e) override;
185-
virtual void moveEvent(QMoveEvent *event) override;
186-
#endif
187-
188-
#ifdef Q_OS_LINUX
185+
virtual void moveEvent(QMoveEvent *event) override;
186+
#elif defined(Q_OS_UNIX)
189187
virtual void moveEvent(QMoveEvent *event) override;
190188
virtual void resizeEvent(QResizeEvent *event) override;
191189
virtual bool event(QEvent *e) override;
@@ -264,7 +262,7 @@ private Q_SLOTS:
264262
*/
265263
void hideAndDeleteLater();
266264

267-
#ifdef Q_OS_LINUX
265+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
268266
/**
269267
* This is a function that responds to FloatingWidgetTitleBar::maximizeRequest()
270268
* Maximize or normalize the container size.

src/FloatingDragPreview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
262262
setAttribute(Qt::WA_TranslucentBackground);
263263
}
264264

265-
#ifdef Q_OS_LINUX
265+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
266266
auto Flags = windowFlags();
267267
Flags |= Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
268268
setWindowFlags(Flags);

src/ads_globals.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "IconProvider.h"
3939
#include "ads_globals.h"
4040

41-
#ifdef Q_OS_LINUX
41+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
4242
#include <QSettings>
4343
#include <QFile>
4444
#include <QApplication>
@@ -52,7 +52,7 @@ namespace internal
5252
{
5353
const int FloatingWidgetDragStartEvent = QEvent::registerEventType();
5454
const int DockedWidgetDragStartEvent = QEvent::registerEventType();
55-
#ifdef Q_OS_LINUX
55+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
5656
static QString _window_manager;
5757
static QHash<QString, xcb_atom_t> _xcb_atom_cache;
5858

@@ -371,7 +371,7 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap
371371
return;
372372
}
373373

374-
#ifdef Q_OS_LINUX
374+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
375375
Button->setIcon(Button->style()->standardIcon(StandarPixmap));
376376
#else
377377
// The standard icons does not look good on high DPI screens so we create

src/ads_globals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include <iostream>
4242

43-
#ifdef Q_OS_LINUX
43+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
4444
#include <xcb/xcb.h>
4545
#endif
4646

@@ -156,7 +156,7 @@ static const char* const DirtyProperty = "dirty";
156156
extern const int FloatingWidgetDragStartEvent;
157157
extern const int DockedWidgetDragStartEvent;
158158

159-
#ifdef Q_OS_LINUX
159+
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
160160
// Utils to directly communicate with the X server
161161
/**
162162
* Get atom from cache or request it from the XServer.

0 commit comments

Comments
 (0)