void TabSwitcherWidget::showEvent(QShowEvent *event) { grabKeyboard(); for (int i = 0; i < m_windowsManager->getWindowCount(); ++i) { Window *window = m_windowsManager->getWindowByIndex(i); if (window) { m_model->appendRow(createRow(window)); } } m_model->sort(1, Qt::DescendingOrder); m_tabsView->setCurrentIndex(m_model->index(0, 0)); const int contentsHeight = (m_model->rowCount() * 22); m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9))); QWidget::showEvent(event); connect(m_windowsManager, SIGNAL(windowAdded(qint64)), this, SLOT(tabAdded(qint64))); connect(m_windowsManager, SIGNAL(windowRemoved(qint64)), this, SLOT(tabRemoved(qint64))); }
void DeclarativeTabModel::addTab(const QString& url, const QString &title) { if (!LinkValidator::navigable(QUrl(url))) { return; } int tabId = createTab(); int linkId = createLink(tabId, url, title); Tab tab(tabId, Link(linkId, url, "", title), 0, 0); #if DEBUG_LOGS qDebug() << "new tab data:" << &tab; #endif int index = m_tabs.count(); beginInsertRows(QModelIndex(), index, index); m_tabs.append(tab); endInsertRows(); // We should trigger this only when // tab is added through new window request. In all other // case we should keep the new tab in background. updateActiveTab(tab, true); emit countChanged(); emit tabAdded(tabId); m_nextTabId = ++tabId; emit nextTabIdChanged(); setWaitingForNewTab(false); }
void TabSwitcherWidget::hideEvent(QHideEvent *event) { releaseKeyboard(); QWidget::hideEvent(event); disconnect(m_windowsManager, SIGNAL(windowAdded(qint64)), this, SLOT(tabAdded(qint64))); disconnect(m_windowsManager, SIGNAL(windowRemoved(qint64)), this, SLOT(tabRemoved(qint64))); m_model->clear(); }
void DeclarativeTabModel::addTab(const QString& url, const QString &title) { if (!LinkValidator::navigable(QUrl(url))) { return; } int tabId = DBManager::instance()->createTab(); int linkId = DBManager::instance()->createLink(tabId, url, title); Tab tab(tabId, Link(linkId, url, "", title), 0, 0); #ifdef DEBUG_LOGS qDebug() << "new tab data:" << &tab; #endif if (m_activeTab.isValid()) { beginInsertRows(QModelIndex(), 0, 0); m_tabs.insert(0, m_activeTab); endInsertRows(); } updateActiveTab(tab); emit countChanged(); emit tabAdded(tabId); m_nextTabId = ++tabId; emit nextTabIdChanged(); }
Tabruler::Tabruler( QWidget* parent, bool haveFirst, int dEin, QList<ParagraphStyle::TabRecord> Tabs, double wid ) : QWidget( parent ), firstLineLabel(0), leftIndentLabel(0), rightIndentLabel(0), firstLineData(0), leftIndentData(0), rightIndentData(0) { docUnitRatio=unitGetRatioFromIndex(dEin); double ww = (wid < 0) ? 4000 : wid; tabrulerLayout = new QVBoxLayout( this ); tabrulerLayout->setMargin(0); tabrulerLayout->setSpacing(5); layout2 = new QHBoxLayout; layout2->setMargin(0); layout2->setSpacing(5); rulerScrollL = new QToolButton(this); rulerScrollL->setArrowType(Qt::LeftArrow); rulerScrollL->setAutoRepeat( true ); layout2->addWidget( rulerScrollL ); ruler = new RulerT( this, dEin, Tabs, haveFirst, wid ); ruler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); layout2->addWidget( ruler ); rulerScrollR = new QToolButton(this); rulerScrollR->setArrowType(Qt::RightArrow); rulerScrollR->setAutoRepeat( true ); layout2->addWidget( rulerScrollR ); layout1 = new QHBoxLayout; layout1->setMargin(0); layout1->setSpacing(5); layout1->setAlignment( Qt::AlignTop ); typeCombo = new QComboBox(this); typeCombo->setEditable(false); typeCombo->clear(); typeCombo->addItem( tr( "Left" ) ); typeCombo->addItem( tr( "Right" ) ); typeCombo->addItem( tr( "Period" ) ); typeCombo->addItem( tr( "Comma" ) ); typeCombo->addItem( tr( "Center" ) ); layout1->addWidget( typeCombo ); tabData = new ScrSpinBox( 0, ww / docUnitRatio, this, dEin ); tabData->setValue(0); positionLabel = new QLabel( tr("&Position:"), this ); positionLabel->setBuddy(tabData); layout1->addWidget( positionLabel ); layout1->addWidget( tabData ); tabFillCombo = new QComboBox(this); tabFillCombo->setEditable(false); tabFillCombo->addItem( tr("None", "tab fill")); tabFillCombo->addItem( tr("Dot")); tabFillCombo->addItem( tr("Hyphen")); tabFillCombo->addItem( tr("Underscore")); tabFillCombo->addItem( tr("Custom")); tabFillComboT = new QLabel( tr( "Fill Char:" ), this ); tabFillComboT->setBuddy(tabFillCombo); layout1->addWidget( tabFillComboT ); layout1->addWidget( tabFillCombo ); layout4 = new QHBoxLayout; layout4->setMargin(0); layout4->setSpacing(5); indentLayout = new QHBoxLayout; indentLayout->setMargin(0); indentLayout->setSpacing(5); if (haveFirst) { firstLineData = new ScrSpinBox( -3000, ww / docUnitRatio, this, dEin); firstLineData->setValue(0); firstLineLabel = new QLabel(this); firstLineLabel->setText(""); firstLineLabel->setPixmap(IconManager::instance()->loadPixmap("firstline.png")); indentLayout->addWidget( firstLineLabel ); indentLayout->addWidget( firstLineData ); leftIndentData = new ScrSpinBox( 0, ww / docUnitRatio, this, dEin ); leftIndentData->setValue(0); leftIndentLabel = new QLabel(this); leftIndentLabel->setText(""); leftIndentLabel->setPixmap(IconManager::instance()->loadPixmap("leftindent.png")); layout4->addWidget( leftIndentLabel ); layout4->addWidget( leftIndentData ); layout4->addStretch(10); rightIndentLabel = new QLabel(this); rightIndentLabel->setText(""); rightIndentLabel->setPixmap(IconManager::instance()->loadPixmap("rightindent.png")); rightIndentData = new ScrSpinBox(0, ww / docUnitRatio, this, dEin); rightIndentData->setValue(0); indentLayout->addWidget(rightIndentLabel); indentLayout->addWidget(rightIndentData); } clearButton = new QPushButton( this ); clearButton->setText( tr( "Delete All" ) ); indentLayout->addSpacing(20); indentLayout->addWidget( clearButton); clearOneButton = new QPushButton( this ); clearOneButton->setText( tr( "Delete Selected" ) ); indentLayout->addWidget( clearOneButton); indentLayout->addStretch(10); if (!haveFirst) { QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); layout1->addItem( spacer ); } layout1->addStretch( 10 ); tabrulerLayout->addLayout( layout1 ); tabrulerLayout->addLayout( layout2 ); indentLayout->addStretch( 10 ); tabrulerLayout->addLayout( indentLayout ); tabrulerLayout->addLayout(layout4); tabData->setEnabled(false); tabFillCombo->setEnabled(false); typeCombo->setEnabled(false); if (Tabs.count() == 0) clearButton->setEnabled(false); clearOneButton->setEnabled(false); resize( minimumSizeHint() ); connect(rulerScrollL, SIGNAL(clicked()), ruler, SLOT(decreaseOffset())); connect(rulerScrollR, SIGNAL(clicked()), ruler, SLOT(increaseOffset())); connect(rulerScrollL, SIGNAL(released()), this, SLOT(resetOFfL())); connect(rulerScrollR, SIGNAL(released()), this, SLOT(resetOFfR())); connect(ruler, SIGNAL(typeChanged(int)) , this, SLOT(setTabType(int))); connect(ruler, SIGNAL(fillCharChanged(QChar)) , this, SLOT(setTabFillChar(QChar))); connect(typeCombo, SIGNAL(activated(int)), this, SLOT(setType())); connect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar())); connect(tabFillCombo, SIGNAL(editTextChanged(const QString &)), this, SLOT(setCustomFillChar(const QString &))); connect(ruler, SIGNAL(tabMoved(double)) , this, SLOT(setTabData(double))); connect(ruler, SIGNAL(tabSelected()), this, SLOT(tabAdded())); connect(ruler, SIGNAL(newTab()), this, SLOT(tabAdded())); connect(ruler, SIGNAL(noTabs()), this, SLOT(lastTabRemoved())); connect(tabData, SIGNAL(valueChanged(double)), this, SLOT(setTab())); connect(clearButton, SIGNAL(clicked()), this, SLOT(clearAll())); connect(clearOneButton, SIGNAL(clicked()), this, SLOT(clearOne())); tabFillCombo->setToolTip( tr( "Fill Character of Tab" ) ); typeCombo->setToolTip( tr( "Type/Orientation of Tab" ) ); tabData->setToolTip( tr( "Position of Tab" ) ); if (haveFirst) { connect(ruler, SIGNAL(firstLineMoved(double)) , this, SLOT(setFirstLineData(double))); connect(ruler, SIGNAL(leftIndentMoved(double)) , this, SLOT(setLeftIndentData(double))); connect(ruler, SIGNAL(mouseReleased()), this, SIGNAL(tabrulerChanged())); connect(ruler, SIGNAL(mouseReleased()), this, SLOT(slotMouseReleased())); connect(firstLineData, SIGNAL(valueChanged(double)), this, SLOT(setFirstLine())); connect(leftIndentData, SIGNAL(valueChanged(double)), this, SLOT(setLeftIndent())); connect(rightIndentData, SIGNAL(valueChanged(double)), this, SLOT(setRightIndent())); firstLineData->setToolTip( tr( "Indentation for first line of the paragraph" ) ); leftIndentData->setToolTip( tr( "Indentation from the left for the whole paragraph" ) ); rightIndentData->setToolTip( tr( "Indentation from the right for the whole paragraph" ) ); firstLineLabel->setToolTip(firstLineData->toolTip()); leftIndentLabel->setToolTip(leftIndentData->toolTip()); rightIndentLabel->setToolTip(rightIndentData->toolTip()); } clearButton->setToolTip( tr( "Delete all Tabulators" ) ); clearOneButton->setToolTip( tr("Delete selected Tabulator")); QString ein = unitGetSuffixFromIndex(dEin); if (dEin == 2) { if (haveFirst) { firstLineData->setDecimals(4); leftIndentData->setDecimals(4); rightIndentData->setDecimals(4); } tabData->setDecimals(4); } if (haveFirst) { firstLineData->setSuffix(ein); leftIndentData->setSuffix(ein); rightIndentData->setSuffix(ein); } tabData->setSuffix(ein); haveF = haveFirst; }