You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from app.core.configurations import Resources
from app.core.main import Adb
from app.core.managers import Global
from app.data.models import FileType, MessageData, MessageType
from app.data.repositories import FileRepository
from app.gui.explorer.toolbar import ParentButton, UploadTools, PathBar
from app.helpers.tools import AsyncRepositoryWorker, ProgressCallbackHelper, read_string_from_file
def handle_selected_files(self, file_names: list):
# Implement your logic here
# For now, let's just print the selected files
print("Selected files:", file_names)
` modified_files.zip
The text was updated successfully, but these errors were encountered:
enable multi-file selection, we'll need to implement the following steps:
Add a Button or Menu Action: This will serve as the trigger for the user to initiate the multi-file selection.
Open a Multi-File Selection Dialog: When the user clicks the button or menu action, a file selection dialog will open, allowing the user to select multiple files.
Handle Selected Files: Once the user selects files and confirms, we'll need to process or handle these files based on the desired functionality (e.g., copying, moving, etc.).
Given the content of files.py, I'll provide code snippets to achieve the above steps:
1. Add a Button or Menu Action:
You can add a button to the toolbar or a menu action. For simplicity, let's add a menu action:
Here, QFileDialog.getOpenFileNames returns a tuple where the first element is a list of selected file paths.
3. Handle Selected Files:
Finally, implement the handle_selected_files method to process the selected files:
defhandle_selected_files(self, file_names: list):
# Implement your logic here# For now, let's just print the selected filesprint("Selected files:", file_names)
Integrating these snippets into files.py will enable multi-file selection in the GUI.
`# ADB File Explorer
Copyright (C) 2
file_selection_action = QAction('Select Multiple Files', self)
file_selection_action.triggered.connect(self.select_multiple_files)
self.file_menu.addAction(file_selection_action)
022 Azat Aldeshov
import sys
from typing import Any
from PyQt5 import QtCore, QtGui
from PyQt5.QtCore import Qt, QPoint, QModelIndex, QAbstractListModel, QVariant, QRect, QSize, QEvent, QObject
from PyQt5.QtGui import QPixmap, QColor, QPalette, QMovie, QKeySequence
from PyQt5.QtWidgets import QMenu, QAction, QMessageBox, QFileDialog, QStyle, QWidget, QStyledItemDelegate,
QStyleOptionViewItem, QApplication, QListView, QVBoxLayout, QLabel, QSizePolicy, QHBoxLayout, QTextEdit,
QMainWindow
from app.core.configurations import Resources
from app.core.main import Adb
from app.core.managers import Global
from app.data.models import FileType, MessageData, MessageType
from app.data.repositories import FileRepository
from app.gui.explorer.toolbar import ParentButton, UploadTools, PathBar
from app.helpers.tools import AsyncRepositoryWorker, ProgressCallbackHelper, read_string_from_file
class FileHeaderWidget(QWidget):
def init(self, parent=None):
super(FileHeaderWidget, self).init(parent)
self.setLayout(QHBoxLayout(self))
policy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
class FileExplorerToolbar(QWidget):
def init(self, parent=None):
super(FileExplorerToolbar, self).init(parent)
self.setLayout(QHBoxLayout(self))
policy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
policy.setHorizontalStretch(1)
class FileItemDelegate(QStyledItemDelegate):
def sizeHint(self, option: 'QStyleOptionViewItem', index: QtCore.QModelIndex) -> QtCore.QSize:
result = super(FileItemDelegate, self).sizeHint(option, index)
result.setHeight(40)
return result
class FileListModel(QAbstractListModel):
def init(self, parent=None):
super().init(parent)
self.items = []
class FileExplorerWidget(QWidget):
FILES_WORKER_ID = 300
DOWNLOAD_WORKER_ID = 399
class TextView(QMainWindow):
def init(self, filename, data):
QMainWindow.init(self)
def select_multiple_files(self):
file_names, _ = QFileDialog.getOpenFileNames(self, 'Select Files')
if file_names:
self.handle_selected_files(file_names)
def handle_selected_files(self, file_names: list):
# Implement your logic here
# For now, let's just print the selected files
print("Selected files:", file_names)
`
modified_files.zip
The text was updated successfully, but these errors were encountered: