20 #include <QDialogButtonBox>
22 #include <QListWidget>
23 #include <QListWidgetItem>
24 #include <QMessageBox>
28 #include <QStackedWidget>
39 : QDialog( parent, fl )
40 , mOptsKey( settingsKey )
43 , mSettings( settings )
44 , mDelSettings( false )
79 if ( title.isEmpty() )
88 layout()->setContentsMargins( 0, 0, 0, 0 );
92 mOptListWidget = findChild<QListWidget *>( QStringLiteral(
"mOptionsListWidget" ) );
93 QFrame *optionsFrame = findChild<QFrame *>( QStringLiteral(
"mOptionsFrame" ) );
94 mOptStackedWidget = findChild<QStackedWidget *>( QStringLiteral(
"mOptionsStackedWidget" ) );
95 mOptSplitter = findChild<QSplitter *>( QStringLiteral(
"mOptionsSplitter" ) );
96 mOptButtonBox = findChild<QDialogButtonBox *>( QStringLiteral(
"buttonBox" ) );
97 QFrame *buttonBoxFrame = findChild<QFrame *>( QStringLiteral(
"mButtonBoxFrame" ) );
98 mSearchLineEdit = findChild<QgsFilterLineEdit *>( QStringLiteral(
"mSearchLineEdit" ) );
109 mOptListWidget->setIconSize( QSize( size + iconBuffer, size + iconBuffer ) );
113 optionsFrame->layout()->setContentsMargins( 0, frameMargin, frameMargin, frameMargin );
114 QVBoxLayout *layout =
static_cast<QVBoxLayout *
>( optionsFrame->layout() );
116 if ( buttonBoxFrame )
118 buttonBoxFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
119 layout->insertWidget( layout->count() + 1, buttonBoxFrame );
129 disconnect(
mOptButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
130 connect(
mOptButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
131 disconnect(
mOptButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
132 connect(
mOptButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
168 if ( !title.isEmpty() )
183 mSettings->value( QStringLiteral(
"/Windows/%1/splitState" ).arg(
mOptsKey ) ).isNull() ? 150 : 16777215 );
194 int curIndx =
mSettings->value( QStringLiteral(
"/Windows/%1/tab" ).arg(
mOptsKey ), 0 ).toInt();
225 QSizePolicy::Policy policy = QSizePolicy::Ignored;
228 policy = QSizePolicy::MinimumExpanding;
248 if ( currentPage->objectName() == page )
259 QListWidgetItem *item =
new QListWidgetItem();
260 item->setIcon( icon );
261 item->setText( title );
262 item->setToolTip( tooltip );
274 if ( currentPage->objectName() == before )
278 QListWidgetItem *item =
new QListWidgetItem();
279 item->setIcon( icon );
280 item->setText( title );
281 item->setToolTip( tooltip );
290 addPage( title, tooltip, icon, widget );
295 const int minimumTextLength = 3;
309 mOptListWidget->setRowHidden( r, text.length() >= minimumTextLength );
314 if ( rsw.first->searchHighlight( text.length() >= minimumTextLength ? text : QString() ) )
344 const auto constWidget =
mOptStackedWidget->widget( i )->findChildren<QWidget *>();
345 for ( QWidget *w : constWidget )
349 QHash<QWidget *, QgsOptionsDialogHighlightWidget *> customHighlightWidgets;
357 if ( customHighlightWidgets.contains( w ) )
359 shw = customHighlightWidgets.value( w );
368 QgsDebugMsgLevel( QStringLiteral(
"Registering: %1" ).arg( w->objectName() ), 4 );
396 QDialog::showEvent( e );
404 QDialog::paintEvent( e );
412 setWindowTitle( QStringLiteral(
"%1 %2 %3" )
414 .arg( QChar( 0x2014 ) )
415 .arg( curitem->text() ) );
434 int snapToIconWidth = iconWidth + 32;
437 mIconOnly = ( splitSizes.at( 0 ) <= snapToIconWidth );
440 int newWidth =
mOptListWidget->verticalScrollBar()->isVisible() ? iconWidth + 22 : iconWidth + 9;
448 splitSizes[1] = splitSizes.at( 1 ) - ( splitSizes.at( 0 ) - newWidth );
449 splitSizes[0] = newWidth;
476 if ( ( *it ).second == index )
485 QMessageBox::warning(
nullptr, tr(
"Missing Objects" ),
486 tr(
"Base options dialog could not be initialized.\n\n"
487 "Missing some of the .ui template objects:\n" )
488 +
" mOptionsListWidget,\n mOptionsStackedWidget,\n mOptionsSplitter,\n mOptionsListFrame",