TxsTabWidget::TxsTabWidget(QWidget *parent) : QTabWidget(parent) { setFocusPolicy(Qt::ClickFocus); setContextMenuPolicy(Qt::PreventContextMenu); QTabBar *tb = new QTabBar(); tb->setContextMenuPolicy(Qt::CustomContextMenu); connect(tb, SIGNAL(customContextMenuRequested(QPoint)), this, SIGNAL(tabBarContextMenuRequested(QPoint))); setTabBar(tb); if (hasAtLeastQt(4,5)){ setDocumentMode(true); const QTabBar* tb=tabBar(); connect(tb,SIGNAL(tabMoved(int,int)),this,SIGNAL(tabMoved(int,int))); }
CentralWidget::CentralWidget(QHelpEngine *engine, QWidget *parent) : QWidget(parent) , findBar(0) , tabWidget(0) , helpEngine(engine) , printer(0) { lastTabPage = 0; globalActionList.clear(); collectionFile = helpEngine->collectionFile(); QString system = QLatin1String("win"); #ifdef Q_OS_MAC system = QLatin1String("mac"); #endif tabWidget = new QTabWidget; tabWidget->setDocumentMode(true); tabWidget->setMovable(true); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); QToolButton *newTabButton = new QToolButton(this); newTabButton->setAutoRaise(true); newTabButton->setToolTip(tr("Add new page")); newTabButton->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/addtab.png").arg(system))); tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner); connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab())); QVBoxLayout *vboxLayout = new QVBoxLayout(this); vboxLayout->setMargin(0); vboxLayout->addWidget(tabWidget); QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); if (tabBar) { tabBar->installEventFilter(this); tabBar->setContextMenuPolicy(Qt::CustomContextMenu); connect(tabBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showTabBarContextMenu(const QPoint&))); } staticCentralWidget = this; }
CentralWidget::CentralWidget(MainWindow *parent) : QWidget(parent) , lastTabPage(0) , tabWidget(0) , findWidget(0) , printer(0) , usesDefaultCollection(parent->usesDefaultCollection()) , m_searchWidget(0) { TRACE_OBJ globalActionList.clear(); staticCentralWidget = this; QVBoxLayout *vboxLayout = new QVBoxLayout(this); QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); vboxLayout->setMargin(0); tabWidget = new QTabWidget(this); #ifndef Q_OS_MAC resourcePath.append(QLatin1String("win")); #else resourcePath.append(QLatin1String("mac")); tabWidget->setDocumentMode(true); #endif connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); QToolButton *newTabButton = new QToolButton(this); newTabButton->setAutoRaise(true); newTabButton->setToolTip(tr("Add new page")); newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png"))); tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner); connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab())); QToolButton *closeTabButton = new QToolButton(this); closeTabButton->setEnabled(false); closeTabButton->setAutoRaise(true); closeTabButton->setToolTip(tr("Close current page")); closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png"))); tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab())); vboxLayout->addWidget(tabWidget); findWidget = new FindWidget(this); vboxLayout->addWidget(findWidget); findWidget->hide(); connect(findWidget, SIGNAL(findNext()), this, SLOT(findNext())); connect(findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious())); connect(findWidget, SIGNAL(find(QString, bool)), this, SLOT(find(QString, bool))); connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab())); QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); if (tabBar) { tabBar->installEventFilter(this); tabBar->setContextMenuPolicy(Qt::CustomContextMenu); connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTabBarContextMenu(QPoint))); } #if defined(QT_NO_WEBKIT) QPalette p = palette(); p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight)); p.setColor(QPalette::Inactive, QPalette::HighlightedText, p.color(QPalette::Active, QPalette::HighlightedText)); setPalette(p); #endif }