const ElementLayout * ElementFactory::findLayout(const Element * element) { return findLayout(element->type(), element->typeID()); }
/*! \brief Adjust plot content to its current size. \sa QwtPlot::resizeEvent */ void QwtPlot::updateLayout() { int hDist, vDist; vDist = hDist = d_canvas->frameWidth() + 2; if (d_axisEnabled[xTop]) hDist = qwtMax(hDist, d_scale[xTop]->minBorderDist()); if (d_axisEnabled[xBottom]) hDist = qwtMax(hDist, d_scale[xBottom]->minBorderDist()); if (d_axisEnabled[yLeft]) vDist = qwtMax(vDist, d_scale[yLeft]->minBorderDist()); if (d_axisEnabled[yRight]) vDist = qwtMax(vDist, d_scale[yRight]->minBorderDist()); QwtRect rPlot = this->contentsRect(); rPlot.cutMargin(d_margin, d_margin, d_margin, d_margin); #ifndef QWT_NO_LEGEND if (d_legend->itemCnt() > 0) { switch(d_legendPos) { case Qwt::Top: case Qwt::Bottom: d_legend->setMaxCols( (rPlot.width() - ScrBarWidth) / d_legend->colWidth()); break; case Qwt::Right: case Qwt::Left: default: d_legend->setMaxCols(1); break; } } #endif QRect rTitle, rLegend, rPixmap, rAxis[axisCnt]; findLayout(FALSE, rPlot, hDist, vDist, QwtPlotPrintFilter(), rTitle, rLegend, rAxis, rPixmap); // // resize and show the visible widgets // if (!d_lblTitle->text().isEmpty()) { d_lblTitle->setGeometry(rTitle); if (!d_lblTitle->isVisible()) d_lblTitle->show(); } else d_lblTitle->hide(); for ( int axis = 0; axis < axisCnt; axis++ ) { if (d_axisEnabled[axis]) { if ( axis == yLeft || axis == yRight ) d_scale[axis]->setBorderDist(vDist, vDist); else d_scale[axis]->setBorderDist(hDist, hDist); d_scale[axis]->setGeometry(rAxis[axis]); if (!d_scale[axis]->isVisible()) d_scale[axis]->show(); } else d_scale[axis]->hide(); } #ifndef QWT_NO_LEGEND if (d_legend->itemCnt() > 0) { d_legend->setGeometry(rLegend); d_legend->show(); } else d_legend->hide(); #endif d_canvas->setGeometry(rPixmap); }
void KeyboardPage::init() { //### Detect current keyboard layout and variant QString currentLayout; QString currentVariant; QProcess process; process.start( "setxkbmap", QStringList() << "-print" ); if ( process.waitForFinished() ) { const QStringList list = QString( process.readAll() ) .split( "\n", QString::SkipEmptyParts ); for ( QString line : list ) { line = line.trimmed(); if ( !line.startsWith( "xkb_symbols" ) ) continue; line = line.remove( "}" ) .remove( "{" ) .remove( ";" ); line = line.mid( line.indexOf( "\"" ) + 1 ); QStringList split = line.split( "+", QString::SkipEmptyParts ); if ( split.size() >= 2 ) { currentLayout = split.at( 1 ); if ( currentLayout.contains( "(" ) ) { int parenthesisIndex = currentLayout.indexOf( "(" ); currentVariant = currentLayout.mid( parenthesisIndex + 1 ) .trimmed(); currentVariant.chop( 1 ); currentLayout = currentLayout .mid( 0, parenthesisIndex ) .trimmed(); } break; } } } //### Models m_models = KeyboardGlobal::getKeyboardModels(); QMapIterator< QString, QString > mi( m_models ); ui->comboBoxModel->blockSignals( true ); while ( mi.hasNext() ) { mi.next(); if ( mi.value() == "pc105" ) m_defaultIndex = ui->comboBoxModel->count(); ui->comboBoxModel->addItem( mi.key() ); } ui->comboBoxModel->blockSignals( false ); // Set to default value pc105 ui->comboBoxModel->setCurrentIndex( m_defaultIndex ); //### Layouts and Variants KeyboardLayoutModel* klm = new KeyboardLayoutModel( this ); ui->listLayout->setModel( klm ); connect( ui->listLayout->selectionModel(), &QItemSelectionModel::currentChanged, this, &KeyboardPage::onListLayoutCurrentItemChanged ); // Block signals ui->listLayout->blockSignals( true ); QPersistentModelIndex currentLayoutItem = findLayout( klm, currentLayout ); if ( !currentLayoutItem.isValid() && ( ( currentLayout == "latin" ) || ( currentLayout == "pc" ) ) ) { currentLayout = "us"; currentLayoutItem = findLayout( klm, currentLayout ); } // Set current layout and variant if ( currentLayoutItem.isValid() ) { ui->listLayout->setCurrentIndex( currentLayoutItem ); updateVariants( currentLayoutItem, currentVariant ); } // Unblock signals ui->listLayout->blockSignals( false ); // Default to the first available layout if none was set // Do this after unblocking signals so we get the default variant handling. if ( !currentLayoutItem.isValid() && klm->rowCount() > 0 ) ui->listLayout->setCurrentIndex( klm->index( 0 ) ); }