add showMacWindowButton
This commit is contained in:
parent
ce69d1a4c5
commit
de1d6abaf0
|
@ -1,5 +1,6 @@
|
||||||
#include "flwindow.h"
|
#include "flwindow.h"
|
||||||
#include "../../framelesshelper.h"
|
#include "../../framelesshelper.h"
|
||||||
|
#include "../../utilities.h"
|
||||||
|
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
@ -30,6 +31,13 @@ void FLWindow::initFramelessWindow()
|
||||||
helper->setHitTestVisible(m_maximizeButton);
|
helper->setHitTestVisible(m_maximizeButton);
|
||||||
helper->setHitTestVisible(m_closeButton);
|
helper->setHitTestVisible(m_closeButton);
|
||||||
helper->install();
|
helper->install();
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
m_minimizeButton->hide();
|
||||||
|
m_maximizeButton->hide();
|
||||||
|
m_closeButton->hide();
|
||||||
|
Utilities::showMacWindowButton(windowHandle());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLWindow::showEvent(QShowEvent *event)
|
void FLWindow::showEvent(QShowEvent *event)
|
||||||
|
@ -89,4 +97,4 @@ void FLWindow::setupUi()
|
||||||
mainLayout->addWidget(m_titleBarWidget);
|
mainLayout->addWidget(m_titleBarWidget);
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ FRAMELESSHELPER_API bool unsetMacWindowHook(QWindow* w);
|
||||||
FRAMELESSHELPER_API bool setMacWindowFrameless(QWindow* w);
|
FRAMELESSHELPER_API bool setMacWindowFrameless(QWindow* w);
|
||||||
FRAMELESSHELPER_API bool startMacDrag(QWindow* w, const QPoint& pos);
|
FRAMELESSHELPER_API bool startMacDrag(QWindow* w, const QPoint& pos);
|
||||||
FRAMELESSHELPER_API Qt::MouseButtons getMacMouseButtons();
|
FRAMELESSHELPER_API Qt::MouseButtons getMacMouseButtons();
|
||||||
|
FRAMELESSHELPER_API bool showMacWindowButton(QWindow *w);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,16 +223,36 @@ bool setMacWindowFrameless(QWindow* w)
|
||||||
nswindow.titlebarAppearsTransparent = true;
|
nswindow.titlebarAppearsTransparent = true;
|
||||||
nswindow.titleVisibility = NSWindowTitleHidden;
|
nswindow.titleVisibility = NSWindowTitleHidden;
|
||||||
nswindow.hasShadow = true;
|
nswindow.hasShadow = true;
|
||||||
nswindow.showsToolbarButton = false;
|
|
||||||
nswindow.movableByWindowBackground = false;
|
nswindow.movableByWindowBackground = false;
|
||||||
nswindow.movable = false;
|
nswindow.movable = false;
|
||||||
[nswindow standardWindowButton:NSWindowCloseButton].hidden = true;
|
|
||||||
[nswindow standardWindowButton:NSWindowMiniaturizeButton].hidden = true;
|
nswindow.showsToolbarButton = false;
|
||||||
[nswindow standardWindowButton:NSWindowZoomButton].hidden = true;
|
[nswindow standardWindowButton:NSWindowCloseButton].hidden = true;
|
||||||
|
[nswindow standardWindowButton:NSWindowMiniaturizeButton].hidden = true;
|
||||||
|
[nswindow standardWindowButton:NSWindowZoomButton].hidden = true;
|
||||||
|
|
||||||
[nswindow makeKeyWindow];
|
[nswindow makeKeyWindow];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool showMacWindowButton(QWindow *w)
|
||||||
|
{
|
||||||
|
NSView* view = reinterpret_cast<NSView *>(w->winId());
|
||||||
|
if (view == nullptr)
|
||||||
|
return false;
|
||||||
|
NSWindow* nswindow = [view window];
|
||||||
|
if (nswindow == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
nswindow.showsToolbarButton = true;
|
||||||
|
[nswindow standardWindowButton:NSWindowCloseButton].hidden = false;
|
||||||
|
[nswindow standardWindowButton:NSWindowMiniaturizeButton].hidden = false;
|
||||||
|
[nswindow standardWindowButton:NSWindowZoomButton].hidden = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool startMacDrag(QWindow* w, const QPoint& pos)
|
bool startMacDrag(QWindow* w, const QPoint& pos)
|
||||||
{
|
{
|
||||||
NSView* view = reinterpret_cast<NSView *>(w->winId());
|
NSView* view = reinterpret_cast<NSView *>(w->winId());
|
||||||
|
|
Loading…
Reference in New Issue