refactor: remove frameless window
remove frameless window and merge it into mainwindow. because we do not need frameless and transparent window, so most of its functions are removed in previous commits.
This commit is contained in:
@@ -39,7 +39,6 @@ endif ()
|
||||
|
||||
set (PPIC_CPP_FILES
|
||||
app/main.cpp
|
||||
app/framelesswindow.cpp
|
||||
app/mainwindow.cpp
|
||||
app/actionmanager.cpp
|
||||
app/graphicsview.cpp
|
||||
@@ -57,7 +56,6 @@ set (PPIC_CPP_FILES
|
||||
)
|
||||
|
||||
set (PPIC_HEADER_FILES
|
||||
app/framelesswindow.h
|
||||
app/mainwindow.h
|
||||
app/actionmanager.h
|
||||
app/graphicsview.h
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2023 Tad Young <yyc12321@outlook.com>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "framelesswindow.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QHoverEvent>
|
||||
#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWindow>
|
||||
|
||||
FramelessWindow::FramelessWindow(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_centralLayout(new QVBoxLayout(this))
|
||||
{
|
||||
this->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
|
||||
|
||||
// YYC MARK:
|
||||
// 72 px is the height of Windows Photo Viewer's bottom line.
|
||||
|
||||
// TODO: This value may be declared as a constant.
|
||||
m_centralLayout->setContentsMargins(QMargins(0, 0, 0, 72));
|
||||
}
|
||||
|
||||
void FramelessWindow::setCentralWidget(QWidget *widget)
|
||||
{
|
||||
if (m_centralWidget) {
|
||||
m_centralLayout->removeWidget(m_centralWidget);
|
||||
m_centralWidget->deleteLater();
|
||||
}
|
||||
|
||||
m_centralLayout->addWidget(widget);
|
||||
m_centralWidget = widget;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef FRAMELESSWINDOW_H
|
||||
#define FRAMELESSWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class FramelessWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FramelessWindow(QWidget *parent = nullptr);
|
||||
|
||||
void setCentralWidget(QWidget * widget);
|
||||
|
||||
private:
|
||||
QVBoxLayout * m_centralLayout = nullptr;
|
||||
QWidget * m_centralWidget = nullptr; // just a pointer, doesn't take the ownership.
|
||||
};
|
||||
|
||||
#endif // FRAMELESSWINDOW_H
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QProcess>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#ifdef HAVE_QTDBUS
|
||||
#include <QDBusInterface>
|
||||
@@ -46,11 +47,17 @@
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: FramelessWindow(parent)
|
||||
: QWidget(parent)
|
||||
, m_am(new ActionManager)
|
||||
, m_pm(new PlaylistManager(this))
|
||||
, m_fileSystemWatcher(new QFileSystemWatcher(this))
|
||||
{
|
||||
this->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
|
||||
m_centralLayout = new QVBoxLayout(this);
|
||||
// YYC MARK:
|
||||
// 72 px is the height of Windows Photo Viewer's bottom line.
|
||||
m_centralLayout->setContentsMargins(QMargins(0, 0, 0, 72)); // TODO: This value may be declared as a constant.
|
||||
|
||||
// YYC MARK:
|
||||
// Blumis set original value is 350 x 330.
|
||||
// It is too small for modern device,
|
||||
@@ -65,7 +72,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
m_gv = new GraphicsView(this);
|
||||
m_gv->setScene(scene);
|
||||
this->setCentralWidget(m_gv);
|
||||
m_centralLayout->addWidget(m_gv);
|
||||
|
||||
m_nav = new NavigatorView(this);
|
||||
// YYC MARK:
|
||||
@@ -299,7 +306,7 @@ void MainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
updateWidgetsPosition();
|
||||
|
||||
return FramelessWindow::showEvent(event);
|
||||
return QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
@@ -364,7 +371,7 @@ void MainWindow::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
event->accept();
|
||||
} else {
|
||||
FramelessWindow::wheelEvent(event);
|
||||
QWidget::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,14 +379,14 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
updateWidgetsPosition();
|
||||
|
||||
return FramelessWindow::resizeEvent(event);
|
||||
return QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
m_menu->exec(mapToGlobal(event->pos()));
|
||||
|
||||
return FramelessWindow::contextMenuEvent(event);
|
||||
return QWidget::contextMenuEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
@@ -390,7 +397,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
return FramelessWindow::dragEnterEvent(event);
|
||||
return QWidget::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::dragMoveEvent(QDragMoveEvent *event)
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "framelesswindow.h"
|
||||
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QPushButton>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMenu;
|
||||
class QVBoxLayout;
|
||||
class QGraphicsView;
|
||||
class QFileSystemWatcher;
|
||||
QT_END_NAMESPACE
|
||||
@@ -22,7 +21,7 @@ class PlaylistManager;
|
||||
class GraphicsView;
|
||||
class NavigatorView;
|
||||
class BottomButtonGroup;
|
||||
class MainWindow : public FramelessWindow
|
||||
class MainWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -104,6 +103,7 @@ private:
|
||||
NavigatorView *m_nav;
|
||||
|
||||
QMenu *m_menu;
|
||||
QVBoxLayout * m_centralLayout = nullptr;
|
||||
QFileSystemWatcher *m_fileSystemWatcher;
|
||||
BottomButtonGroup *m_bottomButtonGroup;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user