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.
|
||||
- [#797] Custom seam allowance ignored in some cases.
|
||||
- [#798] Formula Wizard crashes with translated increments.
|
||||
- [#803] Bug in FancyTabBar widget. Wrongly calculated widget width.
|
||||
|
||||
# Version 0.5.0 May 9, 2017
|
||||
- [#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;
|
||||
for (int tab=0 ; tab<Count() ;++tab)
|
||||
{
|
||||
int width = fm.width(TabText(tab));
|
||||
if (width > maxLabelwidth)
|
||||
QString tabText = TabText(tab).simplified();
|
||||
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;
|
||||
|
||||
|
@ -600,6 +622,7 @@ QString FancyTabBar::TabText(int index) const
|
|||
void FancyTabBar::SetTabText(int index, QString text)
|
||||
{
|
||||
m_attachedTabs.at(index)->m_text=text;
|
||||
setMaximumWidth(TabSizeHint(false).width());
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -643,6 +666,8 @@ void FancyTabBar::InsertTab(int index, const QIcon &icon, const QString &label)
|
|||
tab->m_icon = icon;
|
||||
tab->m_text = label;
|
||||
m_attachedTabs.insert(index, tab);
|
||||
|
||||
setMaximumWidth(TabSizeHint(false).width());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -650,4 +675,6 @@ void FancyTabBar::RemoveTab(int index)
|
|||
{
|
||||
FancyTab *tab = m_attachedTabs.takeAt(index);
|
||||
delete tab;
|
||||
|
||||
setMaximumWidth(TabSizeHint(false).width());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user