QPushButton * ControlUnitDialog::addFunction(QString title, QIcon icon, bool checkable) { QPushButton *button = new QPushButton(selection_groupBox); selButtons_verticalLayout->insertWidget(_selButtons.size(), button); button->setFixedWidth(160); button->setFixedHeight(35); button->setCheckable(checkable); button->setAutoExclusive(checkable); // Icon: button->setIconSize(QSize(22, 22)); button->setIcon(icon); // Font: QFont font = button->font(); font.setFamily(QApplication::font().family()); font.setBold(false); font.setPixelSize(13); // 10pts button->setFont(font); // Text: prepend/append spaces to achieve proper icon positions: QFontMetrics fm(font); title = title.trimmed(); int targetstrsize = button->size().width() - button->iconSize().width() - 18; int barestrsize = fm.size(Qt::TextShowMnemonic, title).width(); if (barestrsize < targetstrsize) { double spacesize = fm.size(Qt::TextShowMnemonic, " ").width(); int nspaces = static_cast<int>((targetstrsize - barestrsize) / spacesize + 0.5); title.prepend( QString( nspaces/2, ' ' ) ); title.append( QString( nspaces - nspaces/2, ' ' ) ); } button->setText(title); // Save, show and return button: button->show(); _selButtons.push_back(button); return button; }
PlaylistBrowser::PlaylistBrowser(QWidget *parent) : QWidget(parent) { p = new PlaylistBrowsertPrivate; QPushButton* pushSave =new QPushButton(); pushSave->setGeometry(QRect(1,1,60,25)); pushSave->setMaximumWidth(60); pushSave->setMinimumWidth(60); pushSave->setText("+"); QFont pushFont = pushSave->font(); pushFont.setBold(true); pushFont.setPointSize(pushFont.pointSize()+4); pushSave->setFont(pushFont); pushSave->setStyleSheet("QPushButton { border: none; padding-top: -3px; margin-left: 8px;max-height: 20px; margin-right: 28px;}"); pushSave->setToolTip(tr( "Add a new list and store current tracks" )); connect( pushSave,SIGNAL(clicked()),this, SLOT(onPushSave())); QVBoxLayout *mainLayout = new QVBoxLayout; QWidget *headWidget = new QWidget(this); headWidget->setMaximumHeight(35); headWidget->setMinimumHeight(25); QHBoxLayout *headWidgetLayout = new QHBoxLayout; headWidgetLayout->setMargin(0); headWidgetLayout->setSpacing(1); headWidgetLayout->setAlignment(Qt::AlignRight); headWidgetLayout->addWidget(pushSave); headWidget->setLayout(headWidgetLayout); p->listPlaylists = new QListWidget(); p->listPlaylists->setAttribute(Qt::WA_MacShowFocusRect, false); p->database = new CollectionDB(); p->database->executeSql( "PRAGMA synchronous = OFF;" ); updateLists(); headWidget->raise(); mainLayout->addWidget(headWidget); mainLayout->addWidget(p->listPlaylists); mainLayout->setMargin(0); mainLayout->setSpacing(0); setMaximumWidth(400); p->directory = ""; setLayout(mainLayout); }
QPushButton* MainWindow::createTagElement(QString text, QString tag, int count, bool appendCount){ QPushButton* lt = new QPushButton(text, this); if(appendCount) lt->setText(text.append("(").append(QString::number(count)).append(")")); lt->setStyleSheet("background-color:transparent"); lt->setStyleSheet(":hover{background-color: red; font-size: 200%}:pressed{border-radius:5px}:default{background-color:blue}"); lt->setProperty("tag", tag); lt->setProperty("words", count); QFont f = lt->font(); f.setPixelSize(f.pixelSize() + 14 + 2*count); lt->setFont(f); connect(lt, SIGNAL(clicked()), this, SLOT(stdTagClicked())); return lt; }
// add a button QPushButton * QTACFunctions::addButton (QString text) { QFont fnt; QPushButton *btn; QString stylesheet; stylesheet = "background: transparent; border: 1px solid transparent;border-color: darkgray;"; btn = new QPushButton (text, this); btn->setFixedSize (QSize (button_width, button_height)); fnt = btn->font (); fnt.setPixelSize (16); fnt.setBold (true); btn->setFont (fnt); btn->setStyleSheet (stylesheet); btn->setAutoFillBackground (false); btn->setFocusPolicy (Qt::NoFocus); Button += btn; return btn; }
void FindPair::setupButtons() { qsm = new QSignalMapper(this); QGridLayout *mainLayout = new QGridLayout(this); for (int i = 0; i < gSize * gSize; ++i) { QPushButton *tmp = new QPushButton(" ", this); buttons[i] = tmp; tmp->setMinimumSize(30, 30); QFont font = tmp->font(); font.setPointSize(16); tmp->setFont(font); tmp->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); connect(tmp, SIGNAL(clicked()), qsm, SLOT(map())); qsm->setMapping(tmp, i); mainLayout->addWidget(tmp, i % gSize, i / gSize); } connect(qsm, SIGNAL(mapped(int)), this, SLOT(wasClicked(int))); setLayout(mainLayout); }
void MapBox::createOptionsDialog() { if (m_optionsWidget) delete m_optionsWidget; m_optionsWidget = new QWidget(this); QGridLayout * optionsLayout = new QGridLayout; QVector<QString> mapTypeNames; QVector<QGraphicsGeoMap::MapType> mapControlTypes; mapControlTypes.append(QGraphicsGeoMap::StreetMap); mapTypeNames.append(tr("Street")); mapControlTypes.append(QGraphicsGeoMap::SatelliteMapDay); mapTypeNames.append(tr("Satellite")); mapControlTypes.append(QGraphicsGeoMap::SatelliteMapNight); mapTypeNames.append(tr("Satellite - Night")); mapControlTypes.append(QGraphicsGeoMap::TerrainMap); mapTypeNames.append(tr("Terrain")); { // map types QSignalMapper * mapper = new QSignalMapper(m_optionsWidget); connect(mapper, SIGNAL(mapped(int)), this, SLOT(mapTypeToggled(int))); QLabel * mapTypesLabel = new QLabel(tr("Map types")); mapTypesLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mapTypesLabel->setAlignment(Qt::AlignHCenter); optionsLayout->addWidget(mapTypesLabel, 0, 0); QList<QGraphicsGeoMap::MapType> types = m_mapWidget->supportedMapTypes(); for (int controlIndex = 0; controlIndex < mapControlTypes.size(); ++controlIndex) { QPushButton *button = new QPushButton(mapTypeNames[controlIndex], m_optionsWidget); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QFont font = button->font(); font.setPointSize(24); button->setFont(font); optionsLayout->addWidget(button, controlIndex+1, 0); int supportedTypeIndex = types.indexOf(mapControlTypes[controlIndex]); if (supportedTypeIndex == -1) { button->setEnabled(false); } else { connect(button, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(button, mapControlTypes[controlIndex]); button->setEnabled(true); //button->setChecked(mapControlTypes[controlIndex] == m_mapWidget->mapType()); } } } { // connectivity modes QVector<QString> connectivityModeNames; QVector<QGraphicsGeoMap::ConnectivityMode> connectivityModes; connectivityModes.append(QGraphicsGeoMap::NoConnectivity); connectivityModeNames.append(tr("No connectivity")); connectivityModes.append(QGraphicsGeoMap::OfflineMode); connectivityModeNames.append(tr("Offline")); connectivityModes.append(QGraphicsGeoMap::OnlineMode); connectivityModeNames.append(tr("Online")); connectivityModes.append(QGraphicsGeoMap::HybridMode); connectivityModeNames.append(tr("Hybrid")); // map types QSignalMapper * mapper = new QSignalMapper(m_optionsWidget); connect(mapper, SIGNAL(mapped(int)), this, SLOT(connectivityModeToggled(int))); QLabel * connectivityModesLabel = new QLabel(tr("Connectivity")); connectivityModesLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connectivityModesLabel->setAlignment(Qt::AlignHCenter); optionsLayout->addWidget(connectivityModesLabel, 0, 1); QList<QGraphicsGeoMap::ConnectivityMode> modes = m_mapWidget->supportedConnectivityModes(); for (int controlIndex = 0; controlIndex < connectivityModes.size(); ++controlIndex) { QPushButton *button = new QPushButton(connectivityModeNames[controlIndex], m_optionsWidget); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QFont font = button->font(); font.setPointSize(24); button->setFont(font); optionsLayout->addWidget(button, controlIndex+1, 1); int supportedTypeIndex = modes.indexOf(connectivityModes[controlIndex]); if (supportedTypeIndex == -1) { button->setEnabled(false); } else { connect(button, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(button, connectivityModes[controlIndex]); button->setEnabled(true); //button->setChecked(connectivityModes[controlIndex] == m_mapWidget->connectivityMode()); } } } /* { // plugins, TODO QList<QString> providers = QGeoServiceProvider::availableServiceProviders(); for (int i = 0; i < providers.count(); ++i) { QAction *providerAction = new QAction(providers[i], this); providerAction->setCheckable(true); providerAction->setChecked(i == 0); m_pluginMenu->addAction(providerAction); } } */ m_optionsWidget->setLayout(optionsLayout); if (displayMode() == DisplayOptions) { setDisplayMode(DisplayNone); setDisplayMode(DisplayOptions); } }
DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Enter number" ) ); QVBoxLayout *mainLayout = new QVBoxLayout( this ); QLabel *textLabel = new QLabel( this ); textLabel->setTextFormat( QLabel::RichText ); textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); m_dialLine = new QLineEdit( this ); m_dialLine->setReadOnly( true ); m_dialLine->setFrame( false ); m_dialLine->setAlignment( Qt::AlignLeft ); QFont dialLine_font( m_dialLine->font() ); dialLine_font.setBold( TRUE ); dialLine_font.setPointSize( 18 ); m_dialLine->setFont( dialLine_font ); QWidget* dialWidget = new QWidget( this ); QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 ); QButtonGroup *dialButtons = new QButtonGroup( ); QPushButton *number0 = new QPushButton( dialWidget ); number0->setText( QString( "0" ) ); QFont number0_font( number0->font() ); number0_font.setBold( TRUE ); number0->setFont( number0_font ); layout->addWidget( number0, 4, 1 ); dialButtons->insert( number0 ); int x = 0, y = 0; for ( int i = 0 ; i < 9; i++ ) { QPushButton *number = new QPushButton( dialWidget ); number->setText( QString( "%1" ).arg( i + 1 ) ); QFont number_font( number->font() ); number_font.setBold( TRUE ); number->setFont( number_font ); dialButtons->insert( number ); layout->addWidget( number, x, y ); if ( y < 2 ) { y++; } else { x++; y = 0; } } connect( dialButtons, SIGNAL( clicked(int) ), this, SLOT( slotEnterNumber(int) ) ); mainLayout->addStretch( 2 ); mainLayout->addWidget( textLabel ); mainLayout->addStretch( 1 ); mainLayout->addWidget( m_dialLine ); mainLayout->addStretch( 2 ); mainLayout->addWidget( dialWidget ); mainLayout->addStretch( 4 ); }
dlgStdPad::dlgStdPad(_cfg_port *cfg_port, QWidget *parent = 0) : QDialog(parent) { QFont f9, f8; f9.setPointSize(9); f9.setWeight(QFont::Light); f8.setPointSize(8); f8.setWeight(QFont::Light); memset(&data, 0x00, sizeof(data)); memcpy(&data.cfg, cfg_port, sizeof(_cfg_port)); setupUi(this); setFont(parent->font()); groupBox_controller->setTitle(tr("Controller %1 : Standard Pad").arg(cfg_port->id)); tabWidget->setCurrentIndex(JOYSTICK); combo_id_init(); for (int a = KEYBOARD; a <= JOYSTICK; a++) { QPlainTextEdit *txt; QPushButton *bt; txt = findChild<QPlainTextEdit *>("plainTextEdit_" + SPT(a) + "_info"); if (txt->font().pointSize() > 9) { txt->setFont(f9); } bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Sequence"); bt->setProperty("myType", QVariant(a)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_in_sequence_clicked(bool))); bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Unset_all"); bt->setProperty("myType", QVariant(a)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_unset_all_clicked(bool))); bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Defaults"); bt->setProperty("myType", QVariant(a)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_defaults_clicked(bool))); for (int b = BUT_A; b < MAX_STD_PAD_BUTTONS; b++) { int vbutton = b + (a * MAX_STD_PAD_BUTTONS); QPushButton *unset; bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_" + SPB(b)); unset = findChild<QPushButton *>("pushButton_" + SPT(a) + "_unset_" + SPB(b)); if (bt->font().pointSize() > 9) { bt->setFont(f9); } if (unset->font().pointSize() > 8) { unset->setFont(f8); } if (a == KEYBOARD) { bt->setText(inpObject::kbd_keyval_to_name(data.cfg.port.input[a][b])); } else { bt->setText(uQString(jsv_to_name(data.cfg.port.input[a][b]))); } bt->installEventFilter(this); bt->setProperty("myVbutton", QVariant(vbutton)); unset->setProperty("myVbutton", QVariant(vbutton)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_input_clicked(bool))); connect(unset, SIGNAL(clicked(bool)), this, SLOT(s_unset_clicked(bool))); } } { comboBox_Controller_type->addItem(tr("Auto")); comboBox_Controller_type->addItem(tr("Original")); comboBox_Controller_type->addItem(tr("3rd-party")); comboBox_Controller_type->setCurrentIndex(data.cfg.port.type_pad); connect(comboBox_Controller_type, SIGNAL(activated(int)), this, SLOT(s_combobox_controller_type_activated(int))); } for (int i = TURBOA; i <= TURBOB; i++) { QSlider *tb = findChild<QSlider *>("horizontalSlider_" + SPB(i + TRB_A)); QLabel *label = findChild<QLabel *>("label_value_slider_" + SPB(i + TRB_A)); tb->setRange(1, TURBO_BUTTON_DELAY_MAX); tb->setProperty("myTurbo", QVariant(i)); tb->setValue(data.cfg.port.turbo[i].frequency); connect(tb, SIGNAL(valueChanged(int)), this, SLOT(s_slider_td_value_changed(int))); label->setFixedWidth(label->sizeHint().width()); td_update_label(i, data.cfg.port.turbo[i].frequency); } pushButton_Apply->setProperty("myPointer", QVariant::fromValue(((void *)cfg_port))); connect(pushButton_Apply, SIGNAL(clicked(bool)), this, SLOT(s_apply_clicked(bool))); connect(pushButton_Discard, SIGNAL(clicked(bool)), this, SLOT(s_discard_clicked(bool))); setAttribute(Qt::WA_DeleteOnClose); setFixedSize(width(), height()); setFocusPolicy(Qt::StrongFocus); groupBox_controller->setFocus(Qt::ActiveWindowFocusReason); data.joy.timer = new QTimer(this); connect(data.joy.timer, SIGNAL(timeout()), this, SLOT(s_pad_joy_read_timer())); data.seq.timer = new QTimer(this); connect(data.seq.timer, SIGNAL(timeout()), this, SLOT(s_pad_in_sequence_timer())); installEventFilter(this); }