SpotifySettingsDialog::SpotifySettingsDialog( QWidget *parent )
    : KDialog( parent )
    , m_settingsWidget(new Ui::SpotifySettingsWidget)
{
    debug() << "Checking Spotify resolver: " << Collections::SpotifyCollection::resolverPath();
    if( !QFile::exists( Collections::SpotifyCollection::resolverPath() ) )
    {
        SpotifyDownloadDialog dialog;
        m_config.reset();
        dialog.exec();
    }

    setCaption( i18n( "Spotify configuration" ) );
    setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply | KDialog::Default );
    enableButtonApply( false );

    QWidget *w = new QWidget(this);
    m_settingsWidget->setupUi( w );
    m_settingsWidget->messageWidget->hide();
    setMainWidget( w );

    connect( this, SIGNAL( okClicked() ),
            this, SLOT( slotTryLogin() ) );
    connect( this, SIGNAL( cancelClicked() ),
            this, SLOT( slotCancel() ) );
    connect( this, SIGNAL( applyClicked() ),
            this, SLOT( slotTryLogin() ) );
    connect( this, SIGNAL( defaultClicked() ),
            this, SLOT( defaults() ) );

    connect( m_settingsWidget->lineUsername, SIGNAL( textChanged( const QString& ) ),
            this, SLOT( slotSettingsChanged() ) );
    connect( m_settingsWidget->linePassword, SIGNAL( textChanged( const QString& ) ),
            this, SLOT( slotSettingsChanged() ) );
    connect( m_settingsWidget->checkHighQuality, SIGNAL( clicked() ),
            this, SLOT( slotSettingsChanged() ) );

    connect( this, SIGNAL( changed( bool ) ), this, SLOT( enableButtonApply( bool ) ) );

    // Load config from KConfig or KWallet
    load();
}
Exemplo n.º 2
0
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();
    }
  }
}
Exemplo n.º 3
0
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();
    }
  }
}
Exemplo n.º 4
0
LoginWidget::LoginWidget(QWidget* parent) : QGroupBox(parent)
{
  //Set the default values for the current item
  idL.clear(); //Clear the login names available
  userSelected = false; //focus on the username first
  pwVisible = false; //Have the password box hide the input behind dots
  allowPWVisible = true; //Allow the password button to show the password text
  showUsers = true; //Display the available users on the system
  updating = false; //not currently updating (internal flag for refreshes)
  allowAnon = false;
	
  //Create the Grid layout
  QHBoxLayout* hlayout1 = new QHBoxLayout();
  QHBoxLayout* hlayout2 = new QHBoxLayout();
  QHBoxLayout* hlayout3 = new QHBoxLayout();
  QHBoxLayout* hlayout4 = new QHBoxLayout();
  QVBoxLayout* vlayout = new QVBoxLayout();
  QFormLayout* flayout = new QFormLayout();
  //Create the items
  userIcon = new QToolButton(this);
  	QAction* tmp = new QAction(this);
	userIcon->setDefaultAction( tmp );
	userIcon->setFocusPolicy(Qt::NoFocus);
  listUserBig = new QListWidget(this);
  	listUserBig->setFocusPolicy(Qt::StrongFocus);
  	listUserBig->setSelectionMode(QAbstractItemView::SingleSelection);
  listUsers = new QComboBox(this);
  	listUsers->setFocusPolicy(Qt::NoFocus); //big one gets keyboard focus instead
  linePassword = new QLineEdit(this);
  	linePassword->setFocusPolicy(Qt::StrongFocus);
  lineDevPassword = new QLineEdit(this);
	lineDevPassword->setFocusPolicy(Qt::StrongFocus);
  lineUsername = new QLineEdit;
	lineUsername->setFocusPolicy(Qt::StrongFocus);
  pushLogin = new QToolButton;
	QAction* tmp1 = new QAction(this);
	pushLogin->setDefaultAction( tmp1 );
	pushLogin->setFocusPolicy(Qt::StrongFocus);
  pushViewPassword = new QToolButton;
	QAction* tmp2 = new QAction(this);
	pushViewPassword->setDefaultAction( tmp2 );
	pushViewPassword->setFocusPolicy(Qt::NoFocus);
  pushUserIcon = new QToolButton;
	QAction* tmp3 = new QAction(this);
	pushUserIcon->setDefaultAction( tmp3 );
	pushUserIcon->setFocusPolicy(Qt::NoFocus);
  pushRefresh = new QToolButton;
    pushRefresh->setFocusPolicy(Qt::NoFocus);
  listDE = new QComboBox(this);
  deIcon = new QLabel(this);
  devIcon = new QLabel(this);
  nousers = new QLabel(this);
    nousers->setWordWrap(true);
  checkAnon = new QCheckBox(this);
    checkAnon->setChecked(false); //always default to disabled
    checkAnon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    
  //Add the items to the grid
    vlayout->addWidget(nousers);
    //user not yet selected widgets
      hlayout1->addWidget(userIcon);
    vlayout->addLayout(hlayout1);
    vlayout->addWidget(listUserBig);
    //User selected widgets
        hlayout3->addWidget(listUsers);
        hlayout3->addWidget(lineUsername);
      flayout->addRow(pushUserIcon, hlayout3);
      flayout->addRow(pushViewPassword, linePassword);
      flayout->addRow(devIcon, lineDevPassword);
      flayout->addRow(deIcon,listDE);
    vlayout->addSpacing(15);
    vlayout->addLayout(flayout);
    vlayout->addSpacing(20);
      hlayout2->addWidget(pushLogin);
    vlayout->addLayout(hlayout2);
    //vlayout->addSpacing(10);
      hlayout4->addStretch();
      hlayout4->addWidget(checkAnon);
      hlayout4->addStretch();
      vlayout->addLayout(hlayout4);
    vlayout->addSpacing(10);
    vlayout->addWidget(pushRefresh);
    
  //Setup the Signals/Slots
  connect(pushLogin,SIGNAL(clicked()),this,SLOT(slotTryLogin()));
  connect(pushUserIcon,SIGNAL(triggered(QAction*)), this, SLOT(slotUserActivated()));
  connect(userIcon,SIGNAL(triggered(QAction*)), this, SLOT(slotUserActivated()));
  connect(listUsers,SIGNAL(activated(int)),this,SLOT(slotChooseUser(int)));
  connect(listUserBig,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(slotUserSelected()) );
  connect(listUserBig,SIGNAL(currentRowChanged(int)),this,SLOT(slotUserHighlighted(int)) );
  connect(listDE,SIGNAL(currentIndexChanged(int)),this,SLOT(slotDesktopChanged(int)) );
  connect(checkAnon, SIGNAL(stateChanged(int)), this, SLOT(slotAnonChanged()) );
  connect(pushRefresh, SIGNAL(clicked()), this, SIGNAL(refreshUsers()) );
  allowPasswordView(allowPWVisible); //setup signal/slots for pushViewPassword
  //Set this layout for the loginWidget
  this->setLayout(vlayout);
  
  //Run the display setup to ensure appropriate visiblility/usage
  updateWidget();
  
}