forked from Ivasoft/DSView
fix: can't use hot key on windows
This commit is contained in:
@@ -422,7 +422,7 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
|
||||
return QFrame::eventFilter(object, event);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (type != QEvent::MouseMove
|
||||
&& type != QEvent::MouseButtonPress
|
||||
&& type != QEvent::MouseButtonRelease
|
||||
@@ -761,7 +761,9 @@ void MainFrame::AttachNativeWindow()
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
setProperty("_q_embedded_native_parent_handle", (WId)nativeWindow->Handle());
|
||||
//SetWindowLong((HWND)winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
|
||||
SetWindowLong((HWND)winId(), GWL_STYLE, WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
|
||||
|
||||
SetParent((HWND)winId(), nativeWindow->Handle());
|
||||
|
||||
QEvent e(QEvent::EmbeddingControl);
|
||||
@@ -775,6 +777,7 @@ void MainFrame::AttachNativeWindow()
|
||||
else{
|
||||
nativeWindow->Show(true);
|
||||
}
|
||||
nativeWindow->ResizeChild();
|
||||
|
||||
nativeWindow->SetBorderColor(QColor(0x80, 0x80, 0x80));
|
||||
_parentNativeWidget = nativeWindow;
|
||||
@@ -862,10 +865,6 @@ bool MainFrame::IsMoving()
|
||||
void MainFrame::ReadSettings()
|
||||
{
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
if (app.frameOptions.language > 0){
|
||||
_mainWindow->switchLanguage(app.frameOptions.language);
|
||||
}
|
||||
|
||||
// The history scale region.
|
||||
int left = app.frameOptions.left;
|
||||
@@ -1097,6 +1096,16 @@ void MainFrame::show_doc()
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* MainFrame::GetMainWindow()
|
||||
{
|
||||
return _mainWindow;
|
||||
}
|
||||
|
||||
QWidget* MainFrame::GetBodyView()
|
||||
{
|
||||
return _mainWindow->GetBodyView();
|
||||
}
|
||||
|
||||
bool MainFrame::nativeEvent(const QByteArray &eventType, void *message, long *result)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -1117,7 +1126,7 @@ bool MainFrame::nativeEvent(const QByteArray &eventType, void *message, long *re
|
||||
*result = long(SendMessageW(hwnd,
|
||||
msg->message, msg->wParam, msg->lParam));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,184 +1,186 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2016 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DSVIEW_PV_MAINFRAME_H
|
||||
#define DSVIEW_PV_MAINFRAME_H
|
||||
|
||||
#include "widgets/border.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QTimer>
|
||||
#include <QRect>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <QWinTaskbarButton>
|
||||
#include <QWinTaskbarProgress>
|
||||
#endif
|
||||
|
||||
#include "toolbars/titlebar.h"
|
||||
|
||||
namespace pv {
|
||||
|
||||
class MainWindow;
|
||||
class WinNativeWidget;
|
||||
|
||||
namespace dialogs {
|
||||
class DSMessageBox;
|
||||
class DSDialog;
|
||||
}
|
||||
|
||||
struct Point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct FormRegion{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
struct FormInitInfo
|
||||
{
|
||||
FormRegion r;
|
||||
bool isMaxSize;
|
||||
int k;
|
||||
};
|
||||
|
||||
class MainFrame :
|
||||
public QFrame,
|
||||
public ITitleParent,
|
||||
public IParentNativeEventCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const int Margin = 5;
|
||||
|
||||
enum borderTypes{
|
||||
None,
|
||||
TopLeft,
|
||||
Left,
|
||||
BottomLeft,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
Right,
|
||||
TopRight,
|
||||
Top
|
||||
}borderTypes;
|
||||
|
||||
public:
|
||||
MainFrame();
|
||||
|
||||
void ShowFormInit();
|
||||
void ShowHelpDocAsync();
|
||||
|
||||
bool IsMaxsized();
|
||||
bool IsNormalsized();
|
||||
bool IsMoving();
|
||||
void SetFormRegion(int x, int y, int w, int h);
|
||||
QRect GetFormRegion();
|
||||
void saveNormalRegion();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
#ifdef _WIN32
|
||||
void showEvent(QShowEvent *event);
|
||||
#endif
|
||||
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||
|
||||
signals:
|
||||
void sig_ParentNativeEvent(int msg);
|
||||
|
||||
public slots:
|
||||
void unfreezing();
|
||||
void show_doc();
|
||||
void setTaskbarProgress(int progress);
|
||||
|
||||
void showNormal();
|
||||
void showMaximized();
|
||||
void showMinimized();
|
||||
void OnParentNaitveWindowEvent(int msg);
|
||||
|
||||
private:
|
||||
void hide_border();
|
||||
void show_border();
|
||||
void writeSettings();
|
||||
void ReadSettings();
|
||||
void AttachNativeWindow();
|
||||
|
||||
//ITitleParent
|
||||
void MoveWindow(int x, int y) override;
|
||||
QPoint GetParentPos() override;
|
||||
bool ParentIsMaxsized() override;
|
||||
void MoveBegin() override;
|
||||
void MoveEnd() override;
|
||||
|
||||
//IParentNativeEventCallback
|
||||
void OnParentNativeEvent(ParentNativeEvent msg) override;
|
||||
|
||||
|
||||
private:
|
||||
toolbars::TitleBar *_titleBar;
|
||||
MainWindow *_mainWindow;
|
||||
|
||||
QGridLayout *_layout;
|
||||
widgets::Border *_left;
|
||||
widgets::Border *_right;
|
||||
widgets::Border *_top;
|
||||
widgets::Border *_bottom;
|
||||
widgets::Border *_top_left;
|
||||
widgets::Border *_top_right;
|
||||
widgets::Border *_bottom_left;
|
||||
widgets::Border *_bottom_right;
|
||||
|
||||
bool _bDraging;
|
||||
int _hit_border;
|
||||
QTimer _timer;
|
||||
bool _freezing;
|
||||
// Taskbar Progress Effert for Win7 and Above
|
||||
#ifdef _WIN32
|
||||
QWinTaskbarButton *_taskBtn;
|
||||
QWinTaskbarProgress *_taskPrg;
|
||||
#endif
|
||||
|
||||
bool _is_win32_parent_window;
|
||||
bool _is_resize_ready;
|
||||
WinNativeWidget *_parentNativeWidget;
|
||||
FormInitInfo _initWndInfo;
|
||||
FormRegion _normalRegion;
|
||||
QPoint _clickPos;
|
||||
QRect _dragStartRegion;
|
||||
QScreen *_move_start_screen;
|
||||
};
|
||||
|
||||
} // namespace pv
|
||||
|
||||
#endif // DSVIEW_PV_MAINFRAME_H
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2016 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DSVIEW_PV_MAINFRAME_H
|
||||
#define DSVIEW_PV_MAINFRAME_H
|
||||
|
||||
#include "widgets/border.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QTimer>
|
||||
#include <QRect>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <QWinTaskbarButton>
|
||||
#include <QWinTaskbarProgress>
|
||||
#endif
|
||||
|
||||
#include "toolbars/titlebar.h"
|
||||
|
||||
namespace pv {
|
||||
|
||||
class MainWindow;
|
||||
class WinNativeWidget;
|
||||
|
||||
namespace dialogs {
|
||||
class DSMessageBox;
|
||||
class DSDialog;
|
||||
}
|
||||
|
||||
struct Point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct FormRegion{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
struct FormInitInfo
|
||||
{
|
||||
FormRegion r;
|
||||
bool isMaxSize;
|
||||
int k;
|
||||
};
|
||||
|
||||
class MainFrame :
|
||||
public QFrame,
|
||||
public ITitleParent,
|
||||
public IParentNativeEventCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const int Margin = 5;
|
||||
|
||||
enum borderTypes{
|
||||
None,
|
||||
TopLeft,
|
||||
Left,
|
||||
BottomLeft,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
Right,
|
||||
TopRight,
|
||||
Top
|
||||
}borderTypes;
|
||||
|
||||
public:
|
||||
MainFrame();
|
||||
|
||||
void ShowFormInit();
|
||||
void ShowHelpDocAsync();
|
||||
|
||||
bool IsMaxsized();
|
||||
bool IsNormalsized();
|
||||
bool IsMoving();
|
||||
void SetFormRegion(int x, int y, int w, int h);
|
||||
QRect GetFormRegion();
|
||||
void saveNormalRegion();
|
||||
QWidget* GetMainWindow();
|
||||
QWidget* GetBodyView();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
#ifdef _WIN32
|
||||
void showEvent(QShowEvent *event);
|
||||
#endif
|
||||
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||
|
||||
signals:
|
||||
void sig_ParentNativeEvent(int msg);
|
||||
|
||||
public slots:
|
||||
void unfreezing();
|
||||
void show_doc();
|
||||
void setTaskbarProgress(int progress);
|
||||
|
||||
void showNormal();
|
||||
void showMaximized();
|
||||
void showMinimized();
|
||||
void OnParentNaitveWindowEvent(int msg);
|
||||
|
||||
private:
|
||||
void hide_border();
|
||||
void show_border();
|
||||
void writeSettings();
|
||||
void ReadSettings();
|
||||
void AttachNativeWindow();
|
||||
|
||||
//ITitleParent
|
||||
void MoveWindow(int x, int y) override;
|
||||
QPoint GetParentPos() override;
|
||||
bool ParentIsMaxsized() override;
|
||||
void MoveBegin() override;
|
||||
void MoveEnd() override;
|
||||
|
||||
//IParentNativeEventCallback
|
||||
void OnParentNativeEvent(ParentNativeEvent msg) override;
|
||||
|
||||
|
||||
private:
|
||||
toolbars::TitleBar *_titleBar;
|
||||
MainWindow *_mainWindow;
|
||||
|
||||
QGridLayout *_layout;
|
||||
widgets::Border *_left;
|
||||
widgets::Border *_right;
|
||||
widgets::Border *_top;
|
||||
widgets::Border *_bottom;
|
||||
widgets::Border *_top_left;
|
||||
widgets::Border *_top_right;
|
||||
widgets::Border *_bottom_left;
|
||||
widgets::Border *_bottom_right;
|
||||
|
||||
bool _bDraging;
|
||||
int _hit_border;
|
||||
QTimer _timer;
|
||||
bool _freezing;
|
||||
// Taskbar Progress Effert for Win7 and Above
|
||||
#ifdef _WIN32
|
||||
QWinTaskbarButton *_taskBtn;
|
||||
QWinTaskbarProgress *_taskPrg;
|
||||
#endif
|
||||
|
||||
bool _is_win32_parent_window;
|
||||
bool _is_resize_ready;
|
||||
WinNativeWidget *_parentNativeWidget;
|
||||
FormInitInfo _initWndInfo;
|
||||
FormRegion _normalRegion;
|
||||
QPoint _clickPos;
|
||||
QRect _dragStartRegion;
|
||||
QScreen *_move_start_screen;
|
||||
};
|
||||
|
||||
} // namespace pv
|
||||
|
||||
#endif // DSVIEW_PV_MAINFRAME_H
|
||||
|
||||
@@ -1407,10 +1407,10 @@ namespace pv
|
||||
qApp->removeTranslator(&_myTrans);
|
||||
retranslateUi();
|
||||
}
|
||||
else
|
||||
{
|
||||
dsv_err("%s%d", "Unknown language code:", language);
|
||||
}
|
||||
|
||||
// QEvent langEvent(QEvent::LanguageChange);
|
||||
// QApplication::sendEvent(QApplication::instance(), &langEvent);
|
||||
// QCoreApplication::sendPostedEvents();
|
||||
}
|
||||
|
||||
void MainWindow::switchTheme(QString style)
|
||||
@@ -2195,5 +2195,10 @@ namespace pv
|
||||
|
||||
_view->update_all_trace_postion();
|
||||
}
|
||||
|
||||
QWidget* MainWindow::GetBodyView()
|
||||
{
|
||||
return _view;
|
||||
}
|
||||
|
||||
} // namespace pv
|
||||
|
||||
@@ -130,9 +130,9 @@ signals:
|
||||
public:
|
||||
//IMainForm
|
||||
void switchLanguage(int language) override;
|
||||
bool able_to_close();
|
||||
|
||||
|
||||
bool able_to_close();
|
||||
QWidget* GetBodyView();
|
||||
|
||||
private:
|
||||
void setup_ui();
|
||||
void retranslateUi();
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "log.h"
|
||||
#include "../config.h"
|
||||
#include "winshadow.h"
|
||||
#include "mainframe.h"
|
||||
|
||||
#define FIXED_WIDTH(widget) (widget->minimumWidth() >= widget->maximumWidth())
|
||||
#define FIXED_HEIGHT(widget) (widget->minimumHeight() >= widget->maximumHeight())
|
||||
@@ -115,7 +116,7 @@ WinNativeWidget::~WinNativeWidget()
|
||||
}
|
||||
}
|
||||
|
||||
void WinNativeWidget::SetChildWidget(QWidget *w)
|
||||
void WinNativeWidget::SetChildWidget(MainFrame *w)
|
||||
{
|
||||
childWidget = w;
|
||||
_childWindow = NULL;
|
||||
@@ -159,7 +160,20 @@ LRESULT CALLBACK WinNativeWidget::WndProc(HWND hWnd, UINT message, WPARAM wParam
|
||||
TrackPopupMenu(GetSystemMenu(hWnd, false), TPM_TOPALIGN | TPM_LEFTALIGN, winrect.left + 5, winrect.top + 5, 0, hWnd, NULL);
|
||||
}
|
||||
break;;
|
||||
}
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
//enable the hot key.
|
||||
QKeyEvent keyEvent(QEvent::KeyPress, (int)wParam, 0);
|
||||
QApplication::sendEvent(self->childWidget->GetBodyView(), &keyEvent);
|
||||
break;
|
||||
}
|
||||
case WM_KEYUP:
|
||||
{
|
||||
QKeyEvent keyEvent(QEvent::KeyRelease, (int)wParam, 0);
|
||||
QApplication::sendEvent(self->childWidget->GetBodyView(), &keyEvent);
|
||||
break;
|
||||
}
|
||||
case WM_NCCALCSIZE:
|
||||
{
|
||||
if (!wParam || self->IsMaxsized()){
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
namespace pv {
|
||||
|
||||
class WinShadow;
|
||||
class MainFrame;
|
||||
|
||||
class WinNativeWidget
|
||||
{
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void SetChildWidget(QWidget *w);
|
||||
void SetChildWidget(MainFrame *w);
|
||||
|
||||
void setGeometry(const int x, const int y, const int width, const int height);
|
||||
|
||||
@@ -106,7 +107,7 @@ private:
|
||||
|
||||
|
||||
private:
|
||||
QWidget* childWidget;
|
||||
MainFrame* childWidget;
|
||||
HWND _childWindow;
|
||||
HWND _hWnd;
|
||||
QWidget *_titleBarWidget;
|
||||
|
||||
Reference in New Issue
Block a user