|
|
|
@ -1,24 +1,30 @@
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
|
|
#include <QWKWidgets/qwkwidgetsglobal.h>
|
|
|
|
|
#include <QWKWidgets/widgetwindowagent.h>
|
|
|
|
|
// #include <QWKWidgets/qwkwidgetsglobal.h>
|
|
|
|
|
// #include <QWKWidgets/widgetwindowagent.h>
|
|
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QtGui/QPainter>
|
|
|
|
|
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
#include "widgetframe/windowbar.h"
|
|
|
|
|
#include "widgetframe/windowbutton.h"
|
|
|
|
|
// #include "widgetframe/windowbar.h"
|
|
|
|
|
// #include "widgetframe/windowbutton.h"
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
|
#include <QtGui/QActionGroup>
|
|
|
|
|
#else
|
|
|
|
|
#include <QtWidgets/QActionGroup>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget* parent)
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
this->setWindowTitle("载荷视频播放软件");
|
|
|
|
|
// windowAgent = new QWK::WidgetWindowAgent(this);
|
|
|
|
|
// windowAgent->setup(this);
|
|
|
|
|
// auto windowBar = new QWK::WindowBar();
|
|
|
|
|
// auto iconButton = new QWK::WindowButton();
|
|
|
|
|
/*
|
|
|
|
|
auto windowAgent = new QWK::WidgetWindowAgent(this);
|
|
|
|
|
windowAgent->setup(this);
|
|
|
|
|
auto windowBar = new QWK::WindowBar();
|
|
|
|
|
auto iconButton = new QWK::WindowButton();
|
|
|
|
|
iconButton->setObjectName(QStringLiteral("icon-button"));
|
|
|
|
|
iconButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
|
@ -43,8 +49,9 @@ MainWindow::MainWindow(QWidget* parent)
|
|
|
|
|
windowBar->setMaxButton(maxButton);
|
|
|
|
|
windowBar->setCloseButton(closeButton);
|
|
|
|
|
windowAgent->setTitleBar(windowBar);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
setMenuWidget(windowBar);
|
|
|
|
|
// windowAgent->setHitTestVisible(windowBar->menuBar(), true);
|
|
|
|
|
*/
|
|
|
|
|
// apply the qss
|
|
|
|
|
QFile qssfile(":/Qss/qss.qss");
|
|
|
|
|
if (qssfile.open(QFile::ReadOnly)) {
|
|
|
|
@ -115,3 +122,198 @@ void MainWindow::showMessageSlots(QString message, int type) {
|
|
|
|
|
m_notifyManager->notify(message, "", type, 3000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
void MainWindow::installWindowAgent() {
|
|
|
|
|
// 1. Setup window agent
|
|
|
|
|
windowAgent = new QWK::WidgetWindowAgent(this);
|
|
|
|
|
windowAgent->setup(this);
|
|
|
|
|
|
|
|
|
|
// 2. Construct your title bar
|
|
|
|
|
auto menuBar = [this]() {
|
|
|
|
|
auto menuBar = new QMenuBar(this);
|
|
|
|
|
|
|
|
|
|
// Virtual menu
|
|
|
|
|
auto file = new QMenu(tr("File(&F)"), menuBar);
|
|
|
|
|
file->addAction(new QAction(tr("New(&N)"), menuBar));
|
|
|
|
|
file->addAction(new QAction(tr("Open(&O)"), menuBar));
|
|
|
|
|
file->addSeparator();
|
|
|
|
|
|
|
|
|
|
auto edit = new QMenu(tr("Edit(&E)"), menuBar);
|
|
|
|
|
edit->addAction(new QAction(tr("Undo(&U)"), menuBar));
|
|
|
|
|
edit->addAction(new QAction(tr("Redo(&R)"), menuBar));
|
|
|
|
|
|
|
|
|
|
// Theme action
|
|
|
|
|
auto darkAction = new QAction(tr("Enable dark theme"), menuBar);
|
|
|
|
|
darkAction->setCheckable(true);
|
|
|
|
|
// connect(darkAction, &QAction::triggered, this, [this](bool checked) {
|
|
|
|
|
// loadStyleSheet(checked ? Dark : Light); //
|
|
|
|
|
// });
|
|
|
|
|
// connect(this, &MainWindow::themeChanged, darkAction,
|
|
|
|
|
// [this, darkAction]() {
|
|
|
|
|
// darkAction->setChecked(currentTheme == Dark); //
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
auto noneAction = new QAction(tr("None"), menuBar);
|
|
|
|
|
noneAction->setData(QStringLiteral("none"));
|
|
|
|
|
noneAction->setCheckable(true);
|
|
|
|
|
noneAction->setChecked(true);
|
|
|
|
|
|
|
|
|
|
auto dwmBlurAction = new QAction(tr("Enable DWM blur"), menuBar);
|
|
|
|
|
dwmBlurAction->setData(QStringLiteral("dwm-blur"));
|
|
|
|
|
dwmBlurAction->setCheckable(true);
|
|
|
|
|
|
|
|
|
|
auto acrylicAction =
|
|
|
|
|
new QAction(tr("Enable acrylic material"), menuBar);
|
|
|
|
|
acrylicAction->setData(QStringLiteral("acrylic-material"));
|
|
|
|
|
acrylicAction->setCheckable(true);
|
|
|
|
|
|
|
|
|
|
auto micaAction = new QAction(tr("Enable mica"), menuBar);
|
|
|
|
|
micaAction->setData(QStringLiteral("mica"));
|
|
|
|
|
micaAction->setCheckable(true);
|
|
|
|
|
|
|
|
|
|
auto micaAltAction = new QAction(tr("Enable mica alt"), menuBar);
|
|
|
|
|
micaAltAction->setData(QStringLiteral("mica-alt"));
|
|
|
|
|
micaAltAction->setCheckable(true);
|
|
|
|
|
|
|
|
|
|
auto winStyleGroup = new QActionGroup(menuBar);
|
|
|
|
|
winStyleGroup->addAction(noneAction);
|
|
|
|
|
winStyleGroup->addAction(dwmBlurAction);
|
|
|
|
|
winStyleGroup->addAction(acrylicAction);
|
|
|
|
|
winStyleGroup->addAction(micaAction);
|
|
|
|
|
winStyleGroup->addAction(micaAltAction);
|
|
|
|
|
// connect(winStyleGroup, &QActionGroup::triggered, this,
|
|
|
|
|
// [this, winStyleGroup](QAction *action) {
|
|
|
|
|
// // Unset all custom style attributes first, otherwise the
|
|
|
|
|
// // style will not display correctly
|
|
|
|
|
// for (const QAction *_act : winStyleGroup->actions()) {
|
|
|
|
|
// const QString data = _act->data().toString();
|
|
|
|
|
// if (data.isEmpty() || data == QStringLiteral("none"))
|
|
|
|
|
// {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// windowAgent->setWindowAttribute(data, false);
|
|
|
|
|
// }
|
|
|
|
|
// const QString data = action->data().toString();
|
|
|
|
|
// if (data == QStringLiteral("none")) {
|
|
|
|
|
// setProperty("custom-style", false);
|
|
|
|
|
// } else if (!data.isEmpty()) {
|
|
|
|
|
// windowAgent->setWindowAttribute(data, true);
|
|
|
|
|
// setProperty("custom-style", true);
|
|
|
|
|
// }
|
|
|
|
|
// style()->polish(this);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// Real menu
|
|
|
|
|
auto settings = new QMenu(tr("Settings(&S)"), menuBar);
|
|
|
|
|
settings->addAction(darkAction);
|
|
|
|
|
|
|
|
|
|
settings->addSeparator();
|
|
|
|
|
settings->addAction(noneAction);
|
|
|
|
|
settings->addAction(dwmBlurAction);
|
|
|
|
|
settings->addAction(acrylicAction);
|
|
|
|
|
settings->addAction(micaAction);
|
|
|
|
|
settings->addAction(micaAltAction);
|
|
|
|
|
|
|
|
|
|
menuBar->addMenu(file);
|
|
|
|
|
menuBar->addMenu(edit);
|
|
|
|
|
menuBar->addMenu(settings);
|
|
|
|
|
return menuBar;
|
|
|
|
|
}();
|
|
|
|
|
menuBar->setObjectName(QStringLiteral("win-menu-bar"));
|
|
|
|
|
|
|
|
|
|
auto titleLabel = new QLabel();
|
|
|
|
|
titleLabel->setAlignment(Qt::AlignCenter);
|
|
|
|
|
titleLabel->setObjectName(QStringLiteral("win-title-label"));
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
|
auto iconButton = new QWK::WindowButton();
|
|
|
|
|
iconButton->setObjectName(QStringLiteral("icon-button"));
|
|
|
|
|
iconButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
|
|
auto pinButton = new QWK::WindowButton();
|
|
|
|
|
pinButton->setCheckable(true);
|
|
|
|
|
pinButton->setObjectName(QStringLiteral("pin-button"));
|
|
|
|
|
pinButton->setProperty("system-button", true);
|
|
|
|
|
pinButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
|
|
auto minButton = new QWK::WindowButton();
|
|
|
|
|
minButton->setObjectName(QStringLiteral("min-button"));
|
|
|
|
|
minButton->setProperty("system-button", true);
|
|
|
|
|
minButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
|
|
auto maxButton = new QWK::WindowButton();
|
|
|
|
|
maxButton->setCheckable(true);
|
|
|
|
|
maxButton->setObjectName(QStringLiteral("max-button"));
|
|
|
|
|
maxButton->setProperty("system-button", true);
|
|
|
|
|
maxButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
|
|
auto closeButton = new QWK::WindowButton();
|
|
|
|
|
closeButton->setObjectName(QStringLiteral("close-button"));
|
|
|
|
|
closeButton->setProperty("system-button", true);
|
|
|
|
|
closeButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
auto windowBar = new QWK::WindowBar();
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
|
windowBar->setIconButton(iconButton);
|
|
|
|
|
windowBar->setPinButton(pinButton);
|
|
|
|
|
windowBar->setMinButton(minButton);
|
|
|
|
|
windowBar->setMaxButton(maxButton);
|
|
|
|
|
windowBar->setCloseButton(closeButton);
|
|
|
|
|
#endif
|
|
|
|
|
windowBar->setMenuBar(menuBar);
|
|
|
|
|
windowBar->setTitleLabel(titleLabel);
|
|
|
|
|
windowBar->setHostWidget(this);
|
|
|
|
|
|
|
|
|
|
windowAgent->setTitleBar(windowBar);
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
|
windowAgent->setHitTestVisible(pinButton, true);
|
|
|
|
|
windowAgent->setSystemButton(QWK::WindowAgentBase::WindowIcon, iconButton);
|
|
|
|
|
windowAgent->setSystemButton(QWK::WindowAgentBase::Minimize, minButton);
|
|
|
|
|
windowAgent->setSystemButton(QWK::WindowAgentBase::Maximize, maxButton);
|
|
|
|
|
windowAgent->setSystemButton(QWK::WindowAgentBase::Close, closeButton);
|
|
|
|
|
#endif
|
|
|
|
|
windowAgent->setHitTestVisible(menuBar, true);
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
windowAgent->setSystemButtonAreaCallback([](const QSize &size) {
|
|
|
|
|
static constexpr const int width = 75;
|
|
|
|
|
return QRect(QPoint(size.width() - width, 0),
|
|
|
|
|
QSize(width, size.height())); //
|
|
|
|
|
});
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
setMenuWidget(windowBar);
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
|
connect(windowBar, &QWK::WindowBar::pinRequested, this,
|
|
|
|
|
[this, pinButton](bool pin) {
|
|
|
|
|
if (isHidden() || isMinimized() || isMaximized() ||
|
|
|
|
|
isFullScreen()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setWindowFlag(Qt::WindowStaysOnTopHint, pin);
|
|
|
|
|
show();
|
|
|
|
|
pinButton->setChecked(pin);
|
|
|
|
|
});
|
|
|
|
|
connect(windowBar, &QWK::WindowBar::minimizeRequested, this,
|
|
|
|
|
&QWidget::showMinimized);
|
|
|
|
|
connect(windowBar, &QWK::WindowBar::maximizeRequested, this,
|
|
|
|
|
[this, maxButton](bool max) {
|
|
|
|
|
if (max) {
|
|
|
|
|
showMaximized();
|
|
|
|
|
} else {
|
|
|
|
|
showNormal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// It's a Qt issue that if a QAbstractButton::clicked triggers a
|
|
|
|
|
// window's maximization, the button remains to be hovered until
|
|
|
|
|
// the mouse move. As a result, we need to manually send leave
|
|
|
|
|
// events to the button.
|
|
|
|
|
// emulateLeaveEvent(maxButton);
|
|
|
|
|
});
|
|
|
|
|
connect(windowBar, &QWK::WindowBar::closeRequested, this, &QWidget::close);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|