void LoginWidget::setUsernames(QStringList uList){ if(uList.isEmpty()){ idL.clear(); listUsers->clear(); listUserBig->clear(); }else{ updating = true; //Make sure that the two user widgets are identical listUsers->clear(); for(int i=0; i<uList.length(); i++){ if(uList[i].contains("::::")){ //This is a special personacrypt user - also needs additional device password listUsers->addItem(uList[i].section("::::",0,0), "persona"); //set internal flag uList[i] = uList[i].section("::::",0,0); //remove this flag for other widgets }else{ listUsers->addItem(uList[i], "normal"); //just show this name (nothing special) } } listUserBig->clear(); listUserBig->addItems(uList); idL.clear(); idL = uList; //save for later listUsers->setCurrentIndex(0); listUserBig->setCurrentRow(0); //Automatically select the user if there is only one updating = false; //done if(uList.length() == 1){ //qDebug() << "Single User System Detected"; slotUserSelected(); } } updateWidget(); }
void KDMUsersWidget::load() { QString str; KConfigGroup configGrp = config->group( "X-*-Greeter" ); selectedUsers = configGrp.readEntry( "SelectedUsers", QStringList() ); hiddenUsers = configGrp.readEntry( "HiddenUsers", QStringList() ); leminuid->setText( configGrp.readEntry( "MinShowUID", defminuid ) ); lemaxuid->setText( configGrp.readEntry( "MaxShowUID", defmaxuid ) ); cbshowlist->setChecked( configGrp.readEntry( "UserList", true ) ); cbcomplete->setChecked( configGrp.readEntry( "UserCompletion", false ) ); cbinverted->setChecked( configGrp.readEntry( "ShowUsers" ) != "Selected" ); cbusrsrt->setChecked( configGrp.readEntry( "SortUsers", true ) ); QString ps = configGrp.readEntry( "FaceSource" ); if (ps == QLatin1String("UserOnly")) rbusronly->setChecked( true ); else if (ps == QLatin1String("PreferUser")) rbprefusr->setChecked( true ); else if (ps == QLatin1String("PreferAdmin")) rbprefadm->setChecked( true ); else rbadmonly->setChecked( true ); slotUserSelected(); slotShowOpts(); slotFaceOpts(); }
void KDMUsersWidget::changeUserPix( const QString &pix ) { QString user( usercombo->currentText() ); if (user == m_defaultText) { user = "******"; if (KMessageBox::questionYesNo( this, i18n("Save image as default image?"), QString(), KStandardGuiItem::save(), KStandardGuiItem::cancel() ) != KMessageBox::Yes) return; } QImage p( pix ); if (p.isNull()) { KMessageBox::sorry( this, i18n("There was an error loading the image\n%1", pix ) ); return; } p = p.scaled( 48, 48, Qt::KeepAspectRatio, Qt::SmoothTransformation ); QString userpix = m_userPixDir + user + ".face.icon"; if (!p.save( userpix, "PNG" )) KMessageBox::sorry( this, i18n("There was an error saving the image:\n%1", userpix ) ); slotUserSelected(); }
//------------------------------------- // PRIVATE SLOTS //------------------------------------- void LoginWidget::slotUserActivated(){ //Toggle the user box as to what is visible if(!userSelected){ slotUserSelected(); }else{ slotUserUnselected(); } }
//------------------------------------- // PRIVATE SLOTS //------------------------------------- void LoginWidget::slotUserActivated(){ if(updating){ return; } //internally updating - skip signal //Toggle the user box as to what is visible if(!userSelected){ slotUserSelected(); }else{ slotUserUnselected(); } }
void KDMUsersWidget::slotFaceOpts() { bool en = !rbusronly->isChecked(); usercombo->setEnabled( en ); userbutton->setEnabled( en ); if (en) slotUserSelected(); else rstuserbutton->setEnabled( false ); }
void LoginWidget::keyPressEvent(QKeyEvent *e){ if( (e->key()==Qt::Key_Enter) || (e->key()==Qt::Key_Return) ){ if(userSelected){ slotTryLogin(); }else{ slotUserSelected(); } }else if(e->key() == Qt::Key_Escape){ if(userSelected){ slotUserUnselected(); }else{ emit escapePressed(); } } }
void LoginWidget::keyPressEvent(QKeyEvent *e){ if(nousers->isVisible()){ return; } if( (e->key()==Qt::Key_Enter) || (e->key()==Qt::Key_Return) ){ if(userSelected || !showUsers){ slotTryLogin(); }else{ slotUserSelected(); } }else if(e->key() == Qt::Key_Escape){ if(userSelected && showUsers){ slotUserUnselected(); }else{ emit escapePressed(); } } }
void LoginWidget::setUsernames(QStringList uList){ if(uList.isEmpty()){ return; } //Make sure that the two user widgets are identical listUsers->clear(); listUsers->addItems(uList); listUserBig->clear(); listUserBig->addItems(uList); idL.clear(); idL = uList; //save for later listUsers->setCurrentIndex(0); listUserBig->setCurrentRow(0); //Automatically select the user if there is only one if(uList.length() == 1){ qDebug() << "Single User System Detected"; slotUserSelected(); } }
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"; } }
void KDMUsersWidget::slotUnsetUserPix() { QFile::remove( m_userPixDir + usercombo->currentText() + ".face.icon" ); slotUserSelected(); }
void LoginWidget::slotChooseUser(int i){ if(i!=-1){ slotUserSelected(); } }