fix: some clazy checks
This commit is contained in:
parent
4d8d98b2ff
commit
6d8f353602
|
@ -131,7 +131,7 @@ SOFTWARE.
|
||||||
|
|
||||||
m_licenseTextEdit->setText(licenseStr.join('\n').arg(qApp->applicationDisplayName(), mitLicense));
|
m_licenseTextEdit->setText(licenseStr.join('\n').arg(qApp->applicationDisplayName(), mitLicense));
|
||||||
|
|
||||||
m_3rdPartyLibsTextEdit->setText(thirdPartyLibsStr.join('\n').arg(QStringLiteral("<i>%1</i>")).arg(qApp->applicationDisplayName()));
|
m_3rdPartyLibsTextEdit->setText(thirdPartyLibsStr.join('\n').arg(QStringLiteral("<i>%1</i>").arg(qApp->applicationDisplayName())));
|
||||||
m_3rdPartyLibsTextEdit->setOpenExternalLinks(true);
|
m_3rdPartyLibsTextEdit->setOpenExternalLinks(true);
|
||||||
|
|
||||||
m_tabWidget->addTab(m_helpTextEdit, tr("&Help"));
|
m_tabWidget->addTab(m_helpTextEdit, tr("&Help"));
|
||||||
|
|
|
@ -21,3 +21,90 @@ void FramelessWindow::setCentralWidget(QWidget *widget)
|
||||||
m_centralLayout->addWidget(widget);
|
m_centralLayout->addWidget(widget);
|
||||||
m_centralWidget = widget;
|
m_centralWidget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FramelessWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
// https://stackoverflow.com/questions/43505580/qt-windows-resizable-frameless-window
|
||||||
|
// Too lazy to do this now.. just stackoverflow it and did a copy and paste..
|
||||||
|
Q_UNUSED(eventType)
|
||||||
|
MSG* msg = static_cast<MSG*>(message);
|
||||||
|
|
||||||
|
if (msg->message == WM_NCHITTEST) {
|
||||||
|
if (isMaximized()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*result = 0;
|
||||||
|
const LONG borderWidth = 8;
|
||||||
|
RECT winrect;
|
||||||
|
GetWindowRect(reinterpret_cast<HWND>(winId()), &winrect);
|
||||||
|
|
||||||
|
// must be short to correctly work with multiple monitors (negative coordinates)
|
||||||
|
short x = msg->lParam & 0x0000FFFF;
|
||||||
|
short y = (msg->lParam & 0xFFFF0000) >> 16;
|
||||||
|
|
||||||
|
bool resizeWidth = minimumWidth() != maximumWidth();
|
||||||
|
bool resizeHeight = minimumHeight() != maximumHeight();
|
||||||
|
if (resizeWidth) {
|
||||||
|
//left border
|
||||||
|
if (x >= winrect.left && x < winrect.left + borderWidth) {
|
||||||
|
*result = HTLEFT;
|
||||||
|
}
|
||||||
|
//right border
|
||||||
|
if (x < winrect.right && x >= winrect.right - borderWidth) {
|
||||||
|
*result = HTRIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resizeHeight) {
|
||||||
|
//bottom border
|
||||||
|
if (y < winrect.bottom && y >= winrect.bottom - borderWidth) {
|
||||||
|
*result = HTBOTTOM;
|
||||||
|
}
|
||||||
|
//top border
|
||||||
|
if (y >= winrect.top && y < winrect.top + borderWidth) {
|
||||||
|
*result = HTTOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resizeWidth && resizeHeight) {
|
||||||
|
//bottom left corner
|
||||||
|
if (x >= winrect.left && x < winrect.left + borderWidth &&
|
||||||
|
y < winrect.bottom && y >= winrect.bottom - borderWidth)
|
||||||
|
{
|
||||||
|
*result = HTBOTTOMLEFT;
|
||||||
|
}
|
||||||
|
//bottom right corner
|
||||||
|
if (x < winrect.right && x >= winrect.right - borderWidth &&
|
||||||
|
y < winrect.bottom && y >= winrect.bottom - borderWidth)
|
||||||
|
{
|
||||||
|
*result = HTBOTTOMRIGHT;
|
||||||
|
}
|
||||||
|
//top left corner
|
||||||
|
if (x >= winrect.left && x < winrect.left + borderWidth &&
|
||||||
|
y >= winrect.top && y < winrect.top + borderWidth)
|
||||||
|
{
|
||||||
|
*result = HTTOPLEFT;
|
||||||
|
}
|
||||||
|
//top right corner
|
||||||
|
if (x < winrect.right && x >= winrect.right - borderWidth &&
|
||||||
|
y >= winrect.top && y < winrect.top + borderWidth)
|
||||||
|
{
|
||||||
|
*result = HTTOPRIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*result != 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QWidget *action = QApplication::widgetAt(QCursor::pos());
|
||||||
|
if (action == this) {
|
||||||
|
*result = HTCAPTION;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return QWidget::nativeEvent(eventType, message, result);
|
||||||
|
#endif // _WIN32
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ public:
|
||||||
|
|
||||||
void setCentralWidget(QWidget * widget);
|
void setCentralWidget(QWidget * widget);
|
||||||
|
|
||||||
signals:
|
protected:
|
||||||
|
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout * m_centralLayout = nullptr;
|
QVBoxLayout * m_centralLayout = nullptr;
|
||||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
QStringList urlStrList = parser.positionalArguments();
|
QStringList urlStrList = parser.positionalArguments();
|
||||||
QList<QUrl> urlList;
|
QList<QUrl> urlList;
|
||||||
for (const QString & str : urlStrList) {
|
for (const QString & str : qAsConst(urlStrList)) {
|
||||||
QUrl url = QUrl::fromLocalFile(str);
|
QUrl url = QUrl::fromLocalFile(str);
|
||||||
if (url.isValid()) {
|
if (url.isValid()) {
|
||||||
urlList.append(url);
|
urlList.append(url);
|
||||||
|
|
|
@ -515,98 +515,6 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
return FramelessWindow::contextMenuEvent(event);
|
return FramelessWindow::contextMenuEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
// https://stackoverflow.com/questions/43505580/qt-windows-resizable-frameless-window
|
|
||||||
// Too lazy to do this now.. just stackoverflow it and did a copy and paste..
|
|
||||||
Q_UNUSED(eventType)
|
|
||||||
MSG* msg = static_cast<MSG*>(message);
|
|
||||||
|
|
||||||
if (msg->message == WM_NCHITTEST) {
|
|
||||||
if (isMaximized()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*result = 0;
|
|
||||||
const LONG borderWidth = 8;
|
|
||||||
RECT winrect;
|
|
||||||
GetWindowRect(reinterpret_cast<HWND>(winId()), &winrect);
|
|
||||||
|
|
||||||
// must be short to correctly work with multiple monitors (negative coordinates)
|
|
||||||
short x = msg->lParam & 0x0000FFFF;
|
|
||||||
short y = (msg->lParam & 0xFFFF0000) >> 16;
|
|
||||||
|
|
||||||
bool resizeWidth = minimumWidth() != maximumWidth();
|
|
||||||
bool resizeHeight = minimumHeight() != maximumHeight();
|
|
||||||
if (resizeWidth) {
|
|
||||||
//left border
|
|
||||||
if (x >= winrect.left && x < winrect.left + borderWidth) {
|
|
||||||
*result = HTLEFT;
|
|
||||||
}
|
|
||||||
//right border
|
|
||||||
if (x < winrect.right && x >= winrect.right - borderWidth) {
|
|
||||||
*result = HTRIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resizeHeight) {
|
|
||||||
//bottom border
|
|
||||||
if (y < winrect.bottom && y >= winrect.bottom - borderWidth) {
|
|
||||||
*result = HTBOTTOM;
|
|
||||||
}
|
|
||||||
//top border
|
|
||||||
if (y >= winrect.top && y < winrect.top + borderWidth) {
|
|
||||||
*result = HTTOP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resizeWidth && resizeHeight) {
|
|
||||||
//bottom left corner
|
|
||||||
if (x >= winrect.left && x < winrect.left + borderWidth &&
|
|
||||||
y < winrect.bottom && y >= winrect.bottom - borderWidth)
|
|
||||||
{
|
|
||||||
*result = HTBOTTOMLEFT;
|
|
||||||
}
|
|
||||||
//bottom right corner
|
|
||||||
if (x < winrect.right && x >= winrect.right - borderWidth &&
|
|
||||||
y < winrect.bottom && y >= winrect.bottom - borderWidth)
|
|
||||||
{
|
|
||||||
*result = HTBOTTOMRIGHT;
|
|
||||||
}
|
|
||||||
//top left corner
|
|
||||||
if (x >= winrect.left && x < winrect.left + borderWidth &&
|
|
||||||
y >= winrect.top && y < winrect.top + borderWidth)
|
|
||||||
{
|
|
||||||
*result = HTTOPLEFT;
|
|
||||||
}
|
|
||||||
//top right corner
|
|
||||||
if (x < winrect.right && x >= winrect.right - borderWidth &&
|
|
||||||
y >= winrect.top && y < winrect.top + borderWidth)
|
|
||||||
{
|
|
||||||
*result = HTTOPRIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*result != 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
QWidget *action = QApplication::widgetAt(QCursor::pos());
|
|
||||||
if (action == this) {
|
|
||||||
*result = HTCAPTION;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return FramelessWindow::nativeEvent(eventType, message, result);
|
|
||||||
#endif // _WIN32
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize MainWindow::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(710, 530);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::centerWindow()
|
void MainWindow::centerWindow()
|
||||||
{
|
{
|
||||||
this->setGeometry(
|
this->setGeometry(
|
||||||
|
@ -683,3 +591,8 @@ void MainWindow::toggleMaximize()
|
||||||
showMaximized();
|
showMaximized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize MainWindow::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(710, 530);
|
||||||
|
}
|
||||||
|
|
|
@ -49,10 +49,6 @@ protected slots:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void contextMenuEvent(QContextMenuEvent *event) override;
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
|
|
||||||
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
|
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
void centerWindow();
|
void centerWindow();
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
void updateWidgetsPosition();
|
void updateWidgetsPosition();
|
||||||
|
@ -63,6 +59,9 @@ protected slots:
|
||||||
void toggleFullscreen();
|
void toggleFullscreen();
|
||||||
void toggleMaximize();
|
void toggleMaximize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint m_oldMousePos;
|
QPoint m_oldMousePos;
|
||||||
QPropertyAnimation *m_fadeOutAnimation;
|
QPropertyAnimation *m_fadeOutAnimation;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user