diff --git a/.all-contributorsrc b/.all-contributorsrc
deleted file mode 100644
index d150871e..00000000
--- a/.all-contributorsrc
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "projectName": "dayu_widgets",
- "projectOwner": "loonghao",
- "repoType": "github",
- "commitConvention": "angular",
- "repoHost": "https://github.com",
- "files": [
- "README.md"
- ],
- "imageSize": 100,
- "commit": true,
- "contributorsPerLine": 7,
- "contributors": [
- {
- "login": "loonghao",
- "name": "Hal",
- "avatar_url": "https://avatars1.githubusercontent.com/u/13111745?v=4",
- "profile": "https://github.com/loonghao",
- "contributions": [
- "ci"
- ]
- },
- {
- "login": "Yanru Mu",
- "name": "Yanru Mu",
- "avatar_url": "https://avatars.githubusercontent.com/u/1860334?v=4",
- "profile": "https://github.com/muyr",
- "contributions": [
- "code"
- ]
- },
- {
- "login": "FXTD-ODYSSEY",
- "name": "FXTD-ODYSSEY",
- "avatar_url": "https://avatars.githubusercontent.com/u/40897360?v=4",
- "profile": "https://github.com/FXTD-ODYSSEY",
- "contributions": [
- "code"
- ]
- },
- ],
- "skipCi": true
-}
diff --git a/.flake8 b/.flake8
deleted file mode 100644
index d92822a4..00000000
--- a/.flake8
+++ /dev/null
@@ -1,3 +0,0 @@
-[flake8]
-ignore = BLK100
-max-line-length = 88
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index eefa0fee..00000000
--- a/.gitignore
+++ /dev/null
@@ -1,108 +0,0 @@
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
-# C extensions
-*.so
-
-# Distribution / packaging
-.Python
-build/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-wheels/
-*.egg-info/
-.installed.cfg
-*.egg
-MANIFEST
-
-# PyInstaller
-# Usually these files are written by a python script from a template
-# before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*.cover
-.hypothesis/
-.pytest_cache/
-
-# Translations
-*.mo
-*.pot
-
-# Django stuff:
-*.log
-local_settings.py
-db.sqlite3
-
-# Flask stuff:
-instance/
-.webassets-cache
-
-# Scrapy stuff:
-.scrapy
-
-# Sphinx documentation
-docs/_build/
-
-# PyBuilder
-target/
-
-# Jupyter Notebook
-.ipynb_checkpoints
-
-# pyenv
-.python-version
-
-# celery beat schedule file
-celerybeat-schedule
-
-# SageMath parsed files
-*.sage.py
-
-# Environments
-.env
-.venv
-env/
-venv/
-ENV/
-env.bak/
-venv.bak/
-
-# Spyder project settings
-.spyderproject
-.spyproject
-
-# Rope project settings
-.ropeproject
-
-# mkdocs documentation
-/site
-
-# mypy
-.mypy_cache/
-.idea/
-
-scripts/deploy.json
-.vscode
\ No newline at end of file
diff --git a/.hound.yml b/.hound.yml
deleted file mode 100644
index faeeeeb9..00000000
--- a/.hound.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-python:
- enabled: true
-
-flake8:
- enabled: true
- config_file: .flake8
-
-fail_on_violations: true
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
deleted file mode 100644
index a415a30a..00000000
--- a/.pre-commit-config.yaml
+++ /dev/null
@@ -1,52 +0,0 @@
-# See https://pre-commit.com for more information
-# See https://pre-commit.com/hooks.html for more hooks
-repos:
- - repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.0.1
- hooks:
- - id: trailing-whitespace
- - id: end-of-file-fixer
- - id: check-yaml
- - id: check-ast
- - id: check-toml
- - id: check-json
- - id: check-xml
- - id: check-merge-conflict # Check for files that contain merge conflict strings
- # - id: fix-encoding-pragma # Remove the coding pragma: # -*- coding: utf-8 -*-
- # - id: mixed-line-ending # Replace or check mixed line ending
- # args: ["--fix=lf"]
- - id: check-added-large-files
- exclude: dayu_widgets/static/
- - repo: https://github.com/ambv/black
- rev: 21.11b1
- hooks:
- - id: black
- language: python
- types: [python]
- - repo: https://github.com/hadialqattan/pycln
- rev: v1.1.0
- hooks:
- - id: pycln
- args: [--config=pyproject.toml]
- - repo: https://github.com/pycqa/isort
- rev: 5.10.1
- hooks:
- - id: isort
- name: isort (python)
- # - repo: https://gitlab.com/pycqa/flake8
- # rev: 3.7.9
- # hooks:
- # - id: flake8
- # - repo: local
- # hooks:
- # - id: pylint
- # name: pylint
- # entry: pylint
- # language: system
- # types: [python]
- # args: ["--max-line-length=80", "--disable=E1101,R0912"]
- - repo: https://github.com/commitizen-tools/commitizen
- rev: v2.20.0
- hooks:
- - id: commitizen
- stages: [commit-msg]
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 70c0096e..00000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,119 +0,0 @@
-## v0.13.1 (2023-09-26)
-
-### Fix
-
-- fix header view context menu Select Invert
-
-## v0.13.0 (2023-09-25)
-
-### Feat
-
-- #66 support python 3.10
-
-## v0.12.2 (2023-08-17)
-
-### Fix
-
-- #67 fix MToolButon set_dayu_size use a custom value, not work
-
-## v0.12.1 (2023-08-17)
-
-### Fix
-
-- flow layout delete item; add clear method
-
-## v0.12.0 (2023-08-17)
-
-### Feat
-
-- add theme var for big view scale #65
-
-## v0.11.6 (2023-03-07)
-
-### Fix
-
-- compat with PyQt5
-
-## v0.11.5 (2022-07-22)
-
-### Fix
-
-- **MItemView**: fix header view order(sort) setting
-
-## v0.11.4 (2022-07-22)
-
-### Fix
-
-- **MItemViewSet-MItemViewFullSet**: fix headerView state restore
-
-## v0.11.3 (2022-07-20)
-
-### Fix
-
-- **MTheme**: fix MTheme.deco function
-
-## v0.11.2 (2022-07-19)
-
-### Fix
-
-- **MPage**: fix MPage sig_page_changed bug
-
-## v0.11.1 (2022-07-19)
-
-### Fix
-
-- fix MLineEdit delay signal not work when user use Chinese input method
-
-## v0.11.0 (2021-12-28)
-
-### Feat
-
-- **MComboBox**: using MCompleter
-
-### Refactor
-
-- **MMenu**: clean up menu code
-- fix example application
-
-## v0.10.1 (2021-12-15)
-
-### Refactor
-
-- **examples**: use application function to launch example
-
-## v0.10.0 (2021-12-14)
-
-### Feat
-
-- **MSplitter**: add animatable feature
-
-## v0.9.1 (2021-12-14)
-
-### Fix
-
-- **MPopup**: fix PyQt5 setMask bug & clean code
-
-## v0.9.0 (2021-12-08)
-
-### Feat
-
-- add MCompleter and MSplitter widget
-
-## v0.8.0 (2021-12-06)
-
-### Fix
-
-- deploy fialed
-- add __all__ import
-- delegate example rename for demo.py
-- clean combox search code
-- chinese input support
-
-### Feat
-
-- edit read_settings and write_settings
-- edit read_settings and write_settings
-- add search and scroll for MMenu
-- add MPopup widget
-- add delegate example
-- add searchable combo box
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 7f73b706..00000000
--- a/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018 phenom-films
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 4f36893a..00000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-recursive-include dayu_widgets/static *
-include MANIFEST.in
diff --git a/README.md b/README.md
deleted file mode 100644
index a8c4fbda..00000000
--- a/README.md
+++ /dev/null
@@ -1,200 +0,0 @@
-# dayu_widgets
-
-
-
-
-
-
-
-
-
-
-
-
-[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
-
-
-
-
-Components for PySide
-
-主要参考了 [AntDesign](https://ant.design/) 组件库,其他参考了 [iView](https://www.iviewui.com/) 组件库,微信基础组件。
-
-更多在此基础上的组件插件:
-
-* [dayu_widgets_tag](https://github.com/muyr/dayu_widgets_tag): [中文](https://muyr.github.io/dayu_widgets_tag/#/zh-cn/) | [EN](https://muyr.github.io/dayu_widgets_tag/#/)
-* [dayu_widgets_log](https://github.com/muyr/dayu_widgets_log): [中文](https://muyr.github.io/dayu_widgets_log/#/zh-cn/) | [EN](https://muyr.github.io/dayu_widgets_log/#/)
-* [dayu_widgets_overlay](https://github.com/FXTD-ODYSSEY/dayu_widgets_overlay)
-
-提供**亮色(light)** 和 **暗色(dark)** 两种主题,每种主题可以设置主题颜色。
-以下截图以:
-
-* 亮色 #1890ff
-* 暗色 #fa8c16
-
-## General
-
-
-### MPushButton(<- QPushButton)
-![pageres](screenshots/push_button_light.png)![pageres](screenshots/push_button_dark.png)
-
-### MLabel (<- QLabel)
-![pageres](screenshots/label_light.png)![pageres](screenshots/label_dark.png)
-
-### MLoading (<- QWidget)
-![pageres](screenshots/loading_light.gif)![pageres](screenshots/loading_dark.gif)
-
-### MToolButton (<- QToolButton)
-![pageres](screenshots/tool_button_light.png)![pageres](screenshots/tool_button_dark.png)
-
-## Navigation
-
-
-### MBreadcrumb (<- QWidget)
-![pageres](screenshots/breadcrumb_light.gif)![pageres](screenshots/breadcrumb_dark.gif)
-
-### MMenuTabWidget (<- QWidget)
-![pageres](screenshots/menu_tab_widget_light.png)![pageres](screenshots/menu_tab_widget_dark.png)
-
-### MPage (<- QWidget)
-![pageres](screenshots/page_light.png)![pageres](screenshots/page_dark.png)
-
-
-## Data Entry
-
-
-### MCheckBox <- QCheckBox
-![pageres](screenshots/check_box_light.png)![pageres](screenshots/check_box_dark.png)
-
-### MClickBrowserFilePushButton <- MPushButton
-### MClickBrowserFileToolButton <- MToolButton
-### MClickBrowserFolderPushButton <- MPushButton
-### MClickBrowserFolderToolButton <- MToolButton
-### MDragFileButton <- MToolButton
-### MDragFolderButton <- MToolButton
-![pageres](screenshots/browser_light.png)![pageres](screenshots/browser_dark.png)
-
-### MLineEdit <- QLineEdit
-![pageres](screenshots/line_edit_light.png)![pageres](screenshots/line_edit_dark.png)
-
-### MRadioButton <- QRadioButton
-![pageres](screenshots/radio_button_light.png)![pageres](screenshots/radio_button_dark.png)
-
-### MSwitch <- QRadioButton
-![pageres](screenshots/switch_light.png)![pageres](screenshots/switch_dark.png)
-
-### MSilder <- QSlider
-![pageres](screenshots/slider_light.png)![pageres](screenshots/slider_dark.png)
-
-### MSpinBox <- QSpinBox
-### MDoubleSpinBox <- QDoubleSpinBox
-### MDateTimeEdit <- QDateTimeEdit
-### MDateEdit <- QDateEdit
-### MTimeEdit <- QTimeEdit
-![pageres](screenshots/spin_box_light.png)![pageres](screenshots/spin_box_dark.png)
-
-
-## Data Display
-
-
-### MAvatar <- QLabel
-![pageres](screenshots/avatar_light.png)![pageres](screenshots/avatar_dark.png)
-
-### MBadge <- QWidget
-![pageres](screenshots/badge_light.png)![pageres](screenshots/badge_dark.png)
-
-
-### MCarousel <- QGraphicsView
-![pageres](screenshots/carousel_light.gif)![pageres](screenshots/carousel_dark.gif)
-
-### MCard <- QWidget
-![pageres](screenshots/card_light.png)![pageres](screenshots/card_dark.png)
-
-### MCollapse <- QWidget
-![pageres](screenshots/collapse_light.gif)![pageres](screenshots/collapse_dark.gif)
-
-### MLineTabWidget <- QWidget
-![pageres](screenshots/line_tab_widget_light.gif)![pageres](screenshots/line_tab_widget_dark.gif)
-
-### MTag <- QLabel
-### MCheckableTag <- QCheckBox
-### MNewTag <- QWidget
-![pageres](screenshots/tag_light.png)![pageres](screenshots/tag_dark.png)
-
-
-## Feedback
-
-
-### MAlert <- QWidget
-![pageres](screenshots/alert_light.png)![pageres](screenshots/alert_dark.png)
-
-### MDrawer <- QWidget
-![pageres](screenshots/drawer_light.gif)![pageres](screenshots/drawer_dark.gif)
-
-### MMessage <- QWidget
-![pageres](screenshots/message_light.gif)![pageres](screenshots/message_dark.gif)
-
-### MProgressBar <- QProgressBar
-![pageres](screenshots/progressbar_light.gif)![pageres](screenshots/progressbar_dark.gif)
-
-### MProgressCircle <- QProgressBar
-![pageres](screenshots/progress_circle_light.png)![pageres](screenshots/progress_circle_dark.png)
-
-### MToast <- QWidget
-![pageres](screenshots/toast_light.gif)![pageres](screenshots/toast_dark.gif)
-
-## Other
-
-### MDivider <- QWidget
-![pageres](screenshots/divider_light.png)![pageres](screenshots/divider_dark.png)
-
-
-# 如何贡献代码
-
-## 安装poetry
-``shell
-pip install poetry
-``
-## 安装依赖
-```shell
-poetry install
-```
-
-## 运行单元测试
-```shell
-poetry run pytest
-```
-
-## 运行 black检查
-```shell
-poetry run black dayu_widgets
-```
-## 运行isort
-```shell
-poetry run isort dayu_widgets
-```
-
-## 提交代码
-```shell
-poetry run cz commit
-```
-
-## Contributors ✨
-
-Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
-
-
-
-
-
-
-
-
-
-
diff --git a/dayu_widgets/__init__.py b/dayu_widgets/__init__.py
deleted file mode 100644
index 5e3b48b1..00000000
--- a/dayu_widgets/__init__.py
+++ /dev/null
@@ -1,137 +0,0 @@
-# -*- coding: utf-8 -*-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import os
-
-
-DEFAULT_STATIC_FOLDER = os.path.join(__path__[0], "static")
-CUSTOM_STATIC_FOLDERS = []
-# Import local modules
-from dayu_widgets.theme import MTheme
-
-
-dayu_theme = MTheme("dark", primary_color=MTheme.orange)
-# dayu_theme.default_size = dayu_theme.small
-# dayu_theme = MTheme('light')
-
-# Import local modules
-from dayu_widgets.alert import MAlert
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.badge import MBadge
-from dayu_widgets.breadcrumb import MBreadcrumb
-from dayu_widgets.browser import MClickBrowserFilePushButton
-from dayu_widgets.browser import MClickBrowserFileToolButton
-from dayu_widgets.browser import MClickBrowserFolderPushButton
-from dayu_widgets.browser import MClickBrowserFolderToolButton
-from dayu_widgets.browser import MDragFileButton
-from dayu_widgets.browser import MDragFolderButton
-from dayu_widgets.button_group import MCheckBoxGroup
-from dayu_widgets.button_group import MPushButtonGroup
-from dayu_widgets.button_group import MRadioButtonGroup
-from dayu_widgets.button_group import MToolButtonGroup
-from dayu_widgets.card import MCard
-from dayu_widgets.card import MMeta
-from dayu_widgets.carousel import MCarousel
-from dayu_widgets.check_box import MCheckBox
-from dayu_widgets.collapse import MCollapse
-from dayu_widgets.combo_box import MComboBox
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.flow_layout import MFlowLayout
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MBigView
-from dayu_widgets.item_view import MListView
-from dayu_widgets.item_view import MTableView
-from dayu_widgets.item_view import MTreeView
-from dayu_widgets.item_view_full_set import MItemViewFullSet
-from dayu_widgets.item_view_set import MItemViewSet
-from dayu_widgets.label import MLabel
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.line_tab_widget import MLineTabWidget
-from dayu_widgets.loading import MLoading
-from dayu_widgets.loading import MLoadingWrapper
-from dayu_widgets.menu import MMenu
-from dayu_widgets.menu_tab_widget import MMenuTabWidget
-from dayu_widgets.message import MMessage
-from dayu_widgets.page import MPage
-from dayu_widgets.progress_bar import MProgressBar
-from dayu_widgets.progress_circle import MProgressCircle
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.radio_button import MRadioButton
-from dayu_widgets.sequence_file import MSequenceFile
-from dayu_widgets.slider import MSlider
-from dayu_widgets.spin_box import MDateEdit
-from dayu_widgets.spin_box import MDateTimeEdit
-from dayu_widgets.spin_box import MDoubleSpinBox
-from dayu_widgets.spin_box import MSpinBox
-from dayu_widgets.spin_box import MTimeEdit
-from dayu_widgets.switch import MSwitch
-from dayu_widgets.tab_widget import MTabWidget
-from dayu_widgets.text_edit import MTextEdit
-from dayu_widgets.toast import MToast
-from dayu_widgets.tool_button import MToolButton
-
-
-__all__ = [
- "MAlert",
- "MAvatar",
- "MBadge",
- "MBreadcrumb",
- "MClickBrowserFilePushButton",
- "MClickBrowserFileToolButton",
- "MClickBrowserFolderPushButton",
- "MClickBrowserFolderToolButton",
- "MDragFileButton",
- "MDragFolderButton",
- "MCheckBoxGroup",
- "MPushButtonGroup",
- "MRadioButtonGroup",
- "MToolButtonGroup",
- "MCard",
- "MMeta",
- "MCarousel",
- "MCheckBox",
- "MCollapse",
- "MComboBox",
- "MDivider",
- "MFieldMixin",
- "MFlowLayout",
- "MSortFilterModel",
- "MTableModel",
- "MBigView",
- "MListView",
- "MTableView",
- "MTreeView",
- "MItemViewFullSet",
- "MItemViewSet",
- "MLabel",
- "MLineEdit",
- "MLineTabWidget",
- "MLoading",
- "MLoadingWrapper",
- "MMenu",
- "MMenuTabWidget",
- "MMessage",
- "MPage",
- "MProgressBar",
- "MProgressCircle",
- "MPushButton",
- "MRadioButton",
- "MSequenceFile",
- "MSlider",
- "MDateEdit",
- "MDateTimeEdit",
- "MDoubleSpinBox",
- "MSpinBox",
- "MTimeEdit",
- "MSwitch",
- "MTabWidget",
- "MTextEdit",
- "MToast",
- "MToolButton",
-]
diff --git a/dayu_widgets/__version__.py b/dayu_widgets/__version__.py
deleted file mode 100644
index a5707a27..00000000
--- a/dayu_widgets/__version__.py
+++ /dev/null
@@ -1,7 +0,0 @@
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-
-__version__ = "0.13.1"
diff --git a/dayu_widgets/alert.py b/dayu_widgets/alert.py
deleted file mode 100644
index a621a392..00000000
--- a/dayu_widgets/alert.py
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MAlert class.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-import six
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.label import MLabel
-from dayu_widgets.mixin import property_mixin
-from dayu_widgets.qt import MPixmap
-from dayu_widgets.qt import get_scale_factor
-from dayu_widgets.tool_button import MToolButton
-
-
-@property_mixin
-class MAlert(QtWidgets.QWidget):
- """
- Alert component for feedback.
-
- Property:
- dayu_type: The feedback type with different color container.
- dayu_text: The feedback string showed in container.
- """
-
- InfoType = "info"
- SuccessType = "success"
- WarningType = "warning"
- ErrorType = "error"
-
- def __init__(self, text="", parent=None, flags=QtCore.Qt.Widget):
- super(MAlert, self).__init__(parent, flags)
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
- self._icon_label = MAvatar()
- self._icon_label.set_dayu_size(dayu_theme.tiny)
- self._content_label = MLabel().secondary()
- self._close_button = MToolButton().svg("close_line.svg").tiny().icon_only()
- self._close_button.clicked.connect(functools.partial(self.setVisible, False))
- scale_x, _ = get_scale_factor()
- margin = 8 * scale_x
- self._main_lay = QtWidgets.QHBoxLayout()
- self._main_lay.setContentsMargins(margin, margin, margin, margin)
- self._main_lay.addWidget(self._icon_label)
- self._main_lay.addWidget(self._content_label)
- self._main_lay.addStretch()
- self._main_lay.addWidget(self._close_button)
-
- self.setLayout(self._main_lay)
-
- self.set_show_icon(True)
- self.set_closable(False)
- self._dayu_type = None
- self._dayu_text = None
- self.set_dayu_type(MAlert.InfoType)
- self.set_dayu_text(text)
-
- def set_closable(self, closable):
- """Display the close icon button or not."""
- self._close_button.setVisible(closable)
-
- def set_show_icon(self, show_icon):
- """Display the information type icon or not."""
- self._icon_label.setVisible(show_icon)
-
- def _set_dayu_text(self):
- self._content_label.setText(self._dayu_text)
- self.setVisible(bool(self._dayu_text))
-
- def set_dayu_text(self, value):
- """Set the feedback content."""
- if isinstance(value, six.string_types):
- self._dayu_text = value
- else:
- raise TypeError(
- "Input argument 'value' should be string type, "
- "but get {}".format(type(value))
- )
- self._set_dayu_text()
-
- def _set_dayu_type(self):
- self._icon_label.set_dayu_image(
- MPixmap(
- "{}_fill.svg".format(self._dayu_type),
- vars(dayu_theme).get(self._dayu_type + "_color"),
- )
- )
- self.style().polish(self)
-
- def set_dayu_type(self, value):
- """Set feedback type."""
- if value in [
- MAlert.InfoType,
- MAlert.SuccessType,
- MAlert.WarningType,
- MAlert.ErrorType,
- ]:
- self._dayu_type = value
- else:
- raise ValueError(
- "Input argument 'value' should be one of "
- "info/success/warning/error string."
- )
- self._set_dayu_type()
-
- def get_dayu_type(self):
- """
- Get MAlert feedback type.
- :return: str
- """
- return self._dayu_type
-
- def get_dayu_text(self):
- """
- Get MAlert feedback message.
- :return: six.string_types
- """
- return self._dayu_text
-
- dayu_text = QtCore.Property(six.text_type, get_dayu_text, set_dayu_text)
- dayu_type = QtCore.Property(str, get_dayu_type, set_dayu_type)
-
- def info(self):
- """Set MAlert to InfoType"""
- self.set_dayu_type(MAlert.InfoType)
- return self
-
- def success(self):
- """Set MAlert to SuccessType"""
- self.set_dayu_type(MAlert.SuccessType)
- return self
-
- def warning(self):
- """Set MAlert to WarningType"""
- self.set_dayu_type(MAlert.WarningType)
- return self
-
- def error(self):
- """Set MAlert to ErrorType"""
- self.set_dayu_type(MAlert.ErrorType)
- return self
-
- def closable(self):
- """Set MAlert closebale is True"""
- self.set_closable(True)
- return self
diff --git a/dayu_widgets/avatar.py b/dayu_widgets/avatar.py
deleted file mode 100644
index 4738c8bb..00000000
--- a/dayu_widgets/avatar.py
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MAvatar.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.qt import MPixmap
-
-
-class MAvatar(QtWidgets.QLabel):
- """
- Avatar component. It can be used to represent people or object.
-
- Property:
- image: avatar image, should be QPixmap.
- dayu_size: the size of image.
- """
-
- def __init__(self, parent=None, flags=QtCore.Qt.Widget):
- super(MAvatar, self).__init__(parent, flags)
- self._default_pix = MPixmap("user_fill.svg")
- self._pixmap = self._default_pix
- self._dayu_size = 0
- self.set_dayu_size(dayu_theme.default_size)
-
- def set_dayu_size(self, value):
- """
- Set the avatar size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self._set_dayu_size()
-
- def _set_dayu_size(self):
- self.setFixedSize(QtCore.QSize(self._dayu_size, self._dayu_size))
- self._set_dayu_image()
-
- def _set_dayu_image(self):
- self.setPixmap(
- self._pixmap.scaledToWidth(self.height(), QtCore.Qt.SmoothTransformation)
- )
-
- def set_dayu_image(self, value):
- """
- Set avatar image.
- :param value: QPixmap or None.
- :return: None
- """
- if value is None:
- self._pixmap = self._default_pix
- elif isinstance(value, QtGui.QPixmap):
- self._pixmap = self._default_pix if value.isNull() else value
- else:
- raise TypeError(
- "Input argument 'value' should be QPixmap or None, "
- "but get {}".format(type(value))
- )
- self._set_dayu_image()
-
- def get_dayu_image(self):
- """
- Get the avatar image.
- :return: QPixmap
- """
- return self._pixmap
-
- def get_dayu_size(self):
- """
- Get the avatar size
- :return: integer
- """
- return self._dayu_size
-
- dayu_image = QtCore.Property(QtGui.QPixmap, get_dayu_image, set_dayu_image)
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- @classmethod
- def huge(cls, image=None):
- """Create a MAvatar with huge size"""
- inst = cls()
- inst.set_dayu_size(dayu_theme.huge)
- inst.set_dayu_image(image)
- return inst
-
- @classmethod
- def large(cls, image=None):
- """Create a MAvatar with large size"""
- inst = cls()
- inst.set_dayu_size(dayu_theme.large)
- inst.set_dayu_image(image)
- return inst
-
- @classmethod
- def medium(cls, image=None):
- """Create a MAvatar with medium size"""
- inst = cls()
- inst.set_dayu_size(dayu_theme.medium)
- inst.set_dayu_image(image)
- return inst
-
- @classmethod
- def small(cls, image=None):
- """Create a MAvatar with small size"""
- inst = cls()
- inst.set_dayu_size(dayu_theme.small)
- inst.set_dayu_image(image)
- return inst
-
- @classmethod
- def tiny(cls, image=None):
- """Create a MAvatar with tiny size"""
- inst = cls()
- inst.set_dayu_size(dayu_theme.tiny)
- inst.set_dayu_image(image)
- return inst
diff --git a/dayu_widgets/badge.py b/dayu_widgets/badge.py
deleted file mode 100644
index 3f44bdda..00000000
--- a/dayu_widgets/badge.py
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""
-MBadge
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import utils
-
-
-class MBadge(QtWidgets.QWidget):
- """
- Badge normally appears in proximity to notifications or user avatars with eye-catching appeal,
- typically displaying unread messages count.
- Show something at the wrapped widget top right.
- There is 3 type styles:
- dot: show a dot
- count: show a number at
- text: show a string
-
- Property:
- dayu_dot: bool
- dayu_text: six.string_types
- dayu_count: int
- dayu_overflow: int
- """
-
- def __init__(self, widget=None, parent=None):
- super(MBadge, self).__init__(parent)
- self._widget = widget
- self._overflow_count = 99
-
- self._dot = False
- self._text = None
- self._count = None
-
- self._badge_button = QtWidgets.QPushButton()
- self._badge_button.setSizePolicy(
- QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum
- )
-
- self._main_lay = QtWidgets.QGridLayout()
- self._main_lay.setContentsMargins(0, 0, 0, 0)
- if widget is not None:
- self._main_lay.addWidget(widget, 0, 0)
- self._main_lay.addWidget(
- self._badge_button, 0, 0, QtCore.Qt.AlignTop | QtCore.Qt.AlignRight
- )
- self.setLayout(self._main_lay)
-
- def get_dayu_overflow(self):
- """
- Get current overflow number
- :return: int
- """
- return self._overflow_count
-
- def set_dayu_overflow(self, num):
- """
- Set the overflow number
- :param num: new max number
- :return: None
- """
- self._overflow_count = num
- self._update_number()
-
- def get_dayu_dot(self):
- """
- Get current style is dot or not and dot is show or not
- :return: bool
- """
- return self._dot
-
- def set_dayu_dot(self, show):
- """
- Set dot style and weather show the dot or not
- :param show: bool
- :return: None
- """
- self._dot = show
- self._badge_button.setText("")
- self._badge_button.setVisible(show)
- self.style().polish(self)
-
- def get_dayu_count(self):
- """
- Get actual count number
- :return: int
- """
- return self._count
-
- def set_dayu_count(self, num):
- """
- Set current style to show a number
-
- :param num: int
- :return: None
- """
- self._count = num
- self._update_number()
-
- def _update_number(self):
- self._badge_button.setText(
- utils.overflow_format(self._count, self._overflow_count)
- )
- self._badge_button.setVisible(self._count > 0)
- self._dot = False
- self.style().polish(self)
-
- def get_dayu_text(self):
- """
- Get current showed text
- :return: six.string_types
- """
- return self._text
-
- def set_dayu_text(self, text):
- """
- Set current style to show a text.
- :param text: six.string_types
- :return: None
- """
- self._text = text
- self._badge_button.setText(self._text)
- self._badge_button.setVisible(bool(self._text))
- self._dot = False
- self.style().polish(self)
-
- dayu_overflow = QtCore.Property(int, get_dayu_overflow, set_dayu_overflow)
- dayu_dot = QtCore.Property(bool, get_dayu_dot, set_dayu_dot)
- dayu_count = QtCore.Property(int, get_dayu_count, set_dayu_count)
- dayu_text = QtCore.Property(str, get_dayu_text, set_dayu_text)
-
- @classmethod
- def dot(cls, show=False, widget=None):
- """
- Create a Badge with dot style.
- :param show: bool
- :param widget: the wrapped widget
- :return: instance badge
- """
- inst = cls(widget=widget)
- inst.set_dayu_dot(show)
- return inst
-
- @classmethod
- def count(cls, count=0, widget=None):
- """
- Create a Badge with number style.
- :param count: int
- :param widget: the wrapped widget
- :return: instance badge
- """
- inst = cls(widget=widget)
- inst.set_dayu_count(count)
- return inst
-
- @classmethod
- def text(cls, text="", widget=None):
- """
- Create a Badge with text style.
- :param text: six.string_types
- :param widget: the wrapped widget
- :return: instance badge
- """
- inst = cls(widget=widget)
- inst.set_dayu_text(text)
- return inst
diff --git a/dayu_widgets/breadcrumb.py b/dayu_widgets/breadcrumb.py
deleted file mode 100644
index c3fa9fce..00000000
--- a/dayu_widgets/breadcrumb.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""
-MBreadcrumb
-"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.label import MLabel
-from dayu_widgets.tool_button import MToolButton
-
-
-class MBreadcrumb(QtWidgets.QWidget):
- """
- MBreadcrumb
-
- A breadcrumb displays the current location within a hierarchy.
- It allows going back to states higher up in the hierarchy.
- """
-
- def __init__(self, separator="/", parent=None):
- super(MBreadcrumb, self).__init__(parent)
- self._separator = separator
- self._main_layout = QtWidgets.QHBoxLayout()
- self._main_layout.setContentsMargins(0, 0, 0, 0)
- self._main_layout.setSpacing(0)
- self._main_layout.addStretch()
- self.setLayout(self._main_layout)
- self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
- self._button_group = QtWidgets.QButtonGroup()
- self._label_list = []
-
- def set_item_list(self, data_list):
- """Set the whole breadcrumb items. It will clear the old widgets."""
- for button in self._button_group.buttons():
- self._button_group.removeButton(button)
- self._main_layout.removeWidget(button)
- button.setVisible(False)
- for sep in self._label_list:
- self._main_layout.removeWidget(sep)
- sep.setVisible(False)
-
- for index, data_dict in enumerate(data_list):
- self.add_item(data_dict, index)
-
- def add_item(self, data_dict, index=None):
- """Add a item"""
- button = MToolButton()
- button.setText(data_dict.get("text"))
- if data_dict.get("svg"):
- button.svg(data_dict.get("svg"))
- if data_dict.get("tooltip"):
- button.setProperty("toolTip", data_dict.get("tooltip"))
- if data_dict.get("clicked"):
- button.clicked.connect(data_dict.get("clicked"))
- if data_dict.get("text"):
- if data_dict.get("svg") or data_dict.get("icon"):
- button.text_beside_icon()
- else:
- button.text_only()
- else:
- button.icon_only()
-
- if self._button_group.buttons():
- separator = MLabel(self._separator).secondary()
- self._label_list.append(separator)
- self._main_layout.insertWidget(self._main_layout.count() - 1, separator)
- self._main_layout.insertWidget(self._main_layout.count() - 1, button)
-
- if index is None:
- self._button_group.addButton(button)
- else:
- self._button_group.addButton(button, index)
diff --git a/dayu_widgets/browser.py b/dayu_widgets/browser.py
deleted file mode 100644
index 091af106..00000000
--- a/dayu_widgets/browser.py
+++ /dev/null
@@ -1,589 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MClickBrowserFilePushButton, MClickBrowserFileToolButton
-MClickBrowserFolderPushButton, MClickBrowserFolderToolButton
-Browser files or folders by selecting.
-
-MDragFileButton, MDragFolderButton
-Browser files or folders by dragging.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import os
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-import six
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import cursor_mixin
-from dayu_widgets.mixin import property_mixin
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.tool_button import MToolButton
-
-
-# NOTE PySide2 Crash without QObject wrapper
-# @Slot()
-def _slot_browser_file(self):
- filter_list = (
- "File(%s)" % (" ".join(["*" + e for e in self.get_dayu_filters()]))
- if self.get_dayu_filters()
- else "Any File(*)"
- )
- if self.get_dayu_multiple():
- r_files, _ = QtWidgets.QFileDialog.getOpenFileNames(
- self, "Browser File", self.get_dayu_path(), filter_list
- )
- if r_files:
- self.sig_files_changed.emit(r_files)
- self.set_dayu_path(r_files[0])
- else:
- r_file, _ = QtWidgets.QFileDialog.getOpenFileName(
- self, "Browser File", self.get_dayu_path(), filter_list
- )
- if r_file:
- self.sig_file_changed.emit(r_file)
- self.set_dayu_path(r_file)
-
-
-# @Slot()
-def _slot_browser_folder(self):
- r_folder = QtWidgets.QFileDialog.getExistingDirectory(
- self, "Browser Folder", self.get_dayu_path()
- )
- if r_folder:
- if self.get_dayu_multiple():
- self.sig_folders_changed.emit([r_folder])
- else:
- self.sig_folder_changed.emit(r_folder)
- self.set_dayu_path(r_folder)
-
-
-# @Slot()
-def _slot_save_file(self):
- filter_list = (
- "File(%s)" % (" ".join(["*" + e for e in self.get_dayu_filters()]))
- if self.get_dayu_filters()
- else "Any File(*)"
- )
- r_file, _ = QtWidgets.QFileDialog.getSaveFileName(
- self, "Save File", self.get_dayu_path(), filter_list
- )
- if r_file:
- self.sig_file_changed.emit(r_file)
- self.set_dayu_path(r_file)
-
-
-class MClickBrowserFilePushButton(MPushButton):
- """A Clickable push button to browser files"""
-
- sig_file_changed = QtCore.Signal(str)
- sig_files_changed = QtCore.Signal(list)
- slot_browser_file = _slot_browser_file
-
- def __init__(self, text="Browser", multiple=False, parent=None):
- super(MClickBrowserFilePushButton, self).__init__(text=text, parent=parent)
- self.setProperty("multiple", multiple)
- self.clicked.connect(self.slot_browser_file)
- self.setToolTip(self.tr("Click to browser file"))
-
- self._path = None
- self._multiple = multiple
- self._filters = []
-
- def get_dayu_filters(self):
- """
- Get browser's format filters
- :return: list
- """
- return self._filters
-
- def set_dayu_filters(self, value):
- """
- Set browser file format filters
- :param value:
- :return: None
- """
- self._filters = value
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- def get_dayu_multiple(self):
- """
- Get browser can select multiple file or not
- :return: bool
- """
- return self._multiple
-
- def set_dayu_multiple(self, value):
- """
- Set browser can select multiple file or not
- :param value: bool
- :return: None
- """
- self._multiple = value
-
- dayu_multiple = QtCore.Property(bool, get_dayu_multiple, set_dayu_multiple)
- dayu_path = QtCore.Property(six.string_types[0], get_dayu_path, set_dayu_path)
- dayu_filters = QtCore.Property(list, get_dayu_filters, set_dayu_filters)
-
-
-class MClickBrowserFileToolButton(MToolButton):
- """A Clickable tool button to browser files"""
-
- sig_file_changed = QtCore.Signal(str)
- sig_files_changed = QtCore.Signal(list)
- slot_browser_file = _slot_browser_file
-
- def __init__(self, multiple=False, parent=None):
- super(MClickBrowserFileToolButton, self).__init__(parent=parent)
- self.set_dayu_svg("cloud_line.svg")
- self.icon_only()
- self.clicked.connect(self.slot_browser_file)
- self.setToolTip(self.tr("Click to browser file"))
-
- self._path = None
- self._multiple = multiple
- self._filters = []
-
- def get_dayu_filters(self):
- """
- Get browser's format filters
- :return: list
- """
- return self._filters
-
- def set_dayu_filters(self, value):
- """
- Set browser file format filters
- :param value:
- :return: None
- """
- self._filters = value
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- def get_dayu_multiple(self):
- """
- Get browser can select multiple file or not
- :return: bool
- """
- return self._multiple
-
- def set_dayu_multiple(self, value):
- """
- Set browser can select multiple file or not
- :param value: bool
- :return: None
- """
- self._multiple = value
-
- dayu_multiple = QtCore.Property(bool, get_dayu_multiple, set_dayu_multiple)
- dayu_path = QtCore.Property(six.string_types[0], get_dayu_path, set_dayu_path)
- dayu_filters = QtCore.Property(list, get_dayu_filters, set_dayu_filters)
-
-
-class MClickSaveFileToolButton(MToolButton):
- """A Clickable tool button to browser files"""
-
- sig_file_changed = QtCore.Signal(str)
- slot_browser_file = _slot_save_file
-
- def __init__(self, multiple=False, parent=None):
- super(MClickSaveFileToolButton, self).__init__(parent=parent)
- self.set_dayu_svg("save_line.svg")
- self.icon_only()
- self.clicked.connect(self.slot_browser_file)
- self.setToolTip(self.tr("Click to save file"))
-
- self._path = None
- self._multiple = multiple
- self._filters = []
-
- def get_dayu_filters(self):
- """
- Get browser's format filters
- :return: list
- """
- return self._filters
-
- def set_dayu_filters(self, value):
- """
- Set browser file format filters
- :param value:
- :return: None
- """
- self._filters = value
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- dayu_path = QtCore.Property(six.string_types[0], get_dayu_path, set_dayu_path)
- dayu_filters = QtCore.Property(list, get_dayu_filters, set_dayu_filters)
-
-
-class MDragFileButton(MToolButton):
- """A Clickable and draggable tool button to upload files"""
-
- sig_file_changed = QtCore.Signal(str)
- sig_files_changed = QtCore.Signal(list)
- slot_browser_file = _slot_browser_file
-
- def __init__(self, text="", multiple=False, parent=None):
- super(MDragFileButton, self).__init__(parent=parent)
- self.setAcceptDrops(True)
- self.setMouseTracking(True)
- self.text_under_icon()
- self.setText(text)
- size = dayu_theme.drag_size
- self.set_dayu_size(size)
- self.setIconSize(QtCore.QSize(size, size))
- self.set_dayu_svg("cloud_line.svg")
-
- self.clicked.connect(self.slot_browser_file)
- self.setSizePolicy(
- QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding
- )
- self.setToolTip(self.tr("Click to browser file"))
-
- self._path = None
- self._multiple = multiple
- self._filters = []
-
- def get_dayu_filters(self):
- """
- Get browser's format filters
- :return: list
- """
- return self._filters
-
- def set_dayu_filters(self, value):
- """
- Set browser file format filters
- :param value:
- :return: None
- """
- self._filters = value
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- def get_dayu_multiple(self):
- """
- Get browser can select multiple file or not
- :return: bool
- """
- return self._multiple
-
- def set_dayu_multiple(self, value):
- """
- Set browser can select multiple file or not
- :param value: bool
- :return: None
- """
- self._multiple = value
-
- dayu_multiple = QtCore.Property(bool, get_dayu_multiple, set_dayu_multiple)
- dayu_path = QtCore.Property(six.string_types[0], get_dayu_path, set_dayu_path)
- dayu_filters = QtCore.Property(list, get_dayu_filters, set_dayu_filters)
-
- def dragEnterEvent(self, event):
- """Override dragEnterEvent. Validate dragged files"""
- if event.mimeData().hasFormat("text/uri-list"):
- file_list = self._get_valid_file_list(event.mimeData().urls())
- count = len(file_list)
- if count == 1 or (count > 1 and self.get_dayu_multiple()):
- event.acceptProposedAction()
- return
-
- def dropEvent(self, event):
- """Override dropEvent to accept the dropped files"""
- file_list = self._get_valid_file_list(event.mimeData().urls())
- if self.get_dayu_multiple():
- self.sig_files_changed.emit(file_list)
- self.set_dayu_path(file_list)
- else:
- self.sig_file_changed.emit(file_list[0])
- self.set_dayu_path(file_list[0])
-
- def _get_valid_file_list(self, url_list):
- # Import built-in modules
- import subprocess
- import sys
-
- file_list = []
- for url in url_list:
- file_name = url.toLocalFile()
- if sys.platform == "darwin":
- sub_process = subprocess.Popen(
- "osascript -e 'get posix path of posix file \"file://{}\" -- kthxbai'".format(
- file_name
- ),
- stdout=subprocess.PIPE,
- shell=True,
- )
- # print sub_process.communicate()[0].strip()
- file_name = sub_process.communicate()[0].strip()
- sub_process.wait()
-
- if os.path.isfile(file_name):
- if self.get_dayu_filters():
- if os.path.splitext(file_name)[-1] in self.get_dayu_filters():
- file_list.append(file_name)
- else:
- file_list.append(file_name)
-
- return file_list
-
-
-class MClickBrowserFolderPushButton(MPushButton):
- """A Clickable push button to browser folders"""
-
- sig_folder_changed = QtCore.Signal(str)
- sig_folders_changed = QtCore.Signal(list)
- slot_browser_folder = _slot_browser_folder
-
- def __init__(self, text="", multiple=False, parent=None):
- super(MClickBrowserFolderPushButton, self).__init__(text=text, parent=parent)
- self.setProperty("multiple", multiple)
- self.clicked.connect(self.slot_browser_folder)
- self.setToolTip(self.tr("Click to browser folder"))
-
- self._path = None
- self._multiple = multiple
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- def get_dayu_multiple(self):
- """
- Get browser can select multiple file or not
- :return: bool
- """
- return self._multiple
-
- def set_dayu_multiple(self, value):
- """
- Set browser can select multiple file or not
- :param value: bool
- :return: None
- """
- self._multiple = value
-
- dayu_multiple = QtCore.Property(bool, get_dayu_multiple, set_dayu_multiple)
- dayu_path = QtCore.Property(six.string_types[0], get_dayu_path, set_dayu_path)
-
-
-@property_mixin
-class MClickBrowserFolderToolButton(MToolButton):
- """A Clickable tool button to browser folders"""
-
- sig_folder_changed = QtCore.Signal(str)
- sig_folders_changed = QtCore.Signal(list)
- slot_browser_folder = _slot_browser_folder
-
- def __init__(self, multiple=False, parent=None):
- super(MClickBrowserFolderToolButton, self).__init__(parent=parent)
-
- self.set_dayu_svg("folder_line.svg")
- self.icon_only()
- self.clicked.connect(self.slot_browser_folder)
- self.setToolTip(self.tr("Click to browser folder"))
-
- self._path = None
- self._multiple = multiple
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- def get_dayu_multiple(self):
- """
- Get browser can select multiple file or not
- :return: bool
- """
- return self._multiple
-
- def set_dayu_multiple(self, value):
- """
- Set browser can select multiple file or not
- :param value: bool
- :return: None
- """
- self._multiple = value
-
- dayu_multiple = QtCore.Property(bool, get_dayu_multiple, set_dayu_multiple)
- dayu_path = QtCore.Property(six.string_types[0], get_dayu_path, set_dayu_path)
-
-
-@property_mixin
-@cursor_mixin
-class MDragFolderButton(MToolButton):
- """A Clickable and draggable tool button to browser folders"""
-
- sig_folder_changed = QtCore.Signal(str)
- sig_folders_changed = QtCore.Signal(list)
- slot_browser_folder = _slot_browser_folder
-
- def __init__(self, multiple=False, parent=None):
- super(MDragFolderButton, self).__init__(parent=parent)
- self.setAcceptDrops(True)
- self.setMouseTracking(True)
- self.text_under_icon()
- self.set_dayu_svg("folder_line.svg")
- size = dayu_theme.drag_size
- self.set_dayu_size(size)
- self.setIconSize(QtCore.QSize(size, size))
- self.setText(self.tr("Click or drag folder here"))
- self.clicked.connect(self.slot_browser_folder)
- self.setSizePolicy(
- QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding
- )
- self.setToolTip(self.tr("Click to browser folder or drag folder here"))
-
- self._path = None
- self._multiple = multiple
-
- def get_dayu_path(self):
- """
- Get last browser file path
- :return: str
- """
- return self._path
-
- def set_dayu_path(self, value):
- """
- Set browser file start path
- :param value: str
- :return: None
- """
- self._path = value
-
- def get_dayu_multiple(self):
- """
- Get browser can select multiple file or not
- :return: bool
- """
- return self._multiple
-
- def set_dayu_multiple(self, value):
- """
- Set browser can select multiple file or not
- :param value: bool
- :return: None
- """
- self._multiple = value
-
- dayu_multiple = QtCore.Property(bool, get_dayu_multiple, set_dayu_multiple)
- dayu_path = QtCore.Property(bool, get_dayu_path, set_dayu_path)
-
- def dragEnterEvent(self, event):
- """Override dragEnterEvent. Validate dragged folders"""
- if event.mimeData().hasFormat("text/uri-list"):
- folder_list = [
- url.toLocalFile()
- for url in event.mimeData().urls()
- if os.path.isdir(url.toLocalFile())
- ]
- count = len(folder_list)
- if count == 1 or (count > 1 and self.get_dayu_multiple()):
- event.acceptProposedAction()
- return
-
- def dropEvent(self, event):
- """Override dropEvent to accept the dropped folders"""
- folder_list = [
- url.toLocalFile()
- for url in event.mimeData().urls()
- if os.path.isdir(url.toLocalFile())
- ]
- if self.get_dayu_multiple():
- self.sig_folders_changed.emit(folder_list)
- else:
- self.sig_folder_changed.emit(folder_list[0])
- self.set_dayu_path(folder_list[0])
diff --git a/dayu_widgets/button_group.py b/dayu_widgets/button_group.py
deleted file mode 100644
index 51a51f13..00000000
--- a/dayu_widgets/button_group.py
+++ /dev/null
@@ -1,299 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-import six
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.check_box import MCheckBox
-from dayu_widgets.menu import MMenu
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import get_scale_factor
-from dayu_widgets.radio_button import MRadioButton
-from dayu_widgets.tool_button import MToolButton
-
-
-class MButtonGroupBase(QtWidgets.QWidget):
- def __init__(self, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MButtonGroupBase, self).__init__(parent=parent)
- self._main_layout = QtWidgets.QBoxLayout(
- QtWidgets.QBoxLayout.LeftToRight
- if orientation == QtCore.Qt.Horizontal
- else QtWidgets.QBoxLayout.TopToBottom
- )
- self._main_layout.setContentsMargins(0, 0, 0, 0)
- self.setLayout(self._main_layout)
- self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
- self._button_group = QtWidgets.QButtonGroup()
- self._orientation = (
- "horizontal" if orientation == QtCore.Qt.Horizontal else "vertical"
- )
-
- def set_spacing(self, value):
- self._main_layout.setSpacing(value)
-
- def get_button_group(self):
- return self._button_group
-
- def create_button(self, data_dict):
- raise NotImplementedError()
-
- def add_button(self, data_dict, index=None):
- if isinstance(data_dict, six.string_types):
- data_dict = {"text": data_dict}
- elif isinstance(data_dict, QtGui.QIcon):
- data_dict = {"icon": data_dict}
- button = self.create_button(data_dict)
- button.setProperty("combine", self._orientation)
- if data_dict.get("text"):
- button.setProperty("text", data_dict.get("text"))
- if data_dict.get("icon"):
- button.setProperty("icon", data_dict.get("icon"))
- if data_dict.get("data"):
- button.setProperty("data", data_dict.get("data"))
- if data_dict.get("checked"):
- button.setProperty("checked", data_dict.get("checked"))
- if data_dict.get("shortcut"):
- button.setProperty("shortcut", data_dict.get("shortcut"))
- if data_dict.get("tooltip"):
- button.setProperty("toolTip", data_dict.get("tooltip"))
- if data_dict.get("checkable"):
- button.setProperty("checkable", data_dict.get("checkable"))
- if data_dict.get("clicked"):
- button.clicked.connect(data_dict.get("clicked"))
- if data_dict.get("toggled"):
- button.toggled.connect(data_dict.get("toggled"))
-
- if index is None:
- self._button_group.addButton(button)
- else:
- self._button_group.addButton(button, index)
- self._main_layout.insertWidget(self._main_layout.count(), button)
- return button
-
- def set_button_list(self, button_list):
- for button in self._button_group.buttons():
- self._button_group.removeButton(button)
- self._main_layout.removeWidget(button)
- button.setVisible(False)
- for index, data_dict in enumerate(button_list):
- button = self.add_button(data_dict, index)
- if index == 0:
- button.setProperty("position", "left")
- elif index == len(button_list) - 1:
- button.setProperty("position", "right")
- else:
- button.setProperty("position", "center")
-
-
-class MPushButtonGroup(MButtonGroupBase):
- def __init__(self, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MPushButtonGroup, self).__init__(orientation=orientation, parent=parent)
- self.set_spacing(1)
- self._dayu_type = MPushButton.PrimaryType
- self._dayu_size = dayu_theme.default_size
- self._button_group.setExclusive(False)
-
- def create_button(self, data_dict):
- button = MPushButton()
- button.set_dayu_size(data_dict.get("dayu_size", self._dayu_size))
- button.set_dayu_type(data_dict.get("dayu_type", self._dayu_type))
- return button
-
- def get_dayu_size(self):
- return self._dayu_size
-
- def get_dayu_type(self):
- return self._dayu_type
-
- def set_dayu_size(self, value):
- self._dayu_size = value
-
- def set_dayu_type(self, value):
- self._dayu_type = value
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
- dayu_type = QtCore.Property(str, get_dayu_type, set_dayu_type)
-
-
-class MCheckBoxGroup(MButtonGroupBase):
- sig_checked_changed = QtCore.Signal(list)
-
- def __init__(self, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MCheckBoxGroup, self).__init__(orientation=orientation, parent=parent)
- scale_x, _ = get_scale_factor()
- self.set_spacing(15 * scale_x)
- self._button_group.setExclusive(False)
-
- self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- self.customContextMenuRequested.connect(self._slot_context_menu)
-
- self._button_group.buttonClicked[int].connect(self._slot_map_signal)
- self._dayu_checked = []
-
- def create_button(self, data_dict):
- return MCheckBox()
-
- @QtCore.Slot(QtCore.QPoint)
- def _slot_context_menu(self, point):
- context_menu = MMenu(parent=self)
- action_select_all = context_menu.addAction("Select All")
- action_select_none = context_menu.addAction("Select None")
- action_select_invert = context_menu.addAction("Select Invert")
- action_select_all.triggered.connect(
- functools.partial(self._slot_set_select, True)
- )
- action_select_none.triggered.connect(
- functools.partial(self._slot_set_select, False)
- )
- action_select_invert.triggered.connect(
- functools.partial(self._slot_set_select, None)
- )
- context_menu.exec_(QtGui.QCursor.pos() + QtCore.QPoint(10, 10))
-
- @QtCore.Slot(bool)
- def _slot_set_select(self, state):
- for check_box in self._button_group.buttons():
- if state is None:
- old_state = check_box.isChecked()
- check_box.setChecked(not old_state)
- else:
- check_box.setChecked(state)
- self._slot_map_signal()
-
- @QtCore.Slot(int)
- def _slot_map_signal(self, state=None):
- self.sig_checked_changed.emit(
- [
- check_box.text()
- for check_box in self._button_group.buttons()
- if check_box.isChecked()
- ]
- )
-
- def set_dayu_checked(self, value):
- if not isinstance(value, list):
- value = [value]
- if value == self.get_dayu_checked():
- return
-
- self._dayu_checked = value
- for check_box in self._button_group.buttons():
- flag = (
- QtCore.Qt.Checked if check_box.text() in value else QtCore.Qt.Unchecked
- )
- if flag != check_box.checkState():
- check_box.setCheckState(flag)
- self.sig_checked_changed.emit(value)
-
- def get_dayu_checked(self):
- return [
- check_box.text()
- for check_box in self._button_group.buttons()
- if check_box.isChecked()
- ]
-
- dayu_checked = QtCore.Property(
- "QVariantList", get_dayu_checked, set_dayu_checked, notify=sig_checked_changed
- )
-
-
-class MRadioButtonGroup(MButtonGroupBase):
- """
- Property:
- dayu_checked
- """
-
- sig_checked_changed = QtCore.Signal(int)
-
- def __init__(self, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MRadioButtonGroup, self).__init__(orientation=orientation, parent=parent)
- scale_x, _ = get_scale_factor()
- self.set_spacing(15 * scale_x)
- self._button_group.setExclusive(True)
- self._button_group.buttonClicked[int].connect(self.sig_checked_changed)
-
- def create_button(self, data_dict):
- return MRadioButton()
-
- def set_dayu_checked(self, value):
- if value == self.get_dayu_checked():
- return
- button = self._button_group.button(value)
- if button:
- button.setChecked(True)
- self.sig_checked_changed.emit(value)
- else:
- print("error")
-
- def get_dayu_checked(self):
- return self._button_group.checkedId()
-
- dayu_checked = QtCore.Property(
- int, get_dayu_checked, set_dayu_checked, notify=sig_checked_changed
- )
-
-
-class MToolButtonGroup(MButtonGroupBase):
- sig_checked_changed = QtCore.Signal(int)
-
- def __init__(
- self,
- size=None,
- type=None,
- exclusive=False,
- orientation=QtCore.Qt.Horizontal,
- parent=None,
- ):
- super(MToolButtonGroup, self).__init__(orientation=orientation, parent=parent)
- self.set_spacing(1)
- self._button_group.setExclusive(exclusive)
- self._size = size
- self._type = type
- self._button_group.buttonClicked[int].connect(self.sig_checked_changed)
-
- def create_button(self, data_dict):
- button = MToolButton()
- if data_dict.get("svg"):
- button.svg(data_dict.get("svg"))
- if data_dict.get("text"):
- if data_dict.get("svg") or data_dict.get("icon"):
- button.text_beside_icon()
- else:
- button.text_only()
- else:
- button.icon_only()
- return button
-
- def set_dayu_checked(self, value):
- if value == self.get_dayu_checked():
- return
- button = self._button_group.button(value)
- if button:
- button.setChecked(True)
- self.sig_checked_changed.emit(value)
- else:
- print("error")
-
- def get_dayu_checked(self):
- return self._button_group.checkedId()
-
- dayu_checked = QtCore.Property(
- int, get_dayu_checked, set_dayu_checked, notify=sig_checked_changed
- )
diff --git a/dayu_widgets/card.py b/dayu_widgets/card.py
deleted file mode 100644
index 3aa4c20b..00000000
--- a/dayu_widgets/card.py
+++ /dev/null
@@ -1,159 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.divider import MDivider
-from dayu_widgets.label import MLabel
-from dayu_widgets.mixin import cursor_mixin
-from dayu_widgets.mixin import hover_shadow_mixin
-from dayu_widgets.tool_button import MToolButton
-
-
-@hover_shadow_mixin
-@cursor_mixin
-class MCard(QtWidgets.QWidget):
- def __init__(
- self, title=None, image=None, size=None, extra=None, type=None, parent=None
- ):
- super(MCard, self).__init__(parent=parent)
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
- self.setProperty("border", False)
- size = size or dayu_theme.default_size
- map_label = {
- dayu_theme.large: (MLabel.H2Level, 20),
- dayu_theme.medium: (MLabel.H3Level, 15),
- dayu_theme.small: (MLabel.H4Level, 10),
- }
- self._title_label = MLabel(text=title)
- self._title_label.set_dayu_level(map_label.get(size)[0])
-
- padding = map_label.get(size)[-1]
- self._title_layout = QtWidgets.QHBoxLayout()
- self._title_layout.setContentsMargins(padding, padding, padding, padding)
- if image:
- self._title_icon = MAvatar()
- self._title_icon.set_dayu_image(image)
- self._title_icon.set_dayu_size(size)
- self._title_layout.addWidget(self._title_icon)
- self._title_layout.addWidget(self._title_label)
- self._title_layout.addStretch()
- if extra:
- self._extra_button = MToolButton().icon_only().svg("more.svg")
- self._title_layout.addWidget(self._extra_button)
-
- self._content_layout = QtWidgets.QVBoxLayout()
-
- self._main_lay = QtWidgets.QVBoxLayout()
- self._main_lay.setSpacing(0)
- self._main_lay.setContentsMargins(1, 1, 1, 1)
- if title:
- self._main_lay.addLayout(self._title_layout)
- self._main_lay.addWidget(MDivider())
- self._main_lay.addLayout(self._content_layout)
- self.setLayout(self._main_lay)
-
- def get_more_button(self):
- return self._extra_button
-
- def set_widget(self, widget):
- self._content_layout.addWidget(widget)
-
- def border(self):
- self.setProperty("border", True)
- self.style().polish(self)
- return self
-
-
-@hover_shadow_mixin
-@cursor_mixin
-class MMeta(QtWidgets.QWidget):
- def __init__(
- self,
- cover=None,
- avatar=None,
- title=None,
- description=None,
- extra=False,
- parent=None,
- ):
- super(MMeta, self).__init__(parent)
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
- self._cover_label = QtWidgets.QLabel()
- self._avatar = MAvatar()
- self._title_label = MLabel().h4()
- self._description_label = MLabel().secondary()
- self._description_label.setWordWrap(True)
- self._description_label.set_elide_mode(QtCore.Qt.ElideRight)
- self._title_layout = QtWidgets.QHBoxLayout()
- self._title_layout.addWidget(self._title_label)
- self._title_layout.addStretch()
- self._extra_button = MToolButton(parent=self).icon_only().svg("more.svg")
- self._title_layout.addWidget(self._extra_button)
- self._extra_button.setVisible(extra)
-
- content_lay = QtWidgets.QFormLayout()
- content_lay.setContentsMargins(5, 5, 5, 5)
- content_lay.addRow(self._avatar, self._title_layout)
- content_lay.addRow(self._description_label)
-
- self._button_layout = QtWidgets.QHBoxLayout()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.setSpacing(0)
- main_lay.setContentsMargins(1, 1, 1, 1)
- main_lay.addWidget(self._cover_label)
- main_lay.addLayout(content_lay)
- main_lay.addLayout(self._button_layout)
- main_lay.addStretch()
- self.setLayout(main_lay)
- self._cover_label.setFixedSize(QtCore.QSize(200, 200))
- # self.setFixedWidth(200)
-
- def get_more_button(self):
- return self._extra_button
-
- def setup_data(self, data_dict):
- if data_dict.get("title"):
- self._title_label.setText(data_dict.get("title"))
- self._title_label.setVisible(True)
- else:
- self._title_label.setVisible(False)
-
- if data_dict.get("description"):
- self._description_label.setText(data_dict.get("description"))
- self._description_label.setVisible(True)
- else:
- self._description_label.setVisible(False)
-
- if data_dict.get("avatar"):
- self._avatar.set_dayu_image(data_dict.get("avatar"))
- self._avatar.setVisible(True)
- else:
- self._avatar.setVisible(False)
-
- if data_dict.get("cover"):
- fixed_height = self._cover_label.width()
- self._cover_label.setPixmap(
- data_dict.get("cover").scaledToWidth(
- fixed_height, QtCore.Qt.SmoothTransformation
- )
- )
- self._cover_label.setVisible(True)
- else:
- self._cover_label.setVisible(False)
diff --git a/dayu_widgets/carousel.py b/dayu_widgets/carousel.py
deleted file mode 100644
index a5c55b27..00000000
--- a/dayu_widgets/carousel.py
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import property_mixin
-
-
-class MGuidPrivate(QtWidgets.QFrame):
- sig_go_to_page = QtCore.Signal()
-
- def __init__(self, parent=None):
- super(MGuidPrivate, self).__init__(parent)
- self.setCursor(QtCore.Qt.PointingHandCursor)
- self.set_checked(False)
-
- def set_checked(self, value):
- self.setStyleSheet(
- "background-color:{}".format(
- dayu_theme.primary_color if value else dayu_theme.background_color
- )
- )
- self.setFixedSize(20 if value else 16, 4)
-
- def mousePressEvent(self, event):
- if event.buttons() == QtCore.Qt.LeftButton:
- self.sig_go_to_page.emit()
- return super(MGuidPrivate, self).mousePressEvent(event)
-
-
-@property_mixin
-class MCarousel(QtWidgets.QGraphicsView):
- def __init__(self, pix_list, autoplay=True, width=500, height=500, parent=None):
- super(MCarousel, self).__init__(parent)
- self.scene = QtWidgets.QGraphicsScene()
- self.scene.setBackgroundBrush(
- QtGui.QBrush(QtGui.QColor(dayu_theme.background_color))
- )
- self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
- self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
- self.setScene(self.scene)
- self.setRenderHints(QtGui.QPainter.Antialiasing)
- self.hor_bar = self.horizontalScrollBar()
- self.carousel_width = width
- self.carousel_height = height
-
- pos = QtCore.QPoint(0, 0)
- pen = QtGui.QPen(QtCore.Qt.red)
- pen.setWidth(5)
- self.page_count = len(pix_list)
- line_width = 20
- total_width = self.page_count * (line_width + 5)
- self.scene.setSceneRect(0, 0, self.page_count * width, height)
-
- self.navigate_lay = QtWidgets.QHBoxLayout()
- self.navigate_lay.setSpacing(5)
- target_size = min(width, height)
- for index, pix in enumerate(pix_list):
- if pix.width() > pix.height():
- new_pix = pix.scaledToWidth(target_size, QtCore.Qt.SmoothTransformation)
- else:
- new_pix = pix.scaledToHeight(
- target_size, QtCore.Qt.SmoothTransformation
- )
- pix_item = QtWidgets.QGraphicsPixmapItem(new_pix)
- pix_item.setPos(pos)
- pix_item.setTransformationMode(QtCore.Qt.SmoothTransformation)
- pos.setX(pos.x() + width)
- line_item = MGuidPrivate()
- line_item.sig_go_to_page.connect(functools.partial(self.go_to_page, index))
- self.navigate_lay.addWidget(line_item)
- self.scene.addItem(pix_item)
-
- hud_widget = QtWidgets.QWidget(self)
- hud_widget.setLayout(self.navigate_lay)
- hud_widget.setStyleSheet("background:transparent")
- hud_widget.move(width / 2 - total_width / 2, height - 30)
-
- self.setFixedWidth(width + 2)
- self.setFixedHeight(height + 2)
- self.loading_ani = QtCore.QPropertyAnimation()
- self.loading_ani.setTargetObject(self.hor_bar)
- self.loading_ani.setEasingCurve(QtCore.QEasingCurve.InOutQuad)
- self.loading_ani.setDuration(500)
- self.loading_ani.setPropertyName(b"value")
- self.autoplay_timer = QtCore.QTimer(self)
- self.autoplay_timer.setInterval(2000)
- self.autoplay_timer.timeout.connect(self.next_page)
-
- self.current_index = 0
- self.go_to_page(0)
- self.set_autoplay(autoplay)
-
- def set_autoplay(self, value):
- self.setProperty("autoplay", value)
-
- def _set_autoplay(self, value):
- if value:
- self.autoplay_timer.start()
- else:
- self.autoplay_timer.stop()
-
- def set_interval(self, ms):
- self.autoplay_timer.setInterval(ms)
-
- def next_page(self):
- index = (
- self.current_index + 1 if self.current_index + 1 < self.page_count else 0
- )
- self.go_to_page(index)
-
- def pre_page(self):
- index = (
- self.current_index - 1 if self.current_index > 0 else self.page_count - 1
- )
- self.go_to_page(index)
-
- def go_to_page(self, index):
- self.loading_ani.setStartValue(self.current_index * self.carousel_width)
- self.loading_ani.setEndValue(index * self.carousel_width)
- self.loading_ani.start()
- self.current_index = index
- for i in range(self.navigate_lay.count()):
- frame = self.navigate_lay.itemAt(i).widget()
- frame.set_checked(i == self.current_index)
diff --git a/dayu_widgets/check_box.py b/dayu_widgets/check_box.py
deleted file mode 100644
index 669d8104..00000000
--- a/dayu_widgets/check_box.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MCheckBox
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.mixin import cursor_mixin
-
-
-@cursor_mixin
-class MCheckBox(QtWidgets.QCheckBox):
- """
- MCheckBox just use stylesheet and set cursor shape when hover. No more extend.
- """
-
- def __init__(self, text="", parent=None):
- super(MCheckBox, self).__init__(text=text, parent=parent)
diff --git a/dayu_widgets/collapse.py b/dayu_widgets/collapse.py
deleted file mode 100644
index e62e57d7..00000000
--- a/dayu_widgets/collapse.py
+++ /dev/null
@@ -1,159 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.label import MLabel
-from dayu_widgets.mixin import property_mixin
-from dayu_widgets.qt import MPixmap
-from dayu_widgets.tool_button import MToolButton
-
-
-@property_mixin
-class MSectionItem(QtWidgets.QWidget):
- sig_context_menu = QtCore.Signal(object)
-
- def __init__(
- self, title="", expand=False, widget=None, closable=False, parent=None
- ):
- super(MSectionItem, self).__init__(parent)
- self._central_widget = None
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
- self.title_label = MLabel(parent=self)
- self.expand_icon = MLabel(parent=self)
- self.expand_icon.setSizePolicy(
- QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum
- )
- self._close_button = MToolButton().icon_only().tiny().svg("close_line.svg")
- self._close_button.clicked.connect(self.close)
-
- header_lay = QtWidgets.QHBoxLayout()
- header_lay.addWidget(self.expand_icon)
- header_lay.addWidget(self.title_label)
- header_lay.addStretch()
- header_lay.addWidget(self._close_button)
- self.header_widget = QtWidgets.QWidget(parent=self)
- self.header_widget.setAttribute(QtCore.Qt.WA_StyledBackground)
- self.header_widget.setObjectName("title")
- self.header_widget.setLayout(header_lay)
- self.header_widget.setSizePolicy(
- QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum
- )
- self.header_widget.setCursor(QtCore.Qt.PointingHandCursor)
- self.title_label.setCursor(QtCore.Qt.PointingHandCursor)
- self.header_widget.installEventFilter(self)
- self.title_label.installEventFilter(self)
-
- self.content_widget = QtWidgets.QWidget(parent=self)
- self.content_layout = QtWidgets.QHBoxLayout()
- self.content_widget.setLayout(self.content_layout)
-
- self.main_lay = QtWidgets.QVBoxLayout()
- self.main_lay.setContentsMargins(0, 0, 0, 0)
- self.main_lay.setSpacing(0)
- self.main_lay.addWidget(self.header_widget)
- self.main_lay.addWidget(self.content_widget)
- self.setLayout(self.main_lay)
- self.setSizePolicy(
- QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
- )
- self.setMouseTracking(True)
- self.set_title(title)
- self.set_closable(closable)
- if widget:
- self.set_content(widget)
- self.set_expand(expand)
-
- def set_content(self, widget):
- if self._central_widget:
- self.content_layout.removeWidget(self._central_widget)
- self._central_widget.close()
- self.content_layout.addWidget(widget)
- self._central_widget = widget
-
- def get_content(self):
- return self._central_widget
-
- def set_closable(self, value):
- self.setProperty("closable", value)
-
- def _set_closable(self, value):
- self.content_widget.setVisible(value)
- self._close_button.setVisible(value)
-
- def set_expand(self, value):
- self.setProperty("expand", value)
-
- def _set_expand(self, value):
- self.content_widget.setVisible(value)
- self.expand_icon.setPixmap(
- MPixmap("down_line.svg" if value else "right_line.svg").scaledToHeight(12)
- )
-
- def set_title(self, value):
- self.setProperty("title", value)
-
- def _set_title(self, value):
- self.title_label.setText(value)
-
- def eventFilter(self, widget, event):
- if widget in [self.header_widget, self.title_label]:
- if event.type() == QtCore.QEvent.MouseButtonRelease:
- self.set_expand(not self.property("expand"))
- return super(QtWidgets.QWidget, self).eventFilter(widget, event)
-
-
-class MCollapse(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(MCollapse, self).__init__(parent)
- self._section_list = []
- self._main_layout = QtWidgets.QVBoxLayout()
- self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
- self._main_layout.setSpacing(1)
- self._main_layout.setContentsMargins(0, 0, 0, 0)
- self.setLayout(self._main_layout)
-
- def add_section(self, section_data):
- section_widget = MSectionItem(
- title=section_data.get("title"),
- expand=section_data.get("expand", False),
- widget=section_data.get("widget"),
- closable=section_data.get("closable", False),
- )
- self._main_layout.insertWidget(self._main_layout.count(), section_widget)
- return section_widget
-
- def add_section_list(self, section_list):
- for section_data in section_list:
- section_widget = self.add_section(section_data)
- section_widget._close_button.clicked.connect(
- functools.partial(self.remove_section, section_widget)
- )
- self._section_list.append(section_widget)
-
- def remove_section(self, widget):
- self._section_list.remove(widget)
-
- def sections(self):
- return self._section_list
-
- def clear(self):
- for widget in self._section_list:
- self._main_layout.removeWidget(widget)
- del widget
diff --git a/dayu_widgets/color_palette.py b/dayu_widgets/color_palette.py
deleted file mode 100644
index ad2c4d7f..00000000
--- a/dayu_widgets/color_palette.py
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.label import MLabel
-from dayu_widgets.message import MMessage
-import dayu_widgets.utils as utils
-
-
-class MColorChart(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(MColorChart, self).__init__(parent)
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.setSpacing(0)
- self.button_list = []
- for index in range(10):
- button = QtWidgets.QPushButton()
- button.setCursor(QtCore.Qt.PointingHandCursor)
- button.setToolTip(self.tr("Click to Copy Color"))
- button.clicked.connect(functools.partial(self.slot_copy_color, button))
- button.setFixedSize(QtCore.QSize(250, 45))
- button.setText("color-{}".format(index + 1))
- main_lay.addWidget(button)
- self.button_list.append(button)
- self.setLayout(main_lay)
-
- def set_colors(self, color_list):
- for index, button in enumerate(self.button_list):
- target = color_list[index]
- button.setText("color-{}\t{}".format(index + 1, target))
- button.setProperty("color", target)
- button.setStyleSheet(
- "QPushButton{{background-color:{};color:{};border: 0 solid black}}"
- "QPushButton:hover{{font-weight:bold;}}".format(
- target, "#000" if index < 5 else "#fff"
- )
- )
-
- def slot_copy_color(self, button):
- color = button.property("color")
- QtWidgets.QApplication.clipboard().setText(color)
- MMessage.success("copied: {}".format(color), parent=self)
-
-
-class MColorPaletteDialog(QtWidgets.QDialog):
- def __init__(self, init_color, parent=None):
- super(MColorPaletteDialog, self).__init__(parent)
- self.setWindowTitle("DAYU Color Palette")
- self.primary_color = QtGui.QColor(init_color)
- self.color_chart = MColorChart()
- self.choose_color_button = QtWidgets.QPushButton()
- self.choose_color_button.setFixedSize(QtCore.QSize(100, 30))
- self.color_label = QtWidgets.QLabel()
- self.info_label = MLabel()
- self.info_label.setProperty("error", True)
- color_lay = QtWidgets.QHBoxLayout()
- color_lay.addWidget(MLabel("Primary Color:"))
- color_lay.addWidget(self.choose_color_button)
- color_lay.addWidget(self.color_label)
- color_lay.addWidget(self.info_label)
- color_lay.addStretch()
- dialog = QtWidgets.QColorDialog(self.primary_color, parent=self)
- dialog.setWindowFlags(QtCore.Qt.Widget)
- dialog.setOption(QtWidgets.QColorDialog.NoButtons)
- dialog.currentColorChanged.connect(self.slot_color_changed)
- setting_lay = QtWidgets.QVBoxLayout()
- setting_lay.addLayout(color_lay)
- setting_lay.addWidget(MDivider())
- setting_lay.addWidget(dialog)
-
- main_lay = QtWidgets.QHBoxLayout()
- main_lay.addWidget(self.color_chart)
- main_lay.addLayout(setting_lay)
- self.setLayout(main_lay)
- self.update_color()
-
- @QtCore.Slot(QtGui.QColor)
- def slot_color_changed(self, color):
- self.primary_color = color
- light = self.primary_color.lightness()
- saturation = self.primary_color.saturation()
- self.info_label.setText("")
- if light <= 70:
- self.info_label.setText("亮度建议不低于70(现在 {})".format(light))
- if saturation <= 70:
- self.info_label.setText("饱和度建议不低于70(现在 {})".format(saturation))
-
- self.update_color()
-
- def update_color(self):
- self.choose_color_button.setStyleSheet(
- "border-radius: 0;border: none;border:1px solid gray;"
- "background-color:{};".format(self.primary_color.name())
- )
- self.color_label.setText(self.primary_color.name())
- self.color_chart.set_colors(
- [utils.generate_color(self.primary_color, index + 1) for index in range(10)]
- )
-
-
-if __name__ == "__main__":
- # Import built-in modules
- import sys
-
- # Import local modules
- from dayu_widgets import dayu_theme
-
- app = QtWidgets.QApplication(sys.argv)
- test = MColorPaletteDialog(init_color="#1890ff")
- dayu_theme.apply(test)
- test.show()
- sys.exit(app.exec_())
diff --git a/dayu_widgets/combo_box.py b/dayu_widgets/combo_box.py
deleted file mode 100644
index 731c6415..00000000
--- a/dayu_widgets/combo_box.py
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.completer import MCompleter
-from dayu_widgets.mixin import cursor_mixin
-from dayu_widgets.mixin import focus_shadow_mixin
-from dayu_widgets.mixin import property_mixin
-import dayu_widgets.utils as utils
-
-
-@property_mixin
-class MComboBoxSearchMixin(object):
- def __init__(self, *args, **kwargs):
- super(MComboBoxSearchMixin, self).__init__(*args, **kwargs)
- self.filter_model = QtCore.QSortFilterProxyModel(self)
- self.filter_model.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
- self.filter_model.setSourceModel(self.model())
- self.completer = MCompleter(self)
- self.completer.setCompletionMode(QtWidgets.QCompleter.UnfilteredPopupCompletion)
- self.completer.setModel(self.filter_model)
-
- def search(self):
- self.setFocusPolicy(QtCore.Qt.StrongFocus)
- self.setEditable(True)
-
- self.setCompleter(self.completer)
-
- edit = self.lineEdit()
- edit.setReadOnly(False)
- edit.returnPressed.disconnect()
- edit.textEdited.connect(self.filter_model.setFilterFixedString)
- self.completer.activated.connect(
- lambda t: t and self.setCurrentIndex(self.findText(t))
- )
-
- def _set_searchable(self, value):
- """search property to True then trigger search"""
- value and self.search()
-
- def setModel(self, model):
- super(MComboBoxSearchMixin, self).setModel(model)
- self.filter_model.setSourceModel(model)
- self.completer.setModel(self.filter_model)
-
- def setModelColumn(self, column):
- self.completer.setCompletionColumn(column)
- self.filter_model.setFilterKeyColumn(column)
- super(MComboBoxSearchMixin, self).setModelColumn(column)
-
-
-@cursor_mixin
-@focus_shadow_mixin
-class MComboBox(MComboBoxSearchMixin, QtWidgets.QComboBox):
- Separator = "/"
- sig_value_changed = QtCore.Signal(object)
-
- def __init__(self, parent=None):
- super(MComboBox, self).__init__(parent)
-
- self._root_menu = None
- self._display_formatter = utils.display_formatter
- self.setEditable(True)
- line_edit = self.lineEdit()
- line_edit.setReadOnly(True)
- line_edit.setTextMargins(4, 0, 4, 0)
- line_edit.setStyleSheet("background-color:transparent")
- line_edit.setCursor(QtCore.Qt.PointingHandCursor)
- line_edit.installEventFilter(self)
- self._has_custom_view = False
- self.set_value("")
- self.set_placeholder(self.tr("Please Select"))
- self.setSizePolicy(
- QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
- )
- self._dayu_size = dayu_theme.default_size
- dayu_theme.apply(self)
-
- def get_dayu_size(self):
- """
- Get the push button height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the avatar size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.lineEdit().setProperty("dayu_size", value)
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def set_formatter(self, func):
- self._display_formatter = func
-
- def set_placeholder(self, text):
- """Display the text when no item selected."""
- self.lineEdit().setPlaceholderText(text)
-
- def set_value(self, value):
- self.setProperty("value", value)
-
- def _set_value(self, value):
- self.lineEdit().setProperty("text", self._display_formatter(value))
- if self._root_menu:
- self._root_menu.set_value(value)
-
- def set_menu(self, menu):
- self._root_menu = menu
- self._root_menu.sig_value_changed.connect(self.sig_value_changed)
- self._root_menu.sig_value_changed.connect(self.set_value)
-
- def setView(self, *args, **kwargs):
- """Override setView to flag _has_custom_view variable."""
- self._has_custom_view = True
- super(MComboBox, self).setView(*args, **kwargs)
-
- def showPopup(self):
- """Override default showPopup. When set custom menu, show the menu instead."""
- if self._has_custom_view or self._root_menu is None:
- super(MComboBox, self).showPopup()
- else:
- super(MComboBox, self).hidePopup()
- self._root_menu.popup(self.mapToGlobal(QtCore.QPoint(0, self.height())))
-
- # def setCurrentIndex(self, index):
- # raise NotImplementedError
-
- def eventFilter(self, widget, event):
- if widget is self.lineEdit() and widget.isReadOnly():
- if event.type() == QtCore.QEvent.MouseButtonPress:
- self.showPopup()
- return super(MComboBox, self).eventFilter(widget, event)
-
- def huge(self):
- """Set MComboBox to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MComboBox to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MComboBox to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MComboBox to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MComboBox to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
diff --git a/dayu_widgets/completer.py b/dayu_widgets/completer.py
deleted file mode 100644
index a71a5eca..00000000
--- a/dayu_widgets/completer.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: TimmyLiang
-# Date : 2021.12
-# Email : 820472580@qq.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import property_mixin
-
-
-@property_mixin
-class MCompleter(QtWidgets.QCompleter):
- ITEM_HEIGHT = 28
-
- def __init__(self, parent=None):
- super(MCompleter, self).__init__(parent)
- self.setProperty("animatable", True)
-
- popup = self.popup()
- dayu_theme.apply(popup)
-
- self._opacity_anim = QtCore.QPropertyAnimation(popup, b"windowOpacity")
- self.setProperty("anim_opacity_duration", 300)
- self.setProperty("anim_opacity_curve", "OutCubic")
- self.setProperty("anim_opacity_start", 0)
- self.setProperty("anim_opacity_end", 1)
-
- self._size_anim = QtCore.QPropertyAnimation(popup, b"size")
- self.setProperty("anim_size_duration", 300)
- self.setProperty("anim_size_curve", "OutCubic")
-
- popup.installEventFilter(self)
-
- def _set_anim_opacity_duration(self, value):
- self._opacity_anim.setDuration(value)
-
- def _set_anim_opacity_curve(self, value):
- curve = getattr(QtCore.QEasingCurve, value, None)
- assert curve, "invalid QEasingCurve"
- self._opacity_anim.setEasingCurve(curve)
-
- def _set_anim_opacity_start(self, value):
- self._opacity_anim.setStartValue(value)
-
- def _set_anim_opacity_end(self, value):
- self._opacity_anim.setEndValue(value)
-
- def _set_anim_size_duration(self, value):
- self._size_anim.setDuration(value)
-
- def _set_anim_size_curve(self, value):
- curve = getattr(QtCore.QEasingCurve, value, None)
- assert curve, "invalid QEasingCurve"
- self._size_anim.setEasingCurve(curve)
-
- def _set_anim_size_start(self, value):
- self._size_anim.setStartValue(value)
-
- def _set_anim_size_end(self, value):
- self._size_anim.setEndValue(value)
-
- def init_size(self):
- popup = self.popup()
-
- model = popup.model()
-
- width = self.widget().width()
- max_height = popup.sizeHint().height()
- item_height = model.data(model.index(0, 0), QtCore.Qt.SizeHintRole)
- height = (item_height or self.ITEM_HEIGHT) * model.rowCount()
- height = height if height < max_height else max_height
-
- start_size = self.property("anim_size_start")
- start_size = start_size if start_size else QtCore.QSize(0, 0)
- end_size = self.property("anim_size_end")
- end_size = end_size if end_size else QtCore.QSize(width, height)
- self._size_anim.setStartValue(start_size)
- self._size_anim.setEndValue(end_size)
-
- def start_anim(self):
- self.init_size()
- self._opacity_anim.start()
- self._size_anim.start()
-
- def eventFilter(self, widget, event):
- if event.type() == QtCore.QEvent.Show and self.property("animatable"):
- self.start_anim()
- return super(MCompleter, self).eventFilter(widget, event)
diff --git a/dayu_widgets/db_path_buttons.py b/dayu_widgets/db_path_buttons.py
deleted file mode 100644
index b64e206e..00000000
--- a/dayu_widgets/db_path_buttons.py
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2018.5
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-from functools import partial
-from itertools import izip_longest
-
-# Import third-party modules
-from qt import *
-import utils
-
-
-def parse_db_orm(orm):
- orm_map = {"view": "items", "search": "items", "folder": "children"}
- return {
- "name": "ROOT" if hasattr(orm, "parent") and orm.parent is None else orm.name,
- "icon": utils.icon_formatter(orm),
- "get_children": lambda x: [
- parse_db_orm(orm)
- for orm in getattr(x, orm_map.get(x.__tablename__, None))
- if orm.active
- ],
- "has_children": lambda x: hasattr(x, orm_map.get(x.__tablename__, None)),
- "data": orm,
- }
-
-
-def parse_path(path):
- # Import built-in modules
- import os
-
- # Import third-party modules
- from static import request_file
-
- return {
- "name": os.path.basename(path) or path,
- "icon": utils.icon_formatter(request_file("icon-browser.png")),
- "get_children": lambda x: [
- parse_path(os.path.join(path, i))
- for i in os.listdir(path)
- if os.path.isdir(os.path.join(path, i))
- ],
- "has_children": lambda x: next(
- (True for i in os.listdir(path) if os.path.isdir(os.path.join(path, i))),
- False,
- ),
- "data": path,
- }
-
-
-class MBaseButton(QWidget):
- sig_name_button_clicked = Signal(int)
- sig_menu_action_clicked = Signal(int, dict)
-
- def __init__(self, data_dict, parent=None):
- super(MBaseButton, self).__init__(parent)
- self.data_dict = data_dict
- name_button = QToolButton(parent=self)
- name_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
- name_button.setIcon(data_dict.get("icon"))
- name_button.clicked.connect(self.slot_button_clicked)
- name_button.setText(data_dict.get("name"))
-
- self.menu_button = QToolButton(parent=self)
- self.menu_button.setAutoRaise(False)
- self.menu_button.setArrowType(Qt.RightArrow)
- self.menu_button.setPopupMode(QToolButton.InstantPopup)
- self.menu_button.setIconSize(QSize(10, 10))
- self.menu_button.clicked.connect(self.slot_show_menu)
- self.menu_button.setVisible(
- data_dict.get("has_children")(data_dict.get("data"))
- )
- main_lay = QHBoxLayout()
- main_lay.setContentsMargins(0, 0, 0, 0)
- main_lay.setSpacing(0)
- main_lay.addWidget(name_button)
- main_lay.addWidget(self.menu_button)
- self.setLayout(main_lay)
-
- @Slot()
- def slot_button_clicked(self):
- self.sig_name_button_clicked.emit(self.data_dict.get("index"))
-
- @Slot()
- def slot_action_clicked(self, sub_obj):
- self.sig_menu_action_clicked.emit(self.data_dict.get("index"), sub_obj)
-
- @Slot()
- def slot_show_menu(self):
- menu = QMenu(self)
- data_list = self.data_dict.get("get_children")(self.data_dict.get("data"))
- for sub_obj in data_list:
- action = menu.addAction(sub_obj.get("icon"), sub_obj.get("name"))
- action.triggered.connect(partial(self.slot_action_clicked, sub_obj))
- self.menu_button.setMenu(menu)
- self.menu_button.showMenu()
-
- def enterEvent(self, *args, **kwargs):
- self.menu_button.setArrowType(Qt.DownArrow)
- return super(MBaseButton, self).enterEvent(*args, **kwargs)
-
- def leaveEvent(self, *args, **kwargs):
- self.menu_button.setArrowType(Qt.RightArrow)
- return super(MBaseButton, self).leaveEvent(*args, **kwargs)
-
-
-class MDBPathButtons(QFrame):
- sig_current_changed = Signal()
-
- @utils.dayu_css()
- def __init__(self, parent=None):
- super(MDBPathButtons, self).__init__(parent)
- self.parse_function = None
- self.data_list = []
-
- self.layout = QHBoxLayout()
- self.layout.setContentsMargins(0, 0, 0, 0)
- self.layout.setSpacing(0)
-
- main_lay = QHBoxLayout()
- main_lay.setContentsMargins(0, 0, 0, 0)
- main_lay.addLayout(self.layout)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def set_parse_function(self, func):
- self.parse_function = func
-
- def setup_data(self, obj):
- self.clear_downstream(0)
- if obj:
- self.add_level(self.parse_function(obj))
- self.sig_current_changed.emit()
-
- def add_level(self, data_dict):
- index = len(self.data_list)
- data_dict.update({"index": index})
- button = MBaseButton(data_dict, parent=self)
- button.sig_name_button_clicked.connect(self.slot_button_clicked)
- button.sig_menu_action_clicked.connect(self.slot_menu_button_clicked)
- self.layout.addWidget(button)
- data_dict.update({"widget": button})
- self.data_list.append(data_dict)
-
- def clear_downstream(self, index):
- for i, data_dict in enumerate(self.data_list):
- if i >= index:
- button = data_dict.get("widget")
- self.layout.removeWidget(button)
- button.setVisible(False)
- self.data_list = self.data_list[:index]
-
- @Slot(QToolButton, dict)
- def slot_show_menu(self, menu_button, data_dict):
- menu = QMenu(self)
- data_list = data_dict.get("get_children")(data_dict.get("data"))
- index = data_dict.get("index")
- for sub_obj in data_list:
- action = menu.addAction(sub_obj.get("icon"), sub_obj.get("name"))
- action.triggered.connect(
- partial(self.slot_menu_button_clicked, index, sub_obj)
- )
- menu_button.setMenu(menu)
- menu_button.showMenu()
-
- @Slot(object)
- def slot_button_clicked(self, index):
- self.clear_downstream(index + 1)
- self.sig_current_changed.emit()
-
- @Slot(object)
- def slot_menu_button_clicked(self, index, data_dict):
- self.clear_downstream(index + 1)
- self.add_level(data_dict)
- self.sig_current_changed.emit()
-
- @Slot(object)
- def slot_go_to(self, obj_list):
- for index, (his_obj, our_obj) in enumerate(
- izip_longest(obj_list, self.get_obj_list())
- ):
- if his_obj is None:
- # 如果传来的 obj_list 最后一个是 None,则我方的 obj 多,直接清理掉多余的
- self.clear_downstream(index)
- return
- elif our_obj is None:
- # 我方的 obj 不够,则追加
- self.add_level(self.parse_function(his_obj))
- elif his_obj != our_obj:
- # 我方 跟 传来的 obj 不一样,清理掉后面的,并追加传来的orm
- self.clear_downstream(index)
- self.add_level(self.parse_function(his_obj))
- else:
- # 我方和传来的 obj 完全一样,不做处理
- continue
-
- def get_obj_list(self):
- return [i.get("data") for i in self.data_list]
-
-
-if __name__ == "__main__":
- # Import built-in modules
- import sys
-
- app = QApplication(sys.argv)
- test = MDBPathButtons()
- test.set_parse_function(parse_path)
- test.setup_data("d:/")
- test.show()
- sys.exit(app.exec_())
diff --git a/dayu_widgets/divider.py b/dayu_widgets/divider.py
deleted file mode 100644
index ff93378d..00000000
--- a/dayu_widgets/divider.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MDivider
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-import six
-
-# Import local modules
-from dayu_widgets.label import MLabel
-
-
-class MDivider(QtWidgets.QWidget):
- """
- A divider line separates different content.
-
- Property:
- dayu_text: six.string_types
- """
-
- _alignment_map = {
- QtCore.Qt.AlignCenter: 50,
- QtCore.Qt.AlignLeft: 20,
- QtCore.Qt.AlignRight: 80,
- }
-
- def __init__(
- self,
- text="",
- orientation=QtCore.Qt.Horizontal,
- alignment=QtCore.Qt.AlignCenter,
- parent=None,
- ):
- super(MDivider, self).__init__(parent)
- self._orient = orientation
- self._text_label = MLabel().secondary()
- self._left_frame = QtWidgets.QFrame()
- self._right_frame = QtWidgets.QFrame()
- self._main_lay = QtWidgets.QHBoxLayout()
- self._main_lay.setContentsMargins(0, 0, 0, 0)
- self._main_lay.setSpacing(0)
- self._main_lay.addWidget(self._left_frame)
- self._main_lay.addWidget(self._text_label)
- self._main_lay.addWidget(self._right_frame)
- self.setLayout(self._main_lay)
-
- if orientation == QtCore.Qt.Horizontal:
- self._left_frame.setFrameShape(QtWidgets.QFrame.HLine)
- self._left_frame.setFrameShadow(QtWidgets.QFrame.Sunken)
- self._right_frame.setFrameShape(QtWidgets.QFrame.HLine)
- self._right_frame.setFrameShadow(QtWidgets.QFrame.Sunken)
- else:
- self._text_label.setVisible(False)
- self._right_frame.setVisible(False)
- self._left_frame.setFrameShape(QtWidgets.QFrame.VLine)
- self._left_frame.setFrameShadow(QtWidgets.QFrame.Plain)
- self.setFixedWidth(2)
- self._main_lay.setStretchFactor(
- self._left_frame, self._alignment_map.get(alignment, 50)
- )
- self._main_lay.setStretchFactor(
- self._right_frame, 100 - self._alignment_map.get(alignment, 50)
- )
- self._text = None
- self.set_dayu_text(text)
-
- def set_dayu_text(self, value):
- """
- Set the divider's text.
- When text is empty, hide the text_label and right_frame to ensure the divider not has a gap.
-
- :param value: six.string_types
- :return: None
- """
- self._text = value
- self._text_label.setText(value)
- if self._orient == QtCore.Qt.Horizontal:
- self._text_label.setVisible(bool(value))
- self._right_frame.setVisible(bool(value))
-
- def get_dayu_text(self):
- """
- Get current text
- :return: six.string_types
- """
- return self._text
-
- dayu_text = QtCore.Property(six.string_types[0], get_dayu_text, set_dayu_text)
-
- @classmethod
- def left(cls, text=""):
- """Create a horizontal divider with text at left."""
- return cls(text, alignment=QtCore.Qt.AlignLeft)
-
- @classmethod
- def right(cls, text=""):
- """Create a horizontal divider with text at right."""
- return cls(text, alignment=QtCore.Qt.AlignRight)
-
- @classmethod
- def center(cls, text=""):
- """Create a horizontal divider with text at center."""
- return cls(text, alignment=QtCore.Qt.AlignCenter)
-
- @classmethod
- def vertical(cls):
- """Create a vertical divider"""
- return cls(orientation=QtCore.Qt.Vertical)
diff --git a/dayu_widgets/dock_widget.py b/dayu_widgets/dock_widget.py
deleted file mode 100644
index dd358a71..00000000
--- a/dayu_widgets/dock_widget.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""MDockWidget"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-
-class MDockWidget(QtWidgets.QDockWidget):
- """
- Just apply the qss. No more extend.
- """
-
- def __init__(self, title="", parent=None, flags=QtCore.Qt.Widget):
- super(MDockWidget, self).__init__(title, parent=parent, flags=flags)
diff --git a/dayu_widgets/drawer.py b/dayu_widgets/drawer.py
deleted file mode 100644
index 67562626..00000000
--- a/dayu_widgets/drawer.py
+++ /dev/null
@@ -1,229 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.6
-# Email : muyanru345@163.com
-###################################################################
-"""MDrawer"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.label import MLabel
-from dayu_widgets.qt import get_scale_factor
-from dayu_widgets.tool_button import MToolButton
-
-
-class MDrawer(QtWidgets.QWidget):
- """
- A panel which slides in from the edge of the screen.
- """
-
- LeftPos = "left"
- RightPos = "right"
- TopPos = "top"
- BottomPos = "bottom"
-
- sig_closed = QtCore.Signal()
-
- def __init__(self, title, position="right", closable=True, parent=None):
- super(MDrawer, self).__init__(parent)
- self.setObjectName("message")
- self.setWindowFlags(QtCore.Qt.Popup)
- # self.setWindowFlags(
- # Qt.FramelessWindowHint | Qt.Popup | Qt.WA_TranslucentBackground)
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
-
- self._title_label = MLabel(parent=self).h4()
- # self._title_label.set_elide_mode(Qt.ElideRight)
- self._title_label.setText(title)
-
- self._close_button = (
- MToolButton(parent=self).icon_only().svg("close_line.svg").small()
- )
- self._close_button.clicked.connect(self.close)
- self._close_button.setVisible(closable or False)
-
- self._title_extra_lay = QtWidgets.QHBoxLayout()
- _title_lay = QtWidgets.QHBoxLayout()
- _title_lay.addWidget(self._title_label)
- _title_lay.addStretch()
- _title_lay.addLayout(self._title_extra_lay)
- _title_lay.addWidget(self._close_button)
- self._bottom_lay = QtWidgets.QHBoxLayout()
- self._bottom_lay.addStretch()
-
- self._scroll_area = QtWidgets.QScrollArea()
- self._scroll_area.setWidgetResizable(True)
- self._main_lay = QtWidgets.QVBoxLayout()
- self._main_lay.addLayout(_title_lay)
- self._main_lay.addWidget(MDivider())
- self._main_lay.addWidget(self._scroll_area)
- self._main_lay.addWidget(MDivider())
- self._main_lay.addLayout(self._bottom_lay)
- self.setLayout(self._main_lay)
-
- self._position = position
-
- self._close_timer = QtCore.QTimer(self)
- self._close_timer.setSingleShot(True)
- self._close_timer.timeout.connect(self.close)
- self._close_timer.timeout.connect(self.sig_closed)
- self._close_timer.setInterval(300)
- self._is_first_close = True
-
- self._pos_ani = QtCore.QPropertyAnimation(self)
- self._pos_ani.setTargetObject(self)
- self._pos_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
- self._pos_ani.setDuration(300)
- self._pos_ani.setPropertyName(b"pos")
-
- self._opacity_ani = QtCore.QPropertyAnimation()
- self._opacity_ani.setTargetObject(self)
- self._opacity_ani.setDuration(300)
- self._opacity_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
- self._opacity_ani.setPropertyName(b"windowOpacity")
- self._opacity_ani.setStartValue(0.0)
- self._opacity_ani.setEndValue(1.0)
-
- def set_widget(self, widget):
- self._scroll_area.setWidget(widget)
-
- def add_widget_to_bottom(self, button):
- self._bottom_lay.addWidget(button)
-
- def add_widget_to_top(self, button):
- self._title_extra_lay.addWidget(button)
-
- def _fade_out(self):
- self._pos_ani.setDirection(QtCore.QAbstractAnimation.Backward)
- self._pos_ani.start()
- self._opacity_ani.setDirection(QtCore.QAbstractAnimation.Backward)
- self._opacity_ani.start()
-
- def _fade_int(self):
- self._pos_ani.start()
- self._opacity_ani.start()
-
- def _set_proper_position(self):
- parent = self.parent()
- parent_geo = parent.geometry()
- if self._position == MDrawer.LeftPos:
- pos = (
- parent_geo.topLeft()
- if parent.parent() is None
- else parent.mapToGlobal(parent_geo.topLeft())
- )
- target_x = pos.x()
- target_y = pos.y()
- self.setFixedHeight(parent_geo.height())
- self._pos_ani.setStartValue(
- QtCore.QPoint(target_x - self.width(), target_y)
- )
- self._pos_ani.setEndValue(QtCore.QPoint(target_x, target_y))
- if self._position == MDrawer.RightPos:
- pos = (
- parent_geo.topRight()
- if parent.parent() is None
- else parent.mapToGlobal(parent_geo.topRight())
- )
- self.setFixedHeight(parent_geo.height())
- target_x = pos.x() - self.width()
- target_y = pos.y()
- self._pos_ani.setStartValue(
- QtCore.QPoint(target_x + self.width(), target_y)
- )
- self._pos_ani.setEndValue(QtCore.QPoint(target_x, target_y))
- if self._position == MDrawer.TopPos:
- pos = (
- parent_geo.topLeft()
- if parent.parent() is None
- else parent.mapToGlobal(parent_geo.topLeft())
- )
- self.setFixedWidth(parent_geo.width())
- target_x = pos.x()
- target_y = pos.y()
- self._pos_ani.setStartValue(
- QtCore.QPoint(target_x, target_y - self.height())
- )
- self._pos_ani.setEndValue(QtCore.QPoint(target_x, target_y))
- if self._position == MDrawer.BottomPos:
- pos = (
- parent_geo.bottomLeft()
- if parent.parent() is None
- else parent.mapToGlobal(parent_geo.bottomLeft())
- )
- self.setFixedWidth(parent_geo.width())
- target_x = pos.x()
- target_y = pos.y() - self.height()
- self._pos_ani.setStartValue(
- QtCore.QPoint(target_x, target_y + self.height())
- )
- self._pos_ani.setEndValue(QtCore.QPoint(target_x, target_y))
-
- def set_dayu_position(self, value):
- """
- Set the placement of the MDrawer.
- top/right/bottom/left, default is right
- :param value: str
- :return: None
- """
- self._position = value
- scale_x, _ = get_scale_factor()
- if value in [MDrawer.BottomPos, MDrawer.TopPos]:
- self.setFixedHeight(200 * scale_x)
- else:
- self.setFixedWidth(200 * scale_x)
-
- def get_dayu_position(self):
- """
- Get the placement of the MDrawer
- :return: str
- """
- return self._position
-
- dayu_position = QtCore.Property(str, get_dayu_position, set_dayu_position)
-
- def left(self):
- """Set drawer's placement to left"""
- self.set_dayu_position(MDrawer.LeftPos)
- return self
-
- def right(self):
- """Set drawer's placement to right"""
- self.set_dayu_position(MDrawer.RightPos)
- return self
-
- def top(self):
- """Set drawer's placement to top"""
- self.set_dayu_position(MDrawer.TopPos)
- return self
-
- def bottom(self):
- """Set drawer's placement to bottom"""
- self.set_dayu_position(MDrawer.BottomPos)
- return self
-
- def show(self):
- self._set_proper_position()
- self._fade_int()
- super(MDrawer, self).show()
- # NOTES(timmyliang): for chinese input
- self.activateWindow()
-
- def closeEvent(self, event):
- if self._is_first_close:
- self._is_first_close = False
- self._close_timer.start()
- self._fade_out()
- event.ignore()
- else:
- event.accept()
diff --git a/dayu_widgets/field_mixin.py b/dayu_widgets/field_mixin.py
deleted file mode 100644
index 27c0165b..00000000
--- a/dayu_widgets/field_mixin.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2018.9
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-
-class MFieldMixin(object):
- computed_dict = None
- props_dict = None
-
- def register_field(self, name, getter=None, setter=None, required=False):
- if self.computed_dict is None:
- self.computed_dict = {}
- if self.props_dict is None:
- self.props_dict = {}
- if callable(getter):
- value = getter()
- self.computed_dict[name] = {
- "value": value,
- "getter": getter,
- "setter": setter,
- "required": required,
- "bind": [],
- }
- else:
- self.props_dict[name] = {"value": getter, "require": required, "bind": []}
- return
-
- def bind(
- self, data_name, widget, qt_property, index=None, signal=None, callback=None
- ):
- data_dict = {
- "data_name": data_name,
- "widget": widget,
- "widget_property": qt_property,
- "index": index,
- "callback": callback,
- }
- if data_name in self.computed_dict:
- self.computed_dict[data_name]["bind"].append(data_dict)
- else:
- self.props_dict[data_name]["bind"].append(data_dict)
- if signal: # 用户操作绑定数据
- getattr(widget, signal).connect(
- functools.partial(self._slot_changed_from_user, data_dict)
- )
- self._data_update_ui(data_dict)
- return widget
-
- def fields(self):
- return self.props_dict.keys() + self.computed_dict.keys()
-
- def field(self, name):
- if name in self.props_dict:
- return self.props_dict[name]["value"]
- elif name in self.computed_dict:
- new_value = self.computed_dict[name]["getter"]()
- self.computed_dict[name]["value"] = new_value
- return new_value
- else:
- raise KeyError('There is no field named "{}"'.format(name))
-
- def set_field(self, name, value):
- if name in self.props_dict:
- self.props_dict[name]["value"] = value
- self._slot_prop_changed(name)
-
- elif name in self.computed_dict:
- self.computed_dict[name]["value"] = value
-
- def _data_update_ui(self, data_dict):
- data_name = data_dict.get("data_name")
- widget = data_dict["widget"]
- index = data_dict["index"]
- widget_property = data_dict["widget_property"]
- callback = data_dict["callback"]
- value = None
- if index is None:
- value = self.field(data_name)
- elif isinstance(self.field(data_name), dict):
- value = self.field(data_name).get(index)
- elif isinstance(self.field(data_name), list):
- value = (
- self.field(data_name)[index]
- if index < len(self.field(data_name))
- else None
- )
- if widget.metaObject().indexOfProperty(
- widget_property
- ) > -1 or widget_property in list(
- map(str, [b.data().decode() for b in widget.dynamicPropertyNames()])
- ):
- widget.setProperty(widget_property, value)
- else:
- widget.set_field(widget_property, value)
- if callable(callback):
- callback()
-
- def _slot_prop_changed(self, property_name):
- for key, setting_dict in self.props_dict.items():
- if key == property_name:
- for data_dict in setting_dict["bind"]:
- self._data_update_ui(data_dict)
-
- for key, setting_dict in self.computed_dict.items():
- for data_dict in setting_dict["bind"]:
- self._data_update_ui(data_dict)
-
- def _slot_changed_from_user(self, data_dict, ui_value):
- self._ui_update_data(data_dict, ui_value)
-
- def _ui_update_data(self, data_dict, ui_value):
- data_name = data_dict.get("data_name")
- index = data_dict.get("index", None)
- if index is None:
- self.set_field(data_name, ui_value)
- else:
- old_value = self.field(data_name)
- old_value[index] = ui_value
- self.set_field(data_name, old_value)
- if data_name in self.props_dict.items():
- self._slot_prop_changed(data_name)
-
- def _is_complete(self):
- for name, data_dict in self.computed_dict.items() + self.props_dict.items():
- if data_dict["required"]:
- if not self.field(name):
- return False
- return True
diff --git a/dayu_widgets/flow_layout.py b/dayu_widgets/flow_layout.py
deleted file mode 100644
index b4b2592f..00000000
--- a/dayu_widgets/flow_layout.py
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.4
-# Email : muyanru345@163.com
-###################################################################
-"""MFlowLayout"""
-
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-
-class MFlowLayout(QtWidgets.QLayout):
- """
- FlowLayout, the code is come from PySide/examples/layouts/flowlayout.py
- I change the code style and add insertWidget method.
- """
-
- def __init__(self, parent=None, margin=0, spacing=-1):
- super(MFlowLayout, self).__init__(parent)
-
- if parent is not None:
- self.setMargin(margin)
-
- self.setSpacing(spacing)
-
- self.item_list = []
-
- def __del__(self):
- item = self.takeAt(0)
- while item:
- item = self.takeAt(0)
-
- def insertWidget(self, index, widget):
- self.addChildWidget(widget)
- if index < 0:
- index = self.count()
- item = QtWidgets.QWidgetItem(widget)
- self.item_list.insert(index, item)
- self.update()
-
- def addItem(self, item):
- self.item_list.append(item)
-
- def count(self):
- return len(self.item_list)
-
- def itemAt(self, index):
- if 0 <= index < len(self.item_list):
- return self.item_list[index]
-
- return None
-
- def takeAt(self, index):
- if 0 <= index < len(self.item_list):
- return self.item_list.pop(index).widget()
-
- return None
-
- def clear(self):
- while self.item_list:
- widget = self.takeAt(0)
- if widget:
- widget.deleteLater()
-
- def expandingDirections(self):
- return QtCore.Qt.Orientations(QtCore.Qt.Orientation(0))
-
- def hasHeightForWidth(self):
- return True
-
- def heightForWidth(self, width):
- height = self.do_layout(QtCore.QRect(0, 0, width, 0), True)
- return height
-
- def setGeometry(self, rect):
- super(MFlowLayout, self).setGeometry(rect)
- self.do_layout(rect, False)
-
- def sizeHint(self):
- return self.minimumSize()
-
- def minimumSize(self):
- size = QtCore.QSize()
-
- for item in self.item_list:
- size = size.expandedTo(item.minimumSize())
-
- size += QtCore.QSize(
- 2 * self.contentsMargins().top(), 2 * self.contentsMargins().top()
- )
- return size
-
- def do_layout(self, rect, test_only):
- x = rect.x()
- y = rect.y()
- line_height = 0
-
- for item in self.item_list:
- wid = item.widget()
- space_x = self.spacing() + wid.style().layoutSpacing(
- QtWidgets.QSizePolicy.PushButton,
- QtWidgets.QSizePolicy.PushButton,
- QtCore.Qt.Horizontal,
- )
- space_y = self.spacing() + wid.style().layoutSpacing(
- QtWidgets.QSizePolicy.PushButton,
- QtWidgets.QSizePolicy.PushButton,
- QtCore.Qt.Vertical,
- )
- next_x = x + item.sizeHint().width() + space_x
- if next_x - space_x > rect.right() and line_height > 0:
- x = rect.x()
- y = y + line_height + space_y
- next_x = x + item.sizeHint().width() + space_x
- line_height = 0
-
- if not test_only:
- item.setGeometry(QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))
-
- x = next_x
- line_height = max(line_height, item.sizeHint().height())
-
- return y + line_height - rect.y()
diff --git a/dayu_widgets/form.py b/dayu_widgets/form.py
deleted file mode 100644
index f1f1b096..00000000
--- a/dayu_widgets/form.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.4
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-
-class MForm(QtWidgets.QWidget):
- Horizontal = "horizontal"
- Vertical = "vertical"
- Inline = "inline"
-
- def __init__(self, layout=None, parent=None):
- super(MForm, self).__init__(parent)
- layout = layout or MForm.Horizontal
- if layout == MForm.Inline:
- self._main_layout = QtWidgets.QHBoxLayout()
- elif layout == MForm.Vertical:
- self._main_layout = QtWidgets.QVBoxLayout()
- else:
- self._main_layout = QtWidgets.QFormLayout()
- self._model = None
- self._label_list = []
-
- def set_model(self, m):
- self._model = m
-
- def set_label_align(self, align):
- for label in self._label_list:
- label.setAlignment(align)
- self._main_layout.setLabelAlignment(align)
-
- @classmethod
- def horizontal(cls):
- return cls(layout=cls.Horizontal)
-
- @classmethod
- def vertical(cls):
- return cls(layout=cls.Vertical)
-
- @classmethod
- def inline(cls):
- return cls(layout=cls.Inline)
diff --git a/dayu_widgets/header_view.py b/dayu_widgets/header_view.py
deleted file mode 100644
index dfe2c593..00000000
--- a/dayu_widgets/header_view.py
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.menu import MMenu
-import dayu_widgets.utils as utils
-
-
-class MHeaderView(QtWidgets.QHeaderView):
- def __init__(self, orientation, parent=None):
- super(MHeaderView, self).__init__(orientation, parent)
- self.setMovable(True)
- self.setClickable(True)
- self.setSortIndicatorShown(True)
- self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- self.customContextMenuRequested.connect(self._slot_context_menu)
- self.setDefaultAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
- self.setProperty(
- "orientation",
- "horizontal" if orientation == QtCore.Qt.Horizontal else "vertical",
- )
-
- # def enterEvent(self, *args, **kwargs):
- # # 调整表头宽度的 cursor 就被覆盖了
- # QApplication.setOverrideCursor(Qt.PointingHandCursor)
- # return super(MHeaderViewPrivate, self).enterEvent(*args, **kwargs)
- #
- # def leaveEvent(self, *args, **kwargs):
- # QApplication.restoreOverrideCursor()
- # return super(MHeaderViewPrivate, self).leaveEvent(*args, **kwargs)
-
- @QtCore.Slot(QtCore.QPoint)
- def _slot_context_menu(self, point):
- context_menu = MMenu(parent=self)
- logical_column = self.logicalIndexAt(point)
- model = utils.real_model(self.model())
- if logical_column >= 0 and model.header_list[logical_column].get(
- "checkable", False
- ):
- action_select_all = context_menu.addAction(self.tr("Select All"))
- action_select_none = context_menu.addAction(self.tr("Select None"))
- action_select_invert = context_menu.addAction(self.tr("Select Invert"))
- action_select_all.triggered.connect(
- functools.partial(
- self._slot_set_select, logical_column, QtCore.Qt.Checked
- )
- )
- action_select_none.triggered.connect(
- functools.partial(
- self._slot_set_select, logical_column, QtCore.Qt.Unchecked
- )
- )
- action_select_invert.triggered.connect(
- functools.partial(self._slot_set_select, logical_column, None)
- )
- context_menu.addSeparator()
-
- fit_action = context_menu.addAction(self.tr("Fit Size"))
- fit_action.triggered.connect(
- functools.partial(self._slot_set_resize_mode, True)
- )
- context_menu.addSeparator()
- for column in range(self.count()):
- action = context_menu.addAction(
- model.headerData(column, QtCore.Qt.Horizontal, QtCore.Qt.DisplayRole)
- )
- action.setCheckable(True)
- action.setChecked(not self.isSectionHidden(column))
- action.toggled.connect(
- functools.partial(self._slot_set_section_visible, column)
- )
- context_menu.exec_(QtGui.QCursor.pos() + QtCore.QPoint(10, 10))
-
- @QtCore.Slot(int, int)
- def _slot_set_select(self, column, state):
- current_model = self.model()
- source_model = utils.real_model(current_model)
- source_model.beginResetModel()
- attr = "{}_checked".format(source_model.header_list[column].get("key"))
- for row in range(current_model.rowCount()):
- real_index = utils.real_index(current_model.index(row, column))
- data_obj = real_index.internalPointer()
- if state is None:
- old_state = utils.get_obj_value(data_obj, attr)
- utils.set_obj_value(
- data_obj,
- attr,
- QtCore.Qt.Unchecked
- if old_state == QtCore.Qt.Checked
- else QtCore.Qt.Checked,
- )
- else:
- utils.set_obj_value(data_obj, attr, state)
- source_model.endResetModel()
- source_model.dataChanged.emit(None, None)
-
- @QtCore.Slot(QtCore.QModelIndex, int)
- def _slot_set_section_visible(self, index, flag):
- self.setSectionHidden(index, not flag)
-
- @QtCore.Slot(bool)
- def _slot_set_resize_mode(self, flag):
- if flag:
- self.resizeSections(QtWidgets.QHeaderView.ResizeToContents)
- else:
- self.resizeSections(QtWidgets.QHeaderView.Interactive)
-
- def setClickable(self, flag):
- try:
- QtWidgets.QHeaderView.setSectionsClickable(self, flag)
- except AttributeError:
- QtWidgets.QHeaderView.setClickable(self, flag)
-
- def setMovable(self, flag):
- try:
- QtWidgets.QHeaderView.setSectionsMovable(self, flag)
- except AttributeError:
- QtWidgets.QHeaderView.setMovable(self, flag)
-
- def resizeMode(self, index):
- try:
- QtWidgets.QHeaderView.sectionResizeMode(self, index)
- except AttributeError:
- QtWidgets.QHeaderView.resizeMode(self, index)
-
- def setResizeMode(self, mode):
- try:
- QtWidgets.QHeaderView.setResizeMode(self, mode)
- except AttributeError:
- QtWidgets.QHeaderView.setSectionResizeMode(self, mode)
diff --git a/dayu_widgets/item_model.py b/dayu_widgets/item_model.py
deleted file mode 100644
index d2cb01ab..00000000
--- a/dayu_widgets/item_model.py
+++ /dev/null
@@ -1,332 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2018.5
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-import six
-
-# Import local modules
-from dayu_widgets.utils import apply_formatter
-from dayu_widgets.utils import display_formatter
-from dayu_widgets.utils import font_formatter
-from dayu_widgets.utils import get_obj_value
-from dayu_widgets.utils import icon_formatter
-from dayu_widgets.utils import set_obj_value
-
-
-SETTING_MAP = {
- QtCore.Qt.BackgroundRole: {"config": "bg_color", "formatter": QtGui.QColor},
- QtCore.Qt.DisplayRole: {"config": "display", "formatter": display_formatter},
- QtCore.Qt.EditRole: {"config": "edit", "formatter": None},
- QtCore.Qt.TextAlignmentRole: {
- "config": "alignment",
- "formatter": {
- "right": QtCore.Qt.AlignRight,
- "left": QtCore.Qt.AlignLeft,
- "center": QtCore.Qt.AlignCenter,
- },
- },
- QtCore.Qt.ForegroundRole: {"config": "color", "formatter": QtGui.QColor},
- QtCore.Qt.FontRole: {"config": "font", "formatter": font_formatter},
- QtCore.Qt.DecorationRole: {"config": "icon", "formatter": icon_formatter},
- QtCore.Qt.ToolTipRole: {"config": "tooltip", "formatter": display_formatter},
- QtCore.Qt.InitialSortOrderRole: {
- "config": "order",
- "formatter": {
- "asc": QtCore.Qt.AscendingOrder,
- "des": QtCore.Qt.DescendingOrder,
- },
- },
- QtCore.Qt.SizeHintRole: {
- "config": "size",
- "formatter": lambda args: QtCore.QSize(*args),
- },
- QtCore.Qt.UserRole: {"config": "data"}, # anything
-}
-
-
-class MTableModel(QtCore.QAbstractItemModel):
- def __init__(self, parent=None):
- super(MTableModel, self).__init__(parent)
- self.origin_count = 0
- self.root_item = {"name": "root", "children": []}
- self.data_generator = None
- self.header_list = []
- self.timer = QtCore.QTimer(self)
- self.timer.timeout.connect(self.fetchMore)
-
- def set_header_list(self, header_list):
- self.header_list = header_list
-
- def set_data_list(self, data_list):
- if hasattr(data_list, "next"):
- self.beginResetModel()
- self.root_item["children"] = []
- self.endResetModel()
- self.data_generator = data_list
- self.origin_count = 0
- self.timer.start()
- else:
- self.beginResetModel()
- self.root_item["children"] = data_list if data_list is not None else []
- self.endResetModel()
- self.data_generator = None
-
- def clear(self):
- self.beginResetModel()
- self.root_item["children"] = []
- self.endResetModel()
-
- def get_data_list(self):
- return self.root_item["children"]
-
- def append(self, data_dict):
- self.root_item["children"].append(data_dict)
- self.fetchMore()
-
- def remove(self, data_dict):
- row = self.root_item["children"].index(data_dict)
- self.beginRemoveRows(QtCore.QModelIndex(), row, row)
- self.root_item["children"].remove(data_dict)
- self.endRemoveRows()
-
- def flags(self, index):
- result = QtCore.QAbstractItemModel.flags(self, index)
- if not index.isValid():
- return QtCore.Qt.ItemIsEnabled
- if self.header_list[index.column()].get("checkable", False):
- result |= QtCore.Qt.ItemIsUserCheckable
- if self.header_list[index.column()].get("selectable", False):
- result |= QtCore.Qt.ItemIsEditable
- if self.header_list[index.column()].get("editable", False):
- result |= QtCore.Qt.ItemIsEditable
- if self.header_list[index.column()].get("draggable", False):
- result |= QtCore.Qt.ItemIsDragEnabled
- if self.header_list[index.column()].get("droppable", False):
- result |= QtCore.Qt.ItemIsDropEnabled
- return QtCore.Qt.ItemFlags(result)
-
- def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
- if orientation == QtCore.Qt.Vertical:
- return super(MTableModel, self).headerData(section, orientation, role)
- if not self.header_list or section >= len(self.header_list):
- return None
- if role == QtCore.Qt.DisplayRole:
- return self.header_list[section]["label"]
- return None
-
- def index(self, row, column, parent_index=None):
- if parent_index and parent_index.isValid():
- parent_item = parent_index.internalPointer()
- else:
- parent_item = self.root_item
-
- children_list = get_obj_value(parent_item, "children")
- if children_list and len(children_list) > row:
- child_item = children_list[row]
- if child_item:
- set_obj_value(child_item, "_parent", parent_item)
- return self.createIndex(row, column, child_item)
- return QtCore.QModelIndex()
-
- def parent(self, index):
- if not index.isValid():
- return QtCore.QModelIndex()
-
- child_item = index.internalPointer()
- parent_item = get_obj_value(child_item, "_parent")
-
- if parent_item is None:
- return QtCore.QModelIndex()
-
- grand_item = get_obj_value(parent_item, "_parent")
- if grand_item is None:
- return QtCore.QModelIndex()
- parent_list = get_obj_value(grand_item, "children")
- return self.createIndex(parent_list.index(parent_item), 0, parent_item)
-
- def rowCount(self, parent_index=None):
- if parent_index and parent_index.isValid():
- parent_item = parent_index.internalPointer()
- else:
- parent_item = self.root_item
- children_obj = get_obj_value(parent_item, "children")
- if hasattr(children_obj, "next") or (children_obj is None):
- return 0
- else:
- return len(children_obj)
-
- def hasChildren(self, parent_index=None):
- if parent_index and parent_index.isValid():
- parent_data = parent_index.internalPointer()
- else:
- parent_data = self.root_item
- children_obj = get_obj_value(parent_data, "children")
- if children_obj is None:
- return False
- if hasattr(children_obj, "next"):
- return True
- else:
- return len(children_obj)
-
- def columnCount(self, parent_index=None):
- return len(self.header_list)
-
- def canFetchMore(self, index):
- try:
- if self.data_generator:
- data = self.data_generator.next()
- self.root_item["children"].append(data)
- return True
- return False
- except StopIteration:
- if self.timer.isActive():
- self.timer.stop()
- return False
-
- def fetchMore(self, index=None):
- self.beginResetModel()
- self.endResetModel()
-
- def data(self, index, role=QtCore.Qt.DisplayRole):
- if not index.isValid():
- return None
-
- attr_dict = self.header_list[index.column()] # 获取该列字段的配置
- data_obj = index.internalPointer()
- attr = attr_dict.get("key")
- if role in SETTING_MAP.keys():
- role_key = SETTING_MAP[role].get("config") # role 配置的关键字
- formatter_from_config = attr_dict.get(role_key) # header中该role的配置
- if not formatter_from_config and role not in [
- QtCore.Qt.DisplayRole,
- QtCore.Qt.EditRole,
- QtCore.Qt.ToolTipRole,
- ]:
- # 如果header中没有配置该role,而且也不是 DisplayRole/EditRole,直接返回None
- return None
- else:
- value = apply_formatter(
- formatter_from_config, get_obj_value(data_obj, attr), data_obj
- )
- formatter_from_model = SETTING_MAP[role].get(
- "formatter", None
- ) # role 配置的转换函数
- result = apply_formatter(formatter_from_model, value)
- return result
-
- if role == QtCore.Qt.CheckStateRole and attr_dict.get("checkable", False):
- state = get_obj_value(data_obj, attr + "_checked")
- return QtCore.Qt.Unchecked if state is None else state
- return None
-
- def setData(self, index, value, role=QtCore.Qt.EditRole):
- if index.isValid() and role in [QtCore.Qt.CheckStateRole, QtCore.Qt.EditRole]:
- attr_dict = self.header_list[index.column()]
- key = attr_dict.get("key")
- data_obj = index.internalPointer()
- if role == QtCore.Qt.CheckStateRole and attr_dict.get("checkable", False):
- key += "_checked"
- # 更新自己
- set_obj_value(data_obj, key, value)
- self.dataChanged.emit(index, index)
-
- # 更新它的children
- for row, sub_obj in enumerate(get_obj_value(data_obj, "children", [])):
- set_obj_value(sub_obj, key, value)
- sub_index = index.child(row, index.column())
- self.dataChanged.emit(sub_index, sub_index)
-
- # 更新它的parent
- parent_index = index.parent()
- if parent_index.isValid():
- parent_obj = parent_index.internalPointer()
- new_parent_value = value
- old_parent_value = get_obj_value(parent_obj, key)
- for sibling_obj in get_obj_value(
- get_obj_value(data_obj, "_parent"), "children", []
- ):
- if value != get_obj_value(sibling_obj, key):
- new_parent_value = 1
- break
- if new_parent_value != old_parent_value:
- set_obj_value(parent_obj, key, new_parent_value)
- self.dataChanged.emit(parent_index, parent_index)
- else:
- set_obj_value(data_obj, key, value)
- # 采用 self.dataChanged.emit方式在houdini16里面会报错
- # TypeError: dataChanged(QModelIndex,QModelIndex,QVector) only accepts 3 arguments, 3 given!
- # 所以临时使用旧式信号的发射方式
- self.dataChanged.emit(index, index)
- # self.dataChanged.emit(index, index)
- return True
- else:
- return False
-
-
-class MSortFilterModel(QtCore.QSortFilterProxyModel):
- def __init__(self, parent=None):
- super(MSortFilterModel, self).__init__(parent)
- if hasattr(self, "setRecursiveFilteringEnabled"):
- self.setRecursiveFilteringEnabled(True)
- self.header_list = []
- self.search_reg = QtCore.QRegExp()
- self.search_reg.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
- self.search_reg.setPatternSyntax(QtCore.QRegExp.Wildcard)
-
- def set_header_list(self, header_list):
- self.header_list = header_list
- for head in self.header_list:
- reg_exp = QtCore.QRegExp()
- reg_exp.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
- reg_exp.setPatternSyntax(QtCore.QRegExp.RegExp)
- head.update({"reg": reg_exp})
-
- def filterAcceptsRow(self, source_row, source_parent):
- # 如果search 栏有内容 先匹配 search 栏的内容
- if self.search_reg.pattern():
- for index, data_dict in enumerate(self.header_list):
- if data_dict.get("searchable", False):
- model_index = self.sourceModel().index(
- source_row, index, source_parent
- )
- value = self.sourceModel().data(model_index)
- if self.search_reg.indexIn(six.text_type(value)) != -1:
- # 搜索匹配上了
- break
- else:
- # 全部搜索完毕,没有一个匹配,直接返回 False
- return False
-
- # 再去匹配 filter 组合
- for index, data_dict in enumerate(self.header_list):
- model_index = self.sourceModel().index(source_row, index, source_parent)
- value = self.sourceModel().data(model_index)
- reg_exp = data_dict.get("reg", None)
- if reg_exp and reg_exp.pattern() and (not reg_exp.exactMatch(value)):
- # 不符合筛选,直接返回 False
- return False
-
- return True
-
- def set_search_pattern(self, pattern):
- self.search_reg.setPattern(pattern)
- self.invalidateFilter()
-
- def set_filter_attr_pattern(self, attr, pattern):
- for data_dict in self.header_list:
- if data_dict.get("key") == attr:
- data_dict.get("reg").setPattern(pattern)
- break
- self.invalidateFilter()
diff --git a/dayu_widgets/item_view.py b/dayu_widgets/item_view.py
deleted file mode 100644
index 29b9f04a..00000000
--- a/dayu_widgets/item_view.py
+++ /dev/null
@@ -1,441 +0,0 @@
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-import six
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets import utils
-from dayu_widgets.header_view import MHeaderView
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.menu import MMenu
-from dayu_widgets.qt import MPixmap
-from dayu_widgets.qt import get_scale_factor
-
-
-HEADER_SORT_MAP = {"asc": QtCore.Qt.AscendingOrder, "desc": QtCore.Qt.DescendingOrder}
-
-
-def draw_empty_content(view, text=None, pix_map=None):
- # Import local modules
- from dayu_widgets import dayu_theme
-
- pix_map = pix_map or MPixmap("empty.svg")
- text = text or view.tr("No Data")
- painter = QtGui.QPainter(view)
- font_metrics = painter.fontMetrics()
- painter.setPen(QtGui.QPen(QtGui.QColor(dayu_theme.secondary_text_color)))
- content_height = pix_map.height() + font_metrics.height()
- padding = 10
- proper_min_size = min(
- view.height() - padding * 2, view.width() - padding * 2, content_height
- )
- if proper_min_size < content_height:
- pix_map = pix_map.scaledToHeight(
- proper_min_size - font_metrics.height(), QtCore.Qt.SmoothTransformation
- )
- content_height = proper_min_size
- painter.drawText(
- view.width() / 2 - font_metrics.width(text) / 2,
- view.height() / 2 + content_height / 2 - font_metrics.height() / 2,
- text,
- )
- painter.drawPixmap(
- view.width() / 2 - pix_map.width() / 2,
- view.height() / 2 - content_height / 2,
- pix_map,
- )
- painter.end()
-
-
-class MOptionDelegate(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- super(MOptionDelegate, self).__init__(parent)
- self.editor = None
- self.showed = False
- self.exclusive = True
- self.parent_widget = None
- self.arrow_space = 20
- self.arrow_height = 6
-
- def set_exclusive(self, flag):
- self.exclusive = flag
-
- def createEditor(self, parent, option, index):
- self.parent_widget = parent
- self.editor = MMenu(exclusive=self.exclusive, parent=parent)
- self.editor.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window)
- model = utils.real_model(index)
- real_index = utils.real_index(index)
- data_obj = real_index.internalPointer()
- attr = "{}_list".format(model.header_list[real_index.column()].get("key"))
-
- self.editor.set_data(utils.get_obj_value(data_obj, attr, []))
- self.editor.sig_value_changed.connect(self._slot_finish_edit)
- return self.editor
-
- def setEditorData(self, editor, index):
- editor.set_value(index.data(QtCore.Qt.EditRole))
-
- def setModelData(self, editor, model, index):
- model.setData(index, editor.property("value"))
-
- def updateEditorGeometry(self, editor, option, index):
- editor.move(
- self.parent_widget.mapToGlobal(
- QtCore.QPoint(option.rect.x(), option.rect.y() + option.rect.height())
- )
- )
-
- def paint(self, painter, option, index):
- painter.save()
- icon_color = dayu_theme.icon_color
- if option.state & QtWidgets.QStyle.State_MouseOver:
- painter.fillRect(option.rect, QtGui.QColor(dayu_theme.primary_5))
- icon_color = "#fff"
- if option.state & QtWidgets.QStyle.State_Selected:
- painter.fillRect(option.rect, QtGui.QColor(dayu_theme.primary_6))
- icon_color = "#fff"
- painter.setRenderHint(QtGui.QPainter.Antialiasing)
- painter.setPen(QtCore.Qt.NoPen)
- painter.setBrush(QtGui.QBrush(QtCore.Qt.white))
- pix = MPixmap("down_fill.svg", icon_color)
- h = option.rect.height()
- pix = pix.scaledToWidth(h * 0.5, QtCore.Qt.SmoothTransformation)
- painter.drawPixmap(
- option.rect.x() + option.rect.width() - h, option.rect.y() + h / 4, pix
- )
- painter.restore()
- super(MOptionDelegate, self).paint(painter, option, index)
-
- @QtCore.Slot(object)
- def _slot_finish_edit(self, obj):
- self.commitData.emit(self.editor)
-
- def sizeHint(self, option, index):
- orig = super(MOptionDelegate, self).sizeHint(option, index)
- return QtCore.QSize(orig.width() + self.arrow_space, orig.height())
-
- # def eventFilter(self, obj, event):
- # if obj is self.editor:
- # print event.type(), obj.size()
- # return super(MOptionDelegate, self).eventFilter(obj, event)
-
-
-def set_header_list(self, header_list):
- scale_x, _ = get_scale_factor()
- self.header_list = header_list
- if self.header_view:
- for index, i in enumerate(header_list):
- self.header_view.setSectionHidden(index, i.get("hide", False))
- self.header_view.resizeSection(index, i.get("width", 100) * scale_x)
- if "order" in i:
- order = i.get("order")
- if order in HEADER_SORT_MAP.values():
- self.header_view.setSortIndicator(index, order)
- elif order in HEADER_SORT_MAP:
- self.header_view.setSortIndicator(index, HEADER_SORT_MAP[order])
- if i.get("selectable", False):
- delegate = MOptionDelegate(parent=self)
- delegate.set_exclusive(i.get("exclusive", True))
- self.setItemDelegateForColumn(index, delegate)
- elif self.itemDelegateForColumn(index):
- self.setItemDelegateForColumn(index, None)
-
-
-def enable_context_menu(self, enable):
- if enable:
- self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- self.customContextMenuRequested.connect(self.slot_context_menu)
- else:
- self.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
-
-
-@QtCore.Slot(QtCore.QPoint)
-def slot_context_menu(self, point):
- proxy_index = self.indexAt(point)
- if proxy_index.isValid():
- need_map = isinstance(self.model(), QtCore.QSortFilterProxyModel)
- selection = []
- for index in (
- self.selectionModel().selectedRows()
- or self.selectionModel().selectedIndexes()
- ):
- data_obj = (
- self.model().mapToSource(index).internalPointer()
- if need_map
- else index.internalPointer()
- )
- selection.append(data_obj)
- event = utils.ItemViewMenuEvent(view=self, selection=selection, extra={})
- self.sig_context_menu.emit(event)
- else:
- event = utils.ItemViewMenuEvent(view=self, selection=[], extra={})
- self.sig_context_menu.emit(event)
-
-
-def mouse_move_event(self, event):
- index = self.indexAt(event.pos())
- real_index = utils.real_index(index)
- if self.header_list[real_index.column()].get("is_link", False):
- key_name = self.header_list[real_index.column()]["attr"]
- data_obj = utils.real_model(self.model()).data_list[real_index.row()]
- value = utils.get_obj_value(data_obj, key_name)
- if value:
- self.setCursor(QtCore.Qt.PointingHandCursor)
- return
- self.setCursor(QtCore.Qt.ArrowCursor)
-
-
-def mouse_release_event(self, event):
- if event.button() != QtCore.Qt.LeftButton:
- QtWidgets.QTableView.mouseReleaseEvent(self, event)
- return
- index = self.indexAt(event.pos())
- real_index = utils.real_index(index)
- if self.headerList[real_index.column()].get("is_link", False):
- key_name = self.header_list[real_index.column()]["attr"]
- data_obj = utils.real_model(self.model()).data_list[real_index.row()]
- value = utils.get_obj_value(data_obj, key_name)
- if value:
- if isinstance(value, dict):
- self.sig_link_clicked.emit(value)
- elif isinstance(value, six.string_types):
- self.sig_link_clicked.emit(data_obj)
- elif isinstance(value, list):
- for i in value:
- self.sig_link_clicked.emit(i)
-
-
-class MTableView(QtWidgets.QTableView):
- set_header_list = set_header_list
- enable_context_menu = enable_context_menu
- slot_context_menu = slot_context_menu
- sig_context_menu = QtCore.Signal(object)
-
- def __init__(self, size=None, show_row_count=False, parent=None):
- super(MTableView, self).__init__(parent)
- self._no_data_image = None
- self._no_data_text = self.tr("No Data")
- size = size or dayu_theme.default_size
- ver_header_view = MHeaderView(QtCore.Qt.Vertical, parent=self)
- ver_header_view.setDefaultSectionSize(size)
- self.setVerticalHeader(ver_header_view)
- self.header_list = []
- self.header_view = MHeaderView(QtCore.Qt.Horizontal, parent=self)
- self.header_view.setFixedHeight(size)
- if not show_row_count:
- ver_header_view.hide()
- self.setHorizontalHeader(self.header_view)
- self.setSortingEnabled(True)
- self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
- self.setAlternatingRowColors(True)
- self.setShowGrid(False)
-
- def set_no_data_text(self, text):
- self._no_data_text = text
-
- def set_no_data_image(self, image):
- self._no_data_image = image
-
- def setShowGrid(self, flag):
- self.header_view.setProperty("grid", flag)
- self.verticalHeader().setProperty("grid", flag)
- self.header_view.style().polish(self.header_view)
-
- return super(MTableView, self).setShowGrid(flag)
-
- # setting = {
- # 'key': attr, # 必填,用来读取 model后台数据结构的属性
- # 'label': attr.title(), # 选填,显示在界面的该列的名字
- # 'width': 100, # 选填,单元格默认的宽度
- # 'default_filter': False, # 选填,如果有组合的filter组件,该属性默认是否显示,默认False
- # 'searchable': False, # 选填,如果有搜索组件,该属性是否可以被搜索,默认False
- # 'editable': False, # 选填,该列是否可以双击编辑,默认False
- # 'selectable': False, # 选填,该列是否可以双击编辑,且使用下拉列表选择。该下拉框的选项们,是通过 data 拿数据的
- # 'checkable': False, # 选填,该单元格是否要加checkbox,默认False
- # 'exclusive': True, # 配合selectable,如果是可以多选的则为 False,如果是单选,则为True
- # 'order': None, # 选填,初始化时,该列的排序方式, 0 升序,1 降序
- # # 下面的是每个单元格的设置,主要用来根据本单元格数据,动态设置样式
- # 'color': None, # QColor选填,该单元格文字的颜色,例如根据百分比数据大小,大于100%显示红色,小于100%显示绿色
- # 'bg_color': None, # 选填,该单元格的背景色,例如根据bool数据,True显示绿色,False显示红色
- # 'display': None, # 选填,该单元显示的内容,例如数据是以分钟为单位,可以在这里给转换成按小时为单位
- # 'align': None, # 选填,该单元格文字的对齐方式
- # 'font': None, # 选填,该单元格文字的格式,例如加下划线、加粗等等
- # 'icon': None, # 选填,该单格元的图标,注意,当 QListView 使用图标模式时,每个item的图片也是在这里设置
- # 'tooltip': None, # 选填,鼠标指向该单元格时,显示的提示信息
- # 'size': None, # 选填,该列的 hint size,设置
- # 'data': None,
- # 'edit': None
- # }
-
- def paintEvent(self, event):
- """Override paintEvent when there is no data to show, draw the preset picture and text."""
- model = utils.real_model(self.model())
- if model is None:
- draw_empty_content(self.viewport(), self._no_data_text, self._no_data_image)
- elif isinstance(model, MTableModel):
- if not model.get_data_list():
- draw_empty_content(
- self.viewport(), self._no_data_text, self._no_data_image
- )
- return super(MTableView, self).paintEvent(event)
-
- def save_state(self, name):
- settings = QtCore.QSettings(
- QtCore.QSettings.IniFormat,
- QtCore.QSettings.UserScope,
- "DAYU",
- "dayu_widgets",
- )
- settings.setValue("{}/headerState".format(name, self.header_view.saveState()))
-
- def load_state(self, name):
- settings = QtCore.QSettings(
- QtCore.QSettings.IniFormat,
- QtCore.QSettings.UserScope,
- "DAYU",
- "dayu_widgets",
- )
- if settings.value("{}/headerState".format(name)):
- self.header_view.restoreState(settings.value("{}/headerState".format(name)))
-
-
-class MTreeView(QtWidgets.QTreeView):
- set_header_list = set_header_list
- enable_context_menu = enable_context_menu
- slot_context_menu = slot_context_menu
- sig_context_menu = QtCore.Signal(object)
-
- def __init__(self, parent=None):
- super(MTreeView, self).__init__(parent)
- self._no_data_image = None
- self._no_data_text = self.tr("No Data")
- self.header_list = []
- self.header_view = MHeaderView(QtCore.Qt.Horizontal)
- self.setHeader(self.header_view)
- self.setSortingEnabled(True)
- self.setAlternatingRowColors(True)
-
- def paintEvent(self, event):
- """Override paintEvent when there is no data to show, draw the preset picture and text."""
- model = utils.real_model(self.model())
- if model is None:
- draw_empty_content(self.viewport(), self._no_data_text, self._no_data_image)
- elif isinstance(model, MTableModel):
- if not model.get_data_list():
- draw_empty_content(
- self.viewport(), self._no_data_text, self._no_data_image
- )
- return super(MTreeView, self).paintEvent(event)
-
- def set_no_data_text(self, text):
- self._no_data_text = text
-
-
-class MBigView(QtWidgets.QListView):
- set_header_list = set_header_list
- enable_context_menu = enable_context_menu
- slot_context_menu = slot_context_menu
- sig_context_menu = QtCore.Signal(object)
-
- def __init__(self, parent=None):
- super(MBigView, self).__init__(parent)
- self._no_data_image = None
- self._no_data_text = self.tr("No Data")
- self.header_list = []
- self.header_view = None
- self.setViewMode(QtWidgets.QListView.IconMode)
- self.setResizeMode(QtWidgets.QListView.Adjust)
- self.setMovement(QtWidgets.QListView.Static)
- self.setSpacing(10)
- default_size = dayu_theme.big_view_default_size
- self.setIconSize(QtCore.QSize(default_size, default_size))
-
- def scale_size(self, factor):
- """Scale the icon size."""
- new_size = self.iconSize() * factor
- max_size = dayu_theme.big_view_max_size
- min_size = dayu_theme.big_view_min_size
- if new_size.width() > max_size:
- new_size = QtCore.QSize(max_size, max_size)
- elif new_size.width() < min_size:
- new_size = QtCore.QSize(min_size, min_size)
- self.setIconSize(new_size)
-
- def wheelEvent(self, event):
- """Override wheelEvent while user press ctrl, zoom the list view icon size."""
- if event.modifiers() == QtCore.Qt.ControlModifier:
- num_degrees = event.delta() / 8.0
- num_steps = num_degrees / 15.0
- factor = pow(1.125, num_steps)
- self.scale_size(factor)
- else:
- super(MBigView, self).wheelEvent(event)
-
- def paintEvent(self, event):
- """Override paintEvent when there is no data to show, draw the preset picture and text."""
- model = utils.real_model(self.model())
- if model is None:
- draw_empty_content(self.viewport(), self._no_data_text, self._no_data_image)
- elif isinstance(model, MTableModel):
- if not model.get_data_list():
- draw_empty_content(
- self.viewport(), self._no_data_text, self._no_data_image
- )
- return super(MBigView, self).paintEvent(event)
-
- def set_no_data_text(self, text):
- self._no_data_text = text
-
-
-class MListView(QtWidgets.QListView):
- set_header_list = set_header_list
- enable_context_menu = enable_context_menu
- slot_context_menu = slot_context_menu
- sig_context_menu = QtCore.Signal(object)
-
- def __init__(self, size=None, parent=None):
- super(MListView, self).__init__(parent)
- self._no_data_image = None
- self._no_data_text = self.tr("No Data")
- self.setProperty("dayu_size", size or dayu_theme.default_size)
- self.header_list = []
- self.header_view = None
- self.setModelColumn(0)
- self.setAlternatingRowColors(True)
-
- def set_show_column(self, attr):
- for index, attr_dict in enumerate(self.header_list):
- if attr_dict.get("key") == attr:
- self.setModelColumn(index)
- break
- else:
- self.setModelColumn(0)
-
- def paintEvent(self, event):
- """Override paintEvent when there is no data to show, draw the preset picture and text."""
- model = utils.real_model(self.model())
- if model is None:
- draw_empty_content(self.viewport(), self._no_data_text, self._no_data_image)
- elif isinstance(model, MTableModel):
- if not model.get_data_list():
- draw_empty_content(
- self.viewport(), self._no_data_text, self._no_data_image
- )
- return super(MListView, self).paintEvent(event)
-
- def set_no_data_text(self, text):
- self._no_data_text = text
diff --git a/dayu_widgets/item_view_full_set.py b/dayu_widgets/item_view_full_set.py
deleted file mode 100644
index b7621bcc..00000000
--- a/dayu_widgets/item_view_full_set.py
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2018.5
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MToolButtonGroup
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MBigView
-from dayu_widgets.item_view import MTableView
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.page import MPage
-from dayu_widgets.tool_button import MToolButton
-
-
-class MItemViewFullSet(QtWidgets.QWidget):
- sig_double_clicked = QtCore.Signal(QtCore.QModelIndex)
- sig_left_clicked = QtCore.Signal(QtCore.QModelIndex)
- sig_current_changed = QtCore.Signal(QtCore.QModelIndex, QtCore.QModelIndex)
- sig_current_row_changed = QtCore.Signal(QtCore.QModelIndex, QtCore.QModelIndex)
- sig_current_column_changed = QtCore.Signal(QtCore.QModelIndex, QtCore.QModelIndex)
- sig_selection_changed = QtCore.Signal(QtCore.QItemSelection, QtCore.QItemSelection)
- sig_context_menu = QtCore.Signal(object)
-
- def __init__(self, table_view=True, big_view=False, parent=None):
- super(MItemViewFullSet, self).__init__(parent)
- self.sort_filter_model = MSortFilterModel()
- self.source_model = MTableModel()
- self.sort_filter_model.setSourceModel(self.source_model)
-
- self.stack_widget = QtWidgets.QStackedWidget()
-
- self.view_button_grp = MToolButtonGroup(exclusive=True)
- data_group = []
- if table_view:
- self.table_view = MTableView(show_row_count=True)
- self.table_view.doubleClicked.connect(self.sig_double_clicked)
- self.table_view.pressed.connect(self.slot_left_clicked)
- self.table_view.setModel(self.sort_filter_model)
- self.stack_widget.addWidget(self.table_view)
- data_group.append(
- {"svg": "table_view.svg", "checkable": True, "tooltip": "Table View"}
- )
- if big_view:
- self.big_view = MBigView()
- self.big_view.doubleClicked.connect(self.sig_double_clicked)
- self.big_view.pressed.connect(self.slot_left_clicked)
- self.big_view.setModel(self.sort_filter_model)
- self.stack_widget.addWidget(self.big_view)
- data_group.append(
- {"svg": "big_view.svg", "checkable": True, "tooltip": "Big View"}
- )
-
- # 设置多个view 共享 MItemSelectionModel
- leader_view = self.stack_widget.widget(0)
- self.selection_model = leader_view.selectionModel()
- for index in range(self.stack_widget.count()):
- if index == 0:
- continue
- other_view = self.stack_widget.widget(index)
- other_view.setSelectionModel(self.selection_model)
-
- self.selection_model.currentChanged.connect(self.sig_current_changed)
- self.selection_model.currentRowChanged.connect(self.sig_current_row_changed)
- self.selection_model.currentColumnChanged.connect(
- self.sig_current_column_changed
- )
- self.selection_model.selectionChanged.connect(self.sig_selection_changed)
-
- self.tool_bar = QtWidgets.QWidget()
- self.top_lay = QtWidgets.QHBoxLayout()
- self.top_lay.setContentsMargins(0, 0, 0, 0)
- if data_group and len(data_group) > 1:
- self.view_button_grp.sig_checked_changed.connect(
- self.stack_widget.setCurrentIndex
- )
- self.view_button_grp.set_button_list(data_group)
- self.view_button_grp.set_dayu_checked(0)
- self.top_lay.addWidget(self.view_button_grp)
- self.search_line_edit = MLineEdit().search().small()
- self.search_attr_button = MToolButton().icon_only().svg("down_fill.svg").small()
- self.search_line_edit.set_prefix_widget(self.search_attr_button)
- self.search_line_edit.textChanged.connect(
- self.sort_filter_model.set_search_pattern
- )
- self.search_line_edit.setVisible(False)
-
- self.top_lay.addStretch()
- self.top_lay.addWidget(self.search_line_edit)
- self.tool_bar.setLayout(self.top_lay)
-
- self.page_set = MPage()
- self.main_lay = QtWidgets.QVBoxLayout()
- self.main_lay.setSpacing(5)
- self.main_lay.setContentsMargins(0, 0, 0, 0)
- self.main_lay.addWidget(self.tool_bar)
- self.main_lay.addWidget(self.stack_widget)
- self.main_lay.addWidget(self.page_set)
- self.setLayout(self.main_lay)
-
- def enable_context_menu(self):
- for index in range(self.stack_widget.count()):
- view = self.stack_widget.widget(index)
- view.enable_context_menu(True)
- view.sig_context_menu.connect(self.sig_context_menu)
-
- def set_no_data_text(self, text):
- for index in range(self.stack_widget.count()):
- view = self.stack_widget.widget(index)
- view.set_no_data_text(text)
-
- def set_selection_mode(self, mode):
- for index in range(self.stack_widget.count()):
- view = self.stack_widget.widget(index)
- view.setSelectionMode(mode)
-
- def tool_bar_visible(self, flag):
- self.tool_bar.setVisible(flag)
-
- @QtCore.Slot(QtCore.QModelIndex)
- def slot_left_clicked(self, start_index):
- button = QtWidgets.QApplication.mouseButtons()
- if button == QtCore.Qt.LeftButton:
- real_index = self.sort_filter_model.mapToSource(start_index)
- self.sig_left_clicked.emit(real_index)
-
- def set_header_list(self, header_list):
- self.source_model.set_header_list(header_list)
- self.sort_filter_model.set_header_list(header_list)
- self.sort_filter_model.setSourceModel(self.source_model)
- self.source_model.clear()
- for index in range(self.stack_widget.count()):
- view = self.stack_widget.widget(index)
- view.set_header_list(header_list)
-
- def tool_bar_append_widget(self, widget):
- self.top_lay.addWidget(widget)
-
- def tool_bar_insert_widget(self, widget):
- self.top_lay.insertWidget(0, widget)
-
- @QtCore.Slot()
- def setup_data(self, data_list):
- self.source_model.clear()
- if data_list:
- self.source_model.set_data_list(data_list)
- self.set_record_count(len(data_list))
-
- @QtCore.Slot(int)
- def set_record_count(self, total):
- self.page_set.set_total(total)
-
- def get_data(self):
- return self.source_model.get_data_list()
-
- def searchable(self):
- """Enable search line edit visible."""
- self.search_line_edit.setVisible(True)
- return self
diff --git a/dayu_widgets/item_view_set.py b/dayu_widgets/item_view_set.py
deleted file mode 100644
index 66df35de..00000000
--- a/dayu_widgets/item_view_set.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2018.5
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MBigView
-from dayu_widgets.item_view import MListView
-from dayu_widgets.item_view import MTableView
-from dayu_widgets.item_view import MTreeView
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.tool_button import MToolButton
-
-
-class MItemViewSet(QtWidgets.QWidget):
- sig_double_clicked = QtCore.Signal(QtCore.QModelIndex)
- sig_left_clicked = QtCore.Signal(QtCore.QModelIndex)
- TableViewType = MTableView
- BigViewType = MBigView
- TreeViewType = MTreeView
- ListViewType = MListView
-
- def __init__(self, view_type=None, parent=None):
- super(MItemViewSet, self).__init__(parent)
- self.main_lay = QtWidgets.QVBoxLayout()
- self.main_lay.setSpacing(5)
- self.main_lay.setContentsMargins(0, 0, 0, 0)
-
- self.sort_filter_model = MSortFilterModel()
- self.source_model = MTableModel()
- self.sort_filter_model.setSourceModel(self.source_model)
- view_class = view_type or MItemViewSet.TableViewType
- self.item_view = view_class()
- self.item_view.doubleClicked.connect(self.sig_double_clicked)
- self.item_view.pressed.connect(self.slot_left_clicked)
- self.item_view.setModel(self.sort_filter_model)
-
- self._search_line_edit = MLineEdit().search().small()
- self._search_attr_button = (
- MToolButton().icon_only().svg("down_fill.svg").small()
- )
- self._search_line_edit.set_prefix_widget(self._search_attr_button)
- self._search_line_edit.textChanged.connect(
- self.sort_filter_model.set_search_pattern
- )
- self._search_line_edit.setVisible(False)
- self._search_lay = QtWidgets.QHBoxLayout()
- self._search_lay.setContentsMargins(0, 0, 0, 0)
- self._search_lay.addStretch()
- self._search_lay.addWidget(self._search_line_edit)
-
- self.main_lay.addLayout(self._search_lay)
- self.main_lay.addWidget(self.item_view)
- self.setLayout(self.main_lay)
-
- @QtCore.Slot(QtCore.QModelIndex)
- def slot_left_clicked(self, start_index):
- button = QtWidgets.QApplication.mouseButtons()
- if button == QtCore.Qt.LeftButton:
- real_index = self.sort_filter_model.mapToSource(start_index)
- self.sig_left_clicked.emit(real_index)
-
- def set_header_list(self, header_list):
- self.source_model.set_header_list(header_list)
- self.sort_filter_model.set_header_list(header_list)
- self.sort_filter_model.setSourceModel(self.source_model)
- self.source_model.clear()
- self.item_view.set_header_list(header_list)
-
- @QtCore.Slot()
- def setup_data(self, data_list):
- self.source_model.clear()
- if data_list:
- self.source_model.set_data_list(data_list)
-
- def get_data(self):
- return self.source_model.get_data_list()
-
- def searchable(self):
- """Enable search line edit visible."""
- self._search_line_edit.setVisible(True)
- return self
-
- def insert_widget(self, widget):
- """Use can insert extra widget into search layout."""
- self._search_lay.insertWidget(0, widget)
diff --git a/dayu_widgets/label.py b/dayu_widgets/label.py
deleted file mode 100644
index d9def9db..00000000
--- a/dayu_widgets/label.py
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-
-
-class MLabel(QtWidgets.QLabel):
- """
- Display title in different level.
- Property:
- dayu_level: integer
- dayu_type: str
- """
-
- SecondaryType = "secondary"
- WarningType = "warning"
- DangerType = "danger"
- H1Level = 1
- H2Level = 2
- H3Level = 3
- H4Level = 4
-
- def __init__(self, text="", parent=None, flags=QtCore.Qt.Widget):
- super(MLabel, self).__init__(text, parent, flags)
- self.setTextInteractionFlags(
- QtCore.Qt.TextBrowserInteraction | QtCore.Qt.LinksAccessibleByMouse
- )
- self.setSizePolicy(
- QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum
- )
- self._dayu_type = ""
- self._dayu_underline = False
- self._dayu_mark = False
- self._dayu_delete = False
- self._dayu_strong = False
- self._dayu_code = False
- self._dayu_level = 0
- self._elide_mode = QtCore.Qt.ElideNone
- self.setProperty("dayu_text", text)
-
- def get_dayu_level(self):
- """Get MLabel level."""
- return self._dayu_level
-
- def set_dayu_level(self, value):
- """Set MLabel level"""
- self._dayu_level = value
- self.style().polish(self)
-
- def set_dayu_underline(self, value):
- """Set MLabel underline style."""
- self._dayu_underline = value
- self.style().polish(self)
-
- def get_dayu_underline(self):
- return self._dayu_underline
-
- def set_dayu_delete(self, value):
- """Set MLabel a delete line style."""
- self._dayu_delete = value
- self.style().polish(self)
-
- def get_dayu_delete(self):
- return self._dayu_delete
-
- def set_dayu_strong(self, value):
- """Set MLabel bold style."""
- self._dayu_strong = value
- self.style().polish(self)
-
- def get_dayu_strong(self):
- return self._dayu_strong
-
- def set_dayu_mark(self, value):
- """Set MLabel mark style."""
- self._dayu_mark = value
- self.style().polish(self)
-
- def get_dayu_mark(self):
- return self._dayu_mark
-
- def set_dayu_code(self, value):
- """Set MLabel code style."""
- self._dayu_code = value
- self.style().polish(self)
-
- def get_dayu_code(self):
- return self._dayu_code
-
- def get_elide_mode(self):
- return self._elide_mode
-
- def set_elide_mode(self, value):
- """Set MLabel elide mode.
- Only accepted Qt.ElideLeft/Qt.ElideMiddle/Qt.ElideRight/Qt.ElideNone"""
- self._elide_mode = value
- self._update_elided_text()
-
- def get_dayu_type(self):
- return self._dayu_type
-
- def set_dayu_type(self, value):
- self._dayu_type = value
- self.style().polish(self)
-
- dayu_level = QtCore.Property(int, get_dayu_level, set_dayu_level)
- dayu_type = QtCore.Property(str, get_dayu_type, set_dayu_type)
- dayu_underline = QtCore.Property(bool, get_dayu_underline, set_dayu_underline)
- dayu_delete = QtCore.Property(bool, get_dayu_delete, set_dayu_delete)
- dayu_strong = QtCore.Property(bool, get_dayu_strong, set_dayu_strong)
- dayu_mark = QtCore.Property(bool, get_dayu_mark, set_dayu_mark)
- dayu_code = QtCore.Property(bool, get_dayu_code, set_dayu_code)
- dayu_elide_mod = QtCore.Property(
- QtCore.Qt.TextElideMode, get_dayu_code, set_dayu_code
- )
-
- def minimumSizeHint(self):
- return QtCore.QSize(1, self.fontMetrics().height())
-
- def text(self):
- """
- Overridden base method to return the original unmodified text
-
- :returns: The original unmodified text
- """
- return self.property("text")
-
- def setText(self, text):
- """
- Overridden base method to set the text on the label
-
- :param text: The text to set on the label
- """
- self.setProperty("text", text)
- self._update_elided_text()
- self.setToolTip(text)
-
- def set_link(self, href, text=None):
- """
-
- :param href: The href attr of a tag
- :param text: The a tag text content
- """
- # 这里富文本的超链接必须使用 html 的样式,使用 qss 不起作用
- link_style = dayu_theme.hyperlink_style
- self.setText(
- '{style}{text}'.format(
- style=link_style, href=href, text=text or href
- )
- )
- self.setOpenExternalLinks(True)
-
- def _update_elided_text(self):
- """
- Update the elided text on the label
- """
- _font_metrics = self.fontMetrics()
- text = self.property("text")
- text = text if text else ""
- _elided_text = _font_metrics.elidedText(
- text, self._elide_mode, self.width() - 2 * 2
- )
- super(MLabel, self).setText(_elided_text)
-
- def resizeEvent(self, event):
- """
- Overridden base method called when the widget is resized.
-
- :param event: The resize event
- """
- self._update_elided_text()
-
- def h1(self):
- """Set QLabel with h1 type."""
- self.set_dayu_level(MLabel.H1Level)
- return self
-
- def h2(self):
- """Set QLabel with h2 type."""
- self.set_dayu_level(MLabel.H2Level)
- return self
-
- def h3(self):
- """Set QLabel with h3 type."""
- self.set_dayu_level(MLabel.H3Level)
- return self
-
- def h4(self):
- """Set QLabel with h4 type."""
- self.set_dayu_level(MLabel.H4Level)
- return self
-
- def secondary(self):
- """Set QLabel with secondary type."""
- self.set_dayu_type(MLabel.SecondaryType)
- return self
-
- def warning(self):
- """Set QLabel with warning type."""
- self.set_dayu_type(MLabel.WarningType)
- return self
-
- def danger(self):
- """Set QLabel with danger type."""
- self.set_dayu_type(MLabel.DangerType)
- return self
-
- def strong(self):
- """Set QLabel with strong style."""
- self.set_dayu_strong(True)
- return self
-
- def mark(self):
- """Set QLabel with mark style."""
- self.set_dayu_mark(True)
- return self
-
- def code(self):
- """Set QLabel with code style."""
- self.set_dayu_code(True)
- return self
-
- def delete(self):
- """Set QLabel with delete style."""
- self.set_dayu_delete(True)
- return self
-
- def underline(self):
- """Set QLabel with underline style."""
- self.set_dayu_underline(True)
- return self
-
- def event(self, event):
- if (
- event.type() == QtCore.QEvent.DynamicPropertyChange
- and event.propertyName() == "dayu_text"
- ):
- self.setText(self.property("dayu_text"))
- return super(MLabel, self).event(event)
diff --git a/dayu_widgets/line_edit.py b/dayu_widgets/line_edit.py
deleted file mode 100644
index e27c36c4..00000000
--- a/dayu_widgets/line_edit.py
+++ /dev/null
@@ -1,251 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""MLineEdit
-Get the user input is a text field
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-import six
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.browser import MClickBrowserFileToolButton
-from dayu_widgets.browser import MClickBrowserFolderToolButton
-from dayu_widgets.browser import MClickSaveFileToolButton
-from dayu_widgets.mixin import focus_shadow_mixin
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.tool_button import MToolButton
-
-
-@focus_shadow_mixin
-class MLineEdit(QtWidgets.QLineEdit):
- """MLineEdit"""
-
- sig_delay_text_changed = QtCore.Signal(six.string_types[0])
-
- def __init__(self, text="", parent=None):
- super(MLineEdit, self).__init__(text, parent)
- self._main_layout = QtWidgets.QHBoxLayout()
- self._main_layout.setContentsMargins(0, 0, 0, 0)
- self._main_layout.addStretch()
-
- self._prefix_widget = None
- self._suffix_widget = None
-
- self.setLayout(self._main_layout)
- self.setProperty("history", self.property("text"))
- self.setTextMargins(2, 0, 2, 0)
-
- self._delay_timer = QtCore.QTimer()
- self._delay_timer.setInterval(500)
- self._delay_timer.setSingleShot(True)
- self._delay_timer.timeout.connect(self._slot_delay_text_changed)
- self.textChanged.connect(self._slot_begin_to_start_delay)
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the push button height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the avatar size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- if hasattr(self._prefix_widget, "set_dayu_size"):
- self._prefix_widget.set_dayu_size(self._dayu_size)
- if hasattr(self._suffix_widget, "set_dayu_size"):
- self._suffix_widget.set_dayu_size(self._dayu_size)
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def set_delay_duration(self, millisecond):
- """Set delay timer's timeout duration."""
- self._delay_timer.setInterval(millisecond)
-
- @QtCore.Slot()
- def _slot_delay_text_changed(self):
- self.sig_delay_text_changed.emit(self.text())
-
- @QtCore.Slot(six.text_type)
- def _slot_begin_to_start_delay(self, _):
- if self._delay_timer.isActive():
- self._delay_timer.stop()
- self._delay_timer.start()
-
- def get_prefix_widget(self):
- """Get the prefix widget for user to edit"""
- return self._prefix_widget
-
- def set_prefix_widget(self, widget):
- """Set the line edit left start widget"""
- if self._prefix_widget:
- index = self._main_layout.indexOf(self._prefix_widget)
- self._main_layout.takeAt(index)
- self._prefix_widget.setVisible(False)
- # if isinstance(widget, MPushButton):
- widget.setProperty("combine", "horizontal")
- widget.setProperty("position", "left")
- if hasattr(widget, "set_dayu_size"):
- widget.set_dayu_size(self._dayu_size)
-
- margin = self.textMargins()
- margin.setLeft(margin.left() + widget.width())
- self.setTextMargins(margin)
-
- self._main_layout.insertWidget(0, widget)
- self._prefix_widget = widget
- return widget
-
- def get_suffix_widget(self):
- """Get the suffix widget for user to edit"""
- return self._suffix_widget
-
- def set_suffix_widget(self, widget):
- """Set the line edit right end widget"""
- if self._suffix_widget:
- index = self._main_layout.indexOf(self._suffix_widget)
- self._main_layout.takeAt(index)
- self._suffix_widget.setVisible(False)
- # if isinstance(widget, MPushButton):
- widget.setProperty("combine", "horizontal")
- widget.setProperty("position", "right")
- if hasattr(widget, "set_dayu_size"):
- widget.set_dayu_size(self._dayu_size)
-
- margin = self.textMargins()
- margin.setRight(margin.right() + widget.width())
- self.setTextMargins(margin)
- self._main_layout.addWidget(widget)
- self._suffix_widget = widget
- return widget
-
- def setText(self, text):
- """Override setText save text to history"""
- self.setProperty("history", "{}\n{}".format(self.property("history"), text))
- return super(MLineEdit, self).setText(text)
-
- def clear(self):
- """Override clear to clear history"""
- self.setProperty("history", "")
- return super(MLineEdit, self).clear()
-
- def search(self):
- """Add a search icon button for MLineEdit."""
- suffix_button = MToolButton().icon_only().svg("close_line.svg")
- suffix_button.clicked.connect(self.clear)
- self.set_suffix_widget(suffix_button)
- self.setPlaceholderText(self.tr("Enter key word to search..."))
- return self
-
- def error(self):
- """A a toolset to MLineEdit to store error info with red style"""
-
- @QtCore.Slot()
- def _slot_show_detail(self):
- dialog = QtWidgets.QTextEdit(self)
- dialog.setReadOnly(True)
- geo = QtWidgets.QApplication.desktop().screenGeometry()
- dialog.setGeometry(
- geo.width() / 2, geo.height() / 2, geo.width() / 4, geo.height() / 4
- )
- dialog.setWindowTitle(self.tr("Error Detail Information"))
- dialog.setText(self.property("history"))
- dialog.setWindowFlags(QtCore.Qt.Dialog)
- dialog.show()
-
- self.setProperty("dayu_type", "error")
- self.setReadOnly(True)
- _suffix_button = MToolButton().icon_only().svg("detail_line.svg")
- _suffix_button.clicked.connect(functools.partial(_slot_show_detail, self))
- self.set_suffix_widget(_suffix_button)
- self.setPlaceholderText(self.tr("Error information will be here..."))
- return self
-
- def search_engine(self, text="Search"):
- """Add a MPushButton to suffix for MLineEdit"""
- _suffix_button = MPushButton(text=text).primary()
- _suffix_button.clicked.connect(self.returnPressed)
- _suffix_button.setFixedWidth(100)
- self.set_suffix_widget(_suffix_button)
- self.setPlaceholderText(self.tr("Enter key word to search..."))
- return self
-
- def file(self, filters=None):
- """Add a MClickBrowserFileToolButton for MLineEdit to select file"""
- _suffix_button = MClickBrowserFileToolButton()
- _suffix_button.sig_file_changed.connect(self.setText)
- _suffix_button.set_dayu_filters(filters or [])
- self.textChanged.connect(_suffix_button.set_dayu_path)
- self.set_suffix_widget(_suffix_button)
- self.setPlaceholderText(self.tr("Click button to browser files"))
- return self
-
- def save_file(self, filters=None):
- """Add a MClickSaveFileToolButton for MLineEdit to set save file"""
- _suffix_button = MClickSaveFileToolButton()
- _suffix_button.sig_file_changed.connect(self.setText)
- _suffix_button.set_dayu_filters(filters or [])
- self.textChanged.connect(_suffix_button.set_dayu_path)
- self.set_suffix_widget(_suffix_button)
- self.setPlaceholderText(self.tr("Click button to set save file"))
- return self
-
- def folder(self):
- """Add a MClickBrowserFolderToolButton for MLineEdit to select folder"""
- _suffix_button = MClickBrowserFolderToolButton()
- _suffix_button.sig_folder_changed.connect(self.setText)
- self.textChanged.connect(_suffix_button.set_dayu_path)
- self.set_suffix_widget(_suffix_button)
- self.setPlaceholderText(self.tr("Click button to browser folder"))
- return self
-
- def huge(self):
- """Set MLineEdit to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MLineEdit to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MLineEdit to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MLineEdit to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MLineEdit to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
-
- def password(self):
- """Set MLineEdit to password echo mode"""
- self.setEchoMode(QtWidgets.QLineEdit.Password)
- return self
diff --git a/dayu_widgets/line_tab_widget.py b/dayu_widgets/line_tab_widget.py
deleted file mode 100644
index d22c71b2..00000000
--- a/dayu_widgets/line_tab_widget.py
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""MLineTabWidget"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.button_group import MButtonGroupBase
-from dayu_widgets.divider import MDivider
-from dayu_widgets.stacked_widget import MStackedWidget
-from dayu_widgets.tool_button import MToolButton
-
-
-class MUnderlineButton(MToolButton):
- """MUnderlineButton"""
-
- def __init__(self, parent=None):
- super(MUnderlineButton, self).__init__(parent)
- self.setCheckable(True)
-
-
-class MUnderlineButtonGroup(MButtonGroupBase):
- """MUnderlineButtonGroup"""
-
- sig_checked_changed = QtCore.Signal(int)
-
- def __init__(self, tab, parent=None):
- super(MUnderlineButtonGroup, self).__init__(parent=parent)
- self._line_tab = tab
- self.set_spacing(1)
- self._button_group.setExclusive(True)
- self._button_group.buttonClicked[int].connect(self.sig_checked_changed)
-
- def create_button(self, data_dict):
- button = MUnderlineButton(parent=self)
- if data_dict.get("svg"):
- button.svg(data_dict.get("svg"))
- if data_dict.get("text"):
- if data_dict.get("svg") or data_dict.get("icon"):
- button.text_beside_icon()
- else:
- button.text_only()
- else:
- button.icon_only()
- button.set_dayu_size(self._line_tab.get_dayu_size())
- return button
-
- def update_size(self, size):
- for button in self._button_group.buttons():
- button.set_dayu_size(size)
-
- def set_dayu_checked(self, value):
- """Set current checked button's id"""
- button = self._button_group.button(value)
- button.setChecked(True)
- self.sig_checked_changed.emit(value)
-
- def get_dayu_checked(self):
- """Get current checked button's id"""
- return self._button_group.checkedId()
-
- dayu_checked = QtCore.Property(
- int, get_dayu_checked, set_dayu_checked, notify=sig_checked_changed
- )
-
-
-class MLineTabWidget(QtWidgets.QWidget):
- """MLineTabWidget"""
-
- def __init__(self, alignment=QtCore.Qt.AlignCenter, parent=None):
- super(MLineTabWidget, self).__init__(parent=parent)
- self.tool_button_group = MUnderlineButtonGroup(tab=self)
- self.bar_layout = QtWidgets.QHBoxLayout()
- self.bar_layout.setContentsMargins(0, 0, 0, 0)
- if alignment == QtCore.Qt.AlignCenter:
- self.bar_layout.addStretch()
- self.bar_layout.addWidget(self.tool_button_group)
- self.bar_layout.addStretch()
- elif alignment == QtCore.Qt.AlignLeft:
- self.bar_layout.addWidget(self.tool_button_group)
- self.bar_layout.addStretch()
- elif alignment == QtCore.Qt.AlignRight:
- self.bar_layout.addStretch()
- self.bar_layout.addWidget(self.tool_button_group)
- self.stack_widget = MStackedWidget()
- self.tool_button_group.sig_checked_changed.connect(
- self.stack_widget.setCurrentIndex
- )
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.setContentsMargins(0, 0, 0, 0)
- main_lay.setSpacing(0)
- main_lay.addLayout(self.bar_layout)
- main_lay.addWidget(MDivider())
- main_lay.addSpacing(5)
- main_lay.addWidget(self.stack_widget)
- self.setLayout(main_lay)
- self._dayu_size = dayu_theme.default
-
- def append_widget(self, widget):
- """Add the widget to line tab's right position."""
- self.bar_layout.addWidget(widget)
-
- def insert_widget(self, widget):
- """Insert the widget to line tab's left position."""
- self.bar_layout.insertWidget(0, widget)
-
- def add_tab(self, widget, data_dict):
- """Add a tab"""
- self.stack_widget.addWidget(widget)
- self.tool_button_group.add_button(data_dict, self.stack_widget.count() - 1)
-
- def get_dayu_size(self):
- """
- Get the line tab size.
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the line tab size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.tool_button_group.update_size(self._dayu_size)
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
diff --git a/dayu_widgets/loading.py b/dayu_widgets/loading.py
deleted file mode 100644
index bae35905..00000000
--- a/dayu_widgets/loading.py
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.4
-# Email : muyanru345@163.com
-###################################################################
-"""
-MLoading
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.qt import MPixmap
-
-
-class MLoading(QtWidgets.QWidget):
- """
- Show a loading animation image.
- """
-
- def __init__(self, size=None, color=None, parent=None):
- super(MLoading, self).__init__(parent)
- size = size or dayu_theme.default_size
- self.setFixedSize(QtCore.QSize(size, size))
- self.pix = MPixmap(
- "loading.svg", color or dayu_theme.primary_color
- ).scaledToWidth(size, QtCore.Qt.SmoothTransformation)
- self._rotation = 0
- self._loading_ani = QtCore.QPropertyAnimation()
- self._loading_ani.setTargetObject(self)
- # self.loading_ani.setEasingCurve(QEasingCurve.InOutQuad)
- self._loading_ani.setDuration(1000)
- self._loading_ani.setPropertyName(b"rotation")
- self._loading_ani.setStartValue(0)
- self._loading_ani.setEndValue(360)
- self._loading_ani.setLoopCount(-1)
- self._loading_ani.start()
-
- def _set_rotation(self, value):
- self._rotation = value
- self.update()
-
- def _get_rotation(self):
- return self._rotation
-
- rotation = QtCore.Property(int, _get_rotation, _set_rotation)
-
- def paintEvent(self, event):
- """override the paint event to paint the 1/4 circle image."""
- painter = QtGui.QPainter(self)
- painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)
- painter.translate(self.pix.width() / 2, self.pix.height() / 2)
- painter.rotate(self._rotation)
- painter.drawPixmap(
- -self.pix.width() / 2,
- -self.pix.height() / 2,
- self.pix.width(),
- self.pix.height(),
- self.pix,
- )
- painter.end()
- return super(MLoading, self).paintEvent(event)
-
- @classmethod
- def huge(cls, color=None):
- """Create a MLoading with huge size"""
- return cls(dayu_theme.huge, color)
-
- @classmethod
- def large(cls, color=None):
- """Create a MLoading with large size"""
- return cls(dayu_theme.large, color)
-
- @classmethod
- def medium(cls, color=None):
- """Create a MLoading with medium size"""
- return cls(dayu_theme.medium, color)
-
- @classmethod
- def small(cls, color=None):
- """Create a MLoading with small size"""
- return cls(dayu_theme.small, color)
-
- @classmethod
- def tiny(cls, color=None):
- """Create a MLoading with tiny size"""
- return cls(dayu_theme.tiny, color)
-
-
-class MLoadingWrapper(QtWidgets.QWidget):
- """
- A wrapper widget to show the loading widget or hide.
- Property:
- dayu_loading: bool. current loading state.
- """
-
- def __init__(self, widget, loading=True, parent=None):
- super(MLoadingWrapper, self).__init__(parent)
- self._widget = widget
- self._mask_widget = QtWidgets.QFrame()
- self._mask_widget.setObjectName("mask")
- self._mask_widget.setSizePolicy(
- QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding
- )
- self._loading_widget = MLoading()
- self._loading_widget.setSizePolicy(
- QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding
- )
-
- self._main_lay = QtWidgets.QGridLayout()
- self._main_lay.setContentsMargins(0, 0, 0, 0)
- self._main_lay.addWidget(widget, 0, 0)
- self._main_lay.addWidget(self._mask_widget, 0, 0)
- self._main_lay.addWidget(self._loading_widget, 0, 0, QtCore.Qt.AlignCenter)
- self.setLayout(self._main_lay)
- self._loading = None
- self.set_dayu_loading(loading)
-
- def _set_loading(self):
- self._loading_widget.setVisible(self._loading)
- self._mask_widget.setVisible(self._loading)
-
- def set_dayu_loading(self, loading):
- """
- Set current state to loading or not
- :param loading: bool
- :return: None
- """
- self._loading = loading
- self._set_loading()
-
- def get_dayu_loading(self):
- """
- Get current loading widget is loading or not.
- :return: bool
- """
- return self._loading
-
- dayu_loading = QtCore.Property(bool, get_dayu_loading, set_dayu_loading)
diff --git a/dayu_widgets/menu.py b/dayu_widgets/menu.py
deleted file mode 100644
index 0f4b0545..00000000
--- a/dayu_widgets/menu.py
+++ /dev/null
@@ -1,641 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-from functools import partial
-import re
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-from Qt.QtCompat import isValid
-import six
-
-# Import local modules
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.mixin import property_mixin
-from dayu_widgets.popup import MPopup
-import dayu_widgets.utils as utils
-
-
-@property_mixin
-class ScrollableMenuBase(QtWidgets.QMenu):
- """
- https://www.pythonfixing.com/2021/10/fixed-how-to-have-scrollable-context.html
- """
-
- deltaY = 0
- dirty = True
- ignoreAutoScroll = False
-
- def __init__(self, *args, **kwargs):
- super(ScrollableMenuBase, self).__init__(*args, **kwargs)
- self._maximumHeight = self.maximumHeight()
- self._actionRects = []
-
- self.scrollTimer = QtCore.QTimer(
- self, interval=50, singleShot=True, timeout=self.checkScroll
- )
- self.scrollTimer.setProperty("defaultInterval", 50)
- self.delayTimer = QtCore.QTimer(self, interval=100, singleShot=True)
-
- self.setMaxItemCount(0)
-
- def _set_max_scroll_count(self, value):
- self.setMaxItemCount(value * 2.2)
-
- @property
- def actionRects(self):
- if self.dirty or not self._actionRects:
- del self._actionRects[:]
- offset = self.offset()
- for action in self.actions():
- geo = super(ScrollableMenuBase, self).actionGeometry(action)
- if offset:
- geo.moveTop(geo.y() - offset)
- self._actionRects.append(geo)
- self.dirty = False
- return self._actionRects
-
- def iterActionRects(self):
- for action, rect in zip(self.actions(), self.actionRects):
- yield action, rect
-
- def setMaxItemCount(self, count):
- style = self.style()
- opt = QtWidgets.QStyleOptionMenuItem()
- opt.initFrom(self)
-
- a = QtWidgets.QAction("fake action", self)
- self.initStyleOption(opt, a)
- size = QtCore.QSize()
- fm = self.fontMetrics()
- qfm = opt.fontMetrics
- size.setWidth(
- fm.boundingRect(QtCore.QRect(), QtCore.Qt.TextSingleLine, a.text()).width()
- )
- size.setHeight(max(fm.height(), qfm.height()))
- self.defaultItemHeight = style.sizeFromContents(
- style.CT_MenuItem, opt, size, self
- ).height()
-
- if not count:
- self.setMaximumHeight(self._maximumHeight)
- else:
- fw = style.pixelMetric(style.PM_MenuPanelWidth, None, self)
- vmargin = style.pixelMetric(style.PM_MenuHMargin, opt, self)
- scrollHeight = self.scrollHeight(style)
- self.setMaximumHeight(
- self.defaultItemHeight * count + (fw + vmargin + scrollHeight) * 2
- )
- self.dirty = True
-
- def scrollHeight(self, style):
- return style.pixelMetric(style.PM_MenuScrollerHeight, None, self) * 2
-
- def isScrollable(self):
- return (
- self.property("scrollable")
- and self.height() < super(ScrollableMenuBase, self).sizeHint().height()
- )
-
- def checkScroll(self):
- pos = self.mapFromGlobal(QtGui.QCursor.pos())
- delta = max(2, int(self.defaultItemHeight * 0.25))
- if self.scrollUpRect.contains(pos):
- delta *= -1
- elif not self.scrollDownRect.contains(pos):
- return
- if self.scrollBy(delta):
- self.scrollTimer.start(self.scrollTimer.property("defaultInterval"))
-
- def offset(self):
- if self.isScrollable():
- return self.deltaY - self.scrollHeight(self.style())
- return 0
-
- def translatedActionGeometry(self, action):
- return self.actionRects[self.actions().index(action)]
-
- def ensureVisible(self, action):
- style = self.style()
- fw = style.pixelMetric(style.PM_MenuPanelWidth, None, self)
- hmargin = style.pixelMetric(style.PM_MenuHMargin, None, self)
- vmargin = style.pixelMetric(style.PM_MenuVMargin, None, self)
- scrollHeight = self.scrollHeight(style)
- extent = fw + hmargin + vmargin + scrollHeight
- r = self.rect().adjusted(0, extent, 0, -extent)
- geo = self.translatedActionGeometry(action)
- if geo.top() < r.top():
- self.scrollBy(-(r.top() - geo.top()))
- elif geo.bottom() > r.bottom():
- self.scrollBy(geo.bottom() - r.bottom())
-
- def scrollBy(self, step):
- if step < 0:
- newDelta = max(0, self.deltaY + step)
- if newDelta == self.deltaY:
- return False
- elif step > 0:
- newDelta = self.deltaY + step
- style = self.style()
- scrollHeight = self.scrollHeight(style)
- bottom = self.height() - scrollHeight
-
- for lastAction in reversed(self.actions()):
- if lastAction.isVisible():
- break
- lastBottom = (
- self.actionGeometry(lastAction).bottom() - newDelta + scrollHeight
- )
- if lastBottom < bottom:
- newDelta -= bottom - lastBottom
- if newDelta == self.deltaY:
- return False
-
- self.deltaY = newDelta
- self.dirty = True
- self.update()
- return True
-
- def actionAt(self, pos):
- for action, rect in self.iterActionRects():
- if rect.contains(pos):
- return action
-
- # class methods reimplementation
-
- def sizeHint(self):
- hint = super(ScrollableMenuBase, self).sizeHint()
- if hint.height() > self.maximumHeight():
- hint.setHeight(self.maximumHeight())
- return hint
-
- def eventFilter(self, source, event):
- if event.type() == event.Show:
- if self.isScrollable() and self.deltaY:
- action = source.menuAction()
- self.ensureVisible(action)
- rect = self.translatedActionGeometry(action)
- delta = rect.topLeft() - self.actionGeometry(action).topLeft()
- source.move(source.pos() + delta)
- return False
- return super(ScrollableMenuBase, self).eventFilter(source, event)
-
- def event(self, event):
- if not self.isScrollable():
- return super(ScrollableMenuBase, self).event(event)
- if event.type() == event.KeyPress and event.key() in (
- QtCore.Qt.Key_Up,
- QtCore.Qt.Key_Down,
- ):
- res = super(ScrollableMenuBase, self).event(event)
- action = self.activeAction()
- if action:
- self.ensureVisible(action)
- self.update()
- return res
- elif event.type() in (event.MouseButtonPress, event.MouseButtonDblClick):
- pos = event.pos()
- if self.scrollUpRect.contains(pos) or self.scrollDownRect.contains(pos):
- if event.button() == QtCore.Qt.LeftButton:
- step = max(2, int(self.defaultItemHeight * 0.25))
- if self.scrollUpRect.contains(pos):
- step *= -1
- self.scrollBy(step)
- self.scrollTimer.start(200)
- self.ignoreAutoScroll = True
- return True
- elif event.type() == event.MouseButtonRelease:
- pos = event.pos()
- self.scrollTimer.stop()
- if not (
- self.scrollUpRect.contains(pos) or self.scrollDownRect.contains(pos)
- ):
- action = self.actionAt(pos)
- if action:
- action.trigger()
- self.close()
- return True
- return super(ScrollableMenuBase, self).event(event)
-
- def timerEvent(self, event):
- if not self.isScrollable():
- # ignore internal timer event for reopening popups
- super(ScrollableMenuBase, self).timerEvent(event)
-
- def mouseMoveEvent(self, event):
- if not self.isScrollable():
- super(ScrollableMenuBase, self).mouseMoveEvent(event)
- return
-
- pos = event.pos()
- if pos.y() < self.scrollUpRect.bottom() or pos.y() > self.scrollDownRect.top():
- if not self.ignoreAutoScroll and not self.scrollTimer.isActive():
- self.scrollTimer.start(200)
- return
- self.ignoreAutoScroll = False
-
- oldAction = self.activeAction()
- if not self.rect().contains(pos):
- action = None
- else:
- y = event.y()
- for action, rect in self.iterActionRects():
- if rect.y() <= y <= rect.y() + rect.height():
- break
- else:
- action = None
-
- self.setActiveAction(action)
- if action and isValid(action) and not action.isSeparator():
-
- def ensureVisible():
- self.delayTimer.timeout.disconnect()
- self.ensureVisible(action)
-
- try:
- self.delayTimer.disconnect()
- except:
- pass
- self.delayTimer.timeout.connect(ensureVisible)
- self.delayTimer.start(150)
- elif oldAction and oldAction.menu() and oldAction.menu().isVisible():
-
- def closeMenu():
- self.delayTimer.timeout.disconnect()
- oldAction.menu().hide()
-
- self.delayTimer.timeout.connect(closeMenu)
- self.delayTimer.start(50)
- self.update()
-
- def wheelEvent(self, event):
- if not self.isScrollable():
- return
- self.delayTimer.stop()
- if event.angleDelta().y() < 0:
- self.scrollBy(self.defaultItemHeight)
- else:
- self.scrollBy(-self.defaultItemHeight)
-
- def showEvent(self, event):
- if self.isScrollable():
- self.deltaY = 0
- self.dirty = True
- for action in self.actions():
- if action.menu():
- action.menu().installEventFilter(self)
- self.ignoreAutoScroll = False
- super(ScrollableMenuBase, self).showEvent(event)
-
- def hideEvent(self, event):
- for action in self.actions():
- if action.menu():
- action.menu().removeEventFilter(self)
- super(ScrollableMenuBase, self).hideEvent(event)
-
- def resizeEvent(self, event):
- super(ScrollableMenuBase, self).resizeEvent(event)
-
- style = self.style()
- l, t, r, b = self.getContentsMargins()
- fw = style.pixelMetric(style.PM_MenuPanelWidth, None, self)
- hmargin = style.pixelMetric(style.PM_MenuHMargin, None, self)
- vmargin = style.pixelMetric(style.PM_MenuVMargin, None, self)
- leftMargin = fw + hmargin + l
- topMargin = fw + vmargin + t
- bottomMargin = fw + vmargin + b
- contentWidth = self.width() - (fw + hmargin) * 2 - l - r
-
- scrollHeight = self.scrollHeight(style)
- self.scrollUpRect = QtCore.QRect(
- leftMargin, topMargin, contentWidth, scrollHeight
- )
- self.scrollDownRect = QtCore.QRect(
- leftMargin,
- self.height() - scrollHeight - bottomMargin,
- contentWidth,
- scrollHeight,
- )
-
- def paintEvent(self, event):
- if not self.isScrollable():
- super(ScrollableMenuBase, self).paintEvent(event)
- return
-
- style = self.style()
- qp = QtGui.QPainter(self)
- rect = self.rect()
- emptyArea = QtGui.QRegion(rect)
-
- menuOpt = QtWidgets.QStyleOptionMenuItem()
- menuOpt.initFrom(self)
- menuOpt.state = style.State_None
- menuOpt.maxIconWidth = 0
- menuOpt.tabWidth = 0
- style.drawPrimitive(style.PE_PanelMenu, menuOpt, qp, self)
-
- fw = style.pixelMetric(style.PM_MenuPanelWidth, None, self)
- topEdge = self.scrollUpRect.bottom()
- bottomEdge = self.scrollDownRect.top()
- offset = self.offset()
- qp.save()
- qp.translate(0, -offset)
- # offset translation is required in order to allow correct fade animations
- for action, actionRect in self.iterActionRects():
- actionRect = self.translatedActionGeometry(action)
- if actionRect.bottom() < topEdge:
- continue
- if actionRect.top() > bottomEdge:
- continue
-
- visible = QtCore.QRect(actionRect)
- if actionRect.bottom() > bottomEdge:
- visible.setBottom(bottomEdge)
- elif actionRect.top() < topEdge:
- visible.setTop(topEdge)
- visible = QtGui.QRegion(visible.translated(0, offset))
- qp.setClipRegion(visible)
- emptyArea -= visible.translated(0, -offset)
-
- opt = QtWidgets.QStyleOptionMenuItem()
- self.initStyleOption(opt, action)
- opt.rect = actionRect.translated(0, offset)
- style.drawControl(style.CE_MenuItem, opt, qp, self)
- qp.restore()
-
- cursor = self.mapFromGlobal(QtGui.QCursor.pos())
- upData = (False, self.deltaY > 0, self.scrollUpRect)
- downData = (True, actionRect.bottom() - 2 > bottomEdge, self.scrollDownRect)
-
- for isDown, enabled, scrollRect in upData, downData:
- qp.setClipRect(scrollRect)
-
- scrollOpt = QtWidgets.QStyleOptionMenuItem()
- scrollOpt.initFrom(self)
- scrollOpt.state = style.State_None
- scrollOpt.state |= style.State_DownArrow if isDown else style.State_UpArrow
- scrollOpt.checkType = scrollOpt.NotCheckable
- scrollOpt.maxIconWidth = scrollOpt.tabWidth = 0
- scrollOpt.rect = scrollRect
- scrollOpt.menuItemType = scrollOpt.Scroller
- if enabled:
- if scrollRect.contains(cursor):
- frame = QtWidgets.QStyleOptionMenuItem()
- frame.initFrom(self)
- frame.rect = scrollRect
- frame.state |= style.State_Selected | style.State_Enabled
- style.drawControl(style.CE_MenuItem, frame, qp, self)
-
- scrollOpt.state |= style.State_Enabled
- scrollOpt.palette.setCurrentColorGroup(QtGui.QPalette.Active)
- else:
- scrollOpt.palette.setCurrentColorGroup(QtGui.QPalette.Disabled)
- style.drawControl(style.CE_MenuScroller, scrollOpt, qp, self)
-
- if fw:
- borderReg = QtGui.QRegion()
- borderReg |= QtGui.QRegion(QtCore.QRect(0, 0, fw, self.height()))
- borderReg |= QtGui.QRegion(
- QtCore.QRect(self.width() - fw, 0, fw, self.height())
- )
- borderReg |= QtGui.QRegion(QtCore.QRect(0, 0, self.width(), fw))
- borderReg |= QtGui.QRegion(
- QtCore.QRect(0, self.height() - fw, self.width(), fw)
- )
- qp.setClipRegion(borderReg)
- emptyArea -= borderReg
- frame = QtWidgets.QStyleOptionFrame()
- frame.rect = rect
- frame.palette = self.palette()
- frame.state = QtWidgets.QStyle.State_None
- frame.lineWidth = style.pixelMetric(style.PM_MenuPanelWidth)
- frame.midLineWidth = 0
- style.drawPrimitive(style.PE_FrameMenu, frame, qp, self)
-
- qp.setClipRegion(emptyArea)
- menuOpt.state = style.State_None
- menuOpt.menuItemType = menuOpt.EmptyArea
- menuOpt.checkType = menuOpt.NotCheckable
- menuOpt.rect = menuOpt.menuRect = rect
- style.drawControl(style.CE_MenuEmptyArea, menuOpt, qp, self)
-
-
-@property_mixin
-class SearchableMenuBase(ScrollableMenuBase):
- def __init__(self, *args, **kwargs):
- super(SearchableMenuBase, self).__init__(*args, **kwargs)
- self.search_popup = MPopup(self)
- self.search_popup.setVisible(False)
- self.search_bar = MLineEdit(parent=self)
- self.search_label = QtWidgets.QLabel()
-
- self.search_bar.textChanged.connect(self.slot_search_change)
- self.search_bar.keyPressEvent = partial(
- self.search_key_event, self.search_bar.keyPressEvent
- )
- self.aboutToHide.connect(lambda: self.search_bar.setText(""))
-
- layout = QtWidgets.QVBoxLayout()
- layout.addWidget(self.search_label)
- layout.addWidget(self.search_bar)
- self.search_popup.setLayout(layout)
-
- self.setProperty("search_placeholder", self.tr("Search Action..."))
- self.setProperty("search_label", self.tr("Search Action..."))
-
- self.setProperty("searchable", True)
- self.setProperty("search_re", "I")
-
- def search_key_event(self, call, event):
- key = event.key()
- # NOTES: support menu original key event on search bar
- if key in (
- QtCore.Qt.Key_Up,
- QtCore.Qt.Key_Down,
- QtCore.Qt.Key_Return,
- QtCore.Qt.Key_Enter,
- ):
- super(SearchableMenuBase, self).keyPressEvent(event)
- elif key == QtCore.Qt.Key_Tab:
- self.search_bar.setFocus()
- return call(event)
-
- def _set_search_label(self, value):
- self.search_label.setText(value)
-
- def _set_search_placeholder(self, value):
- self.search_bar.setPlaceholderText(value)
-
- def _set_search_re(self, value):
- if not isinstance(value, six.text_type):
- raise TypeError("`search_re` property should be a string type")
-
- def slot_search_change(self, text):
- flags = 0
- for m in self.property("search_re") or "":
- flags |= getattr(re, m.upper(), 0)
- search_reg = re.compile(r".*%s.*" % text, flags)
- self._update_search(search_reg)
-
- def _update_search(self, search_reg, parent_menu=None):
- actions = parent_menu.actions() if parent_menu else self.actions()
- vis_list = []
- for action in actions:
- menu = action.menu()
- if not menu:
- is_match = bool(re.match(search_reg, action.text()))
- action.setVisible(is_match)
- is_match and vis_list.append(action)
- else:
- is_match = bool(re.match(search_reg, menu.title()))
- self._update_search("" if is_match else search_reg, menu)
-
- if parent_menu:
- parent_menu.menuAction().setVisible(bool(vis_list) or not search_reg)
-
- def keyPressEvent(self, event):
- key = event.key()
- if self.property("searchable"):
- # NOTES(timmyliang): 26 character trigger search bar
- if 65 <= key <= 90:
- char = chr(key)
- self.search_bar.setText(char)
- self.search_bar.setFocus()
- self.search_bar.selectAll()
- width = self.sizeHint().width()
- width = width if width >= 50 else 50
- offset = QtCore.QPoint(width, 0)
- self.search_popup.move(self.pos() + offset)
- self.search_popup.show()
- elif key == QtCore.Qt.Key_Escape:
- self.search_bar.setText("")
- self.search_popup.hide()
- return super(SearchableMenuBase, self).keyPressEvent(event)
-
-
-@property_mixin
-class MMenu(SearchableMenuBase):
- sig_value_changed = QtCore.Signal(object)
-
- def __init__(self, exclusive=True, cascader=False, title="", parent=None):
- super(MMenu, self).__init__(title=title, parent=parent)
- self.setProperty("cascader", cascader)
- self.setCursor(QtCore.Qt.PointingHandCursor)
- self._action_group = QtWidgets.QActionGroup(self)
- self._action_group.setExclusive(exclusive)
- self._action_group.triggered.connect(self.slot_on_action_triggered)
- self._load_data_func = None
- self.set_value("")
- self.set_data([])
- self.set_separator("/")
-
- def set_separator(self, chr):
- self.setProperty("separator", chr)
-
- def set_load_callback(self, func):
- assert callable(func)
- self._load_data_func = func
- self.aboutToShow.connect(self.slot_fetch_data)
-
- def slot_fetch_data(self):
- data_list = self._load_data_func()
- self.set_data(data_list)
-
- def set_value(self, data):
- assert isinstance(data, (list, six.string_types, six.integer_types, float))
- # if isinstance(data, int):
- # action = self._action_group.actions()[data]
- # data = action.property('value')
- if self.property("cascader") and isinstance(data, six.string_types):
- data = data.split(self.property("separator"))
- self.setProperty("value", data)
-
- def _set_value(self, value):
- data_list = value if isinstance(value, list) else [value]
- flag = False
- for act in self._action_group.actions():
- checked = act.property("value") in data_list
- if act.isChecked() != checked: # 更新来自代码
- act.setChecked(checked)
- flag = True
- if flag:
- self.sig_value_changed.emit(value)
-
- def _add_menu(self, parent_menu, data_dict):
- if "children" in data_dict:
- menu = MMenu(title=data_dict.get("label"), parent=self)
- menu.setProperty("value", data_dict.get("value"))
- parent_menu.addMenu(menu)
- if not (parent_menu is self):
- # 用来将来获取父层级数据
- menu.setProperty("parent_menu", parent_menu)
- for i in data_dict.get("children"):
- self._add_menu(menu, i)
- else:
- action = self._action_group.addAction(
- utils.display_formatter(data_dict.get("label"))
- )
- action.setProperty("value", data_dict.get("value"))
- action.setCheckable(True)
- # 用来将来获取父层级数据
- action.setProperty("parent_menu", parent_menu)
- parent_menu.addAction(action)
-
- def set_data(self, option_list):
- assert isinstance(option_list, list)
- if option_list:
- if all(isinstance(i, six.string_types) for i in option_list):
- option_list = utils.from_list_to_nested_dict(
- option_list, sep=self.property("separator")
- )
- if all(isinstance(i, (int, float)) for i in option_list):
- option_list = [{"value": i, "label": str(i)} for i in option_list]
- # 全部转换成 dict 类型的 list
- self.setProperty("data", option_list)
-
- def _set_data(self, option_list):
- self.clear()
- for act in self._action_group.actions():
- self._action_group.removeAction(act)
-
- for data_dict in option_list:
- self._add_menu(self, data_dict)
-
- def _get_parent(self, result, obj):
- if obj.property("parent_menu"):
- parent_menu = obj.property("parent_menu")
- result.insert(0, parent_menu.property("value"))
- self._get_parent(result, parent_menu)
-
- def slot_on_action_triggered(self, action):
- current_data = action.property("value")
- if self.property("cascader"):
- selected_data = [current_data]
- self._get_parent(selected_data, action)
- else:
- if self._action_group.isExclusive():
- selected_data = current_data
- else:
- selected_data = [
- act.property("value")
- for act in self._action_group.actions()
- if act.isChecked()
- ]
- self.set_value(selected_data)
- self.sig_value_changed.emit(selected_data)
-
- def set_loader(self, func):
- self._load_data_func = func
diff --git a/dayu_widgets/menu_tab_widget.py b/dayu_widgets/menu_tab_widget.py
deleted file mode 100644
index ed012e36..00000000
--- a/dayu_widgets/menu_tab_widget.py
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""A Navigation menu"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.button_group import MButtonGroupBase
-from dayu_widgets.divider import MDivider
-from dayu_widgets.tool_button import MToolButton
-
-
-class MBlockButton(MToolButton):
- """MBlockButton"""
-
- def __init__(self, parent=None):
- super(MBlockButton, self).__init__(parent)
- self.setCheckable(True)
-
-
-class MBlockButtonGroup(MButtonGroupBase):
- """MBlockButtonGroup"""
-
- sig_checked_changed = QtCore.Signal(int)
-
- def __init__(self, tab, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MBlockButtonGroup, self).__init__(orientation=orientation, parent=parent)
- self.set_spacing(1)
- self._menu_tab = tab
- self._button_group.setExclusive(True)
- self._button_group.buttonClicked[int].connect(self.sig_checked_changed)
-
- def create_button(self, data_dict):
- button = MBlockButton()
- if data_dict.get("svg"):
- button.svg(data_dict.get("svg"))
- if data_dict.get("text"):
- if data_dict.get("svg") or data_dict.get("icon"):
- button.text_beside_icon()
- else:
- button.text_only()
- else:
- button.icon_only()
- button.set_dayu_size(self._menu_tab.get_dayu_size())
- return button
-
- def update_size(self, size):
- for button in self._button_group.buttons():
- button.set_dayu_size(size)
-
- def set_dayu_checked(self, value):
- """Set current checked button's id"""
- button = self._button_group.button(value)
- button.setChecked(True)
- self.sig_checked_changed.emit(value)
-
- def get_dayu_checked(self):
- """Get current checked button's id"""
- return self._button_group.checkedId()
-
- dayu_checked = QtCore.Property(
- int, get_dayu_checked, set_dayu_checked, notify=sig_checked_changed
- )
-
-
-class MMenuTabWidget(QtWidgets.QWidget):
- """MMenuTabWidget"""
-
- def __init__(self, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MMenuTabWidget, self).__init__(parent=parent)
- self.tool_button_group = MBlockButtonGroup(tab=self, orientation=orientation)
-
- if orientation == QtCore.Qt.Horizontal:
- self._bar_layout = QtWidgets.QHBoxLayout()
- self._bar_layout.setContentsMargins(10, 0, 10, 0)
- else:
- self._bar_layout = QtWidgets.QVBoxLayout()
- self._bar_layout.setContentsMargins(0, 0, 0, 0)
-
- self._bar_layout.addWidget(self.tool_button_group)
- self._bar_layout.addStretch()
- bar_widget = QtWidgets.QWidget()
- bar_widget.setObjectName("bar_widget")
- bar_widget.setLayout(self._bar_layout)
- bar_widget.setAttribute(QtCore.Qt.WA_StyledBackground)
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.setContentsMargins(0, 0, 0, 0)
- main_lay.setSpacing(0)
- main_lay.addWidget(bar_widget)
-
- if orientation == QtCore.Qt.Horizontal:
- main_lay.addWidget(MDivider())
-
- main_lay.addSpacing(5)
- self.setLayout(main_lay)
- self._dayu_size = dayu_theme.large
-
- def tool_bar_append_widget(self, widget):
- """Add the widget too menubar's right position."""
- self._bar_layout.addWidget(widget)
-
- def tool_bar_insert_widget(self, widget):
- """Insert the widget to menubar's left position."""
- self._bar_layout.insertWidget(0, widget)
-
- def add_menu(self, data_dict, index=None):
- """Add a menu"""
- self.tool_button_group.add_button(data_dict, index)
-
- def get_dayu_size(self):
- """
- Get the menu tab size.
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the menu tab size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.tool_button_group.update_size(self._dayu_size)
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
diff --git a/dayu_widgets/message.py b/dayu_widgets/message.py
deleted file mode 100644
index da346e1a..00000000
--- a/dayu_widgets/message.py
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""MMessage"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.label import MLabel
-from dayu_widgets.loading import MLoading
-from dayu_widgets.qt import MPixmap
-from dayu_widgets.tool_button import MToolButton
-
-
-class MMessage(QtWidgets.QWidget):
- """
- Display global messages as feedback in response to user operations.
- """
-
- InfoType = "info"
- SuccessType = "success"
- WarningType = "warning"
- ErrorType = "error"
- LoadingType = "loading"
-
- default_config = {"duration": 2, "top": 24}
-
- sig_closed = QtCore.Signal()
-
- def __init__(
- self, text, duration=None, dayu_type=None, closable=False, parent=None
- ):
- super(MMessage, self).__init__(parent)
- self.setObjectName("message")
- self.setWindowFlags(
- QtCore.Qt.FramelessWindowHint
- | QtCore.Qt.Dialog
- | QtCore.Qt.WA_TranslucentBackground
- | QtCore.Qt.WA_DeleteOnClose
- )
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
-
- if dayu_type == MMessage.LoadingType:
- _icon_label = MLoading.tiny()
- else:
- _icon_label = MAvatar.tiny()
- current_type = dayu_type or MMessage.InfoType
- _icon_label.set_dayu_image(
- MPixmap(
- "{}_fill.svg".format(current_type),
- vars(dayu_theme).get(current_type + "_color"),
- )
- )
-
- self._content_label = MLabel(parent=self)
- # self._content_label.set_elide_mode(Qt.ElideMiddle)
- self._content_label.setText(text)
-
- self._close_button = (
- MToolButton(parent=self).icon_only().svg("close_line.svg").tiny()
- )
- self._close_button.clicked.connect(self.close)
- self._close_button.setVisible(closable or False)
-
- self._main_lay = QtWidgets.QHBoxLayout()
- self._main_lay.addWidget(_icon_label)
- self._main_lay.addWidget(self._content_label)
- self._main_lay.addStretch()
- self._main_lay.addWidget(self._close_button)
- self.setLayout(self._main_lay)
-
- _close_timer = QtCore.QTimer(self)
- _close_timer.setSingleShot(True)
- _close_timer.timeout.connect(self.close)
- _close_timer.timeout.connect(self.sig_closed)
- _close_timer.setInterval(
- (duration or self.default_config.get("duration")) * 1000
- )
-
- _ani_timer = QtCore.QTimer(self)
- _ani_timer.timeout.connect(self._fade_out)
- _ani_timer.setInterval(
- (duration or self.default_config.get("duration")) * 1000 - 300
- )
-
- _close_timer.start()
- _ani_timer.start()
-
- self._pos_ani = QtCore.QPropertyAnimation(self)
- self._pos_ani.setTargetObject(self)
- self._pos_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
- self._pos_ani.setDuration(300)
- self._pos_ani.setPropertyName(b"pos")
-
- self._opacity_ani = QtCore.QPropertyAnimation()
- self._opacity_ani.setTargetObject(self)
- self._opacity_ani.setDuration(300)
- self._opacity_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
- self._opacity_ani.setPropertyName(b"windowOpacity")
- self._opacity_ani.setStartValue(0.0)
- self._opacity_ani.setEndValue(1.0)
-
- self._set_proper_position(parent)
- self._fade_int()
-
- def _fade_out(self):
- self._pos_ani.setDirection(QtCore.QAbstractAnimation.Backward)
- self._pos_ani.start()
- self._opacity_ani.setDirection(QtCore.QAbstractAnimation.Backward)
- self._opacity_ani.start()
-
- def _fade_int(self):
- self._pos_ani.start()
- self._opacity_ani.start()
-
- def _set_proper_position(self, parent):
- parent_geo = parent.geometry()
- pos = (
- parent_geo.topLeft()
- if parent.parent() is None
- else parent.mapToGlobal(parent_geo.topLeft())
- )
- offset = 0
- for child in parent.children():
- if isinstance(child, MMessage) and child.isVisible():
- offset = max(offset, child.y())
- base = pos.y() + MMessage.default_config.get("top")
- target_x = pos.x() + parent_geo.width() / 2 - 100
- target_y = (offset + 50) if offset else base
- self._pos_ani.setStartValue(QtCore.QPoint(target_x, target_y - 40))
- self._pos_ani.setEndValue(QtCore.QPoint(target_x, target_y))
-
- @classmethod
- def info(cls, text, parent, duration=None, closable=None):
- """Show a normal message"""
- inst = cls(
- text,
- dayu_type=MMessage.InfoType,
- duration=duration,
- closable=closable,
- parent=parent,
- )
- inst.show()
- return inst
-
- @classmethod
- def success(cls, text, parent, duration=None, closable=None):
- """Show a success message"""
- inst = cls(
- text,
- dayu_type=MMessage.SuccessType,
- duration=duration,
- closable=closable,
- parent=parent,
- )
-
- inst.show()
- return inst
-
- @classmethod
- def warning(cls, text, parent, duration=None, closable=None):
- """Show a warning message"""
- inst = cls(
- text,
- dayu_type=MMessage.WarningType,
- duration=duration,
- closable=closable,
- parent=parent,
- )
- inst.show()
- return inst
-
- @classmethod
- def error(cls, text, parent, duration=None, closable=None):
- """Show an error message"""
- inst = cls(
- text,
- dayu_type=MMessage.ErrorType,
- duration=duration,
- closable=closable,
- parent=parent,
- )
- inst.show()
- return inst
-
- @classmethod
- def loading(cls, text, parent):
- """Show a message with loading animation"""
- inst = cls(text, dayu_type=MMessage.LoadingType, parent=parent)
- inst.show()
- return inst
-
- @classmethod
- def config(cls, duration=None, top=None):
- """
- Config the global MMessage duration and top setting.
- :param duration: int (unit is second)
- :param top: int (unit is px)
- :return: None
- """
- if duration is not None:
- cls.default_config["duration"] = duration
- if top is not None:
- cls.default_config["top"] = top
diff --git a/dayu_widgets/mixin.py b/dayu_widgets/mixin.py
deleted file mode 100644
index e7712f4b..00000000
--- a/dayu_widgets/mixin.py
+++ /dev/null
@@ -1,219 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""
-mixin decorators to add Qt class feature.
-"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-
-def property_mixin(cls):
- """Run function after dynamic property value changed"""
-
- def _new_event(self, event):
- if event.type() == QtCore.QEvent.DynamicPropertyChange:
- prp = event.propertyName().data().decode()
- if hasattr(self, "_set_{}".format(prp)):
- callback = getattr(self, "_set_{}".format(prp))
- callback(self.property(str(prp)))
- return super(cls, self).event(event)
-
- setattr(cls, "event", _new_event)
- return cls
-
-
-def cursor_mixin(cls):
- """
- Change Widget cursor:
- when user mouse in: Qt.PointingHandCursor;
- when widget is disabled and mouse in: Qt.ForbiddenCursor
- """
-
- old_enter_event = cls.enterEvent
- old_leave_event = cls.leaveEvent
-
- def _new_enter_event(self, *args, **kwargs):
- old_enter_event(self, *args, **kwargs)
- self.__dict__.update({"__dayu_enter": True})
- QtWidgets.QApplication.setOverrideCursor(
- QtCore.Qt.PointingHandCursor
- if self.isEnabled()
- else QtCore.Qt.ForbiddenCursor
- )
- return super(cls, self).enterEvent(*args, **kwargs)
-
- def _new_leave_event(self, *args, **kwargs):
- old_leave_event(self, *args, **kwargs)
- if self.__dict__.get("__dayu_enter", False):
- QtWidgets.QApplication.restoreOverrideCursor()
- self.__dict__.update({"__dayu_enter": False})
- return super(cls, self).leaveEvent(*args, **kwargs)
-
- def _new_hide_event(self, *args, **kwargs):
- old_leave_event(self, *args, **kwargs)
- if self.__dict__.get("__dayu_enter", False):
- QtWidgets.QApplication.restoreOverrideCursor()
- self.__dict__.update({"__dayu_enter": False})
- return super(cls, self).hideEvent(*args, **kwargs)
-
- setattr(cls, "enterEvent", _new_enter_event)
- setattr(cls, "leaveEvent", _new_leave_event)
- setattr(cls, "hideEvent", _new_hide_event)
- return cls
-
-
-def focus_shadow_mixin(cls):
- """
- Add shadow effect for decorated class when widget focused
- When focus in target widget, enable shadow effect.
- When focus out target widget, disable shadow effect.
- """
- old_focus_in_event = cls.focusInEvent
- old_focus_out_event = cls.focusOutEvent
-
- def _new_focus_in_event(self, *args, **kwargs):
- old_focus_in_event(self, *args, **kwargs)
- if not self.graphicsEffect():
- # Import local modules
- from dayu_widgets import dayu_theme
-
- shadow_effect = QtWidgets.QGraphicsDropShadowEffect(self)
- dayu_type = self.property("dayu_type")
- color = vars(dayu_theme).get("{}_color".format(dayu_type or "primary"))
- shadow_effect.setColor(QtGui.QColor(color))
- shadow_effect.setOffset(0, 0)
- shadow_effect.setBlurRadius(5)
- shadow_effect.setEnabled(False)
- self.setGraphicsEffect(shadow_effect)
- if self.isEnabled():
- self.graphicsEffect().setEnabled(True)
-
- def _new_focus_out_event(self, *args, **kwargs):
- old_focus_out_event(self, *args, **kwargs)
- if self.graphicsEffect():
- self.graphicsEffect().setEnabled(False)
-
- setattr(cls, "focusInEvent", _new_focus_in_event)
- setattr(cls, "focusOutEvent", _new_focus_out_event)
- return cls
-
-
-def hover_shadow_mixin(cls):
- """
- Add shadow effect for decorated class when widget hovered
- When mouse enter target widget, enable shadow effect.
- When mouse leave target widget, disable shadow effect.
- """
- old_enter_event = cls.enterEvent
- old_leave_event = cls.leaveEvent
-
- def _new_enter_event(self, *args, **kwargs):
- old_enter_event(self, *args, **kwargs)
- if not self.graphicsEffect():
- # Import local modules
- from dayu_widgets import dayu_theme
-
- shadow_effect = QtWidgets.QGraphicsDropShadowEffect(self)
- dayu_type = self.property("type")
- color = vars(dayu_theme).get("{}_color".format(dayu_type or "primary"))
- shadow_effect.setColor(QtGui.QColor(color))
- shadow_effect.setOffset(0, 0)
- shadow_effect.setBlurRadius(5)
- shadow_effect.setEnabled(False)
- self.setGraphicsEffect(shadow_effect)
- if self.isEnabled():
- self.graphicsEffect().setEnabled(True)
-
- def _new_leave_event(self, *args, **kwargs):
- old_leave_event(self, *args, **kwargs)
- if self.graphicsEffect():
- self.graphicsEffect().setEnabled(False)
-
- setattr(cls, "enterEvent", _new_enter_event)
- setattr(cls, "leaveEvent", _new_leave_event)
- return cls
-
-
-def _stackable(widget):
- """Used for stacked_animation_mixin to only add mixin for widget who can stacked."""
- # We use widget() to get currentWidget, use currentChanged to play the animation.
- # For now just QTabWidget and QStackedWidget can use this decorator.
- return (
- issubclass(widget, QtWidgets.QWidget)
- and hasattr(widget, "widget")
- and hasattr(widget, "currentChanged")
- )
-
-
-def stacked_animation_mixin(cls):
- """
- Decorator for stacked widget.
- When Stacked widget currentChanged, show opacity and position animation for current widget.
- """
- if not _stackable(cls): # If widget can't stack, return the original widget class
- return cls
- old_init = cls.__init__
-
- def _new_init(self, *args, **kwargs):
- old_init(self, *args, **kwargs)
- self._previous_index = 0
- self._to_show_pos_ani = QtCore.QPropertyAnimation()
- self._to_show_pos_ani.setDuration(400)
- self._to_show_pos_ani.setPropertyName(b"pos")
- self._to_show_pos_ani.setEndValue(QtCore.QPoint(0, 0))
- self._to_show_pos_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
-
- self._to_hide_pos_ani = QtCore.QPropertyAnimation()
- self._to_hide_pos_ani.setDuration(400)
- self._to_hide_pos_ani.setPropertyName(b"pos")
- self._to_hide_pos_ani.setEndValue(QtCore.QPoint(0, 0))
- self._to_hide_pos_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
-
- self._opacity_eff = QtWidgets.QGraphicsOpacityEffect()
- self._opacity_ani = QtCore.QPropertyAnimation()
- self._opacity_ani.setDuration(400)
- self._opacity_ani.setEasingCurve(QtCore.QEasingCurve.InCubic)
- self._opacity_ani.setPropertyName(b"opacity")
- self._opacity_ani.setStartValue(0.0)
- self._opacity_ani.setEndValue(1.0)
- self._opacity_ani.setTargetObject(self._opacity_eff)
- self._opacity_ani.finished.connect(self._disable_opacity)
- self.currentChanged.connect(self._play_anim)
-
- def _play_anim(self, index):
- current_widget = self.widget(index)
- if self._previous_index < index:
- self._to_show_pos_ani.setStartValue(QtCore.QPoint(self.width(), 0))
- self._to_show_pos_ani.setTargetObject(current_widget)
- self._to_show_pos_ani.start()
- else:
- self._to_hide_pos_ani.setStartValue(QtCore.QPoint(-self.width(), 0))
- self._to_hide_pos_ani.setTargetObject(current_widget)
- self._to_hide_pos_ani.start()
- current_widget.setGraphicsEffect(self._opacity_eff)
- current_widget.graphicsEffect().setEnabled(True)
- self._opacity_ani.start()
- self._previous_index = index
-
- def _disable_opacity(self):
- # 如果不关掉effect,会跟子控件的 effect 或 paintEvent 冲突引起 crash
- # QPainter::begin: A paint device can only be painted by one painter at a time.
- self.currentWidget().graphicsEffect().setEnabled(False)
-
- setattr(cls, "__init__", _new_init)
- setattr(cls, "_play_anim", _play_anim)
- setattr(cls, "_disable_opacity", _disable_opacity)
- return cls
diff --git a/dayu_widgets/page.py b/dayu_widgets/page.py
deleted file mode 100644
index 416b0e50..00000000
--- a/dayu_widgets/page.py
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""MPage"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets import utils
-from dayu_widgets.combo_box import MComboBox
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.menu import MMenu
-from dayu_widgets.spin_box import MSpinBox
-from dayu_widgets.tool_button import MToolButton
-
-
-class MPage(QtWidgets.QWidget, MFieldMixin):
- """
- MPage
- A long list can be divided into several pages by MPage,
- and only one page will be loaded at a time.
- """
-
- sig_page_changed = QtCore.Signal(int, int)
-
- def __init__(self, parent=None):
- super(MPage, self).__init__(parent)
- self.register_field("page_size_selected", 25)
- self.register_field(
- "page_size_list",
- [
- {"label": "25 - Fastest", "value": 25},
- {"label": "50 - Fast", "value": 50},
- {"label": "75 - Medium", "value": 75},
- {"label": "100 - Slow", "value": 100},
- ],
- )
- self.register_field("total", 0)
- self.register_field("current_page", 0)
- self.register_field(
- "total_page",
- lambda: utils.get_total_page(
- self.field("total"), self.field("page_size_selected")
- ),
- )
- self.register_field("total_page_text", lambda: str(self.field("total_page")))
- self.register_field(
- "display_text",
- lambda: utils.get_page_display_string(
- self.field("current_page"),
- self.field("page_size_selected"),
- self.field("total"),
- ),
- )
- self.register_field("can_pre", lambda: self.field("current_page") > 1)
- self.register_field(
- "can_next", lambda: self.field("current_page") < self.field("total_page")
- )
- page_setting_menu = MMenu(parent=self)
- self._display_label = MLabel()
- self._display_label.setAlignment(QtCore.Qt.AlignCenter)
- self._change_page_size_button = MComboBox().small()
- self._change_page_size_button.set_menu(page_setting_menu)
- self._change_page_size_button.set_formatter(lambda x: "{} per page".format(x))
-
- self._pre_button = MToolButton().icon_only().svg("left_fill.svg").small()
- self._pre_button.clicked.connect(
- functools.partial(self._slot_change_current_page, -1)
- )
- self._next_button = MToolButton().small().icon_only().svg("right_fill.svg")
- self._next_button.clicked.connect(
- functools.partial(self._slot_change_current_page, 1)
- )
- self._current_page_spin_box = MSpinBox()
- self._current_page_spin_box.setMinimum(1)
- self._current_page_spin_box.set_dayu_size(dayu_theme.small)
- self._current_page_spin_box.valueChanged.connect(self._emit_page_changed)
- self._total_page_label = MLabel()
-
- self.bind("page_size_list", page_setting_menu, "data")
- self.bind(
- "page_size_selected", page_setting_menu, "value", signal="sig_value_changed"
- )
- self.bind(
- "page_size_selected",
- self._change_page_size_button,
- "value",
- signal="sig_value_changed",
- )
- self.bind(
- "current_page", self._current_page_spin_box, "value", signal="valueChanged"
- )
- self.bind("total_page", self._current_page_spin_box, "maximum")
- self.bind("total_page_text", self._total_page_label, "dayu_text")
- self.bind("display_text", self._display_label, "dayu_text")
- self.bind("can_pre", self._pre_button, "enabled")
- self.bind("can_next", self._next_button, "enabled")
-
- self._change_page_size_button.sig_value_changed.connect(self._emit_page_changed)
-
- main_lay = QtWidgets.QHBoxLayout()
- main_lay.setContentsMargins(0, 0, 0, 0)
- main_lay.setSpacing(2)
- main_lay.addStretch()
- main_lay.addWidget(self._display_label)
- main_lay.addStretch()
- main_lay.addWidget(MLabel("|").secondary())
- main_lay.addWidget(self._change_page_size_button)
- main_lay.addWidget(MLabel("|").secondary())
- main_lay.addWidget(self._pre_button)
- main_lay.addWidget(MLabel("Page"))
- main_lay.addWidget(self._current_page_spin_box)
- main_lay.addWidget(MLabel("/"))
- main_lay.addWidget(self._total_page_label)
- main_lay.addWidget(self._next_button)
- self.setLayout(main_lay)
-
- def set_total(self, value):
- """Set page component total count."""
- self.set_field("total", value)
- self.set_field("current_page", 1)
-
- def _slot_change_current_page(self, offset):
- self.set_field("current_page", self.field("current_page") + offset)
- self._emit_page_changed()
-
- def set_page_config(self, data_list):
- """Set page component per page settings."""
- self.set_field(
- "page_size_list",
- [
- {"label": str(data), "value": data} if isinstance(data, int) else data
- for data in data_list
- ],
- )
-
- def _emit_page_changed(self):
- self.sig_page_changed.emit(
- self.field("page_size_selected"), self.field("current_page")
- )
diff --git a/dayu_widgets/popup.py b/dayu_widgets/popup.py
deleted file mode 100644
index 7a84ad9a..00000000
--- a/dayu_widgets/popup.py
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: timmyliang
-# Date : 2021.12
-# Email : 820472580@qq.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.mixin import hover_shadow_mixin
-from dayu_widgets.mixin import property_mixin
-
-
-@hover_shadow_mixin
-@property_mixin
-class MPopup(QtWidgets.QFrame):
- def __init__(self, parent=None):
- super(MPopup, self).__init__(parent)
- self.setWindowFlags(QtCore.Qt.Popup)
- self.mouse_pos = None
- self.setProperty("movable", True)
- self.setProperty("animatable", True)
- QtCore.QTimer.singleShot(0, self.post_init)
-
- self._opacity_anim = QtCore.QPropertyAnimation(self, b"windowOpacity")
- self.setProperty("anim_opacity_duration", 300)
- self.setProperty("anim_opacity_curve", "OutCubic")
- self.setProperty("anim_opacity_start", 0)
- self.setProperty("anim_opacity_end", 1)
-
- self._size_anim = QtCore.QPropertyAnimation(self, b"size")
- self.setProperty("anim_size_duration", 300)
- self.setProperty("anim_size_curve", "OutCubic")
- self.setProperty("border_radius", 15)
-
- def post_init(self):
- start_size = self.property("anim_size_start")
- size = self.sizeHint()
- start_size = start_size if start_size else QtCore.QSize(0, size.height())
- end_size = self.property("anim_size_end")
- end_size = end_size if end_size else size
- self.setProperty("anim_size_start", start_size)
- self.setProperty("anim_size_end", end_size)
-
- def update_mask(self):
- rectPath = QtGui.QPainterPath()
- end_size = self.property("anim_size_end")
- rect = QtCore.QRectF(0, 0, end_size.width(), end_size.height())
- radius = self.property("border_radius")
- rectPath.addRoundedRect(rect, radius, radius)
- self.setMask(QtGui.QRegion(rectPath.toFillPolygon().toPolygon()))
-
- def _get_curve(self, value):
- curve = getattr(QtCore.QEasingCurve, value, None)
- if not curve:
- raise TypeError("Invalid QEasingCurve")
- return curve
-
- def _set_border_radius(self, value):
- QtCore.QTimer.singleShot(0, self.update_mask)
-
- def _set_anim_opacity_duration(self, value):
- self._opacity_anim.setDuration(value)
-
- def _set_anim_opacity_curve(self, value):
- self._opacity_anim.setEasingCurve(self._get_curve(value))
-
- def _set_anim_opacity_start(self, value):
- self._opacity_anim.setStartValue(value)
-
- def _set_anim_opacity_end(self, value):
- self._opacity_anim.setEndValue(value)
-
- def _set_anim_size_duration(self, value):
- self._size_anim.setDuration(value)
-
- def _set_anim_size_curve(self, value):
- self._size_anim.setEasingCurve(self._get_curve(value))
-
- def _set_anim_size_start(self, value):
- self._size_anim.setStartValue(value)
-
- def _set_anim_size_end(self, value):
- self._size_anim.setEndValue(value)
- QtCore.QTimer.singleShot(0, self.update_mask)
-
- def start_anim(self):
- self._size_anim.start()
- self._opacity_anim.start()
-
- def mousePressEvent(self, event):
- if event.button() == QtCore.Qt.LeftButton:
- self.mouse_pos = event.pos()
- return super(MPopup, self).mousePressEvent(event)
-
- def mouseReleaseEvent(self, event):
- self.mouse_pos = None
- return super(MPopup, self).mouseReleaseEvent(event)
-
- def mouseMoveEvent(self, event):
- if (
- event.buttons() == QtCore.Qt.LeftButton
- and self.mouse_pos
- and self.property("movable")
- ):
- self.move(self.mapToGlobal(event.pos() - self.mouse_pos))
- return super(MPopup, self).mouseMoveEvent(event)
-
- def show(self):
- if self.property("animatable"):
- self.start_anim()
- self.move(QtGui.QCursor.pos())
- super(MPopup, self).show()
- # NOTES(timmyliang): for chinese input
- self.activateWindow()
diff --git a/dayu_widgets/progress_bar.py b/dayu_widgets/progress_bar.py
deleted file mode 100644
index b33b9675..00000000
--- a/dayu_widgets/progress_bar.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-
-class MProgressBar(QtWidgets.QProgressBar):
- """
- props:
- status: str
-
- """
-
- ErrorStatus = "error"
- NormalStatus = "primary"
- SuccessStatus = "success"
-
- def __init__(self, parent=None):
- super(MProgressBar, self).__init__(parent=parent)
- self.setAlignment(QtCore.Qt.AlignCenter)
- self._status = MProgressBar.NormalStatus
-
- def auto_color(self):
- self.valueChanged.connect(self._update_color)
- return self
-
- @QtCore.Slot(int)
- def _update_color(self, value):
- if value >= self.maximum():
- self.set_dayu_status(MProgressBar.SuccessStatus)
- else:
- self.set_dayu_status(MProgressBar.NormalStatus)
-
- def get_dayu_status(self):
- return self._status
-
- def set_dayu_status(self, value):
- self._status = value
- self.style().polish(self)
-
- dayu_status = QtCore.Property(str, get_dayu_status, set_dayu_status)
-
- def normal(self):
- self.set_dayu_status(MProgressBar.NormalStatus)
- return self
-
- def error(self):
- self.set_dayu_status(MProgressBar.ErrorStatus)
- return self
-
- def success(self):
- self.set_dayu_status(MProgressBar.SuccessStatus)
- return self
-
- # def paintEvent(self, event):
- # pass
-
-
-"""
-MProgressBar {
- font-size: @font_size_small;
- color: @primary_text_color;
- border: 0 solid @border_color;
- background-color: @border_color;
- min-height: 12px;
- max-height: 12px;
- border-radius: 6px;
-}
-
-MProgressBar::chunk {
- min-height: 12px;
- max-height: 12px;
- border-radius: 5px;
-}
-MProgressBar[status=error]::chunk {
- background-color: @error_6;
-}
-MProgressBar[status=success]::chunk {
- background-color: @success_6;
-}
-MProgressBar[status=primary]::chunk {
- background-color: @primary_color;
-}"""
diff --git a/dayu_widgets/progress_circle.py b/dayu_widgets/progress_circle.py
deleted file mode 100644
index 5b07ebb1..00000000
--- a/dayu_widgets/progress_circle.py
+++ /dev/null
@@ -1,157 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""MProgressCircle"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets import utils
-from dayu_widgets.label import MLabel
-
-
-class MProgressCircle(QtWidgets.QProgressBar):
- """
- MProgressCircle: Display the current progress of an operation flow.
- When you need to display the completion percentage of an operation.
-
- Property:
- dayu_width: int
- dayu_color: str
- """
-
- def __init__(self, dashboard=False, parent=None):
- super(MProgressCircle, self).__init__(parent)
- self._main_lay = QtWidgets.QHBoxLayout()
- self._default_label = MLabel().h3()
- self._default_label.setAlignment(QtCore.Qt.AlignCenter)
- self._main_lay.addWidget(self._default_label)
- self.setLayout(self._main_lay)
- self._color = None
- self._width = None
-
- self._start_angle = 90 * 16
- self._max_delta_angle = 360 * 16
- self._height_factor = 1.0
- self._width_factor = 1.0
- if dashboard:
- self._start_angle = 225 * 16
- self._max_delta_angle = 270 * 16
- self._height_factor = (2 + pow(2, 0.5)) / 4 + 0.03
-
- self.set_dayu_width(dayu_theme.progress_circle_default_radius)
- self.set_dayu_color(dayu_theme.primary_color)
-
- def set_widget(self, widget):
- """
- Set a custom widget to show on the circle's inner center
- and replace the default percent label
- :param widget: QWidget
- :return: None
- """
- self.setTextVisible(False)
- if not widget.styleSheet():
- widget.setStyleSheet("background:transparent")
- self._main_lay.addWidget(widget)
-
- def get_dayu_width(self):
- """
- Get current circle fixed width
- :return: int
- """
- return self._width
-
- def set_dayu_width(self, value):
- """
- Set current circle fixed width
- :param value: int
- :return: None
- """
- self._width = value
- self.setFixedSize(
- QtCore.QSize(
- self._width * self._width_factor, self._width * self._height_factor
- )
- )
-
- def get_dayu_color(self):
- """
- Get current circle foreground color
- :return: str
- """
- return self._color
-
- def set_dayu_color(self, value):
- """
- Set current circle's foreground color
- :param value: str
- :return:
- """
- self._color = value
- self.update()
-
- dayu_color = QtCore.Property(str, get_dayu_color, set_dayu_color)
- dayu_width = QtCore.Property(int, get_dayu_width, set_dayu_width)
-
- def paintEvent(self, event):
- """Override QProgressBar's paintEvent."""
- if self.text() != self._default_label.text():
- self._default_label.setText(self.text())
- if self.isTextVisible() != self._default_label.isVisible():
- self._default_label.setVisible(self.isTextVisible())
-
- percent = utils.get_percent(self.value(), self.minimum(), self.maximum())
- total_width = self.get_dayu_width()
- pen_width = int(3 * total_width / 50.0)
- radius = total_width - pen_width - 1
-
- painter = QtGui.QPainter(self)
- painter.setRenderHints(QtGui.QPainter.Antialiasing)
-
- # draw background circle
- pen_background = QtGui.QPen()
- pen_background.setWidth(pen_width)
- pen_background.setColor(QtGui.QColor(dayu_theme.background_selected_color))
- pen_background.setCapStyle(QtCore.Qt.RoundCap)
- painter.setPen(pen_background)
- painter.drawArc(
- pen_width / 2.0 + 1,
- pen_width / 2.0 + 1,
- radius,
- radius,
- self._start_angle,
- -self._max_delta_angle,
- )
-
- # draw foreground circle
- pen_foreground = QtGui.QPen()
- pen_foreground.setWidth(pen_width)
- pen_foreground.setColor(QtGui.QColor(self._color))
- pen_foreground.setCapStyle(QtCore.Qt.RoundCap)
- painter.setPen(pen_foreground)
- painter.drawArc(
- pen_width / 2.0 + 1,
- pen_width / 2.0 + 1,
- radius,
- radius,
- self._start_angle,
- -percent * 0.01 * self._max_delta_angle,
- )
- painter.end()
-
- @classmethod
- def dashboard(cls, parent=None):
- """Create a dashboard style MCircle"""
- return MProgressCircle(dashboard=True, parent=parent)
diff --git a/dayu_widgets/push_button.py b/dayu_widgets/push_button.py
deleted file mode 100644
index 32432018..00000000
--- a/dayu_widgets/push_button.py
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MPushButton.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import cursor_mixin
-from dayu_widgets.mixin import focus_shadow_mixin
-
-
-@cursor_mixin
-@focus_shadow_mixin
-class MPushButton(QtWidgets.QPushButton):
- """
- QPushButton.
-
- Property:
- dayu_size: The size of push button
- dayu_type: The type of push button.
- """
-
- DefaultType = "default"
- PrimaryType = "primary"
- SuccessType = "success"
- WarningType = "warning"
- DangerType = "danger"
-
- def __init__(self, text="", icon=None, parent=None):
- if icon is None:
- super(MPushButton, self).__init__(text=text, parent=parent)
- else:
- super(MPushButton, self).__init__(icon=icon, text=text, parent=parent)
- self._dayu_type = MPushButton.DefaultType
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the push button height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the avatar size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- def get_dayu_type(self):
- """
- Get the push button type.
- :return: string.
- """
- return self._dayu_type
-
- def set_dayu_type(self, value):
- """
- Set the push button type.
- :return: None
- """
- if value in [
- MPushButton.DefaultType,
- MPushButton.PrimaryType,
- MPushButton.SuccessType,
- MPushButton.WarningType,
- MPushButton.DangerType,
- ]:
- self._dayu_type = value
- else:
- raise ValueError(
- "Input argument 'value' should be one of "
- "default/primary/success/warning/danger string."
- )
- self.style().polish(self)
-
- dayu_type = QtCore.Property(str, get_dayu_type, set_dayu_type)
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def primary(self):
- """Set MPushButton to PrimaryType"""
- self.set_dayu_type(MPushButton.PrimaryType)
- return self
-
- def success(self):
- """Set MPushButton to SuccessType"""
- self.set_dayu_type(MPushButton.SuccessType)
- return self
-
- def warning(self):
- """Set MPushButton to WarningType"""
- self.set_dayu_type(MPushButton.WarningType)
- return self
-
- def danger(self):
- """Set MPushButton to DangerType"""
- self.set_dayu_type(MPushButton.DangerType)
- return self
-
- def huge(self):
- """Set MPushButton to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MPushButton to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MPushButton to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MPushButton to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MPushButton to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
diff --git a/dayu_widgets/qt/__init__.py b/dayu_widgets/qt/__init__.py
deleted file mode 100644
index 27e24287..00000000
--- a/dayu_widgets/qt/__init__.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import contextlib
-import signal
-import sys
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-from Qt.QtSvg import QSvgRenderer
-import six
-
-
-class MCacheDict(object):
- _render = QSvgRenderer()
-
- def __init__(self, cls):
- super(MCacheDict, self).__init__()
- self.cls = cls
- self._cache_pix_dict = {}
-
- def _render_svg(self, svg_path, replace_color=None):
- # Import local modules
- from dayu_widgets import dayu_theme
-
- replace_color = replace_color or dayu_theme.icon_color
- if (self.cls is QtGui.QIcon) and (replace_color is None):
- return QtGui.QIcon(svg_path)
- with open(svg_path, "r") as f:
- data_content = f.read()
- if replace_color is not None:
- data_content = data_content.replace("#555555", replace_color)
- self._render.load(QtCore.QByteArray(six.b(data_content)))
- pix = QtGui.QPixmap(128, 128)
- pix.fill(QtCore.Qt.transparent)
- painter = QtGui.QPainter(pix)
- self._render.render(painter)
- painter.end()
- if self.cls is QtGui.QPixmap:
- return pix
- else:
- return self.cls(pix)
-
- def __call__(self, path, color=None):
- # Import local modules
- from dayu_widgets import utils
-
- full_path = utils.get_static_file(path)
- if full_path is None:
- return self.cls()
- key = "{}{}".format(full_path.lower(), color or "")
- pix_map = self._cache_pix_dict.get(key, None)
- if pix_map is None:
- if full_path.endswith("svg"):
- pix_map = self._render_svg(full_path, color)
- else:
- pix_map = self.cls(full_path)
- self._cache_pix_dict.update({key: pix_map})
- return pix_map
-
-
-def get_scale_factor():
- if not QtWidgets.QApplication.instance():
- app = QtWidgets.QApplication([])
- standard_dpi = 96.0
- scale_factor_x = QtWidgets.QApplication.desktop().logicalDpiX() / standard_dpi
- scale_factor_y = QtWidgets.QApplication.desktop().logicalDpiY() / standard_dpi
- return scale_factor_x, scale_factor_y
-
-
-@contextlib.contextmanager
-def application(*args):
- app = QtWidgets.QApplication.instance()
-
- if not app:
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- app = QtWidgets.QApplication(sys.argv)
- yield app
- app.exec_()
- else:
- yield app
-
-
-MPixmap = MCacheDict(QtGui.QPixmap)
-MIcon = MCacheDict(QtGui.QIcon)
diff --git a/dayu_widgets/radio_button.py b/dayu_widgets/radio_button.py
deleted file mode 100644
index fd6c7022..00000000
--- a/dayu_widgets/radio_button.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MRadioButton
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.mixin import cursor_mixin
-
-
-@cursor_mixin
-class MRadioButton(QtWidgets.QRadioButton):
- """
- MRadioButton just use stylesheet and set cursor shape when hover. No more extend.
- """
-
- def __init__(self, text="", parent=None):
- super(MRadioButton, self).__init__(text=text, parent=parent)
diff --git a/dayu_widgets/sequence_file.py b/dayu_widgets/sequence_file.py
deleted file mode 100644
index 82aa68fb..00000000
--- a/dayu_widgets/sequence_file.py
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-from dayu_path import DayuPath
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.check_box import MCheckBox
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.mixin import property_mixin
-
-
-@property_mixin
-class MSequenceFile(QtWidgets.QWidget, MFieldMixin):
- """
- 这个类必须依赖 DayuPath
- props:
- path: six.string_types
- sequence: bool
- """
-
- sig_is_sequence_changed = QtCore.Signal(bool)
-
- def __init__(self, size=None, parent=None):
- super(MSequenceFile, self).__init__(parent)
- self.sequence_obj = None
- size = size or dayu_theme.small
- self._file_label = MLineEdit()
- self._file_label.set_dayu_size(size)
- self._file_label.setReadOnly(True)
- self._is_sequence_check_box = MCheckBox(self.tr("Sequence"))
- self._is_sequence_check_box.toggled.connect(
- functools.partial(self.setProperty, "sequence")
- )
- self._is_sequence_check_box.toggled.connect(self.sig_is_sequence_changed)
-
- self._info_label = MLabel().secondary()
- self._error_label = MLabel().secondary()
- self._error_label.setProperty("error", True)
- self._error_label.setMinimumWidth(100)
- self._error_label.set_elide_mode(QtCore.Qt.ElideMiddle)
-
- seq_lay = QtWidgets.QHBoxLayout()
- seq_lay.addWidget(self._is_sequence_check_box)
- seq_lay.addWidget(self._info_label)
- seq_lay.addWidget(self._error_label)
- seq_lay.setStretchFactor(self._is_sequence_check_box, 0)
- seq_lay.setStretchFactor(self._info_label, 0)
- seq_lay.setStretchFactor(self._error_label, 100)
-
- self._main_lay = QtWidgets.QVBoxLayout()
- self._main_lay.setContentsMargins(0, 0, 0, 0)
- self._main_lay.addWidget(self._file_label)
- self._main_lay.addLayout(seq_lay)
- self.setLayout(self._main_lay)
- self.set_sequence(True)
-
- def _set_path(self, value):
- path = DayuPath(value)
- for seq_obj in path.scan():
- self.sequence_obj = seq_obj
- self._update_info()
-
- def set_path(self, value):
- self.setProperty("path", value)
-
- def set_sequence(self, value):
- assert isinstance(value, bool)
- self.setProperty("sequence", value)
-
- def _set_sequence(self, value):
- if value != self._is_sequence_check_box.isChecked():
- # 更新来自代码
- self._is_sequence_check_box.setChecked(value)
- self.sig_is_sequence_changed.emit(value)
- self._update_info()
-
- def _update_info(self):
- self._file_label.setProperty(
- "text",
- self.sequence_obj if self.property("sequence") else self.property("path"),
- )
- if self.sequence_obj:
- self._info_label.setText(
- "Format: {ext} "
- "Total: {count} "
- "Range: {start}-{end}".format(
- ext=self.sequence_obj.ext,
- count=len(self.sequence_obj.frames),
- start=self.sequence_obj.frames[0]
- if self.sequence_obj.frames
- else "/",
- end=self.sequence_obj.frames[-1]
- if self.sequence_obj.frames
- else "/",
- )
- )
- error_info = (
- "Missing: {}".format(self.sequence_obj.missing)
- if self.sequence_obj.missing
- else ""
- )
- self._error_label.setText(error_info)
- self._error_label.setToolTip(error_info)
- self._info_label.setVisible(self.property("sequence"))
- self._error_label.setVisible(self.property("sequence"))
diff --git a/dayu_widgets/slider.py b/dayu_widgets/slider.py
deleted file mode 100644
index ab632027..00000000
--- a/dayu_widgets/slider.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-"""MSlider"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-
-class MSlider(QtWidgets.QSlider):
- """
- A Slider component for displaying current value and intervals in range.
-
- MSlider just apply qss for QSlider.
- """
-
- def __init__(self, orientation=QtCore.Qt.Horizontal, parent=None):
- super(MSlider, self).__init__(orientation, parent=parent)
- self._show_text_when_move = True
-
- def disable_show_text(self):
- self._show_text_when_move = False
-
- def mouseMoveEvent(self, event):
- """Override the mouseMoveEvent to show current value as a tooltip."""
- if self._show_text_when_move:
- QtWidgets.QToolTip.showText(event.globalPos(), str(self.value()), self)
- return super(MSlider, self).mouseMoveEvent(event)
diff --git a/dayu_widgets/spin_box.py b/dayu_widgets/spin_box.py
deleted file mode 100644
index bd18cc69..00000000
--- a/dayu_widgets/spin_box.py
+++ /dev/null
@@ -1,313 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-Custom Stylesheet for QSpinBox, QDoubleSpinBox, QDateTimeEdit, QDateEdit, QTimeEdit.
-Only add size arg for their __init__.
-"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import cursor_mixin
-
-
-@cursor_mixin
-class MSpinBox(QtWidgets.QSpinBox):
- """
- MSpinBox just use stylesheet and add dayu_size. No more extend.
- Property:
- dayu_size: The height of MSpinBox
- """
-
- def __init__(self, parent=None):
- super(MSpinBox, self).__init__(parent=parent)
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the MSpinBox height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the MSpinBox size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MSpinBox to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MSpinBox to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MSpinBox to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MSpinBox to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MSpinBox to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
-
-
-@cursor_mixin
-class MDoubleSpinBox(QtWidgets.QDoubleSpinBox):
- """
- MDoubleSpinBox just use stylesheet and add dayu_size. No more extend.
- Property:
- dayu_size: The height of MDoubleSpinBox
- """
-
- def __init__(self, parent=None):
- super(MDoubleSpinBox, self).__init__(parent=parent)
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the MDoubleSpinBox height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the MDoubleSpinBox size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MDoubleSpinBox to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MDoubleSpinBox to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MDoubleSpinBox to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MDoubleSpinBox to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MDoubleSpinBox to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
-
-
-@cursor_mixin
-class MDateTimeEdit(QtWidgets.QDateTimeEdit):
- """
- MDateTimeEdit just use stylesheet and add dayu_size. No more extend.
- Property:
- dayu_size: The height of MDateTimeEdit
- """
-
- def __init__(self, datetime=None, parent=None):
- if datetime is None:
- super(MDateTimeEdit, self).__init__(parent=parent)
- else:
- super(MDateTimeEdit, self).__init__(datetime, parent=parent)
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the MDateTimeEdit height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the MDateTimeEdit size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MDateTimeEdit to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MDateTimeEdit to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MDateTimeEdit to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MDateTimeEdit to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MDateTimeEdit to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
-
-
-@cursor_mixin
-class MDateEdit(QtWidgets.QDateEdit):
- """
- MDateEdit just use stylesheet and add dayu_size. No more extend.
- Property:
- dayu_size: The height of MDateEdit
- """
-
- def __init__(self, date=None, parent=None):
- if date is None:
- super(MDateEdit, self).__init__(parent=parent)
- else:
- super(MDateEdit, self).__init__(date, parent=parent)
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the MDateEdit height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the MDateEdit size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MDateEdit to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MDateEdit to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MDateEdit to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MDateEdit to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MDateEdit to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
-
-
-@cursor_mixin
-class MTimeEdit(QtWidgets.QTimeEdit):
- """
- MTimeEdit just use stylesheet and add dayu_size. No more extend.
- Property:
- dayu_size: The height of MTimeEdit
- """
-
- def __init__(self, time=None, parent=None):
- if time is None:
- super(MTimeEdit, self).__init__(parent=parent)
- else:
- super(MTimeEdit, self).__init__(time, parent=parent)
- self._dayu_size = dayu_theme.default_size
-
- def get_dayu_size(self):
- """
- Get the MTimeEdit height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the MTimeEdit size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MTimeEdit to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MTimeEdit to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MTimeEdit to medium"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MTimeEdit to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MTimeEdit to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
diff --git a/dayu_widgets/splitter.py b/dayu_widgets/splitter.py
deleted file mode 100644
index 55ca4b6f..00000000
--- a/dayu_widgets/splitter.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: TimmyLiang
-# Date : 2021.12
-# Email : 820472580@qq.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-from functools import partial
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import property_mixin
-
-
-@property_mixin
-class MSplitter(QtWidgets.QSplitter):
- def __init__(self, Orientation=QtCore.Qt.Horizontal, parent=None):
- super(MSplitter, self).__init__(Orientation, parent=parent)
- self.setHandleWidth(10)
- self.setProperty("animatable", True)
- self.setProperty("default_size", 100)
- self.setProperty("anim_move_duration", 300)
- dayu_theme.apply(self)
-
- def slot_splitter_click(self, index, first=True):
- size_list = self.sizes()
- prev = index - 1
- prev_size = size_list[prev]
- next_size = size_list[index]
- default_size = self.property("default_size")
- if not prev_size:
- size_list[prev] = default_size
- size_list[index] -= default_size
- elif not next_size:
- size_list[index] = default_size
- size_list[prev] -= default_size
- else:
-
- if first:
- size_list[index] += prev_size
- size_list[prev] = 0
- else:
- size_list[prev] += next_size
- size_list[index] = 0
-
- if self.property("animatable"):
- anim = QtCore.QVariantAnimation(self)
-
- def anim_size(index, size_list, v):
- size_list[index - 1] += size_list[index] - v
- size_list[index] = v
- self.setSizes(size_list)
-
- anim.valueChanged.connect(partial(anim_size, index, size_list))
- anim.setDuration(self.property("anim_move_duration"))
- anim.setStartValue(next_size)
- anim.setEndValue(size_list[index])
- anim.start()
- else:
- self.setSizes(size_list)
-
- def createHandle(self):
- count = self.count()
-
- orient = self.orientation()
- is_horizontal = orient is QtCore.Qt.Horizontal
- handle = QtWidgets.QSplitterHandle(orient, self)
-
- # NOTES: double click average size
- handle.mouseDoubleClickEvent = lambda e: self.setSizes(
- [1 for i in range(self.count())]
- )
-
- layout = QtWidgets.QVBoxLayout() if is_horizontal else QtWidgets.QHBoxLayout()
- layout.setContentsMargins(0, 0, 0, 0)
- handle.setLayout(layout)
-
- button = QtWidgets.QToolButton(handle)
- button.setArrowType(QtCore.Qt.LeftArrow if is_horizontal else QtCore.Qt.UpArrow)
- button.clicked.connect(lambda: self.slot_splitter_click(count, True))
- layout.addWidget(button)
- button = QtWidgets.QToolButton(handle)
- arrow = QtCore.Qt.RightArrow if is_horizontal else QtCore.Qt.DownArrow
- button.setArrowType(arrow)
- button.clicked.connect(lambda: self.slot_splitter_click(count, False))
- layout.addWidget(button)
-
- return handle
diff --git a/dayu_widgets/stacked_widget.py b/dayu_widgets/stacked_widget.py
deleted file mode 100644
index 2cfa18a8..00000000
--- a/dayu_widgets/stacked_widget.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.4
-# Email : muyanru345@163.com
-###################################################################
-"""MStackedWidget"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.mixin import stacked_animation_mixin
-
-
-@stacked_animation_mixin
-class MStackedWidget(QtWidgets.QStackedWidget):
- """Just active animation when current index changed."""
-
- def __init__(self, parent=None):
- super(MStackedWidget, self).__init__(parent)
-
- def disable_animation(self):
- self.currentChanged.disconnect(self._play_anim)
diff --git a/dayu_widgets/static/__init__.py b/dayu_widgets/static/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/dayu_widgets/static/add_line.svg b/dayu_widgets/static/add_line.svg
deleted file mode 100644
index a15acfed..00000000
--- a/dayu_widgets/static/add_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/alert_fill.svg b/dayu_widgets/static/alert_fill.svg
deleted file mode 100644
index ebc86de7..00000000
--- a/dayu_widgets/static/alert_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/alert_line.svg b/dayu_widgets/static/alert_line.svg
deleted file mode 100644
index c1c8f760..00000000
--- a/dayu_widgets/static/alert_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/app-houdini.png b/dayu_widgets/static/app-houdini.png
deleted file mode 100644
index e6bc4291..00000000
Binary files a/dayu_widgets/static/app-houdini.png and /dev/null differ
diff --git a/dayu_widgets/static/app-maya.png b/dayu_widgets/static/app-maya.png
deleted file mode 100644
index ba73c2e2..00000000
Binary files a/dayu_widgets/static/app-maya.png and /dev/null differ
diff --git a/dayu_widgets/static/app-nuke.png b/dayu_widgets/static/app-nuke.png
deleted file mode 100644
index 9bcf3094..00000000
Binary files a/dayu_widgets/static/app-nuke.png and /dev/null differ
diff --git a/dayu_widgets/static/attachment_line.svg b/dayu_widgets/static/attachment_line.svg
deleted file mode 100644
index 98811c63..00000000
--- a/dayu_widgets/static/attachment_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/avatar.png b/dayu_widgets/static/avatar.png
deleted file mode 100644
index ff602d17..00000000
Binary files a/dayu_widgets/static/avatar.png and /dev/null differ
diff --git a/dayu_widgets/static/base.json b/dayu_widgets/static/base.json
deleted file mode 100644
index 832079ce..00000000
--- a/dayu_widgets/static/base.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "color": {
- "primary": "#2d8cf0",
- "info": "#2db7f5",
- "success": "#19be6b",
- "warning": "#ff9900",
- "error": "#ed4014",
- "title_color": "rgba(0, 0, 0, 85%)",
- "primary_text_color": "rgba(0, 0, 0, 65%)",
- "secondary_text_color": "rgba(0, 0, 0, 45%)",
- "disable_color": "rgba(0, 0, 0, 45%)",
- "divider_color": "rgba(0, 0, 0, 9%)",
- "background_color": "rgba(0, 0, 0, 4%)",
- "table_header_color": "rgba(0, 0, 0, 2%)",
- "border_radius_base": "4px",
- "border_radius_sm": "2px",
- "text_title": "#17233d",
- "text_content": "#515a6e",
- "text_select": "#fffff0",
- "text_help": "#808695",
- "disabled": "#e0e0e0",
- "border": "#dcdee2",
- "divider": "#e8eaec",
- "background": "#f8f8f9",
- "in_background": "#ffffff",
- "out_background": "#eee",
- "background_dark": "#cccccc",
- "background_light": "#ffffff",
- "background_selected": "#eeeeee",
- "female": "#ef5b97",
- "male": "#4ebbff",
- "icon": "#555555",
- "icon_disabled": "#999"
- },
- "size": {
- "huge": 48,
- "large": 40,
- "medium": 32,
- "small": 24,
- "tiny": 18,
- "huge_icon": 28,
- "large_icon": 24,
- "medium_icon": 20,
- "small_icon": 14,
- "tiny_icon": 10,
- "huge_radius": 6,
- "large_radius": 5,
- "medium_radius": 4,
- "small_radius": 3,
- "tiny_radius": 2,
- "huge_font": 16,
- "large_font": 14,
- "medium_font": 12,
- "small_font": 12,
- "tiny_font": 11
- },
- "font": {
- "family": "BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",\"Helvetica Neue\",Helvetica,Arial,sans-serif",
- "h1": "font-weight:bold;\nfont-size: 18px",
- "h2": "font-weight:bold;\nfont-size: 14px",
- "h3": "font-weight:bold;\nfont-size: 12px",
- "text": "font-size: 12px",
- "help": "font-size: 12px"
- },
- "icon": {
- "down": "down_line.svg",
- "up": "up_line.svg",
- "left": "left_line.svg",
- "right": "right_line.svg",
- "close": "close_line.svg",
- "calender": "calendar_fill.svg",
- "check": "check.svg",
- "minus": "minus.svg",
- "circle": "circle.svg",
- "sphere": "sphere.svg",
- "splitter": "splitter.svg",
- "float": "float.svg"
- }
-}
diff --git a/dayu_widgets/static/big_view.svg b/dayu_widgets/static/big_view.svg
deleted file mode 100644
index 7f880345..00000000
--- a/dayu_widgets/static/big_view.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/bold.svg b/dayu_widgets/static/bold.svg
deleted file mode 100644
index c3a0243a..00000000
--- a/dayu_widgets/static/bold.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/calendar_fill.png b/dayu_widgets/static/calendar_fill.png
deleted file mode 100644
index fe5f0742..00000000
Binary files a/dayu_widgets/static/calendar_fill.png and /dev/null differ
diff --git a/dayu_widgets/static/calendar_fill.svg b/dayu_widgets/static/calendar_fill.svg
deleted file mode 100644
index 9b8fecb7..00000000
--- a/dayu_widgets/static/calendar_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/calendar_fill_dark.png b/dayu_widgets/static/calendar_fill_dark.png
deleted file mode 100644
index a90941f2..00000000
Binary files a/dayu_widgets/static/calendar_fill_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/calendar_fill_dark.svg b/dayu_widgets/static/calendar_fill_dark.svg
deleted file mode 100644
index d59292ac..00000000
--- a/dayu_widgets/static/calendar_fill_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/calendar_line.png b/dayu_widgets/static/calendar_line.png
deleted file mode 100644
index efa08c12..00000000
Binary files a/dayu_widgets/static/calendar_line.png and /dev/null differ
diff --git a/dayu_widgets/static/calendar_line.svg b/dayu_widgets/static/calendar_line.svg
deleted file mode 100644
index 82a57cda..00000000
--- a/dayu_widgets/static/calendar_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/calendar_line_dark.png b/dayu_widgets/static/calendar_line_dark.png
deleted file mode 100644
index e839f934..00000000
Binary files a/dayu_widgets/static/calendar_line_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/calendar_line_dark.svg b/dayu_widgets/static/calendar_line_dark.svg
deleted file mode 100644
index 4c42bef4..00000000
--- a/dayu_widgets/static/calendar_line_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/check.png b/dayu_widgets/static/check.png
deleted file mode 100644
index de2e2d9b..00000000
Binary files a/dayu_widgets/static/check.png and /dev/null differ
diff --git a/dayu_widgets/static/check.svg b/dayu_widgets/static/check.svg
deleted file mode 100644
index cff1ff9d..00000000
--- a/dayu_widgets/static/check.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/circle.png b/dayu_widgets/static/circle.png
deleted file mode 100644
index e662cb9f..00000000
Binary files a/dayu_widgets/static/circle.png and /dev/null differ
diff --git a/dayu_widgets/static/circle.svg b/dayu_widgets/static/circle.svg
deleted file mode 100644
index 5abbe63f..00000000
--- a/dayu_widgets/static/circle.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/close_fill.svg b/dayu_widgets/static/close_fill.svg
deleted file mode 100644
index 6b885279..00000000
--- a/dayu_widgets/static/close_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/close_line.png b/dayu_widgets/static/close_line.png
deleted file mode 100644
index 03d83b31..00000000
Binary files a/dayu_widgets/static/close_line.png and /dev/null differ
diff --git a/dayu_widgets/static/close_line.svg b/dayu_widgets/static/close_line.svg
deleted file mode 100644
index 8851f6e8..00000000
--- a/dayu_widgets/static/close_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/close_line_dark.png b/dayu_widgets/static/close_line_dark.png
deleted file mode 100644
index 5e9066da..00000000
Binary files a/dayu_widgets/static/close_line_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/close_line_dark.svg b/dayu_widgets/static/close_line_dark.svg
deleted file mode 100644
index ae0821e1..00000000
--- a/dayu_widgets/static/close_line_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/cloud_fill.svg b/dayu_widgets/static/cloud_fill.svg
deleted file mode 100644
index 9a21396a..00000000
--- a/dayu_widgets/static/cloud_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/cloud_line.svg b/dayu_widgets/static/cloud_line.svg
deleted file mode 100644
index c2b44a42..00000000
--- a/dayu_widgets/static/cloud_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/confirm_fill.svg b/dayu_widgets/static/confirm_fill.svg
deleted file mode 100644
index 5818c7cf..00000000
--- a/dayu_widgets/static/confirm_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/confirm_line.svg b/dayu_widgets/static/confirm_line.svg
deleted file mode 100644
index 3d44d22e..00000000
--- a/dayu_widgets/static/confirm_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/dark.json b/dayu_widgets/static/dark.json
deleted file mode 100644
index fe25579a..00000000
--- a/dayu_widgets/static/dark.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "include": "base.json",
- "color": {
- "primary": "#f7931e",
- "primary_light": "#fba137",
- "primary_dark": "#d08022",
- "primary_opacity": "#ffd4a1",
- "text_title": "#17233d",
- "text_content": "#c8c8c8",
- "text_select": "#000000",
- "text_help": "#888",
- "sub_color": "#808695",
- "disabled": "#7d7d7d",
- "border": "#1e1e1e",
- "divider": "#e8eaec",
- "background": "#323232",
- "in_background": "#3a3a3a",
- "out_background": "#494949",
- "background_dark": "#262626",
- "background_light": "#525252",
- "background_selected": "#292929",
- "icon": "#a7a7a7",
- "icon_disabled": "#999"
- },
- "icon": {
- "down": "down_line_dark.svg",
- "up": "up_line_dark.svg",
- "left": "left_line_dark.svg",
- "right": "right_line_dark.svg",
- "close": "close_line_dark.svg",
- "calender": "calendar_fill_dark.svg",
- "float": "float_dark.svg",
- "splitter": "splitter_dark.svg"
- }
-}
diff --git a/dayu_widgets/static/detail_line.svg b/dayu_widgets/static/detail_line.svg
deleted file mode 100644
index 5fcb18a1..00000000
--- a/dayu_widgets/static/detail_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/down_fill.svg b/dayu_widgets/static/down_fill.svg
deleted file mode 100644
index d7805f8f..00000000
--- a/dayu_widgets/static/down_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/down_line.png b/dayu_widgets/static/down_line.png
deleted file mode 100644
index a1f13c70..00000000
Binary files a/dayu_widgets/static/down_line.png and /dev/null differ
diff --git a/dayu_widgets/static/down_line.svg b/dayu_widgets/static/down_line.svg
deleted file mode 100644
index 3d7b8f8a..00000000
--- a/dayu_widgets/static/down_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/down_line_dark.png b/dayu_widgets/static/down_line_dark.png
deleted file mode 100644
index 13dfe01f..00000000
Binary files a/dayu_widgets/static/down_line_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/down_line_dark.svg b/dayu_widgets/static/down_line_dark.svg
deleted file mode 100644
index 34a120c1..00000000
--- a/dayu_widgets/static/down_line_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/edit_fill.svg b/dayu_widgets/static/edit_fill.svg
deleted file mode 100644
index f084a7e3..00000000
--- a/dayu_widgets/static/edit_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/edit_line.svg b/dayu_widgets/static/edit_line.svg
deleted file mode 100644
index 7a5bac7b..00000000
--- a/dayu_widgets/static/edit_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/empty.svg b/dayu_widgets/static/empty.svg
deleted file mode 100644
index 2d7fec1d..00000000
--- a/dayu_widgets/static/empty.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/error_fill.svg b/dayu_widgets/static/error_fill.svg
deleted file mode 100644
index 218c3886..00000000
--- a/dayu_widgets/static/error_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/error_line.svg b/dayu_widgets/static/error_line.svg
deleted file mode 100644
index 4fbdcfee..00000000
--- a/dayu_widgets/static/error_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/female.svg b/dayu_widgets/static/female.svg
deleted file mode 100644
index 08e73f4b..00000000
--- a/dayu_widgets/static/female.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/filter_fill.svg b/dayu_widgets/static/filter_fill.svg
deleted file mode 100644
index 5a7b2caa..00000000
--- a/dayu_widgets/static/filter_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/filter_line.svg b/dayu_widgets/static/filter_line.svg
deleted file mode 100644
index 730f3568..00000000
--- a/dayu_widgets/static/filter_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/float.png b/dayu_widgets/static/float.png
deleted file mode 100644
index 7d42e121..00000000
Binary files a/dayu_widgets/static/float.png and /dev/null differ
diff --git a/dayu_widgets/static/float.svg b/dayu_widgets/static/float.svg
deleted file mode 100644
index 54c4f41c..00000000
--- a/dayu_widgets/static/float.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/float_dark.png b/dayu_widgets/static/float_dark.png
deleted file mode 100644
index 61bf85d2..00000000
Binary files a/dayu_widgets/static/float_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/float_dark.svg b/dayu_widgets/static/float_dark.svg
deleted file mode 100644
index 2ff3ddd0..00000000
--- a/dayu_widgets/static/float_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/folder_fill.svg b/dayu_widgets/static/folder_fill.svg
deleted file mode 100644
index 5f5704d6..00000000
--- a/dayu_widgets/static/folder_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/folder_line.svg b/dayu_widgets/static/folder_line.svg
deleted file mode 100644
index 1c4f9e77..00000000
--- a/dayu_widgets/static/folder_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/home_fill.svg b/dayu_widgets/static/home_fill.svg
deleted file mode 100644
index badb4663..00000000
--- a/dayu_widgets/static/home_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/home_line.svg b/dayu_widgets/static/home_line.svg
deleted file mode 100644
index b1398933..00000000
--- a/dayu_widgets/static/home_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/icon-loading.gif b/dayu_widgets/static/icon-loading.gif
deleted file mode 100644
index 8455b23a..00000000
Binary files a/dayu_widgets/static/icon-loading.gif and /dev/null differ
diff --git a/dayu_widgets/static/info_fill.svg b/dayu_widgets/static/info_fill.svg
deleted file mode 100644
index 7e0205e0..00000000
--- a/dayu_widgets/static/info_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/info_line.svg b/dayu_widgets/static/info_line.svg
deleted file mode 100644
index f1218735..00000000
--- a/dayu_widgets/static/info_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/italic.svg b/dayu_widgets/static/italic.svg
deleted file mode 100644
index dedd090b..00000000
--- a/dayu_widgets/static/italic.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/left_fill.svg b/dayu_widgets/static/left_fill.svg
deleted file mode 100644
index cdd61d6b..00000000
--- a/dayu_widgets/static/left_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/left_line.png b/dayu_widgets/static/left_line.png
deleted file mode 100644
index 536e7a30..00000000
Binary files a/dayu_widgets/static/left_line.png and /dev/null differ
diff --git a/dayu_widgets/static/left_line.svg b/dayu_widgets/static/left_line.svg
deleted file mode 100644
index 16a8154b..00000000
--- a/dayu_widgets/static/left_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/left_line_dark.png b/dayu_widgets/static/left_line_dark.png
deleted file mode 100644
index 804a6b24..00000000
Binary files a/dayu_widgets/static/left_line_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/left_line_dark.svg b/dayu_widgets/static/left_line_dark.svg
deleted file mode 100644
index 30cbd7d2..00000000
--- a/dayu_widgets/static/left_line_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/light.json b/dayu_widgets/static/light.json
deleted file mode 100644
index f95f440f..00000000
--- a/dayu_widgets/static/light.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "include": "base.json",
- "color": {
- "primary": "#f75b47",
- "primary_light": "#f96f5e",
- "primary_dark": "#ea4732",
- "primary_opacity": "#e38e83"
- }
-}
diff --git a/dayu_widgets/static/list_view.svg b/dayu_widgets/static/list_view.svg
deleted file mode 100644
index 8da18ce2..00000000
--- a/dayu_widgets/static/list_view.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/loading.svg b/dayu_widgets/static/loading.svg
deleted file mode 100644
index 2e6ffbd5..00000000
--- a/dayu_widgets/static/loading.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/main.qss b/dayu_widgets/static/main.qss
deleted file mode 100644
index 62522dc0..00000000
--- a/dayu_widgets/static/main.qss
+++ /dev/null
@@ -1,1294 +0,0 @@
-/* public*/
-
-*{
- font-family: @font_family;
- color: @primary_text_color;
- background-color: @background_color;
- font-size: @font_size_base@font_unit;
- selection-color: @text_color_inverse;
- selection-background-color: @primary_color;
-}
-MDateTimeEdit::drop-down,
-MDateEdit::drop-down,
-MComboBox::drop-down {
- subcontrol-origin: content;
- subcontrol-position: center right;
- image: url(@icon_down);
-}
-MDateTimeEdit[dayu_size="@huge"]::drop-down,
-MDateEdit[dayu_size="@huge"]::drop-down,
-MComboBox[dayu_size="@huge"]::drop-down{
- width: @huge@unit;
- height: @huge_icon@unit;
-}
-MDateTimeEdit[dayu_size="@large"]::drop-down,
-MDateEdit[dayu_size="@large"]::drop-down,
-MComboBox[dayu_size="@large"]::drop-down{
- width: @large@unit;
- height: @large_icon@unit;
-}
-MDateTimeEdit[dayu_size="@medium"]::drop-down,
-MDateEdit[dayu_size="@medium"]::drop-down,
-MComboBox[dayu_size="@medium"]::drop-down{
- width: @medium@unit;
- height: @medium_icon@unit;
-}
-MDateTimeEdit[dayu_size="@small"]::drop-down,
-MDateEdit[dayu_size="@small"]::drop-down,
-MComboBox[dayu_size="@small"]::drop-down{
- width: @small@unit;
- height: @small_icon@unit;
-}
-MDateTimeEdit[dayu_size="@tiny"]::drop-down,
-MDateEdit[dayu_size="@tiny"]::drop-down,
-MComboBox[dayu_size="@tiny"]::drop-down{
- width: @tiny@unit;
- height: @tiny_icon@unit;
-}
-
-QAbstractButton[dayu_size="@huge"],
-QAbstractSpinBox[dayu_size="@huge"],
-QComboBox[dayu_size="@huge"],
-QLineEdit[dayu_size="@huge"]{
- font-size: @font_size_large@font_unit;
- border-radius: @border_radius_large@unit;
- min-height: @huge@unit;
- max-height: @huge@unit;
-}
-
-QAbstractButton[dayu_size="@large"],
-QAbstractSpinBox[dayu_size="@large"],
-QComboBox[dayu_size="@large"],
-QLineEdit[dayu_size="@large"]{
- font-size: @font_size_large@font_unit;
- border-radius: @border_radius_large@unit;
- min-height: @large@unit;
- max-height: @large@unit;
-}
-
-QAbstractButton[dayu_size="@medium"],
-QAbstractSpinBox[dayu_size="@medium"],
-QComboBox[dayu_size="@medium"],
-QLineEdit[dayu_size="@medium"]{
- font-size: @font_size_base@font_unit;
- border-radius: @border_radius_base@unit;
- min-height: @medium@unit;
- max-height: @medium@unit;
-}
-
-QAbstractButton[dayu_size="@small"],
-QAbstractSpinBox[dayu_size="@small"],
-QComboBox[dayu_size="@small"],
-QLineEdit[dayu_size="@small"]{
- font-size: @font_size_base@font_unit;
- border-radius: @border_radius_base@unit;
- min-height: @small@unit;
- max-height: @small@unit;
-}
-QAbstractButton[dayu_size="@tiny"],
-QAbstractSpinBox[dayu_size="@tiny"],
-QComboBox[dayu_size="@tiny"],
-QLineEdit[dayu_size="@tiny"]{
- font-size: @font_size_small@font_unit;
- border-radius: @border_radius_small@unit;
- min-height: @tiny@unit;
- max-height: @tiny@unit;
-}
-
-
-MComboBox[dayu_size="@huge"]::drop-down{
- height: @drop_down_huge@unit;
-}
-MComboBox[dayu_size="@large"]::drop-down{
- height: @drop_down_large@unit;
-}
-MComboBox[dayu_size="@medium"]::drop-down{
- height: @drop_down_medium@unit;
-}
-MComboBox[dayu_size="@small"]::drop-down{
- height: @drop_down_small@unit;
-}
-MComboBox[dayu_size="@tiny"]::drop-down{
- height: @drop_down_tiny@unit;
-}
-
-/* MCalendarWidget*/
-#qt_calendar_calendarview {
- background: @background_color;
-}
-
-#qt_calendar_navigationbar {
- background: @background_color;
-}
-
-QCalenderWidget > QToolButton {
- icon-size: @drop_down_medium@unit, @drop_down_medium@unit;
- width: @drop_down_large@unit;
- height: @drop_down_large@unit;
- background: @background_out_color;
-}
-
-QToolButton#qt_calendar_prevmonth {
- qproperty-icon: url(@icon_left);
-}
-
-QToolButton#qt_calendar_nextmonth {
- qproperty-icon: url(@icon_right);
-}
-
-QToolButton#qt_calendar_monthbutton {
- padding-right: @drop_down_huge@unit;
-}
-
-QToolButton#qt_calendar_yearbutton {
- padding-right: @drop_down_huge@unit;
-}
-
-QToolButton#qt_calendar_monthbutton::menu-indicator {
- subcontrol-origin: padding;
- subcontrol-position: center right;
- right: 0;
- width: @drop_down_small@unit;
-}
-
-QCalendarWidget QWidget {
- alternate-background-color: @background_out_color;
-}
-
-
-/* QAbstractSpinBox */
-QAbstractSpinBox {
- spacing: 4px;
- border: 1px solid @border_color;
- border-radius: 3px;
- color: @primary_text_color;
- background-color:@background_in_color;
-}
-
-QAbstractSpinBox:focus{
- border: 1px solid @primary_color;
-}
-
-QAbstractSpinBox::up-button {
- subcontrol-origin: border;
- subcontrol-position: top right;
- margin-top: 1px;
- margin-right: 1px;
- border-left: 1px solid @border_color;
- background: @background_out_color;
-}
-
-QAbstractSpinBox::down-button {
- subcontrol-origin: border;
- subcontrol-position: bottom right;
- margin-bottom: 1px;
- margin-right: 1px;
- border-left: 1px solid @border_color;
- border-top: 1px solid @border_color;
- background: @background_out_color;
-}
-
-QAbstractSpinBox::up-button:hover,
-QAbstractSpinBox::down-button:hover {
- border-left: 1px solid @primary_color;
-}
-
-QAbstractSpinBox::up-arrow {
- image: url(@icon_up);
-}
-QAbstractSpinBox::down-arrow {
- image: url(@icon_down);
-}
-QAbstractSpinBox::up-arrow:disabled,
-QAbstractSpinBox::up-arrow:off,
-QAbstractSpinBox::down-arrow:disabled,
-QAbstractSpinBox::down-arrow:off {
- background-color: @disable_color;
-}
-QAbstractSpinBox[dayu_size="@huge"]::up-button{
- width: @spin_box_huge@unit;
- border-top-right-radius: @border_radius_large@unit;
-}
-QAbstractSpinBox[dayu_size="@huge"]::down-button{
- width: @spin_box_huge@unit;
- border-bottom-right-radius: @border_radius_large@unit;
-}
-QAbstractSpinBox[dayu_size="@large"]::up-button{
- width: @spin_box_large@unit;
- border-top-right-radius: @border_radius_large@unit;
-}
-QAbstractSpinBox[dayu_size="@large"]::down-button{
- width: @spin_box_large@unit;
- border-bottom-right-radius: @border_radius_large@unit;
-}
-QAbstractSpinBox[dayu_size="@medium"]::up-button{
- width: @spin_box_medium@unit;
- border-top-right-radius: @border_radius_base@unit;
-}
-QAbstractSpinBox[dayu_size="@medium"]::down-button{
- width: @spin_box_medium@unit;
- border-bottom-right-radius: @border_radius_base@unit;
-}
-QAbstractSpinBox[dayu_size="@small"]::up-button{
- width: @spin_box_small@unit;
- border-top-right-radius: @border_radius_small@unit;
-}
-QAbstractSpinBox[dayu_size="@small"]::down-button{
- width: @spin_box_small@unit;
- border-bottom-right-radius: @border_radius_small@unit;
-}
-QAbstractSpinBox[dayu_size="@tiny"]::up-button{
- width: @spin_box_tiny@unit;
- border-top-right-radius: @border_radius_small@unit;
-}
-QAbstractSpinBox[dayu_size="@tiny"]::down-button{
- width: @spin_box_tiny@unit;
- border-bottom-right-radius: @border_radius_small@unit;
-}
-QAbstractSpinBox[dayu_size="@huge"]::up-arrow,
-QAbstractSpinBox[dayu_size="@huge"]::down-arrow {
- width: @spin_box_icon_huge@unit;
- height: @spin_box_icon_huge@unit;
-}
-QAbstractSpinBox[dayu_size="@large"]::up-arrow,
-QAbstractSpinBox[dayu_size="@large"]::down-arrow {
- width: @spin_box_icon_large@unit;
- height: @spin_box_icon_large@unit;
-}
-QAbstractSpinBox[dayu_size="@medium"]::up-arrow,
-QAbstractSpinBox[dayu_size="@medium"]::down-arrow {
- width: @spin_box_icon_medium@unit;
- height: @spin_box_icon_medium@unit;
-}
-QAbstractSpinBox[dayu_size="@small"]::up-arrow,
-QAbstractSpinBox[dayu_size="@small"]::down-arrow {
- width: @spin_box_icon_small@unit;
- height: @spin_box_icon_small@unit;
-}
-QAbstractSpinBox[dayu_size="@tiny"]::up-arrow,
-QAbstractSpinBox[dayu_size="@tiny"]::down-arrow {
- width: @spin_box_icon_tiny@unit;
- height: @spin_box_icon_tiny@unit;
-}
-MDateTimeEdit::drop-down, MDateEdit::drop-down{
- subcontrol-origin: border;
- subcontrol-position: center right;
- image: url(@icon_calender);
-}
-
-/* MAlert */
-MAlert{
- border: 1px solid @border_color;
- border-radius: @border_radius_base@unit;
-}
-MAlert[dayu_type=info]{
- border-color: @info_3;
- background-color: @info_1;
-}
-MAlert[dayu_type=success]{
- border-color: @success_3;
- background-color: @success_1;
-}
-MAlert[dayu_type=warning]{
- border-color: @warning_3;
- background-color: @warning_1;
-}
-MAlert[dayu_type=error]{
- border-color: @error_3;
- background-color: @error_1;
-}
-
-/* MAvatar*/
-MAvatar{
- background-color: transparent;
-}
-
-/*MBadge*/
-MBadge{
- margin: 0;
-}
-MBadge > QPushButton{
- font-size:9@font_unit;
- min-height:@badge_width@unit;
- max-height:@badge_width@unit;
- min-width:@badge_width@unit;
- border-radius: @badge_width_radius@unit;
- background-color: red;
- border: none;
- color: white;
- font-weight:bold;
- margin: 0;
-}
-
-MBadge[dayu_dot=true] > QPushButton{
- min-height:@badge_dot@unit;
- max-height:@badge_dot@unit;
- min-width:@badge_dot@unit;
- max-width:@badge_dot@unit;
- border-radius: @badge_dot_radius@unit;
- padding: 0 0;
-}
-
-/* MToolButton*/
-MToolButton {
- border: none;
- padding: 0;
- background-color: transparent;
-}
-MToolButton:hover{
- color: @primary_5;
-}
-MToolButton:pressed{
- color: @primary_7;
-}
-MToolButton:disabled{
- background-color: @disable_color;
-}
-
-MTaobaoButton{
- border-radius: 2px;
- border: 1px solid @border_color;
-}
-MTaobaoButton:hover{
- color: @primary_5;
- border: 1px solid @primary_5;
-}
-MTaobaoButton:checked{
- color: @primary_color;
- border: 2px solid @primary_color;
-}
-
-MBlockButton{
- border-radius: 0;
- padding: 2px 10px;
- border:none;
-}
-MBlockButton:hover{
- color: @primary_color;
- background-color:@background_in_color;
-}
-MBlockButton:checked{
- color: @primary_color;
- background-color:@background_in_color;
-}
-
-MUnderlineButton{
- border-radius: 0;
- padding: 6px 10px;
- border-color: transparent;
-}
-MUnderlineButton:hover{
- border-radius: 0;
- color: @primary_5;
- border: none;
-}
-MUnderlineButton:checked{
- border-radius: 0;
- color: @primary_color;
- border-style: solid;
- border-color: @primary_color;
- border-width: 0 0 2px 0;
-}
-
-
-MToolButton[combine=horizontal]{
- border-radius: 0;
-}
-MToolButton[combine=vertical]{
- border-radius: 0;
-}
-
-MToolButton[dayu_size="@huge"], MPushButton[dayu_size="@huge"]{
- qproperty-iconSize: @huge_icon@unit @huge_icon@unit;
-}
-MToolButton[dayu_size="@large"], MPushButton[dayu_size="@large"]{
- qproperty-iconSize: @large_icon@unit @large_icon@unit;
-}
-MToolButton[dayu_size="@medium"], MPushButton[dayu_size="@medium"]{
- qproperty-iconSize: @medium_icon@unit @medium_icon@unit;
-}
-MToolButton[dayu_size="@small"], MPushButton[dayu_size="@small"]{
- qproperty-iconSize: @small_icon@unit @small_icon@unit;
-}
-MToolButton[dayu_size="@tiny"], MPushButton[dayu_size="@tiny"]{
- qproperty-iconSize: @tiny_icon@unit @tiny_icon@unit;
-}
-
-
-MToolButton::menu-indicator {
- subcontrol-origin: border;
- subcontrol-position: bottom right;
- right: 5px;
- bottom: 5px;
- height: 10px;
- width: 10px;
- image: url(@icon_down);
-}
-
-MDragFileButton, MDragFolderButton{
- color: @primary_text_color;
- background-color: @background_color;
- border: @drag_border@unit dashed @border_color;
- border-radius: @drag_border_radius@unit;
- padding: @drag_padding_x@unit @drag_padding_y@unit;
-}
-MDragFileButton:hover, MDragFolderButton:hover{
- color: @primary_color;
- border-color: @primary_5;
-}
-MDragFileButton:pressed, MDragFolderButton:pressed{
- color: @primary_color;
- border-color: @primary_7;
-}
-
-/* MCheckBox */
-MCheckBox {
- spacing: @check_box_spacing@unit;
-}
-MCheckBox:disabled {
- color: @disable_color;
-}
-
-
-MMenu::indicator:non-exclusive,
-MBigView::indicator,
-MListView::indicator,
-MTreeView::indicator,
-MColumnView::indicator,
-MTableView::indicator,
-MCheckBox::indicator{
- width: @check_box_size@unit;
- height: @check_box_size@unit;
- border-radius: 2px;
- border: 1px solid @border_color;
- background-color: @background_in_color;
-}
-MMenu::indicator:non-exclusive:disabled,
-MBigView::indicator:disabled,
-MListView::indicator:disabled,
-MTreeView::indicator:disabled,
-MColumnView::indicator:disabled,
-MTableView::indicator:disabled,
-MCheckBox::indicator:disabled{
- border: 1px solid @border_color;
- background-color: @background_selected_color;
-}
-MMenu::indicator:non-exclusive:hover,
-MBigView::indicator:hover,
-MListView::indicator:hover,
-MTreeView::indicator:hover,
-MColumnView::indicator:hover,
-MTableView::indicator:hover,
-MCheckBox::indicator:hover{
- border: 1px solid @primary_5;
- background-color: @background_in_color;
-}
-MMenu::indicator:non-exclusive:checked,
-MBigView::indicator:checked,
-MListView::indicator:checked,
-MTreeView::indicator:checked,
-MColumnView::indicator:checked,
-MTableView::indicator:checked,
-MCheckBox::indicator:checked{
- background-color: @primary_color;
- image: url(@icon_check);
-}
-MMenu::indicator:non-exclusive:checked:disabled,
-MBigView::indicator:checked:disabled,
-MListView::indicator:checked:disabled,
-MTreeView::indicator:checked:disabled,
-MColumnView::indicator:checked:disabled,
-MTableView::indicator:checked:disabled,
-MCheckBox::indicator:checked:disabled{
- background-color: @disable_color;
-}
-
-MBigView::indicator:indeterminate,
-MListView::indicator:indeterminate,
-MTreeView::indicator:indeterminate,
-MColumnView::indicator:indeterminate,
-MTableView::indicator:indeterminate,
-MCheckBox::indicator:indeterminate {
- background-color: @primary_color;
- image: url(@icon_minus);
-}
-
-MBigView::indicator:indeterminate:disabled,
-MListView::indicator:indeterminate:disabled,
-MTreeView::indicator:indeterminate:disabled,
-MColumnView::indicator:indeterminate:disabled,
-MTableView::indicator:indeterminate:disabled,
-MCheckBox::indicator:indeterminate:disabled {
- background-color: @disable_color;
-}
-
-
-/* MPushButton */
-MPushButton {
- font-weight: 400;
- border-radius: 5%;
- padding: 1% 10%;
-}
-
-MPushButton[dayu_type=default]{
- background-color: @background_out_color;
- border: 1px solid @border_color;
-}
-MPushButton[dayu_type=default]:hover{
- /*color: @primary_5;*/
- border-color: @primary_5;
-}
-MPushButton[dayu_type=default]:pressed{
- /*color: @primary_7;*/
- border-color: @primary_7;
-}
-
-
-MPushButton[dayu_type=primary]{
- border: none;
- color: @text_color_inverse;
- background-color: @primary_color;
-}
-MPushButton[dayu_type=primary]:hover{
- background-color: @primary_5;
-}
-MPushButton[dayu_type=primary]:pressed{
- background-color: @primary_7;
-}
-
-
-MPushButton[dayu_type=success]{
- border: none;
- color: @text_color_inverse;
- background-color: @success_6;
-}
-MPushButton[dayu_type=success]:hover{
- background-color: @success_5;
-}
-MPushButton[dayu_type=success]:pressed{
- background-color: @success_7;
-}
-
-
-MPushButton[dayu_type=warning]{
- border: none;
- color: @text_color_inverse;
- background-color: @warning_6;
-}
-MPushButton[dayu_type=warning]:hover{
- background-color: @warning_5;
-}
-MPushButton[dayu_type=warning]:pressed{
- background-color: @warning_7;
-}
-
-
-MPushButton[dayu_type=danger]{
- border: none;
- color: white;
- background-color: @error_6;
-}
-MPushButton[dayu_type=danger]:hover{
- background-color: @error_5;
-}
-MPushButton[dayu_type=danger]:pressed{
- background-color: @error_7;
-}
-
-MPushButton[combine=horizontal][position=left],
-MComboBox[combine=horizontal][position=left]{
- margin-left: 1px;
- border-left: none;
- border-bottom-right-radius: 0;
- border-top-right-radius: 0;
-}
-
-MPushButton[combine=horizontal][position=right],
-MComboBox[combine=horizontal][position=right]{
- border-right: none;
- border-bottom-left-radius: 0;
- border-top-left-radius: 0;
-}
-MPushButton[combine=horizontal][position=center],
-MComboBox[combine=horizontal][position=center]{
- /*border: none;*/
- border-radius: 0;
-}
-MPushButton[combine=vertical][position=top],
-MComboBox[combine=vertical][position=top]{
- border-top: none;
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
-}
-MPushButton[combine=vertical][position=bottom],
-MComboBox[combine=vertical][position=bottom]{
- border-bottom: none;
- border-top-left-radius: 0;
- border-top-right-radius: 0;
-}
-
-MPushButton:disabled{
- color: @disable_color;
- border: 2px dashed @disable_color;
- background-color: @background_color;
-}
-
-MPushButton::menu-indicator {
- subcontrol-origin: border;
- subcontrol-position: bottom right;
- right: 5px;
- bottom: 5px;
- height: 10px;
- width: 10px;
- image: url(@icon_down);
-}
-
-/*MRadioButton*/
-MRadioButton {
- spacing: @radio_spacing@unit;
-}
-MRadioButton:disabled {
- color: @disable_color;
-}
-
-MMenu::indicator:exclusive,
-MRadioButton::indicator{
- width: @radio_size@unit;
- height: @radio_size@unit;
- border-radius: @radio_radius@unit;
- border: 1px solid @border_color;
- background-color: @background_in_color;
-}
-MMenu::indicator:exclusive:disabled,
-MRadioButton::indicator:disabled{
- border: 1px solid @border_color;
- background-color: @background_selected_color;
-}
-
-MMenu::indicator:exclusive:hover,
-MRadioButton::indicator:hover{
- border: 1px solid @primary_5;
-}
-MMenu::indicator:exclusive:checked,
-MRadioButton::indicator:checked{
- background-color: @primary_color;
- image: url(@icon_circle);
-}
-MMenu::indicator:exclusive:checked:disabled,
-MRadioButton::indicator:checked:disabled{
- background-color: @disable_color;
-}
-
-
-/*MSwitch*/
-MSwitch{
- spacing: -20px;
-}
-MSwitch::indicator{
- subcontrol-origin: border;
- subcontrol-position: center left;
- image: url(@icon_sphere);
-}
-MSwitch[dayu_size="@huge"]::indicator{
- width: @switch_width_huge@unit;
- height: @switch_height_huge@unit;
- border-radius: @switch_radius_huge@unit;
-}
-MSwitch[dayu_size="@large"]::indicator{
- width: @switch_width_large@unit;
- height: @switch_height_large@unit;
- border-radius: @switch_radius_large@unit;
-}
-MSwitch[dayu_size="@medium"]::indicator{
- width: @switch_width_medium@unit;
- height: @switch_height_medium@unit;
- border-radius: @switch_radius_medium@unit;
-}
-MSwitch[dayu_size="@small"]::indicator{
- width: @switch_width_small@unit;
- height: @switch_height_small@unit;
- border-radius: @switch_radius_small@unit;
-}
-MSwitch[dayu_size="@tiny"]::indicator{
- width: @switch_width_tiny@unit;
- height: @switch_height_tiny@unit;
- border-radius: @switch_radius_tiny@unit;
-}
-MSwitch::indicator:checked{
- image-position: center right;
- background-color: @primary_color;
-}
-MSwitch::indicator:unchecked{
- image-position: center left;
- background-color: @background_selected_color;
-}
-MSwitch::indicator:disabled{
- background-color: @disable_color;
-}
-
-MComboBox{
- border: 1px solid @border_color;
- background-color: @background_in_color;
-}
-QCombBox > QLineEdit{
- background-color: red;
-}
-
-MComboBox:focus{
- border: 1px solid @primary_5;
-}
-MComboBox:hover{
- border: 1px solid @primary_7;
-}
-MComboBox:disabled{
- color: @disable_color;
-}
-/* MLabel */
-MLabel{
- padding: 2px;
- background-color: transparent;
- font-size: @font_size_base@font_unit;
- color: @primary_text_color;
- font-weight: 400;
-}
-MLabel[dayu_level="1"]{
- font-size: @h1_size@font_unit;
- font-weight: 500;
- color: @title_color;
-}
-MLabel[dayu_level="2"]{
- font-size: @h2_size@font_unit;
- font-weight: 500;
- color: @title_color;
-}
-MLabel[dayu_level="3"]{
- font-size: @h3_size@font_unit;
- font-weight: 500;
- color: @title_color;
-}
-MLabel[dayu_level="4"]{
- font-size: @h4_size@font_unit;
- font-weight: 500;
- color: @title_color;
-}
-
-
-MLabel[dayu_underline=true]{
- text-decoration: underline;
-}
-MLabel[dayu_delete=true]{
- text-decoration: line-through;
-}
-MLabel[dayu_strong=true]{
- font-weight: bold;
-}
-MLabel[dayu_code=true]{
- background-color: @background_out_color;
- border: 1px solid @border_color;
-}
-MLabel[dayu_mark=true]{
- background-color: @warning_1;
-}
-
-MLabel[dayu_type=danger]{
- color: @error_6;
-}
-MLabel[dayu_type=warning]{
- color: @warning_6;
-}
-MLabel[dayu_type=secondary]{
- color: @secondary_text_color;
-}
-
-MLabel:disabled{
- color:@disable_color;
-}
-
-MMessage,
-MDrawer{
- padding: 2px;
- border: 1px solid @border_color;
- border-radius: 2px;
- background-color: @background_color;
-}
-
-
-MToast{
- background-color: @toast_color;
-}
-
-MToast QLabel{
- color: @text_color_inverse;
- background-color: transparent;
-}
-
-MSectionItem{
- border: 1px solid @border_color;
- border-radius: 2px;
- background-color: @background_color;
-}
-QWidget#title {
- background-color: @background_out_color;
-}
-MTextEdit {
- border-radius: @border_radius_base@unit;
-}
-MLineEdit,
-MTextEdit{
- border: 1px solid @border_color;
- background-color: @background_in_color;
-}
-
-MLineEdit:focus,
-MTextEdit:focus{
- border: 1px solid @primary_color;
-}
-
-MLineEdit[dayu_type=error]{
- color: @error_5;
-}
-MLineEdit[dayu_type=error]:focus{
- border: 1px solid @error_5;
-}
-MLineEdit:disabled{
- color: @disable_color;
-}
-
-MTabWidget::pane { /* The tab widget frame */
- border: 1px solid @border_color;
- border-radius: 3px;
- top: -1px;
- background-color: @background_color;
-}
-MTabWidget::tab-bar {
- padding: 5px;
-}
- /* Style the tab using the tab sub-control. Note that
- it reads QTabBar _not_ QTabWidget */
-MTabBar::tab {
- border: 1px solid @border_color;
- border-bottom: none;
- border-top-left-radius: 6px;
- border-top-right-radius: 6px;
- background-color: @background_in_color;
-}
-
-QTabBar::tab:selected{
- background: #323232;
- border-bottom: none;
- color: @primary_color;
- background-color: @background_color;
-}
-QTabBar::tab:!selected {
- margin-top: 2px;
- border-bottom: 1px solid @border_color;
-}
-
-MTabBar::tab:hover {
- color: @primary_color;
-}
-MTabBar::close-button {
- subcontrol-origin: content;
- subcontrol-position: right center;
- margin-right: 5px;
- image: url(@icon_close);
-}
-MTabBar::close-button:hover {
- border: 1px solid @primary_color;
-}
-
-MTabBar QToolButton {
- border: 1px solid @border_color;
-}
-MTabBar QToolButton:hover {
- border: 1px solid @primary_5;
-}
-MTabBar QToolButton:disabled {
- background-color: @disable_color;
-}
-MTabBar QToolButton::right-arrow {
- image: url(@icon_right);
-}
-
-MTabBar QToolButton::left-arrow {
- image: url(@icon_left);
-}
-
-/* MHeaderView */
-MHeaderView {
- background-color: @background_out_color;
- color: @title_color;
-}
-MHeaderView::section{
- background-color: @background_out_color;
- border: 0 solid @border_color;
- padding: 1px 6px;
-}
-
-
-MHeaderView[grid=true][orientation=horizontal]::section{
- border-right: 1px solid @border_color;
- border-left: none;
- border-top: none;
- border-bottom: none;
-}
-
-
-MHeaderView[grid=true][orientation=vertical]::section{
- border-bottom: 1px solid @border_color;
- border-right: none;
- border-left: none;
- border-top: none;
-}
-
-MHeaderView::section:hover {
- color: @primary_color;
-}
-
-MHeaderView::up-arrow {
- width: 8px;
- height: 8px;
- position: relative;
- top: -10px;
- right: 50%;
- image: url(@icon_up);
-}
-
-MHeaderView::down-arrow {
- width: 8px;
- height: 8px;
- position: relative;
- top: -10px;
- right: 50%;
- image: url(@icon_down);
-}
-MListView[dayu_size="@huge"]::item{
- min-height: @huge@unit;
- max-height: @huge@unit;
-}
-MListView[dayu_size="@large"]::item{
- min-height: @large@unit;
- max-height: @large@unit;
-}
-MListView[dayu_size="@medium"]::item{
- min-height: @medium@unit;
- max-height: @medium@unit;
-}
-MListView[dayu_size="@small"]::item{
- min-height: @small@unit;
- max-height: @small@unit;
-}
-
-MBigView,
-MListView,
-MTreeView,
-MColumnView,
-MTableView{
- background-color: @background_in_color;
- alternate-background-color: @background_color;
- selection-background-color: rgba(45, 140, 240, 50);
- selection-color:#1e1e1e;
- border: 1px solid @border_color;
- padding: 0;
- gridline-color: @border_color;
-}
-
-MBigView::item:hover,
-MListView::item:hover,
-MTreeView::item:hover,
-MColumnView::item:hover,
-MTableView::item:hover{
- color: @text_color_inverse;
- background-color: @primary_5;
-}
-
-MBigView::item:selected,
-MListView::item:selected,
-MTreeView::item:selected,
-MColumnView::item:selected,
-MTableView::item:selected{
- background-color: @primary_color;
-}
-
-MTableView QTableCornerButton::section {
- background-color: @background_out_color;
- border: 0px solid @border_color;
- border-right: 1px solid @border_color;
- border-bottom: 1px solid @border_color;
- padding: 1px 6px;
-}
-
-QScrollBar:horizontal {
- border: 0 solid @border_color;
- height: 9px;
- margin: 0 32px 0 0;
- background-color: @border_color;
-}
-
-QScrollBar::handle:horizontal {
- background-color: @background_selected_color;
- min-width: 10px;
-}
-
-QScrollBar::add-line:horizontal {
- subcontrol-origin: margin;
- subcontrol-position: right center;
- background: @border_color;
- width: 15px;
-}
-
-QScrollBar::sub-line:horizontal {
- subcontrol-origin: margin;
- subcontrol-position: right center;
- background: @border_color;
- width: 15px;
- right: 16px;
-}
-
-QScrollBar::left-arrow:horizontal {
- width: 9px;
- height: 9px;
- position: relative;
- image: url(@icon_left);
-}
-
-QScrollBar::right-arrow:horizontal {
- width: 9px;
- height: 9px;
- position: relative;
- image: url(@icon_right);
-}
-
-QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
- background: none;
-}
-
-QScrollBar:vertical {
- border: 0 solid @border_color;
- width: 9px;
- margin: 0 0 32px 0 ;
- background-color: @border_color;
-}
-
-QScrollBar::handle:vertical {
- background-color: @background_selected_color;
- min-height: 10px;
-}
-
-QScrollBar::add-line:vertical {
- subcontrol-origin: margin;
- subcontrol-position: center bottom;
- background: @border_color;
- height: 15px;
-}
-
-QScrollBar::sub-line:vertical {
- subcontrol-origin: margin;
- subcontrol-position: center bottom;
- background: @border_color;
- height: 15px;
- bottom: 16px;
-}
-
-QScrollBar::up-arrow:vertical {
- width: 9px;
- height: 9px;
- position: relative;
- image: url(@icon_up)
-}
-
-QScrollBar::down-arrow:vertical {
- width: 9px;
- height: 9px;
- position: relative;
- image: url(@icon_down)
-}
-
-QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
- background: none;
-}
-
-QSplitter::handle {
- background-color: @border_color;
- image: url(@icon_splitter)
-}
-
-QSplitter::handle:horizontal {
- width: 2px;
-}
-
-QSplitter::handle:vertical {
- height: 2px;
-}
-MMenuTabWidget QWidget#bar_widget{
- background: @background_out_color;
- spacing: 3px;
- border-radius: 0;
-}
-MMenuTabWidget[dayu_size="@huge"] QWidget#bar_widget{
- height: @huge@unit;
-}
-MMenuTabWidget[dayu_size="@large"] QWidget#bar_widget{
- height: @large@unit;
-}
-MSlider::groove:horizontal {
- border-radius: @slider_radius@unit;
- height: @slider_height@unit;
-}
-
-MSlider::handle {
- background: @background_in_color;
- border: 2px solid @primary_color;
- width: @slider_handle_size@unit;
- height: @slider_handle_size@unit;
- border-radius: @slider_handle_radius@unit;
-}
-MSlider::handle:disabled{
- border-color: @disable_color;
-}
-
-MSlider::handle:horizontal {
- margin: -@slider_height@unit 0;
-}
-MSlider::groove:vertical {
- border-radius: @slider_radius@unit;
- width: @slider_height@unit;
-}
-
-MSlider::handle:vertical {
- margin: 0 -@slider_height@unit;
-}
-
-MSlider::add-page:horizontal {
- background: @border_color;
-}
-
-MSlider::sub-page:horizontal {
- background: @primary_color;
-}
-MSlider::sub-page:disabled{
- background: @disable_color;
-}
-MSlider::add-page:vertical {
- background: @primary_color;
-}
-
-MSlider::sub-page:vertical {
- background: @border_color;
-}
-MDockWidget {
- font-size: @h3_size@font_unit;
- font-weight: 500;
- color: @title_color;
- titlebar-close-icon: url(@icon_close);
- titlebar-normal-icon: url(@icon_float);
-
-}
-MDockWidget::title {
- background: @background_selected_color;
- text-align: left;
- padding-left: 10px;
-}
-
-MDockWidget::close-button {
- subcontrol-origin: margin;
- subcontrol-position: right center;
- right: 8px;
-}
-
-MDockWidget::float-button {
- subcontrol-origin: margin;
- subcontrol-position: right center;
- right: 30px;
-}
-MDockWidget::close-button:hover, MDockWidget::float-button:hover {
- border: 1px solid @primary_color;
-}
-
-MProgressBar {
- font-size: @font_size_base@font_unit;
- color: @primary_text_color;
- border: 0 solid @border_color;
- background-color: @border_color;
- min-height: @progress_bar_size@unit;
- max-height: @progress_bar_size@unit;
- border-radius: @progress_bar_radius@unit;
-}
-
-MProgressBar::chunk {
- min-height: @progress_bar_size@unit;
- max-height: @progress_bar_size@unit;
- border-radius: @progress_bar_radius@unit;
-}
-MProgressBar[dayu_status=error]::chunk {
- background-color: @error_6;
-}
-MProgressBar[dayu_status=success]::chunk {
- background-color: @success_6;
-}
-MProgressBar[dayu_status=primary]::chunk {
- background-color: @primary_color;
-}
-
-MMenu {
- background-color: @background_color;
- padding: 0;
- border-radius: 2px;
- border: 1px solid @border_color;
-}
-MMenu[checked=true]{
- color: @primary_color;
- background-color: @background_out_color;
-}
-MMenu::item {
- padding: 2px 2px;
-}
-MMenu::item {
- padding: 8px auto;
-}
-MMenu::item:checked {
- color: @primary_color;
- background-color: @background_out_color;
-}
-MMenu::item:selected {
- background-color: @background_out_color;
-}
-
-MMenu::indicator {
- left: 6px;
-}
-
-QToolTip {
- border: none;
- background-color: @background_selected_color;
-}
-
-MLoading {
- background-color: transparent;
-}
-
-MLoadingWrapper #mask{
- background-color: @mask_color;
-}
-
-
-MCard[border=true]{
- border: 1px solid @border_color;
- border-radius: @border_radius_small@unit;
-}
-MCard[border=false]{
- border: 0 solid @border_color;
- border-radius: @border_radius_small@unit;
- background-color: @background_in_color;
-}
-
-MMeta {
- border: 1px solid @border_color;
- border-radius: @border_radius_small@unit;
- background-color: @background_in_color;
-}
-
-MSizeGrip {
- background-color: transparent;
- image: url(@icon_size_grip);
-}
diff --git a/dayu_widgets/static/male.svg b/dayu_widgets/static/male.svg
deleted file mode 100644
index 5f0fbe1e..00000000
--- a/dayu_widgets/static/male.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/media_fill.svg b/dayu_widgets/static/media_fill.svg
deleted file mode 100644
index 35f96540..00000000
--- a/dayu_widgets/static/media_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/media_line.svg b/dayu_widgets/static/media_line.svg
deleted file mode 100644
index 0d5adaf0..00000000
--- a/dayu_widgets/static/media_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/minus.png b/dayu_widgets/static/minus.png
deleted file mode 100644
index 2e66af12..00000000
Binary files a/dayu_widgets/static/minus.png and /dev/null differ
diff --git a/dayu_widgets/static/minus.svg b/dayu_widgets/static/minus.svg
deleted file mode 100644
index 0dafdac8..00000000
--- a/dayu_widgets/static/minus.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/minus_line.svg b/dayu_widgets/static/minus_line.svg
deleted file mode 100644
index fd42cc9c..00000000
--- a/dayu_widgets/static/minus_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/more.svg b/dayu_widgets/static/more.svg
deleted file mode 100644
index 1782c4bb..00000000
--- a/dayu_widgets/static/more.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/refresh_line.svg b/dayu_widgets/static/refresh_line.svg
deleted file mode 100644
index a1922093..00000000
--- a/dayu_widgets/static/refresh_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/right_fill.svg b/dayu_widgets/static/right_fill.svg
deleted file mode 100644
index a76c96a6..00000000
--- a/dayu_widgets/static/right_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/right_line.png b/dayu_widgets/static/right_line.png
deleted file mode 100644
index 15c375cd..00000000
Binary files a/dayu_widgets/static/right_line.png and /dev/null differ
diff --git a/dayu_widgets/static/right_line.svg b/dayu_widgets/static/right_line.svg
deleted file mode 100644
index 98810a58..00000000
--- a/dayu_widgets/static/right_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/right_line_dark.png b/dayu_widgets/static/right_line_dark.png
deleted file mode 100644
index bf9f0a18..00000000
Binary files a/dayu_widgets/static/right_line_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/right_line_dark.svg b/dayu_widgets/static/right_line_dark.svg
deleted file mode 100644
index fa0a7e2b..00000000
--- a/dayu_widgets/static/right_line_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/save_fill.svg b/dayu_widgets/static/save_fill.svg
deleted file mode 100644
index a14cc167..00000000
--- a/dayu_widgets/static/save_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/save_line.svg b/dayu_widgets/static/save_line.svg
deleted file mode 100644
index 180c6e83..00000000
--- a/dayu_widgets/static/save_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/search_line.svg b/dayu_widgets/static/search_line.svg
deleted file mode 100644
index 85a8e37a..00000000
--- a/dayu_widgets/static/search_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/size_grip.png b/dayu_widgets/static/size_grip.png
deleted file mode 100644
index 65f91b5d..00000000
Binary files a/dayu_widgets/static/size_grip.png and /dev/null differ
diff --git a/dayu_widgets/static/size_grip.svg b/dayu_widgets/static/size_grip.svg
deleted file mode 100644
index 4c43b290..00000000
--- a/dayu_widgets/static/size_grip.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/size_grip_dark.png b/dayu_widgets/static/size_grip_dark.png
deleted file mode 100644
index 8ddebd24..00000000
Binary files a/dayu_widgets/static/size_grip_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/size_grip_dark.svg b/dayu_widgets/static/size_grip_dark.svg
deleted file mode 100644
index 13444f32..00000000
--- a/dayu_widgets/static/size_grip_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/sphere.png b/dayu_widgets/static/sphere.png
deleted file mode 100644
index 43c36d2c..00000000
Binary files a/dayu_widgets/static/sphere.png and /dev/null differ
diff --git a/dayu_widgets/static/sphere.svg b/dayu_widgets/static/sphere.svg
deleted file mode 100644
index 01540302..00000000
--- a/dayu_widgets/static/sphere.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/spliter.svg b/dayu_widgets/static/spliter.svg
deleted file mode 100644
index b4b21e38..00000000
--- a/dayu_widgets/static/spliter.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
diff --git a/dayu_widgets/static/splitter.png b/dayu_widgets/static/splitter.png
deleted file mode 100644
index 9dd6680c..00000000
Binary files a/dayu_widgets/static/splitter.png and /dev/null differ
diff --git a/dayu_widgets/static/splitter.svg b/dayu_widgets/static/splitter.svg
deleted file mode 100644
index 62e050e7..00000000
--- a/dayu_widgets/static/splitter.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/splitter_dark.png b/dayu_widgets/static/splitter_dark.png
deleted file mode 100644
index 428e54f7..00000000
Binary files a/dayu_widgets/static/splitter_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/splitter_dark.svg b/dayu_widgets/static/splitter_dark.svg
deleted file mode 100644
index 91d6a8e3..00000000
--- a/dayu_widgets/static/splitter_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/success_fill.svg b/dayu_widgets/static/success_fill.svg
deleted file mode 100644
index 8bd2683b..00000000
--- a/dayu_widgets/static/success_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/success_line.svg b/dayu_widgets/static/success_line.svg
deleted file mode 100644
index b1e2bc2c..00000000
--- a/dayu_widgets/static/success_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/table_view.svg b/dayu_widgets/static/table_view.svg
deleted file mode 100644
index c0649a41..00000000
--- a/dayu_widgets/static/table_view.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/trash_fill.svg b/dayu_widgets/static/trash_fill.svg
deleted file mode 100644
index 4e853e35..00000000
--- a/dayu_widgets/static/trash_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/trash_line.svg b/dayu_widgets/static/trash_line.svg
deleted file mode 100644
index 23becc06..00000000
--- a/dayu_widgets/static/trash_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/tree_view.svg b/dayu_widgets/static/tree_view.svg
deleted file mode 100644
index ed910b29..00000000
--- a/dayu_widgets/static/tree_view.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/underline.svg b/dayu_widgets/static/underline.svg
deleted file mode 100644
index d8d2ef53..00000000
--- a/dayu_widgets/static/underline.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/up_fill.svg b/dayu_widgets/static/up_fill.svg
deleted file mode 100644
index cd32bbfc..00000000
--- a/dayu_widgets/static/up_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/up_line.png b/dayu_widgets/static/up_line.png
deleted file mode 100644
index 51020aff..00000000
Binary files a/dayu_widgets/static/up_line.png and /dev/null differ
diff --git a/dayu_widgets/static/up_line.svg b/dayu_widgets/static/up_line.svg
deleted file mode 100644
index 40c17860..00000000
--- a/dayu_widgets/static/up_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/up_line_dark.png b/dayu_widgets/static/up_line_dark.png
deleted file mode 100644
index 4d930ec7..00000000
Binary files a/dayu_widgets/static/up_line_dark.png and /dev/null differ
diff --git a/dayu_widgets/static/up_line_dark.svg b/dayu_widgets/static/up_line_dark.svg
deleted file mode 100644
index 7113e856..00000000
--- a/dayu_widgets/static/up_line_dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/upload_line.svg b/dayu_widgets/static/upload_line.svg
deleted file mode 100644
index 42c99e0f..00000000
--- a/dayu_widgets/static/upload_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/user_fill.svg b/dayu_widgets/static/user_fill.svg
deleted file mode 100644
index 8ad2c8d3..00000000
--- a/dayu_widgets/static/user_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/user_line.svg b/dayu_widgets/static/user_line.svg
deleted file mode 100644
index 2f1c0338..00000000
--- a/dayu_widgets/static/user_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/vline.png b/dayu_widgets/static/vline.png
deleted file mode 100644
index 8f0c336f..00000000
Binary files a/dayu_widgets/static/vline.png and /dev/null differ
diff --git a/dayu_widgets/static/warning_fill.svg b/dayu_widgets/static/warning_fill.svg
deleted file mode 100644
index b75cd80b..00000000
--- a/dayu_widgets/static/warning_fill.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/static/warning_line.svg b/dayu_widgets/static/warning_line.svg
deleted file mode 100644
index be250c03..00000000
--- a/dayu_widgets/static/warning_line.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/dayu_widgets/switch.py b/dayu_widgets/switch.py
deleted file mode 100644
index b56cf8c6..00000000
--- a/dayu_widgets/switch.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MSwitch
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import cursor_mixin
-
-
-@cursor_mixin
-class MSwitch(QtWidgets.QRadioButton):
- """
- Switching Selector.
-
- Property:
- dayu_size: the size of switch widget. int
- """
-
- def __init__(self, parent=None):
- super(MSwitch, self).__init__(parent)
- self._dayu_size = dayu_theme.default_size
- self.setAutoExclusive(False)
-
- def minimumSizeHint(self):
- """
- Override the QRadioButton minimum size hint. We don't need the text space.
- :return:
- """
- height = self._dayu_size * 1.2
- return QtCore.QSize(height, height / 2)
-
- def get_dayu_size(self):
- """
- Get the switch size.
- :return: int
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the switch size.
- :param value: int
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MSwitch to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MSwitch to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MSwitch to medium size"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MSwitch to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MSwitch to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
diff --git a/dayu_widgets/tab_widget.py b/dayu_widgets/tab_widget.py
deleted file mode 100644
index 52e5086f..00000000
--- a/dayu_widgets/tab_widget.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.mixin import cursor_mixin
-from dayu_widgets.mixin import stacked_animation_mixin
-
-
-@cursor_mixin
-class MTabBar(QtWidgets.QTabBar):
- def __init__(self, parent=None):
- super(MTabBar, self).__init__(parent=parent)
- self.setDrawBase(False)
-
- def tabSizeHint(self, index):
- tab_text = self.tabText(index)
- if self.tabsClosable():
- return QtCore.QSize(
- self.fontMetrics().width(tab_text) + 70,
- self.fontMetrics().height() + 20,
- )
- else:
- return QtCore.QSize(
- self.fontMetrics().width(tab_text) + 50,
- self.fontMetrics().height() + 20,
- )
-
-
-@stacked_animation_mixin
-class MTabWidget(QtWidgets.QTabWidget):
- def __init__(self, parent=None):
- super(MTabWidget, self).__init__(parent=parent)
- self.bar = MTabBar()
- self.setTabBar(self.bar)
-
- def disable_animation(self):
- self.currentChanged.disconnect(self._play_anim)
diff --git a/dayu_widgets/text_edit.py b/dayu_widgets/text_edit.py
deleted file mode 100644
index 437804e4..00000000
--- a/dayu_widgets/text_edit.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.6
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-
-class MSizeGrip(QtWidgets.QSizeGrip):
- def __init__(self, parent=None):
- super(MSizeGrip, self).__init__(parent)
-
-
-class MTextEdit(QtWidgets.QTextEdit):
- def __init__(self, parent=None):
- super(MTextEdit, self).__init__(parent)
- self.setWindowFlags(QtCore.Qt.SubWindow)
- self._size_grip = MSizeGrip(self)
- layout = QtWidgets.QGridLayout()
- layout.setContentsMargins(0, 0, 0, 0)
- layout.addWidget(
- self._size_grip, 0, 0, QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight
- )
- self.setLayout(layout)
- self._size_grip.setVisible(False)
-
- def autosize(self):
- self.textChanged.connect(self._autosize_text_edit)
- return self
-
- def _autosize_text_edit(self):
- # w = self.width()
- doc = self.document()
- print(self.width(), doc.lineCount(), doc.idealWidth())
-
- def resizeable(self):
- """Show the size grip on bottom right. User can use it to resize MTextEdit"""
- self._size_grip.setVisible(True)
- return self
diff --git a/dayu_widgets/theme.py b/dayu_widgets/theme.py
deleted file mode 100644
index dadf8b8b..00000000
--- a/dayu_widgets/theme.py
+++ /dev/null
@@ -1,328 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import string
-
-# Import local modules
-from dayu_widgets import DEFAULT_STATIC_FOLDER
-from dayu_widgets import utils
-from dayu_widgets.qt import get_scale_factor
-
-
-def get_theme_size():
- scale_factor_x, scale_factor_y = get_scale_factor()
- return {
- "border_radius_large": int(6 * scale_factor_x),
- "border_radius_base": int(4 * scale_factor_x),
- "border_radius_small": int(2 * scale_factor_x),
- "huge": int(48 * scale_factor_x),
- "large": int(40 * scale_factor_x),
- "medium": int(32 * scale_factor_x),
- "small": int(24 * scale_factor_x),
- "tiny": int(18 * scale_factor_x),
- "huge_icon": int((48 - 20) * scale_factor_x),
- "large_icon": int((40 - 16) * scale_factor_x),
- "medium_icon": int((32 - 12) * scale_factor_x),
- "small_icon": int((24 - 10) * scale_factor_x),
- "tiny_icon": int((18 - 8) * scale_factor_x),
- "default_size": int(32 * scale_factor_x),
- "badge_width_radius": int(8 * scale_factor_x),
- "badge_width": int(16 * scale_factor_x),
- "badge_dot": int(8 * scale_factor_x),
- "badge_dot_radius": int(4 * scale_factor_x),
- "drop_down_huge": int(20 * scale_factor_x),
- "drop_down_large": int(16 * scale_factor_x),
- "drop_down_medium": int(14 * scale_factor_x),
- "drop_down_small": int(10 * scale_factor_x),
- "drop_down_tiny": int(8 * scale_factor_x),
- "spin_box_huge": int(28 * scale_factor_x),
- "spin_box_large": int(26 * scale_factor_x),
- "spin_box_medium": int(24 * scale_factor_x),
- "spin_box_small": int(20 * scale_factor_x),
- "spin_box_tiny": int(18 * scale_factor_x),
- "spin_box_icon_huge": int(14 * scale_factor_x),
- "spin_box_icon_large": int(12 * scale_factor_x),
- "spin_box_icon_medium": int(10 * scale_factor_x),
- "spin_box_icon_small": int(8 * scale_factor_x),
- "spin_box_icon_tiny": int(6 * scale_factor_x),
- "drag_border": int(2 * scale_factor_x),
- "drag_border_radius": int(10 * scale_factor_x),
- "drag_padding_x": int(20 * scale_factor_x),
- "drag_padding_y": int(40 * scale_factor_x),
- "drag_size": int(60 * scale_factor_x),
- "switch_width_huge": int(58 * scale_factor_x),
- "switch_height_huge": int(30 * scale_factor_x),
- "switch_radius_huge": int(15 * scale_factor_x),
- "switch_width_large": int(48 * scale_factor_x),
- "switch_height_large": int(24 * scale_factor_x),
- "switch_radius_large": int(12 * scale_factor_x),
- "switch_width_medium": int(38 * scale_factor_x),
- "switch_height_medium": int(19 * scale_factor_x),
- "switch_radius_medium": int(9 * scale_factor_x),
- "switch_width_small": int(28 * scale_factor_x),
- "switch_height_small": int(14 * scale_factor_x),
- "switch_radius_small": int(7 * scale_factor_x),
- "switch_width_tiny": int(18 * scale_factor_x),
- "switch_height_tiny": int(10 * scale_factor_x),
- "switch_radius_tiny": int(5 * scale_factor_x),
- "check_box_size": int(13 * scale_factor_x),
- "check_box_spacing": int(4 * scale_factor_x),
- "radio_size": int(14 * scale_factor_x),
- "radio_radius": int(14 * scale_factor_x) / 2.0,
- "radio_spacing": int(4 * scale_factor_x),
- "slider_height": int(4 * scale_factor_x),
- "slider_radius": int(3 * scale_factor_x),
- "slider_handle_size": int(8 * scale_factor_x),
- "slider_handle_radius": int(8 * scale_factor_x) / 1.5,
- "progress_circle_default_radius": int(120 * scale_factor_x),
- "progress_bar_size": int(12 * scale_factor_x),
- "progress_bar_radius": int(12 * scale_factor_x) / 2.0,
- "toast_size": int(120 * scale_factor_x),
- "toast_icon_size": int(60 * scale_factor_x),
- "big_view_default_size": int(120 * scale_factor_x),
- "big_view_max_size": int(400 * scale_factor_x),
- "big_view_min_size": int(24 * scale_factor_x),
- }
-
-
-class QssTemplate(string.Template):
- delimiter = "@"
- idpattern = r"[_a-z][_a-z0-9]*"
-
-
-class MTheme(object):
- blue = "#1890ff"
- purple = "#722ed1"
- cyan = "#13c2c2"
- green = "#52c41a"
- magenta = "#eb2f96"
- pink = "#ef5b97"
- red = "#f5222d"
- orange = "#fa8c16"
- yellow = "#fadb14"
- volcano = "#fa541c"
- geekblue = "#2f54eb"
- lime = "#a0d911"
- gold = "#faad14"
- female_color = "#ef5b97"
- male_color = "#4ebbff"
-
- def __init__(self, theme="light", primary_color=None):
- super(MTheme, self).__init__()
- default_qss_file = utils.get_static_file("main.qss")
- with open(default_qss_file, "r") as f:
- self.default_qss = QssTemplate(f.read())
- self.primary_color, self.item_hover_bg = (None, None)
- (
- self.primary_1,
- self.primary_2,
- self.primary_3,
- self.primary_4,
- self.primary_5,
- self.primary_6,
- self.primary_7,
- self.primary_8,
- self.primary_9,
- self.primary_10,
- ) = (None,) * 10
- self.hyperlink_style = ""
- self._init_color()
- self.set_primary_color(primary_color or MTheme.blue)
- self.set_theme(theme)
- self._init_font()
- # self._init_size()
- self.unit = "px"
- self.font_unit = "pt"
-
- self.text_error_color = self.error_7
- self.text_color_inverse = "#fff"
- self.text_warning_color = self.warning_7
-
- def set_theme(self, theme):
- if theme == "light":
- self._light()
- else:
- self._dark()
- self._init_icon(theme)
-
- def set_primary_color(self, color):
- self.primary_color = color
- self.primary_1 = utils.generate_color(color, 1)
- self.primary_2 = utils.generate_color(color, 2)
- self.primary_3 = utils.generate_color(color, 3)
- self.primary_4 = utils.generate_color(color, 4)
- self.primary_5 = utils.generate_color(color, 5)
- self.primary_6 = utils.generate_color(color, 6)
- self.primary_7 = utils.generate_color(color, 7)
- self.primary_8 = utils.generate_color(color, 8)
- self.primary_9 = utils.generate_color(color, 9)
- self.primary_10 = utils.generate_color(color, 10)
- # item
- self.item_hover_bg = self.primary_1
- # rich text hyperlink style
- self.hyperlink_style = """
- """.format(
- self.primary_color
- )
-
- def _init_icon(self, theme):
- # icon
- pre_str = DEFAULT_STATIC_FOLDER.replace("\\", "/")
- suf_str = "" if theme == "light" else "_dark"
- url_prefix = "{pre}/{{}}{suf}.png".format(pre=pre_str, suf=suf_str)
- url_prefix_2 = "{pre}/{{}}.svg".format(pre=pre_str)
- self.icon_down = url_prefix.format("down_line")
- self.icon_up = url_prefix.format("up_line")
- self.icon_left = url_prefix.format("left_line")
- self.icon_right = url_prefix.format("right_line")
- self.icon_close = url_prefix.format("close_line")
- self.icon_calender = url_prefix.format("calendar_fill")
- self.icon_splitter = url_prefix.format("splitter")
- self.icon_float = url_prefix.format("float")
- self.icon_size_grip = url_prefix.format("size_grip")
-
- self.icon_check = url_prefix_2.format("check")
- self.icon_minus = url_prefix_2.format("minus")
- self.icon_circle = url_prefix_2.format("circle")
- self.icon_sphere = url_prefix_2.format("sphere")
-
- def _init_color(self):
- self.info_color = self.blue
- self.success_color = self.green
- self.processing_color = self.blue
- self.error_color = self.red
- self.warning_color = self.gold
-
- self.info_1 = utils.fade_color(self.info_color, "15%")
- self.info_2 = utils.generate_color(self.info_color, 2)
- self.info_3 = utils.fade_color(self.info_color, "35%")
- self.info_4 = utils.generate_color(self.info_color, 4)
- self.info_5 = utils.generate_color(self.info_color, 5)
- self.info_6 = utils.generate_color(self.info_color, 6)
- self.info_7 = utils.generate_color(self.info_color, 7)
- self.info_8 = utils.generate_color(self.info_color, 8)
- self.info_9 = utils.generate_color(self.info_color, 9)
- self.info_10 = utils.generate_color(self.info_color, 10)
-
- self.success_1 = utils.fade_color(self.success_color, "15%")
- self.success_2 = utils.generate_color(self.success_color, 2)
- self.success_3 = utils.fade_color(self.success_color, "35%")
- self.success_4 = utils.generate_color(self.success_color, 4)
- self.success_5 = utils.generate_color(self.success_color, 5)
- self.success_6 = utils.generate_color(self.success_color, 6)
- self.success_7 = utils.generate_color(self.success_color, 7)
- self.success_8 = utils.generate_color(self.success_color, 8)
- self.success_9 = utils.generate_color(self.success_color, 9)
- self.success_10 = utils.generate_color(self.success_color, 10)
-
- self.warning_1 = utils.fade_color(self.warning_color, "15%")
- self.warning_2 = utils.generate_color(self.warning_color, 2)
- self.warning_3 = utils.fade_color(self.warning_color, "35%")
- self.warning_4 = utils.generate_color(self.warning_color, 4)
- self.warning_5 = utils.generate_color(self.warning_color, 5)
- self.warning_6 = utils.generate_color(self.warning_color, 6)
- self.warning_7 = utils.generate_color(self.warning_color, 7)
- self.warning_8 = utils.generate_color(self.warning_color, 8)
- self.warning_9 = utils.generate_color(self.warning_color, 9)
- self.warning_10 = utils.generate_color(self.warning_color, 10)
-
- self.error_1 = utils.fade_color(self.error_color, "15%")
- self.error_2 = utils.generate_color(self.error_color, 2)
- self.error_3 = utils.fade_color(self.error_color, "35%")
- self.error_4 = utils.generate_color(self.error_color, 4)
- self.error_5 = utils.generate_color(self.error_color, 5)
- self.error_6 = utils.generate_color(self.error_color, 6)
- self.error_7 = utils.generate_color(self.error_color, 7)
- self.error_8 = utils.generate_color(self.error_color, 8)
- self.error_9 = utils.generate_color(self.error_color, 9)
- self.error_10 = utils.generate_color(self.error_color, 10)
-
- def _init_font(self):
- # font
- self.font_family = (
- 'BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",'
- '"Helvetica Neue",Helvetica,Arial,sans-serif'
- )
- self.font_size_base = 9
- self.font_size_large = self.font_size_base + 2
- self.font_size_small = self.font_size_base - 2
- self.h1_size = int(self.font_size_base * 2.71)
- self.h2_size = int(self.font_size_base * 2.12)
- self.h3_size = int(self.font_size_base * 1.71)
- self.h4_size = int(self.font_size_base * 1.41)
-
- def __getattribute__(self, item):
- try:
- return object.__getattribute__(self, item)
- except AttributeError:
- return get_theme_size().get(item, 0)
-
- def _dark(self):
- self.title_color = "#ffffff"
- self.primary_text_color = "#d9d9d9"
- self.secondary_text_color = "#a6a6a6"
- self.disable_color = "#737373"
- self.border_color = "#1e1e1e"
- self.divider_color = "#262626"
- self.header_color = "#0a0a0a"
- self.icon_color = "#a6a6a6"
-
- self.background_color = "#323232"
- self.background_selected_color = "#292929"
- self.background_in_color = "#3a3a3a"
- self.background_out_color = "#494949"
- self.mask_color = utils.fade_color(self.background_color, "90%")
- self.toast_color = "#555555"
-
- def _light(self):
- self.title_color = "#262626"
- self.primary_text_color = "#595959"
- self.secondary_text_color = "#8c8c8c"
- self.disable_color = "#e5e5e5"
- self.border_color = "#d9d9d9"
- self.divider_color = "#e8e8e8"
- self.header_color = "#fafafa"
- self.icon_color = "#8c8c8c"
-
- self.background_color = "#f8f8f9"
- self.background_selected_color = "#bfbfbf"
- self.background_in_color = "#ffffff"
- self.background_out_color = "#eeeeee"
- self.mask_color = utils.fade_color(self.background_color, "90%")
- self.toast_color = "#333333"
-
- def apply(self, widget):
- size_dict = get_theme_size()
- size_dict.update(vars(self))
- widget.setStyleSheet(self.default_qss.substitute(size_dict))
-
- def deco(self, cls):
- original_init__ = cls.__init__
-
- def my__init__(instance, *args, **kwargs):
- original_init__(instance, *args, **kwargs)
- size_dict = get_theme_size()
- size_dict.update(vars(self))
- instance.setStyleSheet(self.default_qss.substitute(size_dict))
-
- def polish(instance):
- instance.style().polish(instance)
-
- setattr(cls, "__init__", my__init__)
- setattr(cls, "polish", polish)
- return cls
diff --git a/dayu_widgets/toast.py b/dayu_widgets/toast.py
deleted file mode 100644
index 121c62e8..00000000
--- a/dayu_widgets/toast.py
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-MToast
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.label import MLabel
-from dayu_widgets.loading import MLoading
-from dayu_widgets.qt import MPixmap
-
-
-class MToast(QtWidgets.QWidget):
- """
- MToast
- A Phone style message.
- """
-
- InfoType = "info"
- SuccessType = "success"
- WarningType = "warning"
- ErrorType = "error"
- LoadingType = "loading"
-
- default_config = {
- "duration": 2,
- }
-
- sig_closed = QtCore.Signal()
-
- def __init__(self, text, duration=None, dayu_type=None, parent=None):
- super(MToast, self).__init__(parent)
- self.setWindowFlags(
- QtCore.Qt.FramelessWindowHint
- | QtCore.Qt.Dialog
- | QtCore.Qt.WA_TranslucentBackground
- | QtCore.Qt.WA_DeleteOnClose
- )
- self.setAttribute(QtCore.Qt.WA_StyledBackground)
-
- _icon_lay = QtWidgets.QHBoxLayout()
- _icon_lay.addStretch()
-
- if dayu_type == MToast.LoadingType:
- _icon_lay.addWidget(
- MLoading(size=dayu_theme.huge, color=dayu_theme.text_color_inverse)
- )
- else:
- _icon_label = MAvatar()
- _icon_label.set_dayu_size(dayu_theme.toast_icon_size)
- _icon_label.set_dayu_image(
- MPixmap(
- "{}_line.svg".format(dayu_type or MToast.InfoType),
- dayu_theme.text_color_inverse,
- )
- )
- _icon_lay.addWidget(_icon_label)
- _icon_lay.addStretch()
-
- _content_label = MLabel()
- _content_label.setText(text)
- _content_label.setAlignment(QtCore.Qt.AlignCenter)
-
- _main_lay = QtWidgets.QVBoxLayout()
- _main_lay.setContentsMargins(0, 0, 0, 0)
- _main_lay.addStretch()
- _main_lay.addLayout(_icon_lay)
- _main_lay.addSpacing(10)
- _main_lay.addWidget(_content_label)
- _main_lay.addStretch()
- self.setLayout(_main_lay)
- self.setFixedSize(QtCore.QSize(dayu_theme.toast_size, dayu_theme.toast_size))
-
- _close_timer = QtCore.QTimer(self)
- _close_timer.setSingleShot(True)
- _close_timer.timeout.connect(self.close)
- _close_timer.timeout.connect(self.sig_closed)
- _close_timer.setInterval(
- (duration or self.default_config.get("duration")) * 1000
- )
- self.has_played = False
-
- if dayu_type != MToast.LoadingType:
- _close_timer.start()
-
- self._opacity_ani = QtCore.QPropertyAnimation()
- self._opacity_ani.setTargetObject(self)
- self._opacity_ani.setDuration(300)
- self._opacity_ani.setEasingCurve(QtCore.QEasingCurve.OutCubic)
- self._opacity_ani.setPropertyName(b"windowOpacity")
- self._opacity_ani.setStartValue(0.0)
- self._opacity_ani.setEndValue(0.9)
-
- self._get_center_position(parent)
- self._fade_int()
-
- def closeEvent(self, event):
- if self.has_played:
- event.accept()
- else:
- self._fade_out()
- event.ignore()
-
- def _fade_out(self):
- self.has_played = True
- self._opacity_ani.setDirection(QtCore.QAbstractAnimation.Backward)
- self._opacity_ani.finished.connect(self.close)
- self._opacity_ani.start()
-
- def _fade_int(self):
- self._opacity_ani.start()
-
- def _get_center_position(self, parent):
- parent_geo = parent.geometry()
- pos = (
- parent_geo.topLeft()
- if parent.parent() is None
- else parent.mapToGlobal(parent_geo.topLeft())
- )
- offset = 0
- for child in parent.children():
- if isinstance(child, MToast) and child.isVisible():
- offset = max(offset, child.y())
- target_x = pos.x() + parent_geo.width() / 2 - self.width() / 2
- target_y = pos.y() + parent_geo.height() / 2 - self.height() / 2
- self.setProperty("pos", QtCore.QPoint(target_x, target_y))
-
- @classmethod
- def info(cls, text, parent, duration=None):
- """Show a normal toast message"""
- inst = cls(text, duration=duration, dayu_type=MToast.InfoType, parent=parent)
- inst.show()
- return inst
-
- @classmethod
- def success(cls, text, parent, duration=None):
- """Show a success toast message"""
- inst = cls(text, duration=duration, dayu_type=MToast.SuccessType, parent=parent)
- inst.show()
- return inst
-
- @classmethod
- def warning(cls, text, parent, duration=None):
- """Show a warning toast message"""
- inst = cls(text, duration=duration, dayu_type=MToast.WarningType, parent=parent)
- inst.show()
- return inst
-
- @classmethod
- def error(cls, text, parent, duration=None):
- """Show an error toast message"""
- inst = cls(text, duration=duration, dayu_type=MToast.ErrorType, parent=parent)
- inst.show()
- return inst
-
- @classmethod
- def loading(cls, text, parent):
- """Show a toast message with loading animation.
- You should close this widget by yourself."""
- inst = cls(text, dayu_type=MToast.LoadingType, parent=parent)
- inst.show()
- return inst
-
- @classmethod
- def config(cls, duration):
- """
- Config the global MToast duration setting.
- :param duration: int (unit is second)
- :return: None
- """
- if duration is not None:
- cls.default_config["duration"] = duration
diff --git a/dayu_widgets/tool_button.py b/dayu_widgets/tool_button.py
deleted file mode 100644
index c6552df6..00000000
--- a/dayu_widgets/tool_button.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""MToolButton"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.mixin import cursor_mixin
-from dayu_widgets.qt import MIcon
-
-
-@cursor_mixin
-class MToolButton(QtWidgets.QToolButton):
- """MToolButton"""
-
- def __init__(self, parent=None):
- super(MToolButton, self).__init__(parent=parent)
- self._dayu_svg = None
- self.setAutoExclusive(False)
- self.setAutoRaise(True)
-
- self._polish_icon()
- self.toggled.connect(self._polish_icon)
- self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
-
- self._dayu_size = dayu_theme.default_size
-
- @QtCore.Slot(bool)
- def _polish_icon(self, checked=None):
- if self._dayu_svg:
- if self.isCheckable() and self.isChecked():
- self.setIcon(MIcon(self._dayu_svg, dayu_theme.primary_color))
- else:
- self.setIcon(MIcon(self._dayu_svg))
-
- def enterEvent(self, event):
- """Override enter event to highlight the icon"""
- if self._dayu_svg:
- self.setIcon(MIcon(self._dayu_svg, dayu_theme.primary_color))
- return super(MToolButton, self).enterEvent(event)
-
- def leaveEvent(self, event):
- """Override leave event to recover the icon"""
- self._polish_icon()
- return super(MToolButton, self).leaveEvent(event)
-
- def get_dayu_size(self):
- """
- Get the tool button height
- :return: integer
- """
- return self._dayu_size
-
- def set_dayu_size(self, value):
- """
- Set the tool button size.
- :param value: integer
- :return: None
- """
- self._dayu_size = value
- self.style().polish(self)
- if self.toolButtonStyle() == QtCore.Qt.ToolButtonIconOnly:
- self.setFixedSize(QtCore.QSize(self._dayu_size, self._dayu_size))
- self.setIconSize(QtCore.QSize(self._dayu_size, self._dayu_size))
-
- def get_dayu_svg(self):
- """Get current svg path"""
- return self._dayu_svg
-
- def set_dayu_svg(self, path):
- """Set current svg path"""
- self._dayu_svg = path
- self._polish_icon()
-
- dayu_size = QtCore.Property(int, get_dayu_size, set_dayu_size)
-
- def huge(self):
- """Set MToolButton to huge size"""
- self.set_dayu_size(dayu_theme.huge)
- return self
-
- def large(self):
- """Set MToolButton to large size"""
- self.set_dayu_size(dayu_theme.large)
- return self
-
- def medium(self):
- """Set MToolButton to medium size"""
- self.set_dayu_size(dayu_theme.medium)
- return self
-
- def small(self):
- """Set MToolButton to small size"""
- self.set_dayu_size(dayu_theme.small)
- return self
-
- def tiny(self):
- """Set MToolButton to tiny size"""
- self.set_dayu_size(dayu_theme.tiny)
- return self
-
- def svg(self, path):
- """Set current svg path"""
- self.set_dayu_svg(path)
- return self
-
- def icon_only(self):
- """Set tool button style to icon only"""
- self.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
- self.setFixedSize(QtCore.QSize(self._dayu_size, self._dayu_size))
- return self
-
- def text_only(self):
- """Set tool button style to text only"""
- self.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
- return self
-
- def text_beside_icon(self):
- """Set tool button style to text beside icon"""
- self.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
- return self
-
- def text_under_icon(self):
- """Set tool button style to text under icon"""
- self.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
- return self
diff --git a/dayu_widgets/utils.py b/dayu_widgets/utils.py
deleted file mode 100644
index 0134e584..00000000
--- a/dayu_widgets/utils.py
+++ /dev/null
@@ -1,596 +0,0 @@
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2018.5
-# Email : muyanru345@163.com
-###################################################################
-"""
-Some helper functions for handling color and formatter.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import collections
-import datetime as dt
-import functools
-import math
-import os
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtGui
-from Qt import QtWidgets
-import six
-
-
-if hasattr(functools, "singledispatch"):
- # Import built-in modules
- from functools import singledispatch
-else:
- from singledispatch import singledispatch
-
-# Import local modules
-from dayu_widgets import CUSTOM_STATIC_FOLDERS
-from dayu_widgets import DEFAULT_STATIC_FOLDER
-from dayu_widgets.qt import MIcon
-from dayu_widgets.qt import get_scale_factor
-
-
-ItemViewMenuEvent = collections.namedtuple(
- "ItemViewMenuEvent", ["view", "selection", "extra"]
-)
-
-
-def get_static_file(path):
- """
- A convenient function to get the file in dayu_widgets/static,
- User just give the name of the file.
- eg. get_static_file('add_line.svg')
- :param path: file name
- :return: if input file found, return the full path, else return None
- """
- if not isinstance(path, six.string_types):
- raise TypeError(
- "Input argument 'path' should be six.string_types type, "
- "but get {}".format(type(path))
- )
- full_path = next(
- (
- os.path.join(prefix, path)
- for prefix in ["", DEFAULT_STATIC_FOLDER] + CUSTOM_STATIC_FOLDERS
- if os.path.isfile(os.path.join(prefix, path))
- ),
- path,
- )
- if os.path.isfile(full_path):
- return full_path
- return None
-
-
-def from_list_to_nested_dict(input_arg, sep="/"):
- """
- A help function to convert the list of string to nested dict
- :param input_arg: a list/tuple/set of string
- :param sep: a separator to split input string
- :return: a list of nested dict
- """
- if not isinstance(input_arg, (list, tuple, set)):
- raise TypeError(
- "Input argument 'input' should be list or tuple or set, "
- "but get {}".format(type(input_arg))
- )
- if not isinstance(sep, six.string_types):
- raise TypeError(
- "Input argument 'sep' should be six.string_types, "
- "but get {}".format(type(sep))
- )
-
- result = []
- for item in input_arg:
- components = item.strip(sep).split(sep)
- component_count = len(components)
- current = result
- for i, comp in enumerate(components):
- atom = next((x for x in current if x["value"] == comp), None)
- if atom is None:
- atom = {"value": comp, "label": comp, "children": []}
- current.append(atom)
- current = atom["children"]
- if i == component_count - 1:
- atom.pop("children")
- return result
-
-
-def fade_color(color, alpha):
- """
- Fade color with given alpha.
- eg. fade_color('#ff0000', '10%) => 'rgba(255, 0, 0, 10%)'
- :param color: string, hex digit format '#RRGGBB'
- :param alpha: string, percent 'number%'
- :return: qss/css color format rgba(r, g, b, a)
- """
- q_color = QtGui.QColor(color)
- return "rgba({}, {}, {}, {})".format(
- q_color.red(), q_color.green(), q_color.blue(), alpha
- )
-
-
-def generate_color(primary_color, index):
- """
- Reference to ant-design color system algorithm.
- :param primary_color: base color. #RRGGBB
- :param index: color step. 1-10 from light to dark
- :return: result color
- """
- # 这里生成颜色的算法,来自 Ant Design, 只做了语言的转换,和颜色的类型的转换,没对算法做任何修改
- # https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less
- # https://zhuanlan.zhihu.com/p/32422584
-
- hue_step = 2
- saturation_step = 16
- saturation_step2 = 5
- brightness_step1 = 5
- brightness_step2 = 15
- light_color_count = 5
- dark_color_count = 4
-
- def _get_hue(color, i, is_light):
- h_comp = color.hue()
- if 60 <= h_comp <= 240:
- hue = h_comp - hue_step * i if is_light else h_comp + hue_step * i
- else:
- hue = h_comp + hue_step * i if is_light else h_comp - hue_step * i
- if hue < 0:
- hue += 359
- elif hue >= 359:
- hue -= 359
- return hue / 359.0
-
- def _get_saturation(color, i, is_light):
- s_comp = color.saturationF() * 100
- if is_light:
- saturation = s_comp - saturation_step * i
- elif i == dark_color_count:
- saturation = s_comp + saturation_step
- else:
- saturation = s_comp + saturation_step2 * i
- saturation = min(100.0, saturation)
- if is_light and i == light_color_count and saturation > 10:
- saturation = 10
- saturation = max(6.0, saturation)
- return round(saturation * 10) / 1000.0
-
- def _get_value(color, i, is_light):
- v_comp = color.valueF()
- if is_light:
- return min((v_comp * 100 + brightness_step1 * i) / 100, 1.0)
- return max((v_comp * 100 - brightness_step2 * i) / 100, 0.0)
-
- light = index <= 6
- hsv_color = (
- QtGui.QColor(primary_color)
- if isinstance(primary_color, six.string_types)
- else primary_color
- )
- index = light_color_count + 1 - index if light else index - light_color_count - 1
- return QtGui.QColor.fromHsvF(
- _get_hue(hsv_color, index, light),
- _get_saturation(hsv_color, index, light),
- _get_value(hsv_color, index, light),
- ).name()
-
-
-@singledispatch
-def real_model(source_model):
- """
- Get the source model whenever user give a source index or proxy index or proxy model.
- """
- return source_model
-
-
-@real_model.register(QtCore.QSortFilterProxyModel)
-def _(proxy_model):
- return proxy_model.sourceModel()
-
-
-@real_model.register(QtCore.QModelIndex)
-def _(index):
- return real_model(index.model())
-
-
-def real_index(index):
- """
- Get the source index whenever user give a source index or proxy index.
- """
- model = index.model()
- if isinstance(model, QtCore.QSortFilterProxyModel):
- return model.mapToSource(index)
- return index
-
-
-def get_obj_value(data_obj, attr, default=None):
- """Get dict's key or object's attribute with given attr"""
- if isinstance(data_obj, dict):
- return data_obj.get(attr, default)
- return getattr(data_obj, attr, default)
-
-
-def set_obj_value(data_obj, attr, value):
- """Set dict's key or object's attribute with given attr and value"""
- if isinstance(data_obj, dict):
- return data_obj.update({attr: value})
- return setattr(data_obj, attr, value)
-
-
-def has_obj_value(data_obj, attr):
- """Return weather dict has the given key or object has the given attribute."""
- if isinstance(data_obj, dict):
- return attr in data_obj.keys()
- return hasattr(data_obj, attr)
-
-
-def apply_formatter(formatter, *args, **kwargs):
- """
- Used for QAbstractModel data method.
- Config a formatter for one field, apply the formatter with the index data.
- :param formatter: formatter. It can be None/dict/callable or just any type of value
- :param args:
- :param kwargs:
- :return: apply the formatter with args and kwargs
- """
- if formatter is None: # 压根就没有配置
- return args[0]
- elif isinstance(formatter, dict): # 字典选项型配置
- return formatter.get(args[0], None)
- elif callable(formatter): # 回调函数型配置
- return formatter(*args, **kwargs)
- # 直接值型配置
- return formatter
-
-
-@singledispatch
-def display_formatter(input_other_type):
- """
- Used for QAbstractItemModel data method for Qt.DisplayRole
- Format any input value to a string.
- :param input_other_type: any type value
- :return: six.string_types
- """
- return str(input_other_type) # this function never reached
-
-
-@display_formatter.register(dict)
-def _(input_dict):
- if "name" in input_dict.keys():
- return display_formatter(input_dict.get("name"))
- elif "code" in input_dict.keys():
- return display_formatter(input_dict.get("code"))
- return str(input_dict)
-
-
-@display_formatter.register(list)
-def _(input_list):
- result = []
- for i in input_list:
- result.append(str(display_formatter(i)))
- return ",".join(result)
-
-
-@display_formatter.register(str)
-def _(input_str):
- # ['utf-8', 'windows-1250', 'windows-1252', 'ISO-8859-1']
- return input_str.decode("windows-1252")
- # return obj.decode()
-
-
-@display_formatter.register(six.text_type)
-def _(input_unicode):
- return input_unicode
-
-
-@display_formatter.register(type(None))
-def _(input_none):
- return "--"
-
-
-@display_formatter.register(int)
-def _(input_int):
- # return str(input_int)
- # 直接返回 int,不影响该列的排序
- return input_int
-
-
-@display_formatter.register(float)
-def _(input_float):
- return "{:.2f}".format(round(input_float, 2))
-
-
-@display_formatter.register(object)
-def _(input_object):
- if hasattr(input_object, "name"):
- return display_formatter(getattr(input_object, "name"))
- if hasattr(input_object, "code"):
- return display_formatter(getattr(input_object, "code"))
- return str(input_object)
-
-
-@display_formatter.register(dt.datetime)
-def _(input_datetime):
- return input_datetime.strftime("%Y-%m-%d %H:%M:%S")
-
-
-def font_formatter(setting_dict):
- """
- Used for QAbstractItemModel data method for Qt.FontRole
- :param underline: font style underline
- :param bold: font style bold
- :return: a QFont instance with given style
- """
- _font = QtGui.QFont()
- _font.setUnderline(setting_dict.get("underline") or False)
- _font.setBold(setting_dict.get("bold") or False)
- return _font
-
-
-@singledispatch
-def icon_formatter(input_other_type):
- """
- Used for QAbstractItemModel data method for Qt.DecorationRole
- A helper function to easy get QIcon.
- The input can be dict/object, string, None, tuple(file_path, fill_color)
- :param input_other_type:
- :return: a QIcon instance
- """
- return input_other_type # this function never reached
-
-
-@icon_formatter.register(dict)
-def _(input_dict):
- attr_list = ["icon"]
- path = next((get_obj_value(input_dict, attr) for attr in attr_list), None)
- return icon_formatter(path)
-
-
-@icon_formatter.register(QtGui.QIcon)
-def _(input_dict):
- return input_dict
-
-
-@icon_formatter.register(object)
-def _(input_object):
- attr_list = ["icon"]
- path = next((get_obj_value(input_object, attr) for attr in attr_list), None)
- return icon_formatter(path)
-
-
-@icon_formatter.register(str)
-def _(input_string):
- return MIcon(input_string)
-
-
-@icon_formatter.register(tuple)
-def _(input_tuple):
- return MIcon(*input_tuple)
-
-
-@icon_formatter.register(type(None))
-def _(input_none):
- return icon_formatter("confirm_fill.svg")
-
-
-def overflow_format(num, overflow):
- """
- Give a integer, return a string.
- When this integer is large than given overflow, return "overflow+"
- """
- if not isinstance(num, int):
- raise ValueError(
- "Input argument 'num' should be int type, " "but get {}".format(type(num))
- )
- if not isinstance(overflow, int):
- raise ValueError(
- "Input argument 'overflow' should be int type, "
- "but get {}".format(type(overflow))
- )
- return str(num) if num <= overflow else "{}+".format(overflow)
-
-
-def get_percent(value, minimum, maximum):
- """
- Get a given value's percent in the range.
- :param value: value
- :param minimum: the range's minimum value
- :param maximum: the range's maximum value
- :return: percent float
- """
- if minimum == maximum:
- # reference from qprogressbar.cpp
- # If max and min are equal and we get this far, it means that the
- # progress bar has one step and that we are on that step. Return
- # 100% here in order to avoid division by zero further down.
- return 100
- return max(0, min(100, (value - minimum) * 100 / (maximum - minimum)))
-
-
-def get_total_page(total, per):
- """
- Get the page count.
- :param total: total count
- :param per: count per page
- :return: page count int
- """
- return int(math.ceil(1.0 * total / per))
-
-
-def get_page_display_string(current, per, total):
- """
- Get the format string x - x of xx
- :param current: current page
- :param per: count per page
- :param total: total count
- :return: str
- """
- return "{start} - {end} of {total}".format(
- start=((current - 1) * per + 1) if current else 0,
- end=min(total, current * per),
- total=total,
- )
-
-
-def read_settings(organization, app_name):
- settings = QtCore.QSettings(
- QtCore.QSettings.IniFormat,
- QtCore.QSettings.UserScope,
- organization,
- app_name,
- )
- result_dict = {key: settings.value(key) for key in settings.childKeys()}
- for grp_name in settings.childGroups():
- settings.beginGroup(grp_name)
- result_dict.update(
- {grp_name + "/" + key: settings.value(key) for key in settings.childKeys()}
- )
- settings.endGroup()
- return result_dict
-
-
-def add_settings(organization, app_name, event_name="closeEvent"):
- def _write_settings(self):
- settings = QtCore.QSettings(
- QtCore.QSettings.IniFormat,
- QtCore.QSettings.UserScope,
- organization,
- app_name,
- )
- for attr, widget, property in self._bind_data:
- if property == "geometry":
- settings.setValue(attr, widget.saveGeometry())
- elif property == "state":
- settings.setValue(attr, widget.saveState())
- else:
- settings.setValue(attr, widget.property(property))
-
- def trigger_event(self, event):
- # 一般是 closeEvent 或者 hideEvent
- # 当窗口作为子组件,比如 tab 的一页时、关闭最顶层窗口时,都不会触发 closeEvent,
- # 此时请使用 hideEvent
- # 如果是作为一个独立的窗口,请使用 closeEvent
- self.write_settings()
- old_event = getattr(self, "old_trigger_event")
- return old_event(event)
-
- def bind(self, attr, widget, property, default=None, formatter=None):
- old_setting_dict = read_settings(organization, app_name)
- value = old_setting_dict.get(attr, default)
- if callable(formatter): # 二次处理 value,比如存入的 bool,读取后要恢复成 bool
- value = formatter(value)
- if property == "geometry": # 窗口大小位置需要特殊处理
- if isinstance(value, QtCore.QRect): # setting 并没有存,使用用户default传入进来的geo
- widget.setGeometry(value)
- elif isinstance(value, QtCore.QByteArray): # settings 有保存值
- widget.restoreGeometry(value)
- elif property == "state": # 类似 QMainWindow/QSplitter等的布局参数需要特殊处理
- # 由于每种类型组件的state 都不同,所以无法让用户手动传入默认参数,只能读取保存的
- # 用户可以使用组件自己的方法去初始化布局
- if isinstance(value, QtCore.QByteArray): # settings 有保存值
- widget.restoreState(value)
- else:
- widget.setProperty(property, value)
- self._bind_data.append((attr, widget, property))
-
- def unbind(self, attr, widget, property):
- self.write_settings()
- self._bind_data.remove((attr, widget, property))
-
- def wrapper(cls):
- cls.bind = bind
- cls.unbind = unbind
- cls.write_settings = _write_settings
- cls._bind_data = []
- if hasattr(cls, event_name):
- old_event = getattr(cls, event_name)
- setattr(cls, "old_trigger_event", old_event)
- setattr(cls, event_name, trigger_event)
- return cls
-
- return wrapper
-
-
-def get_fit_geometry():
- geo = next(
- (screen.availableGeometry() for screen in QtWidgets.QApplication.screens()),
- None,
- )
- return QtCore.QRect(
- geo.width() / 4, geo.height() / 4, geo.width() / 2, geo.height() / 2
- )
-
-
-def convert_to_round_pixmap(orig_pix):
- scale_x, _ = get_scale_factor()
- w = min(orig_pix.width(), orig_pix.height())
- pix_map = QtGui.QPixmap(w, w)
- pix_map.fill(QtCore.Qt.transparent)
-
- painter = QtGui.QPainter(pix_map)
- painter.setRenderHints(
- QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform
- )
-
- path = QtGui.QPainterPath()
- path.addEllipse(0, 0, w, w)
- painter.setClipPath(path)
- painter.drawPixmap(0, 0, w, w, orig_pix)
- return pix_map
-
-
-def generate_text_pixmap(
- width, height, text, alignment=QtCore.Qt.AlignCenter, bg_color=None
-):
- # Import local modules
- from dayu_widgets import dayu_theme
-
- bg_color = bg_color or dayu_theme.background_in_color
- # draw a pixmap with text
- pix_map = QtGui.QPixmap(width, height)
- pix_map.fill(QtGui.QColor(bg_color))
- painter = QtGui.QPainter(pix_map)
- painter.setRenderHints(QtGui.QPainter.TextAntialiasing)
- font = painter.font()
- font.setFamily(dayu_theme.font_family)
- painter.setFont(font)
- painter.setPen(QtGui.QPen(QtGui.QColor(dayu_theme.secondary_text_color)))
-
- font_metrics = painter.fontMetrics()
- text_width = font_metrics.horizontalAdvance(text)
- text_height = font_metrics.height()
- x = width / 2 - text_width / 2
- y = height / 2 - text_height / 2
- if alignment & QtCore.Qt.AlignLeft:
- x = 0
- elif alignment & QtCore.Qt.AlignRight:
- x = width - text_width
- elif alignment & QtCore.Qt.AlignTop:
- y = 0
- elif alignment & QtCore.Qt.AlignBottom:
- y = height - text_height
-
- painter.drawText(x, y, text)
- painter.end()
- return pix_map
-
-
-def get_color_icon(color, size=24):
- scale_x, y = get_scale_factor()
- pix = QtGui.QPixmap(size * scale_x, size * scale_x)
- q_color = color
- if isinstance(color, str):
- if color.startswith("#"):
- q_color = QtGui.QColor(str)
- elif color.count(",") == 2:
- q_color = QtGui.QColor(*tuple(map(int, color.split(","))))
- pix.fill(q_color)
- return QtGui.QIcon(pix)
diff --git a/docs/.nojekyll b/docs/.nojekyll
deleted file mode 100644
index e69de29b..00000000
diff --git a/docs/README.md b/docs/README.md
deleted file mode 100644
index 043d0e9a..00000000
--- a/docs/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# dayu_widgets
-
-[PySide](https://wiki.qt.io/PySide) UI library `dayu_widgets`
-
-reference of [AntDesign](https://ant.design/) UI library, [iView](https://www.iviewui.com/) and wechat
-
-
-We provide **light** 和 **dark** themes. You can custom the primary color
-The screenshots in docs used:
-
-* Light: #1890ff
-* Dark: #fa8c16
-
-
-```python
-import dayu_widgets
-```
diff --git a/docs/_coverpage.md b/docs/_coverpage.md
deleted file mode 100644
index 767d8991..00000000
--- a/docs/_coverpage.md
+++ /dev/null
@@ -1,12 +0,0 @@
-![logo](_media/logo.svg)
-
-# DaYu Widgets 0.0.1
-
-> Web Style Components for PySide
-
-* Based on PySide
-* Easy to use
-* Light & Dark themes
-
-[GitHub](https://github.com/phenom-films/dayu_widgets)
-[Get Started](/README.md)
diff --git a/docs/_media/logo.svg b/docs/_media/logo.svg
deleted file mode 100644
index d84a7541..00000000
--- a/docs/_media/logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/docs/_navbar.md b/docs/_navbar.md
deleted file mode 100644
index e5f8d348..00000000
--- a/docs/_navbar.md
+++ /dev/null
@@ -1,2 +0,0 @@
-* [:uk: English](/)
-* [:cn: 简体中文](/zh-cn/)
diff --git a/docs/_sidebar.md b/docs/_sidebar.md
deleted file mode 100644
index 0f94f94c..00000000
--- a/docs/_sidebar.md
+++ /dev/null
@@ -1,61 +0,0 @@
-* [Dayu Widgets](/README.md)
-* [Quick Guide](/quick_guide.md)
-* [Custom Theme](/theme.md)
-* Components
-
- * General
- * [MIcon](/icon.md)
- * [MLabel](/label.md)
- * [MLoading](/loading.md)
- * [MPixmap](/pixmap.md)
- * [MPushButton](/push_button.md)
- * [MToolButton](/tool_button.md)
-
- * Layout
- * [MFlowLayout](flow_layou.md)
-
- * Navigation
- * [MBreadcrumb](/breadcrumb.md)
- * [MMenuTabWidget](/menu_tab_widget.md)
- * [MPage](/page.md)
- * [MWizard](/wizard.md)
-
- * Data Entry
- * [MCheckBox](/check_box.md)
- * [MCascader](/cascader.md)
- * [MLineEdit](/line_edit.md)
- * [MRadioButton](/radio_button.md)
- * [MSwitch](/swtich.md)
- * [MSlider](/slider.md)
- * [MSpinBox](/spin_box.md)
- * [MDoubleSpinBox](/double_spin_box.md)
- * [MDateTimeEdit](/data_time_edit.md)
- * [MDateEdit](/date_edit.md)
- * [MTimeEdit](/time_edit.md)
- * [Upload](/browser.md)
-
- * Data Display
- * [MAvatar](/avatar.md)
- * [MBadge](/badge.md)
- * [MCarousel](/carousel.md)
- * [MCard](/card.md)
- * [MCollapse](/collapse.md)
- * [MLineTabWidget](/line_tab.md)
- * [Tag](/tag.md)
- * [MListView](/list_view.md)
- * [MTableView](/table_view.md)
- * [MTreeView](/tree_view.md)
- * [MItemViewSet](/item_view_set.md)
- * [MItemViewFullSet](/item_view_full_set.md)
- * [MSequenceFile](/sequence_file.md)
-
- * Feedback
- * [MAlert](/alert.md)
- * [MDrawer](/drawer.md)
- * [MMessage](/message.md)
- * [MProgressBar](/progress_bar.md)
- * [MProgressCircle](/circle.md)
- * [MToast](/toast.md)
-
- * Other
- * [MDivider](/divider.md)
diff --git a/docs/index.html b/docs/index.html
deleted file mode 100644
index e255ddd5..00000000
--- a/docs/index.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
- Document
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/zh-cn/README.md b/docs/zh-cn/README.md
deleted file mode 100644
index 27dfb45f..00000000
--- a/docs/zh-cn/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# dayu_widgets
-
-一个 [PySide](https://wiki.qt.io/PySide) 的组件库
-
-主要参考了 [AntDesign](https://ant.design/) 组件库,其他参考了 [iView](https://www.iviewui.com/) 组件库,微信基础组件。
-
-
-提供**亮色(light)** 和 **暗色(dark)** 两种主题,每种主题可以设置主题颜色。
-以下截图以:
-
-* 亮色 #1890ff
-* 暗色 #fa8c16
-
-
-```python
-import dayu_widgets
-```
diff --git a/docs/zh-cn/_coverpage.md b/docs/zh-cn/_coverpage.md
deleted file mode 100644
index 5b77b840..00000000
--- a/docs/zh-cn/_coverpage.md
+++ /dev/null
@@ -1,12 +0,0 @@
-![logo](../_media/logo.svg)
-
-# DaYu Widgets 0.0.1
-
-> Web 风格的 PySide 组件库
-
-* 基于 PySide
-* 易用
-* 提供亮色和暗色两种主题
-
-[GitHub](https://github.com/phenom-films/dayu_widgets)
-[开始使用](/zh-cn/README.md)
diff --git a/docs/zh-cn/_sidebar.md b/docs/zh-cn/_sidebar.md
deleted file mode 100644
index ba9c0ad9..00000000
--- a/docs/zh-cn/_sidebar.md
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-* [dayu widgets](/zh-cn/README.md)
-* [快速上手](/zh-cn/quick_start.md)
-* [定制主题](/zh-cn/theme.md)
-* 组件
-
- * 通用
-
- * [MIcon](/icon.md)
- * [MLabel](/zh-cn/label.md)
- * [MLoading 加载图标](/zh-cn/loading.md)
- * [MPixmap](/zh-cn/pixmap.md)
- * [MPushButton](/zh-cn/push_button.md)
- * [MToolButton 按钮](/zh-cn/tool_button.md)
-
- * 布局
- * [MFlowLayout 浮动布局](/zh-cn/flow_layou.md)
-
- * 导航
- * [MBreadcrumb 面包屑](/zh-cn/breadcrumb.md)
- * [MMenuTabWidget 菜单形式的导航栏](/zh-cn/menu_tab_widget.md)
- * [MPage 分页](/zh-cn/page.md)
- * [MWizard 步骤](/zh-cn/wizard.md)
-
- * 数据录入
- * [MCheckbox](/zh-cn/check_box.md)
- * [MCascader 级联选择](/cascader.md)
- * [MLineEdit](/zh-cn/line_edit.md)
- * [MRadioButton](/zh-cn/radio_button.md)
- * [MSwitch 开关](/zh-cn/swtich.md)
- * [MSlider](/zh-cn/slider.md)
- * [MSpinBox](/zh-cn/spin_box.md)
- * [MDoubleSpinBox](/zh-cn/double_spin_box.md)
- * [MDateTimeEdit](/zh-cn/data_time_edit.md)
- * [MDateEdit](/zh-cn/date_edit.md)
- * [MTimeEdit](/zh-cn/time_edit.md)
- * [Upload 上传](/zh-cn/browser.md)
-
- * 数据展示
- * [MAvatar 头像](/zh-cn/avatar.md)
- * [MBadge 徽标](/zh-cn/badge.md)
- * [MCarousel 走马灯](/zh-cn/carousel.md)
- * [MCard 卡片](/zh-cn/card.md)
- * [MCollapse 折叠面板](/zh-cn/collapse.md)
- * [MLineTabWidget 下划线式 TabBar](/zh-cn/line_tab.md)
- * [Tag 标签](/zh-cn/tag.md)
- * [MListView](/zh-cn/list_view.md)
- * [MTableView](/zh-cn/table_view.md)
- * [MTreeView](/zh-cn/tree_view.md)
- * [MItemViewSet](/zh-cn/item_view_set.md)
- * [MItemViewFullSet](/zh-cn/item_view_full_set.md)
- * [MSequenceFile](/zh-cn/sequence_file.md)
-
- * 反馈
- * [MAlert 警告提示](/zh-cn/alert.md)
- * [MDrawer 抽屉](/zh-cn/drawer.md)
- * [MMessage 全局提示](/zh-cn/message.md)
- * [MProgressBar](/zh-cn/progress_bar.md)
- * [MProgressCircle 环形进度](/zh-cn/circle.md)
- * [MToast](/zh-cn/toast.md)
-
- * 其他
- * [MDivider 分割线](/zh-cn/divider.md)
diff --git a/examples/__init__.py b/examples/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/examples/_mock_data.py b/examples/_mock_data.py
deleted file mode 100644
index 456720f6..00000000
--- a/examples/_mock_data.py
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import local modules
-from dayu_widgets import dayu_theme
-
-
-def score_color(score, y):
- if score < 60:
- return dayu_theme.error_color
- elif score < 80:
- return dayu_theme.warning_color
- elif score >= 90:
- return dayu_theme.success_color
- return dayu_theme.info_color
-
-
-header_list = [
- {
- "label": "Name",
- "key": "name",
- "checkable": True,
- "searchable": True,
- "width": 200,
- "font": lambda x, y: {"underline": True},
- "icon": "user_fill.svg",
- },
- {
- "label": "Sex",
- "key": "sex",
- "searchable": True,
- "selectable": True,
- "icon": lambda x, y: (
- "{}.svg".format(x.lower()),
- getattr(dayu_theme, x.lower() + "_color"),
- ),
- },
- {
- "label": "Age",
- "key": "age",
- "width": 90,
- "searchable": True,
- "editable": True,
- "display": lambda x, y: "{} 岁".format(x),
- "font": lambda x, y: {"bold": True},
- },
- {
- "label": "Address",
- "key": "city",
- "selectable": True,
- "searchable": True,
- "exclusive": False,
- "width": 120,
- "display": lambda x, y: " & ".join(x) if isinstance(x, list) else x,
- "bg_color": lambda x, y: "transparent" if x else dayu_theme.error_color,
- },
- {
- "label": "Score",
- "key": "score",
- "searchable": True,
- "editable": True,
- "order": "desc",
- "bg_color": score_color,
- "color": "#fff",
- },
- {"label": "Score Copy", "key": "score", "searchable": True, "color": score_color},
-]
-
-data_list = [
- {
- "name": "John Brown",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 18,
- "score": 89,
- "city": "New York",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-03",
- },
- {
- "name": "Jim Green",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 24,
- "score": 55,
- "city": "London",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-01",
- },
- {
- "name": "Zhang Xiaoming",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 30,
- "score": 70,
- "city": "",
- "city_list": ["Beijing", "Shanghai", "Shenzhen", "Guangzhou"],
- "date": "2016-10-02",
- },
- {
- "name": "Jon Snow",
- "sex": "Female",
- "sex_list": ["Male", "Female"],
- "age": 26,
- "score": 60,
- "city": "Ottawa",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-04",
- },
- {
- "name": "Li Xiaohua",
- "sex": "Female",
- "sex_list": ["Male", "Female"],
- "age": 18,
- "score": 97,
- "city": "Ottawa",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-04",
- },
-]
-
-tree_data_list = [
- {
- "name": "John Brown",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 18,
- "score": 89,
- "city": "New York",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-03",
- "children": [
- {
- "name": "Jim Green",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 24,
- "score": 55,
- "city": "London",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-01",
- },
- {
- "name": "Zhang Xiaoming",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 30,
- "score": 70,
- "city": "",
- "city_list": ["Beijing", "Shanghai", "Shenzhen", "Guangzhou"],
- "date": "2016-10-02",
- },
- ],
- },
- {
- "name": "Jon Snow",
- "sex": "Female",
- "sex_list": ["Male", "Female"],
- "age": 26,
- "score": 60,
- "city": "Ottawa",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-04",
- },
- {
- "name": "Li Xiaohua",
- "sex": "Female",
- "sex_list": ["Male", "Female"],
- "age": 18,
- "score": 97,
- "city": "Ottawa",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-04",
- },
-]
diff --git a/examples/alert_example.py b/examples/alert_example.py
deleted file mode 100644
index 27564de7..00000000
--- a/examples/alert_example.py
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.alert import MAlert
-from dayu_widgets.button_group import MPushButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-
-
-class AlertExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(AlertExample, self).__init__(parent)
- self.setWindowTitle("Example for MAlert")
- main_lay = QtWidgets.QVBoxLayout()
- self.setLayout(main_lay)
- main_lay.addWidget(MDivider("different type"))
- main_lay.addWidget(MAlert(text="Information Message", parent=self).info())
- main_lay.addWidget(MAlert(text="Success Message", parent=self).success())
- main_lay.addWidget(MAlert(text="Warning Message", parent=self).warning())
- main_lay.addWidget(MAlert(text="Error Message", parent=self).error())
-
- closable_alert = MAlert("Some Message", parent=self).closable()
-
- main_lay.addWidget(MLabel("不同的提示信息类型"))
- main_lay.addWidget(MDivider("closable"))
- main_lay.addWidget(closable_alert)
- main_lay.addWidget(MDivider("data bind"))
- self.register_field("msg", "")
- self.register_field("msg_type", MAlert.InfoType)
-
- data_bind_alert = MAlert(parent=self)
- data_bind_alert.set_closable(True)
-
- self.bind("msg", data_bind_alert, "dayu_text")
- self.bind("msg_type", data_bind_alert, "dayu_type")
- button_grp = MPushButtonGroup()
- button_grp.set_button_list(
- [
- {
- "text": "error",
- "clicked": functools.partial(
- self.slot_change_alert, "password is wrong", MAlert.ErrorType
- ),
- },
- {
- "text": "success",
- "clicked": functools.partial(
- self.slot_change_alert, "login success", MAlert.SuccessType
- ),
- },
- {
- "text": "no more error",
- "clicked": functools.partial(
- self.slot_change_alert, "", MAlert.InfoType
- ),
- },
- ]
- )
- main_lay.addWidget(button_grp)
- main_lay.addWidget(data_bind_alert)
- main_lay.addStretch()
-
- def slot_change_alert(self, alert_text, alert_type):
- self.set_field("msg_type", alert_type)
- self.set_field("msg", alert_text)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = AlertExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/avatar_example.py b/examples/avatar_example.py
deleted file mode 100644
index 46334464..00000000
--- a/examples/avatar_example.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MPixmap
-
-
-class AvatarExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(AvatarExample, self).__init__(parent)
- self.setWindowTitle("Example for MAvatar")
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different size"))
-
- size_list = [
- ("Huge", MAvatar.huge),
- ("Large", MAvatar.large),
- ("Medium", MAvatar.medium),
- ("Small", MAvatar.small),
- ("Tiny", MAvatar.tiny),
- ]
-
- self.pix_map_list = [
- None,
- MPixmap("avatar.png"),
- MPixmap("app-maya.png"),
- MPixmap("app-nuke.png"),
- MPixmap("app-houdini.png"),
- ]
- form_lay = QtWidgets.QFormLayout()
- form_lay.setLabelAlignment(QtCore.Qt.AlignRight)
-
- for label, cls in size_list:
- h_lay = QtWidgets.QHBoxLayout()
- for image in self.pix_map_list:
- avatar_tmp = cls(image)
- h_lay.addWidget(avatar_tmp)
- h_lay.addStretch()
- form_lay.addRow(MLabel(label), h_lay)
- main_lay.addLayout(form_lay)
- self.register_field("image", None)
- main_lay.addWidget(MDivider("different image"))
- avatar = MAvatar()
- self.bind("image", avatar, "dayu_image")
- button = MPushButton(text="Change Avatar Image").primary()
- button.clicked.connect(self.slot_change_image)
-
- main_lay.addWidget(avatar)
- main_lay.addWidget(button)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_change_image(self):
- """Set the Avatar image random by data bind."""
- # Import built-in modules
- import random
-
- self.set_field("image", random.choice(self.pix_map_list))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = AvatarExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/badge_example.py b/examples/badge_example.py
deleted file mode 100644
index 92fb96eb..00000000
--- a/examples/badge_example.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.badge import MBadge
-from dayu_widgets.combo_box import MComboBox
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.menu import MMenu
-from dayu_widgets.qt import MPixmap
-from dayu_widgets.spin_box import MSpinBox
-from dayu_widgets.tool_button import MToolButton
-
-
-class BadgeExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(BadgeExample, self).__init__(parent)
- self.setWindowTitle("Examples for MBadge")
- self._init_ui()
-
- def _init_ui(self):
- standalone_lay = QtWidgets.QHBoxLayout()
- standalone_lay.addWidget(MBadge.count(0))
- standalone_lay.addWidget(MBadge.count(20))
- standalone_lay.addWidget(MBadge.count(100))
- standalone_lay.addWidget(MBadge.dot(True))
- standalone_lay.addWidget(MBadge.text("new"))
- standalone_lay.addStretch()
-
- button = MToolButton().svg("trash_line.svg")
- avatar = MAvatar.large(MPixmap("avatar.png"))
- button_alert = MToolButton().svg("alert_fill.svg").large()
- badge_1 = MBadge.dot(True, widget=button)
- badge_2 = MBadge.dot(True, widget=avatar)
- badge_3 = MBadge.dot(True, widget=button_alert)
- button.clicked.connect(lambda: badge_1.set_dayu_dot(False))
-
- spin_box = MSpinBox()
- spin_box.setRange(0, 9999)
- spin_box.valueChanged.connect(badge_3.set_dayu_count)
- spin_box.setValue(1)
-
- self.register_field("button1_selected", "北京")
- menu1 = MMenu(parent=self)
- menu1.set_data(["北京", "上海", "广州", "深圳"])
- select1 = MComboBox()
- select1.set_menu(menu1)
- self.bind("button1_selected", select1, "value", signal="sig_value_changed")
-
- badge_hot = MBadge.text("hot", widget=MLabel("你的理想城市 "))
-
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(badge_1)
- sub_lay1.addWidget(badge_2)
- sub_lay1.addWidget(badge_3)
- sub_lay1.addStretch()
-
- sub_lay2 = QtWidgets.QHBoxLayout()
- sub_lay2.addWidget(badge_hot)
- sub_lay2.addWidget(select1)
- sub_lay2.addStretch()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("use standalone"))
- main_lay.addLayout(standalone_lay)
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(sub_lay1)
- main_lay.addWidget(spin_box)
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(sub_lay2)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = BadgeExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/breadcrumb_example.py b/examples/breadcrumb_example.py
deleted file mode 100644
index bcda14de..00000000
--- a/examples/breadcrumb_example.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.breadcrumb import MBreadcrumb
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.message import MMessage
-
-
-class BreadcrumbExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(BreadcrumbExample, self).__init__(parent)
- self.setWindowTitle("Examples for MBreadcrumb")
- self._init_ui()
-
- def _init_ui(self):
- MMessage.config(duration=1)
- entity_list = [
- {
- "clicked": functools.partial(
- self.slot_show_message, MMessage.info, 'Go to "Home Page"'
- ),
- "svg": "home_line.svg",
- },
- {
- "text": "pl",
- "clicked": functools.partial(
- self.slot_show_message, MMessage.info, 'Go to "pl"'
- ),
- "svg": "user_line.svg",
- },
- {
- "text": "pl_0010",
- "clicked": functools.partial(
- self.slot_show_message, MMessage.info, 'Go to "pl_0010"'
- ),
- },
- ]
- no_icon_eg = MBreadcrumb()
- no_icon_eg.set_item_list(entity_list)
-
- separator_eg = MBreadcrumb(separator="=>")
- separator_eg.set_item_list(entity_list)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("normal"))
- main_lay.addWidget(no_icon_eg)
- main_lay.addWidget(MDivider("separator: =>"))
- main_lay.addWidget(separator_eg)
-
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_show_message(self, func, config):
- func(config, parent=self)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = BreadcrumbExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/browser_example.py b/examples/browser_example.py
deleted file mode 100644
index 60451c5a..00000000
--- a/examples/browser_example.py
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.browser import MClickBrowserFilePushButton
-from dayu_widgets.browser import MClickBrowserFileToolButton
-from dayu_widgets.browser import MClickBrowserFolderPushButton
-from dayu_widgets.browser import MClickBrowserFolderToolButton
-from dayu_widgets.browser import MDragFileButton
-from dayu_widgets.browser import MDragFolderButton
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.qt import MIcon
-
-
-class BrowserExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(BrowserExample, self).__init__(parent)
- self.setWindowTitle("Examples for MBrowser...")
- self._init_ui()
-
- def _init_ui(self):
- browser_1 = MClickBrowserFilePushButton(
- text="Browser File PushButton"
- ).primary()
- browser_2 = MClickBrowserFolderPushButton(text="Browser Folder PushButton")
- browser_2.setIcon(MIcon("upload_line.svg"))
- browser_3 = MClickBrowserFilePushButton(
- text="Browser Multi Files", multiple=True
- ).primary()
- lay_1 = QtWidgets.QHBoxLayout()
- lay_1.addWidget(browser_1)
- lay_1.addWidget(browser_2)
- lay_1.addWidget(browser_3)
-
- browser_4 = MClickBrowserFileToolButton().huge()
- label_4 = MLabel()
- label_4.set_elide_mode(QtCore.Qt.ElideMiddle)
- browser_4.sig_file_changed.connect(label_4.setText)
-
- browser_5 = MClickBrowserFolderToolButton().huge()
- label_5 = MLabel()
- label_5.set_elide_mode(QtCore.Qt.ElideMiddle)
- browser_5.sig_folder_changed.connect(label_5.setText)
-
- lay_2 = QtWidgets.QHBoxLayout()
- lay_2.addWidget(label_4)
- lay_2.addWidget(browser_4)
- lay_2.addWidget(label_5)
- lay_2.addWidget(browser_5)
-
- browser_6 = MDragFileButton(text="Click or drag file here")
- browser_6.set_dayu_svg("attachment_line.svg")
- label_6 = MLabel()
- label_6.set_elide_mode(QtCore.Qt.ElideMiddle)
- browser_6.sig_file_changed.connect(label_6.setText)
-
- browser_7 = MDragFolderButton()
- label_7 = MLabel()
- label_7.set_elide_mode(QtCore.Qt.ElideRight)
- browser_7.sig_folder_changed.connect(label_7.setText)
-
- lay_3 = QtWidgets.QGridLayout()
- lay_3.addWidget(browser_6, 2, 0)
- lay_3.addWidget(browser_7, 2, 1)
- lay_3.addWidget(label_6, 3, 0)
- lay_3.addWidget(label_7, 3, 1)
-
- browser_8 = MDragFileButton(
- text="Click or drag media file here", multiple=False
- )
- browser_8.set_dayu_svg("media_line.svg")
- browser_8.set_dayu_filters([".mov", ".mp4"])
- browser_8_label = MLabel()
- browser_8_label.set_elide_mode(QtCore.Qt.ElideRight)
- self.register_field("current_file", "")
- self.bind("current_file", browser_8, "dayu_path", signal="sig_file_changed")
- self.bind("current_file", browser_8_label, "text")
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("MClickBrowser*PushButton"))
- main_lay.addLayout(lay_1)
- main_lay.addWidget(MDivider("MClickBrowser*ToolButton"))
- main_lay.addLayout(lay_2)
- main_lay.addWidget(MDivider("MDragBrowser*ToolButton"))
- main_lay.addLayout(lay_3)
- main_lay.addWidget(MDivider("data bind"))
- main_lay.addWidget(browser_8)
- main_lay.addWidget(browser_8_label)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = BrowserExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/card_example.py b/examples/card_example.py
deleted file mode 100644
index b0e9de93..00000000
--- a/examples/card_example.py
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.4
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.card import MCard
-from dayu_widgets.card import MMeta
-from dayu_widgets.divider import MDivider
-from dayu_widgets.flow_layout import MFlowLayout
-from dayu_widgets.label import MLabel
-from dayu_widgets.qt import MPixmap
-
-
-class CardExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(CardExample, self).__init__(parent)
- self.setWindowTitle("Examples for MCard")
- geo = QtWidgets.QApplication.desktop().screenGeometry()
- width = float(geo.width())
- height = float(geo.height())
- x = int(width / 4)
- y = int(height / 4)
- w = int(width / 1.5)
- h = int(height / 2)
- self.setGeometry(x, y, w, h)
- self._init_ui()
-
- def _init_ui(self):
-
- basic_card_lay = MFlowLayout()
- basic_card_lay.setSpacing(20)
- for setting in [
- {
- "title": "",
- },
- {"title": "Card Title", "size": dayu_theme.small},
- {"title": "Card Title", "image": MPixmap("app-houdini.png")},
- {
- "title": "Card Title",
- "extra": "More",
- "image": MPixmap("app-houdini.png"),
- },
- {
- "title": "Card Title",
- "extra": "More",
- },
- ]:
- card_0 = MCard(**setting)
- content_widget_0 = QtWidgets.QWidget()
- content_lay_0 = QtWidgets.QVBoxLayout()
- content_lay_0.setContentsMargins(15, 15, 15, 15)
- content_widget_0.setLayout(content_lay_0)
- for i in range(4):
- content_lay_0.addWidget(MLabel("Card Content {}".format(i + 1)))
- card_0.set_widget(content_widget_0)
-
- basic_card_lay.addWidget(card_0)
-
- meta_card_lay = MFlowLayout()
- meta_card_lay.setSpacing(20)
- for setting in [
- {
- "title": "Houdini",
- "description": "Side Effects Software的旗舰级产品,是创建高级视觉效果的有效工具",
- "avatar": MPixmap("user_line.svg"),
- "cover": MPixmap("app-houdini.png"),
- },
- {
- "title": "Autodesk Maya",
- "description": "3D 数字动画和视觉效果的世界领先软件应用程序",
- "cover": MPixmap("app-maya.png"),
- },
- ]:
- meta_card = MMeta()
- meta_card.setup_data(setting)
- meta_card_lay.addWidget(meta_card)
-
- task_card_lay = QtWidgets.QVBoxLayout()
- # task_card_lay.setSpacing(10)
- for setting in [
- {
- "title": "Task A",
- "description": "demo pl_0010 Animation \n2019/04/01 - 2019/04/09",
- "avatar": MPixmap("success_line.svg", dayu_theme.success_color),
- },
- {
- "title": "Task B",
- "description": "#2 closed by xiao hua.",
- "avatar": MPixmap("error_line.svg", dayu_theme.error_color),
- },
- {
- "title": "Task C",
- "description": "#3 closed by xiao hua.",
- "avatar": MPixmap("warning_line.svg", dayu_theme.warning_color),
- },
- ] * 5:
- meta_card = MMeta(extra=True)
- meta_card.setup_data(setting)
- task_card_lay.addWidget(meta_card)
-
- left_lay = QtWidgets.QVBoxLayout()
- left_lay.addWidget(MDivider("Basic"))
- left_lay.addLayout(basic_card_lay)
- left_lay.addWidget(MDivider("Meta E-Commerce Example"))
- left_lay.addLayout(meta_card_lay)
- left_lay.addStretch()
- left_widget = QtWidgets.QWidget()
- left_widget.setLayout(left_lay)
-
- right_lay = QtWidgets.QVBoxLayout()
- right_lay.addWidget(MDivider("Meta Task Item Example"))
- scroll = QtWidgets.QScrollArea()
- scroll.setWidgetResizable(True)
- task_widget = QtWidgets.QWidget()
- task_widget.setLayout(task_card_lay)
- scroll.setWidget(task_widget)
-
- right_lay.addWidget(scroll)
- right_widget = QtWidgets.QWidget()
- right_widget.setLayout(right_lay)
-
- splitter = QtWidgets.QSplitter()
- splitter.addWidget(left_widget)
- splitter.addWidget(right_widget)
- splitter.setStretchFactor(0, 80)
- splitter.setStretchFactor(1, 20)
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(splitter)
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = CardExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/carousel_example.py b/examples/carousel_example.py
deleted file mode 100644
index 30264d36..00000000
--- a/examples/carousel_example.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.4
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.carousel import MCarousel
-from dayu_widgets.label import MLabel
-from dayu_widgets.qt import MPixmap
-from dayu_widgets.slider import MSlider
-from dayu_widgets.switch import MSwitch
-
-
-class CarouselExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(CarouselExample, self).__init__(parent)
- self.setWindowTitle("Examples for MCarousel")
- self._init_ui()
-
- def _init_ui(self):
- switch = MSwitch()
- switch.setChecked(True)
- slider = MSlider()
- slider.setRange(1, 10)
- switch_lay = QtWidgets.QFormLayout()
- switch_lay.addRow(MLabel("AutoPlay"), switch)
- switch_lay.addRow(MLabel("Interval"), slider)
- test = MCarousel(
- [MPixmap("app-{}.png".format(a)) for a in ["maya", "nuke", "houdini"]],
- width=300,
- height=300,
- autoplay=True,
- )
- switch.toggled.connect(test.set_autoplay)
- slider.valueChanged.connect(lambda x: test.set_interval(x * 1000))
- slider.setValue(3)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(test)
- main_lay.addLayout(switch_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = CarouselExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/check_box_example.py b/examples/check_box_example.py
deleted file mode 100644
index 2580abc3..00000000
--- a/examples/check_box_example.py
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.check_box import MCheckBox
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-
-
-class CheckBoxExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(CheckBoxExample, self).__init__(parent)
- self.setWindowTitle("Example for MCheckBox")
- grid_lay = QtWidgets.QGridLayout()
-
- for index, (text, state) in enumerate(
- [
- ("Unchecked", QtCore.Qt.Unchecked),
- ("Checked", QtCore.Qt.Checked),
- ("Partially", QtCore.Qt.PartiallyChecked),
- ]
- ):
- check_box_normal = MCheckBox(text)
- check_box_normal.setCheckState(state)
-
- check_box_disabled = MCheckBox(text)
- check_box_disabled.setCheckState(state)
- check_box_disabled.setEnabled(False)
-
- grid_lay.addWidget(check_box_normal, 0, index)
- grid_lay.addWidget(check_box_disabled, 1, index)
-
- icon_lay = QtWidgets.QHBoxLayout()
- for text, icon in [
- ("Maya", MIcon("app-maya.png")),
- ("Nuke", MIcon("app-nuke.png")),
- ("Houdini", MIcon("app-houdini.png")),
- ]:
- check_box_icon = MCheckBox(text)
- check_box_icon.setIcon(icon)
- icon_lay.addWidget(check_box_icon)
-
- check_box_bind = MCheckBox("Data Bind")
- label = MLabel()
- button = MPushButton(text="Change State")
- button.clicked.connect(
- lambda: self.set_field("checked", not self.field("checked"))
- )
- self.register_field("checked", True)
- self.register_field(
- "checked_text", lambda: "Yes!" if self.field("checked") else "No!!"
- )
- self.bind("checked", check_box_bind, "checked", signal="stateChanged")
- self.bind("checked_text", label, "text")
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Basic"))
- main_lay.addLayout(grid_lay)
- main_lay.addWidget(MDivider("Icon"))
- main_lay.addLayout(icon_lay)
- main_lay.addWidget(MDivider("Data Bind"))
- main_lay.addWidget(check_box_bind)
- main_lay.addWidget(label)
- main_lay.addWidget(button)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = CheckBoxExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/check_box_group_example.py b/examples/check_box_group_example.py
deleted file mode 100644
index 2e683fdc..00000000
--- a/examples/check_box_group_example.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MCheckBoxGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-
-
-class CheckBoxGroupExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(CheckBoxGroupExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- self.app_data = [
- {"text": "Maya", "icon": MIcon("app-maya.png")},
- {"text": "Nuke", "icon": MIcon("app-nuke.png")},
- {"text": "Houdini", "icon": MIcon("app-houdini.png")},
- ]
- radio_group_h = MCheckBoxGroup()
- radio_group_v = MCheckBoxGroup(orientation=QtCore.Qt.Vertical)
-
- radio_group_h.set_button_list(self.app_data)
- radio_group_v.set_button_list(self.app_data)
-
- self.data_list = ["北京", "上海", "广州", "深圳", "郑州", "石家庄"]
- radio_group_b = MCheckBoxGroup()
- radio_group_b.set_button_list(self.data_list)
-
- button = MPushButton(text="Change Value")
- button.clicked.connect(self.slot_button_clicked)
-
- label = MLabel()
- self.register_field("checked_app", ["北京", "郑州"])
- self.register_field(
- "checked_app_text", lambda: " & ".join(self.field("checked_app"))
- )
- self.bind(
- "checked_app", radio_group_b, "dayu_checked", signal="sig_checked_changed"
- )
- self.bind("checked_app_text", label, "text")
-
- radio_group_tri = MCheckBoxGroup()
- radio_group_tri.set_button_list(self.app_data)
- self.register_field("check_grp", ["Maya"])
- self.bind(
- "check_grp", radio_group_tri, "dayu_checked", signal="sig_checked_changed"
- )
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Orientation Qt.Horizontal"))
- main_lay.addWidget(radio_group_h)
- main_lay.addWidget(MDivider("Orientation Qt.Vertical"))
- main_lay.addWidget(radio_group_v)
-
- main_lay.addWidget(MDivider("Data Bind"))
- main_lay.addWidget(radio_group_b)
- main_lay.addWidget(label)
- main_lay.addWidget(button)
-
- main_lay.addWidget(MDivider("Try Context Menu"))
- main_lay.addWidget(radio_group_tri)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- @QtCore.Slot()
- def slot_button_clicked(self):
- # Import built-in modules
- import random
-
- start = random.randint(0, len(self.data_list))
- end = random.randint(start, len(self.data_list))
- self.set_field("checked_app", self.data_list[start:end])
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = CheckBoxGroupExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/collapse_example.py b/examples/collapse_example.py
deleted file mode 100644
index 0d2bb324..00000000
--- a/examples/collapse_example.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.collapse import MCollapse
-from dayu_widgets.label import MLabel
-
-
-class CollapseExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(CollapseExample, self).__init__(parent)
- self.setWindowTitle("Examples for MCollapse")
- self._init_ui()
-
- def _init_ui(self):
- label_1 = MLabel(
- "史蒂夫·乔布斯(Steve Jobs),1955年2月24日生于美国加利福尼亚州旧金山,美国发明家、企业家、美国苹果公司联合创办人。"
- )
- label_2 = MLabel(
- "斯蒂夫·盖瑞·沃兹尼亚克(Stephen Gary Wozniak),美国电脑工程师,曾与史蒂夫·乔布斯合伙创立苹果电脑(今之苹果公司)。斯蒂夫·盖瑞·沃兹尼亚克曾就读于美国科罗拉多大学,后转学入美国著名高等学府加州大学伯克利分校(UC Berkeley)并获得电机工程及计算机(EECS)本科学位(1987年)。"
- )
- label_3 = MLabel(
- "乔纳森·伊夫是一位工业设计师,现任Apple公司设计师兼资深副总裁,英国爵士。他曾参与设计了iPod,iMac,iPhone,iPad等众多苹果产品。除了乔布斯,他是对苹果那些著名的产品最有影响力的人。"
- )
- label_1.setWordWrap(True)
- label_2.setWordWrap(True)
- label_3.setWordWrap(True)
- section_list = [
- {"title": "史蒂夫乔布斯", "expand": True, "widget": label_1},
- {
- "title": "可关闭的",
- "expand": True,
- "widget": MLabel("This is a closable collapse item"),
- "closable": True,
- },
- {"title": "斯蒂夫·盖瑞·沃兹尼亚克", "expand": True, "widget": label_2},
- ]
-
- section_group = MCollapse()
- section_group.add_section_list(section_list)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(section_group)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = CollapseExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/combo_box_example.py b/examples/combo_box_example.py
deleted file mode 100644
index bca58017..00000000
--- a/examples/combo_box_example.py
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
-# Import built-in modules
-import itertools
-import random
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.combo_box import MComboBox
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.menu import MMenu
-
-
-class ComboBoxExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ComboBoxExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- cities = ["北京", "上海", "广州", "深圳"]
- self.register_field("button1_selected", "北京")
- menu1 = MMenu(parent=self)
- menu1.set_data(cities)
- size_list = [
- ("Large", dayu_theme.large),
- ("Medium", dayu_theme.medium),
- ("Small", dayu_theme.small),
- ]
- size_lay = QtWidgets.QHBoxLayout()
- for label, size in size_list:
- combo_box = MComboBox()
- combo_box.set_dayu_size(size)
- combo_box.set_menu(menu1)
- size_lay.addWidget(combo_box)
- self.bind(
- "button1_selected", combo_box, "value", signal="sig_value_changed"
- )
-
- self.register_field("button2_selected", ["北京"])
- menu2 = MMenu(exclusive=False, parent=self)
- menu2.set_data(cities)
- select2 = MComboBox()
- select2.set_menu(menu2)
- self.bind("button2_selected", select2, "value", signal="sig_value_changed")
-
- def dynamic_get_city():
- data = cities + ["郑州", "石家庄"]
- start = random.randint(0, len(data))
- end = random.randint(start, len(data))
- return data[start:end]
-
- self.register_field("button3_selected", "")
- menu3 = MMenu(parent=self)
- menu3.set_load_callback(dynamic_get_city)
- select3 = MComboBox()
- select3.set_menu(menu3)
- self.bind("button3_selected", select3, "value", signal="sig_value_changed")
-
- a = [
- {
- "children": [
- {"value": "\u6545\u5bab", "label": "\u6545\u5bab"},
- {"value": "\u5929\u575b", "label": "\u5929\u575b"},
- {"value": "\u738b\u5e9c\u4e95", "label": "\u738b\u5e9c\u4e95"},
- ],
- "value": "\u5317\u4eac",
- "label": "\u5317\u4eac",
- },
- {
- "children": [
- {
- "children": [
- {
- "value": "\u592b\u5b50\u5e99",
- "label": "\u592b\u5b50\u5e99",
- }
- ],
- "value": "\u5357\u4eac",
- "label": "\u5357\u4eac",
- },
- {
- "children": [
- {
- "value": "\u62d9\u653f\u56ed",
- "label": "\u62d9\u653f\u56ed",
- },
- {
- "value": "\u72ee\u5b50\u6797",
- "label": "\u72ee\u5b50\u6797",
- },
- ],
- "value": "\u82cf\u5dde",
- "label": "\u82cf\u5dde",
- },
- ],
- "value": "\u6c5f\u82cf",
- "label": "\u6c5f\u82cf",
- },
- ]
-
- self.register_field("button4_selected", "")
- menu4 = MMenu(cascader=True, parent=self)
- menu4.set_data(a)
- select4 = MComboBox()
- select4.set_menu(menu4)
- select4.set_formatter(lambda x: " / ".join(x))
- self.bind("button4_selected", select4, "value", signal="sig_value_changed")
-
- self.register_field("button5_selected", "")
- menu5 = MMenu(exclusive=False, parent=self)
- menu5.set_data(cities)
- select5 = MComboBox()
- select5.set_menu(menu5)
- select5.set_formatter(lambda x: " & ".join(x))
- self.bind("button5_selected", select5, "value", signal="sig_value_changed")
-
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(MLabel("普通单选各种尺寸"))
- sub_lay1.addLayout(size_lay)
- sub_lay1.addStretch()
- sub_lay2 = QtWidgets.QHBoxLayout()
- sub_lay2.addWidget(MLabel("多选"))
- sub_lay2.addWidget(select2)
- sub_lay2.addStretch()
- sub_lay3 = QtWidgets.QHBoxLayout()
- sub_lay3.addWidget(MLabel("动态生成选项"))
- sub_lay3.addWidget(select3)
- sub_lay3.addStretch()
- sub_lay4 = QtWidgets.QHBoxLayout()
- sub_lay4.addWidget(MLabel("级联选择"))
- sub_lay4.addWidget(select4)
- sub_lay4.addStretch()
- sub_lay5 = QtWidgets.QHBoxLayout()
- sub_lay5.addWidget(MLabel("自定义显示"))
- sub_lay5.addWidget(select5)
- sub_lay5.addStretch()
-
- sub_lay6 = QtWidgets.QHBoxLayout()
- combo = MComboBox()
- items = cities + ["北戴河"]
-
- items += ["a" * i for i in range(20)]
- combo.addItems(items)
- combo.setProperty("searchable", True)
- sub_lay6.addWidget(MLabel("搜索补全"))
- sub_lay6.addWidget(combo)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Select"))
- main_lay.addLayout(sub_lay1)
- main_lay.addLayout(sub_lay2)
- main_lay.addLayout(sub_lay3)
- main_lay.addWidget(MDivider("自定义格式"))
- main_lay.addLayout(sub_lay4)
- main_lay.addLayout(sub_lay5)
- main_lay.addLayout(sub_lay6)
- main_lay.addStretch()
-
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ComboBoxExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/delegate_button_example.py b/examples/delegate_button_example.py
deleted file mode 100644
index a5653e48..00000000
--- a/examples/delegate_button_example.py
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets import utils
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MTableView
-
-
-class MPushButtonDelegate(QtWidgets.QStyledItemDelegate):
- sig_clicked = QtCore.Signal(object)
-
- def __init__(self, parent=None):
- super(MPushButtonDelegate, self).__init__(parent)
- self.editor = None
- self.showed = False
- self.exclusive = True
- self.parent_widget = None
-
- def editorEvent(self, pEvent, model, option, index):
- if pEvent.type() == QtCore.QEvent.MouseButtonRelease:
- index = utils.real_index(index)
- self.sig_clicked.emit(index.internalPointer())
- return True
- return False
-
- def paint(self, painter, option, index):
- button = QtWidgets.QStyleOptionButton()
- button.rect = option.rect
- button.text = "Click Me (" + str(index.data(QtCore.Qt.DisplayRole)) + ")"
- button.state = QtWidgets.QStyle.State_Enabled
-
- QtWidgets.QApplication.style().drawControl(
- QtWidgets.QStyle.CE_PushButton, button, painter
- )
-
-
-header_list = [
- {
- "label": "Name",
- "key": "name",
- "checkable": True,
- "searchable": True,
- "width": 200,
- "font": lambda x, y: {"underline": True},
- "icon": "user_fill.svg",
- },
- {
- "label": "Sex",
- "key": "sex",
- "searchable": True,
- "selectable": True,
- "icon": lambda x, y: (
- "{}.svg".format(x.lower()),
- getattr(dayu_theme, x.lower() + "_color"),
- ),
- },
- {
- "label": "Age",
- "key": "age",
- "width": 90,
- "searchable": True,
- "editable": True,
- "display": lambda x, y: "{} 岁".format(x),
- "font": lambda x, y: {"bold": True},
- },
- {
- "label": "Address",
- "key": "city",
- "selectable": True,
- "searchable": True,
- "exclusive": False,
- "width": 120,
- "display": lambda x, y: " & ".join(x) if isinstance(x, list) else x,
- "bg_color": lambda x, y: "transparent" if x else dayu_theme.error_color,
- },
- {
- "label": "Score",
- "key": "score",
- },
-]
-
-
-class DelegateButtonExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(DelegateButtonExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- model_1 = MTableModel()
- model_1.set_header_list(header_list)
- model_sort = MSortFilterModel()
- model_sort.setSourceModel(model_1)
-
- table_grid = MTableView(size=dayu_theme.small, show_row_count=True)
- table_grid.setShowGrid(True)
- table_grid.setModel(model_sort)
- model_sort.set_header_list(header_list)
- table_grid.set_header_list(header_list)
- button_delegate = MPushButtonDelegate(parent=self)
- table_grid.setItemDelegateForColumn(4, button_delegate)
- button_delegate.sig_clicked.connect(self.slot_cell_clicked)
- model_1.set_data_list(
- [
- {
- "name": "John Brown",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 18,
- "score": 89,
- "city": "New York",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-03",
- },
- {
- "name": "Jim Green",
- "sex": "Male",
- "sex_list": ["Male", "Female"],
- "age": 24,
- "score": 55,
- "city": "London",
- "city_list": ["New York", "Ottawa", "London", "Sydney"],
- "date": "2016-10-01",
- },
- ]
- )
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(table_grid)
- self.setLayout(main_lay)
-
- def slot_cell_clicked(self, data_dict):
- print(data_dict)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = DelegateButtonExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/demo.py b/examples/demo.py
deleted file mode 100644
index 4b8d3dc2..00000000
--- a/examples/demo.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import signal
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-
-signal.signal(signal.SIGINT, signal.SIG_DFL)
-
-# Import built-in modules
-import importlib
-import os
-
-# Import third-party modules
-import Qt
-
-
-# Qt.py global variable for preferred Qt binding
-# os.environ["QT_PREFERRED_BINDING"] = "PyQt4;PyQt5;PySide;PySide2"
-# For Houdini hython.exe
-# os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = r"E:\Houdini18\bin\Qt_plugins\platforms"
-
-
-print(Qt.__binding__)
-
-# Import built-in modules
-import codecs
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.dock_widget import MDockWidget
-from dayu_widgets.item_view_set import MItemViewSet
-
-
-def get_test_widget():
- result = []
- DIR = os.path.dirname(__file__)
- for i in os.listdir(DIR):
- if i.startswith("__") or (not i.endswith(".py")) or i == "demo.py":
- continue
- name = i.split(".")[0]
- module_name = "examples.{component}".format(component=name)
- class_name = "".join(map(lambda x: x.title(), name.split("_")))
- module = importlib.import_module(module_name, class_name)
- if hasattr(module, class_name):
- with codecs.open(os.path.join(DIR, "%s.py" % name), encoding="utf-8") as f:
- result.append((name, getattr(module, class_name), f.readlines()))
- return result
-
-
-class MDemo(QtWidgets.QMainWindow):
- def __init__(self, parent=None):
- super(MDemo, self).__init__(parent)
- self.setWindowTitle("Dayu Widgets Demo")
- self._init_ui()
-
- def _init_ui(self):
- self.text_edit = QtWidgets.QTextEdit()
- self.stacked_widget = QtWidgets.QStackedWidget()
-
- list_widget = MItemViewSet(view_type=MItemViewSet.ListViewType)
- list_widget.set_header_list(
- [{"key": "name", "label": "Name", "icon": "list_view.svg"}]
- )
- list_widget.sig_left_clicked.connect(self.slot_change_widget)
- data_list = []
- for index, (name, cls, code) in enumerate(get_test_widget()):
- data_list.append({"name": name[:-8], "data": code})
- if not callable(cls):
- continue
- widget = cls()
- widget.setProperty("code", code)
- self.stacked_widget.addWidget(widget)
- list_widget.setup_data(data_list)
-
- test_widget = MDockWidget("Example List")
- test_widget.setWidget(list_widget)
- self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, test_widget)
-
- code_widget = MDockWidget("Example Code")
- code_widget.setWidget(self.text_edit)
- self.addDockWidget(QtCore.Qt.RightDockWidgetArea, code_widget)
- self.setCentralWidget(self.stacked_widget)
-
- def slot_change_widget(self, index):
- self.stacked_widget.setCurrentIndex(index.row())
- widget = self.stacked_widget.widget(index.row())
- self.text_edit.setPlainText("".join(widget.property("code")))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = MDemo()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/divider_example.py b/examples/divider_example.py
deleted file mode 100644
index a3002b66..00000000
--- a/examples/divider_example.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-
-
-class DividerExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(DividerExample, self).__init__(parent)
- self.setWindowTitle("Examples for MDivider")
- self._init_ui()
-
- def _init_ui(self):
- div1 = MDivider()
- div2 = MDivider("With Text")
- div3 = MDivider.left("Left Text")
- div4 = MDivider.center("Center Text")
- div5 = MDivider.right("Right Text")
- div6 = MDivider.vertical()
- div7 = MDivider.vertical()
- div8 = MDivider.left("orientation=Qt.Vertical")
- label1 = MLabel("Maya").strong()
- label2 = MLabel("Nuke").underline()
- label3 = MLabel("Houdini").mark()
- sub_lay = QtWidgets.QHBoxLayout()
- sub_lay.addWidget(label1)
- sub_lay.addWidget(div6)
- sub_lay.addWidget(label2)
- sub_lay.addWidget(div7)
- sub_lay.addWidget(label3)
- sub_lay.addStretch()
-
- some_text = (
- "Steven Paul Jobs was an American entrepreneur and business magnate."
- )
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MLabel(some_text))
- main_lay.addWidget(div1)
- main_lay.addWidget(MLabel(some_text))
- main_lay.addWidget(div2)
- main_lay.addWidget(MLabel(some_text))
- main_lay.addWidget(div3)
- main_lay.addWidget(MLabel(some_text))
- main_lay.addWidget(div4)
- main_lay.addWidget(MLabel(some_text))
- main_lay.addWidget(div5)
- main_lay.addLayout(sub_lay)
- main_lay.addWidget(div8)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def computed_text(self):
- return "Clicked: " + str(self.field("count"))
-
- def slot_change_divider_text(self):
- self.set_field("count", self.field("count") + 1)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = DividerExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/drawer_example.py b/examples/drawer_example.py
deleted file mode 100644
index 005ac1ca..00000000
--- a/examples/drawer_example.py
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.6
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MRadioButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.drawer import MDrawer
-from dayu_widgets.label import MLabel
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-from dayu_widgets.qt import get_scale_factor
-from dayu_widgets.spin_box import MDateEdit
-from dayu_widgets.spin_box import MSpinBox
-
-
-class DrawerExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(DrawerExample, self).__init__(parent)
- self.setWindowTitle("Examples for MDrawer")
- self._init_ui()
-
- def _init_ui(self):
- scale_x, _ = get_scale_factor()
- self.button_grp = MRadioButtonGroup()
- self.button_grp.set_button_list(
- ["top", {"text": "right", "checked": True}, "bottom", "left"]
- )
-
- open_button_2 = MPushButton("Open").primary()
- open_button_2.clicked.connect(self.slot_open_button_2)
- placement_lay = QtWidgets.QHBoxLayout()
- placement_lay.addWidget(self.button_grp)
- placement_lay.addSpacing(20 * scale_x)
- placement_lay.addWidget(open_button_2)
- placement_lay.addStretch()
-
- new_account_button = MPushButton(
- text="New account", icon=MIcon("add_line.svg", "#fff")
- ).primary()
- new_account_button.clicked.connect(self.slot_new_account)
- new_account_lay = QtWidgets.QHBoxLayout()
- new_account_lay.addWidget(MLabel("Submit form in drawer"))
- new_account_lay.addWidget(new_account_button)
- new_account_lay.addStretch()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Custom Placement"))
- main_lay.addLayout(placement_lay)
- main_lay.addWidget(MDivider("Submit form in drawer"))
- main_lay.addLayout(new_account_lay)
-
- main_lay.addWidget(MDivider("Preview drawer"))
- self.setLayout(main_lay)
-
- def slot_open_button(self):
- custom_widget = QtWidgets.QWidget()
- custom_lay = QtWidgets.QVBoxLayout()
- custom_lay.addWidget(MLabel("Some contents..."))
- custom_lay.addWidget(MLabel("Some contents..."))
- custom_lay.addWidget(MLabel("Some contents..."))
- custom_widget.setLayout(custom_lay)
-
- drawer = MDrawer("Basic Drawer", parent=self).left()
- scale_x, _ = get_scale_factor()
- drawer.setFixedWidth(300 * scale_x)
- drawer.set_widget(custom_widget)
- drawer.show()
-
- def slot_open_button_2(self):
- custom_widget = QtWidgets.QWidget()
- custom_lay = QtWidgets.QVBoxLayout()
- custom_lay.addWidget(MLabel("Some contents..."))
- custom_lay.addWidget(MLabel("Some contents..."))
- custom_lay.addWidget(MLabel("Some contents..."))
- custom_widget.setLayout(custom_lay)
-
- drawer = MDrawer("Basic Drawer", parent=self)
- drawer.set_dayu_position(
- self.button_grp.get_button_group().checkedButton().text()
- )
-
- scale_x, _ = get_scale_factor()
- drawer.setFixedWidth(300 * scale_x)
- drawer.set_widget(custom_widget)
- drawer.show()
-
- def slot_new_account(self):
- custom_widget = QtWidgets.QWidget()
- custom_lay = QtWidgets.QFormLayout()
- custom_lay.addRow("Name", MLineEdit())
- custom_lay.addRow("Age", MSpinBox())
- custom_lay.addRow("Birth", MDateEdit())
- custom_widget.setLayout(custom_lay)
-
- drawer = MDrawer("New account", parent=self)
- submit_button = MPushButton("Submit").primary()
- submit_button.clicked.connect(drawer.close)
- drawer.add_widget_to_bottom(MPushButton("Cancel"))
- drawer.add_widget_to_bottom(submit_button)
- scale_x, _ = get_scale_factor()
- drawer.setFixedWidth(300 * scale_x)
- drawer.set_widget(custom_widget)
- drawer.show()
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = DrawerExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/field_mixin_example.py b/examples/field_mixin_example.py
deleted file mode 100644
index 5126749b..00000000
--- a/examples/field_mixin_example.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MPixmap
-
-
-class FieldMixinExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(FieldMixinExample, self).__init__(parent)
- self.register_field("my_name", "xiaoming")
- self.register_field("thumbnail_path", "")
- self.register_field("is_enable", True)
- self.register_field("status", "waiting")
- self.register_field("str_enable", self.computed_str_enable)
- self.register_field("thumbnail_pix_map", self.computed_thumbnail_pix_map)
- self.register_field("email", self.computed_email)
-
- name2_label = MLabel()
- email_label = MLabel()
- thumbnail_label = MLabel()
- enable_button = MPushButton().primary()
- self.bind("my_name", name2_label, "dayu_text")
- self.bind("email", email_label, "dayu_text")
- self.bind("is_enable", enable_button, "enabled")
- self.bind("thumbnail_pix_map", thumbnail_label, "pixmap")
- self.bind("str_enable", enable_button, "text")
-
- button = MPushButton(text="Change Data").primary()
- button.clicked.connect(self.slot_change_data)
- main_lay = QtWidgets.QGridLayout()
- main_lay.addWidget(MLabel("Avatar:"), 0, 0)
- main_lay.addWidget(thumbnail_label, 0, 1)
- main_lay.addWidget(MLabel("Name:"), 1, 0)
- main_lay.addWidget(
- self.bind("my_name", MLineEdit(), "text", signal="textEdited"), 1, 1
- )
- main_lay.addWidget(MLabel("Email:"), 2, 0)
- main_lay.addWidget(email_label, 2, 1)
- main_lay.addWidget(MLabel("Enabled:"), 3, 0)
- main_lay.addWidget(enable_button, 3, 1)
- # for index, i in enumerate(self.field('my_name')):
- # main_lay.addRow('name{}:'.format(index), self.bind('my_name', QLabel(), 'text', index=index))
- main_lay.addWidget(button, 4, 1)
-
- temp_lay = QtWidgets.QVBoxLayout()
- temp_lay.addLayout(main_lay)
- temp_lay.addStretch()
- self.setLayout(temp_lay)
-
- def computed_str_enable(self):
- return "Enabled" if self.field("is_enable") else "Disabled"
-
- def computed_thumbnail_pix_map(self):
- return MPixmap(self.field("thumbnail_path"))
-
- def computed_email(self):
- return "{}@phenom-films.com".format(self.field("my_name"))
-
- def slot_change_data(self):
- # Import built-in modules
- import random
-
- self.set_field(
- "my_name",
- random.choice(["xiaoming", "xiaohua", "xiaohong", "hahaha", "lalalala"]),
- )
- self.set_field(
- "thumbnail_path",
- "app-{}.png".format(random.choice(["maya", "nuke", "houdini"])),
- )
- self.set_field("is_enable", bool(random.randint(0, 1)))
- self.set_field("status", "haha")
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = FieldMixinExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/item_view_big_type_example.py b/examples/item_view_big_type_example.py
deleted file mode 100644
index a4a8e513..00000000
--- a/examples/item_view_big_type_example.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtGui
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets import utils as dayu_utils
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.item_view_set import MItemViewSet
-from dayu_widgets.tool_button import MToolButton
-import examples._mock_data as mock
-
-
-class ItemViewBigTypeExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ItemViewBigTypeExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- item_view_set_thumbnail = MItemViewSet(view_type=MItemViewSet.BigViewType)
- item_view_set_thumbnail.set_header_list(
- [
- {
- "label": "Name",
- "key": "name",
- "searchable": True,
- "font": lambda x, y: {"underline": True},
- "icon": lambda x, y: y.get("icon"),
- }
- ]
- )
- add_button = MToolButton().svg("add_line.svg")
- add_button.clicked.connect(
- functools.partial(item_view_set_thumbnail.item_view.scale_size, 1.1)
- )
- minus_button = MToolButton().svg("minus_line.svg")
- minus_button.clicked.connect(
- functools.partial(item_view_set_thumbnail.item_view.scale_size, 0.8)
- )
- button_lay = QtWidgets.QHBoxLayout()
- button_lay.addWidget(minus_button)
- button_lay.addWidget(add_button)
- button_lay.addStretch()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Big View"))
- main_lay.addLayout(button_lay)
- main_lay.addWidget(item_view_set_thumbnail)
- self.setLayout(main_lay)
- for data_dict in mock.data_list:
- icon = QtGui.QIcon(
- dayu_utils.generate_text_pixmap(
- 400,
- 400,
- data_dict.get("name") + "_" + data_dict.get("sex"),
- bg_color=dayu_theme.background_selected_color,
- )
- )
- data_dict.update({"icon": icon})
- item_view_set_thumbnail.setup_data((mock.data_list * 100))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ItemViewBigTypeExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/item_view_full_set_example.py b/examples/item_view_full_set_example.py
deleted file mode 100644
index 00b0ee9e..00000000
--- a/examples/item_view_full_set_example.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import utils
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.item_view_full_set import MItemViewFullSet
-from dayu_widgets.push_button import MPushButton
-import examples._mock_data as mock
-
-
-@utils.add_settings("DaYu", "DaYuExample", event_name="hideEvent")
-class ItemViewFullSetExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ItemViewFullSetExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- item_view_set_table = MItemViewFullSet()
- item_view_set_table.set_header_list(mock.header_list)
-
- item_view_set_all = MItemViewFullSet(big_view=True)
- item_view_set_all.set_header_list(mock.header_list)
-
- refresh_button = MPushButton("Refresh Data")
- refresh_button.clicked.connect(self.slot_update_data)
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Only Table View"))
- main_lay.addWidget(refresh_button)
- main_lay.addWidget(item_view_set_table)
- main_lay.addWidget(MDivider("Table View and Big View"))
- main_lay.addWidget(item_view_set_all)
- self.setLayout(main_lay)
-
- self.view_list = [
- item_view_set_table,
- item_view_set_all,
- ]
- self.bind(
- "item_view_full_set_example_header_state",
- item_view_set_table.table_view.header_view,
- "state",
- )
- self.slot_update_data()
-
- def slot_update_data(self):
- for view in self.view_list:
- view.setup_data(mock.data_list)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ItemViewFullSetExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/item_view_set_example.py b/examples/item_view_set_example.py
deleted file mode 100644
index 1eab4ffb..00000000
--- a/examples/item_view_set_example.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import utils
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.item_view_set import MItemViewSet
-from dayu_widgets.push_button import MPushButton
-import examples._mock_data as mock
-
-
-@utils.add_settings("DaYu", "DaYuExample", event_name="hideEvent")
-class ItemViewSetExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ItemViewSetExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- item_view_set_table = MItemViewSet(view_type=MItemViewSet.TableViewType)
- item_view_set_table.set_header_list(mock.header_list)
- item_view_set_list = MItemViewSet(view_type=MItemViewSet.ListViewType)
- item_view_set_list.set_header_list(mock.header_list)
- item_view_set_tree = MItemViewSet(view_type=MItemViewSet.TreeViewType)
- item_view_set_tree.set_header_list(mock.header_list)
- item_view_set_thumbnail = MItemViewSet(view_type=MItemViewSet.BigViewType)
- item_view_set_thumbnail.set_header_list(mock.header_list)
-
- item_view_set_search = MItemViewSet(view_type=MItemViewSet.TreeViewType)
- item_view_set_search.set_header_list(mock.header_list)
- item_view_set_search.searchable()
- expand_button = MPushButton("Expand All")
- expand_button.clicked.connect(item_view_set_search.item_view.expandAll)
- coll_button = MPushButton("Collapse All")
- coll_button.clicked.connect(item_view_set_search.item_view.collapseAll)
- item_view_set_search.insert_widget(coll_button)
- item_view_set_search.insert_widget(expand_button)
-
- refresh_button = MPushButton("Refresh Data")
- refresh_button.clicked.connect(self.slot_update_data)
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Table View"))
- main_lay.addWidget(refresh_button)
- main_lay.addWidget(item_view_set_table)
- main_lay.addWidget(MDivider("List View"))
- main_lay.addWidget(item_view_set_list)
- main_lay.addWidget(MDivider("Tree View"))
- main_lay.addWidget(item_view_set_tree)
- main_lay.addWidget(MDivider("Big View"))
- main_lay.addWidget(item_view_set_thumbnail)
- main_lay.addWidget(MDivider("With Search line edit"))
- main_lay.addWidget(item_view_set_search)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- item_view_set_tree.setup_data(mock.tree_data_list)
- item_view_set_search.setup_data(mock.tree_data_list)
- self.view_list = [
- item_view_set_table,
- item_view_set_list,
- item_view_set_thumbnail,
- ]
- self.bind(
- "item_view_set_example_header_state",
- item_view_set_table.item_view.header_view,
- "state",
- )
- self.slot_update_data()
-
- def slot_update_data(self):
- for view in self.view_list:
- view.setup_data(mock.data_list)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ItemViewSetExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/label_example.py b/examples/label_example.py
deleted file mode 100644
index f2bda7a2..00000000
--- a/examples/label_example.py
+++ /dev/null
@@ -1,157 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-
-
-class LabelExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(LabelExample, self).__init__(parent)
- self.setWindowTitle("Examples for MLabel")
- self._init_ui()
-
- def _init_ui(self):
- title_lay = QtWidgets.QGridLayout()
- title_lay.addWidget(MLabel("一级标题").h1(), 0, 0)
- title_lay.addWidget(MLabel("二级标题").h2(), 1, 0)
- title_lay.addWidget(MLabel("三级标题").h3(), 2, 0)
- title_lay.addWidget(MLabel("四级标题").h4(), 3, 0)
- title_lay.addWidget(MLabel("h1 Level").h1(), 0, 1)
- title_lay.addWidget(MLabel("h2 Level").h2(), 1, 1)
- title_lay.addWidget(MLabel("h3 Level").h3(), 2, 1)
- title_lay.addWidget(MLabel("h4 Level").h4(), 3, 1)
-
- text_type_lay = QtWidgets.QHBoxLayout()
- text_type_lay.addWidget(MLabel("MLabel: Normal"))
- text_type_lay.addWidget(MLabel("MLabel: Secondary").secondary())
- text_type_lay.addWidget(MLabel("MLabel: Warning").warning())
- text_type_lay.addWidget(MLabel("MLabel: Danger").danger())
- disable_text = MLabel("MLabel: Disabled")
- disable_text.setEnabled(False)
- text_type_lay.addWidget(disable_text)
-
- text_attr_lay = QtWidgets.QHBoxLayout()
- text_attr_lay.addWidget(MLabel("MLabel: Mark").mark())
- text_attr_lay.addWidget(MLabel("MLabel: Code").code())
- text_attr_lay.addWidget(MLabel("MLabel: Underline").underline())
- text_attr_lay.addWidget(MLabel("MLabel: Delete").delete())
- text_attr_lay.addWidget(MLabel("MLabel: Strong").strong())
-
- text_mix_lay = QtWidgets.QHBoxLayout()
- text_mix_lay.addWidget(
- MLabel("MLabel: Strong & Underline").strong().underline()
- )
- text_mix_lay.addWidget(MLabel("MLabel: Danger & Delete").danger().delete())
- text_mix_lay.addWidget(MLabel("MLabel: Warning & Strong").warning().strong())
- text_mix_lay.addWidget(MLabel("MLabel: H4 & Mark").h4().mark())
-
- data_bind_lay = QtWidgets.QHBoxLayout()
- data_bind_label = MLabel()
- button = MPushButton(text="Random An Animal").primary()
- button.clicked.connect(self.slot_change_text)
- data_bind_lay.addWidget(data_bind_label)
- data_bind_lay.addWidget(button)
- data_bind_lay.addStretch()
- self.register_field("show_text", "Guess")
- self.bind("show_text", data_bind_label, "text")
-
- lay_elide = QtWidgets.QVBoxLayout()
- label_none = MLabel(
- "This is a elide NONE mode label. "
- "Ellipsis should NOT appear in the text."
- )
- label_left = MLabel(
- "This is a elide LEFT mode label. "
- "The ellipsis should appear at the beginning of the text. "
- "xiao mao xiao gou xiao ci wei"
- )
- label_left.set_elide_mode(QtCore.Qt.ElideLeft)
- label_middle = MLabel(
- "This is a elide MIDDLE mode label. "
- "The ellipsis should appear in the middle of the text. "
- "xiao mao xiao gou xiao ci wei"
- )
- label_middle.set_elide_mode(QtCore.Qt.ElideMiddle)
- label_right = MLabel()
- label_right.setText(
- "This is a elide RIGHT mode label. "
- "The ellipsis should appear at the end of the text. "
- "Some text to fill the line bala bala bala."
- )
- label_right.set_elide_mode(QtCore.Qt.ElideRight)
- lay_elide.addWidget(label_none)
- lay_elide.addWidget(label_left)
- lay_elide.addWidget(label_middle)
- lay_elide.addWidget(label_right)
-
- hyper_label_1 = MLabel()
- hyper_label_1.set_link("https://baidu.com", text="baidu")
- hyper_label_2 = MLabel()
- hyper_label_2.set_link("https://baidu.com")
- hyper_label_3 = MLabel()
- hyper_label_3.set_link(
- "https://github.com/phenom-films/dayu_widgets", text="Dayu Widgets"
- )
-
- hyperlink_lay = QtWidgets.QVBoxLayout()
- hyperlink_lay.addWidget(hyper_label_1)
- hyperlink_lay.addWidget(hyper_label_2)
- hyperlink_lay.addWidget(hyper_label_3)
- # hyperlink_lay.addWidget()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different level"))
- main_lay.addLayout(title_lay)
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(text_type_lay)
- main_lay.addWidget(MDivider("different property"))
- main_lay.addLayout(text_attr_lay)
- main_lay.addWidget(MDivider("mix"))
- main_lay.addLayout(text_mix_lay)
-
- # main_lay.addWidget(MDivider('data bind'))
- # main_lay.addLayout(data_bind_lay)
- main_lay.addWidget(MDivider("elide mode"))
- main_lay.addLayout(lay_elide)
- main_lay.addWidget(MDivider("hyperlink"))
- main_lay.addLayout(hyperlink_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_change_text(self):
- # Import built-in modules
- import random
-
- self.set_field("show_text", random.choice(["Dog", "Cat", "Rabbit", "Cow"]))
-
- def slot_link_text(self):
- self.set_field("is_link", not self.field("is_link"))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = LabelExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/line_edit_example.py b/examples/line_edit_example.py
deleted file mode 100644
index 917754ed..00000000
--- a/examples/line_edit_example.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.combo_box import MComboBox
-from dayu_widgets.divider import MDivider
-from dayu_widgets.label import MLabel
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.menu import MMenu
-from dayu_widgets.message import MMessage
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.tool_button import MToolButton
-
-
-class LineEditExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(LineEditExample, self).__init__(parent)
- self.setWindowTitle("Examples for MLineEdit")
- self._init_ui()
-
- def _init_ui(self):
- size_lay = QtWidgets.QHBoxLayout()
- line_edit_l = MLineEdit().large()
- line_edit_l.setPlaceholderText("large size")
- line_edit_m = MLineEdit().medium()
- line_edit_m.setPlaceholderText("default size")
- line_edit_s = MLineEdit().small()
- line_edit_s.setPlaceholderText("small size")
- size_lay.addWidget(line_edit_l)
- size_lay.addWidget(line_edit_m)
- size_lay.addWidget(line_edit_s)
-
- line_edit_tool_button = MLineEdit(text="MToolButton")
- line_edit_tool_button.set_prefix_widget(
- MToolButton().svg("user_line.svg").icon_only()
- )
-
- line_edit_label = MLineEdit(text="MLabel")
- tool_button = MLabel(text="User").mark().secondary()
- tool_button.setAlignment(QtCore.Qt.AlignCenter)
- tool_button.setFixedWidth(80)
- line_edit_label.set_prefix_widget(tool_button)
-
- line_edit_push_button = MLineEdit(text="MPushButton")
- push_button = MPushButton(text="Go").primary()
- push_button.setFixedWidth(40)
- line_edit_push_button.set_suffix_widget(push_button)
-
- search_engine_line_edit = MLineEdit().search_engine().large()
- search_engine_line_edit.returnPressed.connect(self.slot_search)
-
- line_edit_options = MLineEdit()
- combobox = MComboBox()
- option_menu = MMenu()
- option_menu.set_separator("|")
- option_menu.set_data([r"http://", r"https://"])
- combobox.set_menu(option_menu)
- combobox.set_value("http://")
- combobox.setFixedWidth(100)
- line_edit_options.set_prefix_widget(combobox)
-
- delay_line_editor = MLineEdit()
- delay_display_label = MLabel()
- delay_button = MPushButton("Click to Edit Text")
- delay_line_editor.sig_delay_text_changed.connect(delay_display_label.setText)
- delay_button.clicked.connect(
- functools.partial(delay_line_editor.setText, "Edited from code")
- )
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different size"))
- main_lay.addLayout(size_lay)
- main_lay.addWidget(MDivider("custom prefix and suffix widget"))
- main_lay.addWidget(line_edit_tool_button)
- main_lay.addWidget(line_edit_label)
- main_lay.addWidget(line_edit_push_button)
- main_lay.addWidget(MDivider("preset"))
-
- main_lay.addWidget(MLabel("error"))
- main_lay.addWidget(
- MLineEdit(text="waring: file d:/ddd/ccc.jpg not exists.").error()
- )
- main_lay.addWidget(MLabel("search"))
- main_lay.addWidget(MLineEdit().search().small())
- main_lay.addWidget(MLabel("search_engine"))
- main_lay.addWidget(search_engine_line_edit)
- main_lay.addWidget(MLabel("file"))
- main_lay.addWidget(MLineEdit().file().small())
- main_lay.addWidget(MLabel("folder"))
- main_lay.addWidget(MLineEdit().folder().small())
- main_lay.addWidget(MLabel("MLineEdit.options()"))
- main_lay.addWidget(line_edit_options)
- main_lay.addWidget(MDivider("Test delay Signal"))
- main_lay.addWidget(delay_line_editor)
- main_lay.addWidget(delay_display_label)
- main_lay.addWidget(delay_button)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- @QtCore.Slot()
- def slot_search(self):
- MMessage.info("查无此人", parent=self)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = LineEditExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/line_tab_widget_example.py b/examples/line_tab_widget_example.py
deleted file mode 100644
index a7e465dd..00000000
--- a/examples/line_tab_widget_example.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.divider import MDivider
-from dayu_widgets.label import MLabel
-from dayu_widgets.line_tab_widget import MLineTabWidget
-from dayu_widgets.tool_button import MToolButton
-
-
-class LineTabWidgetExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(LineTabWidgetExample, self).__init__(parent)
- self.setWindowTitle("Example for MLineTabWidget")
- self._init_ui()
-
- def _init_ui(self):
- main_lay = QtWidgets.QVBoxLayout()
-
- tab_center = MLineTabWidget()
- tab_center.add_tab(
- MLabel("test 1 " * 10), {"text": "Tab 1", "svg": "user_line.svg"}
- )
- tab_center.add_tab(MLabel("test 2 " * 10), {"svg": "calendar_line.svg"})
- tab_center.add_tab(MLabel("test 3 " * 10), "Tab 3")
- tab_center.tool_button_group.set_dayu_checked(0)
-
- tab_left = MLineTabWidget(alignment=QtCore.Qt.AlignLeft)
- tab_left.add_tab(MLabel("test 1 " * 10), "Tab 1")
- tab_left.add_tab(MLabel("test 2 " * 10), "Tab 2")
- tab_left.add_tab(MLabel("test 3 " * 10), "Tab 3")
- tab_left.tool_button_group.set_dayu_checked(0)
-
- tab_right = MLineTabWidget(alignment=QtCore.Qt.AlignRight)
- tab_right.add_tab(MLabel("test 1 " * 10), "Tab 1")
- tab_right.add_tab(MLabel("test 2 " * 10), "Tab 2")
- tab_right.add_tab(MLabel("test 3 " * 10), "Tab 3")
- tab_right.tool_button_group.set_dayu_checked(0)
-
- tab_huge = MLineTabWidget()
- tab_huge.set_dayu_size(dayu_theme.huge)
- tab_huge.add_tab(
- MLabel("test 1 " * 10), {"text": "Tab 1", "svg": "user_line.svg"}
- )
- tab_huge.add_tab(MLabel("test 2 " * 10), "Tab 2")
- tab_huge.add_tab(MLabel("test 3 " * 10), "Tab 3")
- tab_huge.tool_button_group.set_dayu_checked(0)
-
- tab_append_insert = MLineTabWidget()
- tab_append_insert.add_tab(
- MLabel("test 1 " * 10), {"text": "Tab 1", "svg": "user_line.svg"}
- )
- tab_append_insert.add_tab(MLabel("test 2 " * 10), "Tab 2")
- tab_append_insert.add_tab(MLabel("test 3 " * 10), "Tab 3")
- tab_append_insert.tool_button_group.set_dayu_checked(0)
- tab_append_insert.insert_widget(MLabel("Insert Label").h4())
- tab_append_insert.append_widget(
- MToolButton().svg("refresh_line.svg").icon_only()
- )
-
- main_lay.addWidget(MDivider("Center"))
- main_lay.addWidget(tab_center)
- main_lay.addSpacing(20)
- main_lay.addWidget(MDivider("Left"))
- main_lay.addWidget(tab_left)
- main_lay.addSpacing(20)
- main_lay.addWidget(MDivider("Right"))
- main_lay.addWidget(tab_right)
- main_lay.addSpacing(20)
- main_lay.addWidget(MDivider("Huge"))
- main_lay.addWidget(tab_huge)
- main_lay.addWidget(MDivider("append_widget/insert_widget"))
- main_lay.addWidget(tab_append_insert)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = LineTabWidgetExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/list_view_example.py b/examples/list_view_example.py
deleted file mode 100644
index de922b50..00000000
--- a/examples/list_view_example.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MListView
-from dayu_widgets.line_edit import MLineEdit
-import examples._mock_data as mock
-
-
-class ListViewExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ListViewExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- table_small = MListView(size=dayu_theme.small)
- table_default = MListView()
- table_large = MListView(size=dayu_theme.large)
-
- model_1 = MTableModel()
- model_1.set_header_list(mock.header_list)
- model_sort = MSortFilterModel()
- model_sort.setSourceModel(model_1)
- table_small.setModel(model_sort)
- table_default.setModel(model_sort)
- table_large.setModel(model_sort)
- model_sort.set_header_list(mock.header_list)
- table_small.set_header_list(mock.header_list)
- table_default.set_header_list(mock.header_list)
- table_large.set_header_list(mock.header_list)
- model_1.set_data_list(mock.data_list)
-
- line_edit = MLineEdit().search().small()
- line_edit.textChanged.connect(model_sort.set_search_pattern)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(line_edit)
- main_lay.addWidget(MDivider("Small Size"))
- main_lay.addWidget(table_small)
- main_lay.addWidget(MDivider("Default Size"))
- main_lay.addWidget(table_default)
- main_lay.addWidget(MDivider("Large Size"))
- main_lay.addWidget(table_large)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ListViewExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/loading_example.py b/examples/loading_example.py
deleted file mode 100644
index 5c6b79a5..00000000
--- a/examples/loading_example.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.loading import MLoading
-
-
-class LoadingExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(LoadingExample, self).__init__(parent)
- self.setWindowTitle("Examples for MLoading")
- self._init_ui()
-
- def _init_ui(self):
- size_lay = QtWidgets.QHBoxLayout()
- size_list = [
- ("Huge", MLoading.huge),
- ("Large", MLoading.large),
- ("Medium", MLoading.medium),
- ("Small", MLoading.small),
- ("Tiny", MLoading.tiny),
- ]
- for label, cls in size_list:
- size_lay.addWidget(MLabel(label))
- size_lay.addWidget(cls())
- size_lay.addSpacing(10)
-
- color_lay = QtWidgets.QHBoxLayout()
- color_list = [
- ("cyan", "#13c2c2"),
- ("green", "#52c41a"),
- ("magenta", "#eb2f96"),
- ("red", "#f5222d"),
- ("yellow", "#fadb14"),
- ("volcano", "#fa541c"),
- ]
- for label, color in color_list:
- color_lay.addWidget(MLabel(label))
- color_lay.addWidget(MLoading.tiny(color=color))
- color_lay.addSpacing(10)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different size"))
- main_lay.addLayout(size_lay)
- main_lay.addWidget(MDivider("different color"))
- main_lay.addLayout(color_lay)
- main_lay.addWidget(MDivider("loading wrapper"))
- # main_lay.addLayout(wrapper_lay)
-
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = LoadingExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/menu_example.py b/examples/menu_example.py
deleted file mode 100644
index f1bcee31..00000000
--- a/examples/menu_example.py
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.menu import MMenu
-from dayu_widgets.push_button import MPushButton
-
-
-class MenuExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(MenuExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- self.register_field("button1_selected", "北京")
- self.register_field(
- "button1_selected_text", lambda: self.field("button1_selected")
- )
- button1 = MPushButton(text="Normal Menu")
- menu1 = MMenu(parent=self)
- menu1.set_data(["北京", "上海", "广州", "深圳"])
- button1.setMenu(menu1)
- button1.clicked.connect(button1.showMenu)
- label1 = MLabel()
-
- self.bind("button1_selected", menu1, "value", signal="sig_value_changed")
- self.bind("button1_selected_text", label1, "text")
-
- self.register_field("button2_selected", ["北京"])
- self.register_field(
- "button2_selected_text", lambda: ", ".join(self.field("button2_selected"))
- )
- button2 = MPushButton(text="Multi Select Menu")
- menu2 = MMenu(exclusive=False, parent=self)
- menu2.set_data(["北京", "上海", "广州", "深圳"])
- button2.setMenu(menu2)
- button2.clicked.connect(button2.showMenu)
- label2 = MLabel()
- self.bind("button2_selected", menu2, "value", signal="sig_value_changed")
- self.bind("button2_selected_text", label2, "text")
-
- self.register_field("button3_selected", "")
- self.register_field(
- "button3_selected_text", lambda: self.field("button3_selected")
- )
- button3 = MPushButton(text="回调函数获取选项")
- menu3 = MMenu(parent=self)
- menu3.set_load_callback(lambda: ["北京", "上海", "广州", "深圳"])
- button3.setMenu(menu3)
- button3.clicked.connect(button2.showMenu)
- label3 = MLabel()
- self.bind("button3_selected", menu3, "value", signal="sig_value_changed")
- self.bind("button3_selected_text", label3, "text")
-
- self.register_field("button4_selected", "")
- self.register_field(
- "button4_selected_text", lambda: " / ".join(self.field("button4_selected"))
- )
- button4 = MPushButton(text="级联选择")
- menu4 = MMenu(cascader=True, parent=self)
- menu4.set_data(
- ["北京/故宫", "北京/天坛", "北京/王府井", "江苏/南京/夫子庙", "江苏/苏州/拙政园", "江苏/苏州/狮子林"]
- )
- button4.setMenu(menu4)
- button4.clicked.connect(button4.showMenu)
- label4 = MLabel()
- self.bind("button4_selected", menu4, "value", signal="sig_value_changed")
- self.bind("button4_selected_text", label4, "text")
-
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(button1)
- sub_lay1.addWidget(label1)
- sub_lay2 = QtWidgets.QHBoxLayout()
- sub_lay2.addWidget(button2)
- sub_lay2.addWidget(label2)
- sub_lay3 = QtWidgets.QHBoxLayout()
- sub_lay3.addWidget(button3)
- sub_lay3.addWidget(label3)
- sub_lay4 = QtWidgets.QHBoxLayout()
- sub_lay4.addWidget(button4)
- sub_lay4.addWidget(label4)
-
- sub_lay5 = QtWidgets.QHBoxLayout()
- button = MPushButton(text="滚动菜单")
- menu = MMenu(parent=self)
- items = ["北京", "上海", "广州", "深圳", "北戴河", "BBC/data", "BBC/hello", "American"]
- menu.set_data(items)
- menu.setProperty("max_scroll_count", 3)
- menu.setProperty("scrollable", True)
- menu.setProperty("searchable", True)
- button.setMenu(menu)
- sub_lay5.addWidget(button)
-
- sub_lay6 = QtWidgets.QHBoxLayout()
- button = MPushButton(text="搜索菜单")
- menu = MMenu(parent=self)
- items = ["北京", "上海", "广州", "深圳", "北戴河"]
- for item in items:
- menu.addAction(item)
- sub_menu = MMenu(parent=self, title="BBC")
- for item in ["data", "hello"]:
- _menu = MMenu(parent=self, title=item)
- _menu.addAction("tencent")
- _menu.addAction("baidu")
- _menu.addAction("google")
- _menu.setProperty("searchable", True)
- sub_menu.addMenu(_menu)
- menu.addMenu(sub_menu)
- menu.setProperty("searchable", True)
- button.setMenu(menu)
- sub_lay6.addWidget(button)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Select"))
- main_lay.addLayout(sub_lay1)
- main_lay.addLayout(sub_lay2)
- main_lay.addLayout(sub_lay3)
- main_lay.addWidget(MDivider("级联选择"))
- main_lay.addLayout(sub_lay4)
- main_lay.addLayout(sub_lay5)
- main_lay.addLayout(sub_lay6)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = MenuExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/menu_tab_widget_example.py b/examples/menu_tab_widget_example.py
deleted file mode 100644
index 901965c3..00000000
--- a/examples/menu_tab_widget_example.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.badge import MBadge
-from dayu_widgets.label import MLabel
-from dayu_widgets.menu_tab_widget import MMenuTabWidget
-from dayu_widgets.message import MMessage
-from dayu_widgets.tool_button import MToolButton
-
-
-class MenuTabWidgetExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(MenuTabWidgetExample, self).__init__(parent)
- self.setWindowTitle("Examples for MMenuTabWidget")
- self._init_ui()
-
- def _init_ui(self):
- item_list = [
- {
- "text": "Overview",
- "svg": "home_line.svg",
- "clicked": functools.partial(MMessage.info, "首页", parent=self),
- },
- {
- "text": "我的",
- "svg": "user_line.svg",
- "clicked": functools.partial(MMessage.info, "编辑账户", parent=self),
- },
- {
- "text": "Notice",
- "svg": "alert_line.svg",
- "clicked": functools.partial(MMessage.info, "查看通知", parent=self),
- },
- ]
- tool_bar = MMenuTabWidget()
- tool_bar_huge = MMenuTabWidget()
- tool_bar_huge.set_dayu_size(dayu_theme.huge)
- tool_bar_huge_v = MMenuTabWidget(orientation=QtCore.Qt.Vertical)
- tool_bar_huge_v.set_dayu_size(dayu_theme.huge)
- tool_bar.tool_bar_insert_widget(MLabel("DaYu").h4().secondary().strong())
- tool_bar_huge.tool_bar_insert_widget(MLabel("DaYu").h4().secondary().strong())
- dayu_icon = MLabel("DaYu").h4().secondary().strong()
- dayu_icon.setContentsMargins(10, 10, 10, 10)
- tool_bar_huge_v.tool_bar_insert_widget(dayu_icon)
- tool_bar.tool_bar_append_widget(
- MBadge.dot(
- show=True, widget=MToolButton().icon_only().svg("user_fill.svg").large()
- )
- )
- for index, data_dict in enumerate(item_list):
- tool_bar.add_menu(data_dict, index)
- tool_bar_huge.add_menu(data_dict, index)
- tool_bar_huge_v.add_menu(data_dict, index)
-
- tool_bar.tool_button_group.set_dayu_checked(0)
- tool_bar_huge.tool_button_group.set_dayu_checked(0)
- tool_bar_huge_v.tool_button_group.set_dayu_checked(0)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.setContentsMargins(0, 0, 0, 0)
-
- main_lay.addWidget(MLabel("Menu Tab Widget (Large)"))
- main_lay.addWidget(tool_bar)
-
- main_lay.addWidget(MLabel("Menu Tab Widget (Huge)"))
- main_lay.addWidget(tool_bar_huge)
-
- main_lay.addWidget(MLabel("Menu Vertical Tab Widget (Huge)"))
- main_lay.addWidget(tool_bar_huge_v)
-
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = MenuTabWidgetExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/message_example.py b/examples/message_example.py
deleted file mode 100644
index 8a569e6f..00000000
--- a/examples/message_example.py
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MPushButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.message import MMessage
-from dayu_widgets.push_button import MPushButton
-
-
-class MessageExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(MessageExample, self).__init__(parent)
- self.setWindowTitle("Examples for MMessage")
- self._init_ui()
-
- def _init_ui(self):
- button3 = MPushButton(text="Normal Message").primary()
- button4 = MPushButton(text="Success Message").success()
- button5 = MPushButton(text="Warning Message").warning()
- button6 = MPushButton(text="Error Message").danger()
- button3.clicked.connect(
- functools.partial(
- self.slot_show_message, MMessage.info, {"text": "这是一条普通提示"}
- )
- )
- button4.clicked.connect(
- functools.partial(
- self.slot_show_message, MMessage.success, {"text": "恭喜你,成功啦!"}
- )
- )
- button5.clicked.connect(
- functools.partial(
- self.slot_show_message, MMessage.warning, {"text": "我警告你哦!"}
- )
- )
- button6.clicked.connect(
- functools.partial(self.slot_show_message, MMessage.error, {"text": "失败了!"})
- )
-
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(button3)
- sub_lay1.addWidget(button4)
- sub_lay1.addWidget(button5)
- sub_lay1.addWidget(button6)
-
- button_duration = MPushButton(text="show 5s Message")
- button_duration.clicked.connect(
- functools.partial(
- self.slot_show_message,
- MMessage.info,
- {"text": "该条消息将显示5秒后关闭", "duration": 5},
- )
- )
- button_closable = MPushButton(text="closable Message")
- button_closable.clicked.connect(
- functools.partial(
- self.slot_show_message,
- MMessage.info,
- {"text": "可手动关闭提示", "closable": True},
- )
- )
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(sub_lay1)
- main_lay.addWidget(MLabel("不同的提示状态:普通、成功、警告、错误。默认2秒后消失"))
- main_lay.addWidget(MDivider("set duration"))
- main_lay.addWidget(button_duration)
- main_lay.addWidget(MLabel("自定义时长,config中设置duration值,单位为秒"))
-
- main_lay.addWidget(MDivider("set closable"))
- main_lay.addWidget(button_closable)
- main_lay.addWidget(MLabel("设置是否可关闭,config中设置closable 为 True"))
-
- button_grp = MPushButtonGroup()
- button_grp.set_button_list(
- [
- {
- "text": "set duration to 1s",
- "clicked": functools.partial(
- self.slot_set_config, MMessage.config, {"duration": 1}
- ),
- },
- {
- "text": "set duration to 10s",
- "clicked": functools.partial(
- self.slot_set_config, MMessage.config, {"duration": 10}
- ),
- },
- {
- "text": "set top to 5",
- "clicked": functools.partial(
- self.slot_set_config, MMessage.config, {"top": 5}
- ),
- },
- {
- "text": "set top to 50",
- "clicked": functools.partial(
- self.slot_set_config, MMessage.config, {"top": 50}
- ),
- },
- ]
- )
- loading_button = MPushButton("Display a loading indicator")
- loading_button.clicked.connect(self.slot_show_loading)
- main_lay.addWidget(MDivider("set global setting"))
- main_lay.addWidget(button_grp)
- main_lay.addWidget(MLabel("全局设置默认duration(默认2秒);top(离parent顶端的距离,默认24px)"))
- main_lay.addWidget(loading_button)
-
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_show_message(self, func, config):
- func(parent=self, **config)
-
- def slot_set_config(self, func, config):
- func(**config)
-
- def slot_show_loading(self):
- msg = MMessage.loading("正在加载中", parent=self)
- msg.sig_closed.connect(functools.partial(MMessage.success, "加载成功啦!!哈哈哈哈", self))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = MessageExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/page_example.py b/examples/page_example.py
deleted file mode 100644
index f1458eb9..00000000
--- a/examples/page_example.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.page import MPage
-
-
-class PageExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(PageExample, self).__init__(parent)
- self.setWindowTitle("Examples for MPage")
- self._init_ui()
-
- def _init_ui(self):
- page_1 = MPage()
- page_1.set_total(255)
- page_1.sig_page_changed.connect(print)
-
- page_2 = MPage()
- page_2.set_total(100)
-
- main_lay = QtWidgets.QVBoxLayout()
- self.setLayout(main_lay)
- main_lay.addWidget(MDivider())
- main_lay.addWidget(page_1)
- main_lay.addWidget(MDivider())
- main_lay.addWidget(page_2)
- main_lay.addStretch()
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = PageExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/progress_bar_example.py b/examples/progress_bar_example.py
deleted file mode 100644
index da5cffe0..00000000
--- a/examples/progress_bar_example.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.progress_bar import MProgressBar
-from dayu_widgets.push_button import MPushButton
-
-
-class ProgressBarExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ProgressBarExample, self).__init__(parent)
- self.setWindowTitle("Examples for MProgressBar")
- self._init_ui()
-
- def _init_ui(self):
- progress_1 = MProgressBar()
- progress_1.setValue(10)
- progress_1.setAlignment(QtCore.Qt.AlignCenter)
- progress_2 = MProgressBar()
- progress_2.setValue(80)
-
- progress_normal = MProgressBar()
- progress_normal.setValue(30)
- progress_success = MProgressBar().success()
- progress_success.setValue(100)
- progress_error = MProgressBar().error()
- progress_error.setValue(50)
- form_lay = QtWidgets.QFormLayout()
- form_lay.addRow("Primary:", progress_normal)
- form_lay.addRow("Success:", progress_success)
- form_lay.addRow("Error:", progress_error)
-
- self.progress_count = 0
- self.timer = QtCore.QTimer()
- self.timer.setInterval(10)
- self.timer.timeout.connect(self.slot_timeout)
- run_button = MPushButton(text="Run Something")
- run_button.clicked.connect(self.slot_run)
- self.auto_color_progress = MProgressBar().auto_color()
- auto_color_lay = QtWidgets.QVBoxLayout()
- auto_color_lay.addWidget(run_button)
- auto_color_lay.addWidget(self.auto_color_progress)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Basic"))
-
- main_lay.addWidget(progress_1)
- main_lay.addWidget(progress_2)
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(form_lay)
- main_lay.addWidget(MDivider("auto color"))
- main_lay.addLayout(auto_color_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_run(self):
- self.timer.start()
- self.auto_color_progress.setValue(0)
-
- def slot_timeout(self):
- if self.auto_color_progress.value() > 99:
- self.timer.stop()
- else:
- self.auto_color_progress.setValue(self.auto_color_progress.value() + 1)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ProgressBarExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/progress_circle_example.py b/examples/progress_circle_example.py
deleted file mode 100644
index 8096bd88..00000000
--- a/examples/progress_circle_example.py
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.button_group import MPushButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.progress_circle import MProgressCircle
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import get_scale_factor
-
-
-class ProgressCircleExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ProgressCircleExample, self).__init__(parent)
- self.setWindowTitle("Examples for MProgressCircle")
- self._init_ui()
-
- def _init_ui(self):
- main_lay = QtWidgets.QVBoxLayout()
- self.setLayout(main_lay)
- main_lay.addWidget(MDivider("circle"))
- lay1 = QtWidgets.QHBoxLayout()
- circle_1 = MProgressCircle(parent=self)
- circle_1.setFormat("%p Days")
- circle_1.setValue(80)
- circle_2 = MProgressCircle(parent=self)
- circle_2.set_dayu_color(dayu_theme.success_color)
- circle_2.setValue(100)
- circle_3 = MProgressCircle(parent=self)
- circle_3.set_dayu_color(dayu_theme.error_color)
- circle_3.setValue(40)
-
- dashboard_1 = MProgressCircle.dashboard(parent=self)
- dashboard_1.setFormat("%p Days")
- dashboard_1.setValue(80)
- dashboard_2 = MProgressCircle.dashboard(parent=self)
- dashboard_2.set_dayu_color(dayu_theme.success_color)
- dashboard_2.setValue(100)
- dashboard_3 = MProgressCircle.dashboard(parent=self)
- dashboard_3.set_dayu_color(dayu_theme.error_color)
- dashboard_3.setValue(40)
-
- lay1.addWidget(circle_1)
- lay1.addWidget(circle_2)
- lay1.addWidget(circle_3)
-
- dashboard_lay = QtWidgets.QHBoxLayout()
- dashboard_lay.addWidget(dashboard_1)
- dashboard_lay.addWidget(dashboard_2)
- dashboard_lay.addWidget(dashboard_3)
- main_lay.addLayout(lay1)
- main_lay.addWidget(MDivider("dashboard"))
- main_lay.addLayout(dashboard_lay)
- main_lay.addWidget(MDivider("different radius"))
-
- scale_x, _ = get_scale_factor()
- circle_4 = MProgressCircle(parent=self)
- circle_4.set_dayu_width(100 * scale_x)
- circle_4.setValue(40)
- circle_5 = MProgressCircle(parent=self)
- circle_5.setValue(40)
- circle_6 = MProgressCircle(parent=self)
- circle_6.set_dayu_width(160 * scale_x)
- circle_6.setValue(40)
- lay2 = QtWidgets.QHBoxLayout()
- lay2.addWidget(circle_4)
- lay2.addWidget(circle_5)
- lay2.addWidget(circle_6)
-
- main_lay.addLayout(lay2)
- main_lay.addWidget(MDivider("data bind"))
-
- self.register_field("percent", 0)
- self.register_field("color", self.get_color)
- self.register_field("format", self.get_format)
- circle = MProgressCircle(parent=self)
-
- self.bind("percent", circle, "value")
- self.bind("color", circle, "dayu_color")
- self.bind("format", circle, "format")
- lay3 = QtWidgets.QHBoxLayout()
- button_grp = MPushButtonGroup()
- button_grp.set_dayu_type(MPushButton.DefaultType)
- button_grp.set_button_list(
- [
- {
- "text": "+",
- "clicked": functools.partial(self.slot_change_percent, 10),
- },
- {
- "text": "-",
- "clicked": functools.partial(self.slot_change_percent, -10),
- },
- ]
- )
- lay3.addWidget(circle)
- lay3.addWidget(button_grp)
- lay3.addStretch()
- main_lay.addLayout(lay3)
-
- custom_widget = QtWidgets.QWidget()
- custom_layout = QtWidgets.QVBoxLayout()
- custom_layout.setContentsMargins(20, 20, 20, 20)
- custom_layout.addStretch()
- custom_widget.setLayout(custom_layout)
- lab1 = MLabel(text="42,001,776").h3()
- lab2 = MLabel(text="消费人群规模").secondary()
- lab3 = MLabel(text="总占人数 75%").secondary()
- lab1.setAlignment(QtCore.Qt.AlignCenter)
- lab2.setAlignment(QtCore.Qt.AlignCenter)
- lab3.setAlignment(QtCore.Qt.AlignCenter)
- custom_layout.addWidget(lab1)
- custom_layout.addWidget(lab2)
- custom_layout.addWidget(MDivider())
- custom_layout.addWidget(lab3)
- custom_layout.addStretch()
- custom_circle = MProgressCircle()
- custom_circle.set_dayu_width(180 * scale_x)
- custom_circle.setValue(75)
- custom_circle.set_widget(custom_widget)
-
- main_lay.addWidget(MDivider("custom circle"))
- main_lay.addWidget(custom_circle)
- main_lay.addStretch()
-
- def get_color(self):
- p = self.field("percent")
- if p < 30:
- return dayu_theme.error_color
- if p < 60:
- return dayu_theme.warning_color
- if p < 100:
- return dayu_theme.primary_color
- return dayu_theme.success_color
-
- def get_format(self):
- p = self.field("percent")
- if p < 30:
- return ">_<"
- if p < 60:
- return "0_0"
- if p < 100:
- return "^_^"
- return "^o^"
-
- def slot_change_percent(self, value):
- self.set_field("percent", max(0, min(self.field("percent") + value, 100)))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ProgressCircleExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/push_button_example.py b/examples/push_button_example.py
deleted file mode 100644
index 2ac551e1..00000000
--- a/examples/push_button_example.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-
-
-class PushButtonExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(PushButtonExample, self).__init__(parent)
- self.setWindowTitle("Example for MPushButton")
-
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(MPushButton("Default"))
- sub_lay1.addWidget(MPushButton("Primary").primary())
- sub_lay1.addWidget(MPushButton("Success").success())
- sub_lay1.addWidget(MPushButton("Warning").warning())
- sub_lay1.addWidget(MPushButton("Danger").danger())
-
- sub_lay2 = QtWidgets.QHBoxLayout()
- sub_lay2.addWidget(MPushButton("Upload", MIcon("cloud_line.svg")))
- sub_lay2.addWidget(
- MPushButton("Submit", MIcon("folder_line.svg", "#ddd")).primary()
- )
- sub_lay2.addWidget(
- MPushButton("Submit", MIcon("success_line.svg", "#ddd")).success()
- )
- sub_lay2.addWidget(
- MPushButton("Edit", MIcon("edit_line.svg", "#ddd")).warning()
- )
- sub_lay2.addWidget(
- MPushButton("Delete", MIcon("trash_line.svg", "#ddd")).danger()
- )
-
- sub_lay3 = QtWidgets.QHBoxLayout()
- sub_lay3.addWidget(MPushButton("Large").large().primary())
- sub_lay3.addWidget(MPushButton("Medium").medium().primary())
- sub_lay3.addWidget(MPushButton("Small").small().primary())
-
- disabled_button_1 = MPushButton("Disabled").huge()
- disabled_button_1.setEnabled(False)
- disabled_button_2 = MPushButton("Disabled").large()
- disabled_button_2.setEnabled(False)
- disabled_button_3 = MPushButton("Disabled")
- disabled_button_3.setEnabled(False)
- disabled_button_4 = MPushButton("Disabled").small()
- disabled_button_4.setEnabled(False)
- disable_lay = QtWidgets.QHBoxLayout()
- disable_lay.addWidget(disabled_button_1)
- disable_lay.addWidget(disabled_button_2)
- disable_lay.addWidget(disabled_button_3)
- disable_lay.addWidget(disabled_button_4)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(sub_lay1)
- main_lay.addLayout(sub_lay2)
- main_lay.addWidget(MDivider("different size"))
- main_lay.addLayout(sub_lay3)
- main_lay.addWidget(MDivider("disabled"))
- main_lay.addLayout(disable_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = PushButtonExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/push_button_group_example.py b/examples/push_button_group_example.py
deleted file mode 100644
index 586f60d0..00000000
--- a/examples/push_button_group_example.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.button_group import MPushButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-
-
-class PushButtonGroupExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(PushButtonGroupExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- button_config_list = [
- {
- "text": "Add",
- "icon": MIcon("add_line.svg", "#fff"),
- "type": MPushButton.PrimaryType,
- },
- {
- "text": "Edit",
- "icon": MIcon("edit_fill.svg", "#fff"),
- "type": MPushButton.WarningType,
- },
- {
- "text": "Delete",
- "icon": MIcon("trash_line.svg", "#fff"),
- "type": MPushButton.DangerType,
- },
- ]
- button_group_h = MPushButtonGroup()
- button_group_h.set_dayu_size(dayu_theme.large)
- button_group_h.set_button_list(button_config_list)
- h_lay = QtWidgets.QHBoxLayout()
- h_lay.addWidget(button_group_h)
- h_lay.addStretch()
-
- button_group_v = MPushButtonGroup(orientation=QtCore.Qt.Vertical)
- button_group_v.set_button_list(button_config_list)
- h_lay_2 = QtWidgets.QHBoxLayout()
- h_lay_2.addWidget(button_group_v)
- h_lay_2.addStretch()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(
- MLabel(
- "MPushButtonGroup is MPushButton collection. they are not exclusive."
- )
- )
- main_lay.addWidget(MDivider("MPushButton group: Horizontal & Small Size"))
- main_lay.addLayout(h_lay)
- main_lay.addWidget(MDivider("MPushButton group: Vertical & Default Size"))
- main_lay.addLayout(h_lay_2)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = PushButtonGroupExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/radio_button_example.py b/examples/radio_button_example.py
deleted file mode 100644
index be552a12..00000000
--- a/examples/radio_button_example.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-from dayu_widgets.radio_button import MRadioButton
-
-
-class RadioButtonExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(RadioButtonExample, self).__init__(parent)
- self.setWindowTitle("Example for MRadioButton")
- widget_1 = QtWidgets.QWidget()
- lay_1 = QtWidgets.QHBoxLayout()
- lay_1.addWidget(MRadioButton("Maya"))
- lay_1.addWidget(MRadioButton("Nuke"))
- lay_1.addWidget(MRadioButton("Houdini"))
- widget_1.setLayout(lay_1)
-
- check_box_icon_1 = MRadioButton("Folder")
- check_box_icon_1.setIcon(MIcon("folder_fill.svg"))
- check_box_icon_2 = MRadioButton("Media")
- check_box_icon_2.setIcon(MIcon("media_fill.svg"))
- check_box_icon_3 = MRadioButton("User")
- check_box_icon_3.setIcon(MIcon("user_fill.svg"))
- check_box_icon_2.setChecked(True)
- widget_2 = QtWidgets.QWidget()
- lay_2 = QtWidgets.QHBoxLayout()
- lay_2.addWidget(check_box_icon_1)
- lay_2.addWidget(check_box_icon_2)
- lay_2.addWidget(check_box_icon_3)
- widget_2.setLayout(lay_2)
-
- check_box_single = MRadioButton("支付宝")
- check_box_single.setChecked(True)
- check_box_single.setEnabled(False)
-
- check_box_bind = MRadioButton("Data Bind")
- label = MLabel()
- button = MPushButton(text="Change State")
- button.clicked.connect(
- lambda: self.set_field("checked", not self.field("checked"))
- )
- self.register_field("checked", True)
- self.register_field(
- "checked_text", lambda: "Yes!" if self.field("checked") else "No!!"
- )
- self.bind("checked", check_box_bind, "checked", signal="toggled")
- self.bind("checked_text", label, "text")
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Basic"))
- main_lay.addWidget(widget_1)
- main_lay.addWidget(check_box_single)
- main_lay.addWidget(MDivider("Icon"))
- main_lay.addWidget(widget_2)
- main_lay.addWidget(MDivider("Data Bind"))
- main_lay.addWidget(check_box_bind)
- main_lay.addWidget(label)
- main_lay.addWidget(button)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = RadioButtonExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/radio_button_group_example.py b/examples/radio_button_group_example.py
deleted file mode 100644
index ab537c4a..00000000
--- a/examples/radio_button_group_example.py
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MRadioButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-
-
-class RadioButtonGroupExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(RadioButtonGroupExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- radio_group_h = MRadioButtonGroup()
- radio_group_h.set_button_list(["Apple", {"text": "Banana"}, {"text": "Pear"}])
- radio_grp_1_lay = QtWidgets.QHBoxLayout()
- radio_grp_1_lay.addWidget(radio_group_h)
- radio_grp_1_lay.addStretch()
-
- app_data = [
- {"text": "Maya", "icon": MIcon("app-maya.png")},
- {"text": "Nuke", "icon": MIcon("app-nuke.png")},
- {"text": "Houdini", "icon": MIcon("app-houdini.png")},
- ]
-
- radio_group_v = MRadioButtonGroup(orientation=QtCore.Qt.Vertical)
- radio_group_v.set_button_list(app_data)
-
- radio_group_button_h = MRadioButtonGroup()
- radio_group_button_h.set_button_list(app_data)
- radio_grp_h_lay = QtWidgets.QHBoxLayout()
- radio_grp_h_lay.addWidget(radio_group_button_h)
- radio_grp_h_lay.addStretch()
-
- radio_group_button_v = MRadioButtonGroup(orientation=QtCore.Qt.Vertical)
- radio_group_button_v.set_button_list(app_data)
-
- self.register_field("value1", -1)
- self.register_field(
- "value1_text", functools.partial(self.value_to_text, "value1", app_data)
- )
- self.register_field("value2", 0)
- self.register_field(
- "value2_text", functools.partial(self.value_to_text, "value2", app_data)
- )
- self.register_field("value3", -1)
- self.register_field(
- "value3_text", functools.partial(self.value_to_text, "value3", app_data)
- )
-
- button1 = MPushButton(text="Group 1")
- button2 = MPushButton(text="Group 2")
- button3 = MPushButton(text="Group 3")
- button1.clicked.connect(functools.partial(self.slot_change_value, "value1"))
- button2.clicked.connect(functools.partial(self.slot_change_value, "value2"))
- button3.clicked.connect(functools.partial(self.slot_change_value, "value3"))
-
- self.bind("value1", radio_group_v, "dayu_checked", signal="sig_checked_changed")
- self.bind(
- "value2", radio_group_button_h, "dayu_checked", signal="sig_checked_changed"
- )
- self.bind(
- "value3", radio_group_button_v, "dayu_checked", signal="sig_checked_changed"
- )
- self.bind("value1_text", button1, "text")
- self.bind("value2_text", button2, "text")
- self.bind("value3_text", button3, "text")
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("MRadioButtonGroup: orientation=Qt.Horizontal "))
- main_lay.addLayout(radio_grp_1_lay)
- main_lay.addWidget(MDivider("MRadioButtonGroup: orientation=Qt.Vertical"))
- main_lay.addWidget(radio_group_v)
- main_lay.addWidget(button1)
- main_lay.addWidget(
- MDivider("MRadioButtonGroup: orientation=Qt.Horizontal type=button")
- )
- main_lay.addLayout(radio_grp_h_lay)
- main_lay.addWidget(button2)
- main_lay.addWidget(
- MDivider("MRadioButtonGroup: orientation=Qt.Vertical, type=button")
- )
- main_lay.addWidget(radio_group_button_v)
- main_lay.addWidget(button3)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def value_to_text(self, field, data_list):
- return (
- "Please Select One"
- if self.field(field) < 0
- else "You Selected [{}]".format(data_list[self.field(field)].get("text"))
- )
-
- def slot_change_value(self, attr):
- # Import built-in modules
- import random
-
- self.set_field(attr, random.randrange(0, 3))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = RadioButtonGroupExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/sequence_file_example.py b/examples/sequence_file_example.py
deleted file mode 100644
index b6c5b3b8..00000000
--- a/examples/sequence_file_example.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.browser import MDragFileButton
-from dayu_widgets.divider import MDivider
-from dayu_widgets.sequence_file import MSequenceFile
-
-
-class SequenceFileExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(SequenceFileExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- browser = MDragFileButton(text="Click or drag files")
- browser.set_dayu_filters([".py", "pyc", ".jpg", ".mov", "exr"])
- browser.sig_file_changed.connect(self.slot_add_file)
- self.sequence_file_1 = MSequenceFile()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different size"))
- main_lay.addWidget(browser)
- main_lay.addWidget(self.sequence_file_1)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- @QtCore.Slot(str)
- def slot_add_file(self, f):
- self.sequence_file_1.set_path(f)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = SequenceFileExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/slider_example.py b/examples/slider_example.py
deleted file mode 100644
index 4c98405b..00000000
--- a/examples/slider_example.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MPushButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.slider import MSlider
-from dayu_widgets.spin_box import MSpinBox
-
-
-class SliderExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(SliderExample, self).__init__(parent)
- self.setWindowTitle("Examples for MSlider")
- self._init_ui()
-
- def _init_ui(self):
- self.register_field("percent", 20)
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different orientation"))
- for orn in [QtCore.Qt.Horizontal, QtCore.Qt.Vertical]:
- line_edit_hor = MSlider(orn)
- line_edit_hor.setRange(1, 100)
- self.bind("percent", line_edit_hor, "value")
- lay = QtWidgets.QVBoxLayout()
- lay.addWidget(line_edit_hor)
- main_lay.addLayout(lay)
- spin_box = MSpinBox()
- spin_box.setRange(1, 100)
- self.bind("percent", spin_box, "value", signal="valueChanged")
-
- lay3 = QtWidgets.QHBoxLayout()
- button_grp = MPushButtonGroup()
- button_grp.set_button_list(
- [
- {"text": "+", "clicked": functools.partial(self.slot_change_value, 10)},
- {
- "text": "-",
- "clicked": functools.partial(self.slot_change_value, -10),
- },
- ]
- )
- lay3.addWidget(spin_box)
- lay3.addWidget(button_grp)
- lay3.addStretch()
- main_lay.addWidget(MDivider("data bind"))
- main_lay.addLayout(lay3)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_change_value(self, value):
- self.set_field("percent", max(0, min(self.field("percent") + value, 100)))
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = SliderExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/spin_box_example.py b/examples/spin_box_example.py
deleted file mode 100644
index 74409e93..00000000
--- a/examples/spin_box_example.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-"""
-Example code for MDateTimeEdit, MDoubleSpinBox, MSpinBox, MTimeEdit, MDateEdit
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.spin_box import MDateEdit
-from dayu_widgets.spin_box import MDateTimeEdit
-from dayu_widgets.spin_box import MDoubleSpinBox
-from dayu_widgets.spin_box import MSpinBox
-from dayu_widgets.spin_box import MTimeEdit
-
-
-class SpinBoxExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(SpinBoxExample, self).__init__(parent)
- self.setWindowTitle("Examples for Spin Box")
-
- main_lay = QtWidgets.QVBoxLayout()
- class_list = [MSpinBox, MDoubleSpinBox, MDateTimeEdit, MDateEdit, MTimeEdit]
- for cls in class_list:
- main_lay.addWidget(MDivider(cls.__name__))
- lay = QtWidgets.QHBoxLayout()
- lay.addWidget(cls().large())
- lay.addWidget(cls().medium())
- lay.addWidget(cls().small())
- main_lay.addLayout(lay)
-
- main_lay.addWidget(MDivider("Pop Calendar Widget"))
- date_time_edit = MDateTimeEdit()
- date_time_edit.setCalendarPopup(True)
- date_edit = MDateEdit()
- date_edit.setCalendarPopup(True)
- time_edit = MTimeEdit()
- time_edit.setCalendarPopup(True)
- date_lay = QtWidgets.QHBoxLayout()
- date_lay.addWidget(date_time_edit)
- date_lay.addWidget(date_edit)
- date_lay.addWidget(time_edit)
- main_lay.addLayout(date_lay)
-
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = SpinBoxExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/splitter_example.py b/examples/splitter_example.py
deleted file mode 100644
index 0c330c57..00000000
--- a/examples/splitter_example.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: TimmyLiang
-# Date : 2021.12
-# Email : 820472580@qq.com
-###################################################################
-"""
-Example code for MSplitter
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.splitter import MSplitter
-from dayu_widgets.text_edit import MTextEdit
-
-
-class SplitterExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(SplitterExample, self).__init__(parent)
-
- main_splitter = MSplitter(QtCore.Qt.Vertical)
- main_splitter.setHandleWidth(20)
-
- container = QtWidgets.QWidget()
- layout = QtWidgets.QVBoxLayout()
- container.setLayout(layout)
- splitter = MSplitter(QtCore.Qt.Vertical)
- splitter.addWidget(MTextEdit())
- splitter.addWidget(MTextEdit())
- splitter.addWidget(MTextEdit())
- layout.addWidget(splitter)
- main_splitter.addWidget(container)
-
- container = QtWidgets.QWidget()
- layout = QtWidgets.QVBoxLayout()
- container.setLayout(layout)
- splitter = MSplitter()
- splitter.addWidget(MTextEdit())
- splitter.addWidget(MTextEdit())
- splitter.addWidget(MTextEdit())
- layout.addWidget(splitter)
- main_splitter.addWidget(container)
-
- layout = QtWidgets.QVBoxLayout()
- layout.addWidget(main_splitter)
- self.setLayout(layout)
-
- self.resize(800, 800)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets.qt import application
-
- with application() as app:
- test = SplitterExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/switch_example.py b/examples/switch_example.py
deleted file mode 100644
index 382ed955..00000000
--- a/examples/switch_example.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.switch import MSwitch
-
-
-class SwitchExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(SwitchExample, self).__init__(parent)
- self.setWindowTitle("Examples for MSwitch")
- self._init_ui()
-
- def _init_ui(self):
- check_box_1 = MSwitch()
- check_box_1.setChecked(True)
- check_box_2 = MSwitch()
- check_box_3 = MSwitch()
- check_box_3.setEnabled(False)
- lay = QtWidgets.QHBoxLayout()
- lay.addWidget(check_box_1)
- lay.addWidget(check_box_2)
- lay.addWidget(check_box_3)
-
- size_lay = QtWidgets.QFormLayout()
- size_lay.addRow("Huge", MSwitch().huge())
- size_lay.addRow("Large", MSwitch().large())
- size_lay.addRow("Medium", MSwitch().medium())
- size_lay.addRow("Small", MSwitch().small())
- size_lay.addRow("Tiny", MSwitch().tiny())
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("Basic"))
- main_lay.addLayout(lay)
- main_lay.addWidget(MDivider("different size"))
- main_lay.addLayout(size_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets.qt import application
-
- with application() as app:
- test = SwitchExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/tab_widget_example.py b/examples/tab_widget_example.py
deleted file mode 100644
index 763ac5a0..00000000
--- a/examples/tab_widget_example.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.3
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.label import MLabel
-from dayu_widgets.message import MMessage
-from dayu_widgets.tab_widget import MTabWidget
-
-
-class MTabWidgetTest(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(MTabWidgetTest, self).__init__(parent)
- self._init_ui()
- self.resize(500, 500)
-
- def _init_ui(self):
- main_lay = QtWidgets.QVBoxLayout()
-
- tab_card = MTabWidget()
- tab_card.addTab(MLabel("test 1"), "Current Element")
- tab_card.addTab(MLabel("test 2"), "Linked Assets")
- tab_card.addTab(MLabel("test 2"), "Hero Shots")
- tab_card.addTab(MLabel("test 3"), "Linked Metadata")
-
- self.tab_closable = MTabWidget()
- self.tab_closable.setTabsClosable(True)
- self.tab_closable.addTab(MLabel("test 1"), "标签一")
- self.tab_closable.addTab(MLabel("test 2"), "标签二")
- self.tab_closable.addTab(MLabel("test 3"), "标签三")
- # self.tab_closable.tabCloseRequested.connect(self.slot_close_tab)
- main_lay.addWidget(MDivider("Normal"))
- main_lay.addWidget(tab_card)
- main_lay.addWidget(MDivider("Closable"))
- main_lay.addWidget(self.tab_closable)
- self.setLayout(main_lay)
-
- @QtCore.Slot(int)
- def slot_close_tab(self, index):
- if index > 0:
- text = self.tab_closable.tabText(index)
- self.tab_closable.removeTab(index)
- MMessage.info("成功关闭一个标签: {}".format(text), closable=True, parent=self)
- else:
- MMessage.warning("请不要关闭第一个标签", closable=True, parent=self)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = MTabWidgetTest()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/table_view_example.py b/examples/table_view_example.py
deleted file mode 100644
index 8ac01ffa..00000000
--- a/examples/table_view_example.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.alert import MAlert
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MTableView
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.loading import MLoadingWrapper
-from dayu_widgets.push_button import MPushButton
-import examples._mock_data as mock
-
-
-def h(*args):
- cls = args[0]
- widget = cls()
- for i in args:
- if isinstance(i, dict):
- for attr, value in i.get("props", {}).items():
- widget.setProperty(attr, value)
- for signal, slot in i.get("on", {}).items():
- getattr(widget, signal).connect(slot)
- elif isinstance(i, list):
- lay = QtWidgets.QHBoxLayout()
- for j in i:
- lay.addWidget(j)
- widget.setLayout(lay)
- return widget
-
-
-class MFetchDataThread(QtCore.QThread):
- def __init__(self, parent=None):
- super(MFetchDataThread, self).__init__(parent)
-
- def run(self, *args, **kwargs):
- # Import built-in modules
- import time
-
- time.sleep(4)
-
-
-class TableViewExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(TableViewExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- model_1 = MTableModel()
- model_1.set_header_list(mock.header_list)
- model_sort = MSortFilterModel()
- model_sort.setSourceModel(model_1)
-
- table_small = MTableView(size=dayu_theme.small, show_row_count=True)
- table_grid = MTableView(size=dayu_theme.small, show_row_count=True)
- table_grid.setShowGrid(True)
- table_default = MTableView(size=dayu_theme.medium, show_row_count=True)
- thread = MFetchDataThread(self)
-
- self.loading_wrapper = MLoadingWrapper(widget=table_default, loading=False)
- thread.started.connect(
- functools.partial(self.loading_wrapper.set_dayu_loading, True)
- )
- thread.finished.connect(
- functools.partial(self.loading_wrapper.set_dayu_loading, False)
- )
- thread.finished.connect(functools.partial(table_default.setModel, model_sort))
- button = MPushButton(text="Get Data: 4s")
- button.clicked.connect(thread.start)
- switch_lay = QtWidgets.QHBoxLayout()
- switch_lay.addWidget(button)
- switch_lay.addStretch()
- table_large = MTableView(size=dayu_theme.large, show_row_count=False)
-
- table_small.setModel(model_sort)
- table_grid.setModel(model_sort)
- table_large.setModel(model_sort)
- model_sort.set_header_list(mock.header_list)
- table_small.set_header_list(mock.header_list)
- table_grid.set_header_list(mock.header_list)
- table_default.set_header_list(mock.header_list)
- table_large.set_header_list(mock.header_list)
- model_1.set_data_list(mock.data_list)
-
- line_edit = MLineEdit().search().small()
- line_edit.textChanged.connect(model_sort.set_search_pattern)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(line_edit)
- main_lay.addWidget(MDivider("Small Size"))
- main_lay.addWidget(table_small)
- main_lay.addWidget(MDivider("Default Size"))
- main_lay.addLayout(switch_lay)
- main_lay.addWidget(self.loading_wrapper)
- main_lay.addWidget(MDivider("Large Size (Hide Row Count)"))
- main_lay.addWidget(table_large)
- main_lay.addWidget(MDivider("With Grid"))
- main_lay.addWidget(table_grid)
- main_lay.addStretch()
- main_lay.addWidget(MAlert('Simply use "MItemViewSet" or "MItemViewFullSet"'))
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets.qt import application
-
- with application() as app:
- test = TableViewExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/text_edit_example.py b/examples/text_edit_example.py
deleted file mode 100644
index ab346b29..00000000
--- a/examples/text_edit_example.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.6
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.text_edit import MTextEdit
-
-
-class TextEditExample(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(TextEditExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- main_lay = QtWidgets.QVBoxLayout()
-
- main_lay.addWidget(MDivider("no size grip"))
- main_lay.addWidget(MTextEdit(self))
- main_lay.addWidget(MDivider("size grip"))
- main_lay.addWidget(MTextEdit(self).resizeable())
- main_lay.addWidget(MPushButton("text").primary())
-
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = TextEditExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/theme_example.py b/examples/theme_example.py
deleted file mode 100644
index a4cc58f6..00000000
--- a/examples/theme_example.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.button_group import MRadioButtonGroup
-from dayu_widgets.check_box import MCheckBox
-from dayu_widgets.combo_box import MComboBox
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-from dayu_widgets.slider import MSlider
-from dayu_widgets.spin_box import MDateEdit
-from dayu_widgets.spin_box import MSpinBox
-from dayu_widgets.switch import MSwitch
-
-
-class ThemeExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ThemeExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- form_lay = QtWidgets.QFormLayout()
- form_lay.setLabelAlignment(QtCore.Qt.AlignRight)
- gender_grp = MRadioButtonGroup()
- gender_grp.set_button_list(
- [
- {"text": "Female", "icon": MIcon("female.svg")},
- {"text": "Male", "icon": MIcon("male.svg")},
- ]
- )
-
- country_combo_box = MComboBox().small()
- country_combo_box.addItems(["China", "France", "Japan", "US"])
- date_edit = MDateEdit().small()
- date_edit.setCalendarPopup(True)
-
- form_lay.addRow("Name:", MLineEdit().small())
- form_lay.addRow("Gender:", gender_grp)
- form_lay.addRow("Age:", MSpinBox().small())
- form_lay.addRow("Password:", MLineEdit().small().password())
- form_lay.addRow("Country:", country_combo_box)
- form_lay.addRow("Birthday:", date_edit)
- switch = MSwitch()
- switch.setChecked(True)
- form_lay.addRow("Switch:", switch)
- slider = MSlider()
- slider.setValue(30)
- form_lay.addRow("Slider:", slider)
-
- button_lay = QtWidgets.QHBoxLayout()
- button_lay.addStretch()
- button_lay.addWidget(MPushButton(text="Submit").primary())
- button_lay.addWidget(MPushButton(text="Cancel"))
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addLayout(form_lay)
- main_lay.addWidget(MCheckBox("I accept the terms and conditions"))
- main_lay.addStretch()
- main_lay.addWidget(MDivider())
- main_lay.addLayout(button_lay)
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ThemeExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/toast_example.py b/examples/toast_example.py
deleted file mode 100644
index f2925b5a..00000000
--- a/examples/toast_example.py
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import functools
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.label import MLabel
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.toast import MToast
-
-
-class MWorkThread(QtCore.QThread):
- def __init__(self, parent=None):
- super(MWorkThread, self).__init__(parent)
-
- def run(self):
- # Import built-in modules
- import time
-
- time.sleep(3)
-
-
-class ToastExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ToastExample, self).__init__(parent)
- self.setWindowTitle("Examples for MToast")
- self._init_ui()
-
- def _init_ui(self):
- button3 = MPushButton(text="Normal Message").primary()
- button4 = MPushButton(text="Success Message").success()
- button5 = MPushButton(text="Warning Message").warning()
- button6 = MPushButton(text="Error Message").danger()
- button3.clicked.connect(
- functools.partial(self.slot_show_message, MToast.info, {"text": "好像没啥用"})
- )
- button4.clicked.connect(
- functools.partial(self.slot_show_message, MToast.success, {"text": "领取成功"})
- )
- button5.clicked.connect(
- functools.partial(self.slot_show_message, MToast.warning, {"text": "暂不支持"})
- )
- button6.clicked.connect(
- functools.partial(
- self.slot_show_message, MToast.error, {"text": "支付失败,请重试"}
- )
- )
-
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(button3)
- sub_lay1.addWidget(button4)
- sub_lay1.addWidget(button5)
- sub_lay1.addWidget(button6)
-
- loading_button = MPushButton("Loading Toast").primary()
- loading_button.clicked.connect(self.slot_show_loading)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different type"))
- main_lay.addLayout(sub_lay1)
- main_lay.addWidget(MLabel("不同的提示状态:成功、失败、加载中。默认2秒后消失"))
- main_lay.addWidget(loading_button)
-
- main_lay.addStretch()
- self.setLayout(main_lay)
-
- def slot_show_message(self, func, config):
- func(parent=self, **config)
-
- def slot_set_config(self, func, config):
- func(**config)
-
- def slot_show_loading(self):
- my_thread = MWorkThread(parent=self)
- my_thread.finished.connect(self.slot_finished)
- my_thread.start()
- self.msg = MToast.loading("正在加载中", parent=self)
-
- def slot_finished(self):
- self.msg.close()
- MToast.success("加载成功", self)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ToastExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/tool_button_example.py b/examples/tool_button_example.py
deleted file mode 100644
index 5b80ff00..00000000
--- a/examples/tool_button_example.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.tool_button import MToolButton
-
-
-class ToolButtonExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ToolButtonExample, self).__init__(parent)
- self.setWindowTitle("Examples for MToolButton")
- self._init_ui()
-
- def _init_ui(self):
- size_lay = QtWidgets.QVBoxLayout()
- sub_lay1 = QtWidgets.QHBoxLayout()
- sub_lay1.addWidget(MToolButton().svg("left_line.svg").icon_only().huge())
- sub_lay1.addWidget(MToolButton().svg("right_line.svg").icon_only().large())
- sub_lay1.addWidget(MToolButton().svg("up_line.svg").icon_only())
- sub_lay1.addWidget(MToolButton().svg("up_line.svg").icon_only().small())
- sub_lay1.addWidget(MToolButton().svg("down_line.svg").icon_only().tiny())
- custom_size = MToolButton().svg("left_line.svg").icon_only()
- custom_size.set_dayu_size(200)
- custom_size.setToolTip("Custom Size 200")
-
- sub_lay1.addStretch()
- size_lay.addLayout(sub_lay1)
- size_lay.addWidget(custom_size)
-
- button2 = MToolButton().svg("detail_line.svg").icon_only()
- button2.setEnabled(False)
- button7 = MToolButton().svg("bold.svg").icon_only()
- button7.setCheckable(True)
- state_lay = QtWidgets.QHBoxLayout()
- state_lay.addWidget(button2)
- state_lay.addWidget(button7)
- state_lay.addStretch()
-
- button_trash = MToolButton().svg("trash_line.svg").text_beside_icon()
- button_trash.setText("Delete")
- button_login = MToolButton().svg("user_line.svg").text_beside_icon()
- button_login.setText("Login")
-
- button_lay = QtWidgets.QHBoxLayout()
- button_lay.addWidget(button_trash)
- button_lay.addWidget(button_login)
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("different button_size"))
- main_lay.addLayout(size_lay)
- main_lay.addWidget(MDivider("disabled & checkable"))
- main_lay.addLayout(state_lay)
- main_lay.addWidget(MDivider("type=normal"))
- main_lay.addLayout(button_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ToolButtonExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/tool_button_group_example.py b/examples/tool_button_group_example.py
deleted file mode 100644
index 17ccef45..00000000
--- a/examples/tool_button_group_example.py
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.button_group import MToolButtonGroup
-from dayu_widgets.divider import MDivider
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.qt import MIcon
-
-
-class ToolButtonGroupExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(ToolButtonGroupExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- tool_group_h = MToolButtonGroup(size=dayu_theme.small)
- tool_group_h.set_button_list(["Apple", {"text": "Banana"}, {"text": "Pear"}])
- tool_1_lay = QtWidgets.QHBoxLayout()
- tool_1_lay.addWidget(tool_group_h)
- tool_1_lay.addStretch()
-
- app_data = [
- {"text": "Maya", "icon": MIcon("app-maya.png"), "checkable": True},
- {"text": "Nuke", "icon": MIcon("app-nuke.png"), "checkable": True},
- {"text": "Houdini", "icon": MIcon("app-houdini.png"), "checkable": True},
- ]
-
- tool_group_v = MToolButtonGroup(
- exclusive=True, size=dayu_theme.small, orientation=QtCore.Qt.Vertical
- )
- tool_group_v.set_button_list(app_data)
-
- tool_group_button_h = MToolButtonGroup()
- tool_group_button_h.set_button_list(app_data)
- tool_2_lay = QtWidgets.QHBoxLayout()
- tool_2_lay.addWidget(tool_group_button_h)
- tool_2_lay.addStretch()
-
- tool_grp_excl_true = MToolButtonGroup(
- orientation=QtCore.Qt.Horizontal, exclusive=True
- )
- tool_grp_excl_true.set_button_list(
- [
- {"svg": "table_view.svg", "checkable": True, "tooltip": "Table View"},
- {"svg": "list_view.svg", "checkable": True, "tooltip": "List View"},
- {"svg": "tree_view.svg", "checkable": True, "tooltip": "Tree View"},
- {"svg": "big_view.svg", "checkable": True, "tooltip": "Big View"},
- ]
- )
- tool_grp_excl_true.set_dayu_checked(0)
- tool_excl_lay = QtWidgets.QHBoxLayout()
- tool_excl_lay.addWidget(tool_grp_excl_true)
- tool_excl_lay.addStretch()
-
- tool_grp_excl_false = MToolButtonGroup(
- orientation=QtCore.Qt.Horizontal, exclusive=False
- )
- tool_grp_excl_false.set_button_list(
- [
- {"tooltip": "加粗", "svg": "bold.svg", "checkable": True},
- {"tooltip": "倾斜", "svg": "italic.svg", "checkable": True},
- {"tooltip": "下划线", "svg": "underline.svg", "checkable": True},
- ]
- )
- tool_excl_2_lay = QtWidgets.QHBoxLayout()
- tool_excl_2_lay.addWidget(tool_grp_excl_false)
- tool_excl_2_lay.addStretch()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addWidget(MDivider("orientation=Qt.Horizontal "))
- main_lay.addLayout(tool_1_lay)
- main_lay.addWidget(MDivider("orientation=Qt.Vertical"))
- main_lay.addWidget(tool_group_v)
- main_lay.addWidget(MDivider("orientation=Qt.Horizontal"))
- main_lay.addLayout(tool_2_lay)
- main_lay.addWidget(MDivider("checkable=True; exclusive=True"))
- main_lay.addLayout(tool_excl_lay)
- main_lay.addWidget(MDivider("checkable=True; exclusive=False"))
- main_lay.addLayout(tool_excl_2_lay)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = ToolButtonGroupExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/examples/tree_view_example.py b/examples/tree_view_example.py
deleted file mode 100644
index ef0fac31..00000000
--- a/examples/tree_view_example.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-###################################################################
-# Author: Mu yanru
-# Date : 2019.2
-# Email : muyanru345@163.com
-###################################################################
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-
-# Import local modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.field_mixin import MFieldMixin
-from dayu_widgets.item_model import MSortFilterModel
-from dayu_widgets.item_model import MTableModel
-from dayu_widgets.item_view import MTreeView
-from dayu_widgets.line_edit import MLineEdit
-from dayu_widgets.push_button import MPushButton
-import examples._mock_data as mock
-
-
-class TreeViewExample(QtWidgets.QWidget, MFieldMixin):
- def __init__(self, parent=None):
- super(TreeViewExample, self).__init__(parent)
- self._init_ui()
-
- def _init_ui(self):
- model_1 = MTableModel()
- model_1.set_header_list(mock.header_list)
- model_sort = MSortFilterModel()
- model_sort.setSourceModel(model_1)
-
- tree_view = MTreeView()
- tree_view.setModel(model_sort)
-
- model_sort.set_header_list(mock.header_list)
- tree_view.set_header_list(mock.header_list)
- model_1.set_data_list(mock.tree_data_list)
-
- line_edit = MLineEdit().search().small()
- line_edit.textChanged.connect(model_sort.set_search_pattern)
-
- expand_all_button = MPushButton("Expand All").small()
- expand_all_button.clicked.connect(tree_view.expandAll)
- collapse_all_button = MPushButton("Collapse All").small()
- collapse_all_button.clicked.connect(tree_view.collapseAll)
- button_lay = QtWidgets.QHBoxLayout()
- button_lay.addWidget(expand_all_button)
- button_lay.addWidget(collapse_all_button)
- button_lay.addWidget(line_edit)
- button_lay.addStretch()
-
- main_lay = QtWidgets.QVBoxLayout()
- main_lay.addLayout(button_lay)
- main_lay.addWidget(tree_view)
- main_lay.addStretch()
- self.setLayout(main_lay)
-
-
-if __name__ == "__main__":
- # Import local modules
- from dayu_widgets import dayu_theme
- from dayu_widgets.qt import application
-
- with application() as app:
- test = TreeViewExample()
- dayu_theme.apply(test)
- test.show()
diff --git a/poetry.lock b/poetry.lock
deleted file mode 100644
index 7ebac1c9..00000000
--- a/poetry.lock
+++ /dev/null
@@ -1,781 +0,0 @@
-# This file is automatically @generated by Poetry and should not be changed by hand.
-
-[[package]]
-name = "argcomplete"
-version = "1.12.3"
-description = "Bash tab completion for argparse"
-category = "dev"
-optional = false
-python-versions = "*"
-files = [
- {file = "argcomplete-1.12.3-py2.py3-none-any.whl", hash = "sha256:291f0beca7fd49ce285d2f10e4c1c77e9460cf823eef2de54df0c0fec88b0d81"},
- {file = "argcomplete-1.12.3.tar.gz", hash = "sha256:2c7dbffd8c045ea534921e63b0be6fe65e88599990d8dc408ac8c542b72a5445"},
-]
-
-[package.dependencies]
-importlib-metadata = {version = ">=0.23,<5", markers = "python_version == \"2.7\" or python_version == \"3.6\" or python_version == \"3.7\""}
-
-[package.extras]
-test = ["coverage", "flake8", "pexpect", "wheel"]
-
-[[package]]
-name = "atomicwrites"
-version = "1.4.1"
-description = "Atomic file writes."
-category = "dev"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
-files = [
- {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"},
-]
-
-[[package]]
-name = "attrs"
-version = "22.2.0"
-description = "Classes Without Boilerplate"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"},
- {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"},
-]
-
-[package.extras]
-cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"]
-dev = ["attrs[docs,tests]"]
-docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"]
-tests = ["attrs[tests-no-zope]", "zope.interface"]
-tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"]
-
-[[package]]
-name = "black"
-version = "21.12b0"
-description = "The uncompromising code formatter."
-category = "dev"
-optional = false
-python-versions = ">=3.6.2"
-files = [
- {file = "black-21.12b0-py3-none-any.whl", hash = "sha256:a615e69ae185e08fdd73e4715e260e2479c861b5740057fde6e8b4e3b7dd589f"},
- {file = "black-21.12b0.tar.gz", hash = "sha256:77b80f693a569e2e527958459634f18df9b0ba2625ba4e0c2d5da5be42e6f2b3"},
-]
-
-[package.dependencies]
-click = ">=7.1.2"
-dataclasses = {version = ">=0.6", markers = "python_version < \"3.7\""}
-mypy-extensions = ">=0.4.3"
-pathspec = ">=0.9.0,<1"
-platformdirs = ">=2"
-tomli = ">=0.2.6,<2.0.0"
-typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""}
-typing-extensions = [
- {version = ">=3.10.0.0", markers = "python_version < \"3.10\""},
- {version = ">=3.10.0.0,<3.10.0.1 || >3.10.0.1", markers = "python_version >= \"3.10\""},
-]
-
-[package.extras]
-colorama = ["colorama (>=0.4.3)"]
-d = ["aiohttp (>=3.7.4)"]
-jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
-python2 = ["typed-ast (>=1.4.3)"]
-uvloop = ["uvloop (>=0.15.2)"]
-
-[[package]]
-name = "click"
-version = "8.0.4"
-description = "Composable command line interface toolkit"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"},
- {file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"},
-]
-
-[package.dependencies]
-colorama = {version = "*", markers = "platform_system == \"Windows\""}
-importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}
-
-[[package]]
-name = "colorama"
-version = "0.4.5"
-description = "Cross-platform colored terminal text."
-category = "dev"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
-files = [
- {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
- {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
-]
-
-[[package]]
-name = "commitizen"
-version = "2.20.0"
-description = "Python commitizen client tool"
-category = "dev"
-optional = false
-python-versions = ">=3.6.1,<4.0.0"
-files = [
- {file = "commitizen-2.20.0-py3-none-any.whl", hash = "sha256:a8c9f75718f0507d703c3b3aeef43bebc3ed0979c8995f9214185956a1bc1c05"},
- {file = "commitizen-2.20.0.tar.gz", hash = "sha256:b52eb35ffbe8281fc3187e648fae2bdd75ed1d17d31c8a0592909ccb7278292f"},
-]
-
-[package.dependencies]
-argcomplete = ">=1.12.1,<2.0.0"
-colorama = ">=0.4.1,<0.5.0"
-decli = ">=0.5.2,<0.6.0"
-jinja2 = ">=2.10.3"
-packaging = ">=19,<22"
-pyyaml = ">=3.08"
-questionary = ">=1.4.0,<2.0.0"
-termcolor = ">=1.1,<2.0"
-tomlkit = ">=0.5.3,<1.0.0"
-
-[[package]]
-name = "dataclasses"
-version = "0.8"
-description = "A backport of the dataclasses module for Python 3.6"
-category = "dev"
-optional = false
-python-versions = ">=3.6, <3.7"
-files = [
- {file = "dataclasses-0.8-py3-none-any.whl", hash = "sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf"},
- {file = "dataclasses-0.8.tar.gz", hash = "sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97"},
-]
-
-[[package]]
-name = "dayu-path"
-version = "0.5.2"
-description = "a python path lib optimized for Movie industry. Support scan for sequence files, extract frame count and many other useful functions."
-category = "main"
-optional = false
-python-versions = "*"
-files = [
- {file = "dayu_path-0.5.2-py2.py3-none-any.whl", hash = "sha256:d6d738ea8baaaaee4a4f246aaf7f3e60ab4e186a8803e7a82419fce1a818080f"},
- {file = "dayu_path-0.5.2.tar.gz", hash = "sha256:9cee18f7bf3235beacf43c077863de7eeda92d192e18a49f52a71ef73a32de40"},
-]
-
-[[package]]
-name = "decli"
-version = "0.5.2"
-description = "Minimal, easy-to-use, declarative cli tool"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "decli-0.5.2-py3-none-any.whl", hash = "sha256:d3207bc02d0169bf6ed74ccca09ce62edca0eb25b0ebf8bf4ae3fb8333e15ca0"},
- {file = "decli-0.5.2.tar.gz", hash = "sha256:f2cde55034a75c819c630c7655a844c612f2598c42c21299160465df6ad463ad"},
-]
-
-[[package]]
-name = "importlib-metadata"
-version = "4.8.3"
-description = "Read metadata from Python packages"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "importlib_metadata-4.8.3-py3-none-any.whl", hash = "sha256:65a9576a5b2d58ca44d133c42a241905cc45e34d2c06fd5ba2bafa221e5d7b5e"},
- {file = "importlib_metadata-4.8.3.tar.gz", hash = "sha256:766abffff765960fcc18003801f7044eb6755ffae4521c8e8ce8e83b9c9b0668"},
-]
-
-[package.dependencies]
-typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""}
-zipp = ">=0.5"
-
-[package.extras]
-docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"]
-perf = ["ipython"]
-testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy", "pytest-perf (>=0.9.2)"]
-
-[[package]]
-name = "iniconfig"
-version = "1.1.1"
-description = "iniconfig: brain-dead simple config-ini parsing"
-category = "dev"
-optional = false
-python-versions = "*"
-files = [
- {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
- {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
-]
-
-[[package]]
-name = "isort"
-version = "5.10.1"
-description = "A Python utility / library to sort Python imports."
-category = "dev"
-optional = false
-python-versions = ">=3.6.1,<4.0"
-files = [
- {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"},
- {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"},
-]
-
-[package.extras]
-colors = ["colorama (>=0.4.3,<0.5.0)"]
-pipfile-deprecated-finder = ["pipreqs", "requirementslib"]
-plugins = ["setuptools"]
-requirements-deprecated-finder = ["pip-api", "pipreqs"]
-
-[[package]]
-name = "jinja2"
-version = "3.0.3"
-description = "A very fast and expressive template engine."
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"},
- {file = "Jinja2-3.0.3.tar.gz", hash = "sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"},
-]
-
-[package.dependencies]
-MarkupSafe = ">=2.0"
-
-[package.extras]
-i18n = ["Babel (>=2.7)"]
-
-[[package]]
-name = "markupsafe"
-version = "2.0.1"
-description = "Safely add untrusted strings to HTML/XML markup."
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"},
- {file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"},
- {file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"},
- {file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"},
- {file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"},
- {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"},
- {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"},
-]
-
-[[package]]
-name = "mypy-extensions"
-version = "1.0.0"
-description = "Type system extensions for programs checked with the mypy type checker."
-category = "dev"
-optional = false
-python-versions = ">=3.5"
-files = [
- {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
- {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
-]
-
-[[package]]
-name = "packaging"
-version = "21.3"
-description = "Core utilities for Python packages"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
- {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
-]
-
-[package.dependencies]
-pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
-
-[[package]]
-name = "pathspec"
-version = "0.9.0"
-description = "Utility library for gitignore style pattern matching of file paths."
-category = "dev"
-optional = false
-python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
-files = [
- {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"},
- {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
-]
-
-[[package]]
-name = "platformdirs"
-version = "2.4.0"
-description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "platformdirs-2.4.0-py3-none-any.whl", hash = "sha256:8868bbe3c3c80d42f20156f22e7131d2fb321f5bc86a2a345375c6481a67021d"},
- {file = "platformdirs-2.4.0.tar.gz", hash = "sha256:367a5e80b3d04d2428ffa76d33f124cf11e8fff2acdaa9b43d545f5c7d661ef2"},
-]
-
-[package.extras]
-docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"]
-test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"]
-
-[[package]]
-name = "pluggy"
-version = "1.0.0"
-description = "plugin and hook calling mechanisms for python"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
- {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
-]
-
-[package.dependencies]
-importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
-
-[package.extras]
-dev = ["pre-commit", "tox"]
-testing = ["pytest", "pytest-benchmark"]
-
-[[package]]
-name = "prompt-toolkit"
-version = "3.0.19"
-description = "Library for building powerful interactive command lines in Python"
-category = "dev"
-optional = false
-python-versions = ">=3.6.1"
-files = [
- {file = "prompt_toolkit-3.0.19-py3-none-any.whl", hash = "sha256:7089d8d2938043508aa9420ec18ce0922885304cddae87fb96eebca942299f88"},
- {file = "prompt_toolkit-3.0.19.tar.gz", hash = "sha256:08360ee3a3148bdb5163621709ee322ec34fc4375099afa4bbf751e9b7b7fa4f"},
-]
-
-[package.dependencies]
-wcwidth = "*"
-
-[[package]]
-name = "py"
-version = "1.11.0"
-description = "library with cross-python path, ini-parsing, io, code, log facilities"
-category = "dev"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
-files = [
- {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
- {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
-]
-
-[[package]]
-name = "pyparsing"
-version = "3.0.7"
-description = "Python parsing module"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"},
- {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"},
-]
-
-[package.extras]
-diagrams = ["jinja2", "railroad-diagrams"]
-
-[[package]]
-name = "pyside2"
-version = "5.15.2.1"
-description = "Python bindings for the Qt cross-platform application and UI framework"
-category = "dev"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11"
-files = [
- {file = "PySide2-5.15.2.1-5.15.2-cp27-cp27m-macosx_10_13_intel.whl", hash = "sha256:b5e1d92f26b0bbaefff67727ccbb2e1b577f2c0164b349b3d6e80febb4c5bde2"},
- {file = "PySide2-5.15.2.1-5.15.2-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:235240b6ec8206d9fdf0232472c6ef3241783d480425e5b54796f06e39ed23da"},
- {file = "PySide2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-macosx_10_13_intel.whl", hash = "sha256:a9e2e6bbcb5d2ebb421e46e72244a0f4fe0943b2288115f80a863aacc1de1f06"},
- {file = "PySide2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-manylinux1_x86_64.whl", hash = "sha256:23886c6391ebd916e835fa1b5ae66938048504fd3a2934ae3189a96cd5ac0b46"},
- {file = "PySide2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-none-win32.whl", hash = "sha256:439509e53cfe05abbf9a99422a2cbad086408b0f9bf5e6f642ff1b13b1f8b055"},
- {file = "PySide2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-none-win_amd64.whl", hash = "sha256:af6b263fe63ba6dea7eaebae80aa7b291491fe66f4f0057c0aafe780cc83da9d"},
-]
-
-[package.dependencies]
-shiboken2 = "5.15.2.1"
-
-[[package]]
-name = "pytest"
-version = "7.0.1"
-description = "pytest: simple powerful testing with Python"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "pytest-7.0.1-py3-none-any.whl", hash = "sha256:9ce3ff477af913ecf6321fe337b93a2c0dcf2a0a1439c43f5452112c1e4280db"},
- {file = "pytest-7.0.1.tar.gz", hash = "sha256:e30905a0c131d3d94b89624a1cc5afec3e0ba2fbdb151867d8e0ebd49850f171"},
-]
-
-[package.dependencies]
-atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
-attrs = ">=19.2.0"
-colorama = {version = "*", markers = "sys_platform == \"win32\""}
-importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
-iniconfig = "*"
-packaging = "*"
-pluggy = ">=0.12,<2.0"
-py = ">=1.8.2"
-tomli = ">=1.0.0"
-
-[package.extras]
-testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
-
-[[package]]
-name = "pytest-qt"
-version = "4.0.2"
-description = "pytest support for PyQt and PySide applications"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "pytest-qt-4.0.2.tar.gz", hash = "sha256:dfc5240dec7eb43b76bcb5f9a87eecae6ef83592af49f3af5f1d5d093acaa93e"},
- {file = "pytest_qt-4.0.2-py2.py3-none-any.whl", hash = "sha256:e03847ac02a890ccaac0fde1748855b9dce425aceba62005c6cfced6cf7d5456"},
-]
-
-[package.dependencies]
-pytest = ">=3.0.0"
-
-[package.extras]
-dev = ["pre-commit", "tox"]
-doc = ["sphinx", "sphinx-rtd-theme"]
-
-[[package]]
-name = "pyyaml"
-version = "6.0.1"
-description = "YAML parser and emitter for Python"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"},
- {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"},
- {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"},
- {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"},
- {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"},
- {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"},
- {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"},
- {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"},
- {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"},
- {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"},
- {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"},
- {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"},
- {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"},
- {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
- {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"},
- {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"},
- {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"},
- {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"},
- {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"},
- {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"},
- {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"},
- {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"},
- {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"},
- {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"},
- {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"},
- {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"},
- {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"},
- {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"},
- {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"},
- {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"},
- {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"},
- {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"},
- {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"},
- {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"},
- {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"},
- {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"},
- {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"},
- {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"},
- {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"},
- {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"},
-]
-
-[[package]]
-name = "qt-py"
-version = "1.3.8"
-description = "Python 2 & 3 compatibility wrapper around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5."
-category = "main"
-optional = false
-python-versions = "*"
-files = [
- {file = "Qt.py-1.3.8-py2.py3-none-any.whl", hash = "sha256:665b9d4cfefaff2d697876d5027e145a0e0b1ba62dda9652ea114db134bc9911"},
- {file = "Qt.py-1.3.8.tar.gz", hash = "sha256:6d330928f7ec8db8e329b19116c52482b6abfaccfa5edef0248e57d012300895"},
-]
-
-[package.dependencies]
-types-PySide2 = "*"
-
-[[package]]
-name = "questionary"
-version = "1.10.0"
-description = "Python library to build pretty command line user prompts ⭐️"
-category = "dev"
-optional = false
-python-versions = ">=3.6,<4.0"
-files = [
- {file = "questionary-1.10.0-py3-none-any.whl", hash = "sha256:fecfcc8cca110fda9d561cb83f1e97ecbb93c613ff857f655818839dac74ce90"},
- {file = "questionary-1.10.0.tar.gz", hash = "sha256:600d3aefecce26d48d97eee936fdb66e4bc27f934c3ab6dd1e292c4f43946d90"},
-]
-
-[package.dependencies]
-prompt_toolkit = ">=2.0,<4.0"
-
-[package.extras]
-docs = ["Sphinx (>=3.3,<4.0)", "sphinx-autobuild (>=2020.9.1,<2021.0.0)", "sphinx-autodoc-typehints (>=1.11.1,<2.0.0)", "sphinx-copybutton (>=0.3.1,<0.4.0)", "sphinx-rtd-theme (>=0.5.0,<0.6.0)"]
-
-[[package]]
-name = "shiboken2"
-version = "5.15.2.1"
-description = "Python / C++ bindings helper module"
-category = "dev"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11"
-files = [
- {file = "shiboken2-5.15.2.1-5.15.2-cp27-cp27m-macosx_10_13_intel.whl", hash = "sha256:f890f5611ab8f48b88cfecb716da2ac55aef99e2923198cefcf781842888ea65"},
- {file = "shiboken2-5.15.2.1-5.15.2-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:87079c07587859a525b9800d60b1be971338ce9b371d6ead81f15ee5a46d448b"},
- {file = "shiboken2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-macosx_10_13_intel.whl", hash = "sha256:ffd3d0ec3d508e592d7ee3885d27fee1f279a49989f734eb130f46d9501273a9"},
- {file = "shiboken2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-manylinux1_x86_64.whl", hash = "sha256:63debfcc531b6a2b4985aa9b71433d2ad3bac542acffc729cc0ecaa3854390c0"},
- {file = "shiboken2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-none-win32.whl", hash = "sha256:eb0da44b6fa60c6bd317b8f219e500595e94e0322b33ec5b4e9f406bedaee555"},
- {file = "shiboken2-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-none-win_amd64.whl", hash = "sha256:a0d0fdeb12b72c8af349b9642ccc67afd783dca449309f45e78cda50272fd6b7"},
-]
-
-[[package]]
-name = "singledispatch"
-version = "3.7.0"
-description = "Backport functools.singledispatch from Python 3.4 to Python 2.6-3.3."
-category = "main"
-optional = false
-python-versions = ">=2.6"
-files = [
- {file = "singledispatch-3.7.0-py2.py3-none-any.whl", hash = "sha256:bc77afa97c8a22596d6d4fc20f1b7bdd2b86edc2a65a4262bdd7cc3cc19aa989"},
- {file = "singledispatch-3.7.0.tar.gz", hash = "sha256:c1a4d5c1da310c3fd8fccfb8d4e1cb7df076148fd5d858a819e37fffe44f3092"},
-]
-
-[package.dependencies]
-six = "*"
-
-[package.extras]
-docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"]
-testing = ["pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-flake8", "unittest2"]
-
-[[package]]
-name = "six"
-version = "1.16.0"
-description = "Python 2 and 3 compatibility utilities"
-category = "main"
-optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
-files = [
- {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
- {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
-]
-
-[[package]]
-name = "termcolor"
-version = "1.1.0"
-description = "ANSII Color formatting for output in terminal."
-category = "dev"
-optional = false
-python-versions = "*"
-files = [
- {file = "termcolor-1.1.0.tar.gz", hash = "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"},
-]
-
-[[package]]
-name = "tomli"
-version = "1.2.3"
-description = "A lil' TOML parser"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"},
- {file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"},
-]
-
-[[package]]
-name = "tomlkit"
-version = "0.11.6"
-description = "Style preserving TOML library"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "tomlkit-0.11.6-py3-none-any.whl", hash = "sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b"},
- {file = "tomlkit-0.11.6.tar.gz", hash = "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"},
-]
-
-[[package]]
-name = "typed-ast"
-version = "1.5.5"
-description = "a fork of Python 2 and 3 ast modules with type comment support"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "typed_ast-1.5.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4bc1efe0ce3ffb74784e06460f01a223ac1f6ab31c6bc0376a21184bf5aabe3b"},
- {file = "typed_ast-1.5.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5f7a8c46a8b333f71abd61d7ab9255440d4a588f34a21f126bbfc95f6049e686"},
- {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:597fc66b4162f959ee6a96b978c0435bd63791e31e4f410622d19f1686d5e769"},
- {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d41b7a686ce653e06c2609075d397ebd5b969d821b9797d029fccd71fdec8e04"},
- {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5fe83a9a44c4ce67c796a1b466c270c1272e176603d5e06f6afbc101a572859d"},
- {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d5c0c112a74c0e5db2c75882a0adf3133adedcdbfd8cf7c9d6ed77365ab90a1d"},
- {file = "typed_ast-1.5.5-cp310-cp310-win_amd64.whl", hash = "sha256:e1a976ed4cc2d71bb073e1b2a250892a6e968ff02aa14c1f40eba4f365ffec02"},
- {file = "typed_ast-1.5.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c631da9710271cb67b08bd3f3813b7af7f4c69c319b75475436fcab8c3d21bee"},
- {file = "typed_ast-1.5.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b445c2abfecab89a932b20bd8261488d574591173d07827c1eda32c457358b18"},
- {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc95ffaaab2be3b25eb938779e43f513e0e538a84dd14a5d844b8f2932593d88"},
- {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61443214d9b4c660dcf4b5307f15c12cb30bdfe9588ce6158f4a005baeb167b2"},
- {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6eb936d107e4d474940469e8ec5b380c9b329b5f08b78282d46baeebd3692dc9"},
- {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e48bf27022897577d8479eaed64701ecaf0467182448bd95759883300ca818c8"},
- {file = "typed_ast-1.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:83509f9324011c9a39faaef0922c6f720f9623afe3fe220b6d0b15638247206b"},
- {file = "typed_ast-1.5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44f214394fc1af23ca6d4e9e744804d890045d1643dd7e8229951e0ef39429b5"},
- {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:118c1ce46ce58fda78503eae14b7664163aa735b620b64b5b725453696f2a35c"},
- {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be4919b808efa61101456e87f2d4c75b228f4e52618621c77f1ddcaae15904fa"},
- {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fc2b8c4e1bc5cd96c1a823a885e6b158f8451cf6f5530e1829390b4d27d0807f"},
- {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:16f7313e0a08c7de57f2998c85e2a69a642e97cb32f87eb65fbfe88381a5e44d"},
- {file = "typed_ast-1.5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:2b946ef8c04f77230489f75b4b5a4a6f24c078be4aed241cfabe9cbf4156e7e5"},
- {file = "typed_ast-1.5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2188bc33d85951ea4ddad55d2b35598b2709d122c11c75cffd529fbc9965508e"},
- {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0635900d16ae133cab3b26c607586131269f88266954eb04ec31535c9a12ef1e"},
- {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57bfc3cf35a0f2fdf0a88a3044aafaec1d2f24d8ae8cd87c4f58d615fb5b6311"},
- {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:fe58ef6a764de7b4b36edfc8592641f56e69b7163bba9f9c8089838ee596bfb2"},
- {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d09d930c2d1d621f717bb217bf1fe2584616febb5138d9b3e8cdd26506c3f6d4"},
- {file = "typed_ast-1.5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d40c10326893ecab8a80a53039164a224984339b2c32a6baf55ecbd5b1df6431"},
- {file = "typed_ast-1.5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fd946abf3c31fb50eee07451a6aedbfff912fcd13cf357363f5b4e834cc5e71a"},
- {file = "typed_ast-1.5.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ed4a1a42df8a3dfb6b40c3d2de109e935949f2f66b19703eafade03173f8f437"},
- {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:045f9930a1550d9352464e5149710d56a2aed23a2ffe78946478f7b5416f1ede"},
- {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:381eed9c95484ceef5ced626355fdc0765ab51d8553fec08661dce654a935db4"},
- {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:bfd39a41c0ef6f31684daff53befddae608f9daf6957140228a08e51f312d7e6"},
- {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8c524eb3024edcc04e288db9541fe1f438f82d281e591c548903d5b77ad1ddd4"},
- {file = "typed_ast-1.5.5-cp38-cp38-win_amd64.whl", hash = "sha256:7f58fabdde8dcbe764cef5e1a7fcb440f2463c1bbbec1cf2a86ca7bc1f95184b"},
- {file = "typed_ast-1.5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:042eb665ff6bf020dd2243307d11ed626306b82812aba21836096d229fdc6a10"},
- {file = "typed_ast-1.5.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:622e4a006472b05cf6ef7f9f2636edc51bda670b7bbffa18d26b255269d3d814"},
- {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efebbbf4604ad1283e963e8915daa240cb4bf5067053cf2f0baadc4d4fb51b8"},
- {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0aefdd66f1784c58f65b502b6cf8b121544680456d1cebbd300c2c813899274"},
- {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:48074261a842acf825af1968cd912f6f21357316080ebaca5f19abbb11690c8a"},
- {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:429ae404f69dc94b9361bb62291885894b7c6fb4640d561179548c849f8492ba"},
- {file = "typed_ast-1.5.5-cp39-cp39-win_amd64.whl", hash = "sha256:335f22ccb244da2b5c296e6f96b06ee9bed46526db0de38d2f0e5a6597b81155"},
- {file = "typed_ast-1.5.5.tar.gz", hash = "sha256:94282f7a354f36ef5dbce0ef3467ebf6a258e370ab33d5b40c249fa996e590dd"},
-]
-
-[[package]]
-name = "types-pyside2"
-version = "5.15.2.1.6"
-description = "The most accurate stubs for PySide2"
-category = "main"
-optional = false
-python-versions = "*"
-files = [
- {file = "types_pyside2-5.15.2.1.6-py2.py3-none-any.whl", hash = "sha256:5bc2763bc6b595b2c5fc1191ce5147dcc6f44d56efdc2b264b6c082282cc1c57"},
- {file = "types_pyside2-5.15.2.1.6.tar.gz", hash = "sha256:de4b575e57fdb9e5fd8507537cdd770866fdbe1972eadc3793b2026eaec92875"},
-]
-
-[[package]]
-name = "typing-extensions"
-version = "4.1.1"
-description = "Backported and Experimental Type Hints for Python 3.6+"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "typing_extensions-4.1.1-py3-none-any.whl", hash = "sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"},
- {file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"},
-]
-
-[[package]]
-name = "typing-extensions"
-version = "4.7.1"
-description = "Backported and Experimental Type Hints for Python 3.7+"
-category = "dev"
-optional = false
-python-versions = ">=3.7"
-files = [
- {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"},
- {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"},
-]
-
-[[package]]
-name = "wcwidth"
-version = "0.2.6"
-description = "Measures the displayed width of unicode strings in a terminal"
-category = "dev"
-optional = false
-python-versions = "*"
-files = [
- {file = "wcwidth-0.2.6-py2.py3-none-any.whl", hash = "sha256:795b138f6875577cd91bba52baf9e445cd5118fd32723b460e30a0af30ea230e"},
- {file = "wcwidth-0.2.6.tar.gz", hash = "sha256:a5220780a404dbe3353789870978e472cfe477761f06ee55077256e509b156d0"},
-]
-
-[[package]]
-name = "zipp"
-version = "3.6.0"
-description = "Backport of pathlib-compatible object wrapper for zip files"
-category = "dev"
-optional = false
-python-versions = ">=3.6"
-files = [
- {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"},
- {file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"},
-]
-
-[package.extras]
-docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"]
-testing = ["func-timeout", "jaraco.itertools", "pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"]
-
-[metadata]
-lock-version = "2.0"
-python-versions = ">=2.7,<2.8 || >=3.6.0"
-content-hash = "4f0456d8a7de0c1358d349b0b60b9bb07eb9377a31413272b81dc1a51280f399"
diff --git a/pyproject.toml b/pyproject.toml
deleted file mode 100644
index b3224988..00000000
--- a/pyproject.toml
+++ /dev/null
@@ -1,102 +0,0 @@
-[tool.poetry]
-name = "dayu_widgets"
-version = "0.13.1"
-description = "Components for PySide/PyQt."
-homepage = "https://github.com/phenom-films/dayu_widgets"
-repository = "https://github.com/phenom-films/dayu_widgets"
-documentation = "https://phenom-films.github.io/dayu_widgets/#/"
-keywords = ["PySide", "PyQt", "UI", "PySide2", "PyQt5"]
-authors = ["muyanru ", "timmyliang <820472580@qq.com>"]
-license = "MIT"
-readme = "README.md"
-classifiers = [
- "License :: OSI Approved :: MIT License",
- "Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3.5",
- "Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.8",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
-]
-
-packages = [
- { include = "dayu_widgets" },
-]
-[tool.poetry.build]
-generate-setup-file = false
-
-[tool.poetry.dependencies]
-python = ">=2.7,<2.8 || >=3.6.0"
-six = "^1.16.0"
-singledispatch = {version = "^3.7.0", python = "2.7"}
-"Qt.py" = "^1.3.6"
-dayu-path = "^0.5.2"
-
-[tool.poetry.dev-dependencies]
-pytest = {version = "^7.0.0", python = ">=3.6.0,<3.11"}
-PySide2 = {version = "^5.15.2", python = ">=3.6.0,<3.11"}
-pytest-qt = {version = "^4.0.2", python = ">=3.6.0,<3.11"}
-black = {version = "^21.12b0", python = ">=3.6.2,<3.11"}
-isort = {version = "^5.10.1", python = ">=3.6.1,<3.111"}
-commitizen = {version = "^2.20.0", python = ">=3.6.1,<3.11"}
-
-[tool.commitizen]
-name = "cz_conventional_commits"
-version = "0.13.1"
-tag_format = "v$version"
-version_files = [
- "pyproject.toml:version",
- "dayu_widgets/__version__.py"
-]
-
-[build-system]
-requires = ["poetry-core>=1.0.0"]
-build-backend = "poetry.core.masonry.api"
-
-[tool.black]
-line-length = 88
-target_version = ['py36']
-include = '\.pyi?$'
-exclude = '''
-
-(
- /(
- \.eggs # exclude a few common directories in the
- | \.git # root of the project
- | \.hg
- | \.mypy_cache
- | \.tox
- | \.venv
- | _build
- | buck-out
- | build
- | dist
- )/
- | foo.py # also separately exclude a file named foo.py in
- # the root of the project
-)
-'''
-
-[tool.isort]
-profile = "black"
-atomic = true
-include_trailing_comma = true
-lines_after_imports = 2
-lines_between_types = 1
-use_parentheses = true
-filter_files = true
-known_first_party = ["dayu_widgets"]
-
-# Enforce import section headers.
-import_heading_future = "Import future modules"
-import_heading_stdlib = "Import built-in modules"
-import_heading_thirdparty = "Import third-party modules"
-import_heading_firstparty = "Import local modules"
-
-force_sort_within_sections = true
-force_single_line = true
-
-# All project unrelated unknown imports belong to third-party.
-default_section = "THIRDPARTY"
-skip_glob = "*/docs/conf.py"
diff --git a/pytest.ini b/pytest.ini
deleted file mode 100644
index 39baf331..00000000
--- a/pytest.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[pytest]
-testpaths = tests/
diff --git a/renovate.json b/renovate.json
deleted file mode 100644
index 39a2b6e9..00000000
--- a/renovate.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
- "extends": [
- "config:base"
- ]
-}
diff --git a/screenshots/alert_dark.png b/screenshots/alert_dark.png
deleted file mode 100644
index fe3edd8d..00000000
Binary files a/screenshots/alert_dark.png and /dev/null differ
diff --git a/screenshots/alert_light.png b/screenshots/alert_light.png
deleted file mode 100644
index bd438f16..00000000
Binary files a/screenshots/alert_light.png and /dev/null differ
diff --git a/screenshots/avatar_dark.png b/screenshots/avatar_dark.png
deleted file mode 100644
index eca8b87e..00000000
Binary files a/screenshots/avatar_dark.png and /dev/null differ
diff --git a/screenshots/avatar_light.png b/screenshots/avatar_light.png
deleted file mode 100644
index 178e311e..00000000
Binary files a/screenshots/avatar_light.png and /dev/null differ
diff --git a/screenshots/badge_dark.png b/screenshots/badge_dark.png
deleted file mode 100644
index 306182f3..00000000
Binary files a/screenshots/badge_dark.png and /dev/null differ
diff --git a/screenshots/badge_light.png b/screenshots/badge_light.png
deleted file mode 100644
index ce21ef38..00000000
Binary files a/screenshots/badge_light.png and /dev/null differ
diff --git a/screenshots/breadcrumb_dark.gif b/screenshots/breadcrumb_dark.gif
deleted file mode 100644
index 2024c8e4..00000000
Binary files a/screenshots/breadcrumb_dark.gif and /dev/null differ
diff --git a/screenshots/breadcrumb_light.gif b/screenshots/breadcrumb_light.gif
deleted file mode 100644
index 2538359d..00000000
Binary files a/screenshots/breadcrumb_light.gif and /dev/null differ
diff --git a/screenshots/browser_dark.png b/screenshots/browser_dark.png
deleted file mode 100644
index 57b465b5..00000000
Binary files a/screenshots/browser_dark.png and /dev/null differ
diff --git a/screenshots/browser_light.png b/screenshots/browser_light.png
deleted file mode 100644
index 67fdbedb..00000000
Binary files a/screenshots/browser_light.png and /dev/null differ
diff --git a/screenshots/card_dark.png b/screenshots/card_dark.png
deleted file mode 100644
index cecacc96..00000000
Binary files a/screenshots/card_dark.png and /dev/null differ
diff --git a/screenshots/card_light.png b/screenshots/card_light.png
deleted file mode 100644
index b02584ff..00000000
Binary files a/screenshots/card_light.png and /dev/null differ
diff --git a/screenshots/carousel_dark.gif b/screenshots/carousel_dark.gif
deleted file mode 100644
index 91f2745d..00000000
Binary files a/screenshots/carousel_dark.gif and /dev/null differ
diff --git a/screenshots/carousel_light.gif b/screenshots/carousel_light.gif
deleted file mode 100644
index 35a12b19..00000000
Binary files a/screenshots/carousel_light.gif and /dev/null differ
diff --git a/screenshots/check_box_dark.png b/screenshots/check_box_dark.png
deleted file mode 100644
index 6a93c34c..00000000
Binary files a/screenshots/check_box_dark.png and /dev/null differ
diff --git a/screenshots/check_box_light.png b/screenshots/check_box_light.png
deleted file mode 100644
index 2531efd6..00000000
Binary files a/screenshots/check_box_light.png and /dev/null differ
diff --git a/screenshots/collapse_dark.gif b/screenshots/collapse_dark.gif
deleted file mode 100644
index 281dfcc0..00000000
Binary files a/screenshots/collapse_dark.gif and /dev/null differ
diff --git a/screenshots/collapse_light.gif b/screenshots/collapse_light.gif
deleted file mode 100644
index 36e6995d..00000000
Binary files a/screenshots/collapse_light.gif and /dev/null differ
diff --git a/screenshots/divider_dark.png b/screenshots/divider_dark.png
deleted file mode 100644
index 5b5c41f1..00000000
Binary files a/screenshots/divider_dark.png and /dev/null differ
diff --git a/screenshots/divider_light.png b/screenshots/divider_light.png
deleted file mode 100644
index 32de4873..00000000
Binary files a/screenshots/divider_light.png and /dev/null differ
diff --git a/screenshots/drawer_dark.gif b/screenshots/drawer_dark.gif
deleted file mode 100644
index 69d0fe86..00000000
Binary files a/screenshots/drawer_dark.gif and /dev/null differ
diff --git a/screenshots/drawer_light.gif b/screenshots/drawer_light.gif
deleted file mode 100644
index 1df06844..00000000
Binary files a/screenshots/drawer_light.gif and /dev/null differ
diff --git a/screenshots/label_dark.png b/screenshots/label_dark.png
deleted file mode 100644
index f92f96e1..00000000
Binary files a/screenshots/label_dark.png and /dev/null differ
diff --git a/screenshots/label_light.png b/screenshots/label_light.png
deleted file mode 100644
index 2ff80c2c..00000000
Binary files a/screenshots/label_light.png and /dev/null differ
diff --git a/screenshots/line_edit_dark.png b/screenshots/line_edit_dark.png
deleted file mode 100644
index 9c95b766..00000000
Binary files a/screenshots/line_edit_dark.png and /dev/null differ
diff --git a/screenshots/line_edit_light.png b/screenshots/line_edit_light.png
deleted file mode 100644
index 055c5d28..00000000
Binary files a/screenshots/line_edit_light.png and /dev/null differ
diff --git a/screenshots/line_tab_widget_dark.gif b/screenshots/line_tab_widget_dark.gif
deleted file mode 100644
index acbb6dd6..00000000
Binary files a/screenshots/line_tab_widget_dark.gif and /dev/null differ
diff --git a/screenshots/line_tab_widget_light.gif b/screenshots/line_tab_widget_light.gif
deleted file mode 100644
index 6928f101..00000000
Binary files a/screenshots/line_tab_widget_light.gif and /dev/null differ
diff --git a/screenshots/loading_dark.gif b/screenshots/loading_dark.gif
deleted file mode 100644
index 8a7ac7d1..00000000
Binary files a/screenshots/loading_dark.gif and /dev/null differ
diff --git a/screenshots/loading_light.gif b/screenshots/loading_light.gif
deleted file mode 100644
index 8a24149f..00000000
Binary files a/screenshots/loading_light.gif and /dev/null differ
diff --git a/screenshots/menu_tab_widget_dark.png b/screenshots/menu_tab_widget_dark.png
deleted file mode 100644
index 3115962a..00000000
Binary files a/screenshots/menu_tab_widget_dark.png and /dev/null differ
diff --git a/screenshots/menu_tab_widget_light.png b/screenshots/menu_tab_widget_light.png
deleted file mode 100644
index 094a193c..00000000
Binary files a/screenshots/menu_tab_widget_light.png and /dev/null differ
diff --git a/screenshots/message_dark.gif b/screenshots/message_dark.gif
deleted file mode 100644
index 265357d3..00000000
Binary files a/screenshots/message_dark.gif and /dev/null differ
diff --git a/screenshots/message_light.gif b/screenshots/message_light.gif
deleted file mode 100644
index 82f1cf11..00000000
Binary files a/screenshots/message_light.gif and /dev/null differ
diff --git a/screenshots/page_dark.png b/screenshots/page_dark.png
deleted file mode 100644
index 4ca17cc7..00000000
Binary files a/screenshots/page_dark.png and /dev/null differ
diff --git a/screenshots/page_light.png b/screenshots/page_light.png
deleted file mode 100644
index ab6dbe68..00000000
Binary files a/screenshots/page_light.png and /dev/null differ
diff --git a/screenshots/progress_circle_dark.png b/screenshots/progress_circle_dark.png
deleted file mode 100644
index bf810531..00000000
Binary files a/screenshots/progress_circle_dark.png and /dev/null differ
diff --git a/screenshots/progress_circle_light.png b/screenshots/progress_circle_light.png
deleted file mode 100644
index 7085ea01..00000000
Binary files a/screenshots/progress_circle_light.png and /dev/null differ
diff --git a/screenshots/progressbar_dark.gif b/screenshots/progressbar_dark.gif
deleted file mode 100644
index aca38e06..00000000
Binary files a/screenshots/progressbar_dark.gif and /dev/null differ
diff --git a/screenshots/progressbar_light.gif b/screenshots/progressbar_light.gif
deleted file mode 100644
index a312650d..00000000
Binary files a/screenshots/progressbar_light.gif and /dev/null differ
diff --git a/screenshots/push_button_dark.png b/screenshots/push_button_dark.png
deleted file mode 100644
index 6ce338f5..00000000
Binary files a/screenshots/push_button_dark.png and /dev/null differ
diff --git a/screenshots/push_button_light.png b/screenshots/push_button_light.png
deleted file mode 100644
index b1ef63e8..00000000
Binary files a/screenshots/push_button_light.png and /dev/null differ
diff --git a/screenshots/radio_button_dark.png b/screenshots/radio_button_dark.png
deleted file mode 100644
index 51bebf00..00000000
Binary files a/screenshots/radio_button_dark.png and /dev/null differ
diff --git a/screenshots/radio_button_light.png b/screenshots/radio_button_light.png
deleted file mode 100644
index 974ae066..00000000
Binary files a/screenshots/radio_button_light.png and /dev/null differ
diff --git a/screenshots/slider_dark.png b/screenshots/slider_dark.png
deleted file mode 100644
index 6febed2c..00000000
Binary files a/screenshots/slider_dark.png and /dev/null differ
diff --git a/screenshots/slider_light.png b/screenshots/slider_light.png
deleted file mode 100644
index 5a872478..00000000
Binary files a/screenshots/slider_light.png and /dev/null differ
diff --git a/screenshots/spin_box_dark.png b/screenshots/spin_box_dark.png
deleted file mode 100644
index aa579058..00000000
Binary files a/screenshots/spin_box_dark.png and /dev/null differ
diff --git a/screenshots/spin_box_light.png b/screenshots/spin_box_light.png
deleted file mode 100644
index ac6054d2..00000000
Binary files a/screenshots/spin_box_light.png and /dev/null differ
diff --git a/screenshots/switch_dark.png b/screenshots/switch_dark.png
deleted file mode 100644
index 24412701..00000000
Binary files a/screenshots/switch_dark.png and /dev/null differ
diff --git a/screenshots/switch_light.png b/screenshots/switch_light.png
deleted file mode 100644
index f447d05a..00000000
Binary files a/screenshots/switch_light.png and /dev/null differ
diff --git a/screenshots/tag_dark.png b/screenshots/tag_dark.png
deleted file mode 100644
index b6e22c70..00000000
Binary files a/screenshots/tag_dark.png and /dev/null differ
diff --git a/screenshots/tag_light.png b/screenshots/tag_light.png
deleted file mode 100644
index be497384..00000000
Binary files a/screenshots/tag_light.png and /dev/null differ
diff --git a/screenshots/toast_dark.gif b/screenshots/toast_dark.gif
deleted file mode 100644
index dbb6395c..00000000
Binary files a/screenshots/toast_dark.gif and /dev/null differ
diff --git a/screenshots/toast_light.gif b/screenshots/toast_light.gif
deleted file mode 100644
index 1e121ee6..00000000
Binary files a/screenshots/toast_light.gif and /dev/null differ
diff --git a/screenshots/tool_button_dark.png b/screenshots/tool_button_dark.png
deleted file mode 100644
index f24cd8b1..00000000
Binary files a/screenshots/tool_button_dark.png and /dev/null differ
diff --git a/screenshots/tool_button_light.png b/screenshots/tool_button_light.png
deleted file mode 100644
index f054aaa6..00000000
Binary files a/screenshots/tool_button_light.png and /dev/null differ
diff --git a/scripts/deploy.py b/scripts/deploy.py
deleted file mode 100644
index 62bdedd9..00000000
--- a/scripts/deploy.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-
-"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import json
-import os
-import subprocess
-
-
-__author__ = "timmyliang"
-__email__ = "820472580@qq.com"
-__date__ = "2021-11-28 17:12:13"
-
-
-DIR = os.path.dirname(os.path.abspath(__file__))
-with open(os.path.join(DIR, "deploy.json"), "r") as f:
- data = json.load(f)
-
-
-username = data.get("username")
-password = data.get("password")
-subprocess.check_call(
- f"poetry publish --build --username {username} --password {password}"
-)
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/tests/for_test.txt b/tests/for_test.txt
deleted file mode 100644
index e69de29b..00000000
diff --git a/tests/test_alert.py b/tests/test_alert.py
deleted file mode 100644
index f7efb025..00000000
--- a/tests/test_alert.py
+++ /dev/null
@@ -1,87 +0,0 @@
-"""Test MAlert class"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets.alert import MAlert
-import pytest
-
-
-TYPE_LIST = (
- None,
- MAlert.InfoType,
- MAlert.SuccessType,
- MAlert.WarningType,
- MAlert.ErrorType,
-)
-
-TEST_INPUT = []
-TEST_OUTPUT = []
-for text in (None, "", "test"):
- input_dict = {} if text is None else {"text": text}
- result_dict = {"text": "" if text is None else text, "visible": bool(text)}
- for t in TYPE_LIST:
- if t is not None:
- input_dict.update({"type": t})
- result_dict.update({"type": t or "info"})
- TEST_INPUT.append(input_dict)
- TEST_OUTPUT.append(result_dict)
-
-
-@pytest.mark.parametrize(
- "kwargs,result", [(i, r) for i, r in zip(TEST_INPUT, TEST_OUTPUT)]
-)
-def test_malert_init(qtbot, kwargs, result):
- """Test MAlert with different arguments."""
- widget = MAlert()
- if kwargs.get("text"):
- widget.set_dayu_text(kwargs.get("text"))
- if kwargs.get("type"):
- widget.set_dayu_type(kwargs.get("type"))
- qtbot.addWidget(widget)
-
- assert widget.property("dayu_type") == result["type"]
- assert widget.property("dayu_text") == result["text"]
- assert widget.isVisible() == result["visible"]
-
-
-@pytest.mark.parametrize("input_type", ("infos", 3, None, {"name": "test"}))
-def test_malert_with_wrong_type(qtbot, input_type):
- """Test MAlert with wrong type for type arg"""
- with pytest.raises(ValueError) as exc_info:
- widget = MAlert()
- widget.set_dayu_type(input_type)
- qtbot.addWidget(widget)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'value' should be "
- "one of info/success/warning/error string."
- )
-
-
-@pytest.mark.parametrize(
- "input_text, error_type",
- (
- (3, int),
- ([], list),
- ((1,), tuple),
- (set(), set),
- ({}, dict),
- (object(), object),
- ),
-)
-def test_malert_with_wrong_text(qtbot, input_text, error_type):
- """Test MAlert with wrong type for text arg."""
- with pytest.raises(TypeError) as exc_info:
- widget = MAlert()
- widget.set_dayu_text(input_text)
- qtbot.addWidget(widget)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'value' should be string type, "
- "but get {}".format(error_type)
- )
diff --git a/tests/test_avatar.py b/tests/test_avatar.py
deleted file mode 100644
index 8add3e46..00000000
--- a/tests/test_avatar.py
+++ /dev/null
@@ -1,108 +0,0 @@
-"""
-Test MAvatar class
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.avatar import MAvatar
-from dayu_widgets.qt import MPixmap
-import pytest
-
-
-@pytest.mark.parametrize("image", ("check.svg", None))
-@pytest.mark.parametrize(
- "size,result",
- (
- (None, dayu_theme.default_size),
- (dayu_theme.tiny, dayu_theme.tiny),
- (dayu_theme.small, dayu_theme.small),
- (dayu_theme.medium, dayu_theme.medium),
- (dayu_theme.large, dayu_theme.large),
- (dayu_theme.huge, dayu_theme.huge),
- ),
-)
-def test_mavatar_init(qtbot, size, result, image):
- """Test for MAvatar init with different args"""
- widget = MAvatar()
- if image:
- widget.set_dayu_image(MPixmap(image))
- if size:
- widget.set_dayu_size(size)
-
- qtbot.addWidget(widget)
-
- assert widget.height() == result
- assert widget.width() == result
- assert widget.get_dayu_size() == result
- pix = widget.pixmap()
- assert pix is not None
- assert not pix.isNull()
- assert pix.width() == result
- assert pix.width() == result
-
- orig = MPixmap("sphere.svg")
- widget.set_dayu_image(orig)
- pix = widget.pixmap()
- assert pix is not None
- assert not pix.isNull()
- assert pix.width() == result
- assert pix.width() == result
- assert orig is widget.get_dayu_image()
-
-
-@pytest.mark.parametrize("image", ("check.svg", None))
-@pytest.mark.parametrize(
- "cls, result",
- (
- (MAvatar.tiny, dayu_theme.tiny),
- (MAvatar.small, dayu_theme.small),
- (MAvatar.medium, dayu_theme.medium),
- (MAvatar.large, dayu_theme.large),
- (MAvatar.huge, dayu_theme.huge),
- ),
-)
-def test_avatar_class_method(qtbot, cls, result, image):
- """Test for MAvatar class methods"""
- if image:
- widget = cls(MPixmap(image))
- else:
- widget = cls()
- qtbot.addWidget(widget)
-
- assert widget.height() == result
- assert widget.width() == result
- pix = widget.pixmap()
- assert pix is not None
- assert not pix.isNull()
- assert pix.width() == result
- assert pix.width() == result
-
-
-@pytest.mark.parametrize(
- "input_file, error_type",
- (
- ("3", str),
- (3, int),
- (set("google"), set),
- ({"name": "test"}, dict),
- (["g"], list),
- ((2,), tuple),
- (object(), object),
- ),
-)
-def test_mavatar_with_wrong_image(qtbot, input_file, error_type):
- """Make sure when user give a wrong type arg, raise TypeError"""
- with pytest.raises(TypeError) as exc_info:
- widget = MAvatar()
- widget.set_dayu_image(input_file)
- qtbot.addWidget(widget)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'value' should be QPixmap or None,"
- " but get {}".format(error_type)
- )
diff --git a/tests/test_badge.py b/tests/test_badge.py
deleted file mode 100644
index f0eae1dc..00000000
--- a/tests/test_badge.py
+++ /dev/null
@@ -1,139 +0,0 @@
-"""
-Test class MBadge.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from Qt import QtWidgets
-from dayu_widgets.badge import MBadge
-
-
-@pytest.mark.parametrize(
- "show, visible",
- (
- (True, True),
- (False, False),
- ),
-)
-def test_badge_dot(qtbot, show, visible):
- """Test MBadge init."""
- label = QtWidgets.QLabel("test")
- badge_1 = MBadge.dot(show=show, widget=label)
- badge_2 = MBadge.dot(show)
- main_widget = QtWidgets.QWidget()
- main_lay = QtWidgets.QVBoxLayout()
- main_widget.setLayout(main_lay)
- main_lay.addWidget(badge_1)
- main_lay.addWidget(badge_2)
- qtbot.addWidget(main_widget)
- main_widget.show()
-
- assert badge_1._badge_button.isVisible() == visible
- assert badge_2._badge_button.isVisible() == visible
- assert badge_1.get_dayu_dot() == show
- assert badge_2.get_dayu_dot() == show
- assert badge_1.get_dayu_text() is None
- assert badge_2.get_dayu_text() is None
- assert badge_1.get_dayu_count() is None
- assert badge_2.get_dayu_count() is None
-
-
-@pytest.mark.parametrize(
- "num, text, visible",
- (
- (1, "1", True),
- (100, "99+", True),
- (0, "0", False),
- (-1, "-1", False),
- ),
-)
-def test_badge_count(qtbot, num, text, visible):
- """Test MBadge init."""
- label = QtWidgets.QLabel("test")
- badge_1 = MBadge.count(count=num, widget=label)
- badge_2 = MBadge.count(num)
- main_widget = QtWidgets.QWidget()
- main_lay = QtWidgets.QVBoxLayout()
- main_widget.setLayout(main_lay)
- main_lay.addWidget(badge_1)
- main_lay.addWidget(badge_2)
- qtbot.addWidget(main_widget)
- main_widget.show()
-
- assert badge_1._badge_button.text() == text
- assert badge_1._badge_button.isVisible() == visible
- assert badge_2._badge_button.text() == text
- assert badge_2._badge_button.isVisible() == visible
- assert badge_1.get_dayu_dot() is False
- assert badge_2.get_dayu_dot() is False
- assert badge_1.get_dayu_text() is None
- assert badge_2.get_dayu_text() is None
- assert badge_1.get_dayu_count() == num
- assert badge_2.get_dayu_count() == num
- assert badge_1.get_dayu_overflow() == 99
- assert badge_2.get_dayu_overflow() == 99
-
-
-@pytest.mark.parametrize(
- "num, text, overflow",
- (
- (99, "99", 99),
- (100, "99+", 99),
- (20, "10+", 10),
- (9, "9", 10),
- ),
-)
-def test_badge_overflow(qtbot, num, text, overflow):
- """Test MBadge init."""
- badge = MBadge.count(num)
- badge.set_dayu_overflow(overflow)
- main_widget = QtWidgets.QWidget()
- main_lay = QtWidgets.QVBoxLayout()
- main_widget.setLayout(main_lay)
- main_lay.addWidget(badge)
- qtbot.addWidget(main_widget)
- main_widget.show()
-
- assert badge._badge_button.text() == text
- assert badge.get_dayu_dot() is False
- assert badge.get_dayu_text() is None
- assert badge.get_dayu_count() == num
- assert badge.get_dayu_overflow() == overflow
-
-
-@pytest.mark.parametrize(
- "content,text,visible",
- (
- ("hot", "hot", True),
- ("", "", False),
- ),
-)
-def test_badge_text(qtbot, content, text, visible):
- """Test MBadge init."""
- label = QtWidgets.QLabel("test")
- badge_1 = MBadge.text(text=content, widget=label)
- badge_2 = MBadge.text(text=content)
- main_widget = QtWidgets.QWidget()
- main_lay = QtWidgets.QVBoxLayout()
- main_widget.setLayout(main_lay)
- main_lay.addWidget(badge_1)
- main_lay.addWidget(badge_2)
- qtbot.addWidget(main_widget)
- main_widget.show()
-
- assert badge_1._badge_button.text() == text
- assert badge_1._badge_button.isVisible() == visible
- assert badge_2._badge_button.text() == text
- assert badge_2._badge_button.isVisible() == visible
- assert badge_1.get_dayu_dot() is False
- assert badge_2.get_dayu_dot() is False
- assert badge_1.get_dayu_text() == text
- assert badge_2.get_dayu_text() == text
- assert badge_1.get_dayu_count() is None
- assert badge_2.get_dayu_count() is None
diff --git a/tests/test_check_box.py b/tests/test_check_box.py
deleted file mode 100644
index a60fa05f..00000000
--- a/tests/test_check_box.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets.check_box import MCheckBox
-
-
-def test_radio_button_init(qtbot):
- radio_1 = MCheckBox("test")
- radio_2 = MCheckBox("")
- qtbot.addWidget(radio_1)
- qtbot.addWidget(radio_2)
-
- assert radio_1.text() == "test"
- assert radio_2.text() == ""
diff --git a/tests/test_divider.py b/tests/test_divider.py
deleted file mode 100644
index db55b7c4..00000000
--- a/tests/test_divider.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""
-Test class MDivider.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from Qt import QtCore
-from Qt import QtWidgets
-from dayu_widgets.divider import MDivider
-
-
-@pytest.mark.parametrize("text, visible_text", (("", False), ("test", True)))
-@pytest.mark.parametrize(
- "orient, visible_orient",
- ((QtCore.Qt.Horizontal, True), (QtCore.Qt.Vertical, False)),
- ids=("h", "v"),
-)
-@pytest.mark.parametrize(
- "align",
- (QtCore.Qt.AlignLeft, QtCore.Qt.AlignRight, QtCore.Qt.AlignCenter),
- ids=("l", "r", "c"),
-)
-def test_divider_init(qtbot, text, visible_text, orient, visible_orient, align):
- """Test MDivider init."""
- divider = MDivider(text, orientation=orient, alignment=align)
-
- divider.show()
-
- assert divider._text_label.text() == text
- # when orient is vertical, hide the text_label and right_frame
- show = visible_orient and visible_text
- _asset_divider_perform(divider, show, align)
- qtbot.addWidget(divider)
-
-
-@pytest.mark.parametrize("text, visible_text", (("", False), ("test", True)))
-def test_divider_class_method(qtbot, text, visible_text):
- """Test MDivider class methods."""
- main_widget = QtWidgets.QWidget()
- main_lay = QtWidgets.QVBoxLayout()
- main_widget.setLayout(main_lay)
-
- divider_left = MDivider.left(text)
- divider_center = MDivider.center(text)
- divider_right = MDivider.right(text)
- divider_ver = MDivider.vertical()
- main_lay.addWidget(divider_left)
- main_lay.addWidget(divider_center)
- main_lay.addWidget(divider_right)
- main_lay.addWidget(divider_ver)
- qtbot.addWidget(main_widget)
- main_widget.show()
-
- _asset_divider_perform(divider_left, True and visible_text, QtCore.Qt.AlignLeft)
- _asset_divider_perform(divider_right, True and visible_text, QtCore.Qt.AlignRight)
- _asset_divider_perform(divider_center, True and visible_text, QtCore.Qt.AlignCenter)
- _asset_divider_perform(divider_ver, False, QtCore.Qt.AlignCenter)
-
- assert divider_left.get_dayu_text() == text
- assert divider_right.get_dayu_text() == text
- assert divider_center.get_dayu_text() == text
- assert divider_ver.get_dayu_text() == ""
-
-
-def _asset_divider_perform(divider, show, align):
- assert divider._text_label.isVisible() == show
- assert divider._right_frame.isVisible() == show
- assert divider._main_lay.stretch(0) == MDivider._alignment_map.get(align)
- assert divider._main_lay.stretch(2) == (100 - MDivider._alignment_map.get(align))
diff --git a/tests/test_dock_widget.py b/tests/test_dock_widget.py
deleted file mode 100644
index b8f2b6c0..00000000
--- a/tests/test_dock_widget.py
+++ /dev/null
@@ -1,22 +0,0 @@
-"""Test MDockWidget class"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets.dock_widget import MDockWidget
-import pytest
-
-
-@pytest.mark.parametrize("title", ("", "test"))
-def test_dock_widget_init(qtbot, title):
- """Test MDockWidget init"""
- if title:
- dock_widget = MDockWidget(title)
- else:
- dock_widget = MDockWidget()
-
- qtbot.addWidget(dock_widget)
- dock_widget.show()
- assert dock_widget.widget() is None
diff --git a/tests/test_label.py b/tests/test_label.py
deleted file mode 100644
index c1f79a9c..00000000
--- a/tests/test_label.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-Test class MLabel.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from Qt import QtCore
-from Qt import QtWidgets
-from dayu_widgets.label import MLabel
-
-
-@pytest.mark.parametrize(
- "func,text,attr",
- (("h1", "any", 1), ("h2", "", 2), ("h3", "test", 3), ("h4", "doesn't matter", 4)),
-)
-def test_label_dayu_level(qtbot, func, text, attr):
- """Test MLabel with different level"""
- label = MLabel(text)
- getattr(label, func)()
- qtbot.addWidget(label)
-
- assert label.get_dayu_level() == attr
- assert label.text() == text
-
-
-@pytest.mark.parametrize(
- "func,text,attr",
- (
- (None, "any", ""),
- ("secondary", "Secondary", "secondary"),
- ("warning", "Warning", "warning"),
- ("danger", "Danger", "danger"),
- ),
-)
-def test_label_dayu_type(qtbot, func, text, attr):
- """Test MLabel with different type"""
- label = MLabel(text)
- if func:
- getattr(label, func)()
- qtbot.addWidget(label)
-
- assert label.get_dayu_type() == attr
- assert label.text() == text
-
-
-@pytest.mark.parametrize(
- "text, func, attr",
- (
- ("Mark", "mark", "dayu_mark"),
- ("Code", "code", "dayu_code"),
- ("Underline", "underline", "dayu_underline"),
- ("Delete", "delete", "dayu_delete"),
- ("Strong", "strong", "dayu_strong"),
- ),
-)
-def test_label_dayu_style(qtbot, func, text, attr):
- """Test MLabel with different style"""
- label = MLabel(text)
- getattr(label, func)()
- qtbot.addWidget(label)
-
- assert label.property(attr)
- assert label.text() == text
-
-
-@pytest.mark.parametrize("text, elide", (("test" * 30, True), ("test", False)))
-def test_label_elide_mode(qtbot, text, elide):
- """Test MLabel elide mode"""
- main_widget = QtWidgets.QWidget()
- main_widget.setGeometry(0, 0, 30, 200)
- main_lay = QtWidgets.QVBoxLayout()
- main_widget.setLayout(main_lay)
-
- label_left = MLabel()
- label_left.set_elide_mode(QtCore.Qt.ElideLeft)
- label_left.setText(text)
- label_right = MLabel()
- label_right.set_elide_mode(QtCore.Qt.ElideRight)
- label_right.setText(text)
- label_center = MLabel(text)
- label_center.set_elide_mode(QtCore.Qt.ElideMiddle)
- label_center.setText(text)
-
- main_lay.addWidget(label_left)
- main_lay.addWidget(label_right)
- main_lay.addWidget(label_center)
-
- qtbot.addWidget(main_widget)
-
- main_widget.show()
- ellipsis = "…"
- if elide:
- assert label_left.property("text").startswith(ellipsis)
- assert label_right.property("text").endswith(ellipsis)
- center_text = label_center.property("text")
- assert center_text.count(ellipsis) and not center_text.endswith(ellipsis)
- else:
- assert label_left.property("text") == label_left.text()
- assert label_right.property("text") == label_right.text()
- assert label_center.property("text") == label_center.text()
- assert label_left.get_elide_mode() == QtCore.Qt.ElideLeft
- assert label_right.get_elide_mode() == QtCore.Qt.ElideRight
- assert label_center.get_elide_mode() == QtCore.Qt.ElideMiddle
diff --git a/tests/test_loading.py b/tests/test_loading.py
deleted file mode 100644
index abb81957..00000000
--- a/tests/test_loading.py
+++ /dev/null
@@ -1,67 +0,0 @@
-"""
-Test MLoading and MLoadingWrapper class
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from Qt import QtCore
-from Qt import QtWidgets
-from dayu_widgets import dayu_theme
-from dayu_widgets.loading import MLoading
-from dayu_widgets.loading import MLoadingWrapper
-
-
-@pytest.mark.parametrize(
- "cls, size",
- (
- (MLoading.tiny, dayu_theme.tiny),
- (MLoading.small, dayu_theme.small),
- (MLoading.medium, dayu_theme.medium),
- (MLoading.large, dayu_theme.large),
- (MLoading.huge, dayu_theme.huge),
- ),
-)
-@pytest.mark.parametrize("color", (None, "#13c2c2"))
-def test_loading_class_method(qtbot, cls, size, color):
- """Test for MLoading class methods"""
- if color:
- widget = cls(color=color)
- else:
- widget = cls()
- qtbot.addWidget(widget)
-
- assert widget.height() == size
- assert widget.width() == size
- pix = widget.pix
- assert pix is not None
- assert not pix.isNull()
- assert pix.width() == size
- assert pix.width() == size
-
-
-def test_loading_wrapper(qtbot):
- """Test for MLoadingWrapper class methods"""
- label = QtWidgets.QLabel("test")
- label.setFixedSize(QtCore.QSize(100, 100))
- widget = MLoadingWrapper(label, loading=False)
- widget.show()
- qtbot.addWidget(widget)
-
- assert not widget._loading_widget.isVisible()
- assert not widget._mask_widget.isVisible()
- assert not widget.get_dayu_loading()
-
- widget.set_dayu_loading(True)
-
- def check_loading_visible():
- assert widget.get_dayu_loading()
- assert widget._loading_widget.isVisible()
- assert widget._mask_widget.isVisible()
-
- qtbot.waitUntil(check_loading_visible)
diff --git a/tests/test_mixin.py b/tests/test_mixin.py
deleted file mode 100644
index 7b4ad564..00000000
--- a/tests/test_mixin.py
+++ /dev/null
@@ -1,280 +0,0 @@
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtCore
-from Qt import QtWidgets
-import pytest
-
-# Import local modules
-from dayu_widgets import mixin
-
-
-def test_property_mixin(qtbot):
- @mixin.property_mixin
- class _TestClass(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(_TestClass, self).__init__(parent)
- self._test_attr = None
- self.set_my_property("first_value")
-
- def set_my_property(self, value):
- self.setProperty("my_property", value)
-
- def _set_my_property(self, value):
- self._test_attr = value
-
- test_widget = _TestClass()
- assert test_widget._test_attr == "first_value"
- qtbot.addWidget(test_widget)
- test_widget.set_my_property("test_string")
- assert test_widget._test_attr == "test_string"
-
-
-def test_cursor_mixin(qtbot):
- @mixin.cursor_mixin
- class _TestClass(QtWidgets.QPushButton):
- def __init__(self, parent=None):
- super(_TestClass, self).__init__(parent)
- geo = QtWidgets.QApplication.desktop().screenGeometry()
- self.setGeometry(
- geo.width() / 4, geo.height() / 4, geo.width() / 2, geo.height() / 2
- )
-
- main_widget = QtWidgets.QWidget()
- button_test = _TestClass()
- button_normal = QtWidgets.QPushButton()
- test_lay = QtWidgets.QVBoxLayout()
- test_lay.addWidget(button_test)
- test_lay.addWidget(button_normal)
- main_widget.setLayout(test_lay)
-
- qtbot.addWidget(main_widget)
- main_widget.show()
- button_test.setEnabled(False)
- assert QtWidgets.QApplication.overrideCursor() is None # Not override cursor
-
- qtbot.mouseMove(button_test) # mouse enter
-
- def check_cursor():
- assert QtWidgets.QApplication.overrideCursor() is not None
- assert (
- QtWidgets.QApplication.overrideCursor().shape() == QtCore.Qt.ForbiddenCursor
- )
-
- qtbot.waitUntil(check_cursor)
-
- qtbot.mouseMove(button_normal) # mouse leave
-
- def check_cursor():
- assert (
- QtWidgets.QApplication.overrideCursor() is None
- ) # Restore override cursor
-
- qtbot.waitUntil(check_cursor)
-
- button_test.setEnabled(True)
- qtbot.mouseMove(button_test) # mouse enter
-
- def check_cursor():
- assert QtWidgets.QApplication.overrideCursor() is not None
- assert (
- QtWidgets.QApplication.overrideCursor().shape()
- == QtCore.Qt.PointingHandCursor
- )
-
- qtbot.waitUntil(check_cursor)
-
- qtbot.mouseMove(button_normal) # mouse leave
-
- def check_cursor():
- assert (
- QtWidgets.QApplication.overrideCursor() is None
- ) # Restore override cursor
-
- qtbot.waitUntil(check_cursor)
-
-
-def test_focus_shadow_mixin(qtbot):
- @mixin.focus_shadow_mixin
- class _TestClass(QtWidgets.QPushButton):
- def __init__(self, parent=None):
- super(_TestClass, self).__init__(parent)
- geo = QtWidgets.QApplication.desktop().screenGeometry()
- self.setGeometry(
- geo.width() / 4, geo.height() / 4, geo.width() / 2, geo.height() / 2
- )
-
- main_widget = QtWidgets.QWidget()
- button_test = _TestClass()
-
- button_normal = QtWidgets.QPushButton()
- test_lay = QtWidgets.QVBoxLayout()
- test_lay.addWidget(button_test)
- test_lay.addWidget(button_normal)
- main_widget.setLayout(test_lay)
-
- qtbot.addWidget(main_widget)
-
- assert button_test.graphicsEffect() is None
-
- main_widget.show()
- main_widget.setFocus()
- # focus in
-
- qtbot.mouseClick(button_test, QtCore.Qt.LeftButton)
-
- def check_focus_in():
- graphics_effect = button_test.graphicsEffect()
- assert graphics_effect is not None
- assert graphics_effect.isEnabled()
- assert isinstance(graphics_effect, QtWidgets.QGraphicsDropShadowEffect)
-
- qtbot.waitUntil(check_focus_in)
-
- qtbot.mouseClick(button_normal, QtCore.Qt.LeftButton) # focus out
-
- def check_effect():
- assert button_test.graphicsEffect() is not None
- assert not button_test.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_effect)
-
- qtbot.mouseClick(button_test, QtCore.Qt.LeftButton) # focus in
-
- def check_effect():
- assert button_test.graphicsEffect() is not None
- assert button_test.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_effect)
-
-
-def test_hover_shadow_mixin(qtbot):
- @mixin.hover_shadow_mixin
- class _TestClass(QtWidgets.QPushButton):
- def __init__(self, parent=None):
- super(_TestClass, self).__init__(parent)
- geo = QtWidgets.QApplication.desktop().screenGeometry()
- self.setGeometry(
- geo.width() / 4, geo.height() / 4, geo.width() / 2, geo.height() / 2
- )
-
- main_widget = QtWidgets.QWidget()
- button_test = _TestClass()
- button_normal = QtWidgets.QPushButton()
- test_lay = QtWidgets.QVBoxLayout()
- test_lay.addWidget(button_test)
- test_lay.addWidget(button_normal)
- main_widget.setLayout(test_lay)
-
- qtbot.addWidget(main_widget)
-
- assert button_test.graphicsEffect() is None
-
- main_widget.show()
-
- qtbot.mouseMove(button_test) # mouse in
-
- def check_effect():
- graphics_effect = button_test.graphicsEffect()
- assert graphics_effect is not None
- assert graphics_effect.isEnabled()
- assert isinstance(graphics_effect, QtWidgets.QGraphicsDropShadowEffect)
-
- qtbot.waitUntil(check_effect)
-
- qtbot.mouseMove(button_normal) # mouse out
-
- def check_effect():
- assert button_test.graphicsEffect() is not None
- assert not button_test.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_effect)
-
- qtbot.mouseMove(button_test) # mouse in
-
- def check_effect():
- assert button_test.graphicsEffect() is not None
- assert button_test.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_effect)
-
-
-@pytest.mark.parametrize(
- "input_widget, result",
- (
- (QtWidgets.QLabel, False),
- (QtWidgets.QWidget, False),
- (QtWidgets.QStackedWidget, True),
- (QtWidgets.QStackedLayout, False),
- (QtWidgets.QTabWidget, True),
- (QtWidgets.QTabBar, False),
- ),
-)
-def test_stackable(input_widget, result):
- assert mixin._stackable(input_widget) == result
-
-
-def test_stacked_animation_mixin_normal(qtbot):
- @mixin.stacked_animation_mixin
- class _TestClass(QtWidgets.QStackedWidget):
- def __init__(self, parent=None):
- super(_TestClass, self).__init__(parent)
-
- main_widget = _TestClass()
- qtbot.addWidget(main_widget)
- assert hasattr(main_widget, "_to_show_pos_ani")
- assert isinstance(main_widget._to_show_pos_ani, QtCore.QPropertyAnimation)
- assert hasattr(main_widget, "_to_hide_pos_ani")
- assert isinstance(main_widget._to_hide_pos_ani, QtCore.QPropertyAnimation)
- assert hasattr(main_widget, "_opacity_eff")
- assert isinstance(main_widget._opacity_eff, QtWidgets.QGraphicsOpacityEffect)
- assert hasattr(main_widget, "_opacity_ani")
- assert isinstance(main_widget._opacity_ani, QtCore.QPropertyAnimation)
- assert hasattr(main_widget, "_play_anim")
- assert hasattr(main_widget, "_disable_opacity")
-
- assert main_widget._previous_index == 0
- label_1 = QtWidgets.QLabel("test")
- index_1 = main_widget.addWidget(label_1)
-
- def check_index():
- assert main_widget._previous_index == index_1
- assert not label_1.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_index)
-
- label_2 = QtWidgets.QLabel("test2")
- index_2 = main_widget.addWidget(label_2)
- main_widget.setCurrentIndex(index_1)
-
- def check_index():
- assert main_widget._previous_index == index_1
- assert not label_1.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_index)
- main_widget.setCurrentIndex(index_2)
-
- def check_index():
- assert main_widget._previous_index == index_2
- assert not label_2.graphicsEffect().isEnabled()
-
- qtbot.waitUntil(check_index)
-
-
-def test_stacked_animation_mixin_error(qtbot):
- @mixin.stacked_animation_mixin
- class _TestClass(QtWidgets.QPushButton):
- def __init__(self, parent=None):
- super(_TestClass, self).__init__(parent)
-
- main_widget = _TestClass()
- qtbot.addWidget(main_widget)
- assert not hasattr(main_widget, "_to_show_pos_ani")
- assert not hasattr(main_widget, "_to_hide_pos_ani")
- assert not hasattr(main_widget, "_opacity_eff")
- assert not hasattr(main_widget, "_opacity_ani")
- assert not hasattr(main_widget, "_play_anim")
- assert not hasattr(main_widget, "_disable_opacity")
diff --git a/tests/test_progress_bar.py b/tests/test_progress_bar.py
deleted file mode 100644
index 914a5a14..00000000
--- a/tests/test_progress_bar.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets.progress_bar import MProgressBar
-
-
-def test_progress_bar_init(qtbot):
- bar = MProgressBar()
- bar.setRange(0, 10)
- bar.setValue(5)
- assert bar.text() == "50%"
diff --git a/tests/test_progress_circle.py b/tests/test_progress_circle.py
deleted file mode 100644
index 5a756ad2..00000000
--- a/tests/test_progress_circle.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from Qt import QtWidgets
-import pytest
-
-# Import local modules
-from dayu_widgets.progress_circle import MProgressCircle
-
-
-def test_progress_circle_init(qtbot):
- circle = MProgressCircle()
- circle.setRange(0, 10)
- circle.setValue(5)
- qtbot.addWidget(circle)
- assert circle.text() == "50%"
-
-
-@pytest.mark.parametrize("width, result", ((80, 80), (100, 100), (120, 120)))
-def test_progress_circle_width(qtbot, width, result):
- circle = MProgressCircle()
- circle.set_dayu_width(width)
- dashboard = MProgressCircle(dashboard=True)
- dashboard.set_dayu_width(width)
- qtbot.addWidget(circle)
- qtbot.addWidget(dashboard)
- assert circle.width() == result
- assert circle.height() == result
- assert circle.get_dayu_width() == result
-
- assert dashboard.width() == result
- assert dashboard.height() < result
- assert dashboard.get_dayu_width() == result
-
-
-@pytest.mark.parametrize(
- "color, result",
- (
- ("#f00", "#f00"),
- ("#fff", "#fff"),
- ),
-)
-def test_progress_circle_color(qtbot, color, result):
- circle = MProgressCircle()
- circle.set_dayu_color(color)
- qtbot.addWidget(circle)
- circle.show()
- assert circle.get_dayu_color() == result
- circle.set_dayu_color("#0f0")
- assert circle.get_dayu_color() == "#0f0"
- circle.setValue(20)
- assert circle.text() == "20%"
-
-
-def test_progress_circle_widget(qtbot):
- label = QtWidgets.QLabel("text")
- circle = MProgressCircle()
- circle.set_widget(label)
- qtbot.addWidget(circle)
- circle.show()
- circle.repaint()
-
- def check():
- assert not circle.isTextVisible()
- assert not circle._default_label.isVisible()
- assert label.isVisible()
-
- qtbot.waitUntil(check)
-
-
-def test_progress_circle_class_method(qtbot):
- circle = MProgressCircle.dashboard()
- qtbot.addWidget(circle)
- assert circle.width() > circle.height()
diff --git a/tests/test_push_button.py b/tests/test_push_button.py
deleted file mode 100644
index 0c02880d..00000000
--- a/tests/test_push_button.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""Test MPushButton"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.push_button import MPushButton
-from dayu_widgets.qt import MIcon
-import pytest
-
-
-MPUSHBUTTON_TYPE_LIST = (
- MPushButton.DefaultType,
- MPushButton.PrimaryType,
- MPushButton.SuccessType,
- MPushButton.WarningType,
- MPushButton.DangerType,
-)
-
-
-@pytest.mark.parametrize("dayu_type", MPUSHBUTTON_TYPE_LIST)
-@pytest.mark.parametrize(
- "dayu_size",
- (
- dayu_theme.huge,
- dayu_theme.large,
- dayu_theme.medium,
- dayu_theme.small,
- dayu_theme.tiny,
- ),
-)
-@pytest.mark.parametrize("icon", (None, "success_fill.svg"))
-@pytest.mark.parametrize("text", ("test", ""))
-def test_mpushbutton_init(qtbot, dayu_type, dayu_size, icon, text):
- """Test MPushButton set_dayu_size and set_dayu_type."""
- widget = MPushButton(icon=MIcon(icon) if icon else icon, text=text)
- widget.set_dayu_size(dayu_size)
- widget.set_dayu_type(dayu_type)
- qtbot.addWidget(widget)
-
- assert widget.property("dayu_type") == dayu_type
- assert widget.property("dayu_size") == dayu_size
-
-
-@pytest.mark.parametrize(
- "attr, dayu_type",
- zip((None, "primary", "success", "warning", "danger"), MPUSHBUTTON_TYPE_LIST),
-)
-def test_chain_method(qtbot, attr, dayu_type):
- """Test MPushButton class methods."""
- widget = MPushButton()
- if attr:
- getattr(widget, attr)()
- # widget.set_dayu_type(dayu_type)
- qtbot.addWidget(widget)
- assert widget.property("dayu_type") == dayu_type
- assert widget.property("dayu_size") == dayu_theme.default_size
-
-
-@pytest.mark.parametrize("input_type", ("infos", 3, None, {"name": "test"}))
-def test_with_wrong_type(qtbot, input_type):
- """Test MPushButton set_dayu_type method with wrong arg. raise ValueError."""
- with pytest.raises(ValueError) as exc_info:
- widget = MPushButton()
- widget.set_dayu_type(input_type)
- qtbot.addWidget(widget)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'value' should be one of "
- "default/primary/success/warning/danger string."
- )
diff --git a/tests/test_radio_button.py b/tests/test_radio_button.py
deleted file mode 100644
index f5efad72..00000000
--- a/tests/test_radio_button.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets.radio_button import MRadioButton
-
-
-def test_radio_button_init(qtbot):
- radio_1 = MRadioButton("test")
- radio_2 = MRadioButton("")
- qtbot.addWidget(radio_1)
- qtbot.addWidget(radio_2)
-
- assert radio_1.text() == "test"
- assert radio_2.text() == ""
diff --git a/tests/test_slider.py b/tests/test_slider.py
deleted file mode 100644
index 7073dd2a..00000000
--- a/tests/test_slider.py
+++ /dev/null
@@ -1,30 +0,0 @@
-"""Test MSlider class"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from Qt import QtCore
-from dayu_widgets.slider import MSlider
-
-
-@pytest.mark.parametrize("orient", (QtCore.Qt.Horizontal, QtCore.Qt.Vertical))
-def test_slider_init(qtbot, orient):
- """Test MSlider init"""
- slider = MSlider(orientation=orient)
- slider.setValue(10)
- qtbot.addWidget(slider)
- slider.show()
-
- assert slider.value() == 10
-
- # test mouseMoveEvent, show the tooltip
- # qtbot.mouseMove(slider) # mouse enter
- # qtbot.mousePress(slider, Qt.LeftButton) # click
- # qtbot.mouseMove(slider) # click
-
- # assert slider.toolTip() == '10'
diff --git a/tests/test_spin_box.py b/tests/test_spin_box.py
deleted file mode 100644
index cad3081e..00000000
--- a/tests/test_spin_box.py
+++ /dev/null
@@ -1,125 +0,0 @@
-"""Test class: MSpinBox MDoubleSpinBox MDateTimeEdit MDateEdit MTimeEdit"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import datetime
-
-# Import third-party modules
-from dayu_widgets import dayu_theme
-from dayu_widgets import spin_box
-import pytest
-
-
-@pytest.mark.parametrize(
- "size,attr, result",
- (
- (None, None, dayu_theme.default_size),
- (dayu_theme.default_size, None, dayu_theme.default_size),
- (dayu_theme.tiny, "tiny", dayu_theme.tiny),
- (dayu_theme.small, "small", dayu_theme.small),
- (dayu_theme.medium, "medium", dayu_theme.medium),
- (dayu_theme.large, "large", dayu_theme.large),
- (dayu_theme.huge, "huge", dayu_theme.huge),
- ),
-)
-class TestAbstractSpinBox(object):
- """
- Test subclasses of QAbstractSpinBox.
- Use same args for init
- """
-
- @staticmethod
- def test_mspinbox(qtbot, size, attr, result):
- """Test MSpinBox"""
- widget = spin_box.MSpinBox()
- if size:
- widget.set_dayu_size(size)
- qtbot.addWidget(widget)
- assert widget.property("dayu_size") == result
-
- widget_2 = spin_box.MSpinBox()
- if attr:
- getattr(widget_2, attr)()
- qtbot.addWidget(widget_2)
- assert widget_2.property("dayu_size") == result
-
- @staticmethod
- def test_mdoublespinbox(qtbot, size, attr, result):
- """Test MDoubleSpinBox"""
- widget = spin_box.MDoubleSpinBox()
- if size:
- widget.set_dayu_size(size)
- qtbot.addWidget(widget)
- assert widget.property("dayu_size") == result
-
- widget_2 = spin_box.MDoubleSpinBox()
- if attr:
- getattr(widget_2, attr)()
- qtbot.addWidget(widget_2)
- assert widget_2.property("dayu_size") == result
-
- @staticmethod
- def test_mdatetimeedit(qtbot, size, attr, result):
- """Test MDateTimeEdit"""
- widget = spin_box.MDateTimeEdit()
- if size:
- widget.set_dayu_size(size)
- qtbot.addWidget(widget)
- assert widget.property("dayu_size") == result
-
- widget_2 = spin_box.MDateTimeEdit()
- if attr:
- getattr(widget_2, attr)()
- qtbot.addWidget(widget_2)
- assert widget_2.property("dayu_size") == result
-
- date_time_obj = datetime.datetime(2019, 1, 1)
- widget_with_datetime = spin_box.MDateTimeEdit(date_time_obj)
- qtbot.addWidget(widget_with_datetime)
- assert widget_with_datetime.property("dayu_size") == dayu_theme.default_size
- assert widget_with_datetime.dateTime() == date_time_obj
-
- @staticmethod
- def test_mdateedit(qtbot, size, attr, result):
- """Test MDateEdit"""
- widget = spin_box.MDateEdit()
- if size:
- widget.set_dayu_size(size)
- qtbot.addWidget(widget)
- assert widget.property("dayu_size") == result
-
- widget_2 = spin_box.MDateEdit()
- if attr:
- getattr(widget_2, attr)()
- qtbot.addWidget(widget_2)
- assert widget_2.property("dayu_size") == result
-
- date_time_obj = datetime.datetime(2019, 1, 1)
- widget_with_date = spin_box.MDateEdit(date_time_obj)
- qtbot.addWidget(widget_with_date)
- assert widget_with_date.property("dayu_size") == dayu_theme.default_size
- assert widget_with_date.date() == date_time_obj
-
- @staticmethod
- def test_mtimeedit(qtbot, size, attr, result):
- """Test MTimeEdit"""
- widget = spin_box.MTimeEdit()
- if size:
- widget.set_dayu_size(size)
- qtbot.addWidget(widget)
- assert widget.property("dayu_size") == result
-
- widget_2 = spin_box.MTimeEdit()
- if attr:
- getattr(widget_2, attr)()
- qtbot.addWidget(widget_2)
- assert widget_2.property("dayu_size") == result
-
- time_obj = datetime.datetime(2019, 1, 1).time()
- widget_with_time = spin_box.MTimeEdit(time_obj)
- qtbot.addWidget(widget_with_time)
- assert widget_with_time.property("dayu_size") == dayu_theme.default_size
- assert widget_with_time.time() == time_obj
diff --git a/tests/test_stacked_widget.py b/tests/test_stacked_widget.py
deleted file mode 100644
index b09eb025..00000000
--- a/tests/test_stacked_widget.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""Test MStackedWidget class"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import local modules
-from Qt import QtWidgets
-from dayu_widgets.stacked_widget import MStackedWidget
-
-
-def test_stacked_widget_init(qtbot):
- """Test MStackedWidget init"""
- stacked_widget = MStackedWidget()
- stacked_widget.addWidget(QtWidgets.QLabel("test"))
- qtbot.addWidget(stacked_widget)
- stacked_widget.show()
-
- assert stacked_widget.currentIndex() == 0
diff --git a/tests/test_switch.py b/tests/test_switch.py
deleted file mode 100644
index 271fadeb..00000000
--- a/tests/test_switch.py
+++ /dev/null
@@ -1,35 +0,0 @@
-"""Test MSwitch class"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import dayu_theme
-from dayu_widgets.switch import MSwitch
-import pytest
-
-
-@pytest.mark.parametrize(
- "cls, size",
- (
- ("tiny", dayu_theme.tiny),
- ("small", dayu_theme.small),
- ("medium", dayu_theme.medium),
- ("large", dayu_theme.large),
- ("huge", dayu_theme.huge),
- ),
-)
-def test_switch_class_method(qtbot, cls, size):
- """test MSwitch class method"""
- switch = MSwitch()
- getattr(switch, cls)()
- switch.setChecked(True)
- qtbot.addWidget(switch)
-
- assert switch.get_dayu_size() == size
- assert switch.isChecked()
- switch.setChecked(False)
- assert not switch.isChecked()
- assert switch.minimumSizeHint().width() == int(size * 1.2)
- assert switch.minimumSizeHint().height() == int(size * 0.6)
diff --git a/tests/test_utils_apply_formatter.py b/tests/test_utils_apply_formatter.py
deleted file mode 100644
index 55842e29..00000000
--- a/tests/test_utils_apply_formatter.py
+++ /dev/null
@@ -1,43 +0,0 @@
-"""Test utils.apply_formatter function."""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import utils
-import pytest
-
-
-def callable_for_test(*args, **kwargs):
- """A helper function for test when formatter is a complex callback function."""
- return "{};{}".format(
- ";".join([str(i) for i in args]),
- ";".join(["{}:{}".format(k, v) for k, v in kwargs.items()]),
- )
-
-
-COLOR_CONFIG_DICT = {"error": "#f00", "ok": "#0f0", "warning": "#ff0"}
-
-
-@pytest.mark.parametrize(
- "formatter,result,args,kwargs",
- (
- (None, "xiaoming", ("xiaoming",), {"age": 19}),
- (COLOR_CONFIG_DICT, "#f00", ("error",), {}),
- (COLOR_CONFIG_DICT, "#f00", ("error", 3), {"age": 19}),
- (COLOR_CONFIG_DICT, "#0f0", ("ok",), {}),
- (COLOR_CONFIG_DICT, "#ff0", ("warning",), {}),
- (COLOR_CONFIG_DICT, None, ("other",), {}),
- (lambda x, y: x + y, 3, (1, 2), {}),
- (lambda x, y: x + y, "helloxiaoming", ("hello", "xiaoming"), {}),
- # (callable_for_test, '1;2;age:18;name:xiaoming', (1, 2), {'name': 'xiaoming', 'age': 18}),
- ("Show Me", "Show Me", ("xiaoming",), {"age": 19}),
- ("Show Me", "Show Me", (1, 2), {"age": 19}),
- (100, 100, ("xiaoming",), {"age": 19}),
- (100, 100, (1, 2), {"age": 19}),
- ),
-)
-def test_apply_formatter(formatter, result, args, kwargs):
- """Test for apply_formatter with all situation."""
- assert utils.apply_formatter(formatter, *args, **kwargs) == result
diff --git a/tests/test_utils_color.py b/tests/test_utils_color.py
deleted file mode 100644
index 98bc73d0..00000000
--- a/tests/test_utils_color.py
+++ /dev/null
@@ -1,80 +0,0 @@
-"""
-Test Color helper functions.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from Qt import QtGui
-from dayu_widgets import utils
-
-
-@pytest.mark.parametrize(
- "color, alpha, result",
- (
- ("#ff0000", "20%", "rgba(255, 0, 0, 20%)"),
- ("#FF0000", "70%", "rgba(255, 0, 0, 70%)"),
- ("#00FF00", "40%", "rgba(0, 255, 0, 40%)"),
- ("#0a0a0a", "40%", "rgba(10, 10, 10, 40%)"),
- ("#aaa", "80%", "rgba(170, 170, 170, 80%)"),
- ("#009", "80%", "rgba(0, 0, 153, 80%)"),
- ("#ff", "80%", "rgba(0, 0, 0, 80%)"), # wrong color format
- ("#0090", "80%", "rgba(0, 0, 0, 80%)"), # wrong color format
- ),
-)
-def test_fade_color(color, alpha, result):
- """Test fade_color."""
- assert utils.fade_color(color, alpha) == result
-
-
-@pytest.mark.parametrize(
- "color, index, result",
- (
- ("#f5222d", 1, "#fff1f0"),
- ("#f5222d", 2, "#ffccc7"),
- ("#f5222d", 3, "#ffa39e"),
- ("#f5222d", 4, "#ff7875"),
- ("#f5222d", 5, "#ff4d4f"),
- ("#f5222d", 6, "#f5222d"),
- ("#f5222d", 7, "#cf1322"),
- ("#f5222d", 8, "#a8071a"),
- ("#f5222d", 9, "#820014"),
- ("#f5222d", 10, "#5c0011"),
- ("#a0d911", 1, "#fcffe6"),
- ("#a0d911", 3, "#eaff8f"),
- ("#a0d911", 5, "#bae637"),
- ("#a0d911", 7, "#7cb305"),
- ("#a0d911", 9, "#3f6600"),
- ("#722ed1", 2, "#efdbff"),
- ("#722ed1", 4, "#b37feb"),
- ("#722ed1", 6, "#722ed1"),
- ("#722ed1", 8, "#391085"),
- ("#722ed1", 10, "#120338"),
- ("#ffb7b2", 8, "#b36b6c"),
- ),
-)
-def test_generate_color(color, index, result):
- """
- test data reference from https://ant.design/docs/spec/colors-cn
- """
- assert compile_color(utils.generate_color(color, index), result)
-
-
-def compile_color(color1, color2):
- """
- There is some bias when calculate with float. Set margin of error to 0.01
- """
- delta = 0.01
- q_color_1 = QtGui.QColor(color1)
- q_color_2 = QtGui.QColor(color2)
-
- return (
- (abs(q_color_1.redF() - q_color_2.redF()) < delta)
- and (abs(q_color_1.greenF() - q_color_2.greenF()) < delta)
- and (abs(q_color_1.blueF() - q_color_2.blueF()) < delta)
- )
diff --git a/tests/test_utils_formatter.py b/tests/test_utils_formatter.py
deleted file mode 100644
index ab9329b6..00000000
--- a/tests/test_utils_formatter.py
+++ /dev/null
@@ -1,129 +0,0 @@
-"""
-Test the display_formatter icon_formatter font_formatter
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import datetime
-
-# Import third-party modules
-import pytest
-
-# Import local modules
-from dayu_widgets import utils
-from dayu_widgets.qt import MCacheDict
-
-
-class _HasNameObject(object):
- def __init__(self, name, age):
- super(_HasNameObject, self).__init__()
- self.name = name
- self.age = age
-
-
-class _HasCodeObject(object):
- def __init__(self, code, age):
- super(_HasCodeObject, self).__init__()
- self.code = code
- self.age = age
-
-
-class _HasNameAndCodeObject(object):
- def __init__(self, name, code, age):
- super(_HasNameAndCodeObject, self).__init__()
- self.name = name
- self.code = code
- self.age = age
-
-
-class _NoNameAndCodeObject(object):
- def __str__(self):
- return "MyNoNameAndCodeObject()"
-
-
-class _HasIconObject(object):
- def __init__(self, icon=None):
- super(_HasIconObject, self).__init__()
- self.icon = icon
-
-
-@pytest.mark.parametrize(
- "input_value, result",
- (
- ({"name": "Jim", "age": 18}, "Jim"),
- ([{"name": "Jim", "age": 18}, {"name": "Tom", "age": 16}], "Jim,Tom"),
- ({"code": "pl_0010", "id": 111}, "pl_0010"),
- (
- [{"code": "pl_0010", "id": 111}, {"code": "pl_0020", "id": 112}],
- "pl_0010,pl_0020",
- ),
- ({"id": 111, "age": 18}, str({"id": 111, "age": 18})),
- (
- [{"id": 111, "age": 18}, {"id": 112, "age": 19}],
- ",".join(
- [str(item) for item in [{"id": 111, "age": 18}, {"id": 112, "age": 19}]]
- ),
- ),
- ("test", "test"),
- (["test", "test2"], "test,test2"),
- ("test", "test"),
- (["test", "test2"], "test,test2"),
- (None, "--"),
- ([None, "hello"], "--,hello"),
- (_HasNameObject("Jim", 18), "Jim"),
- ([_HasNameObject("Jim", 18), _HasNameObject("Tom", 19)], "Jim,Tom"),
- (_HasCodeObject("pl_0010", 18), "pl_0010"),
- (_HasNameAndCodeObject("Jim", "pl_0010", 18), "Jim"),
- (_NoNameAndCodeObject(), "MyNoNameAndCodeObject()"),
- (datetime.datetime(2019, 1, 1), "2019-01-01 00:00:00"),
- (20, 20),
- (20.051, "20.05"),
- (20.058, "20.06"),
- ([20, 20.058], "20,20.06"),
- (set(), str(set())),
- ),
-)
-def test_utils_default_formatter(input_value, result):
- """Test default_formatter with all kinds of input type"""
- assert utils.display_formatter(input_value) == result
-
-
-@pytest.mark.parametrize("underline", (True, False))
-@pytest.mark.parametrize("bold", (True, False))
-def test_font_formatter(underline, bold):
- """Test font_formatter with different arg values"""
- font = utils.font_formatter({"underline": underline, "bold": bold})
- assert font.underline() == underline
- assert font.bold() == bold
-
-
-@pytest.mark.parametrize(
- "input_data, result",
- (
- ({"icon": "check.svg"}, "check.svg"),
- ({"icon": "add_line.svg"}, "add_line.svg"),
- ({"icon": {"icon": "add_line.svg"}}, "add_line.svg"),
- (("check.svg", "#f00"), "check.svg-#f00"),
- ("add_line.svg", "add_line.svg"),
- ({"name": "xiaoming"}, "confirm_fill.svg"),
- (None, "confirm_fill.svg"),
- (object(), "confirm_fill.svg"),
- (_HasIconObject(), "confirm_fill.svg"),
- (_HasIconObject(icon="check.svg"), "check.svg"),
- (_HasIconObject(icon=_HasIconObject("check.svg")), "check.svg"),
- ),
-)
-def test_icon_formatter(monkeypatch, input_data, result):
- """Test icon_formatter with different input type."""
-
- def _new_call(self, path, color=None):
- """Mock function for MIcon()"""
- if color:
- return "{}-{}".format(path, color)
- return path
-
- monkeypatch.setattr(MCacheDict, "__call__", _new_call)
- assert utils.icon_formatter(input_data) == result
diff --git a/tests/test_utils_from_list_to_nested_dict.py b/tests/test_utils_from_list_to_nested_dict.py
deleted file mode 100644
index a85c581f..00000000
--- a/tests/test_utils_from_list_to_nested_dict.py
+++ /dev/null
@@ -1,176 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Test the function from_list_to_nested_dict.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import utils
-import pytest
-
-
-TEST_DATA = (
- (
- ["a/b/c"],
- [
- {
- "value": "a",
- "label": "a",
- "children": [
- {
- "value": "b",
- "label": "b",
- "children": [{"value": "c", "label": "c"}],
- }
- ],
- }
- ],
- ),
- (
- ["a/b"],
- [{"value": "a", "label": "a", "children": [{"value": "b", "label": "b"}]}],
- ),
- (
- ["/a/b"],
- [{"value": "a", "label": "a", "children": [{"value": "b", "label": "b"}]}],
- ),
- (
- ["a/b/"],
- [{"value": "a", "label": "a", "children": [{"value": "b", "label": "b"}]}],
- ),
- (
- ["a/b/c", "a/b/d"],
- [
- {
- "value": "a",
- "label": "a",
- "children": [
- {
- "value": "b",
- "label": "b",
- "children": [
- {"value": "c", "label": "c"},
- {"value": "d", "label": "d"},
- ],
- }
- ],
- }
- ],
- ),
- (
- ["a/b/c", "a/m/n"],
- [
- {
- "value": "a",
- "label": "a",
- "children": [
- {
- "value": "b",
- "label": "b",
- "children": [{"value": "c", "label": "c"}],
- },
- {
- "value": "m",
- "label": "m",
- "children": [{"value": "n", "label": "n"}],
- },
- ],
- }
- ],
- ),
- (
- ["中国/北京/故宫", "中国/苏州/狮子林"],
- [
- {
- "value": "中国",
- "label": "中国",
- "children": [
- {
- "value": "北京",
- "label": "北京",
- "children": [{"value": "故宫", "label": "故宫"}],
- },
- {
- "value": "苏州",
- "label": "苏州",
- "children": [{"value": "狮子林", "label": "狮子林"}],
- },
- ],
- }
- ],
- ),
-)
-
-
-@pytest.mark.parametrize("input_,result", TEST_DATA, ids=[str(i[0]) for i in TEST_DATA])
-def test_from_list_to_nested_dict(input_, result):
- """Test with different level string."""
- assert utils.from_list_to_nested_dict(input_) == result
-
-
-def test_with_sep():
- """Test when sep is given."""
- result = [
- {
- "value": "a",
- "label": "a",
- "children": [
- {
- "value": "b",
- "label": "b",
- "children": [
- {"value": "c", "label": "c"},
- {"value": "d", "label": "d"},
- ],
- }
- ],
- }
- ]
- assert utils.from_list_to_nested_dict(["a@b@c", "a@b@d"], sep="@") == result
-
-
-@pytest.mark.parametrize(
- "input_arg, error_type",
- (
- (3, int),
- ("a_string", str),
- ({}, dict),
- (object(), object),
- ),
-)
-def test_with_input_wrong_type(input_arg, error_type):
- """Make sure when user give a wrong type arg, raise TypeError"""
- with pytest.raises(TypeError) as exc_info:
- utils.from_list_to_nested_dict(input_arg)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'input' should be list or tuple or set, "
- "but get {}".format(error_type)
- )
-
-
-@pytest.mark.parametrize(
- "input_sep, error_type",
- (
- (3, int),
- ([], list),
- ((1,), tuple),
- (set(), set),
- ({}, dict),
- (object(), object),
- ),
-)
-def test_with_sep_wrong_type(input_sep, error_type):
- """Make sure when user give a wrong type arg, raise TypeError"""
- with pytest.raises(TypeError) as exc_info:
- utils.from_list_to_nested_dict(["a@b@c", "a@b@d"], input_sep)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'sep' should be six.string_types, "
- "but get {}".format(error_type)
- )
diff --git a/tests/test_utils_get_percent.py b/tests/test_utils_get_percent.py
deleted file mode 100644
index 24370bf8..00000000
--- a/tests/test_utils_get_percent.py
+++ /dev/null
@@ -1,29 +0,0 @@
-"""
-Test get_percent.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import utils
-import pytest
-
-
-@pytest.mark.parametrize(
- "value, mini, maxi, result",
- (
- (0, 0, 100, 0),
- (100, 0, 100, 100),
- (1, 0, 100, 1),
- (99, 0, 100, 99),
- (-1, 0, 100, 0),
- (101, 0, 100, 100),
- (101, 10, 110, 91),
- (10, 100, 100, 100),
- ),
-)
-def test_get_percent(value, mini, maxi, result):
- """Test get_percent with normal arg."""
- assert utils.get_percent(value, mini, maxi) == result
diff --git a/tests/test_utils_get_static_file.py b/tests/test_utils_get_static_file.py
deleted file mode 100644
index 7665a804..00000000
--- a/tests/test_utils_get_static_file.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-"""
-Test get_static_file function.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import built-in modules
-import os
-
-# Import third-party modules
-import pytest
-import six
-
-# Import local modules
-from dayu_widgets import CUSTOM_STATIC_FOLDERS
-from dayu_widgets import DEFAULT_STATIC_FOLDER
-from dayu_widgets import utils
-
-
-@pytest.fixture(scope="module", name="custom_folder")
-def setup_custom_folder(tmpdir_factory):
- """Create a folder to represent user's custom static folder"""
- # user has his custom static folder
- # put this icons or images in it
- tmp_folder = tmpdir_factory.mktemp("my_static")
-
- # create a file in base dir
- tmp_folder.join("add_line.svg").ensure()
- # create a sub folder and a file in the sub folder
- tmp_folder.join("sub_folder", "sub_file.png").ensure()
- return tmp_folder
-
-
-@pytest.mark.parametrize(
- "input_path, output_path",
- (
- ("add_line.svg", os.path.join(DEFAULT_STATIC_FOLDER, "add_line.svg")),
- ("check.svg", os.path.join(DEFAULT_STATIC_FOLDER, "check.svg")),
- ("", None),
- ("a_not_exists_file", None),
- (
- os.path.join(os.path.dirname(__file__), "for_test.txt"),
- os.path.join(os.path.dirname(__file__), "for_test.txt"),
- ), # user give a full path file, return
- ("main.qss", os.path.join(DEFAULT_STATIC_FOLDER, "main.qss")),
- ),
-)
-def test_get_static_file(input_path, output_path):
- """Only default static file. Test different situation input."""
- assert utils.get_static_file(input_path) == output_path
-
-
-def test_custom_static_folder(custom_folder):
- """Test when user append a custom static folder."""
- CUSTOM_STATIC_FOLDERS.append(str(custom_folder))
- for input_file, result in (
- ("add_line.svg", os.path.join(DEFAULT_STATIC_FOLDER, "add_line.svg")),
- ("check.svg", os.path.join(DEFAULT_STATIC_FOLDER, "check.svg")),
- ("", None),
- ("a_not_exists_file", None),
- (
- os.path.join(os.path.dirname(__file__), "for_test.txt"),
- # user give a full path file, return
- os.path.join(os.path.dirname(__file__), "for_test.txt"),
- ),
- (
- "sub_folder/sub_file.png",
- os.path.join(str(custom_folder), "sub_folder/sub_file.png"),
- ),
- ):
- assert utils.get_static_file(input_file) == result
-
-
-@pytest.mark.parametrize(
- "input_file, error_type",
- (
- (3, int),
- (set(), set),
- ({}, dict),
- (["g"], list),
- ((2,), tuple),
- (object(), object),
- ),
-)
-def test_with_wrong_type(input_file, error_type):
- """Make sure when user give a wrong type arg, raise TypeError"""
- with pytest.raises(TypeError) as exc_info:
- utils.get_static_file(input_file)
-
- exception_msg = exc_info.value.args[0]
- print(exception_msg)
- assert (
- exception_msg
- == "Input argument 'path' should be six.string_types type, but get {}".format(
- error_type
- )
- )
diff --git a/tests/test_utils_obj_value.py b/tests/test_utils_obj_value.py
deleted file mode 100644
index 42c8313b..00000000
--- a/tests/test_utils_obj_value.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""
-Test get_obj_value set_obj_value has_obj_value
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import utils
-import pytest
-
-
-class _HasNameAgeObject(object):
- def __init__(self, name, age):
- super(_HasNameAgeObject, self).__init__()
- self.name = name
- self.age = age
-
-
-@pytest.mark.parametrize(
- "obj", ({"name": "xiaoming", "age": 18}, _HasNameAgeObject("xiaoming", 18))
-)
-class TestObjValue(object):
- """Test get_obj_value has_obj_value set_obj_value collection."""
-
- @pytest.mark.parametrize(
- "attr, default, result",
- (("name", "hhh", "xiaoming"), ("age", 0, 18), ("score", 0, 0)),
- )
- def test_get_obj_value(self, obj, attr, default, result):
- """Test get_obj_value with dict/object as arg."""
- assert utils.get_obj_value(obj, attr, default) == result
-
- @pytest.mark.parametrize(
- "attr, result",
- (
- ("name", True),
- ("age", True),
- ("sex", False),
- ),
- )
- def test_has_obj_value(self, obj, attr, result):
- """Test has_obj_value with dict/object as arg."""
- assert utils.has_obj_value(obj, attr) == result
-
- @pytest.mark.parametrize(
- "attr, value",
- (
- ("name", "xiaohua"),
- ("age", 30),
- ("id", 80),
- ),
- )
- def test_set_obj_value(self, obj, attr, value):
- """Test set_obj_value with dict/object as arg."""
- utils.set_obj_value(obj, attr, value)
- assert utils.get_obj_value(obj, attr) == value
diff --git a/tests/test_utils_overflow_format.py b/tests/test_utils_overflow_format.py
deleted file mode 100644
index e931de6d..00000000
--- a/tests/test_utils_overflow_format.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test overflow_format.
-"""
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import third-party modules
-from dayu_widgets import utils
-import pytest
-
-
-@pytest.mark.parametrize(
- "num, overflow, result",
- (
- (0, 99, "0"),
- (100, 99, "99+"),
- (20, 99, "20"),
- (20, 50, "20"),
- (-1, 50, "-1"),
- (99, 50, "50+"),
- ),
-)
-def test_overflow_format(num, overflow, result):
- """Test overflow_format with normal arg."""
- assert utils.overflow_format(num, overflow) == result
-
-
-@pytest.mark.parametrize(
- "num, overflow, error_type",
- ((0.0, 99, float), (20.0, 99.0, float), ("20", 50, str), (None, 50, type(None))),
-)
-def test_with_wrong_num_type(num, overflow, error_type):
- """Test overflow_format with wrong"""
- with pytest.raises(ValueError) as exc_info:
- utils.overflow_format(num, overflow)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'num' should be int type, "
- "but get {}".format(error_type)
- )
-
-
-@pytest.mark.parametrize(
- "num, overflow, error_type",
- (
- (100, 99.0, float),
- (10, "99", str),
- (0, None, type(None)),
- ),
-)
-def test_with_wrong_overflow_type(num, overflow, error_type):
- """Test overflow_format with wrong"""
- with pytest.raises(ValueError) as exc_info:
- utils.overflow_format(num, overflow)
-
- exception_msg = exc_info.value.args[0]
- assert (
- exception_msg == "Input argument 'overflow' should be int type, "
- "but get {}".format(error_type)
- )
diff --git a/tests/test_utils_real_model_and_real_index.py b/tests/test_utils_real_model_and_real_index.py
deleted file mode 100644
index 3629aaba..00000000
--- a/tests/test_utils_real_model_and_real_index.py
+++ /dev/null
@@ -1,95 +0,0 @@
-"""
-Test helper functions about Qt MVC: real_model, real_index
-"""
-
-# Import future modules
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-# Import local modules
-from Qt import QtCore
-from Qt import QtGui
-from dayu_widgets import utils
-
-
-def test_with_string_list_model():
- """Test when source model is QStringListModel"""
- source_model = QtCore.QStringListModel(["apple", "pear", "orange"])
- sort_filter_model_1 = QtCore.QSortFilterProxyModel()
- sort_filter_model_1.setSourceModel(source_model)
- sort_filter_model_2 = QtCore.QSortFilterProxyModel()
- sort_filter_model_2.setSourceModel(source_model)
- index_1 = source_model.index(0, 0)
- index_2 = source_model.index(1, 0)
- index_3 = sort_filter_model_1.index(0, 0)
- index_4 = sort_filter_model_1.index(1, 0)
- index_5 = sort_filter_model_2.index(1, 0)
- index_6 = sort_filter_model_2.index(1, 0)
- assert utils.real_model(source_model) is source_model
- assert utils.real_model(sort_filter_model_1) is source_model
- assert utils.real_model(sort_filter_model_2) is source_model
- assert utils.real_model(index_1) is source_model
- assert utils.real_model(index_2) is source_model
- assert utils.real_model(index_3) is source_model
- assert utils.real_model(index_4) is source_model
- assert utils.real_model(index_5) is source_model
- assert utils.real_model(index_6) is source_model
-
-
-def test_with_standard_item_model():
- """Test when source model is QStandardItemModel"""
- source_model = QtGui.QStandardItemModel(2, 2)
- sort_filter_model_1 = QtCore.QSortFilterProxyModel()
- sort_filter_model_1.setSourceModel(source_model)
- sort_filter_model_2 = QtCore.QSortFilterProxyModel()
- sort_filter_model_2.setSourceModel(source_model)
- index_1 = source_model.index(0, 0)
- index_2 = source_model.index(1, 1)
- index_3 = sort_filter_model_1.index(0, 1)
- index_4 = sort_filter_model_1.index(1, 1)
- index_5 = sort_filter_model_2.index(1, 0)
- index_6 = sort_filter_model_2.index(1, 1)
- assert utils.real_model(source_model) is source_model
- assert utils.real_model(sort_filter_model_1) is source_model
- assert utils.real_model(sort_filter_model_2) is source_model
- assert utils.real_model(index_1) is source_model
- assert utils.real_model(index_2) is source_model
- assert utils.real_model(index_3) is source_model
- assert utils.real_model(index_4) is source_model
- assert utils.real_model(index_5) is source_model
- assert utils.real_model(index_6) is source_model
-
-
-def test_real_index():
- """Test real_index function."""
- source_model = QtGui.QStandardItemModel(2, 2)
- sort_filter_model_1 = QtCore.QSortFilterProxyModel()
- sort_filter_model_1.setSourceModel(source_model)
- sort_filter_model_2 = QtCore.QSortFilterProxyModel()
- sort_filter_model_2.setSourceModel(source_model)
-
- index_1_source = source_model.index(0, 0)
- index_2_source = source_model.index(1, 1)
- index_3 = sort_filter_model_1.index(0, 0)
- index_4 = sort_filter_model_1.index(1, 1)
- index_5 = sort_filter_model_2.index(0, 0)
- index_6 = sort_filter_model_2.index(1, 1)
- assert utils.real_index(index_1_source) is index_1_source
- assert utils.real_index(index_2_source) is index_2_source
-
- assert compare_two_model_index(utils.real_index(index_3), index_1_source)
- assert compare_two_model_index(utils.real_index(index_4), index_2_source)
- assert compare_two_model_index(utils.real_index(index_5), index_1_source)
- assert compare_two_model_index(utils.real_index(index_6), index_2_source)
-
-
-def compare_two_model_index(index_1, index_2):
- """
- If the two input index's row and column and their parent is equal, then they are equal for test.
- """
- return (
- (index_1.row() == index_2.row())
- and (index_1.column() == index_2.column())
- and (index_1.parent() == index_2.parent())
- )