Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stretch background of left pane #1210

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 11 additions & 23 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,39 +178,26 @@ class LeftPane(QWidget):
def __init__(self):
super().__init__()

self.setObjectName("LeftPane")

# Set layout
layout = QVBoxLayout(self)
self.setLayout(layout)

# Remove margins and spacing
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.setAlignment(Qt.AlignBottom)
self.setFixedWidth(198)

# Set background image
self.logo = QWidget()
self.online_palette = QPalette()
# the sd logo on the background image becomes more faded in offline mode
self.online_palette.setBrush(QPalette.Background, QBrush(load_image("left_pane.svg")))
self.offline_palette = QPalette()
self.offline_palette.setBrush(
QPalette.Background, QBrush(load_image("left_pane_offline.svg"))
)
self.logo.setPalette(self.offline_palette)
self.logo.setAutoFillBackground(True)
self.logo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.logo.setEnabled(False)

# User profile
self.branding_barre = QLabel()
self.branding_barre.setPixmap(load_image("left_pane.svg"))
self.user_profile = UserProfile()

# Hide user profile widget until user logs in
self.user_profile.hide()

# Add widgets to layout
layout.addWidget(self.user_profile)
layout.addWidget(self.logo)
layout.addWidget(self.branding_barre)

def setup(self, window, controller):
self.user_profile.setup(window, controller)
Expand All @@ -221,14 +208,14 @@ def set_logged_in_as(self, db_user: User):
"""
self.user_profile.set_user(db_user)
self.user_profile.show()
self.logo.setPalette(self.online_palette)
self.branding_barre.setPixmap(load_image("left_pane.svg"))

def set_logged_out(self):
"""
Update the UI to a logged out state.
"""
self.user_profile.hide()
self.logo.setPalette(self.offline_palette)
self.branding_barre.setPixmap(load_image("left_pane_offline.svg"))


class SyncIcon(QLabel):
Expand Down Expand Up @@ -401,10 +388,11 @@ def __init__(self):

# Set background
palette = QPalette()
palette.setBrush(QPalette.Background, QBrush(QColor("#0096DC")))
palette.setBrush(
QPalette.Background, QBrush(Qt.NoBrush)
) # This makes the widget transparent
self.setPalette(palette)
self.setAutoFillBackground(True)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

# Set layout
layout = QHBoxLayout(self)
Expand Down
8 changes: 7 additions & 1 deletion securedrop_client/resources/css/sdclient.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@
color: #0c3e75;
}

#LeftPane {
min-width: 198;
max-width: 198;
}

#UserProfile {
background-color: #0096dc;
padding: 15px;
min-height: 200px
min-height: 60px
}

#UserProfile_icon {
Expand Down
1 change: 1 addition & 0 deletions securedrop_client/resources/images/left_pane.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions securedrop_client/resources/images/left_pane_offline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/integration/test_styles_sdclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_styles_for_left_pane(mocker, main_window):

def test_styles_for_main_view(mocker, main_window):
main_view = main_window.main_view
assert 558 == main_view.height()
assert 558 == main_view.minimumSize().height()
assert "#f9f9ff" == main_view.view_holder.palette().color(QPalette.Background).name()

assert 640 == main_view.empty_conversation_view.minimumSize().width()
Expand Down