diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-01-04 08:57:25 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-01-04 08:57:25 +0100 |
commit | 8ce494b17065c724187dd3f9faec1e419496f871 (patch) | |
tree | fa0c7fb1296f30bfd0cdc241c7556cec8d1e8ba1 /raphodo/computerview.py | |
parent | 18afe3e2ebdb10bbc542d79280344d9adf923d2f (diff) | |
parent | eba0a9bd6f142cdb299cc070060723d00e81205f (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'raphodo/computerview.py')
-rw-r--r-- | raphodo/computerview.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/raphodo/computerview.py b/raphodo/computerview.py new file mode 100644 index 0000000..87664e8 --- /dev/null +++ b/raphodo/computerview.py @@ -0,0 +1,85 @@ +# Copyright (C) 2016 Damon Lynch <damonlynch@gmail.com> + +# This file is part of Rapid Photo Downloader. +# +# Rapid Photo Downloader is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Rapid Photo Downloader is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Rapid Photo Downloader. If not, +# see <http://www.gnu.org/licenses/>. + +""" +Combines a deviceview and a file system view into one widget +""" + +__author__ = 'Damon Lynch' +__copyright__ = "Copyright 2016, Damon Lynch" + +from typing import Union +from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QSplitter, QSizePolicy, QFrame) + +from raphodo.devicedisplay import DeviceView, EmulatedHeaderRow, device_header_row_height +from raphodo.filebrowse import FileSystemView +from raphodo.destinationdisplay import DestinationDisplay +from raphodo.constants import minFileSystemViewHeight +from raphodo.viewutils import QFramedWidget + + +class ComputerWidget(QFramedWidget): + """ + Combines a device view or destination display, and a file system view, into one widget. + + Also contains an empty header row that emulates the look of an actual header row for a + a device view or destination display -- it's used when a valid destination or source is + not yet specified. + """ + + def __init__(self, objectName: str, + view: Union[DeviceView, DestinationDisplay], + fileSystemView: FileSystemView, + select_text: str, + parent: QWidget=None) -> None: + + super().__init__(parent) + self.setObjectName(objectName) + layout = QVBoxLayout() + border_width = QSplitter().lineWidth() + layout.setContentsMargins(border_width, border_width, border_width, border_width) + layout.setSpacing(0) + self.setLayout(layout) + + self.view = view + self.view.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) + self.fileSystemView = fileSystemView + self.emulatedHeader = EmulatedHeaderRow(select_text) + self.emulatedHeader.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) + + layout.addWidget(self.emulatedHeader) + layout.addWidget(self.view) + layout.addStretch() + layout.addWidget(self.fileSystemView, 5) + self.view.setStyleSheet('QListView {border: none;}') + self.fileSystemView.setStyleSheet('FileSystemView {border: none;}') + + def setViewVisible(self, visible: bool) -> None: + self.view.setVisible(visible) + self.emulatedHeader.setVisible(not visible) + self.view.updateGeometry() + + def minimumHeight(self) -> int: + if self.view.isVisible(): + height = self.view.minimumHeight() + else: + height = device_header_row_height() + height += minFileSystemViewHeight() + return height + + |