Skip to content

Commit

Permalink
Use QTableView in CtInfoDialog (#137)
Browse files Browse the repository at this point in the history
* Use QTableView for CtInfoDialog

* remove tr and rename list_games_item_double_clicked

Co-authored-by: DavidoTek <[email protected]>
  • Loading branch information
sonic2kk and DavidoTek authored Nov 16, 2022
1 parent eb78670 commit 8eb0432
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
22 changes: 13 additions & 9 deletions pupgui2/pupgui2ctinfodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,39 @@ def setup_ui(self):

self.ui.btnClose.clicked.connect(self.btn_close_clicked)

self.ui.listGames.itemDoubleClicked.connect(self.list_games_item_double_clicked)
self.ui.listGames.cellDoubleClicked.connect(self.list_games_cell_double_clicked)

def update_game_list_steam(self):
if self.install_loc.get('launcher') == 'steam' and 'vdf_dir' in self.install_loc:
self.games = get_steam_game_list(self.install_loc.get('vdf_dir'), self.ctool.get_internal_name())
self.ui.txtNumGamesUsingTool.setText(str(len(self.games)))

self.ui.listGames.clear()
for game in self.games:
self.ui.listGames.addItem(game.get_app_id_str() + ': ' + game.game_name)
self.ui.listGames.setRowCount(len(self.games))
self.ui.listGames.setHorizontalHeaderLabels([self.tr('AppID'), self.tr('Name')])
for i, game in enumerate(self.games):
self.ui.listGames.setItem(i, 0, QTableWidgetItem(game.get_app_id_str()))
self.ui.listGames.setItem(i, 1, QTableWidgetItem(game.game_name))

self.batch_update_complete.emit(True)

def update_game_list_lutris(self):
self.ui.listGames.clear()
for game in get_lutris_game_list(self.install_loc):
self.ui.listGames.setHorizontalHeaderLabels([self.tr('Slug'), self.tr('Name')])
for i, game in enumerate(get_lutris_game_list(self.install_loc)):
if game.runner == 'wine':
cfg = game.get_game_config()
if self.ctool.displayname == cfg.get('wine', {}).get('version'):
self.ui.listGames.addItem(game.name)
self.ui.listGames.setItem(i, 0, QTableWidgetItem(game.slug))
self.ui.listGames.setItem(i, 1, QTableWidgetItem(game.name))

def btn_close_clicked(self):
self.ui.close()

def list_games_item_double_clicked(self, item):
def list_games_cell_double_clicked(self, row):
if self.install_loc.get('launcher') == 'steam':
steam_game_id = item.text().split(':')[0]
if not steam_game_id == '-1':
open_webbrowser_thread(STEAM_APP_PAGE_URL + steam_game_id)
steam_game_id = str(self.ui.listGames.item(row, 0).text())
open_webbrowser_thread(STEAM_APP_PAGE_URL + steam_game_id)

def btn_batch_update_clicked(self):
steam_config_folder = self.install_loc.get('vdf_dir')
Expand Down
38 changes: 37 additions & 1 deletion pupgui2/resources/ui/pupgui2_ctinfodialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,43 @@
</layout>
</item>
<item>
<widget class="QListWidget" name="listGames"/>
<widget class="QTableWidget" name="listGames">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="rowCount">
<number>0</number>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
Expand Down

0 comments on commit 8eb0432

Please sign in to comment.