void MainWindow::fileSave() { if (! modified) { statusBar()->showMessage(tr("No changes to be saved."), 2000); return; } statusBar()->showMessage(tr("Saving changes...")); { QSettings settings(QLatin1String("QtProject")); settings.beginGroup(QLatin1String("Qt")); QFontDatabase db; QFont font = db.font(ui->fontFamilyCombo->currentText(), ui->fontStyleCombo->currentText(), ui->pointSizeCombo->currentText().toInt()); QStringList actcg, inactcg, discg; bool overrideDesktopSettings = (ui->guiStyleCombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; for (i = 0; i < QPalette::NColorRoles; i++) actcg << editPalette.color(QPalette::Active, QPalette::ColorRole(i)).name(); for (i = 0; i < QPalette::NColorRoles; i++) inactcg << editPalette.color(QPalette::Inactive, QPalette::ColorRole(i)).name(); for (i = 0; i < QPalette::NColorRoles; i++) discg << editPalette.color(QPalette::Disabled, QPalette::ColorRole(i)).name(); } settings.setValue(QLatin1String("font"), font.toString()); settings.setValue(QLatin1String("Palette/active"), actcg); settings.setValue(QLatin1String("Palette/inactive"), inactcg); settings.setValue(QLatin1String("Palette/disabled"), discg); settings.setValue(QLatin1String("fontPath"), fontpaths); settings.setValue(QLatin1String("embedFonts"), ui->fontEmbeddingCheckBox->isChecked()); settings.setValue(QLatin1String("style"), overrideDesktopSettings ? ui->guiStyleCombo->currentText() : QString()); settings.setValue(QLatin1String("doubleClickInterval"), ui->doubleClickIntervalSpinBox->value()); settings.setValue(QLatin1String("cursorFlashTime"), ui->cursorFlashTimeSpinBox->value() == 9 ? 0 : ui->cursorFlashTimeSpinBox->value()); settings.setValue(QLatin1String("wheelScrollLines"), ui->wheelScrollLinesSpinBox->value()); settings.setValue(QLatin1String("resolveSymlinks"), ui->resolveLinksCheckBox->isChecked()); QSize strut(ui->strutWidthSpinBox->value(), ui->strutHeightSpinBox->value()); settings.setValue(QLatin1String("globalStrut/width"), strut.width()); settings.setValue(QLatin1String("globalStrut/height"), strut.height()); settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked()); #ifdef Q_WS_X11 QString style = ui->inputStyleCombo->currentText(); QString str = QLatin1String("On The Spot"); if (style == tr("Over The Spot")) str = QLatin1String("Over The Spot"); else if (style == tr("Off The Spot")) str = QLatin1String("Off The Spot"); else if (style == tr("Root")) str = QLatin1String("Root"); settings.setValue(QLatin1String("XIMInputStyle"), str); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethodCombo->currentText()); #endif QStringList effects; if (ui->effectsCheckBox->isChecked()) { effects << QLatin1String("general"); switch (ui->menuEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } switch (ui->comboEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatecombo"); break; } switch (ui->toolTipEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } switch (ui->toolBoxEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else effects << QLatin1String("none"); settings.setValue(QLatin1String("GUIEffects"), effects); QStringList familysubs = QFont::substitutions(); QStringList::Iterator fit = familysubs.begin(); settings.beginGroup(QLatin1String("Font Substitutions")); while (fit != familysubs.end()) { QStringList subs = QFont::substitutes(*fit); settings.setValue(*fit, subs); fit++; } settings.endGroup(); // Font Substitutions settings.endGroup(); // Qt } #if defined(Q_WS_X11) qt_x11_apply_settings_in_all_apps(); #endif // Q_WS_X11 setModified(false); statusBar()->showMessage(tr("Saved changes.")); }
void MainWindow::fileSave() { if (! modified) { statusBar()->showMessage(tr("No changes to be saved."), 2000); return; } statusBar()->showMessage(tr("Saving changes...")); { QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QFontDatabase db; QFont font = db.font(familycombo->currentText(), stylecombo->currentText(), psizecombo->currentText().toInt()); QStringList actcg, inactcg, discg; bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; for (i = 0; i < QColorGroup::NColorRoles; i++) actcg << editPalette.color(QPalette::Active, (QColorGroup::ColorRole) i).name(); for (i = 0; i < QColorGroup::NColorRoles; i++) inactcg << editPalette.color(QPalette::Inactive, (QColorGroup::ColorRole) i).name(); for (i = 0; i < QColorGroup::NColorRoles; i++) discg << editPalette.color(QPalette::Disabled, (QColorGroup::ColorRole) i).name(); } settings.setValue(QLatin1String("font"), font.toString()); settings.setValue(QLatin1String("Palette/active"), actcg); settings.setValue(QLatin1String("Palette/inactive"), inactcg); settings.setValue(QLatin1String("Palette/disabled"), discg); settings.setValue(QLatin1String("fontPath"), fontpaths); settings.setValue(QLatin1String("embedFonts"), fontembeddingcheckbox->isChecked()); settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString()); settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value()); settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value() ); settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value()); settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked()); QSize strut(strutwidth->value(), strutheight->value()); settings.setValue(QLatin1String("globalStrut/width"), strut.width()); settings.setValue(QLatin1String("globalStrut/height"), strut.height()); settings.setValue(QLatin1String("useRtlExtensions"), rtlExtensions->isChecked()); #ifdef Q_WS_X11 QString style = inputStyle->currentText(); QString str = QLatin1String("On The Spot"); if ( style == trUtf8( "Over The Spot" ) ) str = QLatin1String("Over The Spot"); else if ( style == trUtf8( "Off The Spot" ) ) str = QLatin1String("Off The Spot"); else if ( style == trUtf8( "Root" ) ) str = QLatin1String("Root"); settings.setValue( QLatin1String("XIMInputStyle"), str ); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText()); #endif QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); settings.setValue(QLatin1String("audiosink"), audiosinkCombo->itemData(audiosinkCombo->currentIndex())); settings.setValue(QLatin1String("videomode"), videomodeCombo->itemData(videomodeCombo->currentIndex())); QStringList effects; if (effectcheckbox->isChecked()) { effects << QLatin1String("general"); switch (menueffect->currentItem()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } switch (comboeffect->currentItem()) { case 1: effects << QLatin1String("animatecombo"); break; } switch (tooltipeffect->currentItem()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } switch ( toolboxeffect->currentItem() ) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else effects << QLatin1String("none"); settings.setValue(QLatin1String("GUIEffects"), effects); QStringList familysubs = QFont::substitutions(); QStringList::Iterator fit = familysubs.begin(); settings.beginGroup(QLatin1String("Font Substitutions")); while (fit != familysubs.end()) { QStringList subs = QFont::substitutes(*fit); settings.setValue(*fit, subs); fit++; } settings.endGroup(); // Font Substitutions settings.endGroup(); // Qt } #if defined(Q_WS_X11) qt_x11_apply_settings_in_all_apps(); #endif // Q_WS_X11 setModified(false); statusBar()->showMessage(QLatin1String("Saved changes.")); }
void init(int ac, char **av) { setlocale(LC_NUMERIC, "C"); opt.arg_debug = 0; // default command line args opt.arg_localini = 0; opt.arg_ini[0] = '\0'; opt.arg_font[0] = '\0'; opt.arg_host[0] = '\0'; opt.arg_disable = 0; opt.arg_x = -1; opt.arg_y = -1; opt.arg_w = -1; opt.arg_h = -1; opt.arg_log = 0; opt.arg_fillbackground = 0; for(int i=0; i<ac; i++) // read command line args { if(strncmp(av[i],"-h",2) == 0 || strncmp(av[i],"--",2) == 0) { printf("pvbrowser %s (C) Lehrig Software Engineering, [email protected]\n", VERSION); printf("usage: pvbrowser <-debug<=level>> <-log> <-ini=filename> <-font=name<:size>> <host<:port></mask>> <-disable> <-geometry=x:y:w:h> <-global_strut=width:height> <-delay=milliseconds>\n"); printf("example: pvbrowser\n"); printf("example: pvbrowser localhost\n"); printf("example: pvbrowser localhost:5050\n"); printf("example: pvbrowser -font=courier localhost\n"); printf("example: pvbrowser -font=arial:14 localhost:5050 -disable\n"); printf("example: pvbrowser -geometry=0:0:640:480\n"); printf("example: pvbrowser -global_strut=50:50 # set minimum size for embedded systems\n"); exit(0); } if(strncmp(av[i],"-debug",6) == 0) { opt.arg_debug = 1; // print debugging info if(strncmp(av[i],"-debug=",7) == 0) { sscanf(av[i],"-debug=%d",&opt.arg_debug); } } if(strncmp(av[i],"-log",4) == 0) { opt.arg_log = 1; // print logging info } if(strncmp(av[i],"-fillbackground",15) == 0) { opt.arg_fillbackground = 1; // murnleitner special } if(strncmp(av[i],"-ini=",5) == 0) { if(strlen(av[i]) < MAXOPT) { const char *arg = av[i]; opt.arg_localini = 1; // use inifile in local directory strcpy(opt.arg_ini,&arg[5]); } } if(strncmp(av[i],"-font=",6) == 0) { sscanf(av[i],"-font=%s",opt.arg_font); // use font from command line } if(strncmp(av[i],"-disable",8) == 0) { opt.arg_disable = 1; // disable some menus } if(strncmp(av[i],"-geometry=",10) == 0) { sscanf(av[i],"-geometry=%d:%d:%d:%d",&opt.arg_x,&opt.arg_y,&opt.arg_w,&opt.arg_h); // define geometry of window } if(i>0 && strncmp(av[i],"-",1) != 0) { strcpy(opt.arg_host,av[i]); } if(strncmp(av[i],"-delay=",7) == 0) // delay startup by milliseconds { int delay = 0; sscanf(av[i],"-delay=%d", &delay); if(delay < 0) delay = 0; if(opt.arg_debug) printf("delay startup by %d milliseconds\n", delay); tcp_sleep(delay); } if(strncmp(av[i],"-global_strut=",14) == 0) // set minimum size of some widgets on embedded systems { int width,height; sscanf(av[i],"-global_strut=%d:%d", &width, &height); QSize strut(width,height); QApplication::setGlobalStrut(strut); } } }
void Boid::update(std::vector<Boid *> *boids, ofVec2f * people, int numPeople) { // track positions if (tailLen > 0) { for (int i = tailLen - 1; i > 0; i--) lastPos[i] = lastPos[i-1]; lastPos[0] = pos; } neighbors.clear(); for (int i = 0; i < boids->size(); i++) { Boid *other = (*boids)[i]; if (other != this && pos.squareDistance(other->pos) < maxDist*maxDist) { neighbors.push_back(other); } } int neighborCount = neighbors.size(); if (neighborCount > 0) { ofVec2f v1, v2, v3; if (neighborCount < 4) { if (!personNearby && stayOn) v1 = cohesion(cohesionScalar); else v1 = cohesion(-cohesionScalar*2); v2 = alignment(alignmentScalar); } v3 = separation(separationScalar, minDist); vel += v1 + v2 + v3; } if (numPeople > 0) { if (!personNearby && stayOn) { runAwayVec = people[0]; //cout << "run away vec " << runAwayVec.x << ", " << runAwayVec << "\n\n\n"; personNearby = true; } ofVec2f v4 = fear(fearScalar, runAwayVec); vel += v4; } else personNearby = false; if (!stayOn) { ofVec2f v5 = stayOff(tableCenter); vel += v5; } strutVel = strut(strutScalar * vel.length(), strutFreq); //ofLog(OF_LOG_NOTICE, "%f %f is strutvel", strutVel.x, strutVel.y); if (!personNearby && stayOn) { if (pos.x > maxX - 1.1 * radius) vel.x -= (pos.x - (maxX - 1.1 * radius)) * 0.09; if (pos.x < minX + 1.1 * radius) vel.x += ((minX + 1.1 * radius) - pos.x) * 0.09; if (pos.y > maxY - 1.1 * radius) vel.y -= (pos.y - (maxY - 1.1 * radius)) * 0.09; if (pos.y < minY + 1.1 * radius) vel.y += ((minY + 1.1 * radius) - pos.y) * 0.09; // maintain a max speed vel.limit(0.8f); } else vel.limit(2.5f); if (pos.distanceSquared(tableCenter) > maxDistFromTable*maxDistFromTable) { ofVec2f difference = pos - tableCenter; difference.rescale(maxDistFromTable); pos = tableCenter + difference; } }