Skip to content

Commit

Permalink
added destination clearing (UNSTABLE)
Browse files Browse the repository at this point in the history
  • Loading branch information
vihdutta committed Apr 25, 2021
1 parent 1dbea78 commit e05b9df
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions autosortgui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QLabel
from autosort import copyfromdirs, srcdirs
from asfuncs import RICH_TEXT_FORE, TEXTBACK
Expand Down Expand Up @@ -26,6 +27,15 @@ def run(self):
for statement in function:
self.signals.result.emit(statement)

class CustomQTextEdit(QtWidgets.QTextEdit):
clicked = pyqtSignal()
def mouseReleaseEvent(self, event):
self.clicked.emit()

class CustomQLineEdit(QtWidgets.QLineEdit):
clicked = pyqtSignal()
def mouseReleaseEvent(self, event):
self.clicked.emit()

class Ui_MainWindow(object):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -266,7 +276,7 @@ def setupUi(self, MainWindow):
self.gridLayout.addWidget(self.console, 0, 0, 1, 1)
self.scrollArea.setWidget(self.scrollAreaWidget)
self.gridLayout_3.addWidget(self.scrollArea, 2, 1, 8, 1)
self.sourcedisplay = QtWidgets.QTextEdit(self.background)
self.sourcedisplay = CustomQTextEdit(self.background)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand Down Expand Up @@ -304,7 +314,7 @@ def setupUi(self, MainWindow):
self.sourcedisplay.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
self.sourcedisplay.setObjectName("sourcedisplay")
self.gridLayout_3.addWidget(self.sourcedisplay, 15, 1, 1, 2)
self.destinationdisplay = QtWidgets.QLineEdit(self.background)
self.destinationdisplay = CustomQLineEdit(self.background)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand Down Expand Up @@ -510,16 +520,12 @@ def source_button_click(self):
srcdirs.append(sourcedir)
srcdirsstring = f'{RICH_TEXT_FORE}, {TEXTBACK}'.join(srcdirs)
self.sourcedisplay.setText(srcdirsstring)
else:
pass


def destination_button_click(self):
self.destdir = QFileDialog.getExistingDirectory()
if os.path.isdir(self.destdir):
self.destinationdisplay.setText(self.destdir)
else:
pass


def run_button_click(self):
Expand Down Expand Up @@ -565,6 +571,13 @@ def run_button_click(self):
def statement_returner(self, statement):
self.console.append(statement)

def sourcedisplay_clear(self):
self.sourcedisplay.clear()
srcdirs.clear()

def destinationdisplay_clear(self):
self.destinationdisplay.clear()
self.destdir = ''

def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
Expand All @@ -590,6 +603,9 @@ def retranslateUi(self, MainWindow):
self.destination_button.clicked.connect(self.destination_button_click)
self.run_button.clicked.connect(self.run_button_click)

self.sourcedisplay.clicked.connect(self.sourcedisplay_clear)
self.destinationdisplay.clicked.connect(self.destinationdisplay_clear)


if __name__ == "__main__":
import sys
Expand Down

0 comments on commit e05b9df

Please sign in to comment.