bool HMDScriptingInterface::setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const { auto offscreenUi = DependencyManager::get<OffscreenUi>(); offscreenUi->executeOnUiThread([offscreenUi, enabled] { offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); }); return qApp->getActiveDisplayPlugin()->setHandLaser(hands, enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None, color, direction); }
void runProgram(QString path, QString args) { QProcess proc; QStringList largs; QFileInfo info(path); if (path.contains("%")) { path.replace("%u", args); path.replace("%U", args); path.replace("%f", args); path.replace("%F", args); path.replace("%c", path.split(" ")[0]); path.replace("%k", path.split(" ")[0]); args = ""; } QString toRun = path + " " + args; toRun = toRun.simplified(); QString r; // r = "xdg-open \"" + path + "\" " + args + " 2>/dev/null || sh -c \"" + path + "\" " + args; r = "xdg-open \"" + path.trimmed() + "\" " + args.trimmed() + " 2>/dev/null || sh -c \"" + path.trimmed() + " " + args + "\""; // qDebug() << r.simplified(); QStringList ra; ra += "-c"; ra += r.trimmed().simplified(); // qDebug() << ra; // Firefox needs special treatment in KDE // else it falls behind a window if ((path.contains("http://",Qt::CaseInsensitive) || path.contains("firefox",Qt::CaseInsensitive)) && getDesktop() == DESKTOP_KDE) { proc.execute("sh",ra); } else { proc.startDetached("sh",ra); } //proc.execute("sh", ra); return; }
void ePixmap::setPixmapFromFile(const char *filename) { loadPNG(m_pixmap, filename); if (!m_pixmap) { eDebug("ePixmap::setPixmapFromFile: loadPNG failed"); return; } // TODO: This only works for desktop 0 getDesktop(0)->makeCompatiblePixmap(*m_pixmap); event(evtChangedPixmap); }
bool DesktopSelector::selectDesktop(const StringStorage *name) { HDESK desktop; if (name) { desktop = getDesktop(name); } else { desktop = getInputDesktop(); } bool result = setDesktopToCurrentThread(desktop) != 0; closeDesktop(desktop); return result; }
bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enabled, const glm::vec4& color, const glm::vec3& direction) const { auto offscreenUi = DependencyManager::get<OffscreenUi>(); offscreenUi->executeOnUiThread([offscreenUi, enabled] { offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); }); auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); auto sensorToWorld = myAvatar->getSensorToWorldMatrix(); auto worldToSensor = glm::inverse(sensorToWorld); auto sensorStart = ::transformPoint(worldToSensor, worldStart); auto sensorDirection = ::transformVectorFast(worldToSensor, direction); return qApp->getActiveDisplayPlugin()->setExtraLaser(enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None, color, sensorStart, sensorDirection); }
void createRegistry(char *PluginRootKey1) { // ¤«ï ᮪à é¥¨ï ®¡ê¥¬®¢ :-) HKEY hKey; DWORD Disposition, DataSize; int ExitCode; if (RegCreateKeyEx(HKEY_CURRENT_USER,PluginRootKey1,0,NULL,0,KEY_WRITE,NULL,&hKey,&Disposition) == ERROR_SUCCESS) { Opt.AddToDisksMenu=1; RegSetValueEx(hKey,AddToDisksMenu,0,REG_DWORD,(BYTE *)&Opt.AddToDisksMenu,sizeof(Opt.AddToDisksMenu)); Opt.DisksMenuDigit=9; RegSetValueEx(hKey,DisksMenuDigit,0,REG_DWORD,(BYTE *)&Opt.DisksMenuDigit,sizeof(Opt.DisksMenuDigit)); getDesktop(); DataSize=511; RegSetValueEx(hKey,DefaultFolder,0,REG_SZ,Opt.DefaultFolder,lstrlen(Opt.DefaultFolder)+1); RegCloseKey(hKey); } }
void runProgram(QString path, QString args) { QString fullname = path.split(" ")[0]; QFileInfo info(fullname); /* I would argue that launchy does not need to fully support the desktop entry specification yet/ever. NOTE: %c, %k, and %i are handled during loading */ if( path.contains("%") ){ path.replace("%U", args); path.replace("%u", args); path.replace("%F", args); path.replace("%f", args); /* remove specifiers either not yet supported or depricated */ path.remove(QRegExp("%.")); args = ""; } QString cmd; if( !info.isExecutable() || info.isDir() ){ /* if more then one file is passed, then xdg-open will fail.. */ cmd = "xdg-open \"" + path.trimmed() + "\""; }else if(getDesktop() == DESKTOP_KDE) { /* special case for KDE since some apps start behind other windows */ cmd = "kstart --activate " + path.trimmed() + " " + args.trimmed(); } else /* gnome, xfce, etc */ { path.replace("\"", "\\\""); args.replace("\"", "\\\""); cmd = "sh -c \"" + path.trimmed() + " " + args.trimmed() + "\""; } QProcess::startDetached(cmd); return; }
void *DockPlugin::processEvent(Event *e) { CommandDef *def; switch (e->type()){ case EventInit: init(); break; case EventQuit: if (dock){ delete dock; dock = NULL; } break; case EventRaiseWindow: if (e->param() == getMainWindow()){ if (dock == NULL) init(); if (!getShowMain()) return e->param(); } break; case EventCommandCreate: def = (CommandDef*)(e->param()); if (def->menu_id == MenuMain){ CommandDef d = *def; if (def->flags & COMMAND_IMPORTANT){ if (d.menu_grp == 0) d.menu_grp = 0x1001; }else{ d.menu_grp = 0; } d.menu_id = DockMenu; d.bar_id = 0; Event e(EventCommandCreate, &d); e.process(); } break; case EventCheckState: def = (CommandDef*)(e->param()); if (def->id == CmdToggle){ def->flags &= ~COMMAND_CHECKED; def->text = isMainShow() ? I18N_NOOP("Hide main window") : I18N_NOOP("Show main window"); return e->param(); } break; case EventCommandExec: CommandDef *def = (CommandDef*)(e->param()); if (def->id == CmdToggle){ QWidget *main = getMainWindow(); if(!main) return NULL; if (isMainShow()){ setShowMain(false); main->hide(); }else{ inactiveTime = 0; setShowMain(true); raiseWindow(main,getDesktop()); } return e->param(); } if (def->id == CmdCustomize){ Event eCustomize(EventMenuCustomize, (void*)DockMenu); eCustomize.process(); return e->param(); } if (def->id == CmdQuit) bQuit = true; break; } return NULL; }
int eSubtitleWidget::event(int event, void *data, void *data2) { switch (event) { case evtPaint: { ePtr<eWindowStyle> style; gPainter &painter = *(gPainter*)data2; getStyle(style); eWidget::event(event, data, data2); std::string configvalue; int rt_halignment_flag; configvalue = eConfigManager::getConfigValue("config.subtitles.subtitle_alignment"); if (configvalue == "right") rt_halignment_flag = gPainter::RT_HALIGN_RIGHT; else if (configvalue == "left") rt_halignment_flag = gPainter::RT_HALIGN_LEFT; else rt_halignment_flag = gPainter::RT_HALIGN_CENTER; int borderwidth = eConfigManager::getConfigIntValue("config.subtitles.subtitle_borderwidth", 2) * getDesktop(0)->size().width()/1280; int fontsize = eConfigManager::getConfigIntValue("config.subtitles.subtitle_fontsize", 34) * getDesktop(0)->size().width()/1280; if (m_pixmap) { eRect r = m_pixmap_dest; r.scale(size().width(), 720, size().height(), 576); painter.blitScale(m_pixmap, r); } else if (m_page_ok) { unsigned int elements = m_page.m_elements.size(); subtitleStyles[Subtitle_TTX].font->pointSize=fontsize; painter.setFont(subtitleStyles[Subtitle_TTX].font); for (unsigned int i = 0; i < elements; ++i) { eDVBTeletextSubtitlePageElement &element = m_page.m_elements[i]; if (!element.m_text.empty()) { eRect &area = element.m_area; if (!subtitleStyles[Subtitle_TTX].have_foreground_color) painter.setForegroundColor(element.m_color); else painter.setForegroundColor(subtitleStyles[Subtitle_TTX].foreground_color); painter.renderText(area, element.m_text, gPainter::RT_WRAP|gPainter::RT_VALIGN_BOTTOM|rt_halignment_flag, subtitleStyles[Subtitle_TTX].border_color, borderwidth); } } } else if (m_pango_page_ok) { int elements = m_pango_page.m_elements.size(); subfont_t face; for (int i=0; i<elements; ++i) { face = Subtitle_Regular; ePangoSubtitlePageElement &element = m_pango_page.m_elements[i]; std::string text = element.m_pango_line; text = replace_all(text, "'", "'"); text = replace_all(text, """, "\""); text = replace_all(text, "&", "&"); text = replace_all(text, "<", "<"); text = replace_all(text, ">", ">"); if (eConfigManager::getConfigBoolValue("config.subtitles.pango_subtitle_fontswitch")) { if (text.find("<i>") != std::string::npos || text.find("</i>") != std::string::npos) if (text.find("<b>") != std::string::npos || text.find("</b>") != std::string::npos) face = Subtitle_MAX; else face = Subtitle_Italic; else if (text.find("<b>") != std::string::npos || text.find("</b>") != std::string::npos) face = Subtitle_Bold; } int subtitleColors = eConfigManager::getConfigIntValue("config.subtitles.pango_subtitle_colors", 1); if (!subtitleColors) { text = replace_all(text, "<i>", gRGB(255,255,0)); text = replace_all(text, "<b>", gRGB(0,255,255)); text = replace_all(text, "<u>", (std::string) gRGB(0,255,0)); text = replace_all(text, "</i>", (std::string) gRGB(255,255,255)); text = replace_all(text, "</b>", (std::string) gRGB(255,255,255)); text = replace_all(text, "</u>", (std::string) gRGB(255,255,255)); } else { if (subtitleColors == 2) text = (std::string) gRGB(255, 255, 0) + text; text = replace_all(text, "</u>", ""); text = replace_all(text, "</i>", ""); text = replace_all(text, "</b>", ""); text = replace_all(text, "<u>", ""); text = replace_all(text, "<i>", ""); text = replace_all(text, "<b>", ""); } subtitleStyles[face].font->pointSize=fontsize; painter.setFont(subtitleStyles[face].font); eRect &area = element.m_area; if ( !subtitleStyles[face].have_foreground_color && element.m_have_color ) painter.setForegroundColor(element.m_color); else painter.setForegroundColor(subtitleStyles[face].foreground_color); painter.renderText(area, text, gPainter::RT_WRAP|gPainter::RT_VALIGN_BOTTOM|rt_halignment_flag, subtitleStyles[face].border_color, borderwidth); } } else if (m_dvb_page_ok) { for (std::list<eDVBSubtitleRegion>::iterator it(m_dvb_page.m_regions.begin()); it != m_dvb_page.m_regions.end(); ++it) { eRect r = eRect(it->m_position, it->m_pixmap->size()); r.scale(size().width(), m_dvb_page.m_display_size.width(), size().height(), m_dvb_page.m_display_size.height()); painter.blitScale(it->m_pixmap, r); } } return 0; } default: return eWidget::event(event, data, data2); } }
void Mainwindow::on_actionFind_triggered(bool) { getDesktop()->activateFind (); }