Skip to content
Snippets Groups Projects
Commit 96707f0b authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Make the Options dialog smaller

Also removed no longer used .ui file.

Reviewed-by: Friedemann Kleint
parent 839bc1e9
No related merge requests found
...@@ -189,6 +189,26 @@ static QStandardItemModel *pageModel(const QList<IOptionsPage*> &pages, ...@@ -189,6 +189,26 @@ static QStandardItemModel *pageModel(const QList<IOptionsPage*> &pages,
return model; return model;
} }
// ----------- Pages tree view
/**
* Special version of a QTreeView that has the width of the first column as
* minimum size.
*/
class PageTree : public QTreeView
{
public:
PageTree(QWidget *parent = 0) : QTreeView(parent)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
}
virtual QSize sizeHint() const
{
return QSize(sizeHintForColumn(0) + frameWidth() * 2, 100);
}
};
// ----------- SettingsDialog // ----------- SettingsDialog
// Helpers to sort by category. id // Helpers to sort by category. id
...@@ -215,7 +235,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId, ...@@ -215,7 +235,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
m_applied(false), m_applied(false),
m_stackedLayout(new QStackedLayout), m_stackedLayout(new QStackedLayout),
m_filterLineEdit(new Utils::FilterLineEdit), m_filterLineEdit(new Utils::FilterLineEdit),
m_pageTree(new QTreeView), m_pageTree(new PageTree),
m_headerLabel(new QLabel) m_headerLabel(new QLabel)
{ {
createGui(); createGui();
...@@ -235,7 +255,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId, ...@@ -235,7 +255,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
// Create pages with title labels with a larger, bold font, left-aligned // Create pages with title labels with a larger, bold font, left-aligned
// with the group boxes of the page. // with the group boxes of the page.
foreach(IOptionsPage *page, m_pages) foreach (IOptionsPage *page, m_pages)
m_stackedLayout->addWidget(page->createPage(0)); m_stackedLayout->addWidget(page->createPage(0));
QModelIndex initialIndex; QModelIndex initialIndex;
...@@ -251,7 +271,6 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId, ...@@ -251,7 +271,6 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
const QModelIndex proxyIndex = m_proxyModel->mapFromSource(initialIndex); const QModelIndex proxyIndex = m_proxyModel->mapFromSource(initialIndex);
m_pageTree->selectionModel()->setCurrentIndex(proxyIndex, QItemSelectionModel::ClearAndSelect); m_pageTree->selectionModel()->setCurrentIndex(proxyIndex, QItemSelectionModel::ClearAndSelect);
} }
m_pageTree->resizeColumnToContents(0);
// The order of the slot connection matters here, the filter slot // The order of the slot connection matters here, the filter slot
// opens the matching page after the model has filtered. // opens the matching page after the model has filtered.
...@@ -425,5 +444,13 @@ void SettingsDialog::done(int val) ...@@ -425,5 +444,13 @@ void SettingsDialog::done(int val)
QDialog::done(val); QDialog::done(val);
} }
/**
* Override to make sure the settings dialog starts up as small as possible.
*/
QSize SettingsDialog::sizeHint() const
{
return minimumSize();
}
} }
} }
...@@ -69,6 +69,8 @@ public: ...@@ -69,6 +69,8 @@ public:
// at least once // at least once
bool execDialog(); bool execDialog();
virtual QSize sizeHint() const;
public slots: public slots:
void done(int); void done(int);
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>697</width>
<height>476</height>
</rect>
</property>
<property name="windowTitle">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="filterLayout">
<item>
<widget class="QLineEdit" name="filterLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="filterClearButton">
<property name="toolTip">
<string>Clear filter</string>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="pageTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedPages">
<property name="minimumSize">
<size>
<width>350</width>
<height>250</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>361</y>
</hint>
<hint type="destinationlabel">
<x>297</x>
<y>193</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>361</y>
</hint>
<hint type="destinationlabel">
<x>297</x>
<y>193</y>
</hint>
</hints>
</connection>
</connections>
</ui>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment