//==================================================================================================== FillSelector::FillSelector(QWidget *parent) : QFrame(parent){ for (int i=0; i<FILL_BUTTONS; i++){ QToolButton *tb = new QToolButton(this); tb->setMaximumSize(FILL_BUTTON_SIZE); tb->setObjectName(QString("fillButton").append(QString::number(i))); tb->setCheckable(true); buttongroup.addButton(tb); buttongroup.setId(tb, i); buttons.push_back(tb); } buttongroup.button(0)->setChecked(true); layout = new QGridLayout(this); layout->setSpacing(3); layout->setObjectName(QStringLiteral("fillLayout")); layout->setContentsMargins(1, 1, 1, 1); int r = 0; int c = 0; for (QToolButton *tb : buttons){ layout->addWidget(tb, r, c, 1, 1); c++; if (c==FILL_COLUMNS){ c = 0; r++; } } createIcons(); //this->setFixedSize(FILL_FRAME_SIZE); };
void FilePathPropertyEditor::onInitialize() { QWidget* frame = new QWidget( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); layout->setSpacing( 0 ); layout->setMargin( 0 ); frame->setLayout( layout ); addWidget( frame ); // a field that shows the resource m_droppedFilePath = new DropArea( frame, new FSNodeMimeData( m_paths ) ); connect( m_droppedFilePath, SIGNAL( changed() ), this, SLOT( valChanged() ) ); m_droppedFilePath->setMinimumSize( 20, 20 ); m_droppedFilePath->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); layout->addWidget( m_droppedFilePath ); // a button for NULLing the resource QToolButton* eraseButton = new QToolButton( frame ); eraseButton->setIcon( QIcon( ":/TamyEditor/Resources/Icons/Editor/quit.png" ) ); eraseButton->setToolTip( "Reset value" ); connect( eraseButton, SIGNAL( clicked( bool ) ), this, SLOT( valErased( bool ) ) ); eraseButton->setMinimumSize( 20, 20 ); eraseButton->setMaximumSize( 20, 20 ); eraseButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); layout->addWidget( eraseButton ); refreshPropertyName(); }
QWidget *QgsLocatorFiltersModel::configButton( const QModelIndex &index, QWidget *parent ) const { if ( !index.isValid() ) return nullptr; QgsLocatorFilter *filter = filterForIndex( index ); if ( filter && filter->hasConfigWidget() ) { // use a layout to get the button center aligned QWidget *w = new QWidget( parent ); QToolButton *bt = new QToolButton( ); QHBoxLayout *layout = new QHBoxLayout(); layout->setContentsMargins( 0, 0, 0, 0 ); layout->addWidget( bt ); w->setLayout( layout ); connect( bt, &QToolButton::clicked, this, [ = ]() {filter->openConfigWidget( bt );} ); bt->setMaximumSize( mIconSize, mIconSize ); bt->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); bt->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/settings.svg" ) ) ); return w; } else { return nullptr; } }
QToolButton* ToolBar::createToolButton(QAction *act) { QToolButton *toolButton = new QToolButton(); toolButton->setMinimumSize(QSize(30, 30)); toolButton->setMaximumSize(QSize(30, 30)); toolButton->setDefaultAction(act); toolButton->setStatusTip(act->text()); return toolButton; }
QToolButton *TitleBarWidget::addButton(QBoxLayout *layout, const char *iconPath, ToolWindowSlot slot) { QToolButton *button = new QToolButton(); button->setAutoRaise(true); if (iconPath) button->setIcon(QIcon(iconPath)); button->setMaximumSize(QSize(15, 15)); button->setMinimumSize(button->maximumSize()); button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QObject::connect(button, &QPushButton::clicked, tool_window, slot); layout->addWidget(button); layout->setAlignment(button, Qt::AlignLeft); return button; }
void FileRenamerDlgImpl::resizeIcons() { vector<QToolButton*> v; v.push_back(m_pPrevB); v.push_back(m_pNextB); v.push_back(m_pEditPatternsB); v.push_back(m_pRenameB); int k (m_pCommonData->m_nMainWndIconSize); for (int i = 0, n = cSize(v); i < n; ++i) { QToolButton* p (v[i]); p->setMaximumSize(k, k); p->setMinimumSize(k, k); p->setIconSize(QSize(k - 4, k - 4)); } }
QToolButton * TREE_ARAMA_KERNEL::ADD_BUTTON ( QString button_text,Qt::ToolButtonStyle style,QString icon,int height,int width ) { QToolButton * button = new QToolButton; button->setText ( button_text ); button->setIcon ( QIcon ( icon ) ); button->setToolButtonStyle( style ); if ( height NE -1 AND width NE -1 ) { button->setMinimumSize(height,width); button->setMaximumSize(height,width); } p_h_box_layout->addWidget ( button ); connect(button, SIGNAL ( clicked() ), this, SLOT ( SLOT_BUTTON_CLICKED() ) ); return button; }
MediaSearchWidget::MediaSearchWidget(QWidget *parent) : QWidget(parent) { // m_animate = new StateMachineServer; this->setMinimumSize(160, 20); this->setFixedSize(160, 20); m_searchKeyEdit = new QLineEdit; m_searchKeyEdit->setText( tr("Searching...") ); QToolButton* searchBtn = new QToolButton; QSize size = QSize( 20, this->size().height() ); searchBtn->setMinimumSize(size); searchBtn->setMaximumSize(size); searchBtn->setIconSize(size); searchBtn->setIcon( QIcon(":/images/Button-search.png")); searchBtn->setFocusPolicy(Qt::NoFocus);// 得到焦点时,不显示虚线框 searchBtn->setCursor(QCursor(Qt::PointingHandCursor)); QHBoxLayout *editLayout = new QHBoxLayout(); editLayout->setContentsMargins(0, 0, 0, 0); editLayout->addStretch(); editLayout->addWidget(searchBtn); m_searchKeyEdit->setLayout(editLayout); // 设置输入框中文件输入区,不让输入的文字在被隐藏在按钮下 m_searchKeyEdit->setTextMargins(0, 1, size.width(), 1); QHBoxLayout* hLayout = new QHBoxLayout; hLayout->setContentsMargins(0,0,0,0); hLayout->setSpacing(4); hLayout->addWidget(m_searchKeyEdit); hLayout->setAlignment(Qt::AlignLeft); this->setLayout(hLayout); connect(searchBtn, SIGNAL(clicked()), this, SLOT(searchMusic()) ); // connect(this, SIGNAL(animateHide()), m_animate, SIGNAL(transHide()) ); // /connect(this, SIGNAL(animateShow()), m_animate, SIGNAL(transShow()) ); }
/********************************************************************** * Speed control widget **********************************************************************/ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent ) : QFrame( _parent ), p_intf( _p_i ) { QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setVerticalStretch( 0 ); speedSlider = new QSlider( this ); speedSlider->setSizePolicy( sizePolicy ); speedSlider->setMaximumSize( QSize( 80, 200 ) ); speedSlider->setOrientation( Qt::Vertical ); speedSlider->setTickPosition( QSlider::TicksRight ); speedSlider->setRange( -34, 34 ); speedSlider->setSingleStep( 1 ); speedSlider->setPageStep( 1 ); speedSlider->setTickInterval( 17 ); CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) ); QToolButton *normalSpeedButton = new QToolButton( this ); normalSpeedButton->setMaximumSize( QSize( 26, 20 ) ); normalSpeedButton->setAutoRaise( true ); normalSpeedButton->setText( "1x" ); normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) ); CONNECT( normalSpeedButton, clicked(), this, resetRate() ); QVBoxLayout *speedControlLayout = new QVBoxLayout( this ); speedControlLayout->setContentsMargins( 4, 4, 4, 4 ); speedControlLayout->setSpacing( 4 ); speedControlLayout->addWidget( speedSlider ); speedControlLayout->addWidget( normalSpeedButton ); lastValue = 0; activateOnState(); }
GraphHierarchiesEditor::GraphHierarchiesEditor(QWidget *parent): QWidget(parent), _ui(new Ui::GraphHierarchiesEditorData), _contextGraph(NULL), _model(NULL) { _ui->setupUi(this); _ui->hierarchiesTree->addAction(_ui->actionDelete_All); _ui->actionDelete_All->setShortcutContext(Qt::WidgetWithChildrenShortcut); QToolButton* linkButton = new QToolButton(); linkButton->setObjectName("linkButton"); linkButton->setIcon(QIcon(":/tulip/gui/icons/16/link.png")); linkButton->setToolTip("Click here to disable the synchronization with workspace active panel.\nWhen synchronization is enabled, the graph currently displayed\nin the active panel, becomes the current one in the Graphs panel."); linkButton->setIconSize(QSize(22,22)); linkButton->setMinimumSize(25,25); linkButton->setMaximumSize(25,25); linkButton->setCheckable(true); linkButton->setChecked(true); _ui->header->insertWidget(linkButton); _linkButton = linkButton; connect(linkButton, SIGNAL(toggled(bool)), this, SLOT(toggleSynchronization(bool))); _ui->hierarchiesTree->installEventFilter(this); connect(_ui->hierarchiesTree, SIGNAL(clicked(const QModelIndex &)), this, SLOT(clicked(const QModelIndex &))); }
QT_BEGIN_NAMESPACE PropertyEditor::PropertyEditor(QWidget *widget, QModelingObject *modelingObject, QMetaProperty *metaProperty, QWidget *parent) : QWidget(parent), _widget(widget), _modelingObject(modelingObject), _metaProperty(metaProperty) { QHBoxLayout *layout = new QHBoxLayout; layout->setMargin(0); layout->setSpacing(0); layout->addWidget(_widget); if (widget && _metaProperty->isResettable()) { QToolButton *toolButton = new QToolButton; toolButton->setIcon(QPixmap(QString::fromLatin1(":/icons/resetproperty.png"))); toolButton->setMaximumSize(22, 22); toolButton->setEnabled(_modelingObject->isPropertyModified(*_metaProperty)); connect(toolButton, &QToolButton::clicked, this, &PropertyEditor::resetClicked); layout->addWidget(toolButton); } setLayout(layout); if (QComboBox *comboBox = qobject_cast<QComboBox *>(_widget)) connect(comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &PropertyEditor::currentIndexChanged); if (QCheckBox *checkBox = qobject_cast<QCheckBox *>(_widget)) connect(checkBox, &QCheckBox::stateChanged, this, &PropertyEditor::currentIndexChanged); }
/********************************************************************** * Speed control widget **********************************************************************/ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent ) : QFrame( _parent ), p_intf( _p_i ) { QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Maximum ); sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setVerticalStretch( 0 ); speedSlider = new QSlider( this ); speedSlider->setSizePolicy( sizePolicy ); speedSlider->setMinimumSize( QSize( 140, 20 ) ); speedSlider->setOrientation( Qt::Horizontal ); speedSlider->setTickPosition( QSlider::TicksBelow ); speedSlider->setRange( -34, 34 ); speedSlider->setSingleStep( 1 ); speedSlider->setPageStep( 1 ); speedSlider->setTickInterval( 17 ); CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) ); QToolButton *normalSpeedButton = new QToolButton( this ); normalSpeedButton->setMaximumSize( QSize( 26, 16 ) ); normalSpeedButton->setAutoRaise( true ); normalSpeedButton->setText( "1x" ); normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) ); CONNECT( normalSpeedButton, clicked(), this, resetRate() ); QToolButton *slowerButton = new QToolButton( this ); slowerButton->setMaximumSize( QSize( 26, 16 ) ); slowerButton->setAutoRaise( true ); slowerButton->setToolTip( tooltipL[SLOWER_BUTTON] ); slowerButton->setIcon( QIcon( iconL[SLOWER_BUTTON] ) ); CONNECT( slowerButton, clicked(), THEMIM->getIM(), slower() ); QToolButton *fasterButton = new QToolButton( this ); fasterButton->setMaximumSize( QSize( 26, 16 ) ); fasterButton->setAutoRaise( true ); fasterButton->setToolTip( tooltipL[FASTER_BUTTON] ); fasterButton->setIcon( QIcon( iconL[FASTER_BUTTON] ) ); CONNECT( fasterButton, clicked(), THEMIM->getIM(), faster() ); /* spinBox = new QDoubleSpinBox(); spinBox->setDecimals( 2 ); spinBox->setMaximum( 32 ); spinBox->setMinimum( 0.03F ); spinBox->setSingleStep( 0.10F ); spinBox->setAlignment( Qt::AlignRight ); CONNECT( spinBox, valueChanged( double ), this, updateSpinBoxRate( double ) ); */ QGridLayout* speedControlLayout = new QGridLayout( this ); speedControlLayout->addWidget( speedSlider, 0, 0, 1, 3 ); speedControlLayout->addWidget( slowerButton, 1, 0 ); speedControlLayout->addWidget( normalSpeedButton, 1, 1, 1, 1, Qt::AlignRight ); speedControlLayout->addWidget( fasterButton, 1, 2, 1, 1, Qt::AlignRight ); //speedControlLayout->addWidget( spinBox ); speedControlLayout->setContentsMargins( 0, 0, 0, 0 ); speedControlLayout->setSpacing( 0 ); lastValue = 0; activateOnState(); }
// adds dynamic actions to the toolbar (example settings) void RenderWindow::slotPopulateToolbar(bool completeRefresh) { WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) started", 2); QDir toolbarDir = QDir(systemData.dataDirectory + "toolbar"); toolbarDir.setSorting(QDir::Time); QStringList toolbarFiles = toolbarDir.entryList(QDir::NoDotAndDotDot | QDir::Files); QSignalMapper *mapPresetsFromExamplesLoad = new QSignalMapper(this); QSignalMapper *mapPresetsFromExamplesRemove = new QSignalMapper(this); ui->toolBar->setIconSize( QSize(gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"))); QList<QAction *> actions = ui->toolBar->actions(); QStringList toolbarInActions; for (int i = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (action->objectName() == "actionAdd_Settings_to_Toolbar") continue; if (!toolbarFiles.contains(action->objectName()) || completeRefresh) { // preset has been removed ui->toolBar->removeAction(action); } else { toolbarInActions << action->objectName(); } } for (int i = 0; i < toolbarFiles.size(); i++) { if (toolbarInActions.contains(toolbarFiles.at(i))) { // already present continue; } QString filename = systemData.dataDirectory + "toolbar/" + toolbarFiles.at(i); cThumbnailWidget *thumbWidget = NULL; if (QFileInfo(filename).suffix() == QString("fract")) { WriteLogString("Generating thumbnail for preset", filename, 2); cSettings parSettings(cSettings::formatFullText); parSettings.BeQuiet(true); if (parSettings.LoadFromFile(filename)) { cParameterContainer *par = new cParameterContainer; cFractalContainer *parFractal = new cFractalContainer; InitParams(par); for (int i = 0; i < NUMBER_OF_FRACTALS; i++) InitFractalParams(&parFractal->at(i)); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, par); /*******************************************************************/ if (parSettings.Decode(par, parFractal)) { thumbWidget = new cThumbnailWidget( gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"), 2, this); thumbWidget->UseOneCPUCore(true); thumbWidget->AssignParameters(*par, *parFractal); } delete par; delete parFractal; } } if (thumbWidget) { QWidgetAction *action = new QWidgetAction(this); QToolButton *buttonLoad = new QToolButton; QVBoxLayout *tooltipLayout = new QVBoxLayout; QToolButton *buttonRemove = new QToolButton; tooltipLayout->setContentsMargins(3, 3, 3, 3); tooltipLayout->addWidget(thumbWidget); QIcon iconDelete = QIcon::fromTheme("list-remove", QIcon(":system/icons/list-remove.svg")); buttonRemove->setIcon(iconDelete); buttonRemove->setMaximumSize(QSize(15, 15)); buttonRemove->setStyleSheet("margin-bottom: -2px; margin-left: -2px;"); tooltipLayout->addWidget(buttonRemove); buttonLoad->setToolTip(QObject::tr("Toolbar settings: ") + filename); buttonLoad->setLayout(tooltipLayout); action->setDefaultWidget(buttonLoad); action->setObjectName(toolbarFiles.at(i)); ui->toolBar->addAction(action); mapPresetsFromExamplesLoad->setMapping(buttonLoad, filename); mapPresetsFromExamplesRemove->setMapping(buttonRemove, filename); QApplication::connect(buttonLoad, SIGNAL(clicked()), mapPresetsFromExamplesLoad, SLOT(map())); QApplication::connect( buttonRemove, SIGNAL(clicked()), mapPresetsFromExamplesRemove, SLOT(map())); } } QApplication::connect( mapPresetsFromExamplesLoad, SIGNAL(mapped(QString)), this, SLOT(slotMenuLoadPreset(QString))); QApplication::connect(mapPresetsFromExamplesRemove, SIGNAL(mapped(QString)), this, SLOT(slotMenuRemovePreset(QString))); WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) finished", 2); }
controlMainWindow::controlMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::controlMainWindow) { ui->setupUi(this); ui->statusBar->addWidget(&m_txWidget); connect(&m_socketClient,SIGNAL(tx()),&m_txWidget,SLOT(tx())); connect(&m_socketClient,SIGNAL(rx()),&m_txWidget,SLOT(rx())); //Botones para la barra de herramientas: QToolButton* btnConnect = new QToolButton(this); btnConnect->setMinimumSize(64,64); btnConnect->setMaximumSize(64,64); btnConnect->setIcon(QIcon(":/icons/icons/connect-icon.png")); btnConnect->setIconSize(QSize(64,64)); connect(btnConnect,SIGNAL(toggled(bool)),ui->connectionWidget,SLOT(connectSocket(bool))); btnConnect->setCheckable(true); QToolButton* btnShowSensors = new QToolButton(this); btnShowSensors->setText("Sensors"); btnShowSensors->setCheckable(true); btnShowSensors->setChecked(false); connect(btnShowSensors,SIGNAL(toggled(bool)),ui->sensorViewWidget,SLOT(setVisible(bool))); connect(btnShowSensors,SIGNAL(toggled(bool)),&m_socketClient,SLOT(requestSensorData(bool))); QToolButton* btnShowBright = new QToolButton(this); btnShowBright->setText("Bright"); btnShowBright->setCheckable(true); btnShowBright->setChecked(false); connect(btnShowBright,SIGNAL(toggled(bool)),ui->groupBrightness,SLOT(setVisible(bool))); QToolButton* btnOffsetTool = new QToolButton(this); btnOffsetTool->setText("OffsetTool"); btnOffsetTool->setCheckable(true); btnOffsetTool->setChecked(false); connect(btnOffsetTool,SIGNAL(toggled(bool)),ui->groupOffset ,SLOT(setVisible(bool))); QToolButton* btnShowEffects = new QToolButton(this); btnShowEffects->setText("Effects"); btnShowEffects->setCheckable(true); btnShowEffects->setChecked(true); connect(btnShowEffects,SIGNAL(toggled(bool)),ui->effectsWidget ,SLOT(setVisible(bool))); ui->mainToolBar->addWidget(btnConnect); ui->mainToolBar->addWidget(btnShowSensors); ui->mainToolBar->addWidget(btnShowBright); ui->mainToolBar->addWidget(btnShowEffects); ui->mainToolBar->addWidget(btnOffsetTool); // ui->sensorViewWidget->hide(); // ui->effectsWidget->hide(); ui->groupBrightness->hide(); ui->groupOffset->hide(); connect(ui->connectionWidget,SIGNAL(ready()) ,this,SLOT(enableUI())); connect(ui->connectionWidget,SIGNAL(notReady()) ,this,SLOT(disableUI())); ui->connectionWidget->setClient(&m_socketClient); ui->sensorViewWidget->setClient(&m_socketClient); connect(ui->btnOff, SIGNAL(clicked(bool)),&m_socketClient, SLOT(off())); connect(ui->btnNext, SIGNAL(clicked(bool)),&m_socketClient, SLOT(nextEffect())); connect(ui->btnPrev, SIGNAL(clicked(bool)),&m_socketClient, SLOT(prevEffect())); connect(ui->btnCircle, SIGNAL(clicked(bool)),&m_socketClient, SLOT(animationCircle())); connect(ui->btnDoubleCircle, SIGNAL(clicked(bool)),&m_socketClient, SLOT(animationDoubleCircle())); connect(ui->btnRainbow, SIGNAL(clicked(bool)),&m_socketClient, SLOT(animationRainbow())); connect(ui->btnFlash , SIGNAL(clicked(bool)),&m_socketClient, SLOT(animationFlash())); connect(ui->btnSetColor, SIGNAL(clicked(bool)),this, SLOT(setColor())); connect(ui->sliderBrightness, SIGNAL(valueChanged(int)),this, SLOT(setBrightness(int))); connect(ui->dialOffset, SIGNAL(valueChanged(int)),&m_socketClient,SLOT(setOffset(int))); disableUI(); }