void Q3GroupBoxPrivate::updateFrameWidth() { QRect fr = q->frameRect(); int frameShape = frameStyle & QFrame::Shape_Mask; int frameShadow = frameStyle & QFrame::Shadow_Mask; frameWidth = -1; switch (frameShape) { case QFrame::NoFrame: frameWidth = 0; break; case QFrame::Box: case QFrame::HLine: case QFrame::VLine: switch (frameShadow) { case QFrame::Plain: frameWidth = lineWidth; break; case QFrame::Raised: case QFrame::Sunken: frameWidth = (short)(lineWidth*2 + midLineWidth); break; } break; case QFrame::StyledPanel: updateStyledFrameWidths(); break; case QFrame::WinPanel: frameWidth = 2; break; case QFrame::Panel: switch (frameShadow) { case QFrame::Plain: case QFrame::Raised: case QFrame::Sunken: frameWidth = lineWidth; break; } break; } if (frameWidth == -1) // invalid style frameWidth = 0; q->setFrameRect(fr); }
/*! \reimp */ QAccessible::Relation Q3AccessibleDisplay::relationTo(int child, const QAccessibleInterface *other, int otherChild) const { Relation relation = QAccessibleWidget::relationTo(child, other, otherChild); if (child || otherChild) return relation; QObject *o = other->object(); QLabel *label = qobject_cast<QLabel*>(object()); Q3GroupBox *groupbox = qobject_cast<Q3GroupBox*>(object()); if (label) { if (o == label->buddy()) relation |= Label; } else if (groupbox && !groupbox->title().isEmpty()) { if (groupbox->children().contains(o)) relation |= Label; } return relation; }
/*! \reimp */ int Q3AccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const { *target = 0; if (rel == Labelled) { QObject *targetObject = 0; QLabel *label = qobject_cast<QLabel*>(object()); Q3GroupBox *groupbox = qobject_cast<Q3GroupBox*>(object()); if (label) { if (entry == 1) targetObject = label->buddy(); } else if (groupbox && !groupbox->title().isEmpty()) { rel = Child; } *target = QAccessible::queryAccessibleInterface(targetObject); if (*target) return 0; } return QAccessibleWidget::navigate(rel, entry, target); }
/*! \internal Updates the frame widths from the style. */ void Q3GroupBoxPrivate::updateStyledFrameWidths() { QStyleOptionFrameV2 opt; opt.initFrom(q); QRect cr = q->style()->subElementRect(QStyle::SE_FrameContents, &opt, q); leftFrameWidth = cr.left() - opt.rect.left(); topFrameWidth = cr.top() - opt.rect.top(); rightFrameWidth = opt.rect.right() - cr.right(), bottomFrameWidth = opt.rect.bottom() - cr.bottom(); frameWidth = qMax(qMax(leftFrameWidth, rightFrameWidth), qMax(topFrameWidth, bottomFrameWidth)); }
CTracing::CTracing( QWidget* parent, const char* name ) : QWidget( parent, name, 0 ) { QBoxLayout *playoutTop = new QVBoxLayout( this, 5 ); // Tracing #ifdef QT_V4LAYOUT Q3GroupBox *pgroupbox = new Q3GroupBox( this ); #else QGroupBox *pgroupbox = new QGroupBox( this ); #endif pgroupbox->setFrameStyle( QFrame::Box | QFrame::Raised ); pgroupbox->setTitle( QString("Tracing") ); playoutTop->addWidget( pgroupbox, 5 ); QGridLayout *playoutGrid = new QGridLayout( pgroupbox, 3, 2, 5 ); QLabel *plabel1 = new QLabel( "Enabled", pgroupbox, "plabel1" ); pTracing = new QCheckBox( pgroupbox, "pTracing" ); QLabel *plabel3 = new QLabel( "Force Tracing", pgroupbox, "plabel1" ); pForce = new QCheckBox( pgroupbox, "pForce" ); QLabel *plabel2 = new QLabel( "File", pgroupbox, "plabel2" ); pTraceFile = new CFileSelector( pgroupbox, "pTraceFile" ); playoutGrid->addWidget( plabel1, 1, 0 ); playoutGrid->addWidget( pTracing, 1, 1 ); playoutGrid->addWidget( plabel3, 1, 2 ); playoutGrid->addWidget( pForce, 1, 3 ); playoutGrid->addWidget( plabel2, 2, 0 ); playoutGrid->addWidget( pTraceFile, 2, 1 ); // Connection Pooling #ifdef QT_V4LAYOUT pgroupbox = new Q3GroupBox( this ); #else pgroupbox = new QGroupBox( this ); #endif pgroupbox->setFrameStyle( QFrame::Box | QFrame::Raised ); pgroupbox->setTitle( QString("Connection Pooling") ); playoutTop->addWidget( pgroupbox, 5 ); playoutGrid = new QGridLayout( pgroupbox, 3, 3, 5 ); playoutGrid->setColStretch( 2, 10 ); plabel1 = new QLabel( "Enabled", pgroupbox, "plabel1" ); pPooling = new QCheckBox( pgroupbox, "pPooling" ); playoutGrid->addWidget( plabel1, 1, 0 ); playoutGrid->addWidget( pPooling, 1, 1 ); // Buttons playoutGrid = new QGridLayout( playoutTop, 1, 5, 2 ); QPushButton *pSetDefault = new QPushButton( "De&fault", this ); QPushButton *pApply = new QPushButton( "A&pply", this ); playoutGrid->addWidget( pSetDefault, 1, 1 ); playoutGrid->addWidget( pApply, 1, 3 ); // helpt text QFrame *pframe; pframe = new QFrame( this, "Frame_7" ); pframe->setFrameStyle( QFrame::Box | QFrame::Raised ); playoutTop->addWidget( pframe, 4 ); playoutGrid = new QGridLayout( pframe, 1, 2, 5 ); plabel1 = new QLabel( pframe, "Label_1" ); plabel1->setGeometry( 20, 20, 32, 32 ); plabel1->setPixmap( xpmAdvanced ); plabel1->setMinimumSize( 32, 32 ); // plabel1->setMaximumSize( 32, 32 ); plabel2 = new QLabel( pframe, "Label_2" ); plabel2->setText( "These options are global. As such, they can only be set by the system administrator or someone else with 'root' access. Turn Tracing on to enable logging of calls. Turn Pooling on to enable Driver Pooling options." ); #ifdef QT_V4LAYOUT plabel2->setAlignment( Qt::AlignLeft | Qt::WordBreak ); plabel2->setWordWrap( true ); #else plabel2->setAlignment( AlignLeft | WordBreak ); #endif playoutGrid->addWidget( plabel1, 0, 0 ); playoutGrid->addWidget( plabel2, 0, 1 ); playoutGrid->setColStretch( 1, 10 ); // init values char szTracing[10]; char szForce[10]; char szTracingFile[FILENAME_MAX]; char szPooling[10]; char szGUIPlugin[FILENAME_MAX]; SQLGetPrivateProfileString( "ODBC", "Trace", "No", szTracing, sizeof(szTracing), "odbcinst.ini" ); if ( szTracing[0] == '1' || toupper( szTracing[0] ) == 'Y' || ( toupper( szTracing[0] ) == 'O' && toupper( szForce[0] ) == 'N' )) pTracing->setChecked( true ); SQLGetPrivateProfileString( "ODBC", "ForceTrace", "No", szForce, sizeof(szForce), "odbcinst.ini" ); if ( szForce[0] == '1' || toupper( szForce[0] ) == 'Y' || ( toupper( szForce[0] ) == 'O' && toupper( szForce[0] ) == 'N' )) pForce->setChecked( true ); SQLGetPrivateProfileString( "ODBC", "TraceFile", "/tmp/sql.log", szTracingFile, sizeof(szTracingFile)-1, "odbcinst.ini" ); pTraceFile->pLineEdit->setText( szTracingFile ); SQLGetPrivateProfileString( "ODBC", "Pooling", "No", szPooling, sizeof(szPooling), "odbcinst.ini" ); if ( szPooling[0] == '1' || toupper( szPooling[0] ) == 'Y' || ( toupper( szPooling[0] ) == 'O' && toupper( szForce[0] ) == 'N' )) pPooling->setChecked( true ); connect( pSetDefault, SIGNAL(clicked()), SLOT(setDefault()) ); connect( pApply, SIGNAL(clicked()), SLOT(apply()) ); }
QDataDescriptionWidget::QDataDescriptionWidget(QWidget* parent, core::objectmodel::Base* object):QWidget(parent) { QVBoxLayout* tabLayout = new QVBoxLayout( this, 0, 1, QString("tabInfoLayout")); //Instance { Q3GroupBox *box = new Q3GroupBox(this, QString("Instance")); box->setColumns(2); box->setTitle(QString("Instance")); new QLabel(QString("Name"), box); new QLabel(QString(object->getName().c_str()), box); new QLabel(QString("Class"), box); new QLabel(QString(object->getClassName().c_str()), box); std::string namespacename = core::objectmodel::BaseClass::decodeNamespaceName(typeid(*object)); if (!namespacename.empty()) { new QLabel(QString("Namespace"), box); (new QLabel(QString(namespacename.c_str()), box))->setMinimumWidth(20); } if (!object->getTemplateName().empty()) { new QLabel(QString("Template"), box); (new QLabel(QString(object->getTemplateName().c_str()), box))->setMinimumWidth(20); } tabLayout->addWidget( box ); } //Class description core::ObjectFactory::ClassEntry entry = core::ObjectFactory::getInstance()->getEntry(object->getClassName()); if (! entry.creatorMap.empty()) { Q3GroupBox *box = new Q3GroupBox(this, QString("Class")); box->setColumns(2); box->setTitle(QString("Class")); if (!entry.description.empty() && entry.description != std::string("TODO")) { new QLabel(QString("Description"), box); (new QLabel(QString(entry.description.c_str()), box))->setMinimumWidth(20); } core::ObjectFactory::CreatorMap::iterator it = entry.creatorMap.find(object->getTemplateName()); if (it != entry.creatorMap.end() && *it->second->getTarget()) { new QLabel(QString("Provided by"), box); (new QLabel(QString(it->second->getTarget()), box))->setMinimumWidth(20); } if (!entry.authors.empty() && entry.authors != std::string("TODO")) { new QLabel(QString("Authors"), box); (new QLabel(QString(entry.authors.c_str()), box))->setMinimumWidth(20); } if (!entry.license.empty() && entry.license != std::string("TODO")) { new QLabel(QString("License"), box); (new QLabel(QString(entry.license.c_str()), box))->setMinimumWidth(20); } tabLayout->addWidget( box ); } tabLayout->addStretch(); }
MicroSettingsDlg::MicroSettingsDlg( MicroSettings * microSettings, QWidget *parent, const char *name ) : //KDialog( parent, name, true, i18n("PIC Settings"), KDialog::Ok|KDialog::Apply|KDialog::Cancel, KDialog::Ok, true ) KDialog( parent /*, name, true, i18n("PIC Settings"), KDialog::Ok|KDialog::Apply|KDialog::Cancel, KDialog::Ok, true */ ) { setName(name); setModal(true); setCaption(i18n("PIC Settings")); setButtons(KDialog::Ok | KDialog::Apply | KDialog::Cancel); setDefaultButton(KDialog::Ok); showButtonSeparator(true); m_pMicroSettings = microSettings; m_pNewPinMappingWidget = 0l; m_pNewPinMappingDlg = 0l; m_pWidget = new MicroSettingsWidget(this); QWhatsThis::add( this, i18n("This dialog allows editing of the initial properties of the PIC") ); QWhatsThis::add( m_pWidget->portsGroupBox, i18n("Edit the initial value of the ports here. For each binary number, the order from right-to-left is pins 0 through 7.<br><br>The \"Type (TRIS)\" edit shows the initial input/output state of the ports; 1 represents an input, and 0 an output.<br><br>The \"State (PORT)\" edit shows the initial high/low state of the ports; 1 represents a high, and 0 a low.") ); QWhatsThis::add( m_pWidget->variables, i18n("Edit the initial value of the variables here.<br><br>Note that the value of the variable can only be in the range 0->255. These variables will be initialized before any other code is executed.") ); //BEGIN Initialize initial port settings m_portNames = microSettings->microInfo()->package()->portNames(); m_portTypeEdit.resize( m_portNames.size(), 0 ); m_portStateEdit.resize( m_portNames.size(), 0 ); uint row = 0; QStringList::iterator end = m_portNames.end(); for ( QStringList::iterator it = m_portNames.begin(); it != end; ++it, ++row ) { //BEGIN Get current Type / State text QString portType = QString::number( microSettings->portType(*it), 2 ); QString portState = QString::number( microSettings->portState(*it), 2 ); QString fill; fill.fill( '0', 8-portType.length() ); portType.prepend(fill); fill.fill( '0', 8-portState.length() ); portState.prepend(fill); //END Get current Type / State text Q3GroupBox * groupBox = new Q3GroupBox( *it, m_pWidget->portsGroupBox ); groupBox->setColumnLayout(0, Qt::Vertical ); groupBox->layout()->setSpacing( 6 ); groupBox->layout()->setMargin( 11 ); QGridLayout * groupBoxLayout = new QGridLayout( groupBox->layout() ); groupBoxLayout->setAlignment( Qt::AlignTop ); // TODO: replace this with i18n( "the type", "Type (TRIS register):" ); groupBoxLayout->addWidget( new QLabel( i18n("Type (TRIS register):"), groupBox ), 0, 0 ); groupBoxLayout->addWidget( new QLabel( i18n("State (PORT register):"), groupBox ), 1, 0 ); m_portTypeEdit[row] = new KLineEdit( portType, groupBox ); groupBoxLayout->addWidget( m_portTypeEdit[row], 0, 1 ); m_portStateEdit[row] = new KLineEdit( portState, groupBox ); groupBoxLayout->addWidget( m_portStateEdit[row], 1, 1 ); // (dynamic_cast<QVBoxLayout*>(m_pWidget->portsGroupBox->layout()))->insertWidget( row, groupBox ); (dynamic_cast<QVBoxLayout*>(m_pWidget->portsGroupBox->layout()))->addWidget( groupBox ); } //END Initialize initial port settings //BEGIN Initialize initial variable settings // Hide row headers m_pWidget->variables->setLeftMargin(0); // Make columns as thin as possible m_pWidget->variables->setColumnStretchable( 0, true ); m_pWidget->variables->setColumnStretchable( 1, true ); QStringList variables = microSettings->variableNames(); row = 0; end = variables.end(); for ( QStringList::iterator it = variables.begin(); it != end; ++it ) { VariableInfo *info = microSettings->variableInfo(*it); if (info) { m_pWidget->variables->insertRows( row, 1 ); m_pWidget->variables->setText( row, 0, *it ); m_pWidget->variables->setText( row, 1, info->valueAsString() ); ++row; } } m_pWidget->variables->insertRows( row, 1 ); connect( m_pWidget->variables, SIGNAL(valueChanged(int,int)), this, SLOT(checkAddVariableRow()) ); //END Initialize initial variable settings //BEGIN Initialize pin maps connect( m_pWidget->pinMapAdd, SIGNAL(clicked()), this, SLOT(slotCreatePinMap()) ); connect( m_pWidget->pinMapModify, SIGNAL(clicked()), this, SLOT(slotModifyPinMap()) ); connect( m_pWidget->pinMapRename, SIGNAL(clicked()), this, SLOT(slotRenamePinMap()) ); connect( m_pWidget->pinMapRemove, SIGNAL(clicked()), this, SLOT(slotRemovePinMap()) ); m_pinMappings = microSettings->pinMappings(); m_pWidget->pinMapCombo->insertStringList( m_pinMappings.keys() ); updatePinMapButtons(); //END Initialize pin maps //enableButtonSeparator( false ); showButtonSeparator( false ); setMainWidget(m_pWidget); m_pWidget->adjustSize(); adjustSize(); connect( this, SIGNAL(applyClicked()), this, SLOT(slotSaveStuff()) ); }
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; } } */ }