Skip to content

Commit

Permalink
Add QSplitter to hide TableView in DetailsDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
glubsy committed Jul 2, 2020
1 parent aa79b31 commit 977c20f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
4 changes: 2 additions & 2 deletions qt/details_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
# http://www.gnu.org/licenses/gpl-3.0.html

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QMainWindow

from .details_table import DetailsModel


class DetailsDialog(QDialog):
class DetailsDialog(QMainWindow):
def __init__(self, parent, app, **kwargs):
super().__init__(parent, Qt.Tool, **kwargs)
self.app = app
Expand Down
50 changes: 36 additions & 14 deletions qt/pe/details_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from PyQt5.QtGui import QPixmap, QIcon, QKeySequence
from PyQt5.QtWidgets import (QLayout, QVBoxLayout, QAbstractItemView, QHBoxLayout,
QLabel, QSizePolicy, QToolBar, QToolButton, QGridLayout, QStyle, QAction,
QWidget, QApplication, QSpacerItem )
QWidget, QApplication, QSpacerItem, QSplitter, QFrame )

from hscommon.trans import trget
from hscommon import desktop
Expand All @@ -25,7 +25,6 @@ def __init__(self, parent, app):
self.vController = None
super().__init__(parent, app)


def setupActions(self):
# (name, shortcut, icon, desc, func)
ACTIONS = [
Expand Down Expand Up @@ -63,11 +62,17 @@ def setupActions(self):
def _setupUi(self):
self.setupActions()
self.setWindowTitle(tr("Details"))
self.resize(502, 295)
self.setMinimumSize(QSize(250, 250))
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.resize(502, 502)
self.setMinimumSize(QSize(500, 500))

# self.verticalLayout = QVBoxLayout(self)
# self.verticalLayout.setSpacing(0)
# self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.splitter = QSplitter(Qt.Vertical, self)
self.setCentralWidget(self.splitter)
self.topFrame = QFrame()
self.topFrame.setFrameShape(QFrame.StyledPanel)

self.horizontalLayout = QGridLayout()
# Minimum width for the toolbar in the middle:
self.horizontalLayout.setColumnMinimumWidth(1, 10)
Expand Down Expand Up @@ -157,20 +162,33 @@ def _setupUi(self):
# self.referenceImageViewer.setSizePolicy(sizePolicy)
# self.referenceImageViewer.setAlignment(Qt.AlignCenter)
self.horizontalLayout.addWidget(self.referenceImageViewer, 0, 2, 3, 1)
self.verticalLayout.addLayout(self.horizontalLayout)
# self.verticalLayout.addLayout(self.horizontalLayout)
self.topFrame.setLayout(self.horizontalLayout)
self.splitter.addWidget(self.topFrame)

# container = QWidget(self)
# container.setLayout(self.horizontalLayout)
# self.setLayout(self.horizontalLayout)
# self.splitter.addWidget(self)
self.splitter.setStretchFactor(0, 8)

self.tableView = DetailsTable(self)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.tableView.sizePolicy().hasHeightForWidth())
# sizePolicy.setHeightForWidth(self.tableView.sizePolicy().hasHeightForWidth())
self.tableView.setSizePolicy(sizePolicy)
self.tableView.setMinimumSize(QSize(0, 188))
self.tableView.setMaximumSize(QSize(16777215, 190))
# self.tableView.setMinimumSize(QSize(0, 190))
# self.tableView.setMaximumSize(QSize(16777215, 190))

self.tableView.setAlternatingRowColors(True)
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tableView.setShowGrid(False)
self.verticalLayout.addWidget(self.tableView)
# self.verticalLayout.addLayout(self.tableView)

self.splitter.addWidget(self.tableView)
self.splitter.setStretchFactor(1, 1)

# self.tableView.hide()

self.buttonImgSwap.setEnabled(False)
Expand Down Expand Up @@ -207,7 +225,7 @@ def _update(self):
group = self.app.model.results.get_group_of_duplicate(dupe)
ref = group.ref

if self.vController is None:
if self.vController is None: # Not yet constructed!
return
self.vController.update(ref, dupe)

Expand Down Expand Up @@ -237,6 +255,10 @@ def resizeEvent(self, event):
self.vController._updateImages()

def show(self):
# Compute the maximum size the table view can reach
self.tableView.setMaximumHeight(
self.tableView.rowHeight(1) * self.tableModel.model.row_count()\
+ self.tableView.verticalHeader().sectionSize(0))
DetailsDialogBase.show(self)
self._update()

Expand Down

0 comments on commit 977c20f

Please sign in to comment.