void MainWindow::textToSpeak() { Language *srcLn = mLangageModel->language(ui->sourceComboBox->currentIndex()); Language *targetLn = mLangageModel->language(ui->targetComboBox->currentIndex()); QToolButton * button = qobject_cast<QToolButton*>(sender()); qDebug()<<button->text(); TTSDialog * dialog = 0 ; if ( button->text() == "source") { dialog = new TTSDialog(srcLn,ui->sourceTextEdit->toPlainText()); } if ( button->text() == "target") { dialog = new TTSDialog(targetLn,ui->targetTextEdit->toPlainText()); } if ( !dialog) return; dialog->exec(); }
void CSSEdit::colorSelectClicked() { QToolButton *colorButton; QString propertyName; if (sender() == m_colorButton) { colorButton = m_colorButton; propertyName = "color"; } else if (sender() == m_backgroundButton) { colorButton = m_backgroundButton; propertyName = "background-color"; } else return; if (! m_elements.contains(m_currentElement)) return; Element *element = &m_elements[m_currentElement]; Element parentElement = getParentElement(m_currentElement); QColor color = QColorDialog::getColor(QColor(colorButton->text()), this); if (color.isValid()) { colorButton->setText(color.name()); QPalette palette = colorButton->palette(); palette.setColor(QPalette::Normal, QPalette::ButtonText, color); colorButton->setPalette(palette); if (parentElement[propertyName] == color.name()) element->remove(propertyName); else element->insert(propertyName, color.name()); updatePreview(); } }
Widget::Widget( QWidget *pParent ) : QWidget( pParent ), d( new Private( this ) ) { Manager::registerWidget( this ); connect( Manager::instance(), SIGNAL(aggregationsChanged()), this, SLOT(aggregationsChanged() ) ); connect( Manager::instance(), SIGNAL(themesChanged()), this, SLOT(themesChanged() ) ); setAutoFillBackground( true ); setObjectName( QLatin1String( "messagelistwidget" ) ); QGridLayout * g = new QGridLayout( this ); g->setMargin( 2 ); // use a smaller default g->setSpacing( 2 ); d->mSearchEdit = new KLineEdit( this ); d->mSearchEdit->setClickMessage( i18nc( "Search for messages.", "Search" ) ); d->mSearchEdit->setObjectName( QLatin1String( "quicksearch" ) ); d->mSearchEdit->setClearButtonShown( true ); connect( d->mSearchEdit, SIGNAL( textEdited( const QString & ) ), SLOT( searchEditTextEdited( const QString & ) ) ); connect( d->mSearchEdit, SIGNAL( clearButtonClicked() ), SLOT( searchEditClearButtonClicked() ) ); g->addWidget( d->mSearchEdit, 0, 0 ); // The status filter button. Will be populated later, as populateStatusFilterCombo() is virtual d->mStatusFilterCombo = new KComboBox( this ) ; g->addWidget( d->mStatusFilterCombo, 0, 1 ); // The "Open Full Search" button QToolButton * tb = new QToolButton( this ); tb->setIcon( KIcon( QLatin1String( "edit-find-mail" ) ) ); tb->setText( i18n( "Open Full Search" ) ); tb->setToolTip( tb->text() ); g->addWidget( tb, 0, 2 ); connect( tb, SIGNAL( clicked() ), this, SIGNAL( fullSearchRequest() ) ); d->mView = new View( this ); d->mView->setSortOrder( &d->mSortOrder ); d->mView->setObjectName( QLatin1String( "messagealistview" ) ); g->addWidget( d->mView, 1, 0, 1, 6 ); connect( d->mView->header(), SIGNAL( sectionClicked( int ) ), SLOT( slotViewHeaderSectionClicked( int ) ) ); g->setRowStretch( 1, 1 ); g->setColumnStretch( 0, 1 ); d->mSearchEdit->setEnabled( false ); d->mStatusFilterCombo->setEnabled( false ); d->mSearchTimer = 0; }
void SettingsDialog::chooseColor(QWidget* widget) { QToolButton* but = qobject_cast<QToolButton*>(widget); QString colorName = but->text(); QColorDialog selector; QColor color(SETTINGS->get("Color", colorName).toString()); color = selector.getColor(color); if (color.isValid()) { SETTINGS->set("Color", colorName, color.name()); updateColorToolButtonColor(but); } }
void ItemsWidget::createItems(int categoryId) { // Remove pervious buttons from grid layout this->removeItems(); // Get all items QList<Model::Item> items = Services::Item::getByCategoryId(categoryId); int i=0, col = 0, row = 1; for(QList<Model::Item>::iterator p = items.begin(); p != items.end(); ++p ) { QToolButton* button = new QToolButton; button->setObjectName(QString("%1_itemButton").arg(p->id())); button->setText((Settings::Language::getCurrentLanguage() == Settings::Language::Arabic) ? p->arabicName() : p->englishName()); if ( Settings::Language::getCurrentLanguage() == Settings::Language::English ) { if ( p->id() == 2 || p->id() == 29) button->setFont(QFont("Hacen Liner Screen Bd", 10, QFont::Normal)); else button->setFont(QFont("Hacen Liner Screen Bd", 13, QFont::Normal)); } else button->setFont(QFont("Hacen Liner Screen Bd", 13, QFont::Normal)); button->setIconSize(QSize(128,128)); //button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); button->setToolTip(button->text()); button->setStatusTip(button->text()); connect(button, SIGNAL(clicked()), signalMapper, SLOT(map())); this->signalMapper->setMapping(button, p->id()); layout->addWidget(button, row, col); col++; i++; if ( col % ButtonsPerLine == 0) { row++; col = 0; } } }
QWidget *Abstract_Widget_List::create_button(QWidget *data, QSignalMapper *mapper, QString icon_name, QString text, QString tooltip) const { QToolButton* btn = new QToolButton; btn->setIcon(QIcon::fromTheme(icon_name)); btn->setText(text); btn->setToolTip(tooltip.isNull() ? btn->text() : tooltip ); connect(btn,SIGNAL(clicked()),mapper,SLOT(map())); mapper->setMapping(btn,data); return btn; }
QToolButton* WizardFiller::getExpandButton(HI::GUITestOpStatus &os){ QToolButton* expandButton = NULL; QWidget* dialog = QApplication::activeModalWidget(); GT_CHECK_RESULT(dialog, "activeModalWidget is NULL",NULL); QWizard* wizard = qobject_cast<QWizard*>(dialog); GT_CHECK_RESULT(wizard, "activeModalWidget is not of wizard type",NULL); QList<QWidget*> widList = wizard->currentPage()->findChildren<QWidget*>(); QList<QToolButton*> plusList; foreach(QWidget* w, widList){ QToolButton* but = qobject_cast<QToolButton*>(w); if (but && but->text()=="+" && abs(but->rect().width()-19)<2) plusList.append(but); }
void sudoku::increaseNumber() { QToolButton *clickedButton = qobject_cast<QToolButton *>(sender()); int digitValue = clickedButton->text().toInt(); //TODO complete //change text of button *check* //change value in array - how can I find out which cordinate the button had? // how are the labeled internally // * can I change the labels? // * how can I access the label? //send new state event to controller // prefix magic clickedButton->setText(QString::number(++digitValue % 10)); }
void tst_QToolBar::widgetAction() { // ensure that a QWidgetAction without widget behaves like a normal action QToolBar tb; QWidgetAction *a = new QWidgetAction(0); a->setIconText("Blah"); tb.addAction(a); QWidget *w = tb.widgetForAction(a); QVERIFY(w); QToolButton *button = qobject_cast<QToolButton *>(w); QVERIFY(button); QCOMPARE(a->iconText(), button->text()); delete a; }
void SettingsDialog::setColorDialog() { QString objName; QToolButton *button = qobject_cast<QToolButton *>(sender()); if (button){ objName = button->objectName(); }else return; QColor color = QColorDialog::getColor(Qt::white, this, button->text(), QColorDialog::DontUseNativeDialog ); button->setStyleSheet("background-color: " + color.name() ); // QString string; // QString r = string.setNum(backgroundColor.red(),10); // QString g = string.setNum(backgroundColor.green(), 10); // QString b = string.setNum(backgroundColor.blue(),10); setStyleSheet(); }
/* FIXME make this less of a hack. */ QRect TestCalendarWidget::visualRect(QString const &item) const { TestWidgetsLog() << item << "my geometry is" << geometry(); QRect ret; QAbstractItemView *view = q->findChild<QAbstractItemView*>(); QtUiTest::ListWidget *calendarView = qtuitest_cast<QtUiTest::ListWidget*>(view); if (!calendarView) { return ret; } ret = calendarView->visualRect(item); if (!ret.isNull()) { ret.moveTopLeft( q->mapFromGlobal( view->mapToGlobal(ret.topLeft()) ) ); TestWidgetsLog() << item << "is a visible day at" << ret; return ret; } QToolButton *yearButton = 0; QToolButton *monthButton = 0; QSpinBox *yearSpin = q->findChild<QSpinBox*>(); QMenu *monthMenu = 0; QList<QToolButton*> blist = q->findChildren<QToolButton*>(); foreach(QToolButton *b, blist) { if (!monthButton && (monthMenu = b->menu())) { monthButton = b; } if (!b->menu()) { yearButton = b; } } TestWidgetsLog() << "monthButton" << monthButton << "yearButton" << yearButton; TestWidgetsLog() << "item" << item << "monthMenu" << monthMenu; if (yearButton && yearButton->isVisible() && yearButton->text() == item) { QPoint p = q->mapFromGlobal( yearButton->mapToGlobal(QPoint(yearButton->width()+5, yearButton->height()/2)) ); ret = QRect(p.x() - 2, p.y() - 2, 5, 5); TestWidgetsLog() << "click near yearbutton"; } else if (yearSpin && yearSpin->isVisible() && yearSpin->value() == item.toInt()) { TestWidgetsLog() << "confirm spinbox"; QPoint p = q->mapFromGlobal( yearSpin->mapToGlobal(QPoint(yearSpin->width()+5, yearSpin->height()/2)) ); ret = QRect(p.x() - 2, p.y() - 2, 5, 5); } else if (monthButton && monthButton->isVisible() && monthButton->text() == item) { QPoint p = q->mapFromGlobal( monthButton->mapToGlobal(QPoint(-5, monthButton->height()/2)) ); ret = QRect(p.x() - 2, p.y() - 2, 5, 5); TestWidgetsLog() << "click near monthbutton"; } else if (monthMenu && monthMenu->isVisible() && qtuitest_cast<QtUiTest::ListWidget*>(monthMenu) && qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->list().contains(item)) { ret = qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->visualRect(item); ret.moveTopLeft( q->mapFromGlobal( monthMenu->mapToGlobal(ret.topLeft()) ) ); TestWidgetsLog() << "click on monthmenu"; } else { do { QStringList items = list(); if (items.contains(item)) { ret = QRect(-1, -1, 1, 1); ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) ); break; } foreach (QString s, items) { if (!s.startsWith(GetListRegExp)) continue; QRegExp re(s.mid(GetListRegExp.length())); if (re.exactMatch(item)) { ret = QRect(-1, -1, 1, 1); ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) ); break; } } if (!ret.isNull()) break; } while(0); } TestWidgetsLog() << "returning rect" << ret; return ret; }