22 : QToolButton( parent )
24 setFocusPolicy( Qt::StrongFocus );
27 setStyleSheet( QStringLiteral(
"QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) );
32 setFixedSize( 2 *
static_cast< int >( 1.25 *
iconSize / 2.0 ), 2 *
static_cast< int >(
iconSize * 1.1 / 2.0 ) );
34 setPopupMode( QToolButton::InstantPopup );
36 mMenu =
new QMenu(
this );
37 connect( mMenu, &QMenu::aboutToShow,
this, &QgsMultiEditToolButton::aboutToShowMenu );
44 void QgsMultiEditToolButton::aboutToShowMenu()
52 QAction *noAction = mMenu->addAction( tr(
"No Changes to Commit" ) );
53 noAction->setEnabled(
false );
58 const QString title = !mField.
name().isEmpty() ? tr(
"Set %1 for All Selected Features" ).arg( mField.
name() )
59 : tr(
"Set field for all selected features" );
60 QAction *setFieldAction = mMenu->addAction( title );
61 connect( setFieldAction, &QAction::triggered,
this, &QgsMultiEditToolButton::setFieldTriggered );
66 QAction *resetFieldAction = mMenu->addAction( tr(
"Reset to Original Values" ) );
67 connect( resetFieldAction, &QAction::triggered,
this, &QgsMultiEditToolButton::resetFieldTriggered );
73 void QgsMultiEditToolButton::setFieldTriggered()
80 void QgsMultiEditToolButton::resetFieldTriggered()
87 void QgsMultiEditToolButton::updateState()
92 else if ( mIsMixedValues )
103 tooltip = tr(
"All features in selection have equal value for '%1'" ).arg( mField.
name() );
107 tooltip = tr(
"Some features in selection have different values for '%1'" ).arg( mField.
name() );
111 tooltip = tr(
"Values for '%1' have unsaved changes" ).arg( mField.
name() );
116 setToolTip( tooltip );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...