Author: mir3x Date: Fri Dec 2 09:37:58 2016 New Revision: 34676 URL: http://svn.gna.org/viewcvs/freeciv?rev=34676&view=rev Log: Qt client - added marings size when calculating width of QTablewidget
See patch #8040 Modified: trunk/client/gui-qt/messagedlg.cpp trunk/client/gui-qt/repodlgs.cpp Modified: trunk/client/gui-qt/messagedlg.cpp URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/messagedlg.cpp?rev=34676&r1=34675&r2=34676&view=diff ============================================================================== --- trunk/client/gui-qt/messagedlg.cpp (original) +++ trunk/client/gui-qt/messagedlg.cpp Fri Dec 2 09:37:58 2016 @@ -17,6 +17,7 @@ //Qt +#include <QApplication> #include <QGridLayout> #include <QTableWidget> #include <QHeaderView> @@ -29,6 +30,7 @@ #include "messagedlg.h" +extern QApplication *qapp; /************************************************************************** Message widget constructor **************************************************************************/ @@ -39,6 +41,7 @@ QLabel *empty1, *empty2; QPushButton *but1; QPushButton *but2; + QMargins margins; int len; setAttribute(Qt::WA_DeleteOnClose); @@ -77,8 +80,12 @@ gui()->game_tab_widget->setCurrentIndex(index); fill_data(); - len = msgtab->horizontalHeader()->length() + 16; + margins = msgtab->contentsMargins(); + len = msgtab->horizontalHeader()->length() + margins.left() + + margins.right() + + qapp->style()->pixelMetric(QStyle::PM_ScrollBarExtent); msgtab->setFixedWidth(len); + msgtab->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); but1->setFixedWidth(len / 3); but2->setFixedWidth(len / 3); } Modified: trunk/client/gui-qt/repodlgs.cpp URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/repodlgs.cpp?rev=34676&r1=34675&r2=34676&view=diff ============================================================================== --- trunk/client/gui-qt/repodlgs.cpp (original) +++ trunk/client/gui-qt/repodlgs.cpp Fri Dec 2 09:37:58 2016 @@ -48,7 +48,7 @@ extern QString cut_helptext(QString text); extern QString get_tooltip_improvement(impr_type *building); extern QString get_tooltip_unit(struct unit_type *unit); - +extern QApplication *qapp; /**************************************************************************** From reqtree.c used to get tooltips ****************************************************************************/ @@ -700,6 +700,7 @@ { int len; QStringList slist; + QMargins margins; QGridLayout *units_layout= new QGridLayout; units_widget = new QTableWidget; @@ -739,8 +740,11 @@ SLOT(selection_changed(const QItemSelection &, const QItemSelection &))); setLayout(units_layout); - len = units_widget->horizontalHeader()->length() + 4; + margins = units_widget->contentsMargins(); + len = units_widget->horizontalHeader()->length() + margins.left() + + margins.right(); units_widget->setFixedWidth(len); + units_widget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); find_button->setFixedWidth(len / 3); upgrade_button->setFixedWidth(len / 3); } @@ -793,8 +797,9 @@ int h; int len; QFontMetrics fm(f); + QMargins margins; + h = fm.height() + 6; - units_widget->setRowCount(0); units_widget->clearContents(); memset(unit_array, '\0', sizeof(unit_array)); @@ -925,7 +930,9 @@ units_widget->setItem(row - 1, column, unit_item); } units_widget->resizeColumnsToContents(); - len = units_widget->horizontalHeader()->length() + 4; + margins = units_widget->contentsMargins(); + len = units_widget->horizontalHeader()->length() + margins.left() + + margins.right(); units_widget->setFixedWidth(len); find_button->setFixedWidth(len / 3); upgrade_button->setFixedWidth(len / 3); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits