QString ScriptObject::executeProcess(bool blocking) { int index = ( states().findIndex( currentState()) ); if (index == -1) { printError(i18n("Invalid state for associated text.")); return QString(); } QString evalText = m_associatedText[index]; if ((KommanderWidget::useInternalParser && !evalText.startsWith("#!")) || evalText.startsWith("#!kommander")) { evalAssociatedText(evalText); return global(widgetName() + "_RESULT"); } else { MyProcess process(this); process.setBlocking(blocking); return process.run(evalAssociatedText(evalText)); } }
void Konsole::execute() { QString at = evalAssociatedText().stripWhiteSpace(); if (mProcess) cancel(); mSeenEOL = false; mProcess = new MyProcess(this); mProcess->setBlocking(false); connect(mProcess, SIGNAL(processExited(MyProcess*)), SLOT(processExited(MyProcess*))); connect(mProcess, SIGNAL(processReceivedStdout(MyProcess*, char*, int)), SLOT(processReceivedStdout(MyProcess*, char*, int))); setCursor(QCursor(Qt::WaitCursor)); mProcess->run(at); }
QString PopupMenu::handleDCOP(int function, const QStringList& args) { switch (function) { case DCOP::clear: m_menu->clear(); m_associations.clear(); break; case DCOP::execute: m_params = args; evalAssociatedText(); break; case INSERTMENUITEM: { uint index = args[2].toInt(); int id = -1; if (args[3].isEmpty()) id = m_menu->insertItem(args[0], index); else id = m_menu->insertItem(KGlobal::iconLoader()->loadIcon(args[3], KIcon::NoGroup, KIcon::SizeMedium), args[0], index); m_associations[id] = args[1]; return QString::number(id); break; } case INSERTSUBMENU: { return insertSubmenu(args[0], args[1], args[2].toInt(), args[3]); break; } case CHANGEMENUITEM: { uint id = args[0].toInt(); if (args[3].isEmpty()) m_menu->changeItem(id, args[1]); else m_menu->changeItem(id, KGlobal::iconLoader()->loadIcon(args[3], KIcon::NoGroup, KIcon::SizeMedium), args[1]); m_associations[id] = args[2]; break; } case INSERTSEPARATOR: { uint index = args[0].toInt(); m_menu->insertSeparator(index); } case SETITEMENABLED: { uint id = args[0].toInt(); m_menu->setItemEnabled(id, args[1] == "true" || args[1] == "1" ? true : false); break; } case ITEMENABLED: { uint id = args[0].toInt(); return m_menu->isItemEnabled(id) ? "1" : "0"; break; } case SETITEMVISIBLE: { uint id = args[0].toInt(); m_menu->setItemVisible(id, args[1] == "true" || args[1] == "1" ? true : false); break; } case SETITEMCHECKED: { uint id = args[0].toInt(); m_menu->setItemChecked(id, args[1] == "true" || args[1] == "1" ? true : false); break; } case ITEMVISIBLE: { uint id = args[0].toInt(); return m_menu->isItemVisible(id) ? "1" : "0"; break; } case ITEMCHECKED: { uint id = args[0].toInt(); return m_menu->isItemChecked(id) ? "1" : "0"; break; } case DCOP::item: { uint index = args[0].toInt(); return index < m_params.count() ? m_params[index] : QString::null; } case DCOP::count: return QString::number(m_menu->count()); default: return KommanderWidget::handleDCOP(function, args); } return QString(); }