//----------------------------------------------------------------------------// bool TreeView::handleSelection(const glm::vec2& position, bool should_select, bool is_cumulative, bool is_range) { return handleSelection( indexAtWithAction(position, &TreeView::handleSelectionAction), should_select, is_cumulative, is_range); }
// The ctor. QsciScintillaBase::QsciScintillaBase(QWidget *parent) : QAbstractScrollArea(parent), preeditPos(-1), preeditNrBytes(0) #if QT_VERSION >= 0x050000 , clickCausedFocus(false) #endif { connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleVSb(int))); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleHSb(int))); setAcceptDrops(true); setFocusPolicy(Qt::WheelFocus); setAttribute(Qt::WA_KeyCompression); setAttribute(Qt::WA_InputMethodEnabled); #if QT_VERSION >= 0x050100 setInputMethodHints( Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhMultiLine); #elif QT_VERSION >= 0x040600 setInputMethodHints(Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText); #endif viewport()->setBackgroundRole(QPalette::Base); viewport()->setMouseTracking(true); //viewport()->setAttribute(Qt::WA_NoSystemBackground); //viewport()->setAutoFillBackground(false); //viewport()->setAttribute(Qt::WA_OpaquePaintEvent); // QPainter p( viewport() ); // p.setCompositionMode( QPainter::CompositionMode_Clear ); // p.fillRect( viewport()->rect(), Qt::transparent ); triple_click.setSingleShot(true); #if (QT_VERSION >= 0x040200 && QT_VERSION < 0x050000 && defined(Q_OS_MAC)) || (QT_VERSION >= 0x050200 && defined(Q_OS_OSX)) initialiseRectangularPasteboardMime(); #endif sci = new QsciScintillaQt(this); SendScintilla(SCI_SETCARETPERIOD, QApplication::cursorFlashTime() / 2); // Make sure the lexers are linked in. if (!lexersLinked) { Scintilla_LinkLexers(); lexersLinked = true; } QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) connect(cb, SIGNAL(selectionChanged()), SLOT(handleSelection())); // Add it to the pool. poolList.append(this); }
Documents::Documents(QWidget *pParent) : QWidget(pParent) { setupUi(this); _source = Uninitialized; _sourceid = -1; _doc->addColumn(tr("Type"), _itemColumn, Qt::AlignLeft, true, "target_type" ); _doc->addColumn(tr("Number"), _itemColumn, Qt::AlignLeft, true, "target_number" ); _doc->addColumn(tr("Name"), -1, Qt::AlignLeft, true, "name" ); _doc->addColumn(tr("Description"), -1, Qt::AlignLeft, true, "description"); _doc->addColumn(tr("Relationship"), _itemColumn, Qt::AlignLeft,true, "purpose"); connect(_attachDoc, SIGNAL(clicked()), this, SLOT(sAttachDoc())); connect(_editDoc, SIGNAL(clicked()), this, SLOT(sEditDoc())); connect(_viewDoc, SIGNAL(clicked()), this, SLOT(sViewDoc())); connect(_detachDoc, SIGNAL(clicked()), this, SLOT(sDetachDoc())); connect(_doc, SIGNAL(valid(bool)), _editDoc, SLOT(setEnabled(bool))); connect(_doc, SIGNAL(valid(bool)), _viewDoc, SLOT(setEnabled(bool))); connect(_doc, SIGNAL(valid(bool)), this, SLOT(handleSelection())); handleSelection(); if (_x_privileges) { QMenu * newDocMenu = new QMenu; QAction* imgAct = new QAction(tr("Image"), this); imgAct->setEnabled(_x_privileges->check("MaintainImages")); connect(imgAct, SIGNAL(triggered()), this, SLOT(sNewImage())); newDocMenu->addAction(imgAct); QAction* incdtAct = new QAction(tr("Incident"), this); incdtAct->setEnabled(_x_privileges->check("AddIncidents")); connect(incdtAct, SIGNAL(triggered()), this, SLOT(sNewIncdt())); newDocMenu->addAction(incdtAct); QAction* todoAct = new QAction(tr("To Do"), this); todoAct->setEnabled(_x_privileges->check("MaintainPersonalTodoList") || _x_privileges->check("MaintainOtherTodoLists")); connect(todoAct, SIGNAL(triggered()), this, SLOT(sNewToDo())); newDocMenu->addAction(todoAct); QAction* oppAct = new QAction(tr("Opportunity"), this); oppAct->setEnabled(_x_privileges->check("MaintainOpportunities")); connect(oppAct, SIGNAL(triggered()), this, SLOT(sNewOpp())); newDocMenu->addAction(oppAct); QAction* projAct = new QAction(tr("Project"), this); projAct->setEnabled(_x_privileges->check("MaintainProjects")); connect(projAct, SIGNAL(triggered()), this, SLOT(sNewProj())); newDocMenu->addAction(projAct); _newDoc->setMenu(newDocMenu); } }
void Documents::setReadOnly(bool pReadOnly) { _readOnly = pReadOnly; _newDoc->setEnabled(!pReadOnly); _attachDoc->setEnabled(!pReadOnly); _editDoc->setEnabled(!pReadOnly); _detachDoc->setEnabled(!pReadOnly); handleSelection(); }
// The ctor. QsciScintillaBase::QsciScintillaBase(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { QGridLayout *layout = new QGridLayout(this, 2, 2); txtarea = new QWidget(this, 0, WRepaintNoErase|WResizeNoErase); txtarea->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); txtarea->setMouseTracking(true); txtarea->setAcceptDrops(true); txtarea->setFocusPolicy(WheelFocus); txtarea->setFocusProxy(this); layout->addWidget(txtarea, 0, 0); vsb = new QScrollBar(Vertical, this); layout->addWidget(vsb, 0, 1); connect(vsb, SIGNAL(valueChanged(int)), SLOT(handleVSb(int))); hsb = new QScrollBar(Horizontal, this); layout->addWidget(hsb, 1, 0); connect(hsb, SIGNAL(valueChanged(int)), SLOT(handleHSb(int))); txtarea->installEventFilter(this); setFocusPolicy(WheelFocus); // FIXME: QMacPasteboardMime isn't in Qt v5 yet. #if QT_VERSION >= 0x040200 && defined(Q_OS_MAC) && QT_VERSION < 0x050000 RectangularPasteboardMime::initialise(); #endif sci = new QsciScintillaQt(this); SendScintilla(SCI_SETCARETPERIOD, QApplication::cursorFlashTime() / 2); // Make sure the lexers are linked in. if (!lexersLinked) { Scintilla_LinkLexers(); lexersLinked = true; } QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) connect(cb, SIGNAL(selectionChanged()), SLOT(handleSelection())); // Add it to the pool. poolList.append(this); }
int SciListBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QListWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: handleSelection(); break; default: ; } _id -= 1; } return _id; }
// Handle a keypress void Menu::handleKeyPress(const OIS::KeyEvent &e) { if(mEnteringName) { doEnterName(e); if(mEnteringName) return; } switch(e.key) { default: break; case OIS::KC_UP: case OIS::KC_LEFT: scrollUp(); break; case OIS::KC_DOWN: case OIS::KC_RIGHT: scrollDown(); break; case OIS::KC_ESCAPE: if(mMenuName == "MainMenu") break; if(mMenuName == "GameOptions") { // Restore the settings gameApp->mGameConfig->LoadFile(getConfigLocation(true).c_str()); String str = gameApp->mGameConfig->GetValue("graphics", "bloom", "on"); CompositorManager::getSingleton().setCompositorEnabled(gameApp->getRenderWindow()->getViewport(0), "Bloom", (str != "off")); str = gameApp->mGameConfig->GetValue("graphics", "shadows", "on"); mSceneMgr->setShadowTechnique((str == "off") ? SHADOWTYPE_NONE : SHADOWTYPE_STENCIL_ADDITIVE); str = gameApp->mGameConfig->GetValue("audio", "volume", "1.0"); SoundSystem::getSingleton().setSoundVolume(StringConverter::parseReal(str)); str = gameApp->mGameConfig->GetValue("audio", "music_volume", "0.5"); SoundSystem::getSingleton().setMusicVolume(StringConverter::parseReal(str)); } // Return to main hide(); setMenu("MainMenu", mPrevSelection); break; case OIS::KC_RETURN: case OIS::KC_SPACE: case OIS::KC_LCONTROL: case OIS::KC_RCONTROL: case OIS::KC_LSHIFT: case OIS::KC_RSHIFT: if(mMenuName == "MainMenu") mPrevSelection = mSelection; handleSelection(); break; } }
// The ctor. QsciScintillaBase::QsciScintillaBase(QWidget *parent) : QAbstractScrollArea(parent) { connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleVSb(int))); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleHSb(int))); setAcceptDrops(true); setFocusPolicy(Qt::WheelFocus); setAttribute(Qt::WA_KeyCompression); viewport()->setBackgroundRole(QPalette::Base); viewport()->setMouseTracking(true); viewport()->setAttribute(Qt::WA_NoSystemBackground); triple_click.setSingleShot(true); sci = new ScintillaQt(this); curseurs = new QMap<int, Curseur*>; lockedLines = new QList<int>; SendScintilla(SCI_SETCARETPERIOD, QApplication::cursorFlashTime() / 2); // Make sure the lexers are linked in. if (!lexersLinked) { Scintilla_LinkLexers(); lexersLinked = true; } QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) connect(cb, SIGNAL(selectionChanged()), SLOT(handleSelection())); // Add it to the pool. poolList.append(this); }
/** Constructor */ FileBrowser::FileBrowser(QWidget* parent) : QTableView(parent) { Settings settings; libRoot = settings.value(LIB_ROOT_KEY, DEFAULT_LIB_ROOT).toString(); fsModel = new QFileSystemModel(this); fsModel->setFilter(QDir::AllEntries | QDir::AllDirs | QDir::NoDot); // Want .. setSelectionMode(QTableView::SingleSelection); setSelectionBehavior(QTableView::SelectRows); setShowGrid(false); setSortingEnabled(true); setModel(fsModel); horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents); verticalHeader()->setVisible(false); setRootIndex(fsModel->setRootPath(libRoot)); connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(handleDoubleClick(QModelIndex))); connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(handleSelection(QModelIndex,QModelIndex))); }
void handleEvents() { sf::Event Event; const sf::Input& Input = App->GetInput(); bool shiftDown = Input.IsKeyDown(sf::Key::LShift) || Input.IsKeyDown(sf::Key::RShift); while (App->GetEvent(Event)) { // Close window : exit if (Event.Type == sf::Event::Closed) App->Close(); // // Escape key : exit if (Event.Type == sf::Event::KeyPressed) { if(Event.Key.Code == sf::Key::Escape) App->Close(); else if(Event.Key.Code == sf::Key::Delete) deleteShape(); else if(Event.Key.Code == sf::Key::Up && selected != 0) { Shape* s = findShape(selected); switch(colorM) { case COLOR_R: s->color[0] = ffmin(1.0, s->color[0]+0.05); break; case COLOR_G: s->color[1] = ffmin(1.0, s->color[1]+0.05); break; case COLOR_B: s->color[2] = ffmin(1.0, s->color[2]+0.05); break; } } else if(Event.Key.Code == sf::Key::Down && selected != 0) { Shape* s = findShape(selected); switch(colorM) { case COLOR_R: s->color[0] = ffmax(0.0, s->color[0]-0.05); break; case COLOR_G: s->color[1] = ffmax(0.0, s->color[1]-0.05); break; case COLOR_B: s->color[2] = ffmax(0.0, s->color[2]-0.05); break; } } } // Resize event : adjust viewport if (Event.Type == sf::Event::Resized) { glViewport(0, 0, Event.Size.Width, Event.Size.Height); currentRes[0] = Event.Size.Width; currentRes[1] = Event.Size.Height; update_perspective(); } if (Event.Type == sf::Event::MouseButtonPressed) { lastPos[0] = Event.MouseButton.X; lastPos[1] = Event.MouseButton.Y; float x = Event.MouseButton.X; float y = currentRes[1]-Event.MouseButton.Y; if(Event.MouseButton.Button == sf::Mouse::Left) { if(!handleButtons(x,y)) { handleSelection(Event.MouseButton.X, Event.MouseButton.Y); } } if(Event.MouseButton.Button == sf::Mouse::Left && !shiftDown) { buttonDown[0] = 1; } if(Event.MouseButton.Button == sf::Mouse::Right) buttonDown[1] = 1; if(Event.MouseButton.Button == sf::Mouse::Middle) buttonDown[2] = 1; if(Event.MouseButton.Button == sf::Mouse::Left && shiftDown) buttonDown[2] = 1; } if (Event.Type == sf::Event::MouseButtonReleased) { if(Event.MouseButton.Button == sf::Mouse::Left && !shiftDown) buttonDown[0] = 0; if(Event.MouseButton.Button == sf::Mouse::Right) buttonDown[1] = 0; if(Event.MouseButton.Button == sf::Mouse::Middle) buttonDown[2] = 0; if(Event.MouseButton.Button == sf::Mouse::Left && shiftDown) buttonDown[2] = 0; } if (Event.Type == sf::Event::MouseMoved && (buttonDown[0] || buttonDown[1] || buttonDown[2]) ) { int x = Event.MouseMove.X; int y = Event.MouseMove.Y; if(selected == 0) { if(buttonDown[0]) camera.trackball_rotate(lastPos[0], lastPos[1], x, y, currentRes[0], currentRes[1]); if(buttonDown[1]) camera.trackball_translate(lastPos[0], lastPos[1], x, y); if(buttonDown[2]) camera.trackball_translate_z(lastPos[0], lastPos[1], x, y); } else { Shape* s = findShape(selected); float diff = (x-lastPos[0])-(y-lastPos[1]); vec3 v; switch(axisM) { case X_AXIS: v = vec3(diff,0.0,0.0); break; case Y_AXIS: v = vec3(0.0,diff,0.0); break; case Z_AXIS: v = vec3(0.0,0.0,diff); break; } switch(transM) { case TRANS_TRANSLATION: s->trans.trans += v*0.01; break; case TRANS_ROTATION: s->rot.trans += v*0.1; break; case TRANS_SCALE: s->scale.trans += v*0.01; break; } } lastPos[0] = x; lastPos[1] = y; } } }