fix: move dock clicker too other files
This commit is contained in:
parent
bd668c0dfe
commit
fd4fc7c46d
|
@ -20,6 +20,7 @@ macro(add_target name type)
|
||||||
include/DOtherSide/DosIQAbstractItemModelImpl.h
|
include/DOtherSide/DosIQAbstractItemModelImpl.h
|
||||||
include/DOtherSide/DosQAbstractItemModel.h
|
include/DOtherSide/DosQAbstractItemModel.h
|
||||||
include/DOtherSide/Utils.h
|
include/DOtherSide/Utils.h
|
||||||
|
include/DOtherSide/DosDockClicker.h
|
||||||
src/DOtherSide.cpp
|
src/DOtherSide.cpp
|
||||||
src/DosQMetaObject.cpp
|
src/DosQMetaObject.cpp
|
||||||
src/DosQDeclarative.cpp
|
src/DosQDeclarative.cpp
|
||||||
|
@ -28,6 +29,7 @@ macro(add_target name type)
|
||||||
src/DosQObjectImpl.cpp
|
src/DosQObjectImpl.cpp
|
||||||
src/DosQAbstractItemModel.cpp
|
src/DosQAbstractItemModel.cpp
|
||||||
src/DosQQuickImageProvider.cpp
|
src/DosQQuickImageProvider.cpp
|
||||||
|
src/DosDockClicker.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef DOCKCLICKER_H
|
||||||
|
#define DOCKCLICKER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <QQmlApplicationEngine>
|
||||||
|
#include "DOtherSidetypes.h"
|
||||||
|
|
||||||
|
class DockClicker : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
Qt::ApplicationState _prevAppState;
|
||||||
|
QQmlApplicationEngine* _engine;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DockClicker(DosQQmlApplicationEngine *vptr) {
|
||||||
|
auto engine = static_cast<QQmlApplicationEngine *>(vptr);
|
||||||
|
_engine = engine;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DOCKCLICKER_H
|
|
@ -57,6 +57,7 @@
|
||||||
#include "DOtherSide/DosQAbstractItemModel.h"
|
#include "DOtherSide/DosQAbstractItemModel.h"
|
||||||
#include "DOtherSide/DosQDeclarative.h"
|
#include "DOtherSide/DosQDeclarative.h"
|
||||||
#include "DOtherSide/DosQQuickImageProvider.h"
|
#include "DOtherSide/DosQQuickImageProvider.h"
|
||||||
|
#include "DOtherSide/DosDockClicker.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -155,46 +156,6 @@ void dos_qguiapplication_quit()
|
||||||
qGuiApp->quit();
|
qGuiApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
class DockClicker : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private:
|
|
||||||
Qt::ApplicationState _prevAppState;
|
|
||||||
QQmlApplicationEngine* _engine;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DockClicker(::DosQQmlApplicationEngine *vptr) {
|
|
||||||
auto engine = static_cast<QQmlApplicationEngine *>(vptr);
|
|
||||||
_engine = engine;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool DockClicker::eventFilter(QObject *obj, QEvent *event)
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
if (obj == qApp) {
|
|
||||||
if (event->type() == QEvent::ApplicationStateChange) {
|
|
||||||
auto ev = static_cast<QApplicationStateChangeEvent*>(event);
|
|
||||||
if (_prevAppState == Qt::ApplicationActive && ev->applicationState() == Qt::ApplicationActive) {
|
|
||||||
QObject *topLevel = _engine->rootObjects().value(0);
|
|
||||||
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
|
|
||||||
window->setVisible(true);
|
|
||||||
window->showNormal();
|
|
||||||
}
|
|
||||||
_prevAppState = ev->applicationState();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // Q_OS_MACOS
|
|
||||||
return QObject::eventFilter(obj, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dos_qapplication_create(char *appName)
|
void dos_qapplication_create(char *appName)
|
||||||
{
|
{
|
||||||
static int argc = 1;
|
static int argc = 1;
|
||||||
|
@ -1319,4 +1280,3 @@ char *dos_qurl_replaceHostAndAddPath(char* url, char* newScheme, char* newHost,
|
||||||
|
|
||||||
return convert_to_cstring(newQurl.toString());
|
return convert_to_cstring(newQurl.toString());
|
||||||
}
|
}
|
||||||
#include "DOtherSide.moc"
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include "DOtherSide/DosDockClicker.h"
|
||||||
|
|
||||||
|
#include <QQuickWindow>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
|
bool DockClicker::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (obj == qApp) {
|
||||||
|
if (event->type() == QEvent::ApplicationStateChange) {
|
||||||
|
auto ev = static_cast<QApplicationStateChangeEvent*>(event);
|
||||||
|
if (_prevAppState == Qt::ApplicationActive && ev->applicationState() == Qt::ApplicationActive) {
|
||||||
|
QObject *topLevel = _engine->rootObjects().value(0);
|
||||||
|
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
|
||||||
|
window->setVisible(true);
|
||||||
|
window->showNormal();
|
||||||
|
}
|
||||||
|
_prevAppState = ev->applicationState();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // Q_OS_MACOS
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
Loading…
Reference in New Issue