Skip to content

Commit

Permalink
Qt4 port - (fix #51), import dialog improves
Browse files Browse the repository at this point in the history
  • Loading branch information
boyks authored and Jan Silhan committed Sep 11, 2014
1 parent 1175eeb commit cb44089
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions rpg/gui/dialogs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import (QLabel, QPushButton, QPlainTextEdit,
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import (QLabel, QPushButton, QPlainTextEdit,
QDialogButtonBox, QLineEdit, QVBoxLayout,
QCalendarWidget, QHBoxLayout, QFileDialog,
QComboBox)


class DialogChangelog(QtWidgets.QDialog):
class DialogChangelog(QtGui.QDialog):
def __init__(self, Dialog, Wizard, parent=None):
super(DialogChangelog, self).__init__(parent)

Expand Down Expand Up @@ -65,7 +65,7 @@ def importFromCVS(self):
pass


class DialogError(QtWidgets.QDialog):
class DialogError(QtGui.QDialog):
def __init__(self, Dialog, Wizard, parent=None):
super(DialogError, self).__init__(parent)

Expand Down Expand Up @@ -103,7 +103,7 @@ def acceptIt(self):
self.aceept()


class DialogSRPM(QtWidgets.QDialog):
class DialogSRPM(QtGui.QDialog):
def __init__(self, Dialog, Wizard, parent=None):
super(DialogSRPM, self).__init__(parent)

Expand Down Expand Up @@ -143,7 +143,7 @@ def acceptIt(self):
self.accept()


class DialogSubpackage(QtWidgets.QDialog):
class DialogSubpackage(QtGui.QDialog):
def __init__(self, Dialog, Wizard, parent=None):
super(DialogSubpackage, self).__init__(parent)

Expand Down Expand Up @@ -191,24 +191,24 @@ def acceptIt(self):
self.wizard.tree.addSubpackage(self.nameEdit.text())
self.accept()


class DialogImport(QtWidgets.QFileSystemModel):
"""
class DialogImport(QtGui.QFileSystemModel):
def __init__(self, Wizard, parent=None):
super(DialogImport, self).__init__(parent)
self.wizard = Wizard
self.setRootPath(QtCore.QDir.currentPath())
self.urls = []
self.urls.append(QtCore.QUrl.
'''self.urls.append(QtCore.QUrl.
fromLocalFile(str(QtCore.QStandardPaths.
DesktopLocation)))
self.urls.append(QtCore.QUrl.
fromLocalFile(str(QtCore.QStandardPaths.
DocumentsLocation)))
self.mfiledialog = QtWidgets.QFileDialog()
DocumentsLocation)))'''
self.mfiledialog = QtGui.QFileDialog()
self.mfiledialog.setSidebarUrls(self.urls)
self.mfiledialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
self.mfiledialog.setViewMode(QtWidgets.QFileDialog.Detail)
self.mfiledialog.setFileMode(QtGui.QFileDialog.AnyFile)
self.mfiledialog.setViewMode(QtGui.QFileDialog.Detail)
self.mfiledialog.currentChanged.connect(self.ondialogChanged)
self.mfiledialog.exec_()
self.pathList = self.mfiledialog.selectedFiles()
Expand All @@ -221,3 +221,28 @@ def ondialogChanged(self, filedir):
self.mfiledialog.setFileMode(QFileDialog.Directory)
else:
self.mfiledialog.setFileMode(QFileDialog.AnyFile)
"""

class ImportDialog(QtGui.QFileDialog):
def __init__(self, Wizard, *args):
self.wizard = Wizard
QtGui.QFileDialog.__init__(self, *args)
self.setOption(self.DontUseNativeDialog, True)
self.setFileMode(self.ExistingFiles)
btns = self.findChildren(QtGui.QPushButton)
self.openBtn = [x for x in btns if 'open' in str(x.text()).lower()][0]
self.openBtn.clicked.disconnect()
self.openBtn.clicked.connect(self.openClicked)
self.tree = self.findChild(QtGui.QTreeView)

def openClicked(self):
inds = self.tree.selectionModel().selectedIndexes()
files = []
for i in inds:
if i.column() == 0:
files.append(os.path.join(str(self.directory().absolutePath()),str(i.data().toString())))
self.selectedFiles = files
self.hide()

def filesSelected(self):
return str(self.selectedFiles()[0])

0 comments on commit cb44089

Please sign in to comment.