void FrostEdit::widgetChanged(QWidget* old, QWidget* now) { if(old == now) return; //Let's test was the last clicked widget A) TextEdit B) TabWidget C) TabBar TextEdit* wid = toTextEdit(now); TabWidget* tabwid = qobject_cast<TabWidget*>(now); QTabBar* bar = qobject_cast<QTabBar*>(now) ; //Was TabBar if(bar != nullptr && tabwid == nullptr && wid == nullptr) { tabwid = qobject_cast<TabWidget*>(bar->parentWidget()); updateTabWidget(tabwid); } else if(wid != nullptr && tabwid == nullptr && bar == nullptr) { tabwid = qobject_cast<TabWidget*>(wid->getParentWidget()); updateTabWidget(tabwid); } else if(tabwid != nullptr && bar == nullptr) { updateTabWidget(tabwid); } if(mCurrentTabWidget != nullptr) { if(mCurrentTabWidget->count() != 0 && mCurrentTabWidget != nullptr && mCurrentTabWidget->currentWidget() != nullptr) { QTextDocument* doc = toTextEdit(mCurrentTabWidget->currentWidget())->document(); emit documentChanged(toDocument(doc)); } } }
/** * @brief 마우스 커서가 MainWindow의 탭영역(1,2,3)에 올라가있는지 확인한다. * * +-------------------------------+-+-+-+ * | TITLE BAR |_|O|X| * +----------+----------+---------+-+-+-+ * |##1(Tab)##|##2(Tab)##|###3(Empty)####| * +----------+----------+---------------+ * | | * | 4 | * | | * +-------------------------------------+ * * TabBar::geometry()는 1,2영역을 나타내고, TabWidget::geometry()는 1,2,3,4영역을 나타낸다. * 이 두 geometry()를 연산해서 1,2,3 영역을 찾는다. * * @param mainWindow 대상 메인 윈도 * @return bool * */ bool CWindowManager::isCursorOnTabWithEmptyArea(MainWindow *mainWindow) { QRect barRect; QRect barRectG; QRect widgetRect; QRect widgetRectG; QTabBar* tabBar = 0; QTabWidget* tabWidget = 0; if(!mainWindow) return false; tabBar = mainWindow->getTabBar(); tabWidget = mainWindow->getTabWidget(); barRect = tabBar->geometry(); widgetRect = tabWidget->geometry(); barRectG.setTopLeft(tabBar->mapToGlobal(barRect.topLeft())); barRectG.setBottomRight(tabBar->mapToGlobal(barRect.bottomRight())); widgetRectG.setTopLeft(tabWidget->mapToGlobal(widgetRect.topLeft())); widgetRectG.setBottomRight(tabWidget->mapToGlobal(widgetRect.bottomRight())); widgetRectG.setTopLeft(QPoint(widgetRectG.topLeft().x(), barRectG.topLeft().y())); widgetRectG.setBottomRight(QPoint(widgetRectG.bottomRight().x(), barRectG.bottomRight().y())); return widgetRectG.contains(QCursor::pos()); }
MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { setFixedSize(1920, 1200); setWindowTitle(tr("Babel")); QVBoxLayout *mainLayout = new QVBoxLayout; QTabBar *tb; UiContact *contact = new UiContact(this); QScrollArea *contactScrollArea = new QScrollArea(); contactScrollArea->setWidget(contact); _tabWidget = new QTabWidget; tb = _tabWidget->tabBar(); _tabWidget->addTab(new Home(), tr("Home")); _tabWidget->addTab(contactScrollArea, tr("Contact")); std::ostringstream oss; _tabWidget->setTabsClosable(true); connect(_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); tb->tabButton(0, QTabBar::RightSide)->hide(); tb->tabButton(1, QTabBar::RightSide)->hide(); _tabWidget->setFocusPolicy(Qt::NoFocus); connect(&g_PTUser, SIGNAL(receivedCall(const std::string&)), this, SLOT(receivedCall(const std::string&))); mainLayout->addWidget(_tabWidget); setLayout(mainLayout); }
void QTabWidgetPrivate::init() { Q_Q(QTabWidget); stack = new QStackedWidget(q); stack->setObjectName(QLatin1String("qt_tabwidget_stackedwidget")); stack->setLineWidth(0); // hack so that QMacStyle::layoutSpacing() can detect tab widget pages stack->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::TabWidget)); QObject::connect(stack, SIGNAL(widgetRemoved(int)), q, SLOT(_q_removeTab(int))); QTabBar *tabBar = new QTabBar(q); tabBar->setObjectName(QLatin1String("qt_tabwidget_tabbar")); tabBar->setDrawBase(false); q->setTabBar(tabBar); q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::TabWidget)); #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) q->setFocusPolicy(Qt::NoFocus); else #endif q->setFocusPolicy(Qt::TabFocus); q->setFocusProxy(tabs); q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint( QStyle::SH_TabWidget_DefaultTabPosition, 0, q ))); }
aboutWidget::aboutWidget(QWidget *parent): QDialog(parent), ui(new Ui::aboutWidget) { setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint); ui->setupUi(this); ui->labAppName->setText(ui->labAppName->text() + QString(" <b>") + qApp->applicationVersion() + QString("</b>")); QString versionInfo; versionInfo = tr("built on "); versionInfo.append(__DATE__); versionInfo.append(" "); versionInfo.append(__TIME__); ui->labQtVer->setText(tr("using Qt ") + qVersion()); ui->labVersion->setText(versionInfo); QTabBar *tabs = new QTabBar; ui->frame->layout()->addWidget(tabs); ui->frame->layout()->addWidget(ui->txtArea); tabs->setFixedHeight(24); tabs->insertTab(0, tr("About")); tabs->insertTab(1, tr("Contacts")); tabs->insertTab(2, tr("Thanks")); connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int))); ui->txtArea->setHtml(getAbouT()); }
RMainWindowQt::RMainWindowQt(QWidget* parent, bool hasMdiArea) : QMainWindow(parent), RMainWindow(), mdiArea(NULL) { // uncomment for unified tool bars under Mac: //#if QT_VERSION >= 0x050201 //# ifdef Q_OS_MAC // setUnifiedTitleAndToolBarOnMac(true); //# endif //#endif if (hasMdiArea) { mdiArea = new RMdiArea(this); mdiArea->setViewMode(QMdiArea::TabbedView); mdiArea->setObjectName("MdiArea"); setCentralWidget(mdiArea); // combine into one slot, locked by mutex: connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(subWindowActivated(QMdiSubWindow*))); // part of the workaround for QMdiArea bug // with events filtering through all stacked windows: QTabBar* tabBar = getTabBar(); if (tabBar!=NULL) { connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); if (RSettings::getBoolValue("Appearance/ShowAddTabButton", false)) { tabBar->hide(); } } else {
void GTTabWidget::clickTab(GUITestOpStatus &os, QTabWidget* tabWidget, int idx, Qt::MouseButton button){ GT_CHECK(tabWidget != NULL, "tabWidget is NULL"); setCurrentIndex(os, tabWidget, idx); QTabBar* tabBar = getTabBar(os, tabWidget); QRect r = tabBar->tabRect(idx); GTMouseDriver::moveTo(os, tabBar->mapToGlobal(r.center())); GTMouseDriver::click(os, button); }
void tst_QTabBar::setIconSize() { QFETCH(int, sizeToSet); QFETCH(int, expectedWidth); QTabBar tabBar; tabBar.setIconSize(QSize(sizeToSet, sizeToSet)); QCOMPARE(tabBar.iconSize().width(), expectedWidth); }
SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL ) : QWizard( parent ) { p_intf = _p_intf; setWindowTitle( qtr( "Stream Output" ) ); setWindowRole( "vlc-stream-output" ); /* UI stuff */ ui.setupUi( this ); ui.inputBox->setMRL( inputMRL ); ui.helpEdit->setPlainText( qtr("This wizard will allow you to stream or " "convert your media for use locally, on your private network, " "or on the Internet.\n" "You should start by checking that source matches what you want " "your input to be and then press the \"Next\" " "button to continue.\n") ); ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n" "This is automatically generated " "when you change the above settings,\n" "but you can change it manually." ) ) ; ui.destTab->setTabsClosable( true ); QTabBar* tb = ui.destTab->findChild<QTabBar*>(); if( tb != NULL ) tb->tabButton(0, QTabBar::RightSide)->hide(); CONNECT( ui.destTab, tabCloseRequested( int ), this, closeTab( int ) ); ui.destTab->setTabIcon( 0, QIcon( ":/buttons/playlist/playlist_add" ) ); ui.destBox->addItem( qtr( "File" ) ); ui.destBox->addItem( "HTTP" ); ui.destBox->addItem( "MS-WMSP (MMSH)" ); ui.destBox->addItem( "RTSP" ); ui.destBox->addItem( "RTP / MPEG Transport Stream" ); ui.destBox->addItem( "RTP Audio/Video Profile" ); ui.destBox->addItem( "UDP (legacy)" ); ui.destBox->addItem( "IceCast" ); BUTTONACT( ui.addButton, addDest() ); // /* Connect everything to the updateMRL function */ #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() ); #define CT( x ) CONNECT( ui.x, textChanged( const QString& ), this, updateMRL() ); #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() ); #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() ); /* Misc */ CB( soutAll ); CB( localOutput ); CB( transcodeBox ); CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() ); setButtonText( QWizard::FinishButton, "Stream" ); #undef CC #undef CS #undef CT #undef CB }
void DocumentTabs::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::MidButton) { QTabBar *tabs = tabBar(); removeTab(tabs->tabAt(event->pos())); } QTabWidget::mousePressEvent(event); }
void UserWidget::mouseMoveEvent( QMouseEvent *event){ QTabBar *wid = tabBar(); if(wid==0){ return; } //invalid widget found QPoint relpos = wid->mapFromGlobal( this->mapToGlobal(event->pos()) ); //qDebug() << "Mouse Move Event: " << event->pos().x() << event->pos().y() << relpos.x() << relpos.y() << wid->width() << wid->height(); if(wid && wid->tabAt(relpos) != -1){ qDebug() << " - Mouse over tab"; this->setCurrentIndex( wid->tabAt(relpos) ); } }
void powerfulTabWidget::setNoCloseButton(int iIndex, const QSize &sizeItem) { QTabBar* pTabBar = tabBar(); if (NULL != pTabBar) { QWidget *pWidget = new QWidget; pWidget->resize(sizeItem); pTabBar->setTabButton(iIndex, QTabBar::RightSide, pWidget); } }
void MainTab::mousePressEvent(QMouseEvent* event) { if(event->buttons() == Qt::MidButton) { QTabBar* bar = tabBar(); m_index = bar->tabAt(bar->mapFrom(this, event->pos())); closeTab(); } QTabWidget::mousePressEvent(event); }
void tst_QTabBar::setElideMode() { QFETCH(int, tabElideMode); QTabBar tabBar; if (tabElideMode != -128) tabBar.setElideMode(Qt::TextElideMode(tabElideMode)); QTEST(int(tabBar.elideMode()), "expectedMode"); // Make sure style sheet does not override user set mode tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}"); QTEST(int(tabBar.elideMode()), "expectedMode"); }
void MainWindow::gameProcessFinished(GameProcess* process, int ) { //ui->tabWidget->fi int index = ui->tabWidget->indexOf(process); //ui->tabWidget->setTabText(index, ""); if (index < 1) return; QTabBar* bar = ui->tabWidget->tabBar(); bar->setTabTextColor(index, Qt::red); }
void tst_QTabBar::setUsesScrollButtons() { QFETCH(int, usesArrows); QTabBar tabBar; if (usesArrows != -128) tabBar.setUsesScrollButtons(usesArrows); QTEST(tabBar.usesScrollButtons(), "expectedArrows"); // Make sure style sheet does not override user set mode tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}"); QTEST(tabBar.usesScrollButtons(), "expectedArrows"); }
int GTTabWidget::getTabNumByName(GUITestOpStatus &os, QTabWidget *tabWidget, QString tabName){ GT_CHECK_RESULT(tabWidget != NULL, "tabWidget is NULL", -1); QTabBar* tabBar = getTabBar(os, tabWidget); int num = -1; for(int i=0; i<tabBar->count(); i++){ QString text = tabBar->tabText(i); if(text == tabName){ num = -1; } } GT_CHECK_RESULT(num != -1, "tab " + tabName + " not found", -1); return num; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void Scheme::applyTabPosition(QTabWidget *tab) { QTabBar *tabBar = tab->findChild<QTabBar*>(); if ( tabPosition > 0 ) { tab->setTabPosition(static_cast<QTabWidget::TabPosition>(tabPosition-1)); if ( tabBar ) tabBar->setVisible(true); } else if ( tabPosition == 0 ) { if ( tabBar ) tabBar->setVisible(false); } }
void tst_QTabBar::testCurrentChanged() { QFETCH(int, tabToSet); QFETCH(int, expectedCount); QTabBar tabBar; QSignalSpy spy(&tabBar, SIGNAL(currentChanged(int))); tabBar.addTab("Tab1"); tabBar.addTab("Tab2"); QCOMPARE(tabBar.currentIndex(), 0); tabBar.setCurrentIndex(tabToSet); QCOMPARE(tabBar.currentIndex(), tabToSet); QCOMPARE(spy.count(), expectedCount); }
void MainWindow::setTabCaptions() { QTabBar* bar = ui->tabWidget->tabBar(); short tabCount = this->tabCaptions.length(); for (int x = 0; x < tabCount; ++x) { this->setTabCaption(x, this->tabCaptions.at(x)); if (this->logCount.at(x) > 0) bar->setTabTextColor(x, QColor(0, 0, 0)); else bar->setTabTextColor(x, QColor(180, 180, 180)); } }
void powerfulTabWidget::feed2Full() { QTabBar* pTabBar = tabBar(); if (NULL != pTabBar) { for (int iIndex = 0; iIndex < count(); ++iIndex) { QWidget *pWidget = new QWidget; pWidget->setMaximumSize(pTabBar->width() / count() / 2, pTabBar->height()); pWidget->setMinimumSize(pTabBar->width() / count() / 2, pTabBar->height()); pTabBar->setTabButton(iIndex, QTabBar::LeftSide, pWidget); } } }
bool FancyTabProxyStyle::eventFilter(QObject* o, QEvent* e) { QTabBar* bar = qobject_cast<QTabBar*>(o); if (bar && (e->type() == QEvent::MouseMove || e->type() == QEvent::Leave)) { QMouseEvent* event = static_cast<QMouseEvent*>(e); const QString old_hovered_tab = bar->property("tab_hover").toString(); const QString hovered_tab = e->type() == QEvent::Leave ? QString() : bar->tabText(bar->tabAt(event->pos())); bar->setProperty("tab_hover", hovered_tab); if (old_hovered_tab != hovered_tab) bar->update(); } return false; }
void tst_QTabBar::removeLastTab() { QTabBar tabbar; QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int))); int index = tabbar.addTab("foo"); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toInt(), index); spy.clear(); tabbar.removeTab(index); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toInt(), -1); spy.clear(); }
ExtendedTabWidget::ExtendedTabWidget(QWidget *parent) : QTabWidget(parent) { QTabBar* tb = new QTabBar(this); tb->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); setTabBar(tb); setMovable(true); setTabPosition(QTabWidget::North); setTabShape(QTabWidget::Rounded); setTabsClosable(true); setIconSize(QSize(32, 32)); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(onClose(int))); }
QRect NativeTabItem::GetBounds() { int index = parent->IndexOf(this); QTabBar* folder = parent->GetTabFolder(); QRect localRect = folder->tabRect(index); QPoint topLeft = localRect.topLeft(); QPoint bottomRight = localRect.bottomRight(); QPoint globalTopLeft = folder->mapToGlobal(topLeft); QPoint globalBottomRight = folder->mapToGlobal(bottomRight); return QRect(globalTopLeft, globalBottomRight); }
//----------------------------------------------------------------------------------------- GenericTextEditor::GenericTextEditor(QString documentIcon, QWidget *parent) : QMdiArea(parent) { mDocumentIcon = documentIcon; mAllowDoubleDisplay = false; setObjectName("GenericTextEditor"); setViewMode(QMdiArea::TabbedView); QTabBar* tabBar = findChildren<QTabBar*>().at(0); tabBar->setTabsClosable(true); connect(tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); }
void tst_QTabBar::insertAtCurrentIndex() { QTabBar tabBar; tabBar.addTab("Tab1"); QCOMPARE(tabBar.currentIndex(), 0); tabBar.insertTab(0, "Tab2"); QCOMPARE(tabBar.currentIndex(), 1); tabBar.insertTab(0, "Tab3"); QCOMPARE(tabBar.currentIndex(), 2); tabBar.insertTab(2, "Tab4"); QCOMPARE(tabBar.currentIndex(), 3); }
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))); }
KeyboardDialog::KeyboardDialog(QWidget* parent): QDialog(parent) { m_keyboard = new KeyboardWidget(this); m_keyboard->setKeymap(KeyboardWidget::US); m_keyboard->setContentsMargins(0, 0, 0, 0); connect(m_keyboard, SIGNAL(selected(QString)), this, SIGNAL(selected(QString))); QFrame* keyboardFrame = new QFrame(this); keyboardFrame->setFrameShape(QFrame::WinPanel); keyboardFrame->setFrameShadow(QFrame::Sunken); QVBoxLayout* keyboardFrameLayout = new QVBoxLayout(keyboardFrame); keyboardFrameLayout->addWidget(m_keyboard); QTabBar* tabBar = new QTabBar(this); tabBar->addTab(QIcon(":/img/keyboard/usflag.png"), "US Keymap"); tabBar->addTab(QIcon(":/img/keyboard/deflag.png"), "DE Keymap"); tabBar->addTab(QIcon(":/img/keyboard/frflag.png"), "FR Keymap"); tabBar->addTab(QIcon(":/img/keyboard/rawflag.png"), "RAW Codes"); connect(tabBar, SIGNAL(currentChanged(int)), m_keyboard, SLOT(setKeymap(int))); QLabel* selectedLabel = new QLabel("<b>Selected <a href=\"http://www.whdload.de/docs/en/rawkey.html\">raw key code</a>: </b>", this); selectedLabel->setOpenExternalLinks(true); QLabel* selected = new QLabel("$--", this); selected->setFont(QFont("Courier New", 16, QFont::Bold)); connect(m_keyboard, SIGNAL(selected(QString)), selected, SLOT(setText(QString))); QPushButton* close = new QPushButton("Done", this); connect(close, SIGNAL(clicked()), this, SLOT(accept())); QVBoxLayout* mainLayout = new QVBoxLayout(this); mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->setSpacing(0); mainLayout->addWidget(tabBar); mainLayout->addWidget(keyboardFrame); mainLayout->addSpacing(8); QHBoxLayout* selectionLayout = new QHBoxLayout(); mainLayout->addLayout(selectionLayout); selectionLayout->addWidget(selectedLabel); selectionLayout->addSpacing(8); selectionLayout->addWidget(selected); selectionLayout->addStretch(); selectionLayout->addWidget(close); setModal(true); setWindowTitle(__MAGE__WHDRun__NameAndVersion__ " :: WHDLoad Keyboard"); }
Buttons() { QIcon icon; icon.addFile(":/[email protected]"); QPushButton *button = new QPushButton(this); button->setIcon(icon); button->setText("16@2x"); QTabBar *tab = new QTabBar(this); tab->addTab(QIcon(":/qticon16.png"), "16@1x"); tab->addTab(QIcon(":/[email protected]"), "16@2x"); tab->addTab(QIcon(":/qticon16.png"), ""); tab->addTab(QIcon(":/[email protected]"), ""); tab->move(10, 100); tab->show(); QToolBar *toolBar = new QToolBar(this); toolBar->addAction(QIcon(":/qticon16.png"), "16"); toolBar->addAction(QIcon(":/[email protected]"), "16@2x"); toolBar->addAction(QIcon(":/qticon32.png"), "32"); toolBar->addAction(QIcon(":/[email protected]"), "32@2x"); toolBar->move(10, 200); toolBar->show(); }