Esempio n. 1
0
def openSelectedDirectory():
    get_selected = Ui_MainWindow.treeWidget.selectedItems()
    if get_selected:
        base_node = get_selected[0]
        get_child_node = base_node.text(0)
        client_operation.open_directory(get_child_node)
        Ui_MainWindow.treeWidget.clear()
        Ui_MainWindow.updateClientInterface(
            client_operation.get_current_directory())
Esempio n. 2
0
    def __init__(self):
        super(window, self).__init__()
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        self.set_signals()



        self.cf1=cf(self.ui.l_x1,self.ui.l_y1,self.ui.l_z1,self.ui.l_conn1)
        self.cf2=cf(self.ui.l_x2,self.ui.l_y2,self.ui.l_z2,self.ui.l_conn2)
Esempio n. 3
0
    def __init__(self):
        super(window, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.set_signals()
        Thread(target=self.pozycja).start()

        self.cf1 = cf(self.ui.l_x1, self.ui.l_y1, self.ui.l_z1,
                      self.ui.l_conn1)
        self.cf2 = cf(self.ui.l_x2, self.ui.l_y2, self.ui.l_z2,
                      self.ui.l_conn2)
Esempio n. 4
0
    def __init__(self, parent=None):
        super(ControlMainWindow, self).__init__(parent)

        # definir executavel do scriptLattes
        if 'win' in sys.platform.lower():
            self.CMD = 'scriptLattes.exe'
        else:
            self.CMD = './scriptLattes.py'
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.single = SingleProcessingTabPanel(self)
        self.multiple = MultipleProcessingTabPanel(self)
        self.setWindowIcon(QtGui.QIcon('gui/logo.png'))
Esempio n. 5
0
class ControlMainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(ControlMainWindow, self).__init__(parent)

        # definir executavel do scriptLattes
        if 'win' in sys.platform.lower():
            self.CMD = 'scriptLattes.exe'
        else:
            self.CMD = './scriptLattes.py'
        self.ui =  Ui_MainWindow()
        self.ui.setupUi(self)
        self.single = SingleProcessingTabPanel(self)
        self.multiple = MultipleProcessingTabPanel(self)
        self.setWindowIcon(QtGui.QIcon('gui/logo.png'))
Esempio n. 6
0
	def __init__(self, cmdr, settings, style):  # If called with no argument, this becomes the main window
		"""
		Main GUI class for the application. Generates a Frame which contains all data in one place.
		"""
		QtGui.QMainWindow.__init__(self)
		self.cmdr = cmdr
		self.settings = settings
		self.style = style

		self.status_window = Ui_MainWindow()
		self.status_window.setupUi(self)
		self.setStyleSheet(self.style)

		# File menu
		self.status_window.actionUpdate_EDDB_data.triggered.connect(self.update_eddb)
		self.status_window.actionSettings.triggered.connect(self.settings.open_settings_window)
		self.status_window.actionExit.triggered.connect(self.close)
		self.status_window.actionAbout.triggered.connect(self.about)

		# Buttons
		self.status_window.btn_quit.pressed.connect(self.close)
		self.status_window.btn_refresh.pressed.connect(self.cmdr.refresh_api)
		self.status_window.btn_statistics.pressed.connect(self.close)

		self.add_api_table()  # Populates our table with data from the API

		self.show()
Esempio n. 7
0
    def __init__(self):
        super(window, self).__init__()
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        self.set_signals()
        Thread(target=self.pozycja).start()



        self.cf1=cf(self.ui.l_x1,self.ui.l_y1,self.ui.l_z1,self.ui.l_conn1)
        self.cf2=cf(self.ui.l_x2,self.ui.l_y2,self.ui.l_z2,self.ui.l_conn2)
Esempio n. 8
0
    def __init__(self,app,socket):
        # ustawienia podstawowe
        super(main_window, self).__init__()
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        self.app=app

        # wlaczenie watku zmq
        self.zmq = zmq_thread(socket)
        self.zmq.start()



        # ustawinie sygnalow
        self.setup_signals()

        #inicjalizacja zmiennych
        self.dron_list=[]
        self.row=0
        self.column=0

        self.scan_devices()
Esempio n. 9
0
    def __init__( self ):
        super( MyTennisMatchGui, self ).__init__()
        self.setMinimumWidth( 400 )

        self.player_list    = list()
        self.lobby_list     = list()
        self.window         = Ui_MainWindow()
        self.window.setupUi( self )
        self.match_cfg      = MyMatchConfigDialog()
        self.create_player  = MyPlayerDialog()

        self.__UpdateMatchConfigs()
        self.__SetUpEvents()
        self.__SetUpMenus()

        self.setWindowTitle( "Complex Tennis" )
Esempio n. 10
0
class window(QtGui.QMainWindow):
    def __init__(self):
        super(window, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.set_signals()
        Thread(target=self.pozycja).start()

        self.cf1 = cf(self.ui.l_x1, self.ui.l_y1, self.ui.l_z1,
                      self.ui.l_conn1)
        self.cf2 = cf(self.ui.l_x2, self.ui.l_y2, self.ui.l_z2,
                      self.ui.l_conn2)

    def set_signals(self):
        self.ui.pb_scan.clicked.connect(self.scan)

        self.ui.pb_conn1.clicked.connect(self.pb_conn_clicked1)
        self.ui.pb_conn2.clicked.connect(self.pb_conn_clicked2)

        self.ui.pb_disc1.clicked.connect(self.pb_disc_clicked1)
        self.ui.pb_disc2.clicked.connect(self.pb_disc_clicked2)

        self.ui.pb_send1.clicked.connect(self.pb_send_clicked1)
        self.ui.pb_send2.clicked.connect(self.pb_send_clicked2)

    # ustawienie polaczenie
    def pb_conn_clicked1(self):
        uri = self.ui.cb_device1.currentText()
        self.ui.l_conn1.setText("connecting to {}".format(uri))
        self.cf1.connect(uri)
        self.ui.pb_scan.setEnabled(False)
        self.ui.cb_device1.setEnabled(False)
        self.ui.pb_disc1.setEnabled(True)
        self.ui.pb_send1.setEnabled(True)
        self.ui.pb_conn1.setEnabled(False)
        self.ui.e_thrust1.setEnabled(True)

    def pb_conn_clicked2(self):
        uri = self.ui.cb_device2.currentText()
        self.ui.l_conn2.setText("connecting to {}".format(uri))
        self.cf2.connect(uri)
        self.ui.pb_scan.setEnabled(False)
        self.ui.cb_device2.setEnabled(False)
        self.ui.pb_disc2.setEnabled(True)
        self.ui.pb_send2.setEnabled(True)
        self.ui.pb_conn2.setEnabled(False)
        self.ui.e_thrust2.setEnabled(True)

    # # rozlacznie
    def pb_disc_clicked1(self):
        self.ui.l_conn1.setText("Disconnecting ...")
        self.cf1.close()

        self.ui.cb_device1.setEnabled(True)
        self.ui.pb_disc1.setEnabled(False)
        self.ui.pb_send1.setEnabled(False)
        self.ui.pb_conn1.setEnabled(True)
        self.ui.e_thrust1.setEnabled(False)

        if self.cf2.is_connected:
            self.ui.pb_scan.setEnabled(False)
        else:
            self.ui.pb_scan.setEnabled(True)

    def pb_disc_clicked2(self):
        self.ui.l_conn2.setText("Disconnecting ...")
        self.cf2.close()

        self.ui.cb_device2.setEnabled(True)
        self.ui.pb_disc2.setEnabled(False)
        self.ui.pb_send2.setEnabled(False)
        self.ui.pb_conn2.setEnabled(True)
        self.ui.e_thrust2.setEnabled(False)

        if self.cf1.is_connected:
            self.ui.pb_scan.setEnabled(False)
        else:
            self.ui.pb_scan.setEnabled(True)

    # wyslanie nowego sterowania
    def pb_send_clicked1(self):
        thrust = int(self.ui.e_thrust1.text())
        if thrust > 100:
            thrust = 100
        if thrust < 0:
            thrust = 0

        self.ui.e_thrust1.clear()
        self.ui.e_thrust1.setText(str(thrust))

        thrust = thrust * 500
        self.cf1.update_ctrl(thrust)

    def pb_send_clicked2(self):
        thrust = int(self.ui.e_thrust2.text())
        if thrust > 100:
            thrust = 100
        if thrust < 0:
            thrust = 0

        self.ui.e_thrust2.clear()
        self.ui.e_thrust2.setText(str(thrust))

        thrust = thrust * 500
        self.cf2.update_ctrl(thrust)

    # funkcja wyszukiwania + wypelnienie cb
    def scan(self):
        # find USB devices
        dev = usb.core.find(find_all=True)

        a = cflib.crtp.scan_interfaces()
        self.ui.cb_device1.clear()
        self.ui.cb_device2.clear()

        k = 0
        kk = 0
        for cfg in dev:
            if cfg.idVendor == 6421:
                for i in a:
                    self.ui.cb_device1.addItem(i[0].replace(
                        str(kk), str(k), 1))
                    self.ui.cb_device2.addItem(i[0].replace(
                        str(kk), str(k), 1))
                kk = k
                k += 1
        if len(a) > 0:
            self.ui.pb_conn1.setEnabled(True)
            self.ui.pb_conn2.setEnabled(True)
        else:
            self.ui.pb_conn1.setEnabled(False)
            self.ui.pb_conn2.setEnabled(False)

    def pozycja(self):
        x, y = camera.wykrywanie()
        self.ui.l_x1.setText(str(x))
        self.ui.l_x2.setText(str(y))
Esempio n. 11
0
    # Signup button window
    def login_signup_btn_handler(self):
        signup_dialog = SignUp()
        signup_dialog.exec()
        # signup_dialog.show()
        signup_dialog.close()
        self.focusWidget()

    # Forgot Password button window
    def fp_btn_handler(self):
        fp_dialog = ForgotPass()
        fp_dialog.exec()
        # signup_dialog.show()
        fp_dialog.close()
        self.focusWidget()


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    login = Login()
    if (login.exec_()) == QtWidgets.QDialog.Accepted:
        # print("ACCEPTED", login.login_getValues())
        window = Ui_MainWindow(username=login.login_getValues()["username"])
        window.show()
        sys.exit(app.exec_())
    # else:
        # print("WE ARE IN ELSE")
Esempio n. 12
0
    def __init__(self):
        super(iOSBE, self).__init__(None)

        self.backuppath = None
        self.database = None
        self.cursor = None
        self.manifest = None
        self.infoplist = None
        self.iOSVersion = 0
        self.passwd = None
        self.work_dir = None
        self.extractpath = None
        self.is_active = False
        self.mbdb = None
        self.mru_list = list()
        self.threemaUI = None
        self.contactsUI = None
        self.sqlbrowserUI = None
        self.smsUI = None
        self.callhistoryUI = None
        self.whatsappUI = None

        if "linux" in sys.platform:
            self.mousewait = Qt.WaitCursor
        else:
            self.mousewait = QCursor(Qt.WaitCursor)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.ui.treeViewDomains.setContextMenuPolicy(Qt.CustomContextMenu)
        self.ui.treeViewDomains.customContextMenuRequested.connect(self.ctxMenu)

        self.ui.treeViewDomains.setHeaderLabel("")

        self.ui.treeViewDomains.setColumnWidth(0, 200)
        self.ui.treeViewDomains.setColumnWidth(2, 16)

        self.ui.treeViewDomains.setColumnHidden(1, True)
        self.ui.treeViewDomains.setColumnHidden(3, True)
        self.ui.treeViewDomains.setColumnHidden(4, True)
        self.ui.treeViewDomains.setColumnHidden(5, True)

        # action handlers
        QtCore.QObject.connect(self.ui.action_OpenBackup, QtCore.SIGNAL("triggered(bool)"), self.openBackupGUI)
        QtCore.QObject.connect(self.ui.action_About, QtCore.SIGNAL("triggered(bool)"), self.displayAbout)
        QtCore.QObject.connect(self.ui.action_CloseBackup, QtCore.SIGNAL("triggered(bool)"), self.closeBackup)

        QtCore.QObject.connect(self.ui.action_ExtractApp, QtCore.SIGNAL("triggered(bool)"), self.extractApp)
        QtCore.QObject.connect(self.ui.action_ExtractAll, QtCore.SIGNAL("triggered(bool)"), self.extractAll)

        QtCore.QObject.connect(self.ui.action_Contacts, QtCore.SIGNAL("triggered(bool)"), self.showContacts)
        QtCore.QObject.connect(self.ui.action_CallHistory, QtCore.SIGNAL("triggered(bool)"), self.showCallHistory)
        QtCore.QObject.connect(self.ui.action_Messages, QtCore.SIGNAL("triggered(bool)"), self.showMessages)
        QtCore.QObject.connect(self.ui.action_Threema, QtCore.SIGNAL("triggered(bool)"), self.showThreema)
        QtCore.QObject.connect(self.ui.action_WhatsApp, QtCore.SIGNAL("triggered(bool)"), self.showWhatsapp)

        self.work_dir = makeTmpDir()

        if sys.platform != "darwin":
            self.ui.separatorMRUList.setSeparator(True)
            self.mruLoadList()
            self.mruUpdateFileMenu()
Esempio n. 13
0
class main_window(QtGui.QMainWindow):

    def __init__(self,app,socket):
        # ustawienia podstawowe
        super(main_window, self).__init__()
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        self.app=app

        # wlaczenie watku zmq
        self.zmq = zmq_thread(socket)
        self.zmq.start()



        # ustawinie sygnalow
        self.setup_signals()

        #inicjalizacja zmiennych
        self.dron_list=[]
        self.row=0
        self.column=0

        self.scan_devices()
        # self.add_dron()

    def setup_signals(self):
        self.ui.pb_add_dron.clicked.connect(self.add_dron)
        self.ui.pb_remove.clicked.connect(self.remove_drons)
        self.ui.pb_scan_devices.clicked.connect(self.scan_devices)

        self.zmq.zmq_log.connect(self.zmq_log_recv)

        self.app.aboutToQuit.connect(self.remove_drons)

    def zmq_log_recv(self,data):
        number=5
        dt=data[-1]
        data=data[:-1]
        # print len(self.dron_list)
        if len(self.dron_list)>0:
            for dron in self.dron_list:
                dron.dt=dt

                dron.isCorrect=data[0+number*dron.id]
                # print type(dron.isCorrect)
                dron.x_cam=data[1+number*dron.id]/100.0
                dron.y_cam=data[2+number*dron.id]/100.0
                dron.z_cam=data[3+number*dron.id]/100.0
                dron.yaw_cam=data[4+number*dron.id]*pi/180
                dron.vzcam=(dron.z_cam-dron.z_cam_p)/dt
                dron.z_cam_p=dron.z_cam


                if dron.isCorrect==1.0:

                    pass

                else:
                    pass
                    # dron.x_cam=dron.x_previous
                    # dron.y_cam=dron.y_previous
                    # dron.z_cam=dron.z_previous
                    # dron.yaw_cam=dron.yaw_previous






    def scan_devices(self):
        dev = usb.core.find(find_all=True)
        try:
            a=cflib.crtp.scan_interfaces()
            self.ui.cb_devices.clear()
            k=0
            kk=0
            for cfg in dev:
                if cfg.idVendor==6421:
                    for i in a:
                        self.ui.cb_devices.addItem(i[0].replace(str(kk),str(k),1))
                    kk=k
                    k+=1
        except Exception as e:
            print e

    def add_dron(self):
        number_of_drons=(len(self.dron_list))
        uri=self.ui.cb_devices.currentText()
        if uri!=None and uri!="":
            self.ui.cb_devices.removeItem(self.ui.cb_devices.currentIndex())
            if number_of_drons<4:
                self.dron_list.append(dron(int(self.ui.en_id.text()),uri,self))
                self.ui.en_id.setText(str(number_of_drons+1))
                self.ui.layout_drons.addWidget(self.dron_list[-1],self.row,self.column)
                self.row+=1
                if self.row>=2:
                    self.row=0
                    self.column+=1

    def remove_drons(self):
        self.row=0
        self.column=0
        for dron in self.dron_list:
            dron.cf.close()
            dron.deleteLater()

        self.dron_list=[]
Esempio n. 14
0
class window(QtGui.QMainWindow):

    def __init__(self):
        super(window, self).__init__()
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        self.set_signals()



        self.cf1=cf(self.ui.l_x1,self.ui.l_y1,self.ui.l_z1,self.ui.l_conn1)
        self.cf2=cf(self.ui.l_x2,self.ui.l_y2,self.ui.l_z2,self.ui.l_conn2)
    def set_signals(self):
        self.ui.pb_scan.clicked.connect(self.scan)

        self.ui.pb_conn1.clicked.connect(self.pb_conn_clicked1)
        self.ui.pb_conn2.clicked.connect(self.pb_conn_clicked2)

        self.ui.pb_disc1.clicked.connect(self.pb_disc_clicked1)
        self.ui.pb_disc2.clicked.connect(self.pb_disc_clicked2)

        self.ui.pb_send1.clicked.connect(self.pb_send_clicked1)
        self.ui.pb_send2.clicked.connect(self.pb_send_clicked2)
    # ustawienie polaczenie
    def pb_conn_clicked1(self):
        uri=self.ui.cb_device1.currentText()
        self.ui.l_conn1.setText("connecting to {}".format(uri))
        self.cf1.connect(uri)
        self.ui.pb_scan.setEnabled(False)
        self.ui.cb_device1.setEnabled(False)
        self.ui.pb_disc1.setEnabled(True)
        self.ui.pb_send1.setEnabled(True)
        self.ui.pb_conn1.setEnabled(False)
        self.ui.e_thrust1.setEnabled(True)
    def pb_conn_clicked2(self):
        uri=self.ui.cb_device2.currentText()
        self.ui.l_conn2.setText("connecting to {}".format(uri))
        self.cf2.connect(uri)
        self.ui.pb_scan.setEnabled(False)
        self.ui.cb_device2.setEnabled(False)
        self.ui.pb_disc2.setEnabled(True)
        self.ui.pb_send2.setEnabled(True)
        self.ui.pb_conn2.setEnabled(False)
        self.ui.e_thrust2.setEnabled(True)
    # # rozlacznie
    def pb_disc_clicked1(self):
        self.ui.l_conn1.setText("Disconnecting ...")
        self.cf1.close()

        self.ui.cb_device1.setEnabled(True)
        self.ui.pb_disc1.setEnabled(False)
        self.ui.pb_send1.setEnabled(False)
        self.ui.pb_conn1.setEnabled(True)
        self.ui.e_thrust1.setEnabled(False)

        if self.cf2.is_connected:
            self.ui.pb_scan.setEnabled(False)
        else:
            self.ui.pb_scan.setEnabled(True)
    def pb_disc_clicked2(self):
        self.ui.l_conn2.setText("Disconnecting ...")
        self.cf2.close()

        self.ui.cb_device2.setEnabled(True)
        self.ui.pb_disc2.setEnabled(False)
        self.ui.pb_send2.setEnabled(False)
        self.ui.pb_conn2.setEnabled(True)
        self.ui.e_thrust2.setEnabled(False)

        if self.cf1.is_connected:
            self.ui.pb_scan.setEnabled(False)
        else:
            self.ui.pb_scan.setEnabled(True)
    # wyslanie nowego sterowania
    def pb_send_clicked1(self):
        thrust=int(self.ui.e_thrust1.text())
        if thrust > 100:
            thrust=100
        if thrust < 0:
            thrust=0

        self.ui.e_thrust1.clear()
        self.ui.e_thrust1.setText(str(thrust))

        thrust=thrust*600
        self.cf1.update_ctrl(thrust)
    def pb_send_clicked2(self):
        thrust=int(self.ui.e_thrust2.text())
        if thrust > 100:
            thrust=100
        if thrust < 0:
            thrust=0

        self.ui.e_thrust2.clear()
        self.ui.e_thrust2.setText(str(thrust))

        thrust=thrust*600
        self.cf2.update_ctrl(thrust)
    # funkcja wyszukiwania + wypelnienie cb
    def scan(self):
        # find USB devices
        dev = usb.core.find(find_all=True)


        a=cflib.crtp.scan_interfaces()
        self.ui.cb_device1.clear()
        self.ui.cb_device2.clear()

        k=0
        kk=0
        for cfg in dev:
            if cfg.idVendor==6421:
                for i in a:
                    self.ui.cb_device1.addItem(i[0].replace(str(kk),str(k),1))
                    self.ui.cb_device2.addItem(i[0].replace(str(kk),str(k),1))
                kk=k
                k+=1
        if len(a)>0:
            self.ui.pb_conn1.setEnabled(True)
            self.ui.pb_conn2.setEnabled(True)
        else:
            self.ui.pb_conn1.setEnabled(False)
            self.ui.pb_conn2.setEnabled(False)
Esempio n. 15
0
class MyTennisMatchGui( QWidget ):
    """docstring for MyTennisMatchGui"""
    def __init__( self ):
        super( MyTennisMatchGui, self ).__init__()
        self.setMinimumWidth( 400 )

        self.player_list    = list()
        self.lobby_list     = list()
        self.window         = Ui_MainWindow()
        self.window.setupUi( self )
        self.match_cfg      = MyMatchConfigDialog()
        self.create_player  = MyPlayerDialog()

        self.__UpdateMatchConfigs()
        self.__SetUpEvents()
        self.__SetUpMenus()

        self.setWindowTitle( "Complex Tennis" )


    @Slot()
    def __ShowMatchCfgDialog( self ):
        self.match_cfg.show()


    @Slot()
    def __CloseMatchCfgDialog( self ):
        self.match_cfg.close()


    @Slot()
    def __ShowCreatePlayerDialog(self):
        self.create_player.show()


    @Slot()
    def __SendDialogValues( self ):
        self.__GetDialogValues()
        self.__UpdateMatchConfigs()
        self.match_cfg.close()


    @Slot()
    def __CloseCreatePlayerDialog( self ):
        self.create_player.close()


    @Slot()
    def __AddNewPlayerToList( self ):
        player = self.create_player.GetPlayer()
        self.create_player.close()
        self.player_list.append( player )
        self.window.players_lst.addItem( str( player ) )


    @Slot()
    def PlayMatch( self ):
        self.match_summary_dialog = MyMatchSummaryDialog(
            self.lobby_list[ 0 ],
            self.lobby_list[ 1 ],
            match_config
        )
        self.match_summary_dialog.show()


    def __SetUpEvents( self ):
        self.window.show_modal_btn.clicked.connect( self.__ShowMatchCfgDialog )
        self.window.create_player_btn.clicked.connect( self.__ShowCreatePlayerDialog )
        self.window.play_match_btn.clicked.connect( self.PlayMatch )
        self.match_cfg.window.cancel_btn.clicked.connect( self.__CloseMatchCfgDialog )
        self.match_cfg.window.ok_btn.clicked.connect( self.__SendDialogValues )
        self.create_player.window.cancel_btn.clicked.connect( self.__CloseCreatePlayerDialog )
        self.create_player.window.ok_btn.clicked.connect( self.__AddNewPlayerToList )


    def __GetDialogValues( self ):
        match_config.points_to_win_game     = self.match_cfg.window.pts_to_win_game_sp_b.value()
        match_config.points_to_win_tiebreak = self.match_cfg.window.pts_to_win_tiebreak_sp_b.value()
        match_config.games_to_win_set       = self.match_cfg.window.games_to_win_set_sp_b.value()
        match_config.sets_to_win_match      = self.match_cfg.window.sets_to_win_match_sp_b.value()

        match_config.tiebreaks              = self.match_cfg.window.tiebreaks_ch_b.isChecked()
        match_config.final_set_tiebreak     = self.match_cfg.window.final_set_tiebreak_ch_b.isChecked()


    def __UpdateMatchConfigs( self ):
        self.window.pts_to_win_game_lbl.setText( str( match_config.points_to_win_game ) )
        self.window.pts_to_win_tiebreak_lbl.setText( str( match_config.points_to_win_tiebreak ) )
        self.window.games_to_win_set_lbl.setText( str( match_config.games_to_win_set ) )
        self.window.sets_to_win_match_lbl.setText( str( match_config.sets_to_win_match ) )

        if match_config.tiebreaks:
            self.window.tiebreaks_lbl.setText( "Enabled" )
        else:
            self.window.tiebreaks_lbl.setText( "Disabled" )

        if match_config.final_set_tiebreak:
            self.window.final_set_tiebreak_lbl.setText( "Enabled" )
        else:
            self.window.final_set_tiebreak_lbl.setText( "Disabled" )


    def __SetUpMenus( self ):
        self.window.players_lst.setContextMenuPolicy( Qt.CustomContextMenu )
        self.window.players_lst.customContextMenuRequested.connect( self.__PlayersListMenu )

        self.window.lobby_lst.setContextMenuPolicy( Qt.CustomContextMenu )
        self.window.lobby_lst.customContextMenuRequested.connect( self.__LobbyListMenu )


    def __PlayersListMenu( self, position ):
        list_menu           = QMenu()

        add_player_to_lobby = QAction( self )
        add_player_to_lobby.setText( "Add player to lobby" )
        add_player_to_lobby.triggered.connect( self._AddToLobbyAction )

        rm_player           = QAction( self )
        rm_player.setText( "Remove player" )
        rm_player.triggered.connect( self._RemoveFromPlayersListAction )

        list_menu.addAction( rm_player )
        list_menu.addAction( add_player_to_lobby )

        list_menu.exec_( self.window.players_lst.viewport().mapToGlobal( position ) )


    def __LobbyListMenu( self, position ):
        lobby_menu      = QMenu()

        rm_from_lobby   = QAction( self )
        rm_from_lobby.setText( "Remove player from lobby" )
        rm_from_lobby.triggered.connect( self._RemoveFromLobbyListAction )

        lobby_menu.addAction( rm_from_lobby )

        lobby_menu.exec_( self.window.lobby_lst.viewport().mapToGlobal( position ) )


    def _RemoveFromPlayersListAction( self ):
        try:
            selection   = self.window.players_lst.selectedItems()[ 0 ]
            pos         = self.window.players_lst.row( selection )
            self.window.players_lst.takeItem( pos )
            self.player_list.pop( pos )
        except IndexError:
            pass


    def _RemoveFromLobbyListAction( self ):
        try:
            sel = self.window.lobby_lst.selectedItems()[ 0 ]
            pos     = self.window.lobby_lst.row( sel )

            item = self.window.lobby_lst.takeItem( pos )
            self.window.players_lst.addItem( item )

            player = self.lobby_list.pop( pos )
            self.player_list.append( player )
        except IndexError:
            pass


    def _AddToLobbyAction( self ):
        try:
            selection   = self.window.players_lst.selectedItems()[ 0 ]
            pos         = self.window.players_lst.row( selection )

            if len( self.lobby_list ) < 2:
                self.window.players_lst.takeItem( pos )
                player = self.player_list.pop( pos )
                self.window.lobby_lst.addItem( player.name.full_name )
                self.lobby_list.append( player )
            else:
                pass

        except IndexError:
            pass


    def Run( self ):
        self.show()
        qt_app.exec_()
Esempio n. 16
0
def openParentDirectory():
    client_operation.open_parent_directory()
    Ui_MainWindow.treeWidget.clear()
    Ui_MainWindow.updateClientInterface(
        client_operation.get_current_directory())
Esempio n. 17
0
class EDStatusWindow(QtGui.QMainWindow):
	def __init__(self, cmdr, settings, style):  # If called with no argument, this becomes the main window
		"""
		Main GUI class for the application. Generates a Frame which contains all data in one place.
		"""
		QtGui.QMainWindow.__init__(self)
		self.cmdr = cmdr
		self.settings = settings
		self.style = style

		self.status_window = Ui_MainWindow()
		self.status_window.setupUi(self)
		self.setStyleSheet(self.style)

		# File menu
		self.status_window.actionUpdate_EDDB_data.triggered.connect(self.update_eddb)
		self.status_window.actionSettings.triggered.connect(self.settings.open_settings_window)
		self.status_window.actionExit.triggered.connect(self.close)
		self.status_window.actionAbout.triggered.connect(self.about)

		# Buttons
		self.status_window.btn_quit.pressed.connect(self.close)
		self.status_window.btn_refresh.pressed.connect(self.cmdr.refresh_api)
		self.status_window.btn_statistics.pressed.connect(self.close)

		self.add_api_table()  # Populates our table with data from the API

		self.show()


	def add_api_table(self):
		"""
		Frame with categories and values (not using QTableWidget, but build it from labels in grid.
		"""
		palette = QtGui.QPalette()
		palette.setColor(QtGui.QPalette.Foreground,QtCore.Qt.darkYellow)
		for n in range(len(self.cmdr.values)):
			category = self.cmdr.categories[n]
			methodToCall = getattr(self.status_window, 'lbl_value_' + str(n))  # Creates method names that we can call
			if category == 'Current system':
				url = 'http://eddb.io/system/' + self.cmdr.systems[self.cmdr.api.profile['lastSystem']['name']]
				value = '<A href="' + url + '" style="color:#ff7f27;">' + self.cmdr.values[n] + '</a>'
			elif category == 'Last docked':
				url = 'http://eddb.io/station/' + self.cmdr.stations[self.cmdr.api.profile['lastStarport']['name']]
				value = '<A href="' + url + '" style="color:#ff7f27;">' + self.cmdr.values[n] + '</a>'
			else:
				value = self.cmdr.values[n]

			methodToCall.setText(value + ' ')  # An extra padding for italics underline links

	def update_eddb(self):  # TODO: change window to Qt Designer
		explanation = (
			'This will download systems.json and stations.json from EDDB.io,' +
			'which enables hyperlinks on station and system names.\n\n' +
		    'You typically only need to do this once, or if you are in some '+
			'exotic location in space which has only been recently discovered.'
		)

		reply = QtGui.QMessageBox.question(self, 'Message',
		         explanation, QtGui.QMessageBox.Yes, QtGui.QMessageBox.Cancel)

		if reply == QtGui.QMessageBox.Cancel:
			return

		self.win_download = QtGui.QWidget()
		self.win_download.setWindowTitle('Updating EDDB data')
		self.win_download.setStyleSheet(self.style)
		self.win_download.resize(230, 165)
		self.win_download.move(300, 300)

		grid = QtGui.QGridLayout(self.win_download)
		grid.setColumnMinimumWidth(0, 200)
		grid.setColumnMinimumWidth(1, 40)

		# For animated GIF, we use QMovie
		try:
			gif_busy = QtGui.QMovie('icons/throbber.gif')
			gif_check = QtGui.QPixmap(':icons/check-2x.png')
		except FileNotFoundError as err:
			print(err)
			exit(1)

		self.lbl_systems_update = QtGui.QLabel()
		self.lbl_stations_update = QtGui.QLabel()
		self.lbl_systems_conversion = QtGui.QLabel()
		self.lbl_stations_conversion = QtGui.QLabel()

		grid.addWidget(QtGui.QLabel('Systems update downloading'), 0, 0)
		grid.addWidget(QtGui.QLabel('Stations update downloading'), 1, 0)
		grid.addWidget(QtGui.QLabel('Converting systems JSON data'), 2, 0)
		grid.addWidget(QtGui.QLabel('Converting stations JSON data'), 3, 0)

		grid.addWidget(self.lbl_systems_update, 0, 1)
		grid.addWidget(self.lbl_stations_update, 1, 1)
		grid.addWidget(self.lbl_systems_conversion, 2, 1)
		grid.addWidget(self.lbl_stations_conversion, 3, 1)

		gif_busy.start()  # Starting animation
		self.win_download.show()

		""" We use threading to run download/conversion in the background to allow animated GIFs """
		self.pool = ThreadPool(processes=1)  # This is threads _not_ processes

		self.stations_json_path = os.path.dirname(os.path.abspath(self.settings.stationsDataFile))
		self.systems_json_path = os.path.dirname(os.path.abspath(self.settings.systemsDataFile))

		# Updating labels
		self.lbl_systems_update.setMovie(gif_busy)

		# Running systems download in thread
		self.async_result = self.pool.apply_async(self._download_systems)
		while not hasattr(self.async_result, '_success'):
			QtGui.QApplication.processEvents()

		# Updating labels
		self.lbl_systems_update.setPixmap(gif_check)
		self.lbl_stations_update.setMovie(gif_busy)

		# Running stations download in thread
		self.async_result = self.pool.apply_async(self._download_stations)
		while not hasattr(self.async_result, '_success'):
			QtGui.QApplication.processEvents()

		# Updating labels
		self.lbl_stations_update.setPixmap(gif_check)
		self.lbl_systems_conversion.setMovie(gif_busy)

		# Running systems conversion in thread
		self.async_result = self.pool.apply_async(self._convert_systems)
		while not hasattr(self.async_result, '_success'):
			QtGui.QApplication.processEvents()

		# Updating labels
		self.lbl_systems_conversion.setPixmap(gif_check)
		self.lbl_stations_conversion.setMovie(gif_busy)

		# Running stations conversion in thread
		self.async_result = self.pool.apply_async(self._convert_stations)
		while not hasattr(self.async_result, '_success'):
			QtGui.QApplication.processEvents()

		# Updating labels
		self.lbl_stations_conversion.setPixmap(gif_check)
		QtGui.QApplication.processEvents()

		time.sleep(1)  # Giving the user time to see confirmation
		self.win_download.close()

	def _download_systems(self):
		"""
		Download and save the systems datafile from www.eddb.io/api (gzipped)
		"""
		with open (self.systems_json_path + '/systems_raw.json', 'wb') as self.systems_raw_file:
			self.response = requests.get(self.settings.systemsDataURL, stream=True, headers={'Accept-Encoding': 'gzip, deflate, sdch'})
			self.systems_raw_file.write(self.response.content)

	def _download_stations(self):
		"""
		Download and save the stations datafile from www.eddb.io/api (gzipped)
		"""
		with open (self.stations_json_path + '/stations_raw.json', 'wb') as self.stations_raw_file:
			self.response = requests.get(self.settings.stationsDataURL, stream=True, headers={'Accept-Encoding': 'gzip, deflate, sdch'})
			self.stations_raw_file.write(self.response.content)

	def _convert_stations(self):
		"""
		Convert the stations JSON file into a smaller one with only name and id (strip excess data)
		"""
		stations_list = []
		for station in json.loads(open(self.stations_json_path + '/stations_raw.json').read()):
			stations_list.append({'id': station['id'], 'name':station['name']})
		with open(self.settings.stationsDataFile, 'w') as json_file:
			json.dump(stations_list, json_file, ensure_ascii=False)

	def _convert_systems(self):
		"""
		Convert the systems JSON file into a smaller one with only name and id (strip excess data)
		"""
		systems_list = []
		for system in json.loads(open(self.systems_json_path + '/systems_raw.json').read()):
			systems_list.append({'id': system['id'], 'name':system['name']})
		with open(self.settings.systemsDataFile, 'w') as json_file:
			json.dump(systems_list, json_file, ensure_ascii=False)

	def about(self):
		self.about_window = QtGui.QWidget()
		self.about = Ui_About()
		self.about.setupUi(self.about_window)
		self.about_window.setStyleSheet(self.style)
		self.about.btn_close.pressed.connect(self.about_window.close)
		self.about_window.setWindowFlags(QtCore.Qt.FramelessWindowHint)
		self.about_window.show()
Esempio n. 18
0
class iOSBE(QtGui.QMainWindow):
    def __init__(self):
        super(iOSBE, self).__init__(None)

        self.backuppath = None
        self.database = None
        self.cursor = None
        self.manifest = None
        self.infoplist = None
        self.iOSVersion = 0
        self.passwd = None
        self.work_dir = None
        self.extractpath = None
        self.is_active = False
        self.mbdb = None
        self.mru_list = list()
        self.threemaUI = None
        self.contactsUI = None
        self.sqlbrowserUI = None
        self.smsUI = None
        self.callhistoryUI = None
        self.whatsappUI = None

        if "linux" in sys.platform:
            self.mousewait = Qt.WaitCursor
        else:
            self.mousewait = QCursor(Qt.WaitCursor)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.ui.treeViewDomains.setContextMenuPolicy(Qt.CustomContextMenu)
        self.ui.treeViewDomains.customContextMenuRequested.connect(self.ctxMenu)

        self.ui.treeViewDomains.setHeaderLabel("")

        self.ui.treeViewDomains.setColumnWidth(0, 200)
        self.ui.treeViewDomains.setColumnWidth(2, 16)

        self.ui.treeViewDomains.setColumnHidden(1, True)
        self.ui.treeViewDomains.setColumnHidden(3, True)
        self.ui.treeViewDomains.setColumnHidden(4, True)
        self.ui.treeViewDomains.setColumnHidden(5, True)

        # action handlers
        QtCore.QObject.connect(self.ui.action_OpenBackup, QtCore.SIGNAL("triggered(bool)"), self.openBackupGUI)
        QtCore.QObject.connect(self.ui.action_About, QtCore.SIGNAL("triggered(bool)"), self.displayAbout)
        QtCore.QObject.connect(self.ui.action_CloseBackup, QtCore.SIGNAL("triggered(bool)"), self.closeBackup)

        QtCore.QObject.connect(self.ui.action_ExtractApp, QtCore.SIGNAL("triggered(bool)"), self.extractApp)
        QtCore.QObject.connect(self.ui.action_ExtractAll, QtCore.SIGNAL("triggered(bool)"), self.extractAll)

        QtCore.QObject.connect(self.ui.action_Contacts, QtCore.SIGNAL("triggered(bool)"), self.showContacts)
        QtCore.QObject.connect(self.ui.action_CallHistory, QtCore.SIGNAL("triggered(bool)"), self.showCallHistory)
        QtCore.QObject.connect(self.ui.action_Messages, QtCore.SIGNAL("triggered(bool)"), self.showMessages)
        QtCore.QObject.connect(self.ui.action_Threema, QtCore.SIGNAL("triggered(bool)"), self.showThreema)
        QtCore.QObject.connect(self.ui.action_WhatsApp, QtCore.SIGNAL("triggered(bool)"), self.showWhatsapp)

        self.work_dir = makeTmpDir()

        if sys.platform != "darwin":
            self.ui.separatorMRUList.setSeparator(True)
            self.mruLoadList()
            self.mruUpdateFileMenu()

    def closeEvent(self, event):
        #clean up and remove temporary files...
        rmTmpDir(self.work_dir)

    def ctxMenu(self, pos):

        # managing "standard" files
        selectedItem = self.ui.treeViewDomains.currentItem()
        if (selectedItem):
            pass
        else:
            return

        file = selectedItem.text(0).split(".")
        ftype = ""

        if file.__len__() != 2:
            return

        fext = file[1].encode('ascii','ignore').upper()

        for ext in PICEXTENSIONLIST:
            if fext == ext:
                ftype = "image"
                break

        if ftype == "":
            for ext in SQLITEEXTENSIONLIST:
                if fext == ext:
                    ftype = "sqlite"
                    break

        showMenu = False

        menu = QtGui.QMenu()

        # if image
        if (ftype == "image"):
            action1 = QtGui.QAction("Open with Image Viewer", self)
            action1.triggered.connect(self.openSelectedImage)
            menu.addAction(action1)
            showMenu = True


        # if sqlite
        if (ftype == "sqlite"):
            action1 = QtGui.QAction("Open with SQLite Browser", self)
            action1.triggered.connect(self.openSelectedSqlite)
            menu.addAction(action1)
            showMenu = True
        if (showMenu):
            menu.exec_(self.ui.treeViewDomains.mapToGlobal(pos))

    def isSubWindowOpen(self, win):
        # check if plugin already open
        found = False

    def isWindowOpen(self, win):
        #check if pid file of win is existing
        pass

    def showContacts(self):

        if self.isSubWindowOpen("contactsGUI") == True:
            return

        mbdomain_type = "HomeDomain"
        mbapp_name = "Library/AddressBook"

        if self.extractpath == None:
            dir = self.work_dir
        else:
            dir = self.extractpath

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbfile_path= ?", (mbdomain_type,mbapp_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        abook = dir + "/HomeDomain/Library/AddressBook/AddressBook.sqlitedb"
        abimg = dir + "/HomeDomain/Library/AddressBook/AddressBookImages.sqlitedb"
        self.contactsUI = contactsGUI(abook, abimg, self.work_dir)
        self.contactsUI.show()

    def showMessages(self):
        if self.isSubWindowOpen("smsGUI") == True:
            return

        if self.extractpath == None:
            dir = self.work_dir
        else:
            dir = self.extractpath


        mbdomain_type = "HomeDomain"
        mbapp_name = "Library/AddressBook"

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbfile_path= ?", (mbdomain_type,mbapp_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        mbdomain_type = "HomeDomain"
        mbapp_name = "Library/SMS"

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbfile_path= ?", (mbdomain_type,mbapp_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)


        abook = dir + "/HomeDomain/Library/AddressBook/AddressBook.sqlitedb"
        abimg = dir + "/HomeDomain/Library/AddressBook/AddressBookImages.sqlitedb"
        sms   = dir + "/HomeDomain/Library/SMS/sms.db"

        self.smsUI = smsGUI(sms, abook, abimg)
        self.smsUI.show()

    def showCallHistory(self):

        if self.extractpath == None:
            dir = self.work_dir
        else:
            dir = self.extractpath

        if self.iOSVersion == IPHONE_UNSUPPORTED:
            QtGui.QMessageBox.information(self, "Information", "Unsupported iOS version...")
            return

        if self.iOSVersion == IPHONE_VERSION6 or self.iOSVersion == IPHONE_VERSION7:
            mbdomain_type = "WirelessDomain"
            mbfile_name = "call_history.db"
        elif self.iOSVersion == IPHONE_VERSION8:
            mbdomain_type = "HomeDomain"
            mbfile_name = "CallHistory.storedata"

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbfile_name= ?", (mbdomain_type,mbfile_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        callhistorydb = dir + "/" + dbrecord.mbdomain_type + "/" + str(dbrecord.mbfile_path) + "/" + dbrecord.mbfile_name

        mbdomain_type = "HomeDomain"
        mbapp_name = "Library/AddressBook"

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbfile_path= ?", (mbdomain_type,mbapp_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        abook = dir + "/HomeDomain/Library/AddressBook/AddressBook.sqlitedb"
        abimg = dir + "/HomeDomain/Library/AddressBook/AddressBookImages.sqlitedb"

        self.callhistoryUI = callhistoryGUI(callhistorydb, abook)
        self.callhistoryUI.show()
        return

    def showThreema(self):
        if self.isSubWindowOpen("threemaGUI") == True:
            return

        mbdomain_type = "AppDomain"
        mbapp_name = "ch.threema.iapp"

        if self.extractpath == None:
            dir = self.work_dir
        else:
            dir = self.extractpath

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbapp_name= ?", (mbdomain_type,mbapp_name))
        records = self.cursor.fetchall()

        if len(records) == 0:
            QtGui.QMessageBox.information(self, "Information", "Threema not found...")
            return

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        threemaDB = dir + "/" + mbdomain_type + "/" + mbapp_name + "/Documents/ThreemaData.sqlite"

        self.threemaUI = threemaGUI(threemaDB, dir)
        self.threemaUI.show()

    def showWhatsapp(self):

        if self.iOSVersion == IPHONE_UNSUPPORTED:
            QtGui.QMessageBox.information(self, "Information", "Unsupported iOS version...")
            return
        if self.extractpath == None:
            dir = self.work_dir
        else:
            dir = self.extractpath

        self.cursor.execute("select * from indice where mbapp_name Like '%Whatsapp%' order by domain")
        records = self.cursor.fetchall()

        if len(records) == 0:
            QtGui.QMessageBox.information(self, "Information", "Whatsapp not found...")
            return

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        path2appdomain = "AppDomain/net.whatsapp.WhatsApp"
        if self.iOSVersion == IPHONE_VERSION8:
            path2groupdomain = "AppDomainGroup/group.net.whatsapp.WhatsApp.shared"
        else:
            path2groupdomain = None

        self.whatsappUI = whatsappGUI(path2appdomain, path2groupdomain, self.work_dir)
        self.whatsappUI.show()
        return

    def onTreeClick(self):
        selectedItem = self.ui.treeViewDomains.currentItem()
        file = selectedItem.text(0).split(".")
        if file.__len__() == 2:
            for ext in PICEXTENSIONLIST:
                fext = file[1].encode('ascii','ignore')
                if fext.upper() == ext:
                    self.showPicture(selectedItem.text(4), selectedItem.text(0), ext)
                    break

    def openSelectedSqlite(self):
        selectedItem = self.ui.treeViewDomains.currentItem()
        self.showSQLite(selectedItem.text(4), selectedItem.text(0))

    def openSelectedImage(self):
        selectedItem = self.ui.treeViewDomains.currentItem()
        self.showPicture(selectedItem.text(4), selectedItem.text(0))

    def showSQLite(self, mbd, mbf):
        mbdomain_type = mbd
        mbfile_name = mbf

        if self.extractpath == None:
            dir = self.work_dir
        else:
            dir = self.extractpath

        self.cursor.execute("Select * from indice where mbdomain_type=? and mbfile_name= ?", (mbdomain_type,mbfile_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, dir)

        sqlitedb = dir + "/" + dbrecord.mbdomain_type + "/" + str(dbrecord.mbfile_path) + "/" + dbrecord.mbfile_name

        self.sqlbrowserUI = sqlBrowserGUI(sqlitedb, dir, dbrecord.mbfile_name)
        self.sqlbrowserUI.show()

    def showPicture(self, mbd, mbf):
        mbdomain_type = mbd
        mbfile_name = mbf

        self.cursor.execute("Select * from indice where mbdomain_type = ? and mbfile_name like ?", (mbdomain_type,mbfile_name))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            image_data = self.mbdb.readBackupFile(dbrecord)
        qimg = QtGui.QImage.fromData(image_data)
        qimg = qimg.scaled(800,600).scaled(400,300, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)
        pixmap = QtGui.QPixmap.fromImage(qimg)
        self.w = ImageViewer(pixmap, self.ui.treeViewDomains)
        self.w.setWindowTitle(mbf)
        self.w.show()

    def informationMessage(self, message):
        QtGui.QMessageBox.information(self,
                                      "Information",
                                      message)

    def passwordDialog(self):
        passwd = None
        ok = False

        passwd, ok = QtGui.QInputDialog.getText(self, 'Backup seems to be encrypted. Password required...', 'Password:'******'Password', 'Enter password:'******'t find Info.plist in directory %s.  Not a valid backup directory?" % self.backuppath)
            self.ui.statusbar.showMessage("Stop...")
            return False
        else:
            # refresh gridLayoutInfo
            self.gridLayoutInfo_refresh(self.infoplist)

        if not self.manifest.has_key("BackupKeyBag"):
            self.informationMessage("Only iOSBackup >= Version 5 Supported")

        if self.manifest["IsEncrypted"]:
            self.passwd = self.passwordDialog()

            if self.passwd is None:
                self.informationMessage("Password not given! Will not be able to extract information...")

        progressBar = QtGui.QProgressBar()
        self.ui.statusbar.addWidget(progressBar)
        self.mbdb = MBDB(self.backuppath)

        if self.passwd is not None:
            kb = Keybag.createWithBackupManifest(self.manifest, self.passwd)
            if not kb:
                self.informationMessage(
                    "Can not extract backup key.\nYou can only browse through the domains and apps...")
                # return False

            self.manifest["password"] = self.passwd

            self.mbdb.keybag = kb

        progressBar.setMaximum(self.mbdb.numoffiles)
        if TestMode is True:
            self.database, self.cursor = iOSBackupDB(TestDatabase)
        else:
            self.database, self.cursor = iOSBackupDB()

        store2db(self.cursor, self.mbdb)
        self.database.commit()

        self.ui.treeViewDomains.setHeaderLabel("Files/Domains/Apps")
        standardFiles = QtGui.QTreeWidgetItem(None)
        standardFiles.setText(0, "Standard files")
        self.ui.treeViewDomains.addTopLevelItem(standardFiles)

        for elementName in ['Manifest.plist', 'Info.plist', 'Status.plist']:
            newItem = QtGui.QTreeWidgetItem(standardFiles)
            newItem.setText(0, elementName)
            newItem.setText(1, "X")
            self.ui.treeViewDomains.addTopLevelItem(newItem)

        self.cursor.execute("SELECT DISTINCT(mbdomain_type) FROM indice")

        domain_types = self.cursor.fetchall()

        for domain_type_u in domain_types:
            domain_type = str(domain_type_u[0])

            newDomainFamily = QtGui.QTreeWidgetItem(None)
            newDomainFamily.setText(0, domain_type)

            self.ui.treeViewDomains.addTopLevelItem(newDomainFamily)

            # show new domain family in main view
            QtGui.QApplication.processEvents()

            query = "SELECT DISTINCT(mbapp_name) FROM indice WHERE mbdomain_type = ? ORDER BY mbdomain_type"
            self.cursor.execute(query, (domain_type,))
            domain_names = self.cursor.fetchall()

            for domain_name_u in domain_names:
                domain_name = str(domain_name_u[0])

                if (len(domain_names) > 1):
                    newDomain = QtGui.QTreeWidgetItem(newDomainFamily)
                    newDomain.setText(0, domain_name)
                    self.ui.treeViewDomains.addTopLevelItem(newDomain)

                    rootNode = newDomain
                else:
                    rootNode = newDomainFamily

                # query = "SELECT path, mbfile_path, mbfile_name, size, fileid, mbfile_type FROM indice WHERE mbdomain_type = ? AND mbapp_name = ? ORDER BY mbfile_path, mbfile_name"
                query = "SELECT mbfile_path, mbfile_name, size, id, mbfile_type FROM indice WHERE mbdomain_type = ? AND mbapp_name = ? ORDER BY mbfile_path, mbfile_name"

                self.cursor.execute(query, (domain_type, domain_name))
                nodes = self.cursor.fetchall()

                pathToNode = {'': rootNode}

                for nodeData in nodes:
                    path = str(nodeData[0])
                    # finding parent directory
                    lookup = path
                    missing = collections.deque()
                    dirNode = None
                    while dirNode is None:
                        dirNode = pathToNode.get(lookup, None)

                        if dirNode is None:
                            lookup, sep, component = lookup.rpartition('/')
                            missing.appendleft(component)

                    # creating parent directory if neccesary
                    for component in missing:
                        newPath = QtGui.QTreeWidgetItem(dirNode)
                        newPath.setText(0, component)
                        newPath.setToolTip(0, component)
                        self.ui.treeViewDomains.addTopLevelItem(newPath)

                        dirNode = newPath
                        #lookup = posixpath.join(lookup, component)
                        lookup = path
                        pathToNode[lookup] = newPath
                    try:
                        file_name = str(nodeData[1].encode("utf-8"))
                    except:
                        file_name = nodeData[1]

                    if (nodeData[2]) < 1024:
                        file_dim = str(nodeData[2]) + " b"
                    else:
                        file_dim = str(nodeData[2] / 1024) + " kb"
                    file_id = int(nodeData[3])
                    file_type = str(nodeData[4])

                    if file_type == 'd':
                        newFile = dirNode
                    else:
                        newFile = QtGui.QTreeWidgetItem(newPath)
                        self.ui.treeViewDomains.addTopLevelItem(newFile)

                        newFile.setText(0, file_name)
                        newFile.setToolTip(0, file_name)
                        newFile.setText(2, str(file_dim))

                    newFile.setText(1, file_type)
                    newFile.setText(3, str(file_id))
                    newFile.setText(4, domain_type)
                    newFile.setText(5, domain_name)

        rawFiles = QtGui.QTreeWidgetItem(None)
        rawFiles.setText(0, "Raw files")
        self.ui.treeViewDomains.addTopLevelItem(rawFiles)
        # query = "SELECT mbfile_path, mbfile_name, size, id, mbfile_type FROM indice ORDER BY mbfile_path, mbfile_name"

        query = "SELECT domain, path, size, id, mbfile_type FROM indice ORDER BY domain, path"

        self.cursor.execute(query)
        nodes = self.cursor.fetchall()
        for nodeData in nodes:
            domain_name = str(nodeData[0]).replace("-", "/", 1) + "/" + str(nodeData[1])
            newFile = QtGui.QTreeWidgetItem(rawFiles)
            self.ui.treeViewDomains.addTopLevelItem(newFile)

            if (nodeData[2]) < 1024:
                file_dim = str(nodeData[2]) + " b"
            else:
                file_dim = str(nodeData[2] / 1024) + " kb"
            file_id = int(nodeData[3])
            file_type = str(nodeData[4])
            newFile.setText(0, domain_name)
            newFile.setToolTip(0, domain_name)
            newFile.setText(2, str(file_dim))
            newFile.setText(1, file_type)
            newFile.setText(3, str(file_id))

        self.ui.statusbar.removeWidget(progressBar)
        self.activateMenu(True)
        return True

    def closeBackup(self):
        self.ui.statusbar.showMessage("Close Backup %s..." %self.backuppath)
        self.activateMenu(False)
        self.gridLayoutInfo_refresh()
        self.gridLayoutManifest_refresh()
        self.ui.treeViewDomains.clear()
        self.backuppath = None
        self.database = None
        self.cursor = None
        self.manifest = None
        self.infoplist = None
        self.passwd = None
        self.extractpath = None
        self.ui.statusbar.showMessage("Done...")

    def extractApp(self):

        if self.is_active == False:
            return

        selectedItem = self.ui.treeViewDomains.currentItem()


        if self.backuppath is None:
            msg = "No iOS Backup open..."
            self.informationMessage(msg)
            return

        if (self.extractpath == None) or (len(self.extractpath) == 0):
            self.extractpath = self.getFilepathDialog(self.backuppath)

            if (self.extractpath == None) or (len(self.extractpath) == 0):
                return None

        if selectedItem.text(4) == "AppDomain":
            search = '%' + selectedItem.text(0) + '%'
            self.cursor.execute("Select * from indice where mbapp_name like ?", (search,))
        else:
            search = '%' + selectedItem.text(0) + '%'
            self.cursor.execute("Select * from indice where mbdomain_type = ? and mbfile_path like ?", (selectedItem.text(4),search))
        records = self.cursor.fetchall()

        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, self.extractpath)

    def extractAll(self):
        if self.is_active == False:
            return
        if self.backuppath is None:
            msg = "No iOS Backup open..."
            self.informationMessage(msg)
            return

        if (self.extractpath == None) or (len(self.extractpath) == 0):
            self.extractpath = self.getFilepathDialog(self.backuppath)

            if (self.extractpath == None) or (len(self.extractpath) == 0):
                return None

#        msg = "Will extract App %s to path %s" % (selectedItem.text(0), self.extractpath)
#        self.informationMessage(msg)

        self.cursor.execute("Select * from indice")
        records = self.cursor.fetchall()
        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            self.mbdb.extract_backup_from_db(dbrecord, self.extractpath)

    def gridLayoutInfo_refresh(self, showinfo=None):
        mydict = {"Build Version": self.ui.lblBuildVersion,
                  "Device Name": self.ui.lblDeviceName,
                  "Display Name": self.ui.lblDisplayName,
                  "GUID": self.ui.lblGUID,
                  "ICCID": self.ui.lblICCID,
                  "IMEI": self.ui.lblIMEI,
                  "MEID": self.ui.lblMEID,
                  "Phone Number": self.ui.lblPhoneNumber,
                  "Product Name": self.ui.lblProductName,
                  "Product Type": self.ui.lblProductType,
                  "Product Version": self.ui.lblProductVersion,
                  "Serial Number": self.ui.lblSerialNumber,
                  "Target Identifier": self.ui.lblTargetIdentifier,
                  "Target Type": self.ui.lblTargetType,
                  "Unique Identifier": self.ui.lblUniqueIdentifier,
                  "iTunes Version": self.ui.lbliTunesVersion
                  }

        for i in mydict:
            if showinfo is not None:
                value = unicode(showinfo.get(i, "missing"))
                if i == 'Product Version':
                    self.iOSVersion = self.getIOSVersion(value)
            else:
                value = ''
            try:
                mydict[i].setText(value)
            except:
                pass

    def getIOSVersion(self, version):
        try:
            return int(version.split('.')[0])
        except:
            return 0

    def gridLayoutManifest_refresh(self, showinfo=None):
        mydict = {"Date": self.ui.lblDate,
                  "IsEncrypted": self.ui.lblIsEncrypted,
                  "SystemDomainsVersion": self.ui.lblSystemDomainsVersion,
                  "Version": self.ui.lblVersion,
                  "WasPasscodeSet": self.ui.lblWasPasscodeSet,
                  "BackupKeyBag": self.ui.lblHasBackupKeybag
                  }

        for i in mydict:
            if showinfo is not None:
                value = unicode(showinfo.get(i, "missing"))
                if i == "BackupKeyBag":
                    value = showinfo.has_key("BackupKeyBag")
            else:
                value = ''
            try:
                mydict[i].setText(value)
            except:
                pass

    def mruAddArchive(self, description, path):
        """
		Update the list of Most Recently Used archives, with a newly opened archive.

		description = The "Display name" of the open archive (e.g. "MyPhone (iPhone3)")
		path = The filesystem path of the archive.

		The function updates the MRU list,
		the application settings file, and the "File" Menu.
		"""

        # Remove the path, if it already exists
        tmp = filter(lambda x: x[0] == path, self.mru_list)
        if len(tmp) > 0:
            self.mru_list.remove(tmp[0])

        # Add the new archive, to the beginning of the list
        self.mru_list.insert(0, ( path, description ))

        self.mruSaveList()
        self.mruUpdateFileMenu()

    def mruSaveList(self):
        """
		Saves the list of MRU files to the application settings file.
		"""
        qs = QSettings()

        qs.remove("mru")
        qs.beginWriteArray("mru")
        for i, m in enumerate(self.mru_list):
            (path, description) = m
            qs.setArrayIndex(i)
            qs.setValue("path", path)
            qs.setValue("description", description)
        qs.endArray()

    def mruLoadList(self):
        """
		Loads the list of MRU files from the pplication settings file.
		"""
        self.mru_list = list()
        qs = QSettings()

        count = qs.beginReadArray("mru")
        for i in range(count):
            qs.setArrayIndex(i)
            path = qs.value("path")
            description = qs.value("description")
            if os.path.exists(path):
                self.mru_list.append((path, description))
        qs.endArray()

    def mruUpdateFileMenu(self):
        items = self.ui.menuReopen.actions()
        found_separator = False
        for i, item in enumerate(items):
            if found_separator:
                self.ui.menuReopen.removeAction(item)
            if (not found_separator) and item == self.ui.separatorMRUList:
                found_separator = True

        # Re-create MRU list
        # (Menu item for each MRU item)
        self.ui.separatorMRUList.setVisible(len(self.mru_list) != 0)

        for i, m in enumerate(self.mru_list):
            (path, description) = m

            text = "%d %s" % (i + 1, description)
            if i < 9:
                text = '&' + text

            action = self.ui.menuReopen.addAction(text)
            action.triggered.connect(lambda p=path: self.openBackup(path))