set dir working

master
Jaka Perovšek 2024-09-28 00:54:48 +02:00
parent 73ae09c438
commit a40fd85822
1 changed files with 9 additions and 1 deletions

View File

@ -2,7 +2,7 @@ from PySide6.QtCore import QSize, Qt, Slot, QRect, QFileSystemWatcher, Signal, Q
from PySide6.QtGui import QIcon, QAction, QShortcut, QKeySequence, QPainter, QColor, QTextFormat, QPixmap, QFontMetrics from PySide6.QtGui import QIcon, QAction, QShortcut, QKeySequence, QPainter, QColor, QTextFormat, QPixmap, QFontMetrics
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel, QVBoxLayout, QHBoxLayout, \ from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel, QVBoxLayout, QHBoxLayout, \
QGroupBox, QLineEdit, QCheckBox, QSpinBox, QPlainTextEdit, QSizePolicy, QGridLayout, QTextEdit, QScrollArea, QFrame, \ QGroupBox, QLineEdit, QCheckBox, QSpinBox, QPlainTextEdit, QSizePolicy, QGridLayout, QTextEdit, QScrollArea, QFrame, \
QDoubleSpinBox, QFormLayout, QTimeEdit QDoubleSpinBox, QFormLayout, QTimeEdit, QFileDialog
import webbrowser import webbrowser
import validators import validators
@ -148,6 +148,7 @@ class DirWidget(QWidget):
self.dir_set_btn.setIcon(QIcon("./gui/icons/ic_folder_open_48px.svg")) self.dir_set_btn.setIcon(QIcon("./gui/icons/ic_folder_open_48px.svg"))
self.dir_set_btn.setIconSize(QSize(16, 16)) self.dir_set_btn.setIconSize(QSize(16, 16))
self.dir_set_btn.setToolTip("Set directory with selection dialog") self.dir_set_btn.setToolTip("Set directory with selection dialog")
self.dir_set_btn.clicked.connect(self.set_dir)
self.dir_open_btn = QPushButton() self.dir_open_btn = QPushButton()
self.dir_open_btn.setIcon(QIcon("./gui/icons/ic_open_in_new_24px.svg")) self.dir_open_btn.setIcon(QIcon("./gui/icons/ic_open_in_new_24px.svg"))
@ -165,6 +166,13 @@ class DirWidget(QWidget):
directory = Path(self.directory) directory = Path(self.directory)
os.startfile(directory) os.startfile(directory)
def set_dir(self):
directory = QFileDialog.getExistingDirectory(self, "Select a directory.", dir=self.directory)
if directory:
directory = Path(directory).relative_to(Path.cwd()).as_posix()
self.directory = "./" + directory
self.dir_lineedit.setText(self.directory)
class UrlLineEdit(QLineEdit): class UrlLineEdit(QLineEdit):