Skip to content

Commit

Permalink
Rename CategoryStyle to RibbonCategoryStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Hailin Wang committed Jul 23, 2022
1 parent 79b3a43 commit c243f50
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ribbon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .category import RibbonCategory, CategoryStyle, RibbonNormalCategory, RibbonContextCategory
from .category import RibbonCategory, RibbonCategoryStyle, RibbonNormalCategory, RibbonContextCategory
from .categorylayoutwidget import (RibbonCategoryLayoutWidget, RibbonCategoryLayoutButton, RibbonCategoryScrollArea,
RibbonCategoryScrollAreaContents)
from .gallery import RibbonGallery, RibbonGalleryListWidget, RibbonGalleryButton, RibbonGalleryPopupListWidget
Expand Down
16 changes: 8 additions & 8 deletions ribbon/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .typehints import RibbonType


class CategoryStyle(enum.IntEnum):
class RibbonCategoryStyle(enum.IntEnum):
"""The button style of a category."""
Normal = 0
Context = 1
Expand All @@ -33,7 +33,7 @@ class RibbonCategory(QtWidgets.QFrame):
#: The ribbon parent of this category
_ribbon: typing.Optional[RibbonType]
#: The button style of the category.
_style: CategoryStyle
_style: RibbonCategoryStyle
#: Panels
_panels: typing.Dict[str, RibbonPanel]
#: color of the context category
Expand All @@ -42,7 +42,7 @@ class RibbonCategory(QtWidgets.QFrame):
#: The signal that is emitted when the display options button is clicked.
displayOptionsButtonClicked = QtCore.pyqtSignal(bool)

def __init__(self, title: str, style: CategoryStyle = CategoryStyle.Normal, color: QtGui.QColor = None,
def __init__(self, title: str, style: RibbonCategoryStyle = RibbonCategoryStyle.Normal, color: QtGui.QColor = None,
parent=None):
"""Create a new category.
Expand All @@ -68,7 +68,7 @@ def title(self) -> str:
"""Return the title of the category."""
return self._title

def setCategoryStyle(self, style: CategoryStyle):
def setCategoryStyle(self, style: RibbonCategoryStyle):
"""Set the button style of the category.
:param style: The button style.
Expand Down Expand Up @@ -136,9 +136,9 @@ def __init__(self, title: str, parent: QtWidgets.QWidget):
:param title: The title of the category.
:param parent: The parent widget.
"""
super().__init__(title, CategoryStyle.Normal, parent=parent)
super().__init__(title, RibbonCategoryStyle.Normal, parent=parent)

def setCategoryStyle(self, style: CategoryStyle):
def setCategoryStyle(self, style: RibbonCategoryStyle):
"""Set the button style of the category.
:param style: The button style.
Expand All @@ -156,9 +156,9 @@ def __init__(self, title: str, color: QtGui.QColor, parent: QtWidgets.QWidget):
:param color: The color of the context category.
:param parent: The parent widget.
"""
super().__init__(title, CategoryStyle.Context, color=color, parent=parent)
super().__init__(title, RibbonCategoryStyle.Context, color=color, parent=parent)

def setCategoryStyle(self, style: CategoryStyle):
def setCategoryStyle(self, style: RibbonCategoryStyle):
"""Set the button style of the category.
:param style: The button style.
Expand Down
16 changes: 8 additions & 8 deletions ribbon/ribbonbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from PyQt5 import QtWidgets, QtCore, QtGui

from .category import RibbonCategory, RibbonContextCategory, RibbonNormalCategory, CategoryStyle, contextColors
from .category import RibbonCategory, RibbonContextCategory, RibbonNormalCategory, RibbonCategoryStyle, contextColors
from .separator import RibbonHorizontalSeparator
from .titlewidget import RibbonTitleWidget
from .utils import data_file_path
Expand Down Expand Up @@ -210,7 +210,7 @@ def categories(self) -> typing.List[RibbonCategory]:
def addCategory(
self,
title: str,
style=CategoryStyle.Normal,
style=RibbonCategoryStyle.Normal,
color: QtGui.QColor = None,
) -> typing.Union[RibbonNormalCategory, RibbonContextCategory]:
"""Add a new category to the ribbon.
Expand All @@ -221,23 +221,23 @@ def addCategory(
will be used.
:return: The newly created category.
"""
if style == CategoryStyle.Context:
if style == RibbonCategoryStyle.Context:
if color is None:
color = contextColors[self._contextCategoryCount % len(contextColors)]
self._contextCategoryCount += 1
category = (RibbonContextCategory(title, color, self) if style == CategoryStyle.Context else
category = (RibbonContextCategory(title, color, self) if style == RibbonCategoryStyle.Context else
RibbonNormalCategory(title, self))
category.setFixedHeight(self._ribbonHeight -
self._mainLayout.spacing() * 2 -
self._mainLayout.contentsMargins().top() -
self._mainLayout.contentsMargins().bottom() -
self._titleWidget.height() -
self._separator.height() - 4) # 4: extra space for drawing lines when debugging
if style == CategoryStyle.Normal:
if style == RibbonCategoryStyle.Normal:
self._categories.append(category)
self._titleWidget.tabBar().addTab(title, color)
self._stackedWidget.addWidget(category)
elif style == CategoryStyle.Context:
elif style == RibbonCategoryStyle.Context:
category.hide()
return category

Expand All @@ -247,7 +247,7 @@ def addNormalCategory(self, title: str) -> RibbonNormalCategory:
:param title: The title of the category.
:return: The newly created category.
"""
return self.addCategory(title, CategoryStyle.Normal)
return self.addCategory(title, RibbonCategoryStyle.Normal)

def addContextCategory(self, title: str, color: QtGui.QColor = None) -> RibbonContextCategory:
"""Add a new context category to the ribbon.
Expand All @@ -256,7 +256,7 @@ def addContextCategory(self, title: str, color: QtGui.QColor = None) -> RibbonCo
:param color: The color of the context category, if None, the default color will be used.
:return: The newly created category.
"""
return self.addCategory(title, CategoryStyle.Context, color)
return self.addCategory(title, RibbonCategoryStyle.Context, color)

def showContextCategory(self, category: RibbonContextCategory):
"""Show the given category, if it is not a context category, nothing happens.
Expand Down

0 comments on commit c243f50

Please sign in to comment.