| | |
| | | switch (id) { |
| | | case CentralizeHook: { |
| | | QRect screenGeometry = m_windowHandle->screen()->geometry(); |
| | | int x = screenGeometry.width() / 2 - m_windowHandle->width() / 2; |
| | | int y = screenGeometry.height() / 2 - m_windowHandle->height() / 2; |
| | | m_windowHandle->setPosition(x, y); |
| | | break; |
| | | int x = (screenGeometry.width() - m_windowHandle->width()) / 2; |
| | | int y = (screenGeometry.height() - m_windowHandle->height()) / 2; |
| | | QPoint pos(x, y); |
| | | pos += screenGeometry.topLeft(); |
| | | m_windowHandle->setPosition(pos); |
| | | return; |
| | | } |
| | | |
| | | case RaiseWindowHook: { |
| | | if (m_windowHandle->windowStates() & Qt::WindowMinimized) |
| | | m_windowHandle->showNormal(); |
| | | m_windowHandle->raise(); |
| | | break; |
| | | Qt::WindowStates state = m_delegate->getWindowState(m_host); |
| | | if (state & Qt::WindowMinimized) { |
| | | m_delegate->setWindowState(m_host, state & ~Qt::WindowMinimized); |
| | | } |
| | | m_delegate->bringWindowToTop(m_host); |
| | | return; |
| | | } |
| | | |
| | | case DefaultColorsHook: { |
| | |
| | | } |
| | | |
| | | case RaiseWindowHook: { |
| | | if (m_windowHandle->windowStates() & Qt::WindowMinimized) |
| | | m_windowHandle->showNormal(); |
| | | |
| | | auto hWnd = reinterpret_cast<HWND>(windowId); |
| | | |
| | | // I have no idea what this does, but it works mostly |
| | | // https://www.codeproject.com/Articles/1724/Some-handy-dialog-box-tricks-tips-and-workarounds |
| | | |
| | | ::AttachThreadInput(::GetWindowThreadProcessId(::GetForegroundWindow(), nullptr), |
| | | ::GetCurrentThreadId(), TRUE); |
| | | |
| | | ::SetForegroundWindow(hWnd); |
| | | ::SetFocus(hWnd); |
| | | |
| | | ::AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), nullptr), |
| | | GetCurrentThreadId(), FALSE); |
| | | // FIXME |
| | | return; |
| | | } |
| | | |
| | |
| | | virtual void setCursorShape(QObject *host, Qt::CursorShape shape) const = 0; |
| | | virtual void restoreCursorShape(QObject *host) const = 0; |
| | | virtual void setWindowFlags(QObject *host, Qt::WindowFlags flags) const = 0; |
| | | virtual void bringWindowToTop(QObject *host) const = 0; |
| | | |
| | | private: |
| | | Q_DISABLE_COPY(WindowItemDelegate) |
| | |
| | | static_cast<QQuickWindow *>(host)->setFlags(flags); |
| | | } |
| | | |
| | | void QuickItemDelegate::bringWindowToTop(QObject *host) const { |
| | | static_cast<QQuickWindow *>(host)->raise(); |
| | | } |
| | | |
| | | } |
| | |
| | | void setCursorShape(QObject *host, Qt::CursorShape shape) const override; |
| | | void restoreCursorShape(QObject *host) const override; |
| | | void setWindowFlags(QObject *host, Qt::WindowFlags flags) const override; |
| | | void bringWindowToTop(QObject *host) const override; |
| | | }; |
| | | |
| | | } |
| | |
| | | static_cast<QWidget *>(host)->setWindowFlags(flags); |
| | | } |
| | | |
| | | void WidgetItemDelegate::bringWindowToTop(QObject *host) const { |
| | | static_cast<QWidget *>(host)->raise(); |
| | | } |
| | | |
| | | } |
| | |
| | | void setCursorShape(QObject *host, Qt::CursorShape shape) const override; |
| | | void restoreCursorShape(QObject *host) const override; |
| | | void setWindowFlags(QObject *host, Qt::WindowFlags flags) const override; |
| | | void bringWindowToTop(QObject *host) const override; |
| | | }; |
| | | |
| | | } |