def __init__(self):
        QMainWindow.__init__(self)
        global tipus
        self.avisa = True  # avisa la sortida

        self.ui_cadi = Ui_Form()
        self.ui_cadi.setupUi(self)

        self.ui_cadi.label_3.setVisible(False)
        self.ui_cadi.label_11.setVisible(False)
        self.ui_cadi.b_root.setVisible(False)

        #############
        ####  PC INFO
        #############

        # Get PC info & put on info labels
        kernel = funcions_k.versiokernel()
        versiokademar = funcions_k.versiokademar()
        tipuskademar = funcions_k.tipuskademar()

        cpu = getoutput(""" grep 'cpu MHz' /proc/cpuinfo | awk '{ print $4 }' """)
        cpuinfo = getoutput(" cat /proc/cpuinfo | grep 'model name' ")
        ram = getoutput("""  grep 'MemTotal' /proc/meminfo | awk '{ print $2 }' """)
        hostname = getoutput("hostname -f")
        logedusers = getoutput("users")
        numlogedusers = len(logedusers.split(" "))

        self.ui_cadi.l_kdm.setText("kademar")
        self.ui_cadi.l_kern.setText(kernel)
        self.ui_cadi.l_ver.setText(versiokademar)
        self.ui_cadi.l_tipu.setText(tipuskademar)
        self.ui_cadi.l_cpu.setText(cpu.split("\n")[0] + " Mhz")
        self.ui_cadi.l_cpuinfo.setText(cpuinfo)
        self.ui_cadi.l_ram.setText(ram + " Mb")
        self.ui_cadi.l_host.setText(hostname)

        if not funcions_k.instalat():
            for i in [self.ui_cadi.b_users, self.ui_cadi.b_language]:
                i.setVisible(0)

        #############
        ####  END PC INFO
        #############

        # Ponemos el splash
        self.ui_cadi.pages.setCurrentWidget(self.ui_cadi.tab_principal)

        self.path = "/usr/share/kademar/utils/cadi"
        #####  Signals & Slots  #####

        self.connect(self.ui_cadi.b_sortir, SIGNAL("clicked()"), self.close)

        self.connect(self.ui_cadi.b_root, SIGNAL("clicked()"), self.boto_root)

        # Software
        self.connect(self.ui_cadi.b_software, SIGNAL("clicked()"), self.boto_software)
        # Hardware
        self.connect(self.ui_cadi.b_hardware, SIGNAL("clicked()"), self.boto_hardware)
        # Xarxa
        self.connect(self.ui_cadi.b_xarxa, SIGNAL("clicked()"), self.boto_xarxa)
        # Sistema
        self.connect(self.ui_cadi.b_sistema, SIGNAL("clicked()"), self.boto_sistema)

        # SOFTWARE
        # Boto Preferencies del sistema
        self.connect(self.ui_cadi.b_preferencies_sistema, SIGNAL("clicked()"), self.boto_preferencies)
        ##Synaptic
        self.connect(self.ui_cadi.b_synaptic, SIGNAL("clicked()"), self.boto_synaptic)

        # HARDWARE
        # Impressores
        self.connect(self.ui_cadi.b_impressores, SIGNAL("clicked()"), self.boto_impressores)
        # Bluetooth
        self.connect(self.ui_cadi.b_bluetooth, SIGNAL("clicked()"), self.boto_bluetooth)
        # Teclats Multimedia
        self.connect(self.ui_cadi.b_teclats_multimedia, SIGNAL("clicked()"), self.boto_teclats_multimedia)
        # Kinfocenter
        self.connect(self.ui_cadi.b_kinfocenter, SIGNAL("clicked()"), self.boto_kinfocenter)
        # Ndiswrapper
        self.connect(self.ui_cadi.b_ndiswrapper, SIGNAL("clicked()"), self.boto_ndiswrapper)

        # XARXA
        # Internet & Conectivity Module
        self.connect(self.ui_cadi.b_internet, SIGNAL("clicked()"), self.boto_internet)
        # Modem
        self.connect(self.ui_cadi.b_modem, SIGNAL("clicked()"), self.boto_modem)
        # ADSL/PPPoE
        self.connect(self.ui_cadi.b_pppoe, SIGNAL("clicked()"), self.boto_pppoe)
        # GPRS
        self.connect(self.ui_cadi.b_gprs, SIGNAL("clicked()"), self.boto_gprs)

        # SYSTEM
        # Display
        self.connect(self.ui_cadi.b_display_configuration, SIGNAL("clicked()"), self.boto_display_configuration)
        # Users
        self.connect(self.ui_cadi.b_users, SIGNAL("clicked()"), self.boto_users)
        # Services
        self.connect(self.ui_cadi.b_services, SIGNAL("clicked()"), self.boto_services)
        # Language
        self.connect(self.ui_cadi.b_language, SIGNAL("clicked()"), self.boto_language)
        # Grub
        self.connect(self.ui_cadi.b_grub, SIGNAL("clicked()"), self.boto_grub)

        #### END Signals & Slots ####

        self.modules = [
            ("preferences", self.boto_preferencies),
            ("synaptic", self.boto_synaptic),
            ("printer", self.boto_impressores),
            ("bluetooth", self.boto_bluetooth),
            ("kboardmmedia", self.boto_teclats_multimedia),
            ("kinfocenter", self.boto_kinfocenter),
            ("ndiswrapper", self.boto_ndiswrapper),
            ("internet", self.boto_internet),
            ("modem", self.boto_modem),
            ("pppoe", self.boto_pppoe),
            ("gprs", self.boto_gprs),
            ("display", self.boto_display_configuration),
            ("users", self.boto_users),
            ("services", self.boto_services),
            ("language", self.boto_language),
            ("grub", self.boto_grub),
        ]

        self.tabs = [
            ("software", self.boto_software),
            ("hardware", self.boto_hardware),
            ("net", self.boto_xarxa),
            ("system", self.boto_sistema),
        ]

        a = b = ""
        # Open a module if you have passed as a parameter
        for i in sys.argv[1:]:
            if i.find("--module=") <> -1:  # --module=wifi
                module = i.split("=")[1]  # get only wifi
                for i in self.modules:  # search and open it
                    if i[0].find(module) <> -1:
                        i[1]()
            elif i.find("--tab=") <> -1:  # --tab=hadware
                tab = i.split("=")[1]  # get only hardware
                for i in self.tabs:  # search and open it
                    if i[0].find(tab) <> -1:
                        i[1]()
            elif i.find("--help") <> -1:
                print
                print
                print "CADI: The configurator tool"
                print "---------------------------"
                print
                print "* To open a tab, call with --tab=xxx  param"
                print " - Tabs Availables:"
                for i in self.tabs:
                    b = b + " " + i[0]
                print b
                print
                print "* To open a module, call with --module=xxx  param"
                print " - Modules Availables:"
                for i in self.modules:
                    a = a + " " + i[0]
                print a
                print
    def __init__(self):
        QWidget.__init__(self)

        #Carrega el Gui
        self.ui = uikademarcenter()
        self.ui.setupUi(self)
        self.usbtrayclosed=True


####
# SOUND CONFIGURATION
####
        self.play="paplay" #Play Program
        self.soundconnect="/usr/share/sounds/KDE_Dialog_Appear.wav" #Sound USB connect
        self.sounddisconnect="/usr/share/sounds/KDE_Dialog_Disappear.wav"

####
# END SOUND CONFIGURATION
####

        self.connect(self.ui.b_settings, SIGNAL("clicked()"), self.showsettings)

        global notifier

        #Load configuration files
        self.load_kademarcenter_config()

####  UsbTray Module  ####
        self.usbtray = UsbTray()
        self.connect(self.usbtray, SIGNAL("showmsg"), self.showmsg)
##########################

####  IvMan Work  ####
        self.HardwareDetect = HardwareDetect()
        self.connect(self.HardwareDetect, SIGNAL("showmsg"), self.showmsg)
        self.connect(self.HardwareDetect, SIGNAL("regeneraformusbtray"), self.regeneraformusbtray)
        self.connect(self.HardwareDetect, SIGNAL("showusbtray"), self.showusbtray)
        self.HardwareDetect.start()
######################

#############
####  TRAY MODULE & ACTIONS
#############
        #### TRAY ####
        self.tray = QSystemTrayIcon(self)
        self.trayMenu = QMenu()
        #Definicio de items del menu (solament el que son, icona i descripcio)
        #self.action_quit = QAction(QIcon("/usr/share/kademar/icons/convertir.png"), self.tr('Quit'), self)
        self.action_mainwindow = QAction(QIcon("/usr/share/kademar/icons/endavant.png"), self.tr("Open kademar Center"), self)
        self.action_settings = QAction(QIcon("/usr/share/kademar/icons/configure.png"), self.tr("Configure"), self)


        #Afegit opcions de dalt, en el menu del context
        self.trayMenu.addAction(self.action_mainwindow)
        self.trayMenu.addAction(self.action_settings)

        #self.trayMenu.addAction(self.action_quit)

        #Connectar Accions al fer click a un del menu, la function que executa
        self.connect(self.action_mainwindow, SIGNAL("triggered()"), self.mainwindow)
        self.connect(self.action_settings, SIGNAL("triggered()"), self.showsettings)

        #self.connect(self.action_quit, SIGNAL("triggered()"), self.quitusbtray)

        #Quan fas clic al tray executa eventsdeltray (function)
        self.tray.connect( self.tray, SIGNAL( "activated(QSystemTrayIcon::ActivationReason)" ), self.eventsdeltray )

        self.trayIcon = QIcon("/usr/share/kademar/utils/kademarcenter/img/kademar.png")
        self.tray.setContextMenu(self.trayMenu)
        self.tray.setIcon(self.trayIcon)
        self.tray.setToolTip("kademar Center")
        self.tray.show()
#############
####  END  TRAY MODULE & ACTIONS
#############

#### INITIAL Services Start  ####
        #Initial start of services
        system(scripts.initial_service_start)
#################################

#### INITIAL DEVICE MOUNT ####
        #Initial mount of already plugged devices
        for udi in getoutput(scripts.initial_mount).split():
            print udi
            print "INITIAL DEVICE"
            system("touch /tmp/kademarcenter-inicial")
            self.HardwareDetect.processa_udi(udi, "add")
            system("rm -f /tmp/kademarcenter-inicial")
##############################

#############
####  PC INFO
#############

#Get PC info & put on info labels
        kernel=funcions_k.versiokernel()
        versiokademar=funcions_k.versiokademar()
        tipuskademar=funcions_k.tipuskademar()

        cpu=getoutput(""" grep 'cpu MHz' /proc/cpuinfo | awk '{ print $4 }' """)
        cpuinfo=getoutput(" cat /proc/cpuinfo | grep 'model name' ")
        ram=getoutput("""  grep 'MemTotal' /proc/meminfo | awk '{ print $2 }' """)
        hostname=getoutput("hostname -f")
        logedusers=getoutput("users")
        numlogedusers=len(logedusers.split(" "))

        self.ui.l_kdm.setText("kademar")
        self.ui.l_kern.setText(kernel)
        self.ui.l_ver.setText(versiokademar)
        self.ui.l_tipu.setText(tipuskademar)
        self.ui.l_cpu.setText(cpu.split("\n")[0]+" Mhz")
        self.ui.l_cpuinfo.setText(cpuinfo)
        self.ui.l_ram.setText(ram+" Mb")
        self.ui.l_host.setText(hostname)

        self.kademarstart()
        
        #if live-cd check if executing 32bit kademar on 64bit Machine
        global kademarstartconfig
        if not funcions_k.instalat() and kademarstartconfig.arch_warning:
            if getoutput("arch") != "x86_64": #if system kernel ISN'T 64bit
                #check if machine can support 64 bit system
                check64bit=getoutput(""" for i in `grep cache_alignment /proc/cpuinfo | cut -d: -f2`; do echo $i; break; done """).strip()
                checkSse3=getoutput("""  grep -i sse3 /proc/cpuinfo 2>/dev/null """)
                checkSse4=getoutput("""  grep -i sse4 /proc/cpuinfo 2>/dev/null """)
                if checkSse3 or checkSse4:  #if have sse3 or 4
                    if int(check64bit) >= 64:
                    #warn if it's a machine 64bit capable with a 32bit system
                        QMessageBox.critical(self, self.tr('Executing 32bit kademar on a 64bit Machine'), self.tr("Your computer is a 64bit capable, but you are executing a 32bit kademar.\nThis can cause performance issues and kademar experience could be reduced.\n\nFor live-cd use there's no problem, but if you want to install kademar on this machine, would be better if you download 64bit version from www.kademar.org"))


#############
####  END PC INFO
#############

        #Comprueba dispositivos USB y muestralo si eso
        self.regeneraformusbtray()