nxtRicWordRectValue::nxtRicWordRectValue( QString name, QString tooltip, QWidget *parent ): nxtVarEditAbstract( parent ), control_x( this, tr("X"), NULL, "" ), control_y( this, tr("Y"), NULL, "" ), control_width( this, tr("Width"), NULL, "" ), control_height( this, tr("Height"), NULL, "" ) { //Create the groupbox QGroupBox *gbox = new QGroupBox( name, this ); gbox->setToolTip( tooltip ); //Set up layouts QVBoxLayout *mainlayout = new QVBoxLayout; QVBoxLayout *boxlayout = new QVBoxLayout; setLayout( mainlayout ); gbox->setLayout( boxlayout ); mainlayout->addWidget( gbox ); mainlayout->setContentsMargins( QMargins() ); //Add ric_value controls boxlayout->addWidget( (QWidget*)&control_x ); boxlayout->addWidget( (QWidget*)&control_y ); boxlayout->addWidget( (QWidget*)&control_width ); boxlayout->addWidget( (QWidget*)&control_height ); connect( &control_x, SIGNAL( value_changed() ), this, SIGNAL( value_changed() ) ); connect( &control_y, SIGNAL( value_changed() ), this, SIGNAL( value_changed() ) ); connect( &control_width, SIGNAL( value_changed() ), this, SIGNAL( value_changed() ) ); connect( &control_height, SIGNAL( value_changed() ), this, SIGNAL( value_changed() ) ); }
int QTshotWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMAINWINDOW::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: doHelp(); break; case 1: doQuit(); break; case 2: doOpen(); break; case 3: doNew(); break; case 4: doSave(); break; case 5: doData(); break; case 6: doExport(); break; case 7: doExportOK(); break; case 8: doOptions(); break; case 9: doToggle(); break; case 10: doCollapse(); break; case 11: doPlan(); break; case 12: doExtended(); break; case 13: do3D(); break; case 14: doCrossSection((*reinterpret_cast< DBlock*(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2])),(*reinterpret_cast< bool(*)>(_a[3]))); break; case 15: doCrossSection((*reinterpret_cast< DBlock*(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break; case 16: value_changed((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 17: double_clicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QPoint(*)>(_a[4]))); break; } _id -= 18; } return _id; }
void ObjectProxy::handle_value_change(const Value &val) { // TODO: root should check type value_ = val; if (latency_ < 0 && wait_until_ >= 0) { // latency not set but we have already sent a value out // we guess we are receiving from our own send... // TODO: this can lead to latency_ being too short if we receive another // notification, but it does not matter latency_ = time_ref_.elapsed() - wait_until_; wait_until_ = 0; } else { if (wait_until_) { // (gently) update latency latency_ = latency_ + (time_ref_.elapsed() - wait_until_) / 4; } if (!to_send_.is_empty()) { // send now root_proxy_->send_to_remote(url().c_str(), to_send_); to_send_.set_empty(); wait_until_ = time_ref_.elapsed() + (latency_ * 1.5); } else { wait_until_ = 0; } } value_changed(); }
void OptionLayout::add_option(const boost::shared_ptr<cf3::common::Option>& option) { GraphicalValue * value = GraphicalValue::create_from_option(option, this->parentWidget()); QString name(option->name().c_str()); m_options[name] = value; if( !option->pretty_name().empty() ) name = option->pretty_name().c_str(); value->setToolTip(option->description().c_str()); addRow(name + ':', value); // forward the signal connect(value, SIGNAL(value_changed()), this, SIGNAL(value_changed())); }
void TriggerDock::trigger_stages_changed(int index) { widget_enable(); ds_trigger_set_stage(index); value_changed(); logic_changed(0); inv_changed(0); count_changed(); }
PlaceEdit::PlaceEdit(PlaceEdit *_parent, int _index, QString placeholder_text, QWidget *qparent) : QLineEdit(qparent) { qDebug() << "creating place edit"; setMaxLength (40); setPlaceholderText (placeholder_text); model = new PlaceModel (_index, this); completer = new QCompleter (model, this); completer->setCaseSensitivity (Qt::CaseInsensitive); // TODO put in mask // TODO prevent slashes completer->setModel (model); setCompleter (completer); setValidator (new LineValidator (this)); /* // delay or otherwise act as if the user hit return after 500ms timer = new QTimer (this); timer->setSingleShot(true); timer->setInterval(500); connect(timer, SIGNAL(timeout()), SLOT(handle_check_username())); connect(username, SIGNAL(textEdited(QString)), username_timer, SLOT(start())); connect (this, SIGNAL (textChanged (QString)), model, SLOT (handle_text_changed (QString))); */ if (_parent != NULL) { connect (_parent->get_model(), SIGNAL(value_changed(QString)), model, SLOT(handle_parent_text_changed(QString))); connect (_parent->get_model(), SIGNAL(value_changed(QString)), this, SLOT(handle_parent_text_changed(QString))); } }
void QtUtil :: ParameterSlider :: slider_changed (int pos) { m_value = m_min -> value () + ((m_max -> value () - m_min -> value ()) * pos) / TICKS; setToolTip (QString :: number (m_value)); emit value_changed (m_value); }
void PlaceModel::handle_parent_text_changed (QString text) { qDebug () << "index " << index << " handle_parent_text_changed " << text; places[index] = ""; settings->setValue(settings_name, places[index]); set_url (); emit value_changed (""); }
void NumericalEntry::set_digits(unsigned int digits) { if (_digits != digits) { _digits = digits; value_changed(); g_object_notify (G_OBJECT (this), "digits"); // TODO: do we need this? // since lower/upper may have changed queue_resize(); } }
void nxtCanvasWidget::crop(){ if( !canvas ) return; if(current_tool == TOOL_SELECTION && !selection.isNull() ){ //Crop to selection canvas->crop_to( selection.x(), selection.y(), selection.width(), selection.height() ); } else canvas->autocrop( options ); update(); emit value_changed(); }
void GraphicalArray::bt_remove_clicked() { QModelIndexList selectedItems; selectedItems = m_list_view->selectionModel()->selectedIndexes(); for(int i = selectedItems.size() - 1 ; i >= 0 ; i--) { QModelIndex index = selectedItems.at(i); m_model->removeRow(index.row(), index.parent()); } emit value_changed(); }
void nxtCanvasWidget::mouseDoubleClickEvent( QMouseEvent *event ){ if( active_tool == TOOL_BITMAP ){ //Paste bitmap finally if( canvas ){ canvas->copy_canvas( clipboard, 0, 0, selection.width(), selection.height(), selection.x(), selection.y(), options ); write_buffer(); } //Hide seletion selection.setWidth( 0 ); selection.setHeight( 0 ); update(); emit value_changed(); } }
void PixmapSlider::mouseMoveEvent(QMouseEvent *e) { if (!drag.active) return; float value_ofs=drag.value_at_click+(get_click_pos(e->pos())-drag.pos_at_click); if (value_ofs<0) value_ofs=0; if (value_ofs>1) value_ofs=1; if (value==value_ofs) return; //dont bother if the value is the same value=value_ofs; value_changed(value_ofs); value_changed_signal(value_ofs); update(); }
void PixmapSlider::wheelEvent ( QWheelEvent * e ) { int range=(type==TYPE_VERTICAL)?height():width(); int grabber=(type==TYPE_VERTICAL)?skin.grabber.height():skin.grabber.width(); range-=margin_beg+margin_end+grabber; if (range==0) range=0.0001; float step=1.0/(float)range; if (!e->modifiers()&Qt::ShiftModifier) step*=5.0; if (e->delta()>0) set_value( value + step ); else if (e->delta()<0) set_value( value - step ); value_changed( value ); value_changed_signal(value); }
void GraphicalArray::keyPressEvent(QKeyEvent * event) { GraphicalValue::keyPressEvent(event); // if the path line edit has the focus if(m_edit_add->hasFocus()) { // key code for the pressed key int pressedKey = event->key(); // Qt::Key_Enter : enter key located on the keypad // Qt::Key_Return : return key if(pressedKey == Qt::Key_Enter || pressedKey == Qt::Key_Return) { m_model->setStringList( m_model->stringList() << m_edit_add->text() ); m_edit_add->clear(); emit value_changed(); } } }
void PlaceModel::handle_text_changed (QString text) { qDebug () << "index " << index << " handle_text_changed " << text; //username_timer->stop(); places[index] = text; settings->setValue(settings_name, places[index]); // add this new place into the list associated with our current parent set_url (); /* // what is this doing? if (url2list_cache->contains(url)) { QList<QString> *item_list = url2list_cache->value(url); // yuck QListIterator<QString> i (*item_list); bool found = false; while (i.hasNext() && !found) { if (i.next() == text) { found = true; } } if (!found) { place_list->append(text); sort (0); } } */ emit value_changed (text); }
void nxtCanvasWidget::action( action_event event ){ static QPoint prev_last_mouse; if( active_tool == TOOL_NONE ) return; //First handle the events that doesn't change the canvas if( active_tool == TOOL_SELECTION ){ selection = get_qrect_from_points( mouse_start, mouse_current ); if( selection.height() >= 0 ) selection.setHeight( selection.height()+1 ); if( selection.width() >= 0 ) selection.setWidth( selection.width()+1 ); update(); //TODO: emit signal? } else if( active_tool == TOOL_MOVE ){ if( is_moveable && event != EVENT_MOVE ) //Prevent infinitive loop change_pos( mouse_current.x() - mouse_last.x(), mouse_current.y() - mouse_last.y() ); } else if( canvas ){ //Create a fresh buffer, unless we are drawing in freehand if( active_tool != TOOL_PIXEL ) new_buffer(); //If this is the last action, enable auto-resize //if( event == EVENT_MOUSE_UP ) canvas->set_auto_resize( true ); //TODO: enable, then restore to previous state switch( active_tool ){ case TOOL_PIXEL: //Draw a dot first time, then follow with lines if( event == EVENT_MOUSE_DOWN ) canvas->PointOut( mouse_current.x(), mouse_current.y(), options ); else canvas->connected_line_out( prev_last_mouse.x(), prev_last_mouse.y(), mouse_last.x(), mouse_last.y(), mouse_current.x(), mouse_current.y(), options ); prev_last_mouse = mouse_last; break; case TOOL_LINE: if( key_control ){ //Limit to angles in steps of 15 degrees int dx = mouse_current.x() - mouse_start.x(); int dy = mouse_current.y() - mouse_start.y(); double angle = atan2( (double)( dy ), (double)( dx ) ); double lenght = sqrt( (double)( dx*dx + dy*dy ) ); double limiter = PI * 15 / 180; double new_angle = round_sym( angle / limiter ) * limiter; dy = round_sym( sin( new_angle ) * lenght ); dx = round_sym( cos( new_angle ) * lenght ); canvas->LineOut( mouse_start.x(), mouse_start.y(), mouse_start.x() + dx, mouse_start.y() + dy, options ); } else canvas->LineOut( mouse_start.x(), mouse_start.y(), mouse_current.x(), mouse_current.y(), options ); break; case TOOL_RECT:{ QRect rect = get_qrect_from_points( mouse_start, mouse_current ); //Make it a square if control is pressed if( key_control ){ if( rect.width() > rect.height() ){ if( mouse_current.y() < mouse_start.y() ) rect.translate( 0, rect.height() - rect.width() ); rect.setHeight( rect.width() ); } else{ if( mouse_current.x() < mouse_start.x() ) rect.translate( rect.width() - rect.height(), 0 ); rect.setWidth( rect.height() ); } } canvas->RectOut( rect.x(), rect.y(), rect.width(), rect.height(), options ); } break; case TOOL_ELLIPSE: if( key_control ){ QPoint lenght = mouse_current - mouse_start; int radius = sqrt( (double)( lenght.x()*lenght.x() + lenght.y()*lenght.y() ) ); canvas->CircleOut( mouse_start.x(), mouse_start.y(), radius, options ); } else canvas->EllipseOut( mouse_start.x(), mouse_start.y(), abs( mouse_current.x() - mouse_start.x() ), abs( mouse_current.y() - mouse_start.y() ), options ); break; case TOOL_BITMAP:{ if( clipboard ){ if( event == EVENT_MOUSE_DOWN ){ selection.setWidth( clipboard->get_width() ); selection.setHeight( clipboard->get_height() ); } selection.moveTo( selection.topLeft() + mouse_current - mouse_last ); canvas->copy_canvas( clipboard, 0, 0, selection.width(), selection.height(), selection.x(), selection.y(), options ); } } break; case TOOL_FILL: canvas->bucket_fill( mouse_current.x(), mouse_current.y(), options ); break; default: qDebug( "nxtCanvasWidget::action() unhandled tool: %d", active_tool ); } //If this is the last action, make the buffer permanent if( event == EVENT_MOUSE_UP && active_tool != TOOL_BITMAP ){ // canvas->set_auto_resize( false ); write_buffer(); } update(); emit value_changed(); } }
bool GraphicalArray::set_value(const QVariant & value) { QStringList invalidValues; QStringList values; QStringList list; bool success = true; const QValidator * validator = m_edit_add->validator(); int pos; if(value.type() == QVariant::String) values = value.toString().split(m_separator); else if(value.type() == QVariant::StringList) values = value.toStringList(); else success = false; if( success ) { QStringList::iterator it = values.begin(); for( ; it != values.end() ; it++) { QString value = *it; bool valid = validator == nullptr || value.isEmpty() || validator->validate(value, pos) == QValidator::Acceptable; if(!valid) invalidValues << value; else list << value; success &= valid; } success = invalidValues.empty(); } if(!success) { QString msg; if(invalidValues.count() == 1) msg = "The following value is not valid: %1"; else msg = "The following values are not valid: %1"; msg = msg.arg(invalidValues.join("\"\n \"").prepend("\n \"").append("\"")); NLog::global()->add_message(msg); } else { m_original_value = list; m_model->setStringList(list); emit value_changed(); } return success; }
void GraphicalDouble::text_updated(const QString & text) { emit value_changed(); }
void PIDConfigurator::d_value_changed( const QString& str ) { value_changed( 'D' ); }