3#include "FrmFullScreenToolBar.h"
4#include "ui_FrmFullScreenToolBar.h"
5#include "ui_mainwindow.h"
6#include "RabbitCommonDir.h"
11#include <QApplication>
12#include <QLoggingCategory>
14static Q_LOGGING_CATEGORY(log,
"App.MainWindow.FullScreen")
15static Q_LOGGING_CATEGORY(logRecord, "App.
MainWindow.FullScreen.Record")
19 Qt::FramelessWindowHint
21 | Qt::X11BypassWindowManagerHint
24 | Qt::WindowStaysOnTopHint
25 | Qt::CustomizeWindowHint
27 ui(
new Ui::CFrmFullScreenToolBar),
29 m_pConnecterMenu(
nullptr),
36 setAttribute(Qt::WA_DeleteOnClose);
39 setFocusPolicy(Qt::NoFocus);
41 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure());
42 m_ToolBar.addSeparator();
43 m_pNail = m_ToolBar.addAction(QIcon::fromTheme(
"nail"), tr(
"Nail"),
44 this, SLOT(slotNail()));
45 m_pNail->setCheckable(
true);
46 m_pNail->setChecked(set.value(
"FullScreen/Nail",
true).toBool());
47 m_pNail->setToolTip(tr(
"Nail"));
48 m_pNail->setStatusTip(tr(
"Nail"));
49 m_ToolBar.addSeparator();
50 m_ToolBar.addAction(m_pMain->ui->actionFull_screen_F);
52 m_ToolBar.addSeparator();
53 if(m_pMain->m_pActionConnecterMenu) {
54 m_pConnecterMenu = m_pMain->m_pActionConnecterMenu;
55 m_ToolBar.addAction(m_pConnecterMenu);
58 m_ToolBar.addAction(m_pMain->ui->actionDisconnect_D);
59 m_ToolBar.addSeparator();
60 m_ToolBar.addAction(m_pMain->ui->actionExit_E);
64 check = connect(&m_Timer, SIGNAL(timeout()),
65 this, SLOT(slotTimeOut()));
68 m_Timer.start(m_TimeOut);
73CFrmFullScreenToolBar::~CFrmFullScreenToolBar()
75 qDebug(log) <<
"CFrmFullScreenToolBar::~CFrmFullScreenToolBar()";
81void CFrmFullScreenToolBar::mouseMoveEvent(QMouseEvent *event)
83 if(Qt::LeftButton != event->buttons())
86 QPointF p =
event->pos();
87 move(x() + (p.x() - m_Pos.x()), y() + (p.y() - m_Pos.y()));
90void CFrmFullScreenToolBar::mousePressEvent(QMouseEvent *event)
95int CFrmFullScreenToolBar::ReToolBarSize()
97 int marginW = style()->pixelMetric(
98 QStyle::PM_FocusFrameHMargin) << 1;
99 int marginH = style()->pixelMetric(
100 QStyle::PM_FocusFrameVMargin) << 1;
101 QMargins cm = contentsMargins();
103 QSize size = m_ToolBar.frameSize();
105 resize(marginW + cm.left() + cm.right() + size.width(),
106 marginH + cm.top() + cm.bottom() + size.height());
108 if(frameGeometry().top() > m_pMain->frameGeometry().height() >> 1)
109 move(frameGeometry().left(),
110 m_pMain->frameGeometry().height() - frameGeometry().height());
114void CFrmFullScreenToolBar::slotTimeOut()
119 if(m_pNail->isChecked())
return;
124 resize(width(), area);
126 int h = m_pMain->frameGeometry().height() >> 1;
127 if(frameGeometry().top() < h)
128 move(frameGeometry().left(), 0);
130 move(frameGeometry().left(), m_pMain->frameGeometry().height() - area);
133#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
134void CFrmFullScreenToolBar::enterEvent(QEnterEvent *event)
136void CFrmFullScreenToolBar::enterEvent(QEvent *event)
149void CFrmFullScreenToolBar::leaveEvent(QEvent *event)
152 if(m_pNail->isChecked())
return;
154 m_Timer.start(m_TimeOut);
157void CFrmFullScreenToolBar::slotNail()
159 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure());
160 set.setValue(
"FullScreen/Nail", m_pNail->isChecked());
163void CFrmFullScreenToolBar::slotConnecterMenuChanged(QAction* pAction)
165 if(m_pConnecterMenu) {
166 m_ToolBar.removeAction(m_pConnecterMenu);
167 m_pConnecterMenu = pAction;
168 m_ToolBar.insertAction(m_pMain->ui->actionDisconnect_D, m_pConnecterMenu);