Esempio n. 1
0
    def __init__(self, mode, list_item, port_queue, file_path, target_path='', file_size=0):
        super(TransItem, self).__init__()
        self.mode = mode
        if mode == 'UP':
            self._list_item_ = list_item
            self.port_queue = port_queue
            self.file_path = file_path
            self.target_path = target_path
            self.file_name = os.path.split(file_path)[-1]
            self.file_size = os.path.getsize(file_path)
        else:
            self._list_item_ = list_item
            self.port_queue = port_queue
            self.file_path = file_path            
            self.file_name = os.path.split(file_path)[-1]
            self.file_size = file_size
        self.setContentsMargins(0, 0, 0, 0)
        main_layout = QHBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.item_image = QLabel()
        self.item_image.setFixedSize(QSize(80, 80))
        item_layout = QVBoxLayout()
        self.item_name = QLabel()
        self.item_size = QLabel()
        item_layout.addWidget(self.item_name)
        item_layout.addWidget(self.item_size)
        self.progress_bar = QProgressBar()
        self.progress_bar.setValue(0)
        self.progress_bar.setFixedWidth(self.width()*0.8)
        button_layout = QHBoxLayout()
        self.start_pause_button = QPushButton()
        self.cancel_button = QPushButton()
        self.open_folder_button = QPushButton()
        self.start_pause_button.setCheckable(True)
        self.cancel_button.setCheckable(True)
        self.open_folder_button.setCheckable(True)
        self.start_pause_button.setObjectName('start_pause')
        self.cancel_button.setObjectName('cancel')
        self.open_folder_button.setObjectName('folder')
        button_layout.addWidget(self.start_pause_button)
        button_layout.addWidget(self.cancel_button)
        button_layout.addWidget(self.open_folder_button)
        main_layout.addWidget(self.item_image)
        main_layout.addLayout(item_layout)
        main_layout.addStretch()
        main_layout.addWidget(self.progress_bar)
        main_layout.addLayout(button_layout)
        self.setLayout(main_layout)

        self.item_name.setText(self.file_name)
        self.item_size.setText('0KB/' + str(int(self.file_size/1024)) + 'KB')
        self.item_image.setPixmap(get_pixmap(self.file_name, True).scaled(self.item_image.size()))

        self.item_image.setObjectName('transparent')
        self.item_name.setObjectName('transparent')
        self.item_size.setObjectName('transparent')

        self.start_pause_button.toggled.connect(self.start_pause_task)
        self.cancel_button.clicked.connect(self.cancel_task)
        self.open_folder_button.clicked.connect(self.open_folder)
Esempio n. 2
0
    def __init__(self, file_name, file_info, file_loc):
        super(AttributeWidget, self).__init__()
        # file_name  = file_info[0]
        # file_type  = file_info[1]
        # file_loc   = file_info[2]
        # file_size  = file_info[3]
        # file_ctime = file_info[4]
        # file_mtime = file_info[5]
        self.setWindowTitle('属性')
        pixmap = get_pixmap(file_name, file_info[0])

        file_image = QLabel()
        file_name = QLabel(file_name)
        file_type = QLabel(str(file_info[0]))
        file_loc = QLabel(file_loc)
        file_ctime = QLabel(
            time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(file_info[1])))
        file_mtime = QLabel(
            time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(file_info[2])))
        str_size = get_size(file_info[3])
        file_size = QLabel(str_size)

        h_layout = QHBoxLayout()
        h_layout.addWidget(file_image)
        h_layout.addWidget(file_name)

        grid_layout = QGridLayout()
        grid_layout.addWidget(QLabel('类型:'), 0, 0)
        grid_layout.addWidget(file_type, 0, 1)
        grid_layout.addWidget(QLabel('位置:'), 1, 0)
        grid_layout.addWidget(file_loc, 1, 1)
        grid_layout.addWidget(QLabel('大小:'), 2, 0)
        grid_layout.addWidget(file_size, 2, 1)
        grid_layout.addWidget(QLabel('创建时间:'), 3, 0)
        grid_layout.addWidget(file_ctime, 3, 1)
        grid_layout.addWidget(QLabel('修改时间:'), 4, 0)
        grid_layout.addWidget(file_mtime, 4, 1)

        main_layout = QVBoxLayout()
        main_layout.addLayout(h_layout)
        main_layout.addLayout(grid_layout)

        file_image.setPixmap(pixmap)
        file_name.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        file_name.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)

        self.setLayout(main_layout)
Esempio n. 3
0
 def create_folder(self):
     folder_name = '新建文件夹'
     if '新建文件夹' not in self.file_list:
         pass
     else:
         index = 1
         while True:
             folder_name = '新建文件夹({})'.format(index)
             index += 1
             if folder_name not in self.file_list:
                 break
     list_item = QListWidgetItem()
     list_item.setSizeHint(QSize(self.factor * 8, self.factor * 8))
     widget_item = FileItem(get_pixmap('', False), folder_name, False)
     self.list_widget.insertItem(0, list_item)
     self.list_widget.setItemWidget(list_item, widget_item)
     self.mkdir_signal.emit(os.path.join(self.cur_path, folder_name))
     self.cd_folder()
Esempio n. 4
0
 def filter_file(self, type_list):
     self.list_widget.clear()
     for file in self.file_list.keys():
         if self.file_list[file][4] not in type_list:
             continue
         pixmap = get_pixmap(file, self.file_list[file][0])
         item = QListWidgetItem(QIcon(pixmap), file)
         item = QListWidgetItem(QIcon(pixmap), file)
         item.setSizeHint(QSize(200, 200))
         self.list_widget.addItem(item)
     add_file_widget = FileItem(QPixmap(':/default/default_pngs/add.png'),
                                '添加文件', False)
     add_file_item = QListWidgetItem()
     add_file_item.setSizeHint(QSize(200, 200))
     add_file_item.setFlags(add_file_item.flags() & ~Qt.ItemIsEnabled
                            & ~Qt.ItemIsSelectable)
     self.list_widget.addItem(add_file_item)
     self.list_widget.setItemWidget(add_file_item, add_file_widget)
Esempio n. 5
0
 def list_file(self, file_list):
     self.list_widget.clear()
     self.file_list = file_list
     for file in file_list.keys():
         self.file_list[file].append(os.path.splitext(file)[-1][1:])
         pixmap = get_pixmap(file, file_list[file][0])
         widget_item = FileItem(pixmap, file, file_list[file][0])
         widget_item.rename_signal.connect(self.rename)
         list_item = QListWidgetItem()
         list_item.setSizeHint(QSize(self.factor * 8, self.factor * 8))
         self.list_widget.addItem(list_item)
         self.list_widget.setItemWidget(list_item, widget_item)
     add_file_widget = FileItem(QPixmap(':/default/default_pngs/add.png'),
                                '添加文件', False)
     add_file_item = QListWidgetItem()
     add_file_item.setSizeHint(QSize(self.factor * 8, self.factor * 8))
     add_file_item.setFlags(add_file_item.flags() & ~Qt.ItemIsSelectable)
     self.list_widget.addItem(add_file_item)
     self.list_widget.setItemWidget(add_file_item, add_file_widget)
Esempio n. 6
0
 def filter_file(self, type_list):
     self.list_widget.clear()
     for file in self.file_list.keys():
         if self.file_list[file][4] not in type_list:
             continue
         pixmap = get_pixmap(file, self.file_list[file][0])
         widget_item = FileItem(pixmap, file, self.file_list[file][0])
         widget_item.rename_signal.connect(self.rename)
         list_item = QListWidgetItem()
         list_item.setSizeHint(QSize(self.factor * 8, self.factor * 8))
         self.list_widget.addItem(list_item)
         self.list_widget.setItemWidget(list_item, widget_item)
     add_file_widget = FileItem(QPixmap(':/default/default_pngs/add.png'),
                                '添加文件', False)
     add_file_item = QListWidgetItem()
     add_file_item.setSizeHint(QSize(self.factor * 8, self.factor * 8))
     # add_file_item.setFlags(add_file_item.flags() & ~Qt.ItemIsEnabled & ~Qt.ItemIsSelectable)
     add_file_item.setFlags(add_file_item.flags() & ~Qt.ItemIsSelectable)
     self.list_widget.addItem(add_file_item)
     self.list_widget.setItemWidget(add_file_item, add_file_widget)