20 #include <QDialogButtonBox> 22 #include <QListWidget> 23 #include <QMessageBox> 25 #include <QStackedWidget> 31 : QDialog( parent, fl )
32 , mOptsKey( settingsKey )
34 , mOptListWidget( NULL )
35 , mOptStackedWidget( NULL )
36 , mOptSplitter( NULL )
37 , mOptButtonBox( NULL )
40 , mSettings( settings )
41 , mDelSettings( false )
49 mSettings->setValue( QString(
"/Windows/%1/geometry" ).arg(
mOptsKey ), saveGeometry() );
76 if ( title.isEmpty() )
85 layout()->setContentsMargins( 0, 0, 0, 0 );
90 QFrame* optionsFrame = findChild<QFrame*>(
"mOptionsFrame" );
92 mOptSplitter = findChild<QSplitter*>(
"mOptionsSplitter" );
94 QFrame* buttonBoxFrame = findChild<QFrame*>(
"mButtonBoxFrame" );
96 if ( !
mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame )
101 int size =
mSettings->value(
"/IconSize", 24 ).toInt();
105 mOptListWidget->setIconSize( QSize( size + iconBuffer, size + iconBuffer ) );
108 optionsFrame->layout()->setContentsMargins( 0, 3, 3, 3 );
109 QVBoxLayout* layout =
static_cast<QVBoxLayout*
>( optionsFrame->layout() );
111 if ( buttonBoxFrame )
113 buttonBoxFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
114 layout->insertWidget( layout->count() + 1, buttonBoxFrame );
124 disconnect( mOptButtonBox, SIGNAL( accepted() ),
this, SLOT( accept() ) );
125 connect( mOptButtonBox, SIGNAL( accepted() ),
this, SLOT( accept() ) );
126 disconnect( mOptButtonBox, SIGNAL( rejected() ),
this, SLOT( reject() ) );
127 connect( mOptButtonBox, SIGNAL( rejected() ),
this, SLOT( reject() ) );
157 if ( !title.isEmpty() )
166 restoreGeometry(
mSettings->value( QString(
"/Windows/%1/geometry" ).arg(
mOptsKey ) ).toByteArray() );
170 mSettings->value( QString(
"/Windows/%1/splitState" ).arg(
mOptsKey ) ).isNull() ? 150 : 16777215 );
172 int curIndx =
mSettings->value( QString(
"/Windows/%1/tab" ).arg(
mOptsKey ), 0 ).toInt();
211 QDialog::showEvent( e );
219 QDialog::paintEvent( e );
227 setWindowTitle( QString(
"%1 | %2" ).arg(
mDialogTitle ).arg( curitem->text() ) );
246 int snapToIconWidth = iconWidth + 32;
249 mIconOnly = ( splitSizes.at( 0 ) <= snapToIconWidth );
252 int newWidth =
mOptListWidget->verticalScrollBar()->isVisible() ? iconWidth + 22 : iconWidth + 9;
260 splitSizes[1] = splitSizes.at( 1 ) - ( splitSizes.at( 0 ) - newWidth );
261 splitSizes[0] = newWidth;
288 QMessageBox::warning( 0,
tr(
"Missing objects" ),
289 tr(
"Base options dialog could not be initialized.\n\n" 290 "Missing some of the .ui template objects:\n" )
291 +
" mOptionsListWidget,\n mOptionsStackedWidget,\n mOptionsSplitter",
void warnAboutMissingObjects()
void setSettings(QSettings *settings)
void restoreOptionsBaseUi(QString title=QString())
Restore the base ui.
void paintEvent(QPaintEvent *e) override
void optionsStackedWidget_WidgetRemoved(int indx)
void showEvent(QShowEvent *e) override
QgsOptionsDialogBase(QString settingsKey, QWidget *parent=0, Qt::WindowFlags fl=0, QSettings *settings=0)
Constructor.
QDialogButtonBox * mOptButtonBox
void initOptionsBase(bool restoreUi=true, QString title=QString())
Set up the base ui connections for vertical tabs.
QListWidget * mOptListWidget
void updateOptionsListVerticalTabs()
void optionsStackedWidget_CurrentChanged(int indx)
virtual void updateWindowTitle()
QStackedWidget * mOptStackedWidget
QPointer< QSettings > mSettings