Пример #1
0
void MultipleChoiceWidget::addButton() {
    QSize newSize = this->size();
    QRadioButton * button = new QRadioButton(tr("Insert Text: New"), this);
    //QFont *font = new QFont("Arial", 100);
    //button->setFont(*font);
    correctButtonSize(button);
    questions->append(button);
    box->addButton(button);
    gridLayoutButtonGroup->addWidget(button);
    if (button->width() > this->width())
        newSize.setWidth(button->width());
    newSize.setHeight(questions->size() * button->height());
    this->resize(newSize);
    button->show();
    this->update();
}
Пример #2
0
KKeyChooser::KKeyChooser( QDict<KKeyEntry> *aKeyDict, QWidget *parent )
    : QWidget( parent )
{
	
	bKeyIntercept = FALSE;
	kbMode = NoKey;
	
	aKeyIt = new QDictIterator<KKeyEntry> ( *aKeyDict );
	
	// TOP LAYOUT MANAGER
	
	// The following layout is used for the dialog
	// 		LIST LABELS LAYOUT
	//		SPLIT LIST BOX WIDGET
	//		CHOOSE KEY GROUP BOX WIDGET
	//		BUTTONS LAYOUT
	// Items are added to topLayout as they are created.
	
	QBoxLayout *topLayout = new QVBoxLayout( this, 0, 10 ); 
	
	// CREATE LIST LABELS
	
	QGridLayout *stackLayout = new QGridLayout( 2, 2, 2);
	topLayout->addLayout( stackLayout, 50 );
	
	stackLayout->setRowStretch(1,10);

	keyLabel = new QLabel(this);
	stackLayout->addWidget(keyLabel, 0, 1);
	keyLabel->setText( i18n("Current key") );
	keyLabel->setFixedHeight( keyLabel->sizeHint().height() );
	
	// CREATE SPLIT LIST BOX
	
	// Copy all currentKeyCodes to configKeyCodes
	// and fill up the split list box with the action/key pairs.
	
	wList = new KSplitList( this );
	stackLayout->addMultiCellWidget( wList, 1, 1, 0, 1 );
	
	actLabel = new QLabel( wList, i18n("&Action"), this );
	stackLayout->addWidget( actLabel, 0, 0 );
	actLabel->setFixedHeight( actLabel->sizeHint().height() );
	
	wList->setAutoUpdate(FALSE);
	wList->setFocus();
	
	aIt = aKeyIt;
	aIt->toFirst();
	while ( aIt->current() ) {
		aIt->current()->aConfigKeyCode = aIt->current()->aCurrentKeyCode;
		
		KSplitListItem *sli = new KSplitListItem(
		 	item( aIt->current()->aConfigKeyCode, aIt->currentKey() )
		);
		
		connect( wList, SIGNAL( newWidth( int ) ),
				 sli, SLOT( setWidth( int ) ) );
		wList->insertItem( sli );
		
		++ ( *aIt );
	}

	if ( wList->count() == 0 ) wList->setEnabled( FALSE );
	//connect( wList, SIGNAL( selected( int ) ), SLOT( toChange( int ) ) );
	connect( wList, SIGNAL( highlighted( int ) ), SLOT( updateAction( int ) ) );
	
	// CREATE CHOOSE KEY GROUP
	
	fCArea = new QGroupBox( this );
	topLayout->addWidget( fCArea, 1 );
	
	fCArea->setTitle( i18n("Choose a key for the selected action") );
	fCArea->setFrameStyle( QFrame::Box | QFrame::Sunken );
	
	// CHOOSE KEY GROUP LAYOUT MANAGER
	
	QGridLayout *grid = new QGridLayout( fCArea, 6, 4, 5 );
	
	grid->setRowStretch(0,10);
	grid->setRowStretch(1,10);
	grid->setRowStretch(2,10);
	grid->setRowStretch(3,10);
	grid->setRowStretch(4,10);
	grid->setRowStretch(5,10);

	grid->setColStretch(0,0);
	grid->setColStretch(1,10);
	grid->setColStretch(2,90);
	grid->setColStretch(3,0);
	
	grid->addRowSpacing(0,15);
	grid->addRowSpacing(5,1);
	
	
	kbGroup = new QButtonGroup( fCArea );
    kbGroup->hide();
    kbGroup->setExclusive( true );
	
	QRadioButton *rb = new QRadioButton( i18n("&No key"), fCArea );
    rb->adjustSize();
    rb->setFixedHeight( rb->height() );
    rb->setMinimumWidth( rb->width() );
    kbGroup->insert( rb, NoKey );
	
	grid->addMultiCellWidget( rb, 1, 1, 1, 2 );
	
	rb = new QRadioButton( i18n("&Default key"), fCArea );
    rb->adjustSize();
    rb->setFixedHeight( rb->height() );
    rb->setMinimumWidth( rb->width() );
    kbGroup->insert( rb, DefaultKey );
	
	grid->addMultiCellWidget( rb, 2, 2, 1, 2 );
	
	rb = new QRadioButton( i18n("&Custom key"), fCArea );
    rb->adjustSize();
    rb->setFixedHeight( rb->height() );
    rb->setMinimumWidth( rb->width() );
    kbGroup->insert( rb, CustomKey );
	
	connect( kbGroup, SIGNAL( clicked( int ) ), SLOT( keyMode( int ) ) );
	
	grid->addMultiCellWidget( rb, 3, 3, 1, 2 );
	
	QBoxLayout *pushLayout = new QHBoxLayout( 2 );
	grid->addLayout( pushLayout, 4, 2 );
	
	cShift = new QCheckBox( fCArea );
	cShift->setText( "SHIFT" );
	cShift->setEnabled( FALSE );
	connect( cShift, SIGNAL( clicked() ), SLOT( shiftClicked() ) );
	
	cCtrl = new QCheckBox( fCArea );
	cCtrl->setText( "CTRL" );
	cCtrl->setEnabled( FALSE );
	connect( cCtrl, SIGNAL( clicked() ), SLOT( ctrlClicked() ) );
	
	cAlt = new QCheckBox( fCArea );
	cAlt->setText( "ALT" );
	cAlt->setEnabled( FALSE );
	connect( cAlt, SIGNAL( clicked() ), SLOT( altClicked() ) );
	
	bChange = new KKeyButton("key", fCArea);
	bChange->setEnabled( FALSE );
	connect( bChange, SIGNAL( clicked() ), SLOT( changeKey() ) );
	
	// Set height of checkboxes to basic key button height.
	// Basic key button height = push button height.
	cAlt->adjustSize();
	cAlt->setFixedHeight( bChange->sizeHint().height() );
	cAlt->setMinimumWidth( cAlt->width() );
	cShift->adjustSize();
	cShift->setFixedHeight( bChange->sizeHint().height() );
	cShift->setMinimumWidth( cShift->width() );
	cCtrl->adjustSize();
	cCtrl->setFixedHeight( bChange->sizeHint().height() );
	cCtrl->setMinimumWidth( cCtrl->width() );
	fCArea->setMinimumHeight( bChange->sizeHint().height() + 20 +
		3*rb->height() + 4*10);
	
	// Add widgets to the geometry manager
	
	pushLayout->addWidget( cShift );
	pushLayout->addSpacing( 8 );
	pushLayout->addWidget( cCtrl );
	pushLayout->addSpacing( 8 );
	pushLayout->addWidget( cAlt );
	pushLayout->addSpacing( 18 );
	pushLayout->addWidget( bChange );
	pushLayout->addStretch( 10 );
	
	lNotConfig = new QLabel(fCArea);
	lNotConfig->resize(0,0);
	lNotConfig->setFont( QFont("Helvetica", 14, QFont::Bold) );
	lNotConfig->setAlignment( AlignCenter );
	lNotConfig->setFrameStyle( QFrame::Panel | QFrame::Sunken );
	if ( wList->count()==0 )
		lNotConfig->setText(i18n("No keys defined"));
	else {
		lNotConfig->setText(i18n("Not configurable"));
		lNotConfig->hide();
	}
	lNotConfig->hide();

	lInfo = new QLabel(fCArea);
	resize(0,0);
	lInfo->setAlignment( AlignCenter );
	lInfo->setEnabled( FALSE );
	lInfo->hide();
	
	wList->setAutoUpdate(TRUE);
	wList->update();
	
	globalDict = new QDict<int> ( 37, false );
	globalDict->setAutoDelete( true );
	readGlobalKeys();
	
	topLayout->activate();
}
Пример #3
0
KDMShutdown::KDMShutdown( int mode, QWidget* _parent, const char* _name,
			  const char* _shutdown, 
			  const char* _restart)
     : FDialog( _parent, _name, true)
{
     shutdown = _shutdown;
     restart  = _restart;
     int h = 10, w = 0;
     QFrame* winFrame = new QFrame( this);
     winFrame->setFrameStyle( QFrame::WinPanel | QFrame::Raised);
     QBoxLayout* box = new QBoxLayout( winFrame, QBoxLayout::TopToBottom, 
				       10, 10);
     QString shutdownmsg =  klocale->translate( "Shutdown or restart?");
     if( mode == KDMConfig::RootOnly) {
	  shutdownmsg += '\n';
	  shutdownmsg += klocale->translate( "(Enter Root Password)");
     }
     label = new QLabel( shutdownmsg, winFrame);
     set_fixed( label);
     h += label->height() + 10;
     w = label->width();

     box->addWidget( label, 0, AlignCenter);

     QFrame* sepFrame = new QFrame( this);
     sepFrame->setFrameStyle( QFrame::HLine| QFrame::Sunken);
     h += sepFrame->height(); 
     box->addWidget( sepFrame);

     btGroup = new QButtonGroup( /* this */);
     
     QRadioButton *rb;
     rb = new QRadioButton( winFrame /*btGroup*/);
     rb->setText( klocale->translate("Shutdown"));
     set_min( rb);
     rb->setFocusPolicy( StrongFocus);
     // Default action
     rb->setChecked( true);
     rb->setFocus();
     cur_action = shutdown;
     
     h += rb->height() + 10;
     w = QMAX( rb->width(), w);

     box->addWidget( rb);
     btGroup->insert( rb);
     rb = new QRadioButton( winFrame /*btGroup*/);
     rb->setText( klocale->translate("Shutdown and restart"));
     set_min( rb);
     rb->setFocusPolicy( StrongFocus);
     h += rb->height() + 10;
     w = QMAX( rb->width(), w);

     box->addWidget( rb);
     btGroup->insert( rb);
     rb = new QRadioButton( winFrame /*btGroup*/);
     rb->setText( klocale->translate("Restart X Server"));//better description
     set_min( rb);
     rb->setFocusPolicy( StrongFocus);
     h += rb->height() + 10;
     w = QMAX( rb->width(), w);

     box->addWidget( rb);
     btGroup->insert( rb);

     // Passwd line edit
     if( mode == KDMConfig::RootOnly) {
	  pswdEdit = new QLineEdit( winFrame);
	  //set_min( pswdEdit);
	  pswdEdit->setMinimumHeight( pswdEdit->sizeHint().height());
	  pswdEdit->setEchoMode( QLineEdit::NoEcho);
	  /*QColorGroup   passwdColGroup(
	       QApplication::palette()->normal().foreground(),
	       QApplication::palette()->normal().background(),
	       QApplication::palette()->normal().light(),
	       QApplication::palette()->normal().dark(),
	       QApplication::palette()->normal().mid(),
	       QApplication::palette()->normal().base(),
	       QApplication::palette()->normal().base());
	  QPalette passwdPalette( passwdColGroup, passwdColGroup, 
				  passwdColGroup);
	  pswdEdit->setPalette( passwdPalette);
	  */
	  pswdEdit->setFocusPolicy( StrongFocus);
	  pswdEdit->setFocus();
	  h+= pswdEdit->height() + 10;
	  box->addWidget( pswdEdit);
     }

     QBoxLayout* box3 = new QBoxLayout( QBoxLayout::LeftToRight, 10);
     box->addLayout( box3);

     okButton = new QPushButton( klocale->translate("OK"), winFrame);
     set_min( okButton);
     okButton->setFocusPolicy( StrongFocus);
     cancelButton = new QPushButton( klocale->translate("Cancel"), winFrame);
     set_min( cancelButton);
     //cancelButton->setDefault( true);
     cancelButton->setFocusPolicy( StrongFocus);
     h += cancelButton->height() + 10;
     w = QMAX( (okButton->width() + 10 + cancelButton->width()), w);

     box3->addWidget( okButton);
     box3->addWidget( cancelButton);
     // Connections
     connect( okButton, SIGNAL(clicked()), SLOT(bye_bye()));
     connect( cancelButton, SIGNAL(clicked()), SLOT(reject()));
     connect( btGroup, SIGNAL(clicked(int)), SLOT(rb_clicked(int)));
     if( mode == KDMConfig::RootOnly) {
	  okButton->setEnabled( false);
	  connect( pswdEdit, SIGNAL( returnPressed()), this, SLOT( pw_entered()));
     } else
	  cancelButton->setFocus();
     resize( 20 + w, h);
     winFrame->setGeometry( 0, 0, width(), height());
}