diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2014-10-19 16:15:22 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-10-19 07:24:15 -0700 |
commit | 4de44e6c9f2ef9c3ab8f5cef59e7a3fb04e08298 (patch) | |
tree | f3190cd163b600dc40bbe7a0924aec308234ca78 /qt-ui/tableview.cpp | |
parent | 58ac3b8f86549ca9f373b3ef2a54fe2d71667719 (diff) | |
download | subsurface-4de44e6c9f2ef9c3ab8f5cef59e7a3fb04e08298.tar.gz |
TableView: fix button sizing
Ensure that there is no (clipped) overflowfrom the header.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/tableview.cpp')
-rw-r--r-- | qt-ui/tableview.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qt-ui/tableview.cpp b/qt-ui/tableview.cpp index 8232fb604..1dbfd89eb 100644 --- a/qt-ui/tableview.cpp +++ b/qt-ui/tableview.cpp @@ -53,8 +53,19 @@ TableView::TableView(QWidget *parent) : QGroupBox(parent) plusBtn = new QPushButton(plusIcon, QString(), this); plusBtn->setFlat(true); plusBtn->setToolTip(tr("Add cylinder")); - plusBtn->setIconSize(QSize(metrics.icon->sz_small, metrics.icon->sz_small)); - plusBtn->resize(metrics.icon->sz_med, metrics.icon->sz_med); + + /* now determine the icon and button size. Since the button will be + * placed in the label, make sure that we do not overflow, as it might + * get clipped + */ + int iconSize = metrics.icon->sz_small; + int btnSize = iconSize + 2*min_gap; + if (btnSize > labelRect.height()) { + btnSize = labelRect.height(); + iconSize = btnSize - 2*min_gap; + } + plusBtn->setIconSize(QSize(iconSize, iconSize)); + plusBtn->resize(btnSize, btnSize); connect(plusBtn, SIGNAL(clicked(bool)), this, SIGNAL(addButtonClicked())); } |