10#include <QLoggingCategory>
11#include "mainwindow.h"
14static Q_LOGGING_CATEGORY(log,
"App.View.Table")
15static Q_LOGGING_CATEGORY(logRecord, "App.View.Table.Record")
20 qDebug(log) << Q_FUNC_INFO;
22 setFocusPolicy(Qt::NoFocus);
24 m_pTab =
new QTabWidget(
this);
25 m_pTab->setTabsClosable(
true);
26 m_pTab->setUsesScrollButtons(
true);
27 m_pTab->setMovable(
true);
28 m_pTab->setFocusPolicy(Qt::NoFocus);
29 m_pTab->tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
36 m_pTab->setTabPosition(p->m_Parameter.GetTabPosition());
37 check = connect(&p->m_Parameter, SIGNAL(sigTabPositionChanged()),
38 this, SLOT(slotTabPositionChanged()));
43 check = connect(m_pTab, SIGNAL(tabCloseRequested(
int)),
44 this, SLOT(slotTabCloseRequested(
int)));
46 check = connect(m_pTab, SIGNAL(currentChanged(
int)),
47 this, SLOT(slotCurrentChanged(
int)));
49 check = connect(m_pTab->tabBar(),
50 SIGNAL(customContextMenuRequested(
const QPoint&)),
51 this, SIGNAL(customContextMenuRequested(
const QPoint&)));
55CViewTable::~CViewTable()
57 qDebug(log) << Q_FUNC_INFO;
62void CViewTable::slotCurrentChanged(
int index)
64 qDebug(log) <<
"CViewTable::slotCurrentChanged";
65 emit sigCurrentChanged(GetViewer(index));
68void CViewTable::slotTabCloseRequested(
int index)
70 QWidget* pView = GetViewer(index);
75void CViewTable::slotTabPositionChanged()
78 if(!p || !m_pTab)
return;
79 m_pTab->setTabPosition(p->m_Parameter.GetTabPosition());
82void CViewTable::slotSystemCombination()
86 CFrmViewer* pFrmViewer = qobject_cast<CFrmViewer*>(pView);
88 pFrmViewer->slotSystemCombination();
96 qCritical(log) <<
"CViewTable::AddView: The pView is nullptr";
100 nIndex = m_pTab->addTab(pView, pView->windowTitle());
101 m_pTab->setCurrentIndex(nIndex);
108 int nIndex = GetViewIndex(pView);
109 if(-1 == nIndex)
return 0;
111 m_pTab->removeTab(nIndex);
115void CViewTable::SetWidowsTitle(QWidget* pView,
const QString& szTitle,
116 const QIcon &icon,
const QString &szToolTip)
119 qCritical(log) <<
"CViewTable::SetWidowsTitle: The pView is nullptr";
123 pView->setWindowTitle(szTitle);
124 int nIndex = GetViewIndex(pView);
125 m_pTab->setTabText(nIndex, szTitle);
126 if(m_pMainWindow->m_Parameter.GetEnableTabToolTip())
127 m_pTab->setTabToolTip(nIndex, szToolTip);
129 m_pTab->setTabToolTip(nIndex,
"");
130 if(m_pMainWindow->m_Parameter.GetEnableTabIcon())
131 m_pTab->setTabIcon(nIndex, icon);
133 m_pTab->setTabIcon(nIndex, QIcon());
136int CViewTable::SetFullScreen(
bool bFull)
138 if(!m_pTab)
return -1;
142 m_szStyleSheet = m_pTab->styleSheet();
144 m_pTab->setStyleSheet(
"QTabWidget::pane{top:0px;left:0px;border:none;}");
145 m_pTab->showFullScreen();
147 m_pTab->setStyleSheet(m_szStyleSheet);
148 m_pTab->showNormal();
153int CViewTable::ShowTabBar(
bool bShow)
155 m_pTab->tabBar()->setVisible(bShow);
159QWidget *CViewTable::GetViewer(
int index)
161 if(index < 0 || index >= m_pTab->count())
164 return m_pTab->widget(index);
167int CViewTable::GetViewIndex(QWidget *pView)
169 for(
int i = 0; i < m_pTab->count(); i++)
171 QWidget* p = GetViewer(i);
181 QWidget* pView = m_pTab->currentWidget();
182 if(!pView)
return pView;
186void CViewTable::resizeEvent(QResizeEvent *event)
191 m_pTab->resize(event->size());
194QSize CViewTable::GetDesktopSize()
A widget which displays output image from a CConnectDesktop and sends input keypresses and mouse acti...
virtual int RemoveView(QWidget *pView) override
virtual QWidget * GetCurrentView() override
virtual int AddView(QWidget *pView) override
void sigCloseView(const QWidget *pView)