CInputDialogOrdering::CInputDialogOrdering(QWidget *parent) : QDialog(parent), ui(new Ui::CInputDialogOrdering) { ui->setupUi(this); m_pThread=NULL; m_iNewDealerId=m_iMarkId=-1; ui->pushButtonEdit->setEnabled(false), ui->pushButtonDelete->setEnabled(false); ui->dateEdit->setDate(QDate().currentDate());//set current date ui->lineEditOrderingnumber->setFocus(); ui->pushButtonOk->setEnabled(false); //disable auto default buttons ui->pushButtonAddBarcode->setAutoDefault(false); ui->pushButtonCancel->setAutoDefault(false); ui->pushButtonDelete->setAutoDefault(false); ui->pushButtonEdit->setAutoDefault(false); ui->pushButtonNew->setAutoDefault(false); ui->pushButtonOk->setAutoDefault(false); //date QDate dt=QDate().currentDate(); ui->dateEdit->setMaximumDate(dt); dt=QDate(2009,1,1); ui->dateEdit->setMinimumDate(dt); check_user_input(); settings(false);//load & set settings //context menu ui->tableWidgetWares->setContextMenuPolicy(Qt::CustomContextMenu); m_pContextMenu=new QMenu(QString("context_default"),this); if(m_pContextMenu!=NULL) { m_pContextMenu->addAction(QString::fromUtf8("Hinzufügen")); m_pContextMenu->addAction(QString("Bearbeiten")); m_pContextMenu->addAction(QString::fromUtf8("Löschen")); } //connects context menus connect(m_pContextMenu,SIGNAL(triggered(QAction*)),this,SLOT(receiv_context_menu(QAction*))); connect(ui->tableWidgetWares,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(open_context_menu())); //connects connect(ui->pushButtonNew,SIGNAL(clicked()),this,SLOT(add_ware())); connect(ui->pushButtonAddBarcode,SIGNAL(clicked()),this,SLOT(add_ware_barcode())); connect(ui->pushButtonDelete,SIGNAL(clicked()),this,SLOT(delete_ware())); connect(ui->pushButtonEdit,SIGNAL(clicked()),this,SLOT(edit_ware())); connect(ui->tableWidgetWares,SIGNAL(itemSelectionChanged()),this,SLOT(check_user_input())); connect(ui->tableWidgetWares,SIGNAL(itemDoubleClicked(QTableWidgetItem*)),this,SLOT(edit_ware())); connect(ui->comboBoxDealer,SIGNAL(editTextChanged(QString)),this,SLOT(edit_maker_combobox(QString))); connect(ui->pushButtonOk,SIGNAL(clicked()),this,SLOT(press_ok())); connect(ui->pushButtonCancel,SIGNAL(clicked()),this,SLOT(press_cancel())); //- setMaximumSize(width(),height()); setMinimumSize(width(),height()); }
void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb_ref = p_event; if (mb_ref.is_valid()) { const InputEventMouseButton &mb = **mb_ref; if (mb.is_pressed() && !_dragging) { Vector2 mpos = mb.get_position(); _selected_tangent = get_tangent_at(mpos); if (_selected_tangent == TANGENT_NONE) set_selected_point(get_point_at(mpos)); switch (mb.get_button_index()) { case BUTTON_RIGHT: _context_click_pos = mpos; open_context_menu(get_global_transform().xform(mpos)); break; case BUTTON_MIDDLE: remove_point(_hover_point); break; case BUTTON_LEFT: _dragging = true; break; } } if (!mb.is_pressed() && _dragging && mb.get_button_index() == BUTTON_LEFT) { _dragging = false; if (_has_undo_data) { UndoRedo &ur = *EditorNode::get_singleton()->get_undo_redo(); ur.create_action(_selected_tangent == TANGENT_NONE ? TTR("Modify Curve Point") : TTR("Modify Curve Tangent")); ur.add_do_method(*_curve_ref, "_set_data", _curve_ref->get_data()); ur.add_undo_method(*_curve_ref, "_set_data", _undo_data); // Note: this will trigger one more "changed" signal even if nothing changes, // but it's ok since it would have fired every frame during the drag anyways ur.commit_action(); _has_undo_data = false; } } } Ref<InputEventMouseMotion> mm_ref = p_event; if (mm_ref.is_valid()) { const InputEventMouseMotion &mm = **mm_ref; Vector2 mpos = mm.get_position(); if (_dragging && _curve_ref.is_valid()) { Curve &curve = **_curve_ref; if (_selected_point != -1) { if (!_has_undo_data) { // Save full curve state before dragging points, // because this operation can modify their order _undo_data = curve.get_data(); _has_undo_data = true; } if (_selected_tangent == TANGENT_NONE) { // Drag point Vector2 point_pos = get_world_pos(mpos); int i = curve.set_point_offset(_selected_point, point_pos.x); // The index may change if the point is dragged across another one set_hover_point_index(i); set_selected_point(i); // This is to prevent the user from losing a point out of view. if (point_pos.y < curve.get_min_value()) point_pos.y = curve.get_min_value(); else if (point_pos.y > curve.get_max_value()) point_pos.y = curve.get_max_value(); curve.set_point_value(_selected_point, point_pos.y); } else { // Drag tangent Vector2 point_pos = curve.get_point_position(_selected_point); Vector2 control_pos = get_world_pos(mpos); Vector2 dir = (control_pos - point_pos).normalized(); real_t tangent; if (Math::abs(dir.x) > CMP_EPSILON) tangent = dir.y / dir.x; else tangent = 9999 * (dir.y >= 0 ? 1 : -1); bool link = !Input::get_singleton()->is_key_pressed(KEY_SHIFT); if (_selected_tangent == TANGENT_LEFT) { curve.set_point_left_tangent(_selected_point, tangent); // Note: if a tangent is set to linear, it shouldn't be linked to the other if (link && _selected_point != curve.get_point_count() - 1 && !curve.get_point_right_mode(_selected_point) != Curve::TANGENT_FREE) curve.set_point_right_tangent(_selected_point, tangent); } else { curve.set_point_right_tangent(_selected_point, tangent); if (link && _selected_point != 0 && !curve.get_point_left_mode(_selected_point) != Curve::TANGENT_FREE) curve.set_point_left_tangent(_selected_point, tangent); } } } } else { set_hover_point_index(get_point_at(mpos)); } } Ref<InputEventKey> key_ref = p_event; if (key_ref.is_valid()) { const InputEventKey &key = **key_ref; if (key.is_pressed() && _selected_point != -1) { if (key.get_scancode() == KEY_DELETE) remove_point(_selected_point); } } }