Skip to content

Commit

Permalink
convert float to int as expected by Qt API functions (fixes #116)
Browse files Browse the repository at this point in the history
  • Loading branch information
mu00d8 authored and gaasedelen committed Feb 17, 2022
1 parent 973b40e commit 6e1dcb8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugins/lighthouse/composer/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ def _ui_init(self):
# set the height of the textbox based on some arbitrary math :D
LINE_PADDING = self.document().documentMargin()*2
line_height = self._font_metrics.height() + LINE_PADDING + 2
self.setFixedHeight(line_height)
self.setFixedHeight(int(line_height))

#--------------------------------------------------------------------------
# QPlainTextEdit Overloads
Expand Down
4 changes: 2 additions & 2 deletions plugins/lighthouse/ui/coverage_combobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _ui_init(self):

self.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContentsOnFirstShow)
self.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
self.setMaximumHeight(self._font_metrics.height()*1.75)
self.setMaximumHeight(int(self._font_metrics.height()*1.75))

# draw the QComboBox with a 'Windows'-esque style
self.setStyle(QtWidgets.QStyleFactory.create("Windows"))
Expand Down Expand Up @@ -533,7 +533,7 @@ def __init__(self, director, parent=None):
delete_icon = QtGui.QPixmap(plugin_resource("icons/delete_coverage.png"))

# compute the appropriate size for the deletion icon
icon_height = self._font_metrics.height()*0.75
icon_height = int(self._font_metrics.height()*0.75)
icon_width = icon_height

# scale the icon as appropriate (very likely scaling it down)
Expand Down
6 changes: 3 additions & 3 deletions plugins/lighthouse/ui/coverage_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _ui_layout(self):

# layout the major elements of our widget
layout = QtWidgets.QGridLayout()
layout.setSpacing(get_dpi_scale()*5.0)
layout.setSpacing(get_dpi_scale()*5)
layout.addWidget(self._table_view)
layout.addWidget(self._toolbar)

Expand All @@ -214,8 +214,8 @@ def _ui_show_settings(self):
-1*self._settings_menu.sizeHint().height()
)
center = QtCore.QPoint(
self._settings_button.sizeHint().width()/2,
self._settings_button.sizeHint().height()/2
int(self._settings_button.sizeHint().width()/2),
int(self._settings_button.sizeHint().height()/2)
)
where = self._settings_button.mapToGlobal(center+delta)
self._settings_menu.popup(where)
Expand Down
4 changes: 2 additions & 2 deletions plugins/lighthouse/ui/coverage_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _ui_init_table(self):
entry_rect = entry_fm.boundingRect(entry_text)

# select the larger of the two potential column widths
column_width = max(title_rect.width(), entry_rect.width()*1.2)
column_width = int(max(title_rect.width(), entry_rect.width()*1.2))

# save the final column width
self.setColumnWidth(i, column_width)
Expand Down Expand Up @@ -191,7 +191,7 @@ def _ui_init_table(self):
# NOTE: don't ask too many questions about this voodoo math :D
spacing = entry_fm.height() - entry_fm.xHeight()
tweak = (17*get_dpi_scale() - spacing)/get_dpi_scale()
vh.setDefaultSectionSize(entry_fm.height()+tweak)
vh.setDefaultSectionSize(int(entry_fm.height()+tweak))

def _ui_init_table_ctx_menu_actions(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/lighthouse/util/qt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_dpi_scale():
fm = QtGui.QFontMetricsF(font)

# xHeight is expected to be 40.0 at normal DPI
return fm.height() / 173.0
return int(fm.height() / 173.0)

def compute_color_on_gradiant(percent, color1, color2):
"""
Expand All @@ -79,9 +79,9 @@ def compute_color_on_gradiant(percent, color1, color2):
r2, g2, b2, _ = color2.getRgb()

# compute the new color across the gradiant of color1 -> color 2
r = r1 + percent * (r2 - r1)
g = g1 + percent * (g2 - g1)
b = b1 + percent * (b2 - b1)
r = r1 + int(percent * (r2 - r1))
g = g1 + int(percent * (g2 - g1))
b = b1 + int(percent * (b2 - b1))

# return the new color
return QtGui.QColor(r,g,b)
Expand Down
2 changes: 1 addition & 1 deletion plugins/lighthouse/util/qt/waitbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _ui_init(self):
# configure the main widget / form
self.setSizeGripEnabled(False)
self.setModal(True)
self._dpi_scale = get_dpi_scale()*5.0
self._dpi_scale = get_dpi_scale()*5

# initialize abort button
self._abort_button = QtWidgets.QPushButton("Cancel")
Expand Down

0 comments on commit 6e1dcb8

Please sign in to comment.