Merge pull request #717 from PhenomRetroShare/Fix_SettingListWidth

Fix Setting list width.
This commit is contained in:
csoler 2017-03-07 21:54:56 +01:00 committed by GitHub
commit 283a2ee5fe
2 changed files with 25 additions and 39 deletions

View File

@ -46,9 +46,12 @@
#include "rsharesettings.h"
#include "gui/notifyqt.h"
#include "gui/common/FloatingHelpBrowser.h"
#include "gui/common/RSElidedItemDelegate.h"
#define IMAGE_GENERAL ":/images/kcmsystem24.png"
#define ITEM_SPACING 2
#include "rsettingswin.h"
//RSettingsWin *RSettingsWin::_instance = NULL;
@ -63,6 +66,11 @@ SettingsPage::SettingsPage(QWidget *parent)
/* Initialize help browser */
mHelpBrowser = new FloatingHelpBrowser(this, ui.helpButton);
/* Add own item delegate to get item width*/
RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this);
itemDelegate->setSpacing(QSize(0, ITEM_SPACING));
ui.listWidget->setItemDelegate(itemDelegate);
initStackedWidget();
/* Load window position */
@ -179,8 +187,13 @@ void SettingsPage::addPage(ConfigPage *page)
{
ui.stackedWidget->addWidget(page) ;
QListWidgetItem *item = new QListWidgetItem(QIcon(page->iconPixmap()),page->pageName()) ;
ui.listWidget->addItem(item) ;
QListWidgetItem *item = new QListWidgetItem(QIcon(page->iconPixmap()),page->pageName(),ui.listWidget) ;
QFontMetrics fontMetrics = ui.listWidget->fontMetrics();
int w = ITEM_SPACING*8;
w += ui.listWidget->iconSize().width();
w += fontMetrics.width(item->text());
if (w > ui.listWidget->maximumWidth())
ui.listWidget->setMaximumWidth(w);
}
void

View File

@ -13,14 +13,14 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="SettingsHLayout">
<item>
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
@ -39,42 +39,15 @@
<property name="textElideMode">
<enum>Qt::ElideRight</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::TopToBottom</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>false</bool>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="spacing">
<number>0</number>
</property>
<property name="viewMode">
<enum>QListView::ListMode</enum>
</property>
<property name="modelColumn">
<number>0</number>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="currentRow">
<number>-1</number>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="rightVLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="headerGLayout">
<item row="0" column="2">
<widget class="QToolButton" name="helpButton">
<property name="focusPolicy">
@ -125,7 +98,7 @@
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="Line" name="line_2">
<widget class="Line" name="headerLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -153,7 +126,7 @@
<height>849</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="scrollAreaWidgetContentsVLayout">
<property name="leftMargin">
<number>3</number>
</property>