QgsColorButtonV2::QgsColorButtonV2( QWidget *parent, QString cdt, QColorDialog::ColorDialogOptions cdo, QgsColorSchemeRegistry* registry ) : QToolButton( parent ) , mBehaviour( QgsColorButtonV2::ShowDialog ) , mColorDialogTitle( cdt.isEmpty() ? tr( "Select Color" ) : cdt ) , mColor( QColor() ) , mDefaultColor( QColor() ) //default to invalid color , mColorDialogOptions( cdo ) , mAcceptLiveUpdates( true ) , mColorSet( false ) , mShowNoColorOption( false ) , mNoColorString( tr( "No color" ) ) , mPickingColor( false ) , mMenu( 0 ) { //if a color scheme registry was specified, use it, otherwise use the global instance mColorSchemeRegistry = registry ? registry : QgsColorSchemeRegistry::instance(); setAcceptDrops( true ); setMinimumSize( QSize( 24, 16 ) ); connect( this, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); //setup dropdown menu mMenu = new QMenu( this ); connect( mMenu, SIGNAL( aboutToShow() ), this, SLOT( prepareMenu() ) ); setMenu( mMenu ); setPopupMode( QToolButton::MenuButtonPopup ); }
QgsColorButton::QgsColorButton( QWidget *parent, const QString &cdt, QgsColorSchemeRegistry *registry ) : QToolButton( parent ) , mColorDialogTitle( cdt.isEmpty() ? tr( "Select Color" ) : cdt ) , mNoColorString( tr( "No color" ) ) { //if a color scheme registry was specified, use it, otherwise use the global instance mColorSchemeRegistry = registry ? registry : QgsApplication::colorSchemeRegistry(); setAcceptDrops( true ); setMinimumSize( QSize( 24, 16 ) ); connect( this, &QAbstractButton::clicked, this, &QgsColorButton::buttonClicked ); //setup drop-down menu mMenu = new QMenu( this ); connect( mMenu, &QMenu::aboutToShow, this, &QgsColorButton::prepareMenu ); setMenu( mMenu ); setPopupMode( QToolButton::MenuButtonPopup ); #ifdef Q_OS_WIN mMinimumSize = QSize( 120, 22 ); #else mMinimumSize = QSize( 120, 28 ); #endif mMinimumSize.setHeight( std::max( static_cast<int>( fontMetrics().height() * 1.1 ), mMinimumSize.height() ) ); }
MenuButtonWidget::MenuButtonWidget(const ToolBarsManager::ToolBarDefinition::Entry &definition, QWidget *parent) : ToolButtonWidget(definition, parent), m_menu(new Menu(Menu::NoMenuRole, this)), m_isHidden(false) { setIcon(ThemesManager::createIcon(QLatin1String("otter-browser"), false)); setText(definition.options.value(QLatin1String("text"), tr("Menu")).toString()); setMenu(m_menu); setPopupMode(QToolButton::InstantPopup); setButtonStyle(Qt::ToolButtonTextBesideIcon); handleActionsStateChanged({ActionsManager::ShowToolBarAction}); const MainWindow *mainWindow(MainWindow::findMainWindow(this)); const ToolBarWidget *toolBar(qobject_cast<ToolBarWidget*>(parent)); if (mainWindow) { connect(mainWindow, &MainWindow::arbitraryActionsStateChanged, this, &MenuButtonWidget::handleActionsStateChanged); } if (toolBar) { disconnect(toolBar, &ToolBarWidget::buttonStyleChanged, this, &MenuButtonWidget::setButtonStyle); } connect(m_menu, &Menu::aboutToShow, this, &MenuButtonWidget::updateMenu); }
OutPatternButton::OutPatternButton(QWidget * parent): QToolButton(parent) { setPopupMode(QToolButton::InstantPopup); setMenu(new QMenu(this)); mSeparator = menu()->addSeparator(); }
MenuButton::MenuButton(QWidget *parent) : ToolButton(parent) { setPopupMode(QToolButton::InstantPopup); setIcon(Icons::self()->menuIcon); setToolTip(i18n("Other Actions")); }
// +----------------------------------------------------------- fsdk::VolumeButton::VolumeButton(QWidget *pParent) : QToolButton(pParent) { setPopupMode(QToolButton::InstantPopup); QWidget *pPopup = new QWidget(this); m_pSlider = new CustomSlider(this); m_pSlider->setStyleSheet(SLIDER_STYLE_SHEET); connect(m_pSlider, &QAbstractSlider::valueChanged, this, &VolumeButton::sliderValueChanged); m_pLabel = new QLabel(this); m_pLabel->setAlignment(Qt::AlignCenter); m_pLabel->setText("100%"); m_pLabel->setMinimumWidth(m_pLabel->sizeHint().width()); QBoxLayout *pPopupLayout = new QHBoxLayout(pPopup); pPopupLayout->setMargin(2); pPopupLayout->addWidget(m_pSlider); pPopupLayout->addWidget(m_pLabel); m_pVolumeAction = new QWidgetAction(this); m_pVolumeAction->setDefaultWidget(pPopup); m_pMenu = new QMenu(this); m_pMenu->addAction(m_pVolumeAction); setMenu(m_pMenu); setVolume(100); }
void QgsColorRampButton::setShowMenu( const bool showMenu ) { setMenu( showMenu ? mMenu : nullptr ); setPopupMode( showMenu ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup ); //force recalculation of icon size mIconSize = QSize(); setButtonBackground( mColorRamp ); }
PHIAComboButton::PHIAComboButton( QWidget *parent ) : QToolButton( parent ), _popup( 0 ) { qDebug( "PHIAComboButton::PHIAComboButton()" ); setPopupMode( QToolButton::InstantPopup ); setEnabled( false ); setVisible( false ); }
QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent, const QgsVectorLayer *layer ) : QToolButton( parent ) , mVectorLayer( layer ) { setFocusPolicy( Qt::StrongFocus ); int iconSize = QgsGuiUtils::scaleIconSize( 24 ); // button width is 1.25 * icon size, height 1.1 * icon size. But we round to ensure even pixel sizes for equal margins setFixedSize( 2 * static_cast< int >( 1.25 * iconSize / 2.0 ), 2 * static_cast< int >( iconSize * 1.1 / 2.0 ) ); setIconSize( QSize( iconSize, iconSize ) ); setPopupMode( QToolButton::InstantPopup ); connect( this, &QgsPropertyOverrideButton::activated, this, &QgsPropertyOverrideButton::updateSiblingWidgets ); mDefineMenu = new QMenu( this ); connect( mDefineMenu, &QMenu::aboutToShow, this, &QgsPropertyOverrideButton::aboutToShowMenu ); connect( mDefineMenu, &QMenu::triggered, this, &QgsPropertyOverrideButton::menuActionTriggered ); setMenu( mDefineMenu ); mFieldsMenu = new QMenu( this ); mActionDataTypes = new QAction( this ); // list fields and types in submenu, since there may be many mActionDataTypes->setMenu( mFieldsMenu ); mActionVariables = new QAction( tr( "Variable" ), this ); mVariablesMenu = new QMenu( this ); mActionVariables->setMenu( mVariablesMenu ); mActionColors = new QAction( tr( "Color" ), this ); mColorsMenu = new QMenu( this ); mActionColors->setMenu( mColorsMenu ); mActionActive = new QAction( this ); QFont f = mActionActive->font(); f.setBold( true ); mActionActive->setFont( f ); mActionDescription = new QAction( tr( "Description…" ), this ); mActionCreateAuxiliaryField = new QAction( tr( "Store Data in the Project" ), this ); mActionCreateAuxiliaryField->setCheckable( true ); mActionExpDialog = new QAction( tr( "Edit…" ), this ); mActionExpression = nullptr; mActionPasteExpr = new QAction( tr( "Paste" ), this ); mActionCopyExpr = new QAction( tr( "Copy" ), this ); mActionClearExpr = new QAction( tr( "Clear" ), this ); mActionAssistant = new QAction( tr( "Assistant…" ), this ); QFont assistantFont = mActionAssistant->font(); assistantFont.setBold( true ); mActionAssistant->setFont( assistantFont ); mDefineMenu->addAction( mActionAssistant ); }
MenuButton::MenuButton(QWidget *parent) : QToolButton(parent) { setAutoRaise(true); setPopupMode(QToolButton::InstantPopup); setFocusPolicy(Qt::NoFocus); setStyleSheet("QToolButton::menu-indicator { image: none; }"); setIcon(APP_ICON("menu")); }
QgsDataDefinedButton::QgsDataDefinedButton( QWidget* parent, const QgsVectorLayer* vl, const QgsDataDefined* datadefined, DataTypes datatypes, QString description ) : QToolButton( parent ) { // set up static icons if ( mIconDataDefine.isNull() ) { mIconDataDefine = QgsApplication::getThemeIcon( "/mIconDataDefine.svg" ); mIconDataDefineOn = QgsApplication::getThemeIcon( "/mIconDataDefineOn.svg" ); mIconDataDefineError = QgsApplication::getThemeIcon( "/mIconDataDefineError.svg" ); mIconDataDefineExpression = QgsApplication::getThemeIcon( "/mIconDataDefineExpression.svg" ); mIconDataDefineExpressionOn = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionOn.svg" ); mIconDataDefineExpressionError = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionError.svg" ); } setFocusPolicy( Qt::StrongFocus ); // set default tool button icon properties setFixedSize( 30, 26 ); setStyleSheet( QString( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) ); setIconSize( QSize( 24, 24 ) ); setPopupMode( QToolButton::InstantPopup ); mDefineMenu = new QMenu( this ); connect( mDefineMenu, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowMenu() ) ); connect( mDefineMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( menuActionTriggered( QAction* ) ) ); setMenu( mDefineMenu ); mFieldsMenu = new QMenu( this ); mActionDataTypes = new QAction( this ); // list fields and types in submenu, since there may be many mActionDataTypes->setMenu( mFieldsMenu ); mActionActive = new QAction( this ); QFont f = mActionActive->font(); f.setBold( true ); mActionActive->setFont( f ); mActionDescription = new QAction( tr( "Description..." ), this ); mActionExpDialog = new QAction( tr( "Edit..." ), this ); mActionExpression = 0; mActionPasteExpr = new QAction( tr( "Paste" ), this ); mActionCopyExpr = new QAction( tr( "Copy" ), this ); mActionClearExpr = new QAction( tr( "Clear" ), this ); mActionAssistant = new QAction( tr( "Assistant..." ), this ); // set up sibling widget connections connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( disableEnabledWidgets( bool ) ) ); connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( checkCheckedWidgets( bool ) ) ); init( vl, datadefined, datatypes, description ); }
ListStyleButton::ListStyleButton( QWidget *parent) : QToolButton(parent) , m_letterSynchronization(false) , m_lastAction(0) { m_menu = new QMenu(); setPopupMode(MenuButtonPopup); setMenu(m_menu); connect(this, SIGNAL(triggered(QAction *)), this, SLOT(itemSelected(QAction *))); }
ToolButton_Impl::ToolButton_Impl() : QToolButton(), WidgetInterface(), fFlat(false) { setPopupMode(InstantPopup); setAutoRaise(true); connect(this, SIGNAL(clicked()), this, SLOT(handleClicked()), Qt::QueuedConnection); connect(this, SIGNAL(toggled(bool)), this, SLOT(handleToggled(bool))); connect(SL_QAPP(), SIGNAL(endDrag(QObject *)), this, SLOT(handleEndDrag(QObject *))); }
ComboToolButton::ComboToolButton(QWidget *parent) : QToolButton(parent) { setToolButtonStyle(Qt::ToolButtonTextBesideIcon); setPopupMode(QToolButton::MenuButtonPopup); setAutoRaise(true); connect(this,SIGNAL(triggered(QAction *)),this,SLOT(onMenuSelected(QAction *))); isFirstTime = true; curr_action = NULL; }
QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent, const QgsVectorLayer *layer ) : QToolButton( parent ) , mVectorLayer( layer ) { setFocusPolicy( Qt::StrongFocus ); // icon size is a bit bigger than text, but minimum size of 24 so that we get pixel-aligned rendering on low-dpi screens int iconSize = std::floor( std::max( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.1, 24.0 ) ); // button width is 1.25 * icon size, height 1.1 * icon size. But we round to ensure even pixel sizes for equal margins setFixedSize( 2 * static_cast< int >( 1.25 * iconSize / 2.0 ), 2 * static_cast< int >( iconSize * 1.1 / 2.0 ) ); setStyleSheet( QStringLiteral( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) ); setIconSize( QSize( iconSize, iconSize ) ); setPopupMode( QToolButton::InstantPopup ); connect( this, &QgsPropertyOverrideButton::activated, this, &QgsPropertyOverrideButton::updateSiblingWidgets ); mDefineMenu = new QMenu( this ); connect( mDefineMenu, &QMenu::aboutToShow, this, &QgsPropertyOverrideButton::aboutToShowMenu ); connect( mDefineMenu, &QMenu::triggered, this, &QgsPropertyOverrideButton::menuActionTriggered ); setMenu( mDefineMenu ); mFieldsMenu = new QMenu( this ); mActionDataTypes = new QAction( this ); // list fields and types in submenu, since there may be many mActionDataTypes->setMenu( mFieldsMenu ); mActionVariables = new QAction( tr( "Variable" ), this ); mVariablesMenu = new QMenu( this ); mActionVariables->setMenu( mVariablesMenu ); mActionActive = new QAction( this ); QFont f = mActionActive->font(); f.setBold( true ); mActionActive->setFont( f ); mActionDescription = new QAction( tr( "Description..." ), this ); mActionCreateAuxiliaryField = new QAction( tr( "Store data in the project" ), this ); mActionCreateAuxiliaryField->setCheckable( true ); mActionExpDialog = new QAction( tr( "Edit..." ), this ); mActionExpression = nullptr; mActionPasteExpr = new QAction( tr( "Paste" ), this ); mActionCopyExpr = new QAction( tr( "Copy" ), this ); mActionClearExpr = new QAction( tr( "Clear" ), this ); mActionAssistant = new QAction( tr( "Assistant..." ), this ); QFont assistantFont = mActionAssistant->font(); assistantFont.setBold( true ); mActionAssistant->setFont( assistantFont ); mDefineMenu->addAction( mActionAssistant ); }
QgsAggregateToolButton::QgsAggregateToolButton() { setFocusPolicy( Qt::StrongFocus ); setPopupMode( QToolButton::InstantPopup ); mMenu = new QMenu( this ); connect( mMenu, &QMenu::aboutToShow, this, &QgsAggregateToolButton::aboutToShowMenu ); setMenu( mMenu ); setText( tr( "Exclude" ) ); }
ButtonWithMenu::ButtonWithMenu(QWidget* parent) : ToolButton(parent) , m_menu(new QMenu(this)) { setPopupMode(QToolButton::InstantPopup); setCursor(Qt::ArrowCursor); setFocusPolicy(Qt::ClickFocus); setMenu(m_menu); connect(m_menu, SIGNAL(aboutToShow()), this, SLOT(generateMenu())); }
MenuButton::MenuButton(QWidget *parent) : ToolButton(parent) { setPopupMode(QToolButton::InstantPopup); setIcon(Icons::self()->menuIcon); setToolTip(i18n("Menu")); setHideMenuIndicator(true); if (!Utils::touchFriendly()) { installEventFilter(this); } }
CLoginButton::CLoginButton(QWidget *parent) : QToolButton(parent), isLoggedIn(false) { setPopupMode(QToolButton::InstantPopup); menuCreate(); serverNoResponse.setSingleShot(true); connect(&serverNoResponse, &QTimer::timeout, this, &CLoginButton::sendNoResponse); }
//And now for the button itself QuickTableButton::QuickTableButton(QWidget *parent) : QToolButton(parent) { setToolTip(i18n("Insert a table")); setToolButtonStyle(Qt::ToolButtonIconOnly); setIcon(koIcon("insert-table")); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_menu = new QMenu(this); setMenu(m_menu); setPopupMode(InstantPopup); }
Autoforms::Autoforms( QWidget* parent ) : QToolButton( parent ) { // Men = new QMenu(); buttonGroup1 = new AutoformButtonGroup( NULL ); // MenAct = new QWidgetAction(this); // MenAct->setDefaultWidget(buttonGroup1); // Men->addAction(MenAct); setMenu(buttonGroup1); setPopupMode(QToolButton::InstantPopup); setIcon(QIcon(buttonGroup1->getIconPixmap(0))); connect(buttonGroup1, SIGNAL(buttonClicked(int)), this, SLOT(selForm(int))); }
void BookmarkWidget::updateBookmark(BookmarksItem *bookmark) { if (bookmark != m_bookmark) { return; } const QString title(m_bookmark->data(BookmarksModel::TitleRole).toString().isEmpty() ? tr("(Untitled)") : m_bookmark->data(BookmarksModel::TitleRole).toString()); const BookmarksModel::BookmarkType type(static_cast<BookmarksModel::BookmarkType>(m_bookmark->data(BookmarksModel::TypeRole).toInt())); if (type == BookmarksModel::RootBookmark || type == BookmarksModel::TrashBookmark || type == BookmarksModel::FolderBookmark) { Menu *menu(new Menu(Menu::BookmarksMenuRole, this)); menu->menuAction()->setData(m_bookmark->index()); setPopupMode(QToolButton::InstantPopup); setToolTip(title); setMenu(menu); setEnabled(m_bookmark->rowCount() > 0); } else { QStringList toolTip; toolTip.append(tr("Title: %1").arg(title)); if (!m_bookmark->data(BookmarksModel::UrlRole).toString().isEmpty()) { toolTip.append(tr("Address: %1").arg(m_bookmark->data(BookmarksModel::UrlRole).toString())); } if (m_bookmark->data(BookmarksModel::DescriptionRole).isValid()) { toolTip.append(tr("Description: %1").arg(m_bookmark->data(BookmarksModel::DescriptionRole).toString())); } if (!m_bookmark->data(BookmarksModel::TimeAddedRole).toDateTime().isNull()) { toolTip.append(tr("Created: %1").arg(m_bookmark->data(BookmarksModel::TimeAddedRole).toDateTime().toString())); } if (!m_bookmark->data(BookmarksModel::TimeVisitedRole).toDateTime().isNull()) { toolTip.append(tr("Visited: %1").arg(m_bookmark->data(BookmarksModel::TimeVisitedRole).toDateTime().toString())); } setToolTip(QLatin1String("<div style=\"white-space:pre;\">") + toolTip.join(QLatin1Char('\n')) + QLatin1String("</div>")); setMenu(nullptr); } setText(title); setStatusTip(m_bookmark->data(BookmarksModel::UrlRole).toString()); setIcon(m_bookmark->data(Qt::DecorationRole).value<QIcon>()); }
QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent, const QgsVectorLayer *layer ) : QToolButton( parent ) , mVectorLayer( layer ) { setFocusPolicy( Qt::StrongFocus ); // set default tool button icon properties setFixedSize( 30, 26 ); setStyleSheet( QStringLiteral( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) ); setIconSize( QSize( 24, 24 ) ); setPopupMode( QToolButton::InstantPopup ); connect( this, &QgsPropertyOverrideButton::activated, this, &QgsPropertyOverrideButton::updateSiblingWidgets ); mDefineMenu = new QMenu( this ); connect( mDefineMenu, &QMenu::aboutToShow, this, &QgsPropertyOverrideButton::aboutToShowMenu ); connect( mDefineMenu, &QMenu::triggered, this, &QgsPropertyOverrideButton::menuActionTriggered ); setMenu( mDefineMenu ); mFieldsMenu = new QMenu( this ); mActionDataTypes = new QAction( this ); // list fields and types in submenu, since there may be many mActionDataTypes->setMenu( mFieldsMenu ); mActionVariables = new QAction( tr( "Variable" ), this ); mVariablesMenu = new QMenu( this ); mActionVariables->setMenu( mVariablesMenu ); mActionActive = new QAction( this ); QFont f = mActionActive->font(); f.setBold( true ); mActionActive->setFont( f ); mActionDescription = new QAction( tr( "Description..." ), this ); mActionCreateAuxiliaryField = new QAction( tr( "Store data in the project" ), this ); mActionCreateAuxiliaryField->setCheckable( true ); mActionExpDialog = new QAction( tr( "Edit..." ), this ); mActionExpression = nullptr; mActionPasteExpr = new QAction( tr( "Paste" ), this ); mActionCopyExpr = new QAction( tr( "Copy" ), this ); mActionClearExpr = new QAction( tr( "Clear" ), this ); mActionAssistant = new QAction( tr( "Assistant..." ), this ); QFont assistantFont = mActionAssistant->font(); assistantFont.setBold( true ); mActionAssistant->setFont( assistantFont ); mDefineMenu->addAction( mActionAssistant ); }
void SubscribeToolButton::updateUi() { if (mSubscribed) { #ifdef USE_MENUBUTTONPOPUP setPopupMode(QToolButton::MenuButtonPopup); #else setPopupMode(QToolButton::InstantPopup); #endif setIcon(QIcon(":/images/accepted16.png")); setText(tr("Subscribed")); if(mMenu != NULL) // that's because setMenu does not give away memory ownership delete mMenu ; mMenu = new QMenu; mMenu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate())); if (!mSubscribedActions.empty()) { mMenu->addSeparator(); mMenu->addActions(mSubscribedActions); } setMenu(mMenu); #ifndef USE_MENUBUTTONPOPUP disconnect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate())); #endif } else { setPopupMode(QToolButton::DelayedPopup); setMenu(NULL); setIcon(QIcon(":/images/RSS_004_32.png")); setText(tr("Subscribe")); #ifndef USE_MENUBUTTONPOPUP connect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate())); #endif } }
ShadeButton::ShadeButton(QWidget* parent) : QToolButton(parent) { QString tmp[] = {"0 %", "10 %", "20 %", "30 %", "40 %", "50 %", "60 %", "70 %", "80 %", "90 %", "100 %"}; size_t array = sizeof(tmp) / sizeof(*tmp); FillSh = new QMenu(); FillSh->addAction( tr("Other..."))->setCheckable(true); for (uint a = 0; a < array; ++a) FillSh->addAction(tmp[a])->setCheckable(true); setMenu(FillSh); setPopupMode(QToolButton::InstantPopup); setText("100 %"); FillSh->actions()[11]->setChecked(true); connect( FillSh, SIGNAL(triggered(QAction *)), this, SLOT(setShade(QAction *))); }
BtDisplaySettingsButton::BtDisplaySettingsButton(QWidget *parent) : QToolButton(parent) { initMenu(); setIcon(util::getIcon(CResMgr::displaywindows::displaySettings::icon)); setPopupMode(QToolButton::InstantPopup); setEnabled(false); initMenu(); retranslateUi(); connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(slotOptionToggled(QAction*))); }
// BrushStyleButton class BrushStyleButton::BrushStyleButton(QWidget *parent) : QToolButton(parent) { TimeMeasure t("BrushStyleButton"); setCheckable(true); setPopupMode(QToolButton::InstantPopup); styleWidget = new BrushStyleWidget(this); updateIcon(); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); connect(this->styleWidget, SIGNAL(closed()), this, SLOT(onStyleWidgetClosed())); }
IconButton::IconButton(QWidget *parent) : QToolButton(parent) { setFocusPolicy(Qt::NoFocus); //setToolButtonStyle(Qt::ToolButtonIconOnly); setStyleSheet("QToolButton { background-color:transparent; border: none; padding: 0px}"); setCursor(Qt::ArrowCursor); setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); setContextMenuPolicy(Qt::PreventContextMenu); setAutoRaise(true); setPopupMode (QToolButton::InstantPopup); setArrowType( Qt::NoArrow); }
TextStyleButton::TextStyleButton(QWidget *parent) : QToolButton(parent) { TimeMeasure t("TextStyleButton"); setCheckable(true); setPopupMode(QToolButton::InstantPopup); styleWidget = new TextStyleWidget(this); updateText(); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); connect(this->styleWidget, SIGNAL(closed()), this, SLOT(onStyleWidgetClosed())); connect(this->styleWidget, SIGNAL(fontNameSelected(const QString &)), this, SIGNAL(fontNameSelected(const QString &))); }
SelectImageButton::SelectImageButton(QWidget *parent) : QToolButton(parent) { QMenu *menu = new QMenu(this); setPopupMode(QToolButton::InstantPopup); setIconSize(QSize(64,64)); menu->addAction(QIcon::fromTheme(QLatin1String("document-open-folder")), i18n("Load from file..."), this, SLOT(onLoadImageFromFile())); menu->addAction(QIcon::fromTheme(QLatin1String("edit-clear")), i18n("Clear Image"), this, SLOT(onClearImage())); setMenu(menu); onClearImage(); }