void ItemsTreeView::slotHeaderContextMenu(const QPoint &point) { const int section = header()->logicalIndexAt(point); QMenu menu; for (int i = 0; i < header()->count(); ++i) { const QString title = model()->headerData(i, Qt::Horizontal).toString(); QAction *showHideAction = new QAction(title, &menu); showHideAction->setCheckable(true); showHideAction->setChecked(!header()->isSectionHidden(i)); showHideAction->setData(i); menu.addAction(showHideAction); } const ItemsTreeModel::ColumnType columnType = mItemsTreeModel->columnTypes().at(section); switch (columnType) { case ItemsTreeModel::NextStepDate: case ItemsTreeModel::CreationDate: case ItemsTreeModel::LastModifiedDate: qDebug() << "Clicked on a date!"; default: break; } QAction *selectedAction = menu.exec(header()->mapToGlobal(point)); if (selectedAction) { const QVariant var = selectedAction->data(); if (var.type() == QVariant::Int) { const int toggleSection = var.toInt(); const bool hide = !selectedAction->isChecked(); header()->setSectionHidden(toggleSection, hide); saveHeaderView(); } } }
void TlevelCreatorDlg::tapMenu() { TtouchMenu *menu = new TtouchMenu(this); if (m_levelSett->saveButton()->isEnabled()) { QAction *saveAct = actionFromButton(m_levelSett->saveButton(), menu); saveAct->setData(10); menu->addAction(saveAct); } if (m_levelSett->startExerciseButton()->isEnabled()) { QAction *exerciseAct = actionFromButton(m_levelSett->startExerciseButton(), menu); exerciseAct->setData(11); menu->addAction(exerciseAct); } if (m_levelSett->startExamButton()->isEnabled()) { QAction *examAct = actionFromButton(m_levelSett->startExamButton(), menu); examAct->setData(12); menu->addAction(examAct); } for (int i = 0; i < buttonBox->buttons().size(); ++i) { QAction *buttonAction = new QAction(buttonBox->buttons()[i]->icon(), buttonBox->buttons()[i]->text(), menu); buttonAction->setData((i)); menu->addAction(buttonAction); } QAction *menuAction = menu->exec(QPoint(navList->width(), height() -menu->sizeHint().height()), QPoint(navList->width(), height())); int actionNumber = menuAction ? menuAction->data().toInt() : -1; delete menu; // delete menu before performing its action if (actionNumber != -1) { // no action if (actionNumber < 10) // button box actions buttonBox->buttons()[actionNumber]->click(); else if (actionNumber == 10) m_levelSett->saveButton()->click(); else if (actionNumber == 11) m_levelSett->startExerciseButton()->click(); else if (actionNumber == 12) m_levelSett->startExamButton()->click(); } }
void BookmarksToolbar::moveRight() { QAction* act = qobject_cast<QAction*> (sender()); if (!act) { return; } ToolButton* button = (ToolButton*) act->data().value<void*>(); int index = m_layout->indexOf(button); if (index == m_layout->count() - 1) { return; } ToolButton* buttonRight = qobject_cast<ToolButton*> (m_layout->itemAt(index + 1)->widget()); if (!buttonRight || buttonRight->menu()) { return; } Bookmark bookmark = button->data().value<Bookmark>(); Bookmark bookmarkRight = buttonRight->data().value<Bookmark>(); QSqlQuery query; query.prepare("UPDATE bookmarks SET toolbar_position=? WHERE id=?"); query.addBindValue(index + 1); query.addBindValue(bookmark.id); mApp->dbWriter()->executeQuery(query); query.prepare("UPDATE bookmarks SET toolbar_position=? WHERE id=?"); query.addBindValue(index); query.addBindValue(bookmarkRight.id); mApp->dbWriter()->executeQuery(query); QWidget* w = m_layout->takeAt(index)->widget(); m_layout->insertWidget(index + 1, w); }
void MainWindow::fillLanguages() { // make a group of language actions QActionGroup* actionsDir = new QActionGroup(this); QActionGroup* actionsRes = new QActionGroup(this); QSettings settings; QString locale = QLocale::system().name().left(2); QString lang = settings.value("Language", locale).toString(); if (!Application::availableLanguagesRes().contains(lang)) lang = "en"; bool langSet = false; this->ui->menu_Pomoc->addSeparator(); connect(actionsRes, SIGNAL(triggered(QAction*)), this, SLOT(setLanguageRes(QAction*))); connect(actionsDir, SIGNAL(triggered(QAction*)), this, SLOT(setLanguageDir(QAction*))); foreach (QString avail, Application::availableLanguagesRes()) { // figure out nice names for locales QLocale locale(avail); QString name = QLocale::languageToString(locale.language()); // construct an action QAction* action = this->ui->menu_Pomoc->addAction(name); action->setData(avail); action->setCheckable(true); actionsRes->addAction(action); if (action->data().toString() == lang) { langSet = true; action->setChecked(true); Application::setLanguage(lang, "res"); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QAction *qaAction; QMenu *menMain = new QMenu(); QMenu *menPref = new QMenu(); QMenu *menAcc = new QMenu(); QMenu *menDevel = new QMenu(); QMenu *menEdu = new QMenu(); QMenu *menGraph = new QMenu(); QMenu *menHam = new QMenu(); QMenu *menInter = new QMenu(); QMenu *menMulti = new QMenu(); QMenu *menOffic = new QMenu(); QMenu *menOth = new QMenu(); QMenu *menSci = new QMenu(); QMenu *menSys = new QMenu(); QDesktopWidget *qDesktop = new QDesktopWidget(); QRect qrDesktop = qDesktop->availableGeometry(); QFile file(QDir::homePath() + "/.qtmenu"); QString strProcess; QString strForeColor; QString strBackColor; int nLeft = -1; int nTop = -1; QDir qdDir = QDir(strSysApps); QFileInfoList qflList = qdDir.entryInfoList(); QString strRunCommand = "fbrun -nearmouse"; QString strExitCommand = "fluxbox-remote quit"; QString strRebootCommand = "sudo reboot"; QString strPoweroffCommand = "sudo poweroff"; QStringList strlistCustoms; QString strTheme; bool blShowGNOME = true; bool blShowLXDE = true; bool blShowKDE = true; bool blShowMATE = true; bool blShowXFCE = true; QList<MenuListItem> mliList; MenuListItem mliListTemp; QMenu *menTemp; int nCount = qflList.count() - 1; bool blFirstLoop = true; bool blHasCustoms = false; bool blIconHasPath = false; bool blIconHasExt = false; // process config file if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { while (!file.atEnd()) { strProcess = file.readLine().trimmed(); // left positioning if (strProcess.toLower().startsWith("left=")) { strProcess.remove(0, 5); nLeft = strProcess.toInt(); } else // top positioning if (strProcess.toLower().startsWith("top=")) { strProcess.remove(0, 4); nTop = strProcess.toInt(); } else // custom menu items if (strProcess.toLower().startsWith("custom=")) { strProcess.remove(0, 7); strlistCustoms.append(strProcess); } else // theme if (strProcess.toLower().startsWith("icontheme=")) { strProcess.remove(0, 10); strTheme = strProcess; } else // foreground if (strProcess.toLower().startsWith("fg=")) { strProcess.remove(0, 3); if (strProcess != "") { strForeColor = strProcess; } } else // background if (strProcess.toLower().startsWith("bg=")) { strProcess.remove(0, 3); if (strProcess != "") { strBackColor = strProcess; } } else // show gnome items? if (strProcess.toLower().startsWith("showgnomeitems=")) { strProcess.remove(0, 15); if (strProcess.contains("true") ) { blShowGNOME = true; } else { blShowGNOME = false; } } else // show lxde items? if (strProcess.toLower().startsWith("showlxdeitems=")) { strProcess.remove(0, 14); if (strProcess.contains("true") ) { blShowLXDE = true; } else { blShowLXDE = false; } } else // show kde items? if (strProcess.toLower().startsWith("showkdeitems=")) { strProcess.remove(0, 14); if (strProcess.contains("true") ) { blShowKDE = true; } else { blShowKDE = false; } } else // show mate items? if (strProcess.toLower().startsWith("showmateitems=")) { strProcess.remove(0, 14); if (strProcess.contains("true") ) { blShowMATE = true; } else { blShowMATE = false; } } else // show xfce items? if (strProcess.toLower().startsWith("showxfceitems=")) { strProcess.remove(0, 14); if (strProcess.contains("true") ) { blShowXFCE = true; } else { blShowXFCE = false; } } else // run command if (strProcess.toLower().startsWith("runcommand=")) { strProcess.remove(0, 11); if (strProcess != "") { strRunCommand = strProcess; } } else // exit command if (strProcess.toLower().startsWith("exitcommand=")) { strProcess.remove(0, 12); if (strProcess != "") { strExitCommand = strProcess; } } else // reboot command if (strProcess.toLower().startsWith("restartcommand=")) { strProcess.remove(0, 15); if (strProcess != "") { strRebootCommand = strProcess; } } else // poweroff command if (strProcess.toLower().startsWith("poweroffcommand=")) { strProcess.remove(0, 16); if (strProcess != "") { strPoweroffCommand = strProcess; } } } } // set icon theme if (strTheme != "") { QIcon::setThemeName(strTheme); } else { QIcon::setThemeName("hicolor"); } // custom menu items from config file for (int n = 0; n < strlistCustoms.count(); n++) { MenuListItem mi; strProcess = strlistCustoms.at(n); mi.strName = strProcess.section("|", 0, 0); mi.strExec = strProcess.section("|", 1, 1); mi.strIcon = strProcess.section("|", 2, 2); mi.strCategory = "CustomItems"; mliList.append(mi); blHasCustoms = true; } // read desktop files and insert menu items for (int n = 0; n < nCount;) { QFileInfo fileInfo = qflList.at(n); QFile qfFile(fileInfo.absoluteFilePath()); MenuListItem mi; bool blNoShow = false; bool blOkToParse = false; if (qfFile.open(QIODevice::ReadOnly|QIODevice::Text)) { while (!qfFile.atEnd()) { strProcess = qfFile.readLine(); // set parse flag if we are in the Desktop Entry section if (strProcess.startsWith("[") && strProcess.contains("Desktop Entry")) { blOkToParse = true; } if (blOkToParse) { // app name if (strProcess.startsWith("Name=")) { strProcess.remove(0,5); mi.strName = strProcess.trimmed().remove("_"); } else // app icon if (strProcess.startsWith("Icon=")) { strProcess.remove(0,5); mi.strIcon = strProcess.trimmed(); } else // app exec line if (strProcess.startsWith("Exec=")) { strProcess.remove(0,5); mi.strExec = strProcess.trimmed(); mi.strExec.remove("%F"); mi.strExec.remove("%f"); mi.strExec.remove("%U"); mi.strExec.remove("%u"); } else // app category if (strProcess.startsWith("Categories=")) { if (blFirstLoop) { strProcess.remove(0,11); mi.strCategory = strProcess.trimmed(); } else { mi.strCategory = "Other"; } } else // needs terminal? if (strProcess.startsWith("Terminal=")) { strProcess.remove(0,9); if (strProcess.toLower().contains("true")) { mi.blNeedsTerminal = true; } else { mi.blNeedsTerminal = false; } } else // don't display? if (strProcess.startsWith("NoDisplay=")) { strProcess.remove(0,10); if (strProcess.contains("True") || strProcess.contains("true") ) { blNoShow = true; } } else // show gnome stuff? if (strProcess.contains("OnlyShowIn=GNOME")) { if (blShowGNOME == true) { blNoShow = false; } else { blNoShow = true; } } else // show lxde stuff? if (strProcess.contains("OnlyShowIn=LXDE")) { if (blShowLXDE == true) { blNoShow = false; } else { blNoShow = true; } } else // show kde stuff? if (strProcess.contains("OnlyShowIn=KDE")) { if (blShowKDE == true) { blNoShow = false; } else { blNoShow = true; } } else // show mate stuff? if (strProcess.contains("OnlyShowIn=MATE")) { if (blShowMATE == true) { blNoShow = false; } else { blNoShow = true; } } else // show xfce stuff? if (strProcess.contains("OnlyShowIn=XFCE")) { if (blShowXFCE == true) { blNoShow = false; } else { blNoShow = true; } } else // stop parsing if there are other sections if (strProcess.startsWith("[") && !strProcess.contains("Desktop Entry")) { break; } } } if (mi.strName != "" && !blNoShow) { if (mi.blNeedsTerminal) { mi.strExec = "x-terminal-emulator -e " + mi.strExec; } mliList.append(mi); } } if (qfFile.isOpen()) { qfFile.close(); } // switch to local app folder and start over if (n == (nCount - 1) && blFirstLoop) { qdDir = QDir(QDir::homePath() + "/.local/share/applications"); qflList = qdDir.entryInfoList(); nCount = qflList.count() - 1; n = 0; blFirstLoop = false; QApplication::beep(); } else { n++; } } // sort items alphabetically qSort(mliList); // set up category sub-menus menPref->setIcon(QIcon::fromTheme("preferences-desktop", QIcon::fromTheme("document-send"))); menPref->setTitle("Preferences"); menAcc->setIcon(QIcon::fromTheme("applications-accessories", QIcon::fromTheme("document-send"))); menAcc->setTitle("Accessories"); menDevel->setIcon(QIcon::fromTheme("applications-development", QIcon::fromTheme("document-send"))); menDevel->setTitle("Development"); menEdu->setIcon(QIcon::fromTheme("applications-science", QIcon::fromTheme("document-send"))); menEdu->setTitle("Education"); menGraph->setIcon(QIcon::fromTheme("applications-graphics", QIcon::fromTheme("document-send"))); menGraph->setTitle("Graphics"); menHam->setIcon(QIcon::fromTheme("applications-other", QIcon::fromTheme("document-send"))); menHam->setTitle("Ham Radio"); menInter->setIcon(QIcon::fromTheme("applications-internet", QIcon::fromTheme("document-send"))); menInter->setTitle("Network"); menMulti->setIcon(QIcon::fromTheme("applications-multimedia", QIcon::fromTheme("document-send"))); menMulti->setTitle("Multimedia"); menOffic->setIcon(QIcon::fromTheme("applications-office", QIcon::fromTheme("document-send"))); menOffic->setTitle("Office"); menOth->setIcon(QIcon::fromTheme("applications-other", QIcon::fromTheme("document-send"))); menOth->setTitle("Other"); menSci->setIcon(QIcon::fromTheme("applications-science", QIcon::fromTheme("document-send"))); menSci->setTitle("Science"); menSys->setIcon(QIcon::fromTheme("applications-system", QIcon::fromTheme("document-send"))); menSys->setTitle("System"); // *** collate by standard categories *** for (int i = mliList.size() - 1; i > -1; --i) { menTemp = menOth; mliListTemp = mliList.at(i); // custom items if (mliListTemp.strCategory.contains("CustomItems")) { menTemp = menMain; } else // settings / preferences if (mliListTemp.strCategory.contains("=Settings") || mliListTemp.strCategory.contains(";Settings") ) { menTemp = menPref; } else // system if (mliListTemp.strCategory.contains("System")) { menTemp = menSys; } else // hamradio if (mliListTemp.strCategory.contains("HamRadio")) { menTemp = menHam; } else // science if (mliListTemp.strCategory.contains("Science")) { menTemp = menSci; } else // accessories / utility if (mliListTemp.strCategory.contains("Accessories") || mliListTemp.strCategory.contains("Utility") ) { menTemp = menAcc; } else // development / programming if (mliListTemp.strCategory.contains("Development")) { menTemp = menDevel; } else // education / science if (mliListTemp.strCategory.contains("Education") || mliListTemp.strCategory.contains("Science") ) { menTemp = menEdu; } else // graphics if (mliListTemp.strCategory.contains("Graphics")) { menTemp = menGraph; } else // internet / network if (mliListTemp.strCategory.contains("Internet") || mliListTemp.strCategory.contains("WebBrowser") || mliListTemp.strCategory.contains("Network") ) { menTemp = menInter; } else // multimedia / sound/video if (mliListTemp.strCategory.contains("Audio") || mliListTemp.strCategory.contains("AudioVideo") || mliListTemp.strCategory.contains("Multimedia") ) { menTemp = menMulti; } else // office / productivity if (mliListTemp.strCategory.contains("Office") || mliListTemp.strCategory.contains("Productivity") || mliListTemp.strCategory.contains("WordProcessor") ) { menTemp = menOffic; } /* insert into menu */ qaAction = new QAction(mliListTemp.strName, NULL); // figure out icon blIconHasExt = false; blIconHasPath = false; // has path if (mliListTemp.strIcon.contains("/")) { blIconHasPath = true; } // has extension if (mliListTemp.strIcon.contains(".png") || mliListTemp.strIcon.contains(".xpm") || mliListTemp.strIcon.contains(".svg") ) { blIconHasExt = true; } // no path and no extension if (blIconHasExt == false && blIconHasPath == false) { qaAction->setIcon(QIcon::fromTheme(mliListTemp.strIcon)); } else // path if (blIconHasPath == true) { qaAction->setIcon(QIcon(mliListTemp.strIcon)); } else // extension but no path if (blIconHasExt == true && blIconHasPath == false) { qaAction->setIcon(QIcon::fromTheme(mliListTemp.strIcon)); } if (qaAction->icon().isNull()) { if (file.exists(strSysPix + "/" + mliListTemp.strIcon)) { qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon)); } else if (file.exists(strSysIco + "/" + mliListTemp.strIcon + ".png")) { qaAction->setIcon(QIcon(strSysIco + "/" + mliListTemp.strIcon + ".png")); } else if (file.exists(strSysIco + "/hicolor/scalable/apps/" + mliListTemp.strIcon + ".svg")) { qaAction->setIcon(QIcon(strSysIco + "/hicolor/scalable/apps/" + mliListTemp.strIcon + ".svg")); } else if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".png")) { qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".png")); } else if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".xpm")) { qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".xpm")); } else if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".svg")) { qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".svg")); } } qaAction->setIconVisibleInMenu(true); qaAction->setData(mliListTemp.strExec); menTemp->addAction(qaAction); } // add separator if there are customs if (blHasCustoms) { menMain->addSeparator(); } // preferences if (menPref->actions().count() > 0) { menMain->addMenu(menPref); menMain->addSeparator(); } // accessories if (menAcc->actions().count() > 0) { menMain->addMenu(menAcc); } // development if (menDevel->actions().count() > 0) { menMain->addMenu(menDevel); } // education if (menEdu->actions().count() > 0) { menMain->addMenu(menEdu); } // graphics if (menGraph->actions().count() > 0) { menMain->addMenu(menGraph); } // ham radio if (menHam->actions().count() > 0) { menMain->addMenu(menHam); } // internet/networking if (menInter->actions().count() > 0) { menMain->addMenu(menInter); } // multimedia / sound/video if (menMulti->actions().count() > 0) { menMain->addMenu(menMulti); } // office if (menOffic->actions().count() > 0) { menMain->addMenu(menOffic); } // other if (menOth->actions().count() > 0) { menMain->addMenu(menOth); } // science if (menSci->actions().count() > 0) { menMain->addMenu(menSci); } // system if (menSys->actions().count() > 0) { menMain->addMenu(menSys); } menMain->addSeparator(); qaAction = new QAction("About...", NULL); qaAction->setData("...about..."); qaAction->setIcon(QIcon::fromTheme("dialog-information")); menMain->addAction(qaAction); menMain->addSeparator(); qaAction = new QAction("Run...", NULL); qaAction->setData(strRunCommand); menMain->addAction(qaAction); menMain->addSeparator(); qaAction = new QAction("Exit", NULL); qaAction->setData(strExitCommand); qaAction->setIcon(QIcon::fromTheme("system-log-out")); menMain->addAction(qaAction); qaAction = new QAction("Reboot", NULL); qaAction->setData(strRebootCommand); qaAction->setIcon(QIcon::fromTheme("view-refresh")); menMain->addAction(qaAction); qaAction = new QAction("Shutdown", NULL); qaAction->setData(strPoweroffCommand); qaAction->setIcon(QIcon::fromTheme("system-shutdown")); menMain->addAction(qaAction); // set correct positioning if (nLeft == -1) { nLeft = qrDesktop.left(); } if (nTop == -1) { nTop = qrDesktop.bottom(); } // show menu qaAction = menMain->exec(QPoint(nLeft, nTop)); // perform/run selected action if (qaAction != 0) { QString qsExec = qaAction->data().toString(); if (qsExec == "...about...") { QMessageBox::about(NULL, "About Qt Menu - Standalone", "<h3>Qt Menu - Standalone</h3><br><br>" "Copyright 2014 - Will Brokenbourgh<br>" "Blog: http://www.pismotek.com/brainout/<br><br>" "Version 0.1.1"); } else { QProcess *qp = new QProcess(); qp->setWorkingDirectory(QDir::homePath()); qp->start(qsExec); } } }
// Opens a log file from the recent files list void MainWindow::openRecentFile() { QAction* action = qobject_cast<QAction*>(sender()); if (action) loadFile(action->data().toString()); }
void MainWindow::save() { QAction *action = qobject_cast<QAction *>(sender()); QByteArray fileFormat = action->data().toByteArray(); saveFile(fileFormat); }
void CodChangeMsgDialog::menu_op() { QMenu m(0); MenuFactory::addItem(m, tr("Choose"), -1); m.addSeparator(); int index = list.indexOf(edoper->currentText().trimmed()); if (index != -1) MenuFactory::addItem(m, tr("Select in browser"), 0); BrowserNode * bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlOperation) && !bn->deletedp() && (opers.indexOf((OperationData *) bn->get_data()) != -1)) MenuFactory::addItem(m, tr("Choose operation selected in browser"), 1); else bn = 0; if (cl != 0) MenuFactory::addItem(m, tr("Create operation and choose it"), 2); if ((index != -1) || (bn != 0) || (cl != 0)) { QAction* retAction = m.exec(QCursor::pos()); if(retAction) { switch (retAction->data().toInt()) { case 0: opers[index]->get_browser_node()->select_in_browser(); break; case 2: bn = cl->add_operation(); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { OperationData * od = (OperationData *) bn->get_data(); if ((index = opers.indexOf(od)) == -1) { index = opers.count(); opers.append(od); QString s = od->definition(TRUE, FALSE); list.append(s); edoper->addItem(s); } } edoper->setCurrentIndex(index + 1); } } } }
void RecentFiles::openRecentFile() { QAction *action = qobject_cast<QAction *>(sender()); if (action) emit openFile(action->data().toString()); }
void MainWindow::openRecentSrcFile(void) { QAction *action = qobject_cast<QAction *>(sender()); loadSrc(QStringList() << action->data().toString()); }
void MainWindow::setForceField() { QAction* action = qobject_cast<QAction*>(sender()); if (action) m_viewerModel.setForceField(action->data().toString()); }
void ParameterDialog::menu_type() { QMenu m(0); MenuFactory::addItem(m, tr("Choose"), -1); m.addSeparator(); int index = list.indexOf(edtype->currentText().trimmed()); if (index != -1) MenuFactory::addItem(m, tr("Select in browser"), 0); BrowserNode * bn = 0; if (! visit) { bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlClass) && !bn->deletedp()) MenuFactory::addItem(m, tr("Choose class selected in browser"), 1); else bn = 0; MenuFactory::addItem(m, tr("Create class and choose it"), 2); } if (!visit || (index != -1) || (bn != 0)) { QAction* retAction = m.exec(QCursor::pos()); if(retAction) { switch (retAction->data().toInt()) { case 0: nodes.at(index)->select_in_browser(); break; case 2: bn = BrowserClass::add_class(FALSE, view); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { QString s = bn->full_name(TRUE); if ((index = list.indexOf(s)) == -1) { // new class, may be created through an other dialog index = 0; QStringList::Iterator iter = list.begin(); QStringList::Iterator iter_end = list.end(); while ((iter != iter_end) && (*iter < s)) { ++iter; index += 1; } nodes.insert((unsigned) index, bn); list.insert(iter, s); edtype->insertItem(index + offset,s); } } edtype->setCurrentIndex(index + offset); break; default: break; } } } }
void NodeEditorWindows::openRecentFile() { QAction *action = qobject_cast<QAction *>(sender()); if (action) _project->openProject(action->data().toString()); }
void TableWidget::moveRowDown(){ QAction *action = qobject_cast<QAction *>(sender()); ColumnType t = (ColumnType)action->data().toInt(); int current = currentRow(); moveRow( current, current+1, t ); }
void View::actn_LoadFaceRecognitionMethodState_Triggered() { QAction *action = qobject_cast<QAction*>(sender()); if (action != NULL) loadFaceRecognitionMethodState(action->data().toString()); }
void JoyControlStickContextMenu::setStickMode() { QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); stick->setJoyMode((JoyControlStick::JoyMode)item); }
void JoyControlStickContextMenu::setStickPreset() { PadderCommon::lockInputDevices(); InputDevice *tempDevice = stick->getParentSet()->getInputDevice(); QMetaObject::invokeMethod(tempDevice, "haltServices", Qt::BlockingQueuedConnection); QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *upButtonSlot = 0; JoyButtonSlot *downButtonSlot = 0; JoyButtonSlot *leftButtonSlot = 0; JoyButtonSlot *rightButtonSlot = 0; JoyButtonSlot *upLeftButtonSlot = 0; JoyButtonSlot *upRightButtonSlot = 0; JoyButtonSlot *downLeftButtonSlot = 0; JoyButtonSlot *downRightButtonSlot = 0; if (item == 0) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 1) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 2) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 3) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 4) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(45); } else if (item == 5) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(45); } else if (item == 6) { if (stick->getJoyMode() == JoyControlStick::StandardMode || stick->getJoyMode() == JoyControlStick::FourWayCardinal) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (stick->getJoyMode() == JoyControlStick::EightWayMode) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } else if (stick->getJoyMode() == JoyControlStick::FourWayDiagonal) { upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } stick->setDiagonalRange(45); } else if (item == 7) { QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton*> *buttons = stick->getButtons(); QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton*> iter(*buttons); while (iter.hasNext()) { JoyControlStickButton *button = iter.next().value(); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection); //button->clearSlotsEventReset(); } stick->setDiagonalRange(45); } if (upButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickUp); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, upButtonSlot->getSlotCode()), Q_ARG(unsigned int, upButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, upButtonSlot->getSlotMode())); //button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickDown); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, downButtonSlot->getSlotCode()), Q_ARG(unsigned int, downButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, downButtonSlot->getSlotMode())); //button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeft); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, leftButtonSlot->getSlotCode()), Q_ARG(unsigned int, leftButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, leftButtonSlot->getSlotMode())); //button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRight); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, rightButtonSlot->getSlotCode()), Q_ARG(unsigned int, rightButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, rightButtonSlot->getSlotMode())); //button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeftUp); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, upLeftButtonSlot->getSlotCode()), Q_ARG(unsigned int, upLeftButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, upLeftButtonSlot->getSlotMode())); //button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRightUp); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, upRightButtonSlot->getSlotCode()), Q_ARG(unsigned int, upRightButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, upRightButtonSlot->getSlotMode())); //button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeftDown); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, downLeftButtonSlot->getSlotCode()), Q_ARG(unsigned int, downLeftButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, downLeftButtonSlot->getSlotMode())); //button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRightDown); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, downRightButtonSlot->getSlotCode()), Q_ARG(unsigned int, downRightButtonSlot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, downRightButtonSlot->getSlotMode())); //button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } PadderCommon::unlockInputDevices(); }
void MainWindow::setPartialChargeType() { QAction* action = qobject_cast<QAction*>(sender()); if (action) m_viewerModel.setPartialChargeType(action->data().toString()); }
void EffectRack::menuRequested(QListWidgetItem* it)/*{{{*/ { if (it == 0 || track == 0) return; RackSlot* curitem = (RackSlot*) it; Pipeline* epipe = track->efxPipe(); int idx = row(curitem); QString name; bool mute = false; bool nativeGui = false; Pipeline* pipe = track->efxPipe(); if (pipe) { name = pipe->name(idx); mute = (pipe->isActive(idx) == false); nativeGui = pipe->hasNativeGui(idx); } //enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SAVE }; enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SHOW_NATIVE, SAVE }; QMenu* menu = new QMenu; QAction* newAction = menu->addAction(tr("new")); QAction* changeAction = menu->addAction(tr("change")); QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); //, UP, UP); QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); //, DOWN, DOWN); QAction* removeAction = menu->addAction(tr("remove")); //, REMOVE, REMOVE); QAction* bypassAction = menu->addAction(tr("bypass")); //, BYPASS, BYPASS); QAction* showGuiAction = menu->addAction(tr("show gui")); //, SHOW, SHOW); QAction* showNativeGuiAction = menu->addAction(tr("show native gui")); //, SHOW_NATIVE, SHOW_NATIVE); QAction* saveAction = menu->addAction(tr("save preset")); newAction->setData(NEW); changeAction->setData(CHANGE); upAction->setData(UP); downAction->setData(DOWN); removeAction->setData(REMOVE); bypassAction->setData(BYPASS); showGuiAction->setData(SHOW); showNativeGuiAction->setData(SHOW_NATIVE); saveAction->setData(SAVE); bypassAction->setCheckable(true); showGuiAction->setCheckable(true); showNativeGuiAction->setCheckable(true); bypassAction->setChecked(mute); showGuiAction->setChecked(pipe->guiVisible(idx)); showNativeGuiAction->setEnabled(nativeGui); if (nativeGui) showNativeGuiAction->setChecked(pipe->nativeGuiVisible(idx)); if (pipe->empty(idx)) { menu->removeAction(changeAction); menu->removeAction(saveAction); upAction->setEnabled(false); downAction->setEnabled(false); removeAction->setEnabled(false); bypassAction->setEnabled(false); showGuiAction->setEnabled(false); showNativeGuiAction->setEnabled(false); } else { menu->removeAction(newAction); if (idx == 0) upAction->setEnabled(true); if (idx == ((int)epipe->size() - 1)) downAction->setEnabled(false); } QPoint pt = QCursor::pos(); QAction* act = menu->exec(pt, 0); //delete menu; if (!act) { delete menu; return; } int sel = act->data().toInt(); delete menu; int pdepth = epipe->size(); switch (sel) { case NEW: { choosePlugin(it); break; } case CHANGE: { choosePlugin(it, true); break; } case REMOVE: { BasePlugin* oldPlugin = (*epipe)[idx]; oldPlugin->setActive(false); oldPlugin->aboutToRemove(); if(debugMsg) qCritical("Plugin to remove now and here"); audio->msgAddPlugin(track, idx, 0); song->dirty = true; break; } case BYPASS: { bool flag = !pipe->isActive(idx); pipe->setActive(idx, flag); break; } case SHOW: { bool flag = !pipe->guiVisible(idx); pipe->showGui(idx, flag); break; } case SHOW_NATIVE: { printf("Show native GUI called\n"); bool flag = !pipe->nativeGuiVisible(idx); pipe->showNativeGui(idx, flag); break; } case UP: if (idx > 0) { setCurrentItem(item(idx - 1)); pipe->move(idx, true); } break; case DOWN: if (idx < pdepth) { setCurrentItem(item(idx + 1)); pipe->move(idx, false); } break; case SAVE: savePreset(idx); break; } //Already done on songChanged //updateContents(); song->update(SC_RACK); }/*}}}*/
void MainWindow::slotFileOpenRecent() { QAction *action = qobject_cast<QAction *>(sender()); if (action) openDatabase(action->data().toString()); }
void SoFCColorBar::handleEvent (SoHandleEventAction *action) { const SoEvent * event = action->getEvent(); // check for mouse button events if (event->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { const SoMouseButtonEvent* e = static_cast<const SoMouseButtonEvent*>(event); // calculate the mouse position relative to the colorbar // const SbViewportRegion& vp = action->getViewportRegion(); float fRatio = vp.getViewportAspectRatio(); SbVec2f pos = event->getNormalizedPosition(vp); float pX,pY; pos.getValue(pX,pY); pX = pX*10.0f-5.0f; pY = pY*10.0f-5.0f; // now calculate the real points respecting aspect ratio information // if (fRatio > 1.0f) { pX = pX * fRatio; } else if (fRatio < 1.0f) { pY = pY / fRatio; } // check if the cursor is near to the color bar if (_fMinX > pX || pX > _fMaxX || _fMinY > pY || pY > _fMaxY) return; // not inside the rectangle // left mouse pressed action->setHandled(); if ((e->getButton() == SoMouseButtonEvent::BUTTON1)) { if (e->getState() == SoButtonEvent::DOWN) { // double click event if (_timer.restart() < QApplication::doubleClickInterval()) { QApplication::postEvent( new SoFCColorBarProxyObject(this), new QEvent(QEvent::User)); } } } // right mouse pressed else if ((e->getButton() == SoMouseButtonEvent::BUTTON2)) { if (e->getState() == SoButtonEvent::UP) { SoFCColorBarBase* current = getActiveBar(); QMenu menu; int i=0; for (std::vector<SoFCColorBarBase*>::const_iterator it = _colorBars.begin(); it != _colorBars.end(); ++it) { QAction* item = menu.addAction(QLatin1String((*it)->getColorBarName())); item->setCheckable(true); item->setChecked((*it) == current); item->setData(QVariant(i++)); } menu.addSeparator(); QAction* option = menu.addAction(QObject::tr("Options...")); QAction* action = menu.exec(QCursor::pos()); if (action == option) { QApplication::postEvent( new SoFCColorBarProxyObject(this), new QEvent(QEvent::User)); } else if (action) { int id = action->data().toInt(); pColorMode->whichChild = id; } } } } }
/** * @brief Set the appropriate mode for a DPad based on the item chosen. */ void DPadContextMenu::setDPadMode() { QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); dpad->setJoyMode((JoyDPad::JoyMode)item); }
QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, int y, IdentifyMode mode, QList<QgsMapLayer*> layerList, LayerType layerType ) { QList<IdentifyResult> results; mLastPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y ); mLastExtent = mCanvas->extent(); mLastMapUnitsPerPixel = mCanvas->mapUnitsPerPixel(); if ( mode == DefaultQgsSetting ) { QSettings settings; mode = static_cast<IdentifyMode>( settings.value( "/Map/identifyMode", 0 ).toInt() ); } if ( mode == LayerSelection ) { // fill map of layer / identify results mLayerIdResults.clear(); QList<IdentifyResult> idResult = identify( x, y, TopDownAll ); QList<IdentifyResult>::const_iterator it = idResult.constBegin(); for ( ; it != idResult.constEnd(); ++it ) { QgsMapLayer *layer = it->mLayer; if ( mLayerIdResults.contains( layer ) ) { mLayerIdResults[layer].append( *it ); } else { mLayerIdResults.insert( layer, QList<IdentifyResult>() << *it ); } } //fill selection menu with entries from mmLayerIdResults QMenu layerSelectionMenu; QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator resultIt = mLayerIdResults.constBegin(); for ( ; resultIt != mLayerIdResults.constEnd(); ++resultIt ) { QAction* action = new QAction( QString( "%1 (%2)" ).arg( resultIt.key()->name() ).arg( resultIt.value().size() ), 0 ); action->setData( resultIt.key()->id() ); //add point/line/polygon icon QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( resultIt.key() ); if ( vl ) { switch ( vl->geometryType() ) { case QGis::Point: action->setIcon( QgsApplication::getThemeIcon( "/mIconPointLayer.png" ) ); break; case QGis::Line: action->setIcon( QgsApplication::getThemeIcon( "/mIconLineLayer.png" ) ); break; case QGis::Polygon: action->setIcon( QgsApplication::getThemeIcon( "/mIconPolygonLayer.png" ) ); break; default: break; } } else if ( resultIt.key()->type() == QgsMapLayer::RasterLayer ) { action->setIcon( QgsApplication::getThemeIcon( "/mIconRaster.png" ) ); } connect( action, SIGNAL( hovered() ), this, SLOT( handleMenuHover() ) ); layerSelectionMenu.addAction( action ); } if ( mLayerIdResults.size() > 1 ) { QAction *action = new QAction( tr( "All (%1)" ).arg( idResult.size() ), 0 ); connect( action, SIGNAL( hovered() ), this, SLOT( handleMenuHover() ) ); layerSelectionMenu.addAction( action ); } // exec layer selection menu QPoint globalPos = mCanvas->mapToGlobal( QPoint( x + 5, y + 5 ) ); QAction* selectedAction = layerSelectionMenu.exec( globalPos ); if ( selectedAction ) { if ( selectedAction->data().toString().isEmpty() ) { results = idResult; } else { QgsMapLayer* selectedLayer = QgsMapLayerRegistry::instance()->mapLayer( selectedAction->data().toString() ); QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator sIt = mLayerIdResults.find( selectedLayer ); if ( sIt != mLayerIdResults.constEnd() ) { results = sIt.value(); } } } deleteRubberBands(); } else if ( mode == ActiveLayer && layerList.isEmpty() ) { QgsMapLayer *layer = mCanvas->currentLayer(); if ( !layer ) { emit identifyMessage( tr( "No active layer. To identify features, you must choose an active layer." ) ); return results; } QApplication::setOverrideCursor( Qt::WaitCursor ); identifyLayer( &results, layer, mLastPoint, mLastExtent, mLastMapUnitsPerPixel, layerType ); } else { QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); int layerCount; if ( layerList.isEmpty() ) layerCount = mCanvas->layerCount(); else layerCount = layerList.count(); for ( int i = 0; i < layerCount; i++ ) { QgsMapLayer *layer ; if ( layerList.isEmpty() ) layer = mCanvas->layer( i ); else layer = layerList.value( i ); emit identifyProgress( i, mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying on %1..." ).arg( layer->name() ) ); if ( noIdentifyLayerIdList.contains( layer->id() ) ) continue; if ( identifyLayer( &results, layer, mLastPoint, mLastExtent, mLastMapUnitsPerPixel, layerType ) ) { if ( mode == TopDownStopAtFirst ) break; } } emit identifyProgress( mCanvas->layerCount(), mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying done." ) ); } QApplication::restoreOverrideCursor(); return results; }
/** * @brief Assign the appropriate slots to DPad buttons based on the preset item * that was chosen. */ void DPadContextMenu::setDPadPreset() { QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *upButtonSlot = 0; JoyButtonSlot *downButtonSlot = 0; JoyButtonSlot *leftButtonSlot = 0; JoyButtonSlot *rightButtonSlot = 0; JoyButtonSlot *upLeftButtonSlot = 0; JoyButtonSlot *upRightButtonSlot = 0; JoyButtonSlot *downLeftButtonSlot = 0; JoyButtonSlot *downRightButtonSlot = 0; if (item == 0) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 1) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 2) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 3) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 4) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 5) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 6) { if (dpad->getJoyMode() == JoyDPad::StandardMode || dpad->getJoyMode() == JoyDPad::FourWayCardinal) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (dpad->getJoyMode() == JoyDPad::EightWayMode) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } else if (dpad->getJoyMode() == JoyDPad::FourWayDiagonal) { upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } } else if (item == 7) { QHash<int, JoyDPadButton*> *buttons = dpad->getButtons(); QHashIterator<int, JoyDPadButton*> iter(*buttons); while (iter.hasNext()) { JoyDPadButton *button = iter.next().value(); button->clearSlotsEventReset(); } } if (upButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeft); button->clearSlotsEventReset(false); button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRight); button->clearSlotsEventReset(false); button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } }
void MenuCallback::actionInvoked() { QAction* action = qobject_cast<QAction*>(sender()); QString commandId = action->data().toString(); commandInvoked(commandId); }
void TwitterPostWidget::checkAnchor(const QUrl& url) { QString scheme = url.scheme(); TwitterApiMicroBlog* blog = qobject_cast<TwitterApiMicroBlog*>(currentAccount()->microblog()); TwitterApiAccount *account = qobject_cast<TwitterApiAccount*>(currentAccount()); if( scheme == "tag" ) { blog->searchBackend()->requestSearchResults(currentAccount(), KUrl::fromPunycode(url.host().toUtf8()), (int)TwitterSearch::ReferenceHashtag); } else if(scheme == "user") { KMenu menu; KAction * info = new KAction( KIcon("user-identity"), i18nc("Who is user", "Who is %1", url.host()), &menu ); KAction * from = new KAction(KIcon("edit-find-user"), i18nc("Posts from user", "Posts from %1",url.host()), &menu); KAction * to = new KAction(KIcon("meeting-attending"), i18nc("Replies to user", "Replies to %1", url.host()), &menu); KAction *cont = new KAction(KIcon("user-properties"),i18nc("Including user name", "Including %1", url.host()), &menu); KAction * openInBrowser = new KAction(KIcon("applications-internet"), i18nc("Open profile page in browser", "Open profile in browser"), &menu); from->setData(TwitterSearch::FromUser); to->setData(TwitterSearch::ToUser); cont->setData(TwitterSearch::ReferenceUser); menu.addAction(info); menu.addAction(from); menu.addAction(to); menu.addAction(cont); menu.addAction(openInBrowser); //Subscribe/UnSubscribe/Block bool isSubscribe = false; QString accountUsername = currentAccount()->username().toLower(); QString postUsername = url.host().toLower(); KAction *subscribe = 0, *block = 0, *replyTo = 0, *dMessage = 0; if(accountUsername != postUsername){ menu.addSeparator(); QMenu *actionsMenu = menu.addMenu(KIcon("applications-system"), i18n("Actions")); replyTo = new KAction(KIcon("edit-undo"), i18nc("Write a message to user attention", "Write to %1", url.host()), actionsMenu); actionsMenu->addAction(replyTo); if( account->friendsList().contains( url.host(), Qt::CaseInsensitive ) ){ dMessage = new KAction(KIcon("mail-message-new"), i18nc("Send direct message to user", "Send private message to %1", url.host()), actionsMenu); actionsMenu->addAction(dMessage); isSubscribe = false;//It's UnSubscribe subscribe = new KAction( KIcon("list-remove-user"), i18nc("Unfollow user", "Unfollow %1", url.host()), actionsMenu); } else { isSubscribe = true; subscribe = new KAction( KIcon("list-add-user"), i18nc("Follow user", "Follow %1", url.host()), actionsMenu); } block = new KAction( KIcon("dialog-cancel"), i18nc("Block user", "Block %1", url.host()), actionsMenu); actionsMenu->addAction(subscribe); actionsMenu->addAction(block); } QAction * ret = menu.exec(QCursor::pos()); if(ret == 0) return; if(ret == info) { TwitterApiWhoisWidget *wd = new TwitterApiWhoisWidget(account, url.host(), currentPost(), this); wd->show(QCursor::pos()); return; } else if(ret == subscribe){ if(isSubscribe) { blog->createFriendship(currentAccount(), url.host()); } else { blog->destroyFriendship(currentAccount(), url.host()); } return; }else if(ret == block){ blog->blockUser(currentAccount(), url.host()); return; } else if(ret == openInBrowser){ Choqok::openUrl( QUrl( currentAccount()->microblog()->profileUrl(currentAccount(), url.host()) ) ); return; } else if(ret == replyTo){ emit reply( QString("@%1").arg(url.host()), QString() ); return; } else if(ret == dMessage){ blog->showDirectMessageDialog(account,url.host()); return; } int type = ret->data().toInt(); blog->searchBackend()->requestSearchResults(currentAccount(), url.host(), type); } else TwitterApiPostWidget::checkAnchor(url); }
void MainWindow::on_actRecentFile_triggered() { QAction *tAction = qobject_cast<QAction *>(sender()); if (tAction) openFile(tAction->data().toString()); }
void JoyControlStickContextMenu::setStickPreset() { QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *upButtonSlot = 0; JoyButtonSlot *downButtonSlot = 0; JoyButtonSlot *leftButtonSlot = 0; JoyButtonSlot *rightButtonSlot = 0; JoyButtonSlot *upLeftButtonSlot = 0; JoyButtonSlot *upRightButtonSlot = 0; JoyButtonSlot *downLeftButtonSlot = 0; JoyButtonSlot *downRightButtonSlot = 0; if (item == 0) { PadderCommon::inputDaemonMutex.lock(); upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 1) { PadderCommon::inputDaemonMutex.lock(); upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 2) { PadderCommon::inputDaemonMutex.lock(); upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 3) { PadderCommon::inputDaemonMutex.lock(); upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 4) { PadderCommon::inputDaemonMutex.lock(); upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(45); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 5) { PadderCommon::inputDaemonMutex.lock(); upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(45); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 6) { PadderCommon::inputDaemonMutex.lock(); if (stick->getJoyMode() == JoyControlStick::StandardMode || stick->getJoyMode() == JoyControlStick::FourWayCardinal) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (stick->getJoyMode() == JoyControlStick::EightWayMode) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } else if (stick->getJoyMode() == JoyControlStick::FourWayDiagonal) { upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } stick->setDiagonalRange(45); PadderCommon::inputDaemonMutex.unlock(); } else if (item == 7) { QMetaObject::invokeMethod(&helper, "clearButtonsSlotsEventReset"); QMetaObject::invokeMethod(stick, "setDiagonalRange", Q_ARG(int, 45)); }
void DesignerEventHandler::onContextMenu(QContextMenuEvent * e) { QMenu * menu = new QMenu(parentWidget); QAction * copy_action = menu->addAction(tr("Copy"), this, SLOT(onCopy())); menu->addAction(tr("Paste"), this, SLOT(onPaste())); QAction * delete_action = menu->addAction(tr("Delete"), this, SLOT(onDelete())); QAction * delete_with_s_action = menu->addAction(tr("Delete with sourcers"), this, SLOT(onDeleteWithSourcers())); QMenu* go = menu->addMenu(tr("Geometry operations")); go->addAction(tr("Align left") , this, SLOT(onAlignLeft())); go->addAction(tr("Align top") , this, SLOT(onAlignTop())); go->addAction(tr("Align right"), this, SLOT(onAlignRight())); go->addAction(tr("Align bottom"),this, SLOT(onAlignBottom())); go->addAction(tr("Align vertical"),this, SLOT(onAlignVertical())); go->addAction(tr("Align horisontal"), this, SLOT (onAlignHorizontal()) ); go->addAction(tr("Queue x"), this, SLOT (onQuequeX()) ); go->addAction(tr("Queue y"), this, SLOT (onQuequeY()) ); go->insertSeparator(); go->addAction(tr("Same width"), this, SLOT(onSameWidth())); go->addAction(tr("Same height"), this, SLOT(onSameHeight())); QMenu* popupWindows = menu->addMenu(tr("Popup windows")); QMenu* leftButtonPW = popupWindows->addMenu(tr("Left button")); QAction * left_pw_add_action = leftButtonPW->addAction( tr("Add"), this, SLOT(onLeftPwAdd())); QAction * left_pw_copy_action = leftButtonPW->addAction( tr("Copy"), this, SLOT(onLeftPwCopy())); leftButtonPW->addAction( tr("Paste"), this, SLOT(onLeftPwPaste())); QAction * left_pw_delete_action = leftButtonPW->addAction( tr("Delete"), this, SLOT(onLeftDelete())); QMenu* rightButtonPW = popupWindows->addMenu (tr ("Right button")); QAction * right_pw_add_action = rightButtonPW->addAction( tr("Add"), this, SLOT(onRightPwAdd())); QAction * right_pw_copy_action = rightButtonPW->addAction( tr("Copy"), this, SLOT(onRightPwCopy())); rightButtonPW->addAction( tr("Paste"), this, SLOT(onRightPwPaste())); QAction * right_pw_delete_action = rightButtonPW->addAction( tr("Delete"), this, SLOT(onRightDelete())); QAction* show_properties_action = menu->addAction(tr("Properties"), this, SLOT(showProps())); QFont f = show_properties_action->font(); f.setBold(true); show_properties_action->setFont(f); menu->addAction( tr("Export lists"), this, SLOT(onExportLists()) ); //menu->insertSeparator(); QMenu * predef = menu->addMenu ("Predef windows"); QStringList names = PredefPw::Factory::availableNames(); for (QStringList::iterator iter = names.begin(); iter != names.end(); ++iter ) { QAction * a = predef->addAction (*iter); //a->setMenu (predef); a->setData (12345); } menu->addAction ( "Find sourcer", this, SLOT (onFindSourcerByWidget() ) ); if (selected_widgets.count( ) == 0 ){ copy_action->setEnabled(false); delete_action->setEnabled(false); delete_with_s_action->setEnabled(false); go->setEnabled(false); popupWindows->setEnabled(false); } else { VtlWidget * w = (VtlWidget*)checkWidget(e->pos()); if (w) { if (w->isLbPopupCreated()) { left_pw_add_action->setEnabled(false); } else { left_pw_copy_action->setEnabled(false); left_pw_delete_action->setEnabled(false); } if (w->isRbPopupCreated()) { right_pw_add_action->setEnabled(false); } else { right_pw_copy_action->setEnabled(false); right_pw_delete_action->setEnabled(false); } } } if ( context_widget ) context_widget->prepareContextMenu (menu); if (e->state() & Qt::ControlModifier ) control_modifier = true; QAction * a = menu->exec(e->globalPos()); control_modifier = false; if ( a && a->data().toInt() == 12345 ) { QMessageBox box ( vtl::app ); QAbstractButton * left_btn = box.addButton ("Left" , QMessageBox::ActionRole ); QAbstractButton * right_btn = box.addButton ("Right", QMessageBox::ActionRole ); box.setWindowTitle ("Mouse button?"); box.exec (); if ( box.clickedButton() == left_btn ) { for (SWPtrList::iterator iter = selected_widgets.begin(); iter != selected_widgets.end(); ++iter ) { (*iter)->createLbPredefPw ( a->text() ); } } else if (box.clickedButton() == right_btn ) { for (SWPtrList::iterator iter = selected_widgets.begin(); iter != selected_widgets.end(); ++iter ) { (*iter)->createRbPredefPw ( a->text() ); } } } delete menu; }
void SendButton::showItem() { QAction *action = qobject_cast<QAction *>(sender()); if (action) SendWidget::i()->input()->setMsg(action->data().toInt()); }