8#include <QLoggingCategory>
11#include "RabbitCommonDir.h"
12#include "RabbitCommonTools.h"
13#include "FrmFullScreenToolBar.h"
14#include "ui_FrmFullScreenToolBar.h"
15#include "ui_mainwindow.h"
17static Q_LOGGING_CATEGORY(log,
"App.MainWindow.FullScreen")
23 m_pOperateMenu(
nullptr),
32 setAttribute(Qt::WA_DeleteOnClose);
33 setAttribute(Qt::WA_ShowWithoutActivating);
34 setAutoFillBackground(
true);
35 setAttribute(Qt::WA_TranslucentBackground,
false);
37 Qt::WindowFlags flags;
38 flags = Qt::WindowStaysOnTopHint
40 | Qt::X11BypassWindowManagerHint
42 | Qt::FramelessWindowHint
43 | Qt::CustomizeWindowHint;
44 if(-1 == QGuiApplication::platformName().indexOf(QRegularExpression(
"wayland.*"))) {
47 setWindowFlags(flags);
51 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure());
52 m_ToolBar.addSeparator();
53 m_pNail = m_ToolBar.addAction(QIcon::fromTheme(
"nail"), tr(
"Nail"),
54 this, SLOT(slotNail()));
55 m_pNail->setCheckable(
true);
56 m_pNail->setChecked(set.value(
"FullScreen/Nail",
true).toBool());
57 m_pNail->setToolTip(tr(
"Nail"));
58 m_pNail->setStatusTip(tr(
"Nail"));
59 m_ToolBar.addSeparator();
60 m_ToolBar.addAction(m_pMain->ui->actionFull_screen_F);
62 m_ToolBar.addSeparator();
63 if(m_pMain->m_pActionOperateMenu) {
64 m_pOperateMenu = m_pMain->m_pActionOperateMenu;
65 m_ToolBar.addAction(m_pOperateMenu);
68 m_ToolBar.addAction(m_pMain->ui->actionStop);
69 m_ToolBar.addSeparator();
70 m_ToolBar.addAction(m_pMain->ui->actionExit_E);
74 check = connect(&m_Timer, SIGNAL(timeout()),
75 this, SLOT(slotTimeOut()));
78 m_Timer.start(m_TimeOut);
82CFrmFullScreenToolBar::~CFrmFullScreenToolBar()
84 qDebug(log) <<
"CFrmFullScreenToolBar::~CFrmFullScreenToolBar()";
90void CFrmFullScreenToolBar::mouseMoveEvent(QMouseEvent *event)
92 if(Qt::LeftButton != event->buttons())
95 QPointF p =
event->pos();
96 move(x() + (p.x() - m_Pos.x()), y() + (p.y() - m_Pos.y()));
99void CFrmFullScreenToolBar::mousePressEvent(QMouseEvent *event)
101 m_Pos =
event->pos();
104int CFrmFullScreenToolBar::ReToolBarSize()
106 QPalette palette = this->palette();
107 palette.setColor(QPalette::Window,
108 m_pMain->palette().color(QPalette::Window));
109 this->setPalette(palette);
111 int marginW = style()->pixelMetric(
112 QStyle::PM_FocusFrameHMargin) << 1;
113 int marginH = style()->pixelMetric(
114 QStyle::PM_FocusFrameVMargin) << 1;
115 QMargins cm = contentsMargins();
117 QSize size = m_ToolBar.frameSize();
119 resize(marginW + cm.left() + cm.right() + size.width(),
120 marginH + cm.top() + cm.bottom() + size.height());
122 if(frameGeometry().top() > m_pMain->frameGeometry().height() >> 1)
123 move(frameGeometry().left(),
124 m_pMain->frameGeometry().height() - frameGeometry().height());
127 qDebug(log) << Q_FUNC_INFO <<
"frameGeometry:" << frameGeometry()
128 <<
"main window frameGeometry:" << m_pMain->frameGeometry();
133void CFrmFullScreenToolBar::slotTimeOut()
138 if(m_pNail->isChecked())
return;
140 QPalette palette = this->palette();
141 palette.setColor(QPalette::Window,
142 RabbitCommon::CTools::InvertColor(palette.color(QPalette::Window)));
143 this->setPalette(palette);
148 resize(width(), area);
150 int h = m_pMain->frameGeometry().height() >> 1;
151 if(frameGeometry().top() < h)
152 move(frameGeometry().left(), 0);
154 move(frameGeometry().left(), m_pMain->frameGeometry().height() - area);
157 qDebug(log) << Q_FUNC_INFO <<
"frameGeometry:" << frameGeometry()
158 <<
"main window frameGeometry:" << m_pMain->frameGeometry();
161#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
162void CFrmFullScreenToolBar::enterEvent(QEnterEvent *event)
164void CFrmFullScreenToolBar::enterEvent(QEvent *event)
177void CFrmFullScreenToolBar::leaveEvent(QEvent *event)
180 if(m_pNail->isChecked())
return;
182 m_Timer.start(m_TimeOut);
185void CFrmFullScreenToolBar::slotNail()
187 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure());
188 set.setValue(
"FullScreen/Nail", m_pNail->isChecked());
191void CFrmFullScreenToolBar::slotOperateMenuChanged(QAction* pAction)
194 m_ToolBar.removeAction(m_pOperateMenu);
195 m_pOperateMenu = pAction;
196 m_ToolBar.insertAction(m_pMain->ui->actionStop, m_pOperateMenu);