Compare commits
2
Commits
7e8fd4ea21
...
a01d640c27
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a01d640c27 | ||
|
|
16800df138 |
@@ -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
|
||||
+15
-23
@@ -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,17 +306,7 @@ void MainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
updateWidgetsPosition();
|
||||
|
||||
return FramelessWindow::showEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::enterEvent(QEnterEvent *event)
|
||||
{
|
||||
return FramelessWindow::enterEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::leaveEvent(QEvent *event)
|
||||
{
|
||||
return FramelessWindow::leaveEvent(event);
|
||||
return QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
@@ -322,7 +319,7 @@ void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
switch (Settings::instance()->doubleClickBehavior()) {
|
||||
case Settings::DoubleClickBehavior::Close:
|
||||
quitAppAction();
|
||||
closeWindow();
|
||||
event->accept();
|
||||
break;
|
||||
case Settings::DoubleClickBehavior::Maximize:
|
||||
@@ -374,7 +371,7 @@ void MainWindow::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
event->accept();
|
||||
} else {
|
||||
FramelessWindow::wheelEvent(event);
|
||||
QWidget::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,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)
|
||||
@@ -400,7 +397,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
return FramelessWindow::dragEnterEvent(event);
|
||||
return QWidget::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::dragMoveEvent(QDragMoveEvent *event)
|
||||
@@ -448,11 +445,6 @@ void MainWindow::toggleAvoidResetTransform()
|
||||
m_gv->setAvoidResetTransform(!m_gv->isAvoidResetTransform());
|
||||
}
|
||||
|
||||
void MainWindow::quitAppAction(bool force)
|
||||
{
|
||||
closeWindow();
|
||||
}
|
||||
|
||||
void MainWindow::toggleFullscreen()
|
||||
{
|
||||
if (isFullScreen()) {
|
||||
|
||||
+3
-6
@@ -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
|
||||
|
||||
@@ -44,8 +43,6 @@ public:
|
||||
|
||||
protected slots:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void enterEvent(QEnterEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
@@ -58,7 +55,6 @@ protected slots:
|
||||
void closeWindow();
|
||||
void updateWidgetsPosition();
|
||||
void toggleAvoidResetTransform();
|
||||
void quitAppAction(bool force = false);
|
||||
void toggleFullscreen();
|
||||
void toggleMaximize();
|
||||
|
||||
@@ -107,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