bool MouseWheelFocusEventFilter::eventFilter(QObject* object, QEvent* event) { QWidget* parent = qobject_cast<QWidget*>(object); switch (event->type()) { case QEvent::FocusIn: parent->setFocusPolicy(Qt::WheelFocus); event->accept(); return false; case QEvent::FocusOut: parent->setFocusPolicy(Qt::StrongFocus); event->accept(); return false; case QEvent::Wheel: if (parent->focusPolicy() == Qt::WheelFocus) { event->accept(); return false; } else { event->ignore(); return true; } default: return QObject::eventFilter(object, event); } }
void TaskDialog::initNotesTab(QScrollArea *scrollArea) { /* construct */ QWidget* noteDetail = new QWidget(scrollArea); QFormLayout *fl = new QFormLayout; inputNotes = new QTextEdit( ); inputNotes->setLineWrapMode( QTextEdit::WidgetWidth ); QFontMetrics fmTxtNote( inputNotes->font() ); inputNotes->setFixedHeight( fmTxtNote.height() * 5 ); inputNotesQC = new QDLEditClient( inputNotes, "qdlnotes" ); inputNotesQC->setupStandardContextMenu(); comboCategory = new TodoCategorySelector; fl->addRow(tr("Notes"), inputNotes); fl->addRow(tr("Category"), comboCategory); noteDetail->setLayout(fl); /* init */ comboCategory->selectCategories(todo.categories()); inputNotes->setHtml( todo.notes() ); QDL::loadLinks( todo.customField( QDL::CLIENT_DATA_KEY ), QDL::clients( inputNotes ) ); inputNotesQC->verifyLinks(); /* connect - no connections */ scrollArea->setWidget(noteDetail); noteDetail->setFocusPolicy(Qt::NoFocus); }
void GLViewer::setup() { QSurfaceFormat format; format.setVersion(3, 2); format.setProfile(QSurfaceFormat::CoreProfile); format.setDepthBufferSize(16); m_canvas = new Canvas(format); m_canvas->setContinuousRepaint(true, 0); m_canvas->setSwapInterval(Canvas::VerticalSyncronization); m_canvas->setPainter(m_painter); QWidget *widget = QWidget::createWindowContainer(m_canvas); widget->setMinimumSize(1, 1); widget->setAutoFillBackground(false); // Important for overdraw, not occluding the scene. widget->setFocusPolicy(Qt::TabFocus); widget->setParent(this); QHBoxLayout *layout = new QHBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(widget); setLayout(layout); show(); }
MouseWheelFocusEventFilter::~MouseWheelFocusEventFilter() { QWidget* parent = qobject_cast<QWidget*>(QObject::parent()); parent->setFocusPolicy(m_old_focus_policy); parent->removeEventFilter(this); }
QWidget *QgsAttributeTableDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { Q_UNUSED( option ); QgsVectorLayer *vl = layer( index.model() ); if ( !vl ) return nullptr; int fieldIdx = index.model()->data( index, QgsAttributeTableModel::FieldIndexRole ).toInt(); QgsAttributeEditorContext context( masterModel( index.model() )->editorContext(), QgsAttributeEditorContext::Popup ); QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( vl, fieldIdx, nullptr, parent, context ); QWidget *w = eww->widget(); w->setAutoFillBackground( true ); w->setFocusPolicy( Qt::StrongFocus ); // to make sure QMouseEvents are propagated to the editor widget const int fieldOrigin = vl->fields().fieldOrigin( fieldIdx ); bool readOnly = true; if ( fieldOrigin == QgsFields::OriginJoin ) { int srcFieldIndex; const QgsVectorLayerJoinInfo *info = vl->joinBuffer()->joinForFieldIndex( fieldIdx, vl->fields(), srcFieldIndex ); if ( info && info->isEditable() ) readOnly = info->joinLayer()->editFormConfig().readOnly( srcFieldIndex ); } else readOnly = vl->editFormConfig().readOnly( fieldIdx ); eww->setEnabled( !readOnly ); return w; }
int TestWin::setupLayout(void) { // right pannel m_helpMsg = new QTextEdit(this); m_helpMsg->setReadOnly(true); m_helpMsg->setFocusPolicy(Qt::NoFocus); // left pannel QWidget *wLeftPanel = new QWidget(this); QVBoxLayout *vl = new QVBoxLayout(wLeftPanel); wLeftPanel->setLayout(vl); wLeftPanel->setFocusPolicy(Qt::NoFocus); m_ADI = new QADI(this); m_Compass = new QCompass(this); m_infoList = new QKeyValueListView(this); vl->addWidget(m_ADI, 0, Qt::AlignTop|Qt::AlignHCenter); vl->addWidget(m_Compass, 0, Qt::AlignTop|Qt::AlignHCenter); vl->addWidget(m_infoList, 2, 0); vl->setMargin(0); vl->setSpacing(4); // overall layout QHBoxLayout *hl = new QHBoxLayout(this); this->setLayout(hl); hl->addWidget(m_helpMsg, 1); hl->addWidget(wLeftPanel, 0); return 0; }
QmlWindow::QmlWindow(QUrl qmlSource, bool persistent, QWidget *parent) : QWidget(parent) , m_view(0) , m_lastSize(QSize()) , m_exiting(false) , m_persistent(persistent) { QHBoxLayout *layout = new QHBoxLayout(this); layout->setContentsMargins(0,0,0,0); m_view = new QQuickView(); m_view->connect(m_view->engine(), &QQmlEngine::quit, m_view, &QWindow::close); // QQmlApplicationEngine *engine = new QQmlApplicationEngine(qmlSource); QWidget *container = QWidget::createWindowContainer(m_view); container->setMinimumSize(100, 100); container->setMaximumSize(60000, 60000); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); m_view->setSource(qmlSource); m_view->setResizeMode(QQuickView::SizeRootObjectToView); m_view->rootObject()->setProperty("window", QVariant::fromValue(this)); layout->addWidget(container); }
void TaskDialog::initRecurrenceTab(QScrollArea *scrollArea) { /* construct */ QWidget *recurrenceDetail = new QWidget(scrollArea); recurStack = new QStackedLayout; recurControls = new QWidget(); // todoAppt passed in non-const recurDetails = new RecurrenceDetails(todoAppt); QFormLayout *fl = new QFormLayout(); recurDetails->initGui(fl); recurControls->setLayout(fl); QLabel *noRecurLabel = new QLabel(tr("Add a due date to this task to allow recurrence.")); noRecurLabel->setWordWrap(true); noRecurLabel->setFocusPolicy(Qt::StrongFocus); recurStack->addWidget(recurControls); recurStack->addWidget(noRecurLabel); recurrenceDetail->setLayout(recurStack); /* init */ recurStack->setCurrentIndex(todo.hasDueDate() ? 0 : 1); recurDetails->updateUI(); /* connect - no connections */ scrollArea->setWidget(recurrenceDetail); recurrenceDetail->setFocusPolicy(Qt::NoFocus); }
static void qwtSetTabOrder( QWidget *first, QWidget *second, bool withChildren ) { QList<QWidget *> tabChain; tabChain += first; tabChain += second; if ( withChildren ) { QList<QWidget *> children = second->findChildren<QWidget *>(); QWidget *w = second->nextInFocusChain(); while ( children.contains( w ) ) { children.removeAll( w ); tabChain += w; w = w->nextInFocusChain(); } } for ( int i = 0; i < tabChain.size() - 1; i++ ) { QWidget *from = tabChain[i]; QWidget *to = tabChain[i+1]; const Qt::FocusPolicy policy1 = from->focusPolicy(); const Qt::FocusPolicy policy2 = to->focusPolicy(); QWidget *proxy1 = from->focusProxy(); QWidget *proxy2 = to->focusProxy(); from->setFocusPolicy( Qt::TabFocus ); from->setFocusProxy( NULL); to->setFocusPolicy( Qt::TabFocus ); to->setFocusProxy( NULL); QWidget::setTabOrder( from, to ); from->setFocusPolicy( policy1 ); from->setFocusProxy( proxy1); to->setFocusPolicy( policy2 ); to->setFocusProxy( proxy2 ); } }
int LuaMyWidget2::setAcceptFocus(lua_State *L) { QWidget* obj = ObjectHelper<QWidget>::check( L, 1 ); bool b = true; if( lua_gettop(L) > 1 && lua_isboolean( L, 2 ) ) b = lua_toboolean( L, 2 ); obj->setFocusPolicy( (b)?Qt::StrongFocus:Qt::NoFocus ); return 0; }
void TaskDialog::initTaskTab(QScrollArea *scrollArea) { /* construct */ QWidget* taskDetail = new QWidget(scrollArea); QFormLayout *fl = new QFormLayout; inputDescription = new QLineEdit; comboPriority = new QComboBox; comboPriority->addItem(tr("1 - Very High")); comboPriority->addItem(tr("2 - High")); comboPriority->addItem(tr("3 - Normal")); comboPriority->addItem(tr("4 - Low")); comboPriority->addItem(tr("5 - Very Low")); dueCheck = new QGroupBox; dueCheck->setCheckable(true); dueCheck->setTitle(tr("Due:")); QFormLayout *duelayout = new QFormLayout; dueEdit = new QDateEdit; duelayout->addRow(tr("Due:"), dueEdit); reminderPicker = new ReminderPicker(this, duelayout, todoAppt); dueCheck->setLayout(duelayout); fl->addRow(tr("Desc."), inputDescription); fl->addRow(tr("Priority"), comboPriority); fl->addRow(dueCheck); taskDetail->setLayout(fl); /* initialize */ inputDescription->setText(todo.description()); comboPriority->setCurrentIndex( todo.priority() - 1 ); if (todo.dueDate().isValid()) { dueCheck->setChecked(true); dueEdit->setDate(todo.dueDate()); } else { dueCheck->setChecked(false); dueEdit->setDate(QDate::currentDate()); } reminderPicker->updateUI(todo.dueDate().isValid()); /* connect */ connect( dueEdit, SIGNAL(dateChanged(QDate)), this, SLOT(dueDateChanged(QDate)) ); connect( dueCheck, SIGNAL(toggled(bool)), this, SLOT(dueDateChecked(bool)) ); scrollArea->setWidget(taskDetail); taskDetail->setFocusPolicy(Qt::NoFocus); }
QWidget * repo::gui::RepoComboBoxDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const { QWidget *widget = 0; if (index.isValid() && index.column() < factories.size()) { widget = factories[index.column()]->createEditor(index.data(Qt::EditRole).userType(), parent); if (widget) widget->setFocusPolicy(Qt::WheelFocus); } return widget; }
QWidget *QItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const { Q_D(const QItemDelegate); if (!index.isValid()) return 0; const QItemEditorFactory *factory = d->f; if (factory == 0) factory = QItemEditorFactory::defaultFactory(); QWidget *w = factory->createEditor(index.data(Qt::EditRole).userType(), parent); if (w) w->setFocusPolicy(Qt::WheelFocus); return w; }
void Player::setSkin(const QString& skin_name) { QDir dir = QDir(Settings::path); dir.cd("skins"); #ifdef Q_OS_WIN dir.cd(skin_name); #else if (!dir.cd(skin_name)) dir = QDir(QDir::homePath() + "/.lplayer/skins/" + skin_name); #endif // Load skin.qml if (chdir(dir.absolutePath().toUtf8().constData())) { QMessageBox::warning(this, "Error", tr("Failed to read skin!")); exit(EXIT_FAILURE); } QFile qssFile("skin.qss"); if (!qssFile.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::warning(this, "Error", tr("Failed to read skin!")); exit(EXIT_FAILURE); } QString qss = QString::fromUtf8(qssFile.readAll()); qssFile.close(); setStyleSheet(qss); // Set fixed sizes QFile sizeFile("fixed_sizes"); if (sizeFile.open(QFile::ReadOnly | QFile::Text)) { QByteArray data = sizeFile.readAll().simplified().replace(" ", ""); sizeFile.close(); QStringList sizeInfos = QString::fromUtf8(data).split(';', QString::SkipEmptyParts); foreach (QString item, sizeInfos) { QStringList properties = item.split(','); QWidget *widget = findChild<QWidget*>(properties[0]); if (widget) { int w = properties[1].toInt(), h = properties[2].toInt(); if (w) widget->setFixedWidth(w); if (h) widget->setFixedHeight(h); widget->setFocusPolicy(Qt::NoFocus); } }
void Viewer::setupCanvas(const QSurfaceFormat & format) { m_canvas = new Canvas(format); m_canvas->setContinuousRepaint(true, 0); m_canvas->setSwapInterval(Canvas::VerticalSyncronization); connect(m_canvas, &Canvas::fpsUpdate, this, &Viewer::fpsChanged); connect(m_canvas, &Canvas::numCubesUpdate, this, &Viewer::numCubesChanged); QWidget * widget = QWidget::createWindowContainer(m_canvas); widget->setMinimumSize(1, 1); widget->setAutoFillBackground(false); // Important for overdraw, not occluding the scene. widget->setFocusPolicy(Qt::TabFocus); setCentralWidget(widget); show(); }
Holoview::Holoview(const QMap<QString, QSize> &customSizeHints, QWidget *parent, Qt::WindowFlags flags) : MainWindow(customSizeHints, parent, flags) { //ui.setupUi(this); QSurfaceFormat format; format.setSamples(4); window.setFormat(format); window.resize(640, 480); window.setAnimating(true); QWidget *oglContainer = QWidget::createWindowContainer(&window); oglContainer->setMinimumSize(640,480); oglContainer->setMaximumSize(1280,960); oglContainer->setFocusPolicy(Qt::TabFocus); setCentralWidget(oglContainer); }
virtual void notificationEvent(int eventId) { if (eventId == MenuLineEdit::MenuLineConfigurationChangedEvent) { /// load setting limitKeyboardTabStops KSharedConfigPtr config(KSharedConfig::openConfig(QStringLiteral("kbibtexrc"))); static QString const configGroupName = QStringLiteral("User Interface"); KConfigGroup configGroup(config, configGroupName); const bool limitKeyboardTabStops = configGroup.readEntry(MenuLineEdit::keyLimitKeyboardTabStops, false); /// check each widget inside MenuLineEdit for (int i = hLayout->count() - 1; i >= 0; --i) { QWidget *w = hLayout->itemAt(i)->widget(); if (w != NULL && w != m_singleLineEditText && w != m_multiLineEditText) { /// for all widgets except the main editing widget: change tab focus policy w->setFocusPolicy(limitKeyboardTabStops ? Qt::ClickFocus : Qt::StrongFocus); } } } }
NoteeditPart::NoteeditPart(QWidget *parent, const char *name) : KParts::ReadOnlyPart(parent, name) { setInstance(NoteeditFactory::instance()); // create a canvas to insert our widget QWidget *canvas = new QWidget(parent); canvas->setFocusPolicy(QWidget::ClickFocus); setWidget(canvas); m_extension = new NoteeditBrowserExtension(this); nr = new NResource(); NResource::mapper_ = new NMidiMapper(); mainWidget_ = new NMainFrameWidget(actionCollection(), true, canvas); mainWidget_ ->setGeometry(0, 0, KPART_START_WIDTH, KPART_START_HEIGHT); mainWidget_ ->setFocusPolicy(QWidget::ClickFocus); mainWidget_ ->show(); setXMLFile("noteedit_part.rc"); }
void QmlWindow::finalizeView() { QWidget *container = QWidget::createWindowContainer(m_view); container->setMinimumSize(100, 100); container->setMaximumSize(60000, 60000); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); m_view->setSource(m_source); m_view->setResizeMode(QQuickView::SizeRootObjectToView); QVBoxLayout *layout = new QVBoxLayout(this); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); #ifndef Q_OS_MACX layout->addWidget(m_menuBar); #endif layout->addWidget(container); }
QWidget* QgsAttributeTableDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { Q_UNUSED( option ); QgsVectorLayer *vl = layer( index.model() ); if ( !vl ) return nullptr; int fieldIdx = index.model()->data( index, QgsAttributeTableModel::FieldIndexRole ).toInt(); QgsAttributeEditorContext context( masterModel( index.model() )->editorContext(), QgsAttributeEditorContext::Popup ); QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( vl, fieldIdx, nullptr, parent, context ); QWidget* w = eww->widget(); w->setAutoFillBackground( true ); w->setFocusPolicy( Qt::StrongFocus ); // to make sure QMouseEvents are propagated to the editor widget eww->setEnabled( !vl->editFormConfig().readOnly( fieldIdx ) ); return w; }
void BrowserBar::addBrowser( QWidget *widget, const QString &title, const QString& icon ) { const int id = m_tabBar->tabs()->count(); // the next available id const QString name( widget->name() ); QWidget *tab; widget->reparent( m_browserBox, QPoint() ); widget->hide(); m_tabBar->appendTab( SmallIcon( icon ), id, title ); tab = m_tabBar->tab( id ); tab->setFocusPolicy( QWidget::NoFocus ); //FIXME you can focus on the tab, but they respond to no input! //we use a SignalMapper to show/hide the corresponding browser when tabs are clicked connect( tab, SIGNAL(clicked()), m_mapper, SLOT(map()) ); m_mapper->setMapping( tab, id ); connect( tab, SIGNAL(initiateDrag ( int ) ), this, SLOT( showBrowser( int )) ); m_browsers.push_back( widget ); }
void KMdiFocusList::addWidgetTree( QWidget* w ) { //this method should never be called twice on the same hierarchy m_list.insert( w, w->focusPolicy() ); w->setFocusPolicy( QWidget::ClickFocus ); kdDebug( 760 ) << "KMdiFocusList::addWidgetTree: adding toplevel" << endl; connect( w, SIGNAL( destroyed( QObject * ) ), this, SLOT( objectHasBeenDestroyed( QObject* ) ) ); QObjectList *l = w->queryList( "QWidget" ); QObjectListIt it( *l ); QObject *obj; while ( ( obj = it.current() ) != 0 ) { QWidget * wid = ( QWidget* ) obj; m_list.insert( wid, wid->focusPolicy() ); wid->setFocusPolicy( QWidget::ClickFocus ); kdDebug( 760 ) << "KMdiFocusList::addWidgetTree: adding widget" << endl; connect( wid, SIGNAL( destroyed( QObject * ) ), this, SLOT( objectHasBeenDestroyed( QObject* ) ) ); ++it; } delete l; }
QWidget * AMActionRunnerQueueItemDelegate3::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option) const AMActionRunnerQueueModel3* model = qobject_cast<const AMActionRunnerQueueModel3*>(index.model()); if(!model) return 0; AMAction3* action = model->actionAtIndex(index); if(!action) return 0; QWidget* rv = AMActionRegistry3::s()->createEditorForInfo(action->info()); if(rv) { rv->setParent(parent); rv->setFocusPolicy(Qt::StrongFocus); rv->setBackgroundRole(QPalette::Window); rv->setAutoFillBackground(true); } return rv; }
TimelineDock::TimelineDock(QWidget *parent) : QDockWidget(parent), ui(new Ui::TimelineDock), m_quickView(this), m_position(-1) { qDebug() << "begin"; ui->setupUi(this); toggleViewAction()->setIcon(windowIcon()); qmlRegisterType<MultitrackModel>("Shotcut.Models", 1, 0, "MultitrackModel"); QDir importPath = QmlUtilities::qmlDir(); importPath.cd("modules"); m_quickView.engine()->addImportPath(importPath.path()); m_quickView.engine()->addImageProvider(QString("thumbnail"), new ThumbnailProvider); QmlUtilities::setCommonProperties(&m_quickView); m_quickView.rootContext()->setContextProperty("timeline", this); m_quickView.rootContext()->setContextProperty("multitrack", &m_model); m_quickView.setResizeMode(QQuickView::SizeRootObjectToView); m_quickView.setColor(palette().window().color()); connect(&m_model, &MultitrackModel::modified, this, &TimelineDock::clearSelectionIfInvalid); QWidget* container = QWidget::createWindowContainer(&m_quickView, this); container->setFocusPolicy(Qt::TabFocus); delete ui->scrollAreaWidgetContents; ui->scrollArea->setWidget(container); connect(MLT.videoWidget(), SIGNAL(frameDisplayed(const SharedFrame&)), this, SLOT(onShowFrame(const SharedFrame&))); #ifdef Q_OS_WIN onVisibilityChanged(true); #else connect(this, &QDockWidget::visibilityChanged, this, &TimelineDock::onVisibilityChanged); #endif qDebug() << "end"; }
RangeSlider::RangeSlider(QWidget *parent) : QWidget(parent) { rightLabel = new QLabel(); leftLabel = new QLabel(); mainLayout = new QHBoxLayout(); refParent = parent; QQuickView *view = new QQuickView(); QWidget *container = QWidget::createWindowContainer(view, this); container->setMinimumSize(40,40); container->setMaximumSize(400, 50); container->setFocusPolicy(Qt::TabFocus); view->setSource(QUrl("../applicationOpenImu/app/rangeSlider.qml")); // Get pointers to first and second values in range slider QQuickItem *object = view->rootObject(); QObject::connect(object, SIGNAL(firstUpdated(QVariant)),parent, SLOT(firstUpdated(QVariant))); QObject::connect(object, SIGNAL(secondUpdated(QVariant)),parent, SLOT(secondUpdated(QVariant))); mainLayout->addWidget(leftLabel); mainLayout->addWidget(container); mainLayout->addWidget(rightLabel); mainLayout->setSpacing(0); this->setLayout(mainLayout); QSizePolicy spLeft(QSizePolicy::Preferred, QSizePolicy::Preferred); spLeft.setHorizontalStretch(1); leftLabel->setSizePolicy(spLeft); rightLabel->setSizePolicy(spLeft); QSizePolicy spRight(QSizePolicy::Preferred, QSizePolicy::Preferred); spRight.setHorizontalStretch(4); container->setSizePolicy(spRight); }
void KexiDBAutoField::createEditor() { if (subwidget()) { delete(QWidget *)subwidget(); } QWidget *newSubwidget; //kDebug() << "widgetType:" << d->widgetType; switch (d->widgetType) { case Text: case Double: //! @todo setup validator case Integer: //! @todo setup validator case Date: case Time: case DateTime: { KexiDBLineEdit *le = new KexiDBLineEdit(this); newSubwidget = le; le->setFrame(false); break; } case MultiLineText: newSubwidget = new KexiDBTextEdit(this); break; case Boolean: newSubwidget = new KexiDBCheckBox(dataSource(), this); break; case Image: newSubwidget = new KexiDBImageBox(designMode(), this); break; case ComboBox: { KexiDBComboBox *cbox = new KexiDBComboBox(this); newSubwidget = cbox; cbox->setDesignMode(designMode()); break; } default: newSubwidget = 0; changeText(d->caption); break; } //kDebug() << newSubwidget; setSubwidget(newSubwidget); //this will also allow to declare subproperties, see KFormDesigner::WidgetWithSubpropertiesInterface if (newSubwidget) { newSubwidget->setObjectName( QString::fromLatin1("KexiDBAutoField_") + newSubwidget->metaObject()->className()); dynamic_cast<KexiDataItemInterface*>(newSubwidget)->setParentDataItemInterface(this); dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox newSubwidget->setProperty("dataSource", dataSource()); //needed at least by KexiDBImageBox KFormDesigner::DesignTimeDynamicChildWidgetHandler::childWidgetAdded(this); newSubwidget->show(); d->label->setBuddy(newSubwidget); if (d->focusPolicyChanged) {//if focusPolicy is changed at top level, editor inherits it newSubwidget->setFocusPolicy(focusPolicy()); } else {//if focusPolicy is not changed at top level, inherit it from editor QWidget::setFocusPolicy(newSubwidget->focusPolicy()); } setFocusProxy(newSubwidget); //ok? if (parentWidget()) newSubwidget->setPalette(qApp->palette()); copyPropertiesToEditor(); } setLabelPosition(labelPosition()); }
void Inspector::update(Score* s) { if (_inspectorEdit) // if within an inspector-originated edit return; _score = s; bool sameTypes = true; if (!el()) return; for (Element* ee : *el()) { if (((element()->type() != ee->type()) && // different and (!element()->isSystemText() || !ee->isStaffText()) && // neither system text nor (!element()->isStaffText() || !ee->isSystemText()) && // staff text either side and (!element()->isPedalSegment() || !ee->isTextLineSegment()) && // neither pedal nor (!element()->isTextLineSegment()|| !ee->isPedalSegment()) && // text line either side and (!element()->isSlurTieSegment() || !ee->isSlurTieSegment())) || // neither Slur nor Tie either side, or (ee->isNote() && toNote(ee)->chord()->isGrace() != toNote(element())->chord()->isGrace())) // HACK { sameTypes = false; break; } } if (oe != element() || oSameTypes != sameTypes) { delete ie; ie = 0; oe = element(); oSameTypes = sameTypes; if (!element()) ie = new InspectorEmpty(this); else if (!sameTypes) ie = new InspectorGroupElement(this); else { switch(element()->type()) { case ElementType::FBOX: case ElementType::VBOX: ie = new InspectorVBox(this); break; case ElementType::TBOX: ie = new InspectorTBox(this); break; case ElementType::HBOX: ie = new InspectorHBox(this); break; case ElementType::ARTICULATION: ie = new InspectorArticulation(this); break; case ElementType::FERMATA: ie = new InspectorFermata(this); break; case ElementType::SPACER: ie = new InspectorSpacer(this); break; case ElementType::NOTE: ie = new InspectorNote(this); break; case ElementType::ACCIDENTAL: ie = new InspectorAccidental(this); break; case ElementType::REST: ie = new InspectorRest(this); break; case ElementType::CLEF: ie = new InspectorClef(this); break; case ElementType::TIMESIG: ie = new InspectorTimeSig(this); break; case ElementType::KEYSIG: ie = new InspectorKeySig(this); break; case ElementType::TUPLET: ie = new InspectorTuplet(this); break; case ElementType::BEAM: ie = new InspectorBeam(this); break; case ElementType::IMAGE: ie = new InspectorImage(this); break; case ElementType::LASSO: ie = new InspectorLasso(this); break; case ElementType::VOLTA_SEGMENT: ie = new InspectorVolta(this); break; case ElementType::OTTAVA_SEGMENT: ie = new InspectorOttava(this); break; case ElementType::TRILL_SEGMENT: ie = new InspectorTrill(this); break; case ElementType::HAIRPIN_SEGMENT: ie = new InspectorHairpin(this); break; case ElementType::TEXTLINE_SEGMENT: ie = new InspectorTextLine(this); break; case ElementType::PEDAL_SEGMENT: ie = new InspectorPedal(this); break; case ElementType::LET_RING_SEGMENT: ie = new InspectorLetRing(this); break; case ElementType::PALM_MUTE_SEGMENT: ie = new InspectorPalmMute(this); break; case ElementType::SLUR_SEGMENT: case ElementType::TIE_SEGMENT: ie = new InspectorSlurTie(this); break; case ElementType::BAR_LINE: ie = new InspectorBarLine(this); break; case ElementType::JUMP: ie = new InspectorJump(this); break; case ElementType::MARKER: ie = new InspectorMarker(this); break; case ElementType::GLISSANDO: case ElementType::GLISSANDO_SEGMENT: ie = new InspectorGlissando(this); break; case ElementType::TEMPO_TEXT: ie = new InspectorTempoText(this); break; case ElementType::DYNAMIC: ie = new InspectorDynamic(this); break; case ElementType::AMBITUS: ie = new InspectorAmbitus(this); break; case ElementType::FRET_DIAGRAM: ie = new InspectorFretDiagram(this); break; case ElementType::LAYOUT_BREAK: ie = new InspectorBreak(this); break; case ElementType::BEND: ie = new InspectorBend(this); break; case ElementType::TREMOLOBAR: ie = new InspectorTremoloBar(this); break; case ElementType::ARPEGGIO: ie = new InspectorArpeggio(this); break; case ElementType::BREATH: ie = new InspectorCaesura(this); break; case ElementType::LYRICS: ie = new InspectorLyric(this); break; case ElementType::STAFF_TEXT: case ElementType::SYSTEM_TEXT: case ElementType::REHEARSAL_MARK: ie = new InspectorStaffText(this); break; case ElementType::STAFFTYPE_CHANGE: ie = new InspectorStaffTypeChange(this); break; case ElementType::BRACKET: ie = new InspectorBracket(this); break; case ElementType::INSTRUMENT_NAME: ie = new InspectorIname(this); break; case ElementType::FINGERING: ie = new InspectorFingering(this); break; case ElementType::STEM: ie = new InspectorStem(this); break; case ElementType::HARMONY: ie = new InspectorHarmony(this); break; case ElementType::VIBRATO_SEGMENT: ie = new InspectorVibrato(this); break; case ElementType::NOTEDOT: ie = new InspectorNoteDot(this); break; default: if (element()->isText()) ie = new InspectorText(this); else ie = new InspectorElement(this); break; } } sa->setWidget(ie); // will destroy previous set widget //focus policies were set by hand in each inspector_*.ui. this code just helps keeping them like they are //also fixes mac problem. on Mac Qt::TabFocus doesn't work, but Qt::StrongFocus works QList<QWidget*> widgets = ie->findChildren<QWidget*>(); for (int i = 0; i < widgets.size(); i++) { QWidget* currentWidget = widgets.at(i); switch (currentWidget->focusPolicy()) { case Qt::WheelFocus: case Qt::StrongFocus: if (currentWidget->inherits("QComboBox") || currentWidget->parent()->inherits("QAbstractSpinBox") || currentWidget->inherits("QAbstractSpinBox") || currentWidget->inherits("QLineEdit")) ; //leave it like it is else currentWidget->setFocusPolicy(Qt::TabFocus); break; case Qt::NoFocus: case Qt::ClickFocus: currentWidget->setFocusPolicy(Qt::NoFocus); break; case Qt::TabFocus: break; } } } if (ie) ie->setElement(); }
QuickInspectorWidget::QuickInspectorWidget(QWidget *parent) : QWidget(parent), ui(new Ui::QuickInspectorWidget), m_renderTimer(new QTimer(this)), m_sceneChangedSinceLastRequest(false), m_waitingForImage(false), m_imageProvider(new QuickSceneImageProvider), m_preview(new QQuickView) { ui->setupUi(this); ObjectBroker::registerClientObjectFactoryCallback<QuickInspectorInterface*>( createQuickInspectorClient); m_interface = ObjectBroker::object<QuickInspectorInterface*>(); connect(m_interface, SIGNAL(sceneChanged()), this, SLOT(sceneChanged())); connect(m_interface, SIGNAL(sceneRendered(QVariantMap)), this, SLOT(sceneRendered(QVariantMap))); ui->windowComboBox->setModel(ObjectBroker::model("com.kdab.GammaRay.QuickWindowModel")); connect(ui->windowComboBox, SIGNAL(currentIndexChanged(int)), m_interface, SLOT(selectWindow(int))); if (ui->windowComboBox->currentIndex() >= 0) { m_interface->selectWindow(ui->windowComboBox->currentIndex()); } QSortFilterProxyModel *proxy = new QuickClientItemModel(this); proxy->setSourceModel(ObjectBroker::model("com.kdab.GammaRay.QuickItemModel")); proxy->setDynamicSortFilter(true); ui->itemTreeView->setModel(proxy); ui->itemTreeSearchLine->setProxy(proxy); QItemSelectionModel *selectionModel = ObjectBroker::selectionModel(proxy); ui->itemTreeView->setSelectionModel(selectionModel); ui->itemTreeView->setItemDelegate(new QuickItemDelegate(ui->itemTreeView)); connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemSelectionChanged(QItemSelection))); connect(proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(itemModelDataChanged(QModelIndex,QModelIndex))); QSortFilterProxyModel *sgProxy = new KRecursiveFilterProxyModel(this); sgProxy->setSourceModel(ObjectBroker::model("com.kdab.GammaRay.QuickSceneGraphModel")); sgProxy->setDynamicSortFilter(true); ui->sgTreeView->setModel(sgProxy); ui->sgTreeSearchLine->setProxy(sgProxy); QItemSelectionModel *sgSelectionModel = ObjectBroker::selectionModel(sgProxy); ui->sgTreeView->setSelectionModel(sgSelectionModel); connect(sgSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemSelectionChanged(QItemSelection))); new QuickItemTreeWatcher(ui->itemTreeView, ui->sgTreeView, this); new DeferredResizeModeSetter(ui->itemTreeView->header(), 0, QHeaderView::ResizeToContents); ui->itemPropertyWidget->setObjectBaseName("com.kdab.GammaRay.QuickItem"); ui->sgPropertyWidget->setObjectBaseName("com.kdab.GammaRay.QuickSceneGraph"); qmlRegisterType<AnnotatedScenePreview>("com.kdab.GammaRay", 1, 0, "AnnotatedScenePreview"); QWidget *previewContainter = QWidget::createWindowContainer(m_preview, ui->previewTreeSplitter); previewContainter->setFocusPolicy(Qt::StrongFocus); m_preview->setResizeMode(QQuickView::SizeRootObjectToView); m_preview->engine()->addImageProvider("quicksceneprovider", m_imageProvider); m_preview->setSource(QUrl("qrc:/gammaray/plugins/quickinspector/quickpreview.qml")); m_rootItem = qobject_cast< QQuickItem *>(m_preview->rootObject()); qmlRegisterUncreatableType<QuickInspectorInterface>( "com.kdab.GammaRay", 1, 0, "QuickInspectorInterface", "Can't create. Only for enums."); m_preview->engine()->rootContext()->setContextProperty("inspectorInterface", m_interface); QTimer::singleShot(0, this, SLOT(setSplitterSizes())); m_renderTimer->setInterval(100); m_renderTimer->setSingleShot(true); connect(m_renderTimer, SIGNAL(timeout()), this, SLOT(requestRender())); connect(m_interface, SIGNAL(features(GammaRay::QuickInspectorInterface::Features)), this, SLOT(setFeatures(GammaRay::QuickInspectorInterface::Features))); m_interface->checkFeatures(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget container; container.resize(640, 680); container.setFocusPolicy ( Qt::NoFocus ); Engine engine(NULL); QMenuBar open_menu_bar(&container); QMenu open_menu("&File", &container); QAction open("&Open", &container); open.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); open_menu.addAction(&open); QAction reset("&Reset", &container); reset.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); open_menu.addAction(&reset); QAction save("&Save", &container); save.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); open_menu.addAction(&save); QAction close("&Close", &container); close.setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4)); open_menu.addAction(&close); QMenu draw_menu("&Drawmodes", &container); QAction points("&Points", &container); points.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); draw_menu.addAction(&points); QAction wire("&Wireframe", &container); wire.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); draw_menu.addAction(&wire); QAction flat("&Flat shaded", &container); flat.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); draw_menu.addAction(&flat); QAction smooth("&Smooth shaded", &container); smooth.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); draw_menu.addAction(&smooth); /**** MENU CONVEX HULL ****/ QMenu convex_hull("Convex Hull", &container); QAction calc("&Calculate CH", &container); calc.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); convex_hull.addAction(&calc); /**** MENU HELP ****/ QMenu help_menu("&?", &container); QAction help("&Help", &container); help.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); help_menu.addAction(&help); QAction about("&About", &container); about.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); help_menu.addAction(&about); open_menu_bar.addMenu(&open_menu); open_menu_bar.addMenu(&draw_menu); open_menu_bar.addMenu(&convex_hull); open_menu_bar.addMenu(&help_menu); Window_gl window(&container); window.setGeometry(0,22,640, 680); container.show(); QDialog instructions( NULL ); instructions.setFixedSize(300,180); instructions.setWindowTitle("Help"); QLabel instr_text("\nUp - Sposta l'osservatore verso l'alto\nDown - Sposta l'osservatore verso il basso\nLeft - Ruota verso sinistra\nRight - Ruota verso destra\nShift+Up - Zoom In\nShift+Down - Zoom out\n\nSi ricorda che il programma e' in grado di gestire\nsolo files di tipo .OFF.\nAltri formati non sono attualmente supportati.", &instructions); instr_text.setTextFormat(Qt::AutoText); instr_text.setWordWrap(true); instructions.hide(); QDialog credits( NULL ); credits.setFixedSize(300,100); credits.setWindowTitle("Credits"); QLabel cred_text("\tCGVew v.1.7\n\nA cura di Fabio Guggeri ([email protected])\ne Stefano Marras ([email protected]).\n", &credits); cred_text.setTextFormat(Qt::AutoText); cred_text.setWordWrap(true); credits.hide(); QObject::connect( &open, SIGNAL(triggered()), &engine, SLOT(open_file()) ); QObject::connect( &reset, SIGNAL(triggered()), &window, SLOT(reset()) ); QObject::connect( &reset, SIGNAL(triggered()), &engine, SLOT(reset()) ); QObject::connect( &save, SIGNAL(triggered()), &engine, SLOT(save_file()) ); QObject::connect( &points, SIGNAL(triggered()), &window, SLOT(set_p_drawmode()) ); QObject::connect( &wire, SIGNAL(triggered()), &window, SLOT(set_w_drawmode()) ); QObject::connect( &flat, SIGNAL(triggered()), &window, SLOT(set_f_drawmode()) ); QObject::connect( &smooth, SIGNAL(triggered()), &window, SLOT(set_s_drawmode()) ); QObject::connect( &help, SIGNAL(triggered()), &instructions, SLOT(show()) ); QObject::connect( &about, SIGNAL(triggered()), &credits, SLOT(show()) ); QObject::connect( &close, SIGNAL(triggered()), &app, SLOT(quit()) ); QObject::connect( &engine, SIGNAL(send_dcel(QVector<DCEL>&)), &window, SLOT(add_dcel(QVector<DCEL>&)) ); QObject::connect( &calc, SIGNAL(triggered()), &engine, SLOT(calculate_ch()) ); window.setFocus(); return app.exec(); }
void TaskDialog::initProgressTab(QScrollArea *scrollArea) { /* construct */ QWidget *progressDetail = new QWidget(scrollArea); QFormLayout *fl = new QFormLayout; comboStatus = new QComboBox; comboStatus->addItem(tr("Not Started")); comboStatus->addItem(tr("In Progress")); comboStatus->addItem(tr("Completed")); comboStatus->addItem(tr("Waiting")); comboStatus->addItem(tr("Deferred")); spinComplete = new QSpinBox; spinComplete->setMinimum(0); spinComplete->setMaximum(100); spinComplete->setSuffix(tr("%")); startedCheck = new QGroupBox; startedCheck->setCheckable(true); startedCheck->setTitle(tr("Started:")); completedCheck = new QGroupBox; completedCheck->setCheckable(true); completedCheck->setTitle(tr("Completed:")); startedEdit = new QDateEdit; completedEdit = new QDateEdit; QVBoxLayout *vl = new QVBoxLayout(); vl->addWidget(startedEdit); startedCheck->setLayout(vl); vl = new QVBoxLayout(); vl->addWidget(completedEdit); completedCheck->setLayout(vl); fl->addRow(tr("Status"), comboStatus); fl->addRow(tr("Progress"), spinComplete); fl->addRow(startedCheck); fl->addRow(completedCheck); progressDetail->setLayout(fl); /* initialize */ QDate current = QDate::currentDate(); comboStatus->setCurrentIndex( todo.status() ); spinComplete->setValue(todo.percentCompleted()); if ( !todo.startedDate().isNull() ) { startedCheck->setChecked(true); startedEdit->setDate(todo.startedDate()); } else { startedCheck->setChecked(false); startedEdit->setDate(current); } if ( todo.isCompleted() ) { completedCheck->setChecked(true); completedEdit->setDate(todo.completedDate()); } else { completedCheck->setChecked(false); completedEdit->setDate(current); } /* connect */ connect( startedEdit, SIGNAL(dateChanged(QDate)), this, SLOT(startDateChanged(QDate)) ); connect( completedEdit, SIGNAL(dateChanged(QDate)), this, SLOT(endDateChanged(QDate)) ); connect( comboStatus, SIGNAL(activated(int)), this, SLOT(statusChanged(int)) ); connect( startedCheck, SIGNAL(toggled(bool)), this, SLOT(startDateChecked(bool)) ); connect( completedCheck, SIGNAL(toggled(bool)), this, SLOT(endDateChecked(bool)) ); connect( spinComplete, SIGNAL(valueChanged(int)), this, SLOT(percentChanged(int)) ); scrollArea->setWidget(progressDetail); progressDetail->setFocusPolicy(Qt::NoFocus); }