def show_configuration(self, widget, data=None): """ Create and show the configuration window. :param widget: :param data: """ config_w = ConfigWindow(self.config) config_w.show_all()
def on_show_config_clicked(self): if self.working_dir: self.config = FileConfigLoader( self.get_config_path()).load_config() self.cfg = ConfigWindow(self) self.cfg.set_configuration(self.get_config_path(), self.working_dir) self.cfg.cw.set_save_path(self.get_config_path()) self.cfg.show()
def on_show_config_clicked(self): if self.working_dir: self.config = FileConfigLoader(self.get_config_path()).load_config() self.cfg = ConfigWindow(self) self.cfg.set_configuration(self.get_config_path(), self.working_dir) self.cfg.cw.set_save_path(self.get_config_path()) self.cfg.show()
def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.settings = QtCore.QSettings() QtCore.QDir.setCurrent(self.settings.value("image/directory", IMAGE_DIRECTORY).toString()) self.createImageList() self.opencvwidget = MyOpenCVWidget(self.label_webcam) self.configWindow = ConfigWindow(self) self.connect(self.opencvwidget, QtCore.SIGNAL("error"), self.label_webcam.setText)
class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.settings = QtCore.QSettings() QtCore.QDir.setCurrent(self.settings.value("image/directory", IMAGE_DIRECTORY).toString()) self.createImageList() self.opencvwidget = MyOpenCVWidget(self.label_webcam) self.configWindow = ConfigWindow(self) self.connect(self.opencvwidget, QtCore.SIGNAL("error"), self.label_webcam.setText) def createImageList(self): self.imageFiles = [file for file in os.listdir(".") if file.startswith("kamera_")] self.imageFiles.sort() imageLayout = QtGui.QHBoxLayout() self.imageListWidget = QtGui.QWidget() self.imageListWidget.setLayout(imageLayout) for imageFile in self.imageFiles: self.addImage(QtGui.QPixmap(imageFile)) self.scrollArea_photos.setWidget(self.imageListWidget) def addImage(self, pixmap): label = QtGui.QLabel(self.imageListWidget) label.setPixmap(pixmap.scaledToHeight(100)) label.setMaximumSize(label.pixmap().size()) label.setStyleSheet("border-right:2px solid gray;border-bottom:2px solid black") self.imageListWidget.layout().insertWidget(0, label) @QtCore.pyqtSignature("bool") def on_pushButton_save_clicked(self): fileextension = self.settings.value("image/format", IMAGE_FORMAT).toString() filename = "kamera_%s.%s" % (QtCore.QDateTime.currentDateTime().toString("yyyyMMdd-hhmmss"), fileextension) self.opencvwidget.snapShot().save(filename) self.addImage(self.opencvwidget.pixmap) @QtCore.pyqtSignature("bool") def on_pushButton_about_clicked(self): title = QtGui.QApplication.translate("MainWindow", "About Kamera") text = QtGui.QApplication.translate("MainWindow", "Kamera %1 - webcam photographer\nThis software is released under the terms of GPL v3.\nhttp://kamera.googlecode.com\n\nDeveloper:\nUgur Cetin <ugur.jnmbk at gmail.com>").arg(__init__.__version__) QtGui.QMessageBox.about(self, title, text) @QtCore.pyqtSignature("bool") def on_pushButton_configure_clicked(self): self.configWindow.show()
class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def __init__(self, *args, **kwargs): self.fullScreen = False super(MainWindow, self).__init__(*args, **kwargs) self.setupUi(self) self.show() self.pb_build_progress.setHidden(True) self.bind_controls() self.building = False self.proc = None self.build_step = 0 self.working_dir = None self.regex_tool = None self.config = None def bind_controls(self): self.btn_build.clicked.connect(self.on_build_clicked) self.cmb_brands.currentIndexChanged.connect(self.on_brand_changed) self.brands_model = SimpleStringListModel(self.get_available_brands()) self.cmb_brands.setModel(self.brands_model) self.cmb_platforms.setModel(SimpleStringListModel(self.get_platforms_for_brand(None))) self.cmb_platforms.currentIndexChanged.connect(self.on_platform_changed) self.btn_configure.clicked.connect(self.on_configure_clicked) self.btn_show_config.clicked.connect(self.on_show_config_clicked) self.btn_install_on_device.clicked.connect(self.on_install_clicked) self.btn_reset_scm.clicked.connect(self.on_scm_reset_clicked) self.btn_sign.clicked.connect(self.on_sign_app_clicked) self.actionRegex_Tool.triggered.connect(self.on_toggle_regex_tool) ###### Event Handlers ####### def on_toggle_regex_tool(self): global regex_shown if not self.regex_tool: self.regex_tool = RegexTool() if regex_shown: self.regex_tool.hide() else: self.regex_tool.show() regex_shown = not regex_shown def on_scm_reset_clicked(self): def state_changed(state): if state== QtCore.QProcess.ProcessState.NotRunning: self.run_external_proc("git clean -f", os.path.dirname(self.working_dir)) self.run_external_proc("git reset --hard HEAD", os.path.dirname(self.working_dir), state_changed) def on_show_config_clicked(self): if self.working_dir: self.config = FileConfigLoader(self.get_config_path()).load_config() self.cfg = ConfigWindow(self) self.cfg.set_configuration(self.get_config_path(), self.working_dir) self.cfg.cw.set_save_path(self.get_config_path()) self.cfg.show() def on_brand_changed(self): brand = self.cmb_brands.currentText() self.cmb_platforms.setModel(SimpleStringListModel(self.get_platforms_for_brand(brand))) def on_platform_changed(self): ind = self.cmb_platforms.currentIndex() if ind>0: self.working_dir = solution_dir.replace('{PlatformType}', solution_for_platform[self.cmb_platforms.currentText()]) self.config = FileConfigLoader(self.get_config_path()).load_config() else: self.working_dir = None def on_configure_clicked(self): config_loader = FileConfigLoader(self.get_config_path()) builder = AppConfigurator(config_loader, ZmqChainedLoger(port), verbose=self.cb_verbose.isChecked(), debug_mode=self.cb_verbose.isChecked()) builder.set_execution_dir(self.working_dir) self.worker = ConfigRunnerThread(builder) self.set_message_receiver() self.worker.start() self.worker.finished.connect(self.on_worker_finished) def on_worker_finished(self): self.worker.builder = None del self.worker self.messages_thread.terminate() del self.messages_thread def set_message_receiver(self): self.messages_thread = MessageSubsriberThread(port) self.messages_thread.on_message_received.connect(self.on_message_received) self.messages_thread.start(QtCore.QThread.TimeCriticalPriority) def on_message_received(self, message): self.txt_output.append("%s" % message) def on_build_clicked(self): if self.working_dir: if self.is_repo_clean(): self.building = not self.building if self.building: self.start_build("make build", os.path.dirname(self.working_dir)) self.btn_build.setText("Cancel") self.freeze_buttons(True) else: self.cancel_build() self.btn_build.setText("Build") self.freeze_buttons(False) else: print "repo is not commited" else: print "no working dir set" def on_sign_app_clicked(self): self.run_external_proc("make sign", os.path.dirname(self.working_dir)) def on_install_clicked(self): self.run_external_proc("make install", os.path.dirname(self.working_dir)) ######End Event Handlers ####### def get_config_path(self): global_vars = GlobalVars.get_instance() global_vars.current_config_path=os.path.join(config_path, self.cmb_brands.currentText(), self.cmb_platforms.currentText(),"bc.json") return global_vars.current_config_path #self.pb_build_progress.setHidden(not self.building) def get_available_brands(self): brands = [d for d in os.listdir(config_path) if os.path.isdir(os.path.join(config_path, d))] brands.insert(0, "--Select Brand--") return brands def get_platforms_for_brand(self, brand): plats = [] if brand: bpath = os.path.join(config_path, brand) if os.path.exists(bpath): plats = [d for d in os.listdir(bpath) if os.path.isdir(os.path.join(bpath, d))] plats.insert(0, "--Select Platform--") return plats def is_repo_clean(self): #self.start_build("git status", self.working_dir) return True def start_build(self, comm, working_dir): self.build_step+=1 print working_dir print "building" self.proc = QtCore.QProcess(self) self.proc.setWorkingDirectory(working_dir) self.proc.readyReadStandardOutput.connect(self.__show_output__) self.proc.readyReadStandardOutput.connect(self.__show_error__) self.proc.setProcessChannelMode(QtCore.QProcess.ProcessChannelMode.MergedChannels) self.proc.closeWriteChannel() self.proc.stateChanged.connect(self.__build_state_changed__) #self.proc.setReadChannel(QtCore.QProcess.StandardError) self.proc.start(comm) #self.proc.start("make", "configure brand="++" verbose=-v") def run_external_proc(self, cmd,working_dir, state_changed=None): self.proc = QtCore.QProcess(self) self.proc.setWorkingDirectory(working_dir) self.proc.readyReadStandardOutput.connect(self.__show_output__) self.proc.readyReadStandardOutput.connect(self.__show_error__) self.proc.setProcessChannelMode(QtCore.QProcess.ProcessChannelMode.MergedChannels) if state_changed: self.proc.stateChanged.connect(state_changed) self.proc.closeWriteChannel() #self.proc.setReadChannel(QtCore.QProcess.StandardError) self.proc.start(cmd) #self.proc.start("make", "configure brand="++" verbose=-v") def __show_output__(self): output = self.proc.readAllStandardOutput() self.txt_output.append(str(output)) def __show_error__(self): output = self.proc.readAllStandardError() self.txt_output.append(str(output)) def __build_state_changed__(self, st): if st== QtCore.QProcess.ProcessState.NotRunning: if self.build_step == 1: if self.cb_revert.isChecked(): print "Reverting changes" self.start_build("git reset --hard HEAD", self.working_dir) else: print "Skipped Reverting" self.build_step+=1 if self.build_step == 2: self.btn_build.setText("Build Again") self.freeze_buttons(False) self.building = False self.build_step = -1 #if QtCore.QProcess.ProcessState. def cancel_build(self): print "cancelled" self.txt_output.clear() def freeze_buttons(self, freeze): self.cmb_brands.setDisabled(freeze) self.cmb_platforms.setDisabled(freeze) self.cb_verbose.setDisabled(freeze) self.btn_configure.setDisabled(freeze) self.btn_install_on_device.setDisabled(freeze) self.btn_reset_scm.setDisabled(freeze)
def click_config(self, widget): ConfigWindow(self.webview, self, self.config)
class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def __init__(self, *args, **kwargs): self.fullScreen = False super(MainWindow, self).__init__(*args, **kwargs) self.setupUi(self) self.show() self.pb_build_progress.setHidden(True) self.bind_controls() self.building = False self.proc = None self.build_step = 0 self.working_dir = None self.regex_tool = None self.config = None def bind_controls(self): self.btn_build.clicked.connect(self.on_build_clicked) self.cmb_brands.currentIndexChanged.connect(self.on_brand_changed) self.brands_model = SimpleStringListModel(self.get_available_brands()) self.cmb_brands.setModel(self.brands_model) self.cmb_platforms.setModel( SimpleStringListModel(self.get_platforms_for_brand(None))) self.cmb_platforms.currentIndexChanged.connect( self.on_platform_changed) self.btn_configure.clicked.connect(self.on_configure_clicked) self.btn_show_config.clicked.connect(self.on_show_config_clicked) self.btn_install_on_device.clicked.connect(self.on_install_clicked) self.btn_reset_scm.clicked.connect(self.on_scm_reset_clicked) self.btn_sign.clicked.connect(self.on_sign_app_clicked) self.actionRegex_Tool.triggered.connect(self.on_toggle_regex_tool) ###### Event Handlers ####### def on_toggle_regex_tool(self): global regex_shown if not self.regex_tool: self.regex_tool = RegexTool() if regex_shown: self.regex_tool.hide() else: self.regex_tool.show() regex_shown = not regex_shown def on_scm_reset_clicked(self): def state_changed(state): if state == QtCore.QProcess.ProcessState.NotRunning: self.run_external_proc("git clean -f", os.path.dirname(self.working_dir)) self.run_external_proc("git reset --hard HEAD", os.path.dirname(self.working_dir), state_changed) def on_show_config_clicked(self): if self.working_dir: self.config = FileConfigLoader( self.get_config_path()).load_config() self.cfg = ConfigWindow(self) self.cfg.set_configuration(self.get_config_path(), self.working_dir) self.cfg.cw.set_save_path(self.get_config_path()) self.cfg.show() def on_brand_changed(self): brand = self.cmb_brands.currentText() self.cmb_platforms.setModel( SimpleStringListModel(self.get_platforms_for_brand(brand))) def on_platform_changed(self): ind = self.cmb_platforms.currentIndex() if ind > 0: self.working_dir = solution_dir.replace( '{PlatformType}', solution_for_platform[self.cmb_platforms.currentText()]) self.config = FileConfigLoader( self.get_config_path()).load_config() else: self.working_dir = None def on_configure_clicked(self): config_loader = FileConfigLoader(self.get_config_path()) builder = AppConfigurator(config_loader, ZmqChainedLoger(port), verbose=self.cb_verbose.isChecked(), debug_mode=self.cb_verbose.isChecked()) builder.set_execution_dir(self.working_dir) self.worker = ConfigRunnerThread(builder) self.set_message_receiver() self.worker.start() self.worker.finished.connect(self.on_worker_finished) def on_worker_finished(self): self.worker.builder = None del self.worker self.messages_thread.terminate() del self.messages_thread def set_message_receiver(self): self.messages_thread = MessageSubsriberThread(port) self.messages_thread.on_message_received.connect( self.on_message_received) self.messages_thread.start(QtCore.QThread.TimeCriticalPriority) def on_message_received(self, message): self.txt_output.append("%s" % message) def on_build_clicked(self): if self.working_dir: if self.is_repo_clean(): self.building = not self.building if self.building: self.start_build("make build", os.path.dirname(self.working_dir)) self.btn_build.setText("Cancel") self.freeze_buttons(True) else: self.cancel_build() self.btn_build.setText("Build") self.freeze_buttons(False) else: print "repo is not commited" else: print "no working dir set" def on_sign_app_clicked(self): self.run_external_proc("make sign", os.path.dirname(self.working_dir)) def on_install_clicked(self): self.run_external_proc("make install", os.path.dirname(self.working_dir)) ######End Event Handlers ####### def get_config_path(self): global_vars = GlobalVars.get_instance() global_vars.current_config_path = os.path.join( config_path, self.cmb_brands.currentText(), self.cmb_platforms.currentText(), "bc.json") return global_vars.current_config_path #self.pb_build_progress.setHidden(not self.building) def get_available_brands(self): brands = [ d for d in os.listdir(config_path) if os.path.isdir(os.path.join(config_path, d)) ] brands.insert(0, "--Select Brand--") return brands def get_platforms_for_brand(self, brand): plats = [] if brand: bpath = os.path.join(config_path, brand) if os.path.exists(bpath): plats = [ d for d in os.listdir(bpath) if os.path.isdir(os.path.join(bpath, d)) ] plats.insert(0, "--Select Platform--") return plats def is_repo_clean(self): #self.start_build("git status", self.working_dir) return True def start_build(self, comm, working_dir): self.build_step += 1 print working_dir print "building" self.proc = QtCore.QProcess(self) self.proc.setWorkingDirectory(working_dir) self.proc.readyReadStandardOutput.connect(self.__show_output__) self.proc.readyReadStandardOutput.connect(self.__show_error__) self.proc.setProcessChannelMode( QtCore.QProcess.ProcessChannelMode.MergedChannels) self.proc.closeWriteChannel() self.proc.stateChanged.connect(self.__build_state_changed__) #self.proc.setReadChannel(QtCore.QProcess.StandardError) self.proc.start(comm) #self.proc.start("make", "configure brand="++" verbose=-v") def run_external_proc(self, cmd, working_dir, state_changed=None): self.proc = QtCore.QProcess(self) self.proc.setWorkingDirectory(working_dir) self.proc.readyReadStandardOutput.connect(self.__show_output__) self.proc.readyReadStandardOutput.connect(self.__show_error__) self.proc.setProcessChannelMode( QtCore.QProcess.ProcessChannelMode.MergedChannels) if state_changed: self.proc.stateChanged.connect(state_changed) self.proc.closeWriteChannel() #self.proc.setReadChannel(QtCore.QProcess.StandardError) self.proc.start(cmd) #self.proc.start("make", "configure brand="++" verbose=-v") def __show_output__(self): output = self.proc.readAllStandardOutput() self.txt_output.append(str(output)) def __show_error__(self): output = self.proc.readAllStandardError() self.txt_output.append(str(output)) def __build_state_changed__(self, st): if st == QtCore.QProcess.ProcessState.NotRunning: if self.build_step == 1: if self.cb_revert.isChecked(): print "Reverting changes" self.start_build("git reset --hard HEAD", self.working_dir) else: print "Skipped Reverting" self.build_step += 1 if self.build_step == 2: self.btn_build.setText("Build Again") self.freeze_buttons(False) self.building = False self.build_step = -1 #if QtCore.QProcess.ProcessState. def cancel_build(self): print "cancelled" self.txt_output.clear() def freeze_buttons(self, freeze): self.cmb_brands.setDisabled(freeze) self.cmb_platforms.setDisabled(freeze) self.cb_verbose.setDisabled(freeze) self.btn_configure.setDisabled(freeze) self.btn_install_on_device.setDisabled(freeze) self.btn_reset_scm.setDisabled(freeze)