Пример #1
0
void
KColorDialog::setDefaultColor( const TQColor& col )
{
    if ( !d->cbDefaultColor )
    {
        //
        // a little space between
        //
        d->l_right->addSpacing(10);

        //
        // and the "default color" checkbox, under all items on the right side
        //
        d->cbDefaultColor = new TQCheckBox( i18n( "Default color" ), mainWidget() );
        d->cbDefaultColor->setChecked(true);

        d->l_right->addWidget( d->cbDefaultColor );

        mainWidget()->setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX ); // cancel setFixedSize()
        d->tl_layout->activate();
        mainWidget()->setMinimumSize( mainWidget()->sizeHint() );
        disableResize();

        connect( d->cbDefaultColor, TQT_SIGNAL( clicked() ), TQT_SLOT( slotDefaultColorClicked() ) );
    }

    d->defaultColor = col;

    slotDefaultColorClicked();
}
Пример #2
0
RestartOrBack::RestartOrBack (QWidget *parent)
	: KDialogBase (parent, "rbDialog", true, 0, KDialogBase::User1 | KDialogBase::User2, KDialogBase::User2, false, i18n("&Restart"), i18n("&Back") )
{
	setPlainCaption( i18n("Finished Execution") );
	setButtonWhatsThis( KDialogBase::User1, i18n("Click here to restart the current logo program.") );
	setButtonWhatsThis( KDialogBase::User2, i18n("Click here to switch back to the edit mode.") );
	QWidget *baseWidget = new QWidget(this);
	setMainWidget(baseWidget);
	baseLayout = new QVBoxLayout(baseWidget);
	
	label = new QLabel(baseWidget);
	label->setText( i18n("Execution was finished without errors.\nWhat do you want to do next?") );
	label->setScaledContents(true);
	baseLayout->addWidget(label);
	disableResize();
}
Пример #3
0
KColorDialog::KColorDialog( TQWidget *parent, const char *name, bool modal )
  :KDialogBase( parent, name, modal, i18n("Select Color"),
		modal ? Ok|Cancel : Close,
		Ok, true )
{
  d = new KColorDialogPrivate;
  d->bRecursion = true;
  d->bColorPicking = false;
#ifdef Q_WS_X11
  d->oldfilter = 0;
#endif
  d->cbDefaultColor = 0L;
  connect( this, TQT_SIGNAL(okClicked(void)),this,TQT_SLOT(slotWriteSettings(void)));
  connect( this, TQT_SIGNAL(closeClicked(void)),this,TQT_SLOT(slotWriteSettings(void)));

  TQLabel *label;

  //
  // Create the top level page and its layout
  //
  TQWidget *page = new TQWidget( this );
  setMainWidget( page );

  TQGridLayout *tl_layout = new TQGridLayout( page, 3, 3, 0, spacingHint() );
  d->tl_layout = tl_layout;
  tl_layout->addColSpacing( 1, spacingHint() * 2 );

  //
  // the more complicated part: the left side
  // add a V-box
  //
  TQVBoxLayout *l_left = new TQVBoxLayout();
  tl_layout->addLayout(l_left, 0, 0);

  //
  // add a H-Box for the XY-Selector and a grid for the
  // entry fields
  //
  TQHBoxLayout *l_ltop = new TQHBoxLayout();
  l_left->addLayout(l_ltop);

  // a little space between
  l_left->addSpacing(10);

  TQGridLayout *l_lbot = new TQGridLayout(3, 6);
  l_left->addLayout(TQT_TQLAYOUT(l_lbot));

  //
  // the palette and value selector go into the H-box
  //
  d->hsSelector = new KHSSelector( page );
  d->hsSelector->setMinimumSize(140, 70);
  l_ltop->addWidget(d->hsSelector, 8);
  connect( d->hsSelector, TQT_SIGNAL( valueChanged( int, int ) ),
	   TQT_SLOT( slotHSChanged( int, int ) ) );

  d->valuePal = new KValueSelector( page );
  d->valuePal->setMinimumSize(26, 70);
  l_ltop->addWidget(d->valuePal, 1);
  connect( d->valuePal, TQT_SIGNAL( valueChanged( int ) ),
	   TQT_SLOT( slotVChanged( int ) ) );


  //
  // add the HSV fields
  //
  label = new TQLabel( i18n("H:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 0, 2);
  d->hedit = new KColorSpinBox( 0, 359, 1, page );
  d->hedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->hedit) ) );
  l_lbot->addWidget(d->hedit, 0, 3);
  connect( d->hedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotHSVChanged() ) );

  label = new TQLabel( i18n("S:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 1, 2);
  d->sedit = new KColorSpinBox( 0, 255, 1, page );
  d->sedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->sedit) ) );
  l_lbot->addWidget(d->sedit, 1, 3);
  connect( d->sedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotHSVChanged() ) );

  label = new TQLabel( i18n("V:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 2, 2);
  d->vedit = new KColorSpinBox( 0, 255, 1, page );
  d->vedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->vedit) ) );
  l_lbot->addWidget(d->vedit, 2, 3);
  connect( d->vedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotHSVChanged() ) );

  //
  // add the RGB fields
  //
  label = new TQLabel( i18n("R:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 0, 4);
  d->redit = new KColorSpinBox( 0, 255, 1, page );
  d->redit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->redit) ) );
  l_lbot->addWidget(d->redit, 0, 5);
  connect( d->redit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotRGBChanged() ) );

  label = new TQLabel( i18n("G:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget( label, 1, 4);
  d->gedit = new KColorSpinBox( 0, 255,1, page );
  d->gedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->gedit) ) );
  l_lbot->addWidget(d->gedit, 1, 5);
  connect( d->gedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotRGBChanged() ) );

  label = new TQLabel( i18n("B:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 2, 4);
  d->bedit = new KColorSpinBox( 0, 255, 1, page );
  d->bedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->bedit) ) );
  l_lbot->addWidget(d->bedit, 2, 5);
  connect( d->bedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotRGBChanged() ) );

  //
  // the entry fields should be wide enough to hold 8888888
  //
  int w = d->hedit->fontMetrics().width("8888888");
  d->hedit->setFixedWidth(w);
  d->sedit->setFixedWidth(w);
  d->vedit->setFixedWidth(w);

  d->redit->setFixedWidth(w);
  d->gedit->setFixedWidth(w);
  d->bedit->setFixedWidth(w);

  //
  // add a layout for the right side
  //
  d->l_right = new TQVBoxLayout;
  tl_layout->addLayout(d->l_right, 0, 2);

  //
  // Add the palette table
  //
  d->table = new KPaletteTable( page );
  d->l_right->addWidget(d->table, 10);

  connect( d->table, TQT_SIGNAL( colorSelected( const TQColor &, const TQString & ) ),
	   TQT_SLOT( slotColorSelected( const TQColor &, const TQString & ) ) );

  connect(
    d->table,
    TQT_SIGNAL( colorDoubleClicked( const TQColor &, const TQString & ) ),
    TQT_SLOT( slotColorDoubleClicked( const TQColor &, const TQString & ) )
  );
  // Store the default value for saving time.
  d->originalPalette = d->table->palette();

  //
  // a little space between
  //
  d->l_right->addSpacing(10);

  TQHBoxLayout *l_hbox = new TQHBoxLayout( d->l_right );

  //
  // The add to custom colors button
  //
  TQPushButton *button = new TQPushButton( page );
  button->setText(i18n("&Add to Custom Colors"));
  l_hbox->addWidget(button, 0, AlignLeft);
  connect( button, TQT_SIGNAL( clicked()), TQT_SLOT( slotAddToCustomColors()));

  //
  // The color picker button
  //
  button = new TQPushButton( page );
  button->setPixmap( BarIcon("colorpicker"));
  l_hbox->addWidget(button, 0, AlignHCenter );
  connect( button, TQT_SIGNAL( clicked()), TQT_SLOT( slotColorPicker()));

  //
  // a little space between
  //
  d->l_right->addSpacing(10);

  //
  // and now the entry fields and the patch (=colored box)
  //
  TQGridLayout *l_grid = new TQGridLayout( d->l_right, 2, 3);

  l_grid->setColStretch(2, 1);

  label = new TQLabel( page );
  label->setText(i18n("Name:"));
  l_grid->addWidget(TQT_TQWIDGET(label), 0, 1, Qt::AlignLeft);

  d->colorName = new TQLabel( page );
  l_grid->addWidget(TQT_TQWIDGET(d->colorName), 0, 2, Qt::AlignLeft);

  label = new TQLabel( page );
  label->setText(i18n("HTML:"));
  l_grid->addWidget(TQT_TQWIDGET(label), 1, 1, Qt::AlignLeft);

  d->htmlName = new KLineEdit( page );
  d->htmlName->setMaxLength( 13 ); // Qt's TQColor allows 12 hexa-digits
  d->htmlName->setText("#FFFFFF"); // But HTML uses only 6, so do not worry about the size
  w = d->htmlName->fontMetrics().width(TQString::fromLatin1("#DDDDDDD"));
  d->htmlName->setFixedWidth(w);
  l_grid->addWidget(TQT_TQWIDGET(d->htmlName), 1, 2, Qt::AlignLeft);

  connect( d->htmlName, TQT_SIGNAL( textChanged(const TQString &) ),
      TQT_SLOT( slotHtmlChanged() ) );

  d->patch = new KColorPatch( page );
  d->patch->setFixedSize(48, 48);
  l_grid->addMultiCellWidget(TQT_TQWIDGET(d->patch), 0, 1, 0, 0, Qt::AlignHCenter | Qt::AlignVCenter);
  connect( d->patch, TQT_SIGNAL( colorChanged( const TQColor&)),
	   TQT_SLOT( setColor( const TQColor&)));

  tl_layout->activate();
  page->setMinimumSize( page->sizeHint() );

  readSettings();
  d->bRecursion = false;
  d->bEditHsv = false;
  d->bEditRgb = false;
  d->bEditHtml = false;

  disableResize();
  KColor col;
  col.setHsv( 0, 0, 255 );
  _setColor( col );

  d->htmlName->installEventFilter(this);
  d->hsSelector->installEventFilter(this);
  d->hsSelector->setAcceptDrops(true);
}