Last active
October 27, 2021 05:36
-
-
Save yamadaaaaaaa/c0d371003facd72c858b8fa788bf59fc to your computer and use it in GitHub Desktop.
ymd_launcher.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | |
| # ymd_launcher.py | |
| # VERSION : 1.0.0 | |
| # AUTHOR : yamada = ymd | |
| # DATE : 2021/8/1 | |
| # DESCRIPTION : DCC Launcher for Windows. | |
| # USAGE : ymd_launcher.mod copy to C:\Users\<user>\Documents\maya\<version>\modules | |
| # Open ymd_launcher.mod and change the path to the location where you placed the ymd_launcher folder. | |
| # just run this script in maya scriptEditor python tab | |
| # Copyright (c) 2020 ymd | |
| # The MIT License (MIT) | |
| #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | |
| import sys | |
| import os | |
| import re | |
| import traceback | |
| import subprocess | |
| import shutil | |
| import csv | |
| import string | |
| import ctypes | |
| import datetime | |
| import glob | |
| import functools | |
| from PySide2 import QtCore, QtGui, QtWidgets | |
| _qapp = -1 | |
| from shiboken2 import wrapInstance | |
| ui = None | |
| mainWindow = None | |
| #background-color: rgb(146, 140, 54); | |
| styleList = ''' | |
| QListWidget { | |
| show-decoration-selected: 1; | |
| selection-color: white; | |
| selection-background-color: rgb(62, 98, 173); | |
| color: rgb(255, 255, 255); | |
| background-color: rgb(30, 30, 30); | |
| } | |
| QListWidget::item:!selected:hover{ | |
| background-color: rgb(80, 80, 80); | |
| color: rgb(255, 255, 255); | |
| } | |
| QListWidget::item:selected:hover{ | |
| background-color: rgb(187, 85, 72); | |
| color: rgb(255, 255, 255); | |
| } | |
| ''' | |
| # border-style: inset; | |
| # border-width: 2px; | |
| # border-color: rgb(62, 98, 173); | |
| #background-color: rgb(146, 140, 54); | |
| #background-color: rgb(62, 98, 173); | |
| styleBtnA = ''' | |
| QPushButton { | |
| background-color: rgba(0, 0, 0, 0); | |
| selection-background-color: rgb(62, 98, 173); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| QPushButton:hover { | |
| background-color: rgb(62, 98, 173); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| QPushButton:checked { | |
| background-color: rgb(146, 140, 54); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| QPushButton:checked:hover { | |
| background-color: rgb(187, 85, 72); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| ''' | |
| styleBtnD = ''' | |
| QPushButton { | |
| background-color: rgb(110, 110, 110); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| QPushButton:hover { | |
| background-color: rgb(180, 180, 180); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| QPushButton:pressed { | |
| background-color: rgb(0, 0, 0); | |
| color: rgb(255, 255, 255); | |
| border-radius:10px; | |
| } | |
| QToolTip { | |
| background-color: black; | |
| color: white; | |
| border: black solid 1px; | |
| } | |
| ''' | |
| def get_module(): | |
| path_module = os.path.dirname(sys.argv[0]) | |
| path_module = os.path.dirname(path_module) | |
| path_modules = os.path.join(path_module,'modules') | |
| path_icon = os.path.join(path_module,'icons') | |
| path_conf = os.path.join(path_module,'prefs','ymd_launcher.json') | |
| path_image = os.path.join(path_module,'images') | |
| size_btn = 50 | |
| icon_listA = glob.glob(os.path.join(path_icon,"*.png")) | |
| icon_listB = glob.glob(os.path.join(path_icon,"*.jpg")) | |
| icon_listC = glob.glob(os.path.join(path_icon,"*.tif")) | |
| icon_list = icon_listA + icon_listB + icon_listC | |
| icon_list.sort() | |
| return path_modules, icon_list, path_conf, size_btn, path_image | |
| def get_drives(): | |
| list_drives = [] | |
| for _drive in string.ascii_uppercase: | |
| if not os.path.exists(_drive + ":" + os.sep):continue | |
| list_drives.append(_drive) | |
| return list_drives | |
| def save_prefs(): | |
| list_gui_value = list() | |
| is_temp = "FALSE" | |
| list_temp = list() | |
| path_conf_dir = os.path.join(path_module,'prefs') | |
| if not os.path.exists(path_conf_dir): | |
| os.makedirs(path_conf_dir) | |
| # 01 window size | |
| window_width = mainWindow.width() | |
| window_height = mainWindow.height() | |
| window_size = [window_width,window_height] | |
| list_gui_value.append(window_size) | |
| # 02 gui settings | |
| if ui.checkBox_dirMemory.checkState(): | |
| is_temp = "TRUE" | |
| list_gui_value.append([is_temp,ui.comboBox_fileTypeFilter.currentText()]) | |
| is_temp = "FALSE" | |
| # 03 gui dir | |
| for i in range(1, max_dir): | |
| gui_temp = getattr(ui, 'listWidget_dir' + str(i)) | |
| if not gui_temp.currentItem():continue | |
| list_temp.append(gui_temp.currentItem().text().encode("utf-8")) | |
| list_gui_value.append(list_temp) | |
| list_temp = list() | |
| # 04 bookmark | |
| _root = ui_bookmark.treeWidget_bookmark.invisibleRootItem() | |
| item_child = _root.childCount() | |
| for id in range(item_child): | |
| _item = _root.child(id) | |
| list_temp.append(_item.text(0) + "::" + _item.text(1)) | |
| list_gui_value.append(list_temp) | |
| list_temp = list() | |
| with open(path_conf, 'w') as f: | |
| csvWriter = csv.writer(f) | |
| for item_gui_value in list_gui_value: | |
| csvWriter.writerow(item_gui_value) | |
| def load_prefs(_mode=""): | |
| if not os.path.exists(path_conf):return | |
| with open(path_conf, 'rb') as f: | |
| csvReader = csv.reader(f) | |
| list_csv_value = [_row for _row in csvReader] | |
| if len(list_csv_value[0]) != 0: | |
| str_value = list_csv_value[0] | |
| mainWindow.resize(int(str_value[0]),int(str_value[1])) | |
| if len(list_csv_value[1]) != 0: | |
| str_value = list_csv_value[1] | |
| ui.checkBox_dirMemory.setChecked(str_value[0] == "TRUE") | |
| _id = ui.comboBox_fileTypeFilter.findText(str_value[1], QtCore.Qt.MatchFixedString) | |
| if _id >= 0: | |
| ui.comboBox_fileTypeFilter.setCurrentIndex(_id) | |
| if len(list_csv_value[3]) != 0: | |
| str_value = list_csv_value[3] | |
| list_temp = list() | |
| list_temp_tree = list() | |
| for _item in str_value: | |
| list_temp.append((_item.split("::")[0],_item.split("::")[1])) | |
| for _item in list_temp: | |
| item_tree = QtWidgets.QTreeWidgetItem(_item) | |
| list_temp_tree.append(item_tree) | |
| item_tree.setFlags(QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | \ | |
| QtCore.Qt.ItemIsSelectable) | |
| ui_bookmark.treeWidget_bookmark.addTopLevelItems(list_temp_tree) | |
| if len(list_csv_value[2]) != 0: | |
| str_value = list_csv_value[2] | |
| str_path = "" | |
| for _dir in str_value: | |
| if re.search(":",_dir): | |
| str_path = os.path.join(str_path, _dir + os.sep) | |
| else: | |
| str_path = os.path.join(str_path, _dir) | |
| set_path_expand("expand", str_path) | |
| ''' | |
| ui.listWidget_src.verticalScrollBar().valueChanged.connect(\ | |
| ui.listWidget_dst.verticalScrollBar().setValue) | |
| ui.listWidget_dst.verticalScrollBar().valueChanged.connect(\ | |
| ui.listWidget_src.verticalScrollBar().setValue) | |
| ''' | |
| class my_ScrollAreaDD(QtWidgets.QWidget): | |
| dropped = QtCore.Signal(list) | |
| def __init__(self, type, parent=None): | |
| super(my_ScrollAreaDD, self).__init__(parent) | |
| self.setAcceptDrops(True) | |
| def dragEnterEvent(self, event): | |
| if event.mimeData().hasUrls: | |
| event.accept() | |
| else: | |
| event.ignore() | |
| def dragMoveEvent(self, event): | |
| if event.mimeData().hasUrls: | |
| event.setDropAction(QtCore.Qt.CopyAction) | |
| event.accept() | |
| else: | |
| event.ignore() | |
| def dropEvent(self, event): | |
| if event.mimeData().hasUrls: | |
| event.setDropAction(QtCore.Qt.CopyAction) | |
| event.accept() | |
| file_path = [u.toLocalFile() for u in event.mimeData().urls()] | |
| self.dropped.emit(file_path) | |
| else: | |
| event.ignore() | |
| class my_widgetBtn(QtWidgets.QWidget): | |
| def __init__(self, *argv, **keywords ): | |
| super(my_widgetBtn,self).__init__(*argv,**keywords) | |
| self.gui_btn = [] | |
| self.add_button() | |
| def resizeEvent(self,event): | |
| self.resize_move_btn(self.size().width()) | |
| def resize_move_btn(self, wid): | |
| path_modules, icon_list, path_conf, size_btn, path_image = get_module() | |
| base_y = 0 | |
| base_x = 0 | |
| size_x = base_x | |
| size_y = base_y | |
| for btn in self.gui_btn: | |
| if wid > size_x + size_btn: | |
| btn.move(size_x, size_y) | |
| size_x = size_x + size_btn | |
| else: | |
| size_x = base_x | |
| size_y = size_y + size_btn | |
| btn.move(size_x, size_y) | |
| size_x = size_x + size_btn | |
| def add_button(self): | |
| path_modules, icon_list, path_conf, size_btn, path_image = get_module() | |
| self.gridLayout_btn = QtWidgets.QGridLayout(self) | |
| self.gridLayout_btn.setContentsMargins(0, 0, 0, 0) | |
| self.gridLayout_btn.setObjectName("gridLayout_btn") | |
| for i in range(len(icon_list)): | |
| item_btn = QtWidgets.QPushButton('',self) | |
| self.gridLayout_btn.addWidget(item_btn) | |
| self.gui_btn.append(item_btn) | |
| item_btn.setMaximumSize(QtCore.QSize(size_btn, size_btn)) | |
| item_btn.setMinimumSize(QtCore.QSize(size_btn, size_btn)) | |
| item_btn.move(0, 0) | |
| item_btn.setStyleSheet(styleBtnA) | |
| class my_ScrollArea(QtWidgets.QScrollArea): | |
| def __init__(self, parent=None): | |
| QtWidgets.QScrollArea.__init__(self, parent) | |
| #def moveEvent(self, event): | |
| # sequence = self.findChildren(QtWidgets.QPushButton) | |
| # height_btn = 0 | |
| # for obj_PushButton in sequence: | |
| # height_btn = obj_PushButton.height() | |
| # pos_y = obj_PushButton.y() | |
| # if height_btn == 0:return | |
| # size_bar = height_btn * (pos_y / height_btn) | |
| # self.verticalScrollBar().setMaximum(size_bar) | |
| # self.verticalScrollBar().update() | |
| # print(size_bar) | |
| def paintEvent(self, event): | |
| sequence = self.findChildren(QtWidgets.QPushButton) | |
| height_btn = 0 | |
| for obj_PushButton in sequence: | |
| height_btn = obj_PushButton.height() | |
| pos_y = obj_PushButton.y() | |
| if height_btn == 0:return | |
| size_bar = height_btn * (pos_y / height_btn) | |
| if pos_y + height_btn < self.size().height(): | |
| size_bar = 0.0 | |
| if size_bar == 0.0: | |
| self.verticalScrollBar().hide() | |
| return | |
| self.verticalScrollBar().show() | |
| self.verticalScrollBar().setMaximum(size_bar) | |
| #self.verticalScrollBar().update() | |
| #def resizeEvent(self, event): | |
| # self.verticalScrollBar().update() | |
| # sequence = self.findChildren(QtWidgets.QPushButton) | |
| # height_btn = 0 | |
| # for obj_PushButton in sequence: | |
| # height_btn = obj_PushButton.height() | |
| # pos_y = obj_PushButton.y() | |
| # if height_btn == 0:return | |
| # size_bar = height_btn * (pos_y / height_btn) | |
| # self.verticalScrollBar().setMaximum(size_bar) | |
| #def eventFilter(self, i_obj, i_event): | |
| # print(str(i_event.type())) | |
| class ymd_mainWindow(QtWidgets.QMainWindow): | |
| def __init__(self, *args, **kwargs): | |
| super(ymd_mainWindow, self).__init__(*args, **kwargs) | |
| #self.setWindowFlags(QtCore.Qt.FramelessWindowHint) | |
| self.is_drag = False | |
| self.pos = QtCore.QPoint(0, 0) | |
| def mousePressEvent(self, event): | |
| self.is_drag = True | |
| self.pos = event.pos() | |
| super(ymd_mainWindow, self).mousePressEvent(event) | |
| def mouseReleaseEvent(self, event): | |
| self.is_drag = False | |
| super(ymd_mainWindow, self).mouseReleaseEvent(event) | |
| def mouseMoveEvent(self, event): | |
| if self.is_drag: | |
| self.move(self.mapToParent(event.pos() - self.pos)) | |
| super(ymd_mainWindow, self).mouseMoveEvent(event) | |
| class Ui_Window_ymd_launcher(object): | |
| def setupUi(self, Window_ymd_launcher): | |
| Window_ymd_launcher.setObjectName("Window_ymd_launcher") | |
| Window_ymd_launcher.resize(441, 377) | |
| Window_ymd_launcher.setMinimumSize(QtCore.QSize(0, 0)) | |
| Window_ymd_launcher.setStyleSheet("background-color: rgb(50, 50, 50);\n" | |
| "color: rgb(255, 255, 255);\n" | |
| "") | |
| self.centralwidget = QtWidgets.QWidget(Window_ymd_launcher) | |
| self.centralwidget.setObjectName("centralwidget") | |
| self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget) | |
| self.gridLayout_3.setObjectName("gridLayout_3") | |
| self.widget_top = QtWidgets.QWidget(self.centralwidget) | |
| self.widget_top.setObjectName("widget_top") | |
| self.gridLayout_5 = QtWidgets.QGridLayout(self.widget_top) | |
| self.gridLayout_5.setContentsMargins(0, 0, 0, 0) | |
| self.gridLayout_5.setObjectName("gridLayout_5") | |
| self.splitter = QtWidgets.QSplitter(self.widget_top) | |
| self.splitter.setOrientation(QtCore.Qt.Vertical) | |
| self.splitter.setObjectName("splitter") | |
| self.scrollArea_up = my_ScrollArea(self.splitter) | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| sizePolicy.setHeightForWidth(self.scrollArea_up.sizePolicy().hasHeightForWidth()) | |
| self.scrollArea_up.setSizePolicy(sizePolicy) | |
| self.scrollArea_up.setMinimumSize(QtCore.QSize(0, 75)) | |
| self.scrollArea_up.setStyleSheet("background-color: rgb(30, 30, 30);") | |
| self.scrollArea_up.setFrameShape(QtWidgets.QFrame.NoFrame) | |
| self.scrollArea_up.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) | |
| self.scrollArea_up.setWidgetResizable(True) | |
| self.scrollArea_up.setObjectName("scrollArea_up") | |
| self.scrollAreaWidgetContents_2 = my_widgetBtn() | |
| self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 405, 75)) | |
| self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| self.scrollArea_up.setWidget(self.scrollAreaWidgetContents_2) | |
| self.frame_contents = QtWidgets.QFrame(self.splitter) | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| sizePolicy.setHeightForWidth(self.frame_contents.sizePolicy().hasHeightForWidth()) | |
| self.frame_contents.setSizePolicy(sizePolicy) | |
| self.frame_contents.setMinimumSize(QtCore.QSize(0, 0)) | |
| self.frame_contents.setMaximumSize(QtCore.QSize(16777212, 16777215)) | |
| self.frame_contents.setLayoutDirection(QtCore.Qt.LeftToRight) | |
| self.frame_contents.setAutoFillBackground(False) | |
| self.frame_contents.setStyleSheet("") | |
| self.frame_contents.setFrameShape(QtWidgets.QFrame.NoFrame) | |
| self.frame_contents.setFrameShadow(QtWidgets.QFrame.Plain) | |
| self.frame_contents.setObjectName("frame_contents") | |
| self.gridLayout_4 = QtWidgets.QGridLayout(self.frame_contents) | |
| self.gridLayout_4.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) | |
| self.gridLayout_4.setContentsMargins(0, 0, 0, 0) | |
| self.gridLayout_4.setSpacing(3) | |
| self.gridLayout_4.setObjectName("gridLayout_4") | |
| self.horizontalLayout_2 = QtWidgets.QHBoxLayout() | |
| self.horizontalLayout_2.setSpacing(6) | |
| self.horizontalLayout_2.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize) | |
| self.horizontalLayout_2.setObjectName("horizontalLayout_2") | |
| self.comboBox_project = QtWidgets.QComboBox(self.frame_contents) | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| sizePolicy.setHeightForWidth(self.comboBox_project.sizePolicy().hasHeightForWidth()) | |
| self.comboBox_project.setSizePolicy(sizePolicy) | |
| self.comboBox_project.setMinimumSize(QtCore.QSize(0, 30)) | |
| self.comboBox_project.setMaximumSize(QtCore.QSize(16777215, 30)) | |
| self.comboBox_project.setToolTip("") | |
| self.comboBox_project.setStyleSheet("background-color: rgb(30, 30, 30);") | |
| self.comboBox_project.setObjectName("comboBox_project") | |
| self.horizontalLayout_2.addWidget(self.comboBox_project) | |
| self.gridLayout_4.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) | |
| self.horizontalLayout_3 = QtWidgets.QHBoxLayout() | |
| self.horizontalLayout_3.setSpacing(3) | |
| self.horizontalLayout_3.setObjectName("horizontalLayout_3") | |
| self.listWidget_left = QtWidgets.QListWidget(self.frame_contents) | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| sizePolicy.setHeightForWidth(self.listWidget_left.sizePolicy().hasHeightForWidth()) | |
| self.listWidget_left.setSizePolicy(sizePolicy) | |
| self.listWidget_left.setMinimumSize(QtCore.QSize(200, 0)) | |
| self.listWidget_left.setMaximumSize(QtCore.QSize(16777215, 16777215)) | |
| self.listWidget_left.setStyleSheet("background-color: rgb(30, 30, 30);") | |
| self.listWidget_left.setFrameShape(QtWidgets.QFrame.NoFrame) | |
| self.listWidget_left.setObjectName("listWidget_left") | |
| self.horizontalLayout_3.addWidget(self.listWidget_left) | |
| self.listWidget_right = QtWidgets.QListWidget(self.frame_contents) | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| sizePolicy.setHeightForWidth(self.listWidget_right.sizePolicy().hasHeightForWidth()) | |
| self.listWidget_right.setSizePolicy(sizePolicy) | |
| self.listWidget_right.setMinimumSize(QtCore.QSize(200, 0)) | |
| self.listWidget_right.setMaximumSize(QtCore.QSize(16777215, 16777215)) | |
| self.listWidget_right.setStyleSheet("background-color: rgb(30, 30, 30);") | |
| self.listWidget_right.setFrameShape(QtWidgets.QFrame.NoFrame) | |
| self.listWidget_right.setObjectName("listWidget_right") | |
| self.horizontalLayout_3.addWidget(self.listWidget_right) | |
| self.gridLayout_4.addLayout(self.horizontalLayout_3, 1, 0, 1, 1) | |
| self.scrollArea_un = QtWidgets.QScrollArea(self.splitter) | |
| sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) | |
| sizePolicy.setHorizontalStretch(0) | |
| sizePolicy.setVerticalStretch(0) | |
| sizePolicy.setHeightForWidth(self.scrollArea_un.sizePolicy().hasHeightForWidth()) | |
| self.scrollArea_un.setSizePolicy(sizePolicy) | |
| self.scrollArea_un.setMinimumSize(QtCore.QSize(0, 75)) | |
| self.scrollArea_un.setStyleSheet("background-color: rgb(30, 30, 30);") | |
| self.scrollArea_un.setFrameShape(QtWidgets.QFrame.NoFrame) | |
| self.scrollArea_un.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) | |
| self.scrollArea_un.setWidgetResizable(True) | |
| self.scrollArea_un.setObjectName("scrollArea_un") | |
| self.scrollAreaWidgetContents = QtWidgets.QWidget() | |
| self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 405, 75)) | |
| self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") | |
| self.gridLayout = QtWidgets.QGridLayout(self.scrollAreaWidgetContents) | |
| self.gridLayout.setContentsMargins(0, 0, 0, 0) | |
| self.gridLayout.setSpacing(0) | |
| self.gridLayout.setObjectName("gridLayout") | |
| self.scrollArea_un.setWidget(self.scrollAreaWidgetContents) | |
| self.gridLayout_5.addWidget(self.splitter, 0, 0, 1, 1) | |
| self.horizontalLayout = QtWidgets.QHBoxLayout() | |
| self.horizontalLayout.setObjectName("horizontalLayout") | |
| self.checkBox_always = QtWidgets.QCheckBox(self.widget_top) | |
| self.checkBox_always.setMinimumSize(QtCore.QSize(65, 30)) | |
| self.checkBox_always.setMaximumSize(QtCore.QSize(65, 30)) | |
| self.checkBox_always.setObjectName("checkBox_always") | |
| self.horizontalLayout.addWidget(self.checkBox_always) | |
| self.widget_copyright = QtWidgets.QWidget(self.widget_top) | |
| self.widget_copyright.setMinimumSize(QtCore.QSize(0, 30)) | |
| self.widget_copyright.setMaximumSize(QtCore.QSize(16777215, 30)) | |
| self.widget_copyright.setLayoutDirection(QtCore.Qt.LeftToRight) | |
| self.widget_copyright.setObjectName("widget_copyright") | |
| self.gridLayout_6 = QtWidgets.QGridLayout(self.widget_copyright) | |
| self.gridLayout_6.setContentsMargins(0, 0, 0, 0) | |
| self.gridLayout_6.setObjectName("gridLayout_6") | |
| self.label = QtWidgets.QLabel(self.widget_copyright) | |
| self.label.setMinimumSize(QtCore.QSize(0, 14)) | |
| self.label.setMaximumSize(QtCore.QSize(16777215, 14)) | |
| self.label.setLayoutDirection(QtCore.Qt.LeftToRight) | |
| self.label.setStyleSheet("color: rgb(0, 0, 0);") | |
| self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) | |
| self.label.setObjectName("label") | |
| self.gridLayout_6.addWidget(self.label, 0, 1, 1, 1) | |
| self.horizontalLayout.addWidget(self.widget_copyright) | |
| self.pushButton_close = QtWidgets.QPushButton(self.widget_top) | |
| self.pushButton_close.setMinimumSize(QtCore.QSize(50, 20)) | |
| self.pushButton_close.setMaximumSize(QtCore.QSize(50, 20)) | |
| self.pushButton_close.setCursor(QtCore.Qt.PointingHandCursor) | |
| self.pushButton_close.setStyleSheet("background-color: rgb(110, 110, 110);\n" | |
| "color: rgb(255, 255, 255);border-radius:10px;") | |
| self.pushButton_close.setFlat(True) | |
| self.pushButton_close.setObjectName("pushButton_close") | |
| self.horizontalLayout.addWidget(self.pushButton_close) | |
| self.gridLayout_5.addLayout(self.horizontalLayout, 1, 0, 1, 1) | |
| self.gridLayout_3.addWidget(self.widget_top, 0, 0, 1, 1) | |
| Window_ymd_launcher.setCentralWidget(self.centralwidget) | |
| self.statusBar = QtWidgets.QStatusBar(Window_ymd_launcher) | |
| self.statusBar.setObjectName("statusBar") | |
| Window_ymd_launcher.setStatusBar(self.statusBar) | |
| self.actionHelp = QtWidgets.QAction(Window_ymd_launcher) | |
| self.actionHelp.setObjectName("actionHelp") | |
| self.retranslateUi(Window_ymd_launcher) | |
| QtCore.QMetaObject.connectSlotsByName(Window_ymd_launcher) | |
| def retranslateUi(self, Window_ymd_launcher): | |
| Window_ymd_launcher.setWindowTitle(QtWidgets.QApplication.translate("Window_ymd_launcher", "ymd_launcher", None, -1)) | |
| self.checkBox_always.setText(QtWidgets.QApplication.translate("Window_ymd_launcher", "Always", None, -1)) | |
| self.label.setText(QtWidgets.QApplication.translate("Window_ymd_launcher", "(c) 2020 ymd", None, -1)) | |
| self.pushButton_close.setText(QtWidgets.QApplication.translate("Window_ymd_launcher", "close", None, -1)) | |
| self.actionHelp.setText(QtWidgets.QApplication.translate("Window_ymd_launcher", "Help", None, -1)) | |
| def selected_dcc(obj_PushButton, dic_icon, ui): | |
| str_icon = dic_icon[obj_PushButton] | |
| print(str_icon) | |
| sequence = ui.scrollArea_up.findChildren(QtWidgets.QPushButton) | |
| for obj_PushButton_tmp in sequence: | |
| if obj_PushButton_tmp != obj_PushButton: | |
| obj_PushButton_tmp.setChecked(False) | |
| else: | |
| obj_PushButton_tmp.setChecked(True) | |
| ui.listWidget_left.addItem("2022 EN") | |
| ui.listWidget_right.addItem("2022 JP") | |
| class my_notificationArea(QtWidgets.QSystemTrayIcon): | |
| def __init__(self,parent=None): | |
| super(my_notificationArea,self).__init__(parent) | |
| path_modules, icon_list, path_conf, size_btn, path_image = get_module() | |
| icons = os.path.join(path_image,"ymd.png") | |
| hover_text = u"ymd_Launcher 1.0.0" | |
| self.actionQuit = QtWidgets.QAction(QtGui.QIcon(''),"&Quit",self, | |
| statusTip="Quit", triggered=self.Quit) | |
| self.actionShow = QtWidgets.QAction(QtGui.QIcon(''),"&show",self, | |
| statusTip="show", triggered=self.show_window) | |
| # contents context | |
| self.notificationIconMenu = QtWidgets.QMenu(parent) | |
| self.notificationIconMenu.addAction(self.actionShow) | |
| self.notificationIconMenu.addAction(self.actionQuit) | |
| # set context and icon | |
| self.notificationIcon = QtWidgets.QSystemTrayIcon(self) | |
| self.notificationIcon.setToolTip(hover_text) | |
| self.notificationIcon.setContextMenu(self.notificationIconMenu) | |
| self.notificationIcon.setIcon(QtGui.QIcon(icons)) | |
| self.notificationIcon.activated.connect(self.activatedNotification) | |
| self.notificationIcon.show() | |
| # set balloon | |
| icon = QtWidgets.QSystemTrayIcon.Information | |
| self.notificationIcon.showMessage(hover_text,u'run',icon,500) | |
| def activatedNotification(self, reason): | |
| if reason == QtWidgets.QSystemTrayIcon.Trigger: | |
| self.show_window() | |
| def Quit(self): | |
| QtWidgets.QApplication.quit() | |
| def show_window(self): | |
| mainWindow.show() | |
| def dropped_widget(filePaths): | |
| print(filePaths) | |
| def main(): | |
| global ui | |
| global mainWindow | |
| dic_icon = {} | |
| path_modules, icon_list, path_conf, size_btn, path_image = get_module() | |
| window_name = 'Window_ymd_launcher' | |
| tool_name = 'ymd_launcher' | |
| tool_ver = '1.0.0' | |
| app = QtWidgets.QApplication(sys.argv) | |
| mainWindow = ymd_mainWindow() | |
| mainWindow.setWindowTitle(QtWidgets.QApplication.translate( \ | |
| window_name, \ | |
| tool_name+' ver'+tool_ver, \ | |
| None, _qapp)) | |
| ##mainWindow.resize(100,500) | |
| ui = Ui_Window_ymd_launcher() | |
| ui.setupUi(mainWindow) | |
| # ui settings -------------------------------------------- | |
| # icons | |
| sequence = mainWindow.findChildren(QtWidgets.QPushButton) | |
| idx = 0 | |
| for obj_PushButton in sequence: | |
| if obj_PushButton.text() == 'close':continue | |
| if not os.path.exists(icon_list[idx]):continue | |
| image = QtGui.QImage(icon_list[idx]) | |
| for x in range(image.width()): | |
| for y in range(image.height()): | |
| pcolor = image.pixelColor(x, y) | |
| if pcolor.alpha() > 0: | |
| n_color = QtGui.QColor(pcolor) | |
| n_color.setAlpha(pcolor.alpha()*0.9) | |
| image.setPixelColor(x, y, n_color) | |
| q_pixmap = QtGui.QPixmap(image) | |
| q_icon = QtGui.QIcon(q_pixmap) | |
| obj_PushButton.setIcon(QtGui.QIcon(q_icon)) | |
| obj_PushButton.setIconSize(QtCore.QSize(size_btn-10,size_btn-10)) | |
| icon_name = os.path.splitext(os.path.basename(icon_list[idx]))[0] | |
| dic_icon.setdefault(obj_PushButton, icon_name) | |
| idx = idx + 1 | |
| obj_PushButton.clicked.connect(functools.partial(selected_dcc,obj_PushButton,dic_icon,ui)) | |
| obj_PushButton.setCheckable(True) | |
| mainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) | |
| mainWindow.setAttribute(QtCore.Qt.WA_TranslucentBackground) | |
| style_base = "background-color:rgba(146, 140, 54, 200);" | |
| style_widget = "border-top-left-radius:10px;border-top-right-radius:10px;" | |
| ui.centralwidget.setStyleSheet(style_base + style_widget) | |
| style_bar = "min-height: 10;border-bottom-left-radius:10px;border-bottom-right-radius:10px;" | |
| mainWindow.statusBar().setStyleSheet(style_base + style_bar) | |
| #ui.widget_top.setStyleSheet(style_base + "border-radius:10px;") | |
| ui.pushButton_close.setStyleSheet(styleBtnD) | |
| ui.listWidget_left.setFont(QtGui.QFont('Meiryo', 12)) | |
| ui.listWidget_right.setFont(QtGui.QFont('Meiryo', 12)) | |
| # keyboard ------------------------------------------------ | |
| QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Escape),mainWindow, mainWindow.hide) | |
| #QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_F5),MainWindow, ui.set_project) | |
| # ui connect ----------------------------------------------- | |
| QtCore.QObject.connect(ui.pushButton_close, QtCore.SIGNAL("clicked()"), mainWindow.hide) | |
| #ui.scrollArea_un.dropped.connect(dropped_widget) | |
| # --------------------------------------------------------- | |
| #load_prefs() | |
| #mainWindow.show() | |
| mainWindow.setAttribute(QtCore.Qt.WA_DeleteOnClose) | |
| # systray | |
| if not QtWidgets.QSystemTrayIcon.isSystemTrayAvailable() == True: | |
| raise OSError(u"not use") | |
| QtWidgets.QApplication.setQuitOnLastWindowClosed(False) | |
| my_notificationArea(mainWindow) | |
| sys.exit(app.exec_()) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment