void CommandsPanel::Layout::applyLayout() { size_t wc = 25;//widgets().size(); if( wc==0 ) return; size_t wcx = 5,//sqrt(wc), wcy = 4;//wcx; //int w = owner()->w() - margin().xMargin(), // h = owner()->h() - margin().yMargin(); array2d<BtnBase*> p; p.resize(wcx, wcy); for( size_t i=0; i<widgets().size(); ++i ){ BtnBase * b = dynamic_cast<BtnBase*>( widgets()[i] ); if( b ){ int x = b->x, y = b->y; if( p[x][y]!=0 ){ int d = p.width()*p.height(); for( int i=0; i<p.width(); ++i ) for( int r=0; r<p.height(); ++r ){ if( p[i][r]==0 && abs(i-x)+abs(r-y)<d ){ x = i; y = r; d = abs(i-x)+abs(r-y); } } } if( p[x][y]==0 ){ p[x][y] = b; } } } for( size_t i=0; i<wcy; ++i ) for( size_t r=0; r<wcx; ++r ){ //size_t id = i*wcx+r; if( p[r][i]/*id < widgets().size()*/ ){ //int x0 = r*w/wcx, x1 = (r+1)*w/wcx, // y0 = i*h/wcy, y1 = (i+1)*h/wcy; int sz = 50; int x0 = r*sz+2, y0 = i*sz+2; placeIn( p[r][i],//widgets()[id], x0+margin().left, y0+margin().top, sz, sz ); } } }
bool DMXUSB::rescanWidgets() { while (m_outputs.isEmpty() == false) delete m_outputs.takeFirst(); while (m_inputs.isEmpty() == false) delete m_inputs.takeFirst(); QList <DMXUSBWidget*> widgets(QLCFTDI::widgets()); foreach (DMXUSBWidget* widget, widgets) { if (widget->type() == DMXUSBWidget::ProRX) { m_inputs << widget; EnttecDMXUSBProRX* prorx = (EnttecDMXUSBProRX*) widget; connect(prorx, SIGNAL(valueChanged(quint32,quint32,uchar)), this, SIGNAL(valueChanged(quint32,quint32,uchar))); } else { m_outputs << widget; } } emit configurationChanged(); return true; }
void VirtualConsole::reselectWidgets() { QList <VCWidget*> widgets(m_selectedWidgets); clearWidgetSelection(); foreach (VCWidget* w, widgets) setWidgetSelected(w, true); }
void KexiDBComboBox::createEditor() { KexiDBAutoField::createEditor(); if (subwidget()) { subwidget()->setGeometry(editorGeometry()); if (!d->isEditable) { QStyleOptionComboBox option; option.initFrom(subwidget()); const QRect comboRect = subwidget()->style()->subControlRect( QStyle::CC_ComboBox, &option, QStyle::SC_ComboBoxEditField, subwidget()); kDebug() << "comboRect:" << comboRect; subwidget()->setContentsMargins(comboRect.left(), comboRect.top(), width() - comboRect.right(), height() - comboRect.bottom()); int l, t, r, b; subwidget()->getContentsMargins(&l, &t, &r, &b); kDebug() << "altered margins:" << l << t << r << b; subwidget()->setFocusPolicy(Qt::NoFocus); subwidget()->setCursor(QCursor(Qt::ArrowCursor)); // widgets like listedit have IbeamCursor, we don't want that QPalette subwidgetPalette(subwidget()->palette()); subwidgetPalette.setColor(QColorGroup::Base, Qt::transparent); subwidget()->setPalette(subwidgetPalette); d->subWidgetsWithDisabledEvents.clear(); d->subWidgetsWithDisabledEvents << subwidget(); subwidget()->installEventFilter(this); QList<QWidget*> widgets(subwidget()->findChildren<QWidget*>()); foreach(QWidget *widget, widgets) { d->subWidgetsWithDisabledEvents << widget; widget->installEventFilter(this); } }
virtual Widgets GetWidgets() const { Widgets widgets(WidgetsPage::GetWidgets()); widgets.push_back(m_spinctrl); widgets.push_back(m_spinctrldbl); return widgets; }
void VirtualConsole::clearWidgetSelection() { /* Get a copy of selected widget list */ QList <VCWidget*> widgets(m_selectedWidgets); /* Clear the list so isWidgetSelected() returns false for all widgets */ m_selectedWidgets.clear(); /* Update all widgets to clear the selection frame around them */ QListIterator <VCWidget*> it(widgets); while (it.hasNext() == true) it.next()->update(); /* Change the custom menu to the latest-selected widget's menu */ updateCustomMenu(); /* Enable or disable actions */ updateActions(); }
void KexiFormEventHandler::setMainWidgetForEventHandling(QWidget* mainWidget) { d->mainWidget = mainWidget; if (!d->mainWidget) return; //find widgets whose will work as data items //! @todo look for other widgets too QList<QWidget*> widgets(d->mainWidget->findChildren<QWidget*>()); foreach(QWidget *widget, widgets) { if (!widget->inherits("QPushButton") ){ continue; } bool ok; KexiFormEventAction::ActionData data; data.string = widget->property("onClickAction").toString(); data.option = widget->property("onClickActionOption").toString(); if (data.isEmpty()) continue; QString actionType, actionArg; KexiPart::Info* partInfo = data.decodeString(actionType, actionArg, ok); if (!ok) continue; kDebug() << "actionType:" << actionType << "actionArg:" << actionArg; if (actionType == "kaction" || actionType == "currentForm") { QAction *action = KexiMainWindowIface::global()->actionCollection()->action( actionArg); if (!action) continue; QObject::disconnect(widget, SIGNAL(clicked()), action, SLOT(trigger())); //safety QObject::connect(widget, SIGNAL(clicked()), action, SLOT(trigger())); } else if (partInfo) { //'open or execute' action KexiFormEventAction* action = new KexiFormEventAction(widget, actionType, actionArg, data.option); QObject::disconnect(widget, SIGNAL(clicked()), action, SLOT(slotTrigger())); QObject::connect(widget, SIGNAL(clicked()), action, SLOT(slotTrigger())); } } }
void ScroolWidget::ProxyLayout::applyLayout() { int sw = widgets().size()*spacing(), sh = sw; for( size_t i=0; i<widgets().size(); ++i ){ Tempest::Size s = sizeHint( widgets()[i] ); sw += s.w; sh += s.h; } Widget* sbox = owner()->owner(); Tempest::Size sback, stop; if( widgets().size() ){ sback = sizeHint( widgets().back() ); stop = sizeHint( widgets()[0] ); } if( orientation()==Tempest::Vertical ){ int sscroll = 0; if( scroolBeforeBegin ) sscroll = -std::max(sbox->h()-stop.h, stop.h); if( scroolAfterEnd ) scrool->setRange( sscroll, sh-std::min( sback.h, sbox->h()) ); else scrool->setRange( sscroll, sh-scrool->h() ); owner()->setPosition( 0, -scrool->value() ); owner()->resize( owner()->w(), sh ); } else { int sscroll = 0; if( scroolBeforeBegin ) sscroll = -std::max(sbox->w()-stop.w, stop.w); if( scroolAfterEnd ) scrool->setRange( sscroll, sw-std::min(sback.w, sbox->w()));else scrool->setRange( sscroll, sw-scrool->w() ); owner()->setPosition( -scrool->value(), 0 ); owner()->resize( sw, owner()->h()); } LinearLayout::applyLayout(); }
void PythonContext::GlobalInit() { // must happen on the UI thread if(qApp->thread() != QThread::currentThread()) { qFatal("PythonContext::GlobalInit MUST be called from the UI thread"); return; } // for the exception signal qRegisterMetaType<QList<QString>>("QList<QString>"); PyImport_AppendInittab("_renderdoc", &PyInit_renderdoc); PyImport_AppendInittab("_qrenderdoc", &PyInit_qrenderdoc); #if defined(STATIC_QRENDERDOC) // add the location where our libs will be for statically-linked python installs { QDir bin = QFileInfo(QCoreApplication::applicationFilePath()).absoluteDir(); QString pylibs = QDir::cleanPath(bin.absoluteFilePath(lit("../share/renderdoc/pylibs"))); pylibs.toWCharArray(python_home); Py_SetPythonHome(python_home); } #endif Py_SetProgramName(program_name); Py_Initialize(); PyEval_InitThreads(); OutputRedirectorType.tp_name = "renderdoc_output_redirector"; OutputRedirectorType.tp_basicsize = sizeof(OutputRedirector); OutputRedirectorType.tp_flags = Py_TPFLAGS_DEFAULT; OutputRedirectorType.tp_doc = "Output redirector, to be able to catch output to stdout and stderr"; OutputRedirectorType.tp_new = PyType_GenericNew; OutputRedirectorType.tp_dealloc = &PythonContext::outstream_del; OutputRedirectorType.tp_methods = OutputRedirector_methods; OutputRedirector_methods[0].ml_meth = &PythonContext::outstream_write; OutputRedirector_methods[1].ml_meth = &PythonContext::outstream_flush; PyObject *main_module = PyImport_AddModule("__main__"); PyModule_AddObject(main_module, "renderdoc", PyImport_ImportModule("_renderdoc")); PyModule_AddObject(main_module, "qrenderdoc", PyImport_ImportModule("_qrenderdoc")); main_dict = PyModule_GetDict(main_module); // replace sys.stdout and sys.stderr with our own objects. These have a 'this' pointer of NULL, // which then indicates they need to forward to a global object // import sys PyDict_SetItemString(main_dict, "sys", PyImport_ImportModule("sys")); PyObject *rlcompleter = PyImport_ImportModule("rlcompleter"); if(rlcompleter) { PyDict_SetItemString(main_dict, "rlcompleter", rlcompleter); } else { // ignore a failed import PyErr_Clear(); } // sysobj = sys PyObject *sysobj = PyDict_GetItemString(main_dict, "sys"); // sysobj.stdout = renderdoc_output_redirector() // sysobj.stderr = renderdoc_output_redirector() if(PyType_Ready(&OutputRedirectorType) >= 0) { // for compatibility with earlier versions of python that took a char * instead of const char * char noparams[1] = ""; PyObject *redirector = PyObject_CallFunction((PyObject *)&OutputRedirectorType, noparams); PyObject_SetAttrString(sysobj, "stdout", redirector); OutputRedirector *output = (OutputRedirector *)redirector; output->isStdError = 0; output->context = NULL; redirector = PyObject_CallFunction((PyObject *)&OutputRedirectorType, noparams); PyObject_SetAttrString(sysobj, "stderr", redirector); output = (OutputRedirector *)redirector; output->isStdError = 1; output->context = NULL; } // if we need to append to sys.path to locate PySide2, do that now #if defined(PYSIDE2_SYS_PATH) { PyObject *syspath = PyObject_GetAttrString(sysobj, "path"); #ifndef STRINGIZE #define STRINGIZE2(a) #a #define STRINGIZE(a) STRINGIZE2(a) #endif PyObject *str = PyUnicode_FromString(STRINGIZE(PYSIDE2_SYS_PATH)); PyList_Append(syspath, str); Py_DecRef(str); Py_DecRef(syspath); } #endif // set up PySide #if PYSIDE2_ENABLED { Shiboken::AutoDecRef core(Shiboken::Module::import("PySide2.QtCore")); if(!core.isNull()) SbkPySide2_QtCoreTypes = Shiboken::Module::getTypes(core); else qCritical() << "Failed to load PySide2.QtCore"; Shiboken::AutoDecRef gui(Shiboken::Module::import("PySide2.QtGui")); if(!gui.isNull()) SbkPySide2_QtGuiTypes = Shiboken::Module::getTypes(gui); else qCritical() << "Failed to load PySide2.QtGui"; Shiboken::AutoDecRef widgets(Shiboken::Module::import("PySide2.QtWidgets")); if(!widgets.isNull()) SbkPySide2_QtWidgetsTypes = Shiboken::Module::getTypes(widgets); else qCritical() << "Failed to load PySide2.QtWidgets"; } #endif // release GIL so that python work can now happen on any thread PyEval_SaveThread(); }