20 : QToolButton( parent )
22 setFocusPolicy( Qt::StrongFocus );
25 setFixedSize( 22, 22 );
26 setStyleSheet( QStringLiteral(
"QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) );
27 setIconSize( QSize( 16, 16 ) );
28 setPopupMode( QToolButton::InstantPopup );
30 mMenu =
new QMenu(
this );
31 connect( mMenu, &QMenu::aboutToShow,
this, &QgsMultiEditToolButton::aboutToShowMenu );
38 void QgsMultiEditToolButton::aboutToShowMenu()
46 QAction *noAction = mMenu->addAction( tr(
"No Changes to Commit" ) );
47 noAction->setEnabled(
false );
52 QString title = !mField.
name().isEmpty() ? tr(
"Set %1 for All Selected Features" ).arg( mField.
name() )
53 : tr(
"Set field for all selected features" );
54 QAction *setFieldAction = mMenu->addAction( title );
55 connect( setFieldAction, &QAction::triggered,
this, &QgsMultiEditToolButton::setFieldTriggered );
60 QAction *resetFieldAction = mMenu->addAction( tr(
"Reset to Original Values" ) );
61 connect( resetFieldAction, &QAction::triggered,
this, &QgsMultiEditToolButton::resetFieldTriggered );
67 void QgsMultiEditToolButton::setFieldTriggered()
74 void QgsMultiEditToolButton::resetFieldTriggered()
81 void QgsMultiEditToolButton::updateState()
86 else if ( mIsMixedValues )
97 tooltip = tr(
"All features in selection have equal value for '%1'" ).arg( mField.
name() );
101 tooltip = tr(
"Some features in selection have different values for '%1'" ).arg( mField.
name() );
105 tooltip = tr(
"Values for '%1' have unsaved changes" ).arg( mField.
name() );
110 setToolTip( tooltip );
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.