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
|
set (PPIC_CPP_FILES
|
||||||
app/main.cpp
|
app/main.cpp
|
||||||
app/framelesswindow.cpp
|
|
||||||
app/mainwindow.cpp
|
app/mainwindow.cpp
|
||||||
app/actionmanager.cpp
|
app/actionmanager.cpp
|
||||||
app/graphicsview.cpp
|
app/graphicsview.cpp
|
||||||
@@ -57,7 +56,6 @@ set (PPIC_CPP_FILES
|
|||||||
)
|
)
|
||||||
|
|
||||||
set (PPIC_HEADER_FILES
|
set (PPIC_HEADER_FILES
|
||||||
app/framelesswindow.h
|
|
||||||
app/mainwindow.h
|
app/mainwindow.h
|
||||||
app/actionmanager.h
|
app/actionmanager.h
|
||||||
app/graphicsview.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 <QProcess>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#ifdef HAVE_QTDBUS
|
#ifdef HAVE_QTDBUS
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
@@ -46,11 +47,17 @@
|
|||||||
using namespace Qt::Literals::StringLiterals;
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: FramelessWindow(parent)
|
: QWidget(parent)
|
||||||
, m_am(new ActionManager)
|
, m_am(new ActionManager)
|
||||||
, m_pm(new PlaylistManager(this))
|
, m_pm(new PlaylistManager(this))
|
||||||
, m_fileSystemWatcher(new QFileSystemWatcher(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:
|
// YYC MARK:
|
||||||
// Blumis set original value is 350 x 330.
|
// Blumis set original value is 350 x 330.
|
||||||
// It is too small for modern device,
|
// It is too small for modern device,
|
||||||
@@ -65,7 +72,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
m_gv = new GraphicsView(this);
|
m_gv = new GraphicsView(this);
|
||||||
m_gv->setScene(scene);
|
m_gv->setScene(scene);
|
||||||
this->setCentralWidget(m_gv);
|
m_centralLayout->addWidget(m_gv);
|
||||||
|
|
||||||
m_nav = new NavigatorView(this);
|
m_nav = new NavigatorView(this);
|
||||||
// YYC MARK:
|
// YYC MARK:
|
||||||
@@ -299,7 +306,7 @@ void MainWindow::showEvent(QShowEvent *event)
|
|||||||
{
|
{
|
||||||
updateWidgetsPosition();
|
updateWidgetsPosition();
|
||||||
|
|
||||||
return FramelessWindow::showEvent(event);
|
return QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
@@ -364,7 +371,7 @@ void MainWindow::wheelEvent(QWheelEvent *event)
|
|||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
} else {
|
} else {
|
||||||
FramelessWindow::wheelEvent(event);
|
QWidget::wheelEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,14 +379,14 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|||||||
{
|
{
|
||||||
updateWidgetsPosition();
|
updateWidgetsPosition();
|
||||||
|
|
||||||
return FramelessWindow::resizeEvent(event);
|
return QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
m_menu->exec(mapToGlobal(event->pos()));
|
m_menu->exec(mapToGlobal(event->pos()));
|
||||||
|
|
||||||
return FramelessWindow::contextMenuEvent(event);
|
return QWidget::contextMenuEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||||
@@ -390,7 +397,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FramelessWindow::dragEnterEvent(event);
|
return QWidget::dragEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dragMoveEvent(QDragMoveEvent *event)
|
void MainWindow::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
|||||||
@@ -5,14 +5,13 @@
|
|||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "framelesswindow.h"
|
|
||||||
|
|
||||||
#include <QParallelAnimationGroup>
|
#include <QParallelAnimationGroup>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QMenu;
|
class QMenu;
|
||||||
|
class QVBoxLayout;
|
||||||
class QGraphicsView;
|
class QGraphicsView;
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -22,7 +21,7 @@ class PlaylistManager;
|
|||||||
class GraphicsView;
|
class GraphicsView;
|
||||||
class NavigatorView;
|
class NavigatorView;
|
||||||
class BottomButtonGroup;
|
class BottomButtonGroup;
|
||||||
class MainWindow : public FramelessWindow
|
class MainWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -104,6 +103,7 @@ private:
|
|||||||
NavigatorView *m_nav;
|
NavigatorView *m_nav;
|
||||||
|
|
||||||
QMenu *m_menu;
|
QMenu *m_menu;
|
||||||
|
QVBoxLayout * m_centralLayout = nullptr;
|
||||||
QFileSystemWatcher *m_fileSystemWatcher;
|
QFileSystemWatcher *m_fileSystemWatcher;
|
||||||
BottomButtonGroup *m_bottomButtonGroup;
|
BottomButtonGroup *m_bottomButtonGroup;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user