17#include "moc_qgsmultiedittoolbutton.cpp"
23 : QToolButton( parent )
25 setFocusPolicy( Qt::StrongFocus );
28 setStyleSheet( QStringLiteral(
"QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) );
31 setIconSize( QSize( iconSize, iconSize ) );
33 setFixedSize( 2 *
static_cast<int>( 1.25 * iconSize / 2.0 ), 2 *
static_cast<int>( iconSize * 1.1 / 2.0 ) );
35 setPopupMode( QToolButton::InstantPopup );
37 mMenu =
new QMenu(
this );
38 connect( mMenu, &QMenu::aboutToShow,
this, &QgsMultiEditToolButton::aboutToShowMenu );
45void QgsMultiEditToolButton::aboutToShowMenu()
53 QAction *noAction = mMenu->addAction( tr(
"No Changes to Commit" ) );
54 noAction->setEnabled(
false );
59 const QString title = !mField.
name().isEmpty() ? tr(
"Set %1 for All Selected Features" ).arg( mField.
name() )
60 : tr(
"Set field for all selected features" );
61 QAction *setFieldAction = mMenu->addAction( title );
62 connect( setFieldAction, &QAction::triggered,
this, &QgsMultiEditToolButton::setFieldTriggered );
67 QAction *resetFieldAction = mMenu->addAction( tr(
"Reset to Original Values" ) );
68 connect( resetFieldAction, &QAction::triggered,
this, &QgsMultiEditToolButton::resetFieldTriggered );
74void QgsMultiEditToolButton::setFieldTriggered()
81void QgsMultiEditToolButton::resetFieldTriggered()
88void QgsMultiEditToolButton::updateState()
93 else if ( mIsMixedValues )
104 tooltip = tr(
"All features in selection have equal value for '%1'" ).arg( mField.
name() );
108 tooltip = tr(
"Some features in selection have different values for '%1'" ).arg( mField.
name() );
112 tooltip = tr(
"Values for '%1' have unsaved changes" ).arg( mField.
name() );
117 setToolTip( tooltip );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...