-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving style of tabbed dock widgets for Cosmic theme, specifically…
… to remove the duplicate titles (i.e. Project Files / Project Files). Also working to restore the ability for dock widgets to be detached and reattached easily, and minimized/maximized like normal windows when floating.
- Loading branch information
Showing
9 changed files
with
451 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
""" | ||
@file | ||
@brief This file contains a custom title bar used by dock widgets | ||
@author Jonathan Thomas <[email protected]> | ||
@section LICENSE | ||
Copyright (c) 2008-2024 OpenShot Studios, LLC | ||
(http://www.openshotstudios.com). This file is part of | ||
OpenShot Video Editor (http://www.openshot.org), an open-source project | ||
dedicated to delivering high quality video editing and animation solutions | ||
to the world. | ||
OpenShot Video Editor 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. | ||
OpenShot Video Editor 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 OpenShot Library. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QLabel | ||
|
||
|
||
class HiddenTitleBar(QWidget): | ||
def __init__(self, dock_widget, title_text=""): | ||
super().__init__() | ||
self.dock_widget = dock_widget | ||
self.dragging = False # Flag for dragging | ||
self.start_pos = None | ||
|
||
# Set up a horizontal layout | ||
layout = QHBoxLayout(self) | ||
|
||
# Add a QLabel for the title (optional, based on title_text) | ||
title_label = QLabel(title_text) | ||
if title_text: | ||
title_label.setObjectName("dock-title-label") | ||
else: | ||
title_label.setObjectName("dock-title-handle") | ||
|
||
# Add the QLabel to the layout | ||
layout.addWidget(title_label) | ||
|
||
# Add a spacer to push buttons to the right | ||
layout.addStretch() | ||
|
||
# Add close and undock buttons | ||
close_button = QPushButton() | ||
undock_button = QPushButton() | ||
|
||
# Set object names for styling via stylesheets | ||
close_button.setObjectName("dock-close-button") | ||
undock_button.setObjectName("dock-float-button") | ||
|
||
# Connect the buttons to the appropriate actions | ||
close_button.clicked.connect(self.dock_widget.close) | ||
undock_button.clicked.connect(self.toggle_dock_state) | ||
|
||
# Add buttons to the layout | ||
layout.addWidget(undock_button) | ||
layout.addWidget(close_button) | ||
|
||
# Set margins and reduce height for the title bar | ||
layout.setContentsMargins(0, 0, 0, 0) | ||
self.setFixedHeight(20) # Reduced height | ||
|
||
def toggle_dock_state(self): | ||
"""Toggle between docked and floating states.""" | ||
if self.dock_widget.isFloating(): | ||
# Restore the default title bar when docking | ||
self.dock_widget.setFloating(False) | ||
else: | ||
# Float the widget and apply custom title bar | ||
self.dock_widget.setFloating(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.