Fixed issue #803. Bug in FancyTabBar widget. Wrong calculated widget width.
(grafted from 20b63b26e1c49e8de9b71a267fbddd3dd3ed69b6) --HG-- branch : develop
This commit is contained in:
parent
f938cc04fe
commit
1a8d4488ec
|
@ -85,6 +85,7 @@
|
||||||
- [#788] Unhardcode icon path in GNU/Linux launcher.
|
- [#788] Unhardcode icon path in GNU/Linux launcher.
|
||||||
- [#797] Custom seam allowance ignored in some cases.
|
- [#797] Custom seam allowance ignored in some cases.
|
||||||
- [#798] Formula Wizard crashes with translated increments.
|
- [#798] Formula Wizard crashes with translated increments.
|
||||||
|
- [#803] Bug in FancyTabBar widget. Wrongly calculated widget width.
|
||||||
|
|
||||||
# Version 0.5.0 May 9, 2017
|
# Version 0.5.0 May 9, 2017
|
||||||
- [#581] User can now filter input lists by keyword in function wizard.
|
- [#581] User can now filter input lists by keyword in function wizard.
|
||||||
|
|
|
@ -82,11 +82,33 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
||||||
int maxLabelwidth = 0;
|
int maxLabelwidth = 0;
|
||||||
for (int tab=0 ; tab<Count() ;++tab)
|
for (int tab=0 ; tab<Count() ;++tab)
|
||||||
{
|
{
|
||||||
int width = fm.width(TabText(tab));
|
QString tabText = TabText(tab).simplified();
|
||||||
if (width > maxLabelwidth)
|
const QStringList words = tabText.split(QLatin1Char(' '));
|
||||||
|
|
||||||
|
if (words.size() > 1)
|
||||||
{
|
{
|
||||||
maxLabelwidth = width;
|
QString sentence;
|
||||||
|
foreach(const QString & word, words)
|
||||||
|
{
|
||||||
|
sentence = sentence.isEmpty() ? sentence = word : sentence + QLatin1Char(' ') + word;
|
||||||
|
|
||||||
|
const int width = fm.width(sentence);
|
||||||
|
if (maxLabelwidth < width)
|
||||||
|
{
|
||||||
|
maxLabelwidth = width;
|
||||||
|
sentence.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int width = fm.width(tabText);
|
||||||
|
if (width > maxLabelwidth)
|
||||||
|
{
|
||||||
|
maxLabelwidth = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
int iconHeight = minimum ? 0 : 32;
|
int iconHeight = minimum ? 0 : 32;
|
||||||
|
|
||||||
|
@ -600,6 +622,7 @@ QString FancyTabBar::TabText(int index) const
|
||||||
void FancyTabBar::SetTabText(int index, QString text)
|
void FancyTabBar::SetTabText(int index, QString text)
|
||||||
{
|
{
|
||||||
m_attachedTabs.at(index)->m_text=text;
|
m_attachedTabs.at(index)->m_text=text;
|
||||||
|
setMaximumWidth(TabSizeHint(false).width());
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,6 +666,8 @@ void FancyTabBar::InsertTab(int index, const QIcon &icon, const QString &label)
|
||||||
tab->m_icon = icon;
|
tab->m_icon = icon;
|
||||||
tab->m_text = label;
|
tab->m_text = label;
|
||||||
m_attachedTabs.insert(index, tab);
|
m_attachedTabs.insert(index, tab);
|
||||||
|
|
||||||
|
setMaximumWidth(TabSizeHint(false).width());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -650,4 +675,6 @@ void FancyTabBar::RemoveTab(int index)
|
||||||
{
|
{
|
||||||
FancyTab *tab = m_attachedTabs.takeAt(index);
|
FancyTab *tab = m_attachedTabs.takeAt(index);
|
||||||
delete tab;
|
delete tab;
|
||||||
|
|
||||||
|
setMaximumWidth(TabSizeHint(false).width());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user