Ejemplo n.º 1
0
Installer::Installer(QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);
    translator = new QTranslator();

    connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(slotNext()));

    connect(helpButton, SIGNAL(clicked()), this, SLOT(slotHelp()));
    connect(pushTouchKeyboard, SIGNAL(clicked()), this, SLOT(slotPushVirtKeyboard()));
    connect(pushChangeKeyLayout, SIGNAL(clicked()), this, SLOT(slotPushKeyLayout()));

    connect(lineHostname,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckHost()));

    connect(lineRootPW, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));
    connect(lineRootPW2, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));

    connect(lineName,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(lineName,SIGNAL(editingFinished()),this,SLOT(slotSuggestUsername()));
    connect(lineUsername,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(linePW,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(linePW2,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));

    backButton->setText(tr("&Back"));
    nextButton->setText(tr("&Next"));


    // Load the keyboard info
    keyModels = Scripts::Backend::keyModels();
    keyLayouts = Scripts::Backend::keyLayouts();

    // Load the timezones
    comboBoxTimezone->clear();
    QString curZone = Scripts::Backend::guessTimezone();
    comboBoxTimezone->addItems(Scripts::Backend::timezones());
    if ( ! curZone.isEmpty() ) {
      int index = comboBoxTimezone->findText(curZone, Qt::MatchStartsWith);
      if (index != -1)
         comboBoxTimezone->setCurrentIndex(index);
    } else {
      // Set America/New_York to default
      int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
      if (index != -1)
         comboBoxTimezone->setCurrentIndex(index);
    }

    // Load the hostname
    lineHostname->setText(pcbsd::Utils::getConfFileValue("/etc/rc.conf", "hostname=", 1));

    // Start on the first screen
    installStackWidget->setCurrentIndex(0);
    backButton->setVisible(false);
}
Ejemplo n.º 2
0
void PCDMgui::createGUIfromTheme(){
  QString style;
  QString tmpIcon; //used for checking image files before loading them
  QWidget *leftscreen = 0;
  for(int i=0; i<screens.length(); i++){
    if(screens[i]->x()==0){
      leftscreen = screens[i];
    }
  }
  //Define the default icon size
  int perc = qRound(leftscreen->height()*0.035); //use 3.5% of the screen height
  defIconSize = QSize(perc,perc);
  //Set the background image
  if(DEBUG_MODE){ qDebug() << "Setting Background Image"; }
  if( currentTheme->itemIsEnabled("background") ){
    tmpIcon = currentTheme->itemIcon("background");
    if( tmpIcon.isEmpty() || !QFile::exists(tmpIcon) ){ tmpIcon = ":/images/backgroundimage.jpg"; }
    //use "border-image" instead of "background-image" to stretch rather than tile the image
    QString bgstyle = "QWidget#BGSCREEN{border-image: url(BGIMAGE) stretch;}"; 
    bgstyle.replace("BGIMAGE", tmpIcon);
    style.append(bgstyle);
  }
  //Set the application style sheet
  style.append(" "+ currentTheme->styleSheet() );
  this->setStyleSheet( style.simplified() );

  //Check for whether the desktop switcher is on the toolbar or not
  simpleDESwitcher = (currentTheme->itemValue("desktop") == "simple");
  
  //get the default translation directory
  if(DEBUG_MODE){ qDebug() << "Load Translations"; }
  translationDir = "/usr/local/share/pcbsd/i18n/";
  //Fill the translator
  m_translator = new QTranslator();
  //Create the Toolbar
  toolbar = new QToolBar();
  //Add the Toolbar to the window
  if(DEBUG_MODE){ qDebug() << "Create Toolbar"; }
    //use the theme location   
    QString tarea = currentTheme->itemValue("toolbar");
    if(tarea == "left"){
      this->addToolBar( Qt::LeftToolBarArea, toolbar ); 	    
    }else if( tarea=="top"){
      this->addToolBar( Qt::TopToolBarArea, toolbar );  	   
      toolbar->setFixedWidth(leftscreen->width());
    }else if(tarea=="right"){
      this->addToolBar( Qt::RightToolBarArea, toolbar );   	    
    }else{ //bottom is default
      this->addToolBar( Qt::BottomToolBarArea, toolbar ); 	
      toolbar->setFixedWidth(leftscreen->width());
    }
    //Set toolbar flags
    toolbar->setVisible(true);
    toolbar->setMovable(false);
    toolbar->setFloatable(false);
    toolbar->setContextMenuPolicy(Qt::PreventContextMenu); //make sure no right-click menu
    //Set the default style and icon sizes
    QString tstyle = currentTheme->itemIcon("toolbar").toLower(); //use the theme style
    if(tstyle=="textonly"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly); }
    else if(tstyle=="textbesideicon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); }
    else if(tstyle=="textundericon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); }
    else{ toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); } //default to icon only
    
    QSize tmpsz = currentTheme->itemIconSize("toolbar");
    if(!tmpsz.isValid()){ tmpsz = defIconSize; }
    toolbar->setIconSize( tmpsz ); //use theme size
    toolbar->setFocusPolicy( Qt::NoFocus );
  //Populate the Toolbar with items (starts at leftmost/topmost)
    //----Virtual Keyboard
    if(currentTheme->itemIsEnabled("vkeyboard") ){
      if(DEBUG_MODE){ qDebug() << " - Create Virtual Keyboard Button"; }
      tmpIcon = currentTheme->itemIcon("vkeyboard");
      if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/input-keyboard.png"; }
      virtkeyboardButton = new QAction( QIcon(tmpIcon),tr("Virtual Keyboard"),this );
      toolbar->addAction(virtkeyboardButton);
      connect( virtkeyboardButton, SIGNAL(triggered()), this, SLOT(slotPushVirtKeyboard()) );
    }else{
      virtkeyboardButton = new QAction(this);
    }

    //----Locale Switcher
    if(DEBUG_MODE){ qDebug() << " - Create Locale Button"; }
    tmpIcon = currentTheme->itemIcon("locale");
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/language.png"; }
    localeButton = new QAction( QIcon(tmpIcon),tr("Locale"),this );
    toolbar->addAction(localeButton);
    connect( localeButton, SIGNAL(triggered()), this, SLOT(slotChangeLocale()) );
    
    //----Keyboard Layout Switcher
    if(DEBUG_MODE){ qDebug() << " - Create Keyboard Layout Button"; }
    tmpIcon = currentTheme->itemIcon("keyboard");
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/keyboard.png"; }
    keyboardButton = new QAction( QIcon(tmpIcon),tr("Keyboard Layout"),this );
    toolbar->addAction(keyboardButton);
    connect( keyboardButton, SIGNAL(triggered()), this, SLOT(slotChangeKeyboardLayout()) );

    //----Add a spacer
    QWidget* spacer = new QWidget();
    spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
    toolbar->addWidget(spacer);
        
    //----System Shutdown/Restart
    if(DEBUG_MODE){ qDebug() << " - Create System Button"; }
    tmpIcon = currentTheme->itemIcon("system");
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/system.png"; }
    QAction* act = new QAction( QIcon(tmpIcon),tr("System"),this );
    systemButton = new QToolButton();
    systemButton->setDefaultAction(act);
    systemMenu = new QMenu();
    toolbar->addWidget(systemButton);
    systemButton->setPopupMode( QToolButton::InstantPopup );
    systemButton->setFocusPolicy( Qt::NoFocus );
    
  //Create the grid layout
  QGridLayout* grid = new QGridLayout;
  if(DEBUG_MODE){ qDebug() << "Fill Desktop Area"; }
  //Populate the grid with items
    //----Header Image
    QLabel* header = new QLabel; 
    if( currentTheme->itemIsEnabled("header") ){
      if(DEBUG_MODE){ qDebug() << " - Create Header"; }
      tmpIcon = currentTheme->itemIcon("header");
      if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/banner.png"; }
      QPixmap tmp( tmpIcon );
      header->setPixmap( tmp.scaled( currentTheme->itemIconSize("header") ) );
      grid->addWidget( header, currentTheme->itemLocation("header","row"), \
                      currentTheme->itemLocation("header","col"), \
                      currentTheme->itemLocation("header","rowspan"), \
                      currentTheme->itemLocation("header","colspan"), Qt::AlignCenter);
    }
    
    //Username/Password/Login widget
    if(DEBUG_MODE){ qDebug() << " - Create Login Widget"; }
    loginW = new LoginWidget;
    /*loginW->setUsernames(Backend::getSystemUsers()); //add in the detected users
    QString lastUser = Backend::getLastUser();
    if(!lastUser.isEmpty()){ //set the previously used user
    	loginW->setCurrentUser(lastUser); 
    }*/
    //Set Icons from theme
    tmpIcon = currentTheme->itemIcon("login");
    tmpsz = currentTheme->itemIconSize("login");
    if(!tmpsz.isValid()){ tmpsz = defIconSize; }
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/next.png"; }
    loginW->changeButtonIcon("login",tmpIcon, tmpsz);
    tmpIcon = currentTheme->itemIcon("anonlogin");
    tmpsz = currentTheme->itemIconSize("login");
    if(!tmpsz.isValid()){ tmpsz = defIconSize; }
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/next-stealth.png"; }
    loginW->changeButtonIcon("anonlogin", tmpIcon, tmpsz);
    tmpIcon = currentTheme->itemIcon("user");
    slotUserChanged(loginW->currentUsername()); //Make sure that we have the correct user icon
    tmpIcon = currentTheme->itemIcon("password");
    tmpsz = currentTheme->itemIconSize("password");
    if(!tmpsz.isValid()){ tmpsz = defIconSize; }
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/password.png"; }
    loginW->changeButtonIcon("pwview",tmpIcon, tmpsz);
    tmpIcon = currentTheme->itemIcon("encdevice");
    tmpsz = currentTheme->itemIconSize("device");
    if(!tmpsz.isValid()){ tmpsz = defIconSize; }
    if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/usbdevice.png"; }
    loginW->changeButtonIcon("device", tmpIcon, tmpsz);
    //Enable/disable the password view functionality
    loginW->allowPasswordView( Config::allowPasswordView() );
    loginW->allowUserSelection( Config::allowUserSelection() );
    loginW->allowAnonLogin( Config::allowAnonLogin() );
    //Add item to the grid
    grid->addWidget( loginW, currentTheme->itemLocation("login","row"), \
                      currentTheme->itemLocation("login","col"), \
                      currentTheme->itemLocation("login","rowspan"), \
                      currentTheme->itemLocation("login","colspan"), Qt::AlignCenter);
    //Connect the signals/slots
    connect(loginW,SIGNAL(loginRequested(QString,QString)),this,SLOT(slotStartLogin(QString,QString)));
    connect(loginW,SIGNAL(escapePressed()),this,SLOT(slotShutdownComputer()));
    connect(loginW,SIGNAL(UserSelected(QString)), this, SLOT(slotUserSelected(QString)) );
    connect(loginW,SIGNAL(UserChanged(QString)), this, SLOT(slotUserChanged(QString)) );
    
    //----Desktop Environment Switcher
    if(simpleDESwitcher){
      tmpsz = currentTheme->itemIconSize("desktop");
      if(!tmpsz.isValid()){ tmpsz = defIconSize; }
      loginW->setDesktopIconSize(tmpsz);
    }else{
      if(DEBUG_MODE){ qDebug() << " - Create DE Switcher"; }
      //Create the switcher
      deSwitcher = new FancySwitcher(this, !currentTheme->itemIsVertical("desktop") );
      tmpsz = currentTheme->itemIconSize("desktop");
      if(!tmpsz.isValid()){ tmpsz = defIconSize; }
      deSwitcher->setIconSize(tmpsz.height());
      tmpIcon = currentTheme->itemIcon("nextde");
      if( !tmpIcon.isEmpty() && QFile::exists(tmpIcon) ){ deSwitcher->changeButtonIcon("forward", tmpIcon); }
      tmpIcon = currentTheme->itemIcon("previousde");
      if( !tmpIcon.isEmpty() && QFile::exists(tmpIcon) ){ deSwitcher->changeButtonIcon("back", tmpIcon); }
      //Figure out if we need to smooth out the animation
      deSwitcher->setNumberAnimationFrames("4"); 
      //NOTE: A transparent widget background slows the full animation to a crawl with a stretched background image

      grid->addWidget( deSwitcher, currentTheme->itemLocation("desktop","row"), \
                      currentTheme->itemLocation("desktop","col"), \
                      currentTheme->itemLocation("desktop","rowspan"), \
                      currentTheme->itemLocation("desktop","colspan"), Qt::AlignCenter);
    }
    //----WINDOW SPACERS
    QStringList spacers = currentTheme->getSpacers();
    for(int i=0; i<spacers.length(); i++){
      bool isVertical = (spacers[i].section("::",0,0) == "true");
      int row = spacers[i].section("::",1,1).toInt();
      int col = spacers[i].section("::",2,2).toInt();
      //qDebug() << "Add Spacer:" << isVertical << row << col;
      if(isVertical){
        grid->setRowStretch(row,1);
      }else{ //horizontal
        grid->setColumnStretch(col,1);
      }
    }

  //Connect the grid to the leftmost screen widget
  leftscreen->setLayout(grid);
    
  //Now translate the UI and set all the text
  if(DEBUG_MODE){ qDebug() << " - Fill GUI with data"; }
  //retranslateUi();
  LoadAvailableUsers(); //Note: this is the first time it is run
  if(DEBUG_MODE){ qDebug() << " - Translate GUI"; }
  retranslateUi();
  if(DEBUG_MODE){ qDebug() << "Done with initialization"; }

}
Ejemplo n.º 3
0
Installer::Installer(QWidget *parent) : QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint)
{
    setupUi(this);
    //Setup the window
    if(!DEBUG){ this->setGeometry( QApplication::primaryScreen()->geometry() ); }//full screen
    else{ this->setWindowFlags(Qt::Window); } //don't keep on bottom/frameless for testing

    translator = new QTranslator();

    connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(slotNext()));

    connect(helpButton, SIGNAL(clicked()), this, SLOT(slotHelp()));
    connect(pushTouchKeyboard, SIGNAL(clicked()), this, SLOT(slotPushVirtKeyboard()));
    connect(pushChangeKeyLayout, SIGNAL(clicked()), this, SLOT(slotPushKeyLayout()));

    connect(lineHostname,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckHost()));
    connect(lineDomainName, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckDomainName()) );

    connect(lineRootPW, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));
    connect(lineRootPW2, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));

    connect(lineName,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(lineName,SIGNAL(editingFinished()),this,SLOT(slotSuggestUsername()));
    connect(lineUsername,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(linePW,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(linePW2,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(line_PCpass, SIGNAL(textChanged(const QString)), this, SLOT(slotCheckUser())) ;
    connect(line_PCpass_repeat, SIGNAL(textChanged(const QString)), this, SLOT(slotCheckUser())) ;
    connect(group_usePC, SIGNAL(toggled(bool)), this, SLOT(slotCheckUser()) );
    connect(push_PC_device, SIGNAL(clicked()), this, SLOT(slotGetPCDevice()) );
    
    connect(tool_testAudio, SIGNAL(clicked()), this, SLOT(slotPlayAudioTest()) );
    connect(slider_volume, SIGNAL(valueChanged(int)), this, SLOT(slotAudioVolumeChanged()) );
    connect(combo_audiodevice, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetAudioDev()) );
    backButton->setText(tr("&Back"));
    nextButton->setText(tr("&Next"));


    // Load the keyboard info
    keyModels = Scripts::Backend::keyModels();
    keyLayouts = Scripts::Backend::keyLayouts();

    // If we have a saved keyboard layout from installation, use it first
    QString kD;
    if ( QFile::exists("/var/.wizardKeyboard") ) {
      QFile kFile("/var/.wizardKeyboard");
      if ( kFile.open(QIODevice::ReadOnly | QIODevice::Text) ) {
         kD = kFile.readLine().simplified();
         kFile.close();
         
         kbMod = kD.section(" ", 0, 0);
         kbLay = kD.section(" ", 1, 1);
         kbVar = kD.section(" ", 2, 2);
	 Scripts::Backend::changeKbMap(kbMod, kbLay, kbVar);
      } 
    }

    // Load the timezones
    comboBoxTimezone->clear();
    QString curZone = Scripts::Backend::guessTimezone();
    comboBoxTimezone->addItems(Scripts::Backend::timezones());
    if ( ! curZone.isEmpty() ) {
      int index = comboBoxTimezone->findText(curZone, Qt::MatchStartsWith);
      if (index != -1) {
         comboBoxTimezone->setCurrentIndex(index);
      } else {
        // Set America/New_York to default
        index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
        if (index != -1)
           comboBoxTimezone->setCurrentIndex(index);
      }
    } else {
      // Set America/New_York to default
      int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
      if (index != -1)
         comboBoxTimezone->setCurrentIndex(index);
    }

    // Load the hostname
     lineHostname->setText(pcbsd::Utils::getConfFileValue("/etc/rc.conf", "hostname=", 1).section(".",0,0));

    // Load the domain name
    lineDomainName->setText(pcbsd::Utils::getConfFileValue("/etc/rc.conf", "hostname=",1).section(".",1,100));

    //Load the available Services into the UI
    LoadServices();
    
    // Start on the first screen
    installStackWidget->setCurrentIndex(0);
    backButton->setVisible(false);

    // Update the status bar
    // This makes the status text more "visible" instead of using the blue background
    //statusBar()->setStyleSheet("background: white");

    
    //Load the audio settings values
    combo_audiodevice->clear();
    QStringList devs = pcbsd::Utils::runShellCommand("pc-sysconfig list-audiodev").join("").split(", ");
    int def = -1; bool found = false;
    for(int i=0; i<devs.length(); i++){
      combo_audiodevice->addItem(devs[i], devs[i].section(":",0,0)); //<full text>, <pcmID>
      if(devs[i].contains(" default")){ found = true; def = i; }
    }
    if(def<0 && !devs.isEmpty()){ def=0; }
    if(def<0){
      //No audio devices found - disable this functionality
      Page_Audio->setEnabled(false); //just do the whole page - nothing will work
    }else{
      combo_audiodevice->setCurrentIndex(def); //make sure this item is initially selected
      if(!found){ slotSetAudioDev(); } //make sure to run the setup command initially
    }
    slider_volume->setValue(100);
    slotAudioVolumeChanged(); //update the volume % label
    
}
Ejemplo n.º 4
0
Installer::Installer(QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);
    translator = new QTranslator();

    connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(slotNext()));

    connect(helpButton, SIGNAL(clicked()), this, SLOT(slotHelp()));
    connect(pushTouchKeyboard, SIGNAL(clicked()), this, SLOT(slotPushVirtKeyboard()));
    connect(pushChangeKeyLayout, SIGNAL(clicked()), this, SLOT(slotPushKeyLayout()));

    connect(lineHostname,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckHost()));

    connect(lineRootPW, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));
    connect(lineRootPW2, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));

    connect(lineName,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(lineName,SIGNAL(editingFinished()),this,SLOT(slotSuggestUsername()));
    connect(lineUsername,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(linePW,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
    connect(linePW2,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));

    backButton->setText(tr("&Back"));
    nextButton->setText(tr("&Next"));


    // Load the keyboard info
    keyModels = Scripts::Backend::keyModels();
    keyLayouts = Scripts::Backend::keyLayouts();

    // If we have a saved keyboard layout from installation, use it first
    QString kD;
    if ( QFile::exists("/var/.wizardKeyboard") ) {
      QFile kFile("/var/.wizardKeyboard");
      if ( kFile.open(QIODevice::ReadOnly | QIODevice::Text) ) {
         kD = kFile.readLine().simplified();
         kFile.close();
         
         kbMod = kD.section(" ", 0, 0);
         kbLay = kD.section(" ", 1, 1);
         kbVar = kD.section(" ", 2, 2);
	 Scripts::Backend::changeKbMap(kbMod, kbLay, kbVar);
      } 
    }

    // Load the timezones
    comboBoxTimezone->clear();
    QString curZone = Scripts::Backend::guessTimezone();
    comboBoxTimezone->addItems(Scripts::Backend::timezones());
    if ( ! curZone.isEmpty() ) {
      int index = comboBoxTimezone->findText(curZone, Qt::MatchStartsWith);
      if (index != -1)
         comboBoxTimezone->setCurrentIndex(index);
    } else {
      // Set America/New_York to default
      int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
      if (index != -1)
         comboBoxTimezone->setCurrentIndex(index);
    }

    // Load the hostname
    lineHostname->setText(pcbsd::Utils::getConfFileValue("/etc/rc.conf", "hostname=", 1));

    // Start on the first screen
    installStackWidget->setCurrentIndex(0);
    backButton->setVisible(false);

    // Update the status bar
    // This makes the status text more "visible" instead of using the blue background
    statusBar()->setStyleSheet("background: white");
}