예제 #1
0
CColorDialog::CColorDialog (QWidget * parent, const char *name, F4lmApp * p):
        QWidget (parent, name)
{
        //QColor renk;
        //renk=QColorDialog::getColor(renk,this);
    realp = p;

    Q3VBoxLayout *topLayout = new Q3VBoxLayout (this);

    Q3ButtonGroup *ToolsButtonGroup =new Q3ButtonGroup (this, "ToolsButtonGroup");
    ToolsButtonGroup->setGeometry (QRect (150, 70, 71, 291));
    ToolsButtonGroup->setLineWidth (0);
    ToolsButtonGroup->setTitle (trUtf8 (""));

    QToolButton *ToolButton1 =new QToolButton (ToolsButtonGroup, "ToolButton1");
    ToolButton1->setGeometry (QRect (0, 10, 30, 30));
    ToolButton1->setText (trUtf8 ("CC"));
    connect (ToolButton1, SIGNAL (clicked ()), this,SLOT (slotColorChooser ()));

    QToolButton *ToolButton2 =new QToolButton (ToolsButtonGroup, "ToolButton2");
    ToolButton2->setGeometry (QRect (30, 10, 30, 30));
    ToolButton2->setText (trUtf8 ("..."));

        //CColorSwatches* s=new CColorSwatches(this,"color_swatches",p);
    topLayout->addWidget (ToolsButtonGroup);
        //topLayout->addWidget(s);
}
예제 #2
0
QWidget *Q3ButtonGroupPlugin::createWidget(QWidget *parent)
{
    Q3ButtonGroup *g = new Q3ButtonGroup(parent);
    g->setColumnLayout(0, Qt::Vertical);
    g->setInsideMargin(0);
    g->layout()->setSpacing(-1);
    return g;
}
예제 #3
0
void tst_q3buttongroup::buttonId()
{
    Q3ButtonGroup bg;
    QPushButton *button = new QPushButton("Foo", &bg);
    int id = bg.insert(button, 1);
    QApplication::instance()->processEvents();
    QCOMPARE(id, bg.id(button));
}
예제 #4
0
void tst_q3buttongroup::task198864_insert()
{
#if 0
    Q3ButtonGroup *group = new Q3ButtonGroup;
    QWidget *parent = new QWidget;

    const int id1 = group->insert(new QPushButton(parent));
    QCOMPARE(id1, 0);
    const int id2 = group->insert(new QPushButton(parent));
    QCOMPARE(id2, 1);

    delete parent;
    parent = new QWidget;

    const int id3 = group->insert(new QPushButton(parent));
    QCOMPARE(id3, 0);
#endif

    Q3ButtonGroup *group = new Q3ButtonGroup;

    QPushButton *button1 = new QPushButton;
    const int id1 = group->insert(button1);
    QCOMPARE(id1, 0);

    QPushButton *button2 = new QPushButton;
    const int id2 = group->insert(button2);
    QCOMPARE(id2, 1);

    delete button1;
    delete button2;

    QPushButton *button3 = new QPushButton;
    const int id3 = group->insert(button3);
    QCOMPARE(id3, 0);
}
예제 #5
0
//***********************************************
void Options::set_general()
{

  QWidget *general = new QWidget(this);  
  Q3BoxLayout *all = new Q3VBoxLayout(general,10);

  Q3GroupBox *b1 = new Q3GroupBox(2,Horizontal,"",general);

  QLabel *l = new QLabel("Default resource type",b1);
  l->setText("Default resource type");  //to avoid compilation warning
  
  type = new QComboBox(false,b1,"type");
  type->insertItem( "LOGIC" );
  type->insertItem( "PICTURE" );
  type->insertItem( "VIEW" );
  type->insertItem( "SOUND" );

  QLabel *l2 = new QLabel("Picedit style",b1);
  l2->setText("Picedit style");  //to avoid compilation warning

  picstyle = new QComboBox(false,b1,"picstyle");
  picstyle->insertItem( "One window" );
  picstyle->insertItem( "Two windows" );

  all->addWidget(b1);

  Q3ButtonGroup *extract = new Q3ButtonGroup(2,Horizontal,"Extract logic as",general);
  extract->setMaximumSize(200,100);
  extract->setExclusive(true);
  text = new QRadioButton("Text",extract);
  binary = new QRadioButton("Binary",extract);

  all->addWidget(extract);


  addTab(general,"General");

}
예제 #6
0
BrowserSearchDialog::BrowserSearchDialog()
    : QDialog(0, "Browser search", FALSE, Qt::WDestructiveClose)
{
    the = this;
    setCaption(TR("Browser search"));

    Q3VBoxLayout * vbox = new Q3VBoxLayout(this);

    vbox->setMargin(5);

    Q3GridLayout * gl = new Q3GridLayout(vbox, 4, 2, 5/*space*/);

    gl->addWidget(new QLabel(TR("Kind"), this), 0, 0, Qt::AlignLeft);
    kind = new Q3ComboBox(FALSE, this);

    for (int index = 0; index != sizeof(Kinds) / sizeof(*Kinds); index += 1)
        kind->insertItem(TR(Kinds[index].lbl));

    kind->setCurrentItem(saved_kind);
    gl->addWidget(kind, 0, 1);

    ed = new LineEdit(this);
    ed->setText(saved_ed);
    gl->addWidget(new QLabel(TR("Containing"), this), 1, 0, Qt::AlignLeft);
    gl->addWidget(ed, 1, 1);
    ed->setFocus();

    Q3HBox * hb = new Q3HBox(this);

    gl->addWidget(hb, 2, 1);

    Q3GroupBox * gb = new Q3GroupBox(2, Qt::Horizontal, hb);

    case_sensitive = new QCheckBox(TR("case sensitive"), gb);
    case_sensitive->setChecked(saved_case_sensitive);
    even_deleted = new QCheckBox(TR("even deleted"), gb);
    even_deleted->setChecked(saved_even_deleted);

    Q3ButtonGroup * bg = new Q3ButtonGroup(4, Qt::Horizontal, hb);

    bg->setExclusive(TRUE);
    for_name = new QRadioButton(TR("name"), bg);
    for_name->setChecked(saved_name);
    for_stereotype = new QRadioButton(TR("stereotype"), bg);
    for_stereotype->setChecked(saved_stereotype);
    for_comment = new QRadioButton(TR("description"), bg);
    for_comment->setChecked(saved_comment);
    for_decldefbody = new QRadioButton(TR("declaration/definition/body"), bg);
    for_decldefbody->setChecked(saved_decldefbody);

    gl->addWidget(new QLabel(TR("Result"), this), 3, 0, Qt::AlignLeft);
    results = new Q3ComboBox(FALSE, this);
    gl->addWidget(results, 3, 1);

    Q3HBoxLayout * hbox = new Q3HBoxLayout(vbox);
    QPushButton * search_b = new QPushButton(TR("Search"), this);
    QPushButton * close_b = new QPushButton(TR("Close"), this);

    hbox->setMargin(5);
    hbox->addWidget(search_b);
    hbox->addWidget(select_b = new QPushButton(TR("Select"), this));
    hbox->addWidget(mark_unmark_b = new QPushButton(TR("Unmark"), this));
    hbox->addWidget(mark_them_b = new QPushButton(TR("Mark them"), this));
    hbox->addWidget(unmark_all_b = new QPushButton(TR("Unmark all"), this));
    hbox->addWidget(close_b);

    search_b->setDefault(TRUE);

    connect(search_b, SIGNAL(clicked()), this, SLOT(search()));
    connect(select_b, SIGNAL(clicked()), this, SLOT(select()));
    connect(close_b, SIGNAL(clicked()), this, SLOT(reject()));
    connect(mark_unmark_b, SIGNAL(clicked()), this, SLOT(mark_unmark()));
    connect(mark_them_b, SIGNAL(clicked()), this, SLOT(mark_them()));
    connect(unmark_all_b, SIGNAL(clicked()), this, SLOT(unmark_all()));
    connect(results, SIGNAL(activated(int)), this, SLOT(selected(int)));

    if ((saved_kind != 0) || !saved_ed.isEmpty())
        search();
    else
        selected(-1);

    open_dialog(this);
}
예제 #7
0
AttributeDialog::AttributeDialog(AttributeData * a, bool new_st_attr)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose),
      new_in_st(new_st_attr), att(a) {
  a->browser_node->edit_start();
  
  if (a->browser_node->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }
  
  visit = !hasOkButton();
  ClassData * cld = (ClassData *) 
    ((BrowserNode *) a->browser_node->parent())->get_data();
  QString stereotype = cld->get_stereotype();
  QString lang_st;
  
  in_enum = (stereotype == "enum");
  
  lang_st = GenerationSettings::cpp_class_stereotype(stereotype);
  cpp_in_enum = in_enum || (lang_st == "enum");
  cpp_ignored = !cpp_in_enum && ((lang_st == "typedef") || (lang_st == "ignored"));
  
  lang_st = GenerationSettings::java_class_stereotype(stereotype);
  java_in_enum = in_enum || (lang_st == "enum");
  java_in_enum_pattern = !java_in_enum && (lang_st == "enum_pattern");
  java_ignored = (lang_st == "ignored");
  
  lang_st = GenerationSettings::php_class_stereotype(stereotype);
  php_in_enum = in_enum || (lang_st == "enum");
  php_ignored = !php_in_enum && (lang_st == "ignored");
  
  lang_st = GenerationSettings::python_class_stereotype(stereotype);
  python_in_enum = in_enum || (lang_st == "enum");
  python_ignored = !python_in_enum && (lang_st == "ignored");
  
  lang_st = GenerationSettings::idl_class_stereotype(stereotype);
  idl_in_enum = in_enum || (lang_st == "enum");
  idl_in_typedef = !idl_in_enum && (lang_st == "typedef");
  idl_in_struct = !idl_in_enum && ((lang_st == "struct") || (lang_st == "exception"));
  idl_in_union = !idl_in_enum && (lang_st == "union");
  
  setCaption((in_enum || java_in_enum_pattern) ? TR("Enum item dialog") : TR("Attribute dialog"));
  
  Q3Grid * grid;
  Q3HBox * htab;
  QString s;
    
  // general tab
  
  grid = new Q3Grid(2, this);
  umltab = grid;
  grid->setMargin(5);
  grid->setSpacing(5);
  
  new QLabel(TR("class : "), grid);
  new QLabel(((BrowserNode *) a->get_browser_node()->parent())->full_name(TRUE),
	     grid);
  
  new QLabel(TR("name :"), grid);
  edname = new LineEdit(a->name(), grid);
  edname->setReadOnly(visit);

  QFont font = edname->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  
  if (!java_in_enum_pattern) {
    new QLabel(TR("stereotype :"), grid);
    htab = new Q3HBox(grid);
    edstereotype = new Q3ComboBox(!visit, htab);
    edstereotype->insertItem(toUnicode(a->get_stereotype()));
    if (!visit) {
      edstereotype->insertStringList(BrowserAttribute::default_stereotypes());
      edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlAttribute));
      if (java_in_enum) {
	int n = edstereotype->count();
	
	for (attribute_st_rank = 0; attribute_st_rank != n; attribute_st_rank += 1)
	  if (edstereotype->text(attribute_st_rank) == "attribute")
	    break;
	     
	if (attribute_st_rank == n) {
	  edstereotype->insertItem("attribute");
	  n += 1;
	}
	
	for (empty_st_rank = 0; empty_st_rank != n; empty_st_rank += 1)
	  if (edstereotype->text(empty_st_rank).isEmpty())
	    break;
	     
	if (empty_st_rank == n)
	  edstereotype->insertItem("");
      }
      edstereotype->setAutoCompletion(completion());
    }
    edstereotype->setCurrentItem(0);
    
    QSizePolicy sp = edstereotype->sizePolicy();
    
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);
    
    new QLabel(TR("    multiplicity :  "), htab);
    multiplicity = new Q3ComboBox(!visit, htab);
    multiplicity->setSizePolicy(sp);
    previous_multiplicity = a->get_multiplicity();
    multiplicity->insertItem(previous_multiplicity);
    if (!visit) {
      multiplicity->insertItem("1");
      multiplicity->insertItem("0..1");
      multiplicity->insertItem("*");
      multiplicity->insertItem("1..*");
    }
    
    connect(new SmallPushButton(TR("type :"), grid), SIGNAL(clicked()),
	    this, SLOT(menu_type()));    
    edtype = new Q3ComboBox(!visit, grid);
    edtype->insertItem(a->get_type().get_full_type());
    BrowserClass::instances(nodes);
    nodes.full_names(list);        
    if (!visit) {
      QStringList l = GenerationSettings::basic_types();
      
      cld->addFormals(l);
      edtype->insertStringList(l);
      offset = edtype->count();
      edtype->insertStringList(list);
      edtype->setAutoCompletion(completion());
      view = a->browser_node->container(UmlClass);
    }
    edtype->setCurrentItem(0);
    edtype->setSizePolicy(sp);

    new QLabel(TR("initial value :"), grid);
  }
  else {
    multiplicity = 0;
    new QLabel(TR("value :"), grid);
  }
  
  htab = new Q3HBox(grid);
  edinit = new LineEdit(a->get_init_value(), htab);
  if (visit)
    edinit->setReadOnly(TRUE);
  else
    connect(new SmallPushButton(TR("Editor"), htab), SIGNAL(clicked()),
	    this, SLOT(edit_init()));

  Q3ButtonGroup * bg;
  
  if (!java_in_enum_pattern) {  
    new QLabel(grid);
    
    htab = new Q3HBox(grid);
    bg = uml_visibility.init(htab, a->get_uml_visibility(), TRUE);
    if (visit)
      bg->setEnabled(FALSE);
    
    bg = new Q3ButtonGroup(7, Qt::Horizontal, QString::null, htab);
    bg->setExclusive(FALSE);
    classattribute_cb = new QCheckBox("static", bg);
    if (a->get_isa_class_attribute())
      classattribute_cb->setChecked(TRUE);
    classattribute_cb->setDisabled(visit);
    
    volatile_cb = new QCheckBox("volatile", bg);
    if (a->isa_volatile_attribute)
      volatile_cb->setChecked(TRUE);
    volatile_cb->setDisabled(visit);
    
    constattribute_cb = new QCheckBox(TR("read-only"), bg);
    if (a->get_isa_const_attribute())
      constattribute_cb->setChecked(TRUE);
    constattribute_cb->setDisabled(visit);
    
    derived_cb = new QCheckBox(TR("derived"), bg);
    if (a->get_is_derived())
      derived_cb->setChecked(TRUE);
    derived_cb->setDisabled(visit);
    connect(derived_cb, SIGNAL(toggled(bool)), SLOT(derived_changed(bool)));
    
    derivedunion_cb = new QCheckBox("union", bg);
    if (a->get_is_derivedunion())
      derivedunion_cb->setChecked(TRUE);
    derivedunion_cb->setDisabled(visit || !derived_cb->isChecked());
    
    ordered_cb = new QCheckBox(TR("ordered"), bg);
    if (a->get_is_ordered())
      ordered_cb->setChecked(TRUE);
    ordered_cb->setDisabled(visit);
    
    unique_cb = new QCheckBox("unique", bg);
    if (a->get_is_unique())
      unique_cb->setChecked(TRUE);
    unique_cb->setDisabled(visit);
  }
  
  Q3VBox * vtab = new Q3VBox(grid);
  
  new QLabel(TR("description :"), vtab);
  if (! visit) {
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
    connect(new SmallPushButton(TR("Default"), vtab), SIGNAL(clicked()),
	    this, SLOT(default_description()));
  }
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(a->browser_node->get_comment());
  comment->setFont(font);
  
  vtab = new Q3VBox(grid);
  new QLabel(TR("constraint :"), vtab);
  if (! visit) {
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_constraint()));
  }
  constraint = new MultiLineEdit(grid);
  constraint->setReadOnly(visit);
  constraint->setText(a->constraint);
  constraint->setFont(font);
  
  addTab(grid, "Uml");
  
  // C++
  
  if (! cpp_ignored) {
    grid = new Q3Grid(2, this);
    cpptab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);
    
    if (!cpp_in_enum) {  
      new QLabel(TR("Visibility :"), grid);
      htab = new Q3HBox(grid);
      
      Q3ButtonGroup * bg =
	cpp_visibility.init(htab, a->get_cpp_visibility(), FALSE, 0, TR("follow uml"));
      
      if (visit)
	bg->setEnabled(FALSE);
      
      new QLabel(" ", htab);
      
      mutable_cb = new QCheckBox("mutable", htab);
      if (a->cpp_mutable)
	mutable_cb->setChecked(TRUE);
      if (visit)
	mutable_cb->setDisabled(TRUE);
      else
	connect(mutable_cb, SIGNAL(toggled(bool)), this, SLOT(cpp_update()));
    }
예제 #8
0
파일: PinDialog.cpp 프로젝트: SciBoy/douml
PinDialog::PinDialog(PinData * pi)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), pin(pi) {
  pi->browser_node->edit_start();
  
  if (pi->browser_node->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }

  visit = !hasOkButton();
  setCaption(TR("Pin dialog"));
  
  Q3Grid * grid;
  Q3HBox * htab;
  QString s;
    
  // general tab
  
  grid = new Q3Grid(2, this);
  umltab = grid;
  grid->setMargin(5);
  grid->setSpacing(5);
  
  new QLabel(TR("name :"), grid);
  edname = new LineEdit(pi->name(), grid);
  edname->setReadOnly(visit);

  QFont font = edname->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  
  new QLabel(TR("stereotype : "), grid);
  edstereotype = new Q3ComboBox(!visit, grid);
  edstereotype->insertItem(toUnicode(pi->stereotype));
  if (! visit) {
    edstereotype->insertStringList(BrowserPin::default_stereotypes());
    edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlActivityPin));
    edstereotype->setAutoCompletion(completion());
  }
  edstereotype->setCurrentItem(0);
  
  QSizePolicy sp = edstereotype->sizePolicy();
  
  sp.setHorData(QSizePolicy::Expanding);
  edstereotype->setSizePolicy(sp);
    
  connect(new SmallPushButton(TR("type :"), grid), SIGNAL(clicked()),
	  this, SLOT(menu_type()));
  
  edtype = new Q3ComboBox(!visit, grid);
  edtype->insertItem(pi->get_type().get_full_type());
  if (!visit) {
    BrowserClass::instances(nodes);
    nodes.full_names(list);
    
    edtype->insertStringList(GenerationSettings::basic_types());
    offset = edtype->count();
    edtype->insertStringList(list);
    edtype->setAutoCompletion(completion());
    view = pi->browser_node->container(UmlClass);
  }
  edtype->setCurrentItem(0);
  edtype->setSizePolicy(sp);
  
  new QLabel(TR("direction :"), grid);
  htab = new Q3HBox(grid);
  eddir = new Q3ComboBox(FALSE, htab);
  
  UmlParamDirection dir = pi->get_dir();
  
  eddir->insertItem(stringify(dir));
  if (! visit) {
    // note : inout not allowed
    if (dir != UmlIn)
      eddir->insertItem(stringify(UmlIn));
    if (dir != UmlOut)
      eddir->insertItem(stringify(UmlOut));
    if (dir != UmlReturn)
      eddir->insertItem(stringify(UmlReturn));
  }
  
  new QLabel(TR("   multiplicity : "), htab);
  edmultiplicity = new Q3ComboBox(!visit, htab);
  edmultiplicity->setSizePolicy(sp);
  edmultiplicity->insertItem(pi->get_multiplicity());
  if (!visit) {
    edmultiplicity->insertItem("1");
    edmultiplicity->insertItem("0..1");
    edmultiplicity->insertItem("*");
    edmultiplicity->insertItem("1..*");
  }
  
  new QLabel(TR("   ordering : "), htab);
  edordering = new Q3ComboBox(FALSE, htab);
  
  UmlOrderingKind o = pi->get_ordering();
  
  edordering->insertItem(stringify(o));
  if (!visit) {
    if (o != UmlUnordered)
      edordering->insertItem(stringify(UmlUnordered));
    if (o != UmlOrdered)
      edordering->insertItem(stringify(UmlOrdered));
    if (o != UmlLifo)
      edordering->insertItem(stringify(UmlLifo));
    if (o != UmlFifo)
      edordering->insertItem(stringify(UmlFifo));
  }
    
  new QLabel(TR("   effect : "), htab);
  edeffect = new Q3ComboBox(FALSE, htab);
  
  UmlParamEffect e = pi->get_effect();
  
  edeffect->insertItem(stringify(e));
  if (!visit) {
    if (e != UmlNoEffect)
      edeffect->insertItem(stringify(UmlNoEffect));
    if (e != UmlCreate)
      edeffect->insertItem(stringify(UmlCreate));
    if (e != UmlRead)
      edeffect->insertItem(stringify(UmlRead));
    if (e != UmlUpdate)
      edeffect->insertItem(stringify(UmlUpdate));
    if (e != UmlDelete)
      edeffect->insertItem(stringify(UmlDelete));
  }
    
  new QLabel(TR("in state : "), grid);
  edin_state = new LineEdit(pi->in_state, grid);
  edin_state->setReadOnly(visit);
       
  new QLabel(grid);
  htab = new Q3HBox(grid);
  Q3ButtonGroup * bg = 
    new Q3ButtonGroup(2, Qt::Horizontal, QString::null, htab);
  
  is_control_cb = new QCheckBox(TR("is_control"), bg);
  if (pi->is_control)
    is_control_cb->setChecked(TRUE);
  is_control_cb->setDisabled(visit);
  
  unique_cb = new QCheckBox(TR("unique"), bg);
  if (pi->unique)
    unique_cb->setChecked(TRUE);
  unique_cb->setDisabled(visit);
  
  bg = 
    new Q3ButtonGroup(3, Qt::Horizontal, QString::null, htab);
  bg->setExclusive(TRUE);
  
  standard_rb = new QRadioButton(TR("standard"), bg);
  exception_rb = new QRadioButton(TR("exception"), bg);
  stream_rb = new QRadioButton(TR("stream"), bg);
  
  if (pi->exception)
    exception_rb->setChecked(TRUE);
  else if (pi->stream)
    stream_rb->setChecked(TRUE);
  else
    standard_rb->setChecked(TRUE);
  
  Q3VBox * vtab = new Q3VBox(grid);
  new QLabel(TR("description :"), vtab);
  if (! visit) {
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
  }
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(pi->browser_node->get_comment());
  comment->setFont(font);
  
  addTab(grid, "Uml");
  
  init_tab(ocltab, eduml_selection, pin->uml_selection, "Ocl",
	   SLOT(edit_uml_selection()), TRUE);

  // C++
  init_tab(cpptab, edcpp_selection, pin->cpp_selection, "C++",
	   SLOT(edit_cpp_selection()),
	   GenerationSettings::cpp_get_default_defs());

  // Java
  init_tab(javatab, edjava_selection, pin->java_selection, "Java",
	   SLOT(edit_java_selection()),
	   GenerationSettings::java_get_default_defs());
  
  // USER : list key - value
  
  grid = new Q3Grid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);
  
  kvtable = new KeyValuesTable(pi->browser_node, grid, visit);
  addTab(grid, TR("Properties"));
  
  //
    
  connect(this, SIGNAL(currentChanged(QWidget *)),
	  this, SLOT(change_tabs(QWidget *)));
  
  open_dialog(this);
}
예제 #9
0
void GPConfigDlg::appendWidget(QWidget* parent, CameraWidget* widget)
{
    QWidget* newParent = parent;

    CameraWidgetType widget_type;
    const char* widget_name;
    const char* widget_info;
    const char* widget_label;
    float widget_value_float;
    int widget_value_int;
    const char* widget_value_string;
    gp_widget_get_type(widget, &widget_type);
    gp_widget_get_label(widget, &widget_label);
    gp_widget_get_info(widget, &widget_info);
    gp_widget_get_name(widget, &widget_name);

    // gphoto2 doesn't seem to have any standard for i18n
    QString whats_this = QString::fromLocal8Bit(widget_info);

    // Add this widget to parent
    switch (widget_type)
    {
        case GP_WIDGET_WINDOW:
        {
            setCaption(widget_label);

            break;
        }

        case GP_WIDGET_SECTION:
        {
            if (!d->tabWidget)
            {
                d->tabWidget = new QTabWidget(parent);
                parent->layout()->addWidget(d->tabWidget);
            }

            QWidget* tab = new QWidget(d->tabWidget);
            // widgets are to be aligned vertically in the tab
            QVBoxLayout* tabLayout = new QVBoxLayout(tab, marginHint(),
                                                     spacingHint());
            d->tabWidget->insertTab(tab, widget_label);
            KVBox* tabContainer = new KVBox(tab);
            tabContainer->setSpacing(spacingHint());
            tabLayout->addWidget(tabContainer);
            newParent = tabContainer;

            tabLayout->addStretch();

            break;
        }

        case GP_WIDGET_TEXT:
        {
            gp_widget_get_value(widget, &widget_value_string);

            Q3Grid* grid = new Q3Grid(2, Qt::Horizontal, parent);
            parent->layout()->addWidget(grid);
            grid->setSpacing(spacingHint());
            new QLabel(QString::fromLocal8Bit(widget_label) + ':', grid);
            QLineEdit* lineEdit = new QLineEdit(widget_value_string, grid);
            d->wmap.insert(widget, lineEdit);

            if (!whats_this.isEmpty())
            {
                grid->setWhatsThis(whats_this);
            }

            break;
        }

        case GP_WIDGET_RANGE:
        {
            float widget_low;
            float widget_high;
            float widget_increment;
            gp_widget_get_range(widget, &widget_low, &widget_high, &widget_increment);
            gp_widget_get_value(widget, &widget_value_float);

            Q3GroupBox* groupBox = new Q3GroupBox(1, Qt::Horizontal, widget_label, parent);
            parent->layout()->addWidget(groupBox);
            QSlider* slider = new QSlider(
                (int)widget_low,
                (int)widget_high,
                (int)widget_increment,
                (int)widget_value_float,
                Qt::Horizontal,
                groupBox);
            d->wmap.insert(widget, slider);

            if (!whats_this.isEmpty())
            {
                groupBox->setWhatsThis(whats_this);
            }

            break;
        }

        case GP_WIDGET_TOGGLE:
        {
            gp_widget_get_value(widget, &widget_value_int);

            QCheckBox* checkBox = new QCheckBox(widget_label, parent);
            parent->layout()->addWidget(checkBox);
            checkBox->setChecked(widget_value_int);
            d->wmap.insert(widget, checkBox);

            if (!whats_this.isEmpty())
            {
                checkBox->setWhatsThis(whats_this);
            }

            break;
        }

        case GP_WIDGET_RADIO:
        {
            gp_widget_get_value(widget, &widget_value_string);

            int count = gp_widget_count_choices(widget);

            // for less than 5 options, align them horizontally
            Q3ButtonGroup* buttonGroup;

            if (count > 4)
            {
                buttonGroup = new Q3VButtonGroup(widget_label, parent);
            }
            else
            {
                buttonGroup = new Q3HButtonGroup(widget_label, parent);
            }

            parent->layout()->addWidget(buttonGroup);

            for (int i = 0; i < count; ++i)
            {
                const char* widget_choice;
                gp_widget_get_choice(widget, i, &widget_choice);

                new QRadioButton(widget_choice, buttonGroup);

                if (!strcmp(widget_value_string, widget_choice))
                {
                    buttonGroup->setButton(i);
                }
            }

            d->wmap.insert(widget, buttonGroup);

            if (!whats_this.isEmpty())
            {
                buttonGroup->setWhatsThis(whats_this);
            }

            break;
        }

        case GP_WIDGET_MENU:
        {
            gp_widget_get_value(widget, &widget_value_string);

            QComboBox* comboBox = new KComboBox(parent);
            parent->layout()->addWidget(comboBox);
            comboBox->clear();

            for (int i = 0; i < gp_widget_count_choices(widget); ++i)
            {
                const char* widget_choice;
                gp_widget_get_choice(widget, i, &widget_choice);

                comboBox->insertItem(widget_choice);

                if (!strcmp(widget_value_string, widget_choice))
                {
                    comboBox->setCurrentItem(i);
                }
            }

            d->wmap.insert(widget, comboBox);

            if (!whats_this.isEmpty())
            {
                comboBox->setWhatsThis(whats_this);
            }

            break;
        }

        case GP_WIDGET_BUTTON:
        {
            // TODO
            // I can't see a way of implementing this. Since there is
            // no way of telling which button sent you a signal, we
            // can't map to the appropriate widget->callback
            QLabel* label = new QLabel(i18n("Button (not supported by KControl)"), parent);
            parent->layout()->addWidget(label);

            break;
        }

        case GP_WIDGET_DATE:
        {
            // TODO
            QLabel* label = new QLabel(i18n("Date (not supported by KControl)"), parent);
            parent->layout()->addWidget(label);

            break;
        }

        default:
            return;
    }

    // Append all this widgets children
    for (int i = 0; i < gp_widget_count_children(widget); ++i)
    {
        CameraWidget* widget_child;
        gp_widget_get_child(widget, i, &widget_child);
        appendWidget(newParent, widget_child);
    }

    // Things that must be done after all children were added
    /*
        switch (widget_type) {
        case GP_WIDGET_SECTION:
            {
                tabLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) );
                break;
            }
        }
    */
}
예제 #10
0
void GPConfigDlg::updateWidgetValue(CameraWidget* widget)
{
    CameraWidgetType widget_type;
    gp_widget_get_type(widget, &widget_type);

    switch (widget_type)
    {
        case GP_WIDGET_WINDOW:
            // nothing to do
            break;

        case GP_WIDGET_SECTION:
            // nothing to do
            break;

        case GP_WIDGET_TEXT:
        {
            QLineEdit* lineEdit = static_cast<QLineEdit*>(d->wmap[widget]);
            gp_widget_set_value(widget, (void*)lineEdit->text().toLocal8Bit().data());

            break;
        }

        case GP_WIDGET_RANGE:
        {
            QSlider* slider = static_cast<QSlider*>(d->wmap[widget]);
            float value_float = slider->value();
            gp_widget_set_value(widget, (void*)&value_float);

            break;
        }

        case GP_WIDGET_TOGGLE:
        {
            QCheckBox* checkBox = static_cast<QCheckBox*>(d->wmap[widget]);
            int value_int = checkBox->isChecked() ? 1 : 0;
            gp_widget_set_value(widget, (void*)&value_int);

            break;
        }

        case GP_WIDGET_RADIO:
        {
            Q3ButtonGroup* buttonGroup = static_cast<Q3VButtonGroup*>(d->wmap[widget]);
            gp_widget_set_value(widget, (void*)buttonGroup->selected()->text().toLocal8Bit().data());

            break;
        }

        case GP_WIDGET_MENU:
        {
            QComboBox* comboBox = static_cast<QComboBox*>(d->wmap[widget]);
            gp_widget_set_value(widget, (void*)comboBox->currentText().toLocal8Bit().data());

            break;
        }

        case GP_WIDGET_BUTTON:
            // nothing to do
            break;

        case GP_WIDGET_DATE:
        {
            // not implemented
            break;
        }
    }

    // Copy child widget values
    for (int i = 0; i < gp_widget_count_children(widget); ++i)
    {
        CameraWidget* widget_child;
        gp_widget_get_child(widget, i, &widget_child);
        updateWidgetValue(widget_child);
    }
}
DeviceConfigureDialog::DeviceConfigureDialog( MediaDevice *device )
        : KDialog( Amarok::mainWindow() )
        , m_device( device )
{
    setCaption( i18n("Select Plugin for %1", m_device->name() ) );
    setModal( true );
    setButtons( Ok | Cancel );
    showButtonSeparator( true );

    kapp->setTopWidget( this );
    setCaption( KDialog::makeStandardCaption( i18n( "Configure Media Device" ) ) );
    showButton( KDialog::Apply, false );

    KVBox* vbox = new KVBox( this );
    setMainWidget( vbox );
    vbox->setSpacing( KDialog::spacingHint() );

    QLabel *connectLabel = 0;
    m_connectEdit = 0;
    QLabel *disconnectLabel = 0;
    m_disconnectEdit = 0;
    m_transcodeCheck = 0;
    Q3ButtonGroup *transcodeGroup = 0;
    m_transcodeAlways = 0;
    m_transcodeWhenNecessary = 0;
    m_transcodeRemove = 0;

    if( device )
    {
        device->loadConfig();

        // pre-connect/post-disconnect (mount/umount)
        connectLabel = new QLabel( vbox );
        connectLabel->setText( i18n( "Pre-&connect command:" ) );
        m_connectEdit = new HintLineEdit( device->m_preconnectcmd, vbox );
        m_connectEdit->setHint( i18n( "Example: mount %d" ) );
        connectLabel->setBuddy( m_connectEdit );
        m_connectEdit->setToolTip( i18n( "Set a command to be run before connecting to your device (e.g. a mount command) here.\n%d is replaced by the device node, %m by the mount point.\nEmpty commands are not executed." ) );

        disconnectLabel = new QLabel( vbox );
        disconnectLabel->setText( i18n( "Post-&disconnect command:" ) );
        m_disconnectEdit = new HintLineEdit( device->m_postdisconnectcmd, vbox );
        disconnectLabel->setBuddy( m_disconnectEdit );
        m_disconnectEdit->setHint( i18n( "Example: eject %d" ) );
        m_disconnectEdit->setToolTip( i18n( "Set a command to be run after disconnecting from your device (e.g. an eject command) here.\n%d is replaced by the device node, %m by the mount point.\nEmpty commands are not executed." ) );

        // transcode
        m_transcodeCheck = new QCheckBox( vbox );
        m_transcodeCheck->setText( i18n( "&Transcode before transferring to device" ) );
        m_transcodeCheck->setChecked( device->m_transcode );

        transcodeGroup = new Q3VButtonGroup( vbox );
        QString format = "mp3";
        if( !device->supportedFiletypes().isEmpty() )
            format = device->supportedFiletypes().first();
        transcodeGroup->setTitle( i18n( "Transcode to preferred format (%1) for device", format ) );
        m_transcodeAlways = new QRadioButton( transcodeGroup );
        m_transcodeAlways->setText( i18n( "Whenever possible" ) );
        m_transcodeAlways->setChecked( device->m_transcodeAlways );
        m_transcodeWhenNecessary = new QRadioButton( transcodeGroup );
        m_transcodeWhenNecessary->setText( i18n( "When necessary" ) );
        m_transcodeWhenNecessary->setChecked( !device->m_transcodeAlways );
        connect( m_transcodeCheck, SIGNAL(toggled(bool)),
                transcodeGroup, SLOT(setEnabled(bool)) );
        transcodeGroup->insert( m_transcodeAlways );
        transcodeGroup->insert( m_transcodeWhenNecessary );
        m_transcodeRemove = new QCheckBox( transcodeGroup );
        m_transcodeRemove->setText( i18n( "Remove transcoded files after transfer" ) );
        m_transcodeRemove->setChecked( device->m_transcodeRemove );

        const ScriptManager *sm = ScriptManager::instance();
        m_transcodeCheck->setEnabled( !sm->transcodeScriptRunning().isEmpty() );
        transcodeGroup->setEnabled( !sm->transcodeScriptRunning().isEmpty() && device->m_transcode );
        if( sm->transcodeScriptRunning().isNull() )
        {
            m_transcodeCheck->setToolTip( i18n( "For this feature, a script of type \"Transcode\" has to be running" ) );
            transcodeGroup->setToolTip( i18n( "For this feature, a script of type \"Transcode\" has to be running" ) );
        }

        device->addConfigElements( vbox );
    }

    m_accepted = false;
}
예제 #12
0
void ShortcutsModule::initGUI()
{
	kDebug(125) << "A-----------";
	KActionCollection* actionCollection = m_actionsGeneral;
// see also KShortcutsModule::init() below !!!
	QAction* a = 0L;
#define NOSLOTS
//#define KICKER_ALL_BINDINGS
#include "../../kwin/kwinbindings.cpp"
//#include "../../kicker/kicker/core/kickerbindings.cpp"
//#include "../../kicker/taskbar/taskbarbindings.cpp"
//#include "../../kdesktop/kdesktopbindings.cpp"
#include "../../klipper/klipperbindings.cpp"
#include "../kxkb/kxkbbindings.cpp"

	kDebug(125) << "B-----------";

	kDebug(125) << "C-----------";
	createActionsGeneral();
	kDebug(125) << "D-----------";
	createActionsSequence();
	kDebug(125) << "E-----------";

	kDebug(125) << "F-----------";
	QVBoxLayout* pVLayout = new QVBoxLayout( this );
	pVLayout->addSpacing( KDialog::marginHint() );

	// (o) [Current      ] <Remove>   ( ) New <Save>

	QHBoxLayout *pHLayout = new QHBoxLayout();
	pVLayout->addItem( pHLayout );
	Q3ButtonGroup* pGroup = new Q3ButtonGroup( this );
	pGroup->hide();

	m_prbPre = new QRadioButton( "", this );
	connect( m_prbPre, SIGNAL(clicked()), SLOT(slotSchemeCur()) );
	pGroup->insert( m_prbPre );
	pHLayout->addWidget( m_prbPre );

	m_pcbSchemes = new QComboBox( this );
	m_pcbSchemes->setMinimumWidth( 100 );
	m_pcbSchemes->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
	connect( m_pcbSchemes, SIGNAL(activated(int)), SLOT(slotSelectScheme(int)) );
	pHLayout->addWidget( m_pcbSchemes );

	pHLayout->addSpacing( KDialog::marginHint() );

	m_pbtnRemove = new QPushButton( i18n("&Remove"), this );
	m_pbtnRemove->setEnabled( false );
	connect( m_pbtnRemove, SIGNAL(clicked()), SLOT(slotRemoveScheme()) );
	m_pbtnRemove->setWhatsThis( i18n("Click here to remove the selected key bindings scheme. You cannot"
		" remove the standard system-wide schemes 'Current scheme' and 'KDE default'.") );
	pHLayout->addWidget( m_pbtnRemove );

	pHLayout->addSpacing( KDialog::marginHint() * 3 );

	m_prbNew = new QRadioButton( i18n("New scheme"), this );
	m_prbNew->setEnabled( false );
	pGroup->insert( m_prbNew );
	pHLayout->addWidget( m_prbNew );

	m_pbtnSave = new QPushButton( i18n("&Save..."), this );
	m_pbtnSave->setEnabled( false );
	m_pbtnSave->setWhatsThis( i18n("Click here to add a new key bindings scheme. You will be prompted for a name.") );
	connect( m_pbtnSave, SIGNAL(clicked()), SLOT(slotSaveSchemeAs()) );
	pHLayout->addWidget( m_pbtnSave );

	pHLayout->addStretch( 1 );

	m_pTab = new QTabWidget( this );
	pVLayout->addWidget( m_pTab );

	m_listGeneral = new KActionCollection( this );
	//m_listGeneral->addActions(m_actionsGeneral);
	m_pseGeneral = new KShortcutsEditor( m_listGeneral, this, false );
	m_pTab->addTab( m_pseGeneral, i18n("&Global Shortcuts") );
	//connect( m_pseGeneral, SIGNAL(keyChange()), SLOT(slotKeyChange()) );

	m_listSequence = new KActionCollection( this );
	m_pseSequence = new KShortcutsEditor( m_listSequence, this, false );
	m_pTab->addTab( m_pseSequence, i18n("Shortcut Se&quences") );
	//connect( m_pseSequence, SIGNAL(keyChange()), SLOT(slotKeyChange()) );

	m_listApplication = new KActionCollection( this );
	m_pseApplication = new KShortcutsEditor( m_listApplication, this, false );
	m_pTab->addTab( m_pseApplication, i18n("App&lication Shortcuts") );
	//connect( m_pseApplication, SIGNAL(keyChange()), SLOT(slotKeyChange()) );

	kDebug(125) << "G-----------";
	readSchemeNames();

	kDebug(125) << "I-----------";
	slotSchemeCur();

	kDebug(125) << "J-----------";
}