class ListProjectsDialog(QDialog): requestOpenProject = pyqtSignal(str) def __init__(self): QDialog.__init__(self ) # Set up the user interface from Designer. self.ui = Ui_ListModules() self.ui.setupUi(self) self.ui.moduleList.itemClicked.connect(self.openProject) self.setWindowFlags(Qt.FramelessWindowHint) self.ui.pushButton.clicked.connect(self.reject) scr = QApplication.desktop().screenGeometry(0) self.move( scr.center() - self.rect().center() ) def loadProjectList(self, paths): log(paths[0]) modules = [] for path in paths: for modulepath in glob.glob(os.path.join(path, '*.qgs')): moduleName = os.path.basename(modulepath)[:-4] item = QListWidgetItem(moduleName, self.ui.moduleList, QListWidgetItem.UserType) item.setData(QListWidgetItem.UserType, modulepath) print modulepath self.ui.moduleList.addItem( item ) def openProject(self, item): path = item.data(QListWidgetItem.UserType).toString() self.requestOpenProject.emit(path)
class ProjectsWidget(QWidget): requestOpenProject = pyqtSignal(QMapProject) def __init__(self): QWidget.__init__(self ) self.ui = Ui_ListModules() self.ui.setupUi(self) self.ui.moduleList.itemClicked.connect(self.openProject) def loadProjectList(self, projects): self.ui.moduleList.clear() for project in projects: if not project.vaild: continue item = QListWidgetItem(self.ui.moduleList, QListWidgetItem.UserType) item.setData(QListWidgetItem.UserType, project) item.setSizeHint(QSize(200, 200)) projectwidget = ProjectWidget(self.ui.moduleList) projectwidget.image = QPixmap(project.splash) projectwidget.name = project.name projectwidget.description = project.description projectwidget.version = project.version # pix = QPixmap(project.splash) # icon = QIcon(pix.scaled(200,200)) # item.setIcon(icon) self.ui.moduleList.addItem(item) self.ui.moduleList.setItemWidget(item, projectwidget) def openProject(self, item): # self.setDisabled(True) project = item.data(QListWidgetItem.UserType) self.selectedProject = project self.requestOpenProject.emit(project)
def __init__(self): QDialog.__init__(self ) # Set up the user interface from Designer. self.ui = Ui_ListModules() self.ui.setupUi(self) self.ui.moduleList.itemClicked.connect(self.openProject) self.setWindowFlags(Qt.FramelessWindowHint) self.ui.pushButton.clicked.connect(self.reject) scr = QApplication.desktop().screenGeometry(0) self.move( scr.center() - self.rect().center() )
def __init__(self): QWidget.__init__(self ) self.ui = Ui_ListModules() self.ui.setupUi(self) self.ui.moduleList.itemClicked.connect(self.openProject)