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_pShowTabBar = m_ToolBar.addAction(QIcon::fromTheme(
"tabbar"), tr(
"TabBar"),
59 this, SLOT(slotShowTabBar()));
60 m_pShowTabBar->setCheckable(
true);
61 m_pShowTabBar->setStatusTip(tr(
"Tab bar"));
62 m_pShowTabBar->setToolTip(tr(
"Tab bar"));
64 m_ToolBar.addAction(m_pMain->ui->actionDisconnect_D);
65 m_ToolBar.addSeparator();
66 m_ToolBar.addAction(m_pMain->ui->actionExit_E);
70 check = connect(&m_Timer, SIGNAL(timeout()),
71 this, SLOT(slotTimeOut()));
74 m_Timer.start(m_TimeOut);
79CFrmFullScreenToolBar::~CFrmFullScreenToolBar()
81 qDebug(log) <<
"CFrmFullScreenToolBar::~CFrmFullScreenToolBar()";
87void CFrmFullScreenToolBar::mouseMoveEvent(QMouseEvent *event)
89 if(Qt::LeftButton != event->buttons())
92 QPointF p =
event->pos();
93 move(x() + (p.x() - m_Pos.x()), y() + (p.y() - m_Pos.y()));
96void CFrmFullScreenToolBar::mousePressEvent(QMouseEvent *event)
101int CFrmFullScreenToolBar::ReToolBarSize()
103 int marginW = style()->pixelMetric(
104 QStyle::PM_FocusFrameHMargin) << 1;
105 int marginH = style()->pixelMetric(
106 QStyle::PM_FocusFrameVMargin) << 1;
107 QMargins cm = contentsMargins();
109 QSize size = m_ToolBar.frameSize();
111 resize(marginW + cm.left() + cm.right() + size.width(),
112 marginH + cm.top() + cm.bottom() + size.height());
114 if(frameGeometry().top() > m_pMain->frameGeometry().height() >> 1)
115 move(frameGeometry().left(),
116 m_pMain->frameGeometry().height() - frameGeometry().height());
120void CFrmFullScreenToolBar::slotTimeOut()
125 if(m_pNail->isChecked())
return;
130 resize(width(), area);
132 int h = m_pMain->frameGeometry().height() >> 1;
133 if(frameGeometry().top() < h)
134 move(frameGeometry().left(), 0);
136 move(frameGeometry().left(), m_pMain->frameGeometry().height() - area);
139#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
140void CFrmFullScreenToolBar::enterEvent(QEnterEvent *event)
142void CFrmFullScreenToolBar::enterEvent(QEvent *event)
155void CFrmFullScreenToolBar::leaveEvent(QEvent *event)
158 if(m_pNail->isChecked())
return;
160 m_Timer.start(m_TimeOut);
163void CFrmFullScreenToolBar::slotShowTabBar()
165 emit sigShowTabBar(m_pShowTabBar->isChecked());
168void CFrmFullScreenToolBar::slotNail()
170 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure());
171 set.setValue(
"FullScreen/Nail", m_pNail->isChecked());
174void CFrmFullScreenToolBar::slotConnecterMenuChanged(QAction* pAction)
176 if(m_pConnecterMenu) {
177 m_ToolBar.removeAction(m_pConnecterMenu);
178 m_pConnecterMenu = pAction;
179 m_ToolBar.insertAction(m_pShowTabBar, m_pConnecterMenu);