no message
parent
99ef959c68
commit
4490a55f31
32
Qss.cpp
32
Qss.cpp
|
@ -247,7 +247,6 @@ void QssMainWindow::OnMaxOrRestore(bool max)
|
|||
setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
this->m_frame->setMinimumSize(0, 0);
|
||||
this->m_frame->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
QSize sizeHint = parentWidget()->sizeHint();
|
||||
|
||||
QDesktopWidget desktop;
|
||||
QRect rc = desktop.availableGeometry(-1);
|
||||
|
@ -259,12 +258,23 @@ void QssMainWindow::OnMaxOrRestore(bool max)
|
|||
this->setFixedHeight(rc.height() - m_titleBar->height());
|
||||
}
|
||||
}
|
||||
|
||||
void QssMainWindow::DpiChange(qreal dpi)
|
||||
// 实际测试切换分辨率会触发这个slot
|
||||
void QssMainWindow::PhisycalDpiChange(qreal dpi)
|
||||
{
|
||||
qDebug()<<"change dpi of QssMainWindow"<<dpi;
|
||||
qDebug()<<"dpi changed,reason: configuration "<<dpi;
|
||||
|
||||
}
|
||||
// 实际测试切换分辨率或者修改缩放比率都会触发这个slot
|
||||
void QssMainWindow::LogicalDpiChange(qreal dpi)
|
||||
{
|
||||
qDebug()<<"dpi changed,reason: configuration "<<dpi;
|
||||
m_dpi_ratio = 96/dpi;
|
||||
qDebug()<<"factor is "<<m_dpi_ratio;
|
||||
auto parent = this->parentWidget();
|
||||
parent->setGeometry(parent->geometry().x(),parent->geometry().y(),
|
||||
parent->geometry().width()*m_dpi_ratio,
|
||||
parent->geometry().height()*m_dpi_ratio);
|
||||
}
|
||||
|
||||
|
||||
QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = 0*/,float scale)
|
||||
|
@ -317,7 +327,11 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* =
|
|||
if(nullptr != mCurrentScreen){
|
||||
connect(mCurrentScreen,
|
||||
SIGNAL(physicalDotsPerInchChanged(qreal)),
|
||||
this,SLOT(DpiChange(qreal)));
|
||||
this,SLOT(PhisycalDpiChange(qreal)));
|
||||
|
||||
connect(mCurrentScreen,
|
||||
SIGNAL(logicalDotsPerInchChanged(qreal)),
|
||||
this,SLOT(LogicalDpiChange(qreal)));
|
||||
}
|
||||
rangeObjectList(m_frame,0);
|
||||
return;
|
||||
|
@ -333,6 +347,11 @@ QWidget *QssMainWindow::TitleBar()
|
|||
return m_titleBar;
|
||||
}
|
||||
|
||||
void QssMainWindow::RangeObject()
|
||||
{
|
||||
rangeObjectList(m_frame,0);
|
||||
}
|
||||
|
||||
void QssMainWindow::DetectDpiChange()
|
||||
{
|
||||
int screenNum = qApp->desktop()->screenNumber(this);
|
||||
|
@ -428,7 +447,6 @@ void QssMainWindow::showNormal()
|
|||
|
||||
void QssMainWindow::setWindowTitle( QString title )
|
||||
{
|
||||
//m_frame->setWindowTitle(title);
|
||||
m_titleBar->setTitle(title);
|
||||
}
|
||||
|
||||
|
@ -467,8 +485,6 @@ void QssMainWindow::onMouseMoveEvent(QMouseEvent * ev)
|
|||
setCursorShape(CalCursorPos(ev->pos(),CalCursorCol(ev->pos())));
|
||||
}
|
||||
QPoint ptCurrentPos = QCursor::pos();
|
||||
QPoint ptMoveSize = ptCurrentPos - m_ptViewMousePos;
|
||||
QRect rtTempGeometry = this->geometry();
|
||||
QRect rtCentralGeo = this->centralWidget()->geometry();
|
||||
QRect rtMainWindow = this->geometry();
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
|
19
Qss.h
19
Qss.h
|
@ -26,7 +26,9 @@
|
|||
class QPushButton;
|
||||
class QLabel;
|
||||
class QMouseEvent;
|
||||
|
||||
#define STANDARD_DPI 96.0
|
||||
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02e0
|
||||
#endif
|
||||
|
@ -108,19 +110,7 @@ class QssEventFilter
|
|||
{
|
||||
public:
|
||||
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE
|
||||
{/*
|
||||
MSG* pMsg = reinterpret_cast<MSG*>(message);
|
||||
if(nullptr != pMsg){
|
||||
switch (pMsg->message)
|
||||
{
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
qDebug()<<"DPI CHANGED";
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// TODO: filter out or modify msg struct here
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -131,7 +121,9 @@ class QssMainWindow : public QMainWindow
|
|||
|
||||
public slots:
|
||||
void OnMaxOrRestore(bool max);
|
||||
void DpiChange(qreal);
|
||||
void PhisycalDpiChange(qreal);
|
||||
void LogicalDpiChange(qreal);
|
||||
|
||||
public:
|
||||
typedef enum{
|
||||
EVENT_MOVE = 523,
|
||||
|
@ -140,6 +132,7 @@ public:
|
|||
virtual ~QssMainWindow();
|
||||
|
||||
QWidget *TitleBar();
|
||||
void RangeObject();
|
||||
void DetectDpiChange();
|
||||
void ShowMask();
|
||||
void HideMask();
|
||||
|
|
Loading…
Reference in New Issue