QList<QUrl> ExternalPlaylist::readTraktorLibraryPlaylist(const QString& playlistName, const Preferences& prefs){ QMutexLocker locker(&externalPlaylistMutex); QList<QUrl> results; QStringList resultStrings; QString xPath; QStringList params = (QStringList() << "playlistName" << playlistName); #ifndef Q_OS_MAC // QXmlQuery on Windows xPath += "doc($inputDocument)//NODE[@TYPE='PLAYLIST' and @NAME=($playlistName)]"; xPath += "/PLAYLIST[@TYPE='LIST']/ENTRY/PRIMARYKEY/@KEY/string(.)"; #else // XQilla on Mac xPath += "declare variable $playlistName external;"; xPath += "//NODE[@TYPE='PLAYLIST' and @NAME=($playlistName)]"; xPath += "/PLAYLIST[@TYPE='LIST']/ENTRY/PRIMARYKEY/@KEY/string(.)"; #endif resultStrings = executeXmlQuery(prefs.getTraktorLibraryPath(), xPath, params); for(int i=0; i<(signed)resultStrings.size(); i++) results.push_back(fixTraktorAddressing(resultStrings[i])); return results; }
QList<QUrl> ExternalPlaylist::readITunesLibraryPlaylist(const QString& playlistName, const Preferences& prefs){ QMutexLocker locker(&externalPlaylistMutex); QList<QUrl> results; QStringList resultStrings; QString xPath; QStringList params = (QStringList() << "playlistName" << playlistName); #ifndef Q_OS_MAC // QXmlQuery on Windows xPath += "let $d := doc($inputDocument)/plist/dict "; xPath += "for $track in $d/array[preceding-sibling::key[1]='Playlists']"; xPath += "/dict[child::string[preceding-sibling::key[1]='Name'][1]=($playlistName)]"; xPath += "/array/dict/integer[preceding-sibling::key[1]='Track ID'] "; xPath += "return $d/dict[preceding-sibling::key[1]='Tracks']"; xPath += "/dict[preceding-sibling::key[1]=$track]"; xPath += "/string[preceding-sibling::key[1]='Location']/string(text())"; #else // XQilla on Mac xPath += "declare variable $playlistName external;"; xPath += "let $d := plist/dict "; xPath += "for $track in $d/array[preceding-sibling::key[1]='Playlists']"; xPath += "/dict[child::string[preceding-sibling::key[1]='Name'][1]=($playlistName)]"; xPath += "/array/dict/integer[preceding-sibling::key[1]='Track ID'] "; xPath += "return $d/dict[preceding-sibling::key[1]='Tracks']"; xPath += "/dict[preceding-sibling::key[1]=$track]"; xPath += "/string[preceding-sibling::key[1]='Location']/string(text())"; #endif resultStrings = executeXmlQuery(prefs.getITunesLibraryPath(), xPath, params); for(int i=0; i<(signed)resultStrings.size(); i++) results.push_back(fixITunesAddressing(resultStrings[i])); return results; }
QList<ExternalPlaylistObject> ExternalPlaylist::readPlaylistsFromITunesLibrary(const Preferences& prefs){ QMutexLocker locker(&externalPlaylistMutex); QList<ExternalPlaylistObject> results; QStringList resultStrings; QString xPath; QStringList defaultPlaylists = GuiStrings::getInstance()->iTunesDefaultPlaylists(); #ifndef Q_OS_MAC // QXmlQuery on Windows xPath += "doc($inputDocument)/plist/dict"; xPath += "/array[preceding-sibling::key[1]='Playlists']"; xPath += "/dict/string[preceding-sibling::key[1]='Name']/string(text())"; #else // XQilla on Mac xPath += "plist/dict/array[preceding-sibling::key[1]='Playlists']"; xPath += "/dict/string[preceding-sibling::key[1]='Name']/text()"; // likewise in Windows? #endif resultStrings = executeXmlQuery(prefs.getITunesLibraryPath(), xPath); for(int i=0; i<(signed)resultStrings.size(); i++){ if(defaultPlaylists.contains(resultStrings[i])) continue; ExternalPlaylistObject o(resultStrings[i], SOURCE_ITUNES); results.push_back(o); } return results; }
InstrumentNameWidget::InstrumentNameWidget(QWidget* parent) : PixmapWidget( parent, "InstrumentNameWidget" ) { // infoLog( "INIT" ); m_nWidgetWidth = 17; m_nWidgetHeight = 116; Preferences *pref = Preferences::get_instance(); QString family = pref->getMixerFontFamily(); int size = pref->getMixerFontPointSize(); m_mixerFont.setFamily( family ); m_mixerFont.setPointSize( size ); setPixmap( "/mixerPanel/mixerline_label_background.png" ); this->resize( m_nWidgetWidth, m_nWidgetHeight ); }
FxMixerLine::FxMixerLine(QWidget* parent) : PixmapWidget( parent, "FxMixerLine" ) { m_nWidth = MIXERLINE_WIDTH; m_nHeight = MIXERLINE_HEIGHT; setMinimumSize( m_nWidth, m_nHeight ); setMaximumSize( m_nWidth, m_nHeight ); resize( m_nWidth, m_nHeight ); m_fMaxPeak = 0.0; // MixerLine Background image setPixmap( "/mixerPanel/mixerline_background.png" ); // active button activeBtn = new ToggleButton( this, "/mixerPanel/btn_on_on.png", "/mixerPanel/btn_on_off.png", "/mixerPanel/btn_on_over.png", QSize( 18, 12 ) ); activeBtn->move( 2, 5 ); activeBtn->setToolTip( trUtf8( "FX on/off") ); connect( activeBtn, SIGNAL( clicked(Button*) ), this, SLOT( click(Button*) ) ); Preferences *pref = Preferences::get_instance(); // m_pFader m_pFader = new Fader( this, false, false ); m_pFader->move( 22, 106 ); connect( m_pFader, SIGNAL( valueChanged(Fader*) ), this, SLOT( faderChanged(Fader*) ) ); QString family = pref->getMixerFontFamily(); int size = pref->getMixerFontPointSize(); QFont mixerFont( family, size ); m_pNameWidget = new InstrumentNameWidget( this ); m_pNameWidget->move( 2, 106 ); m_pNameWidget->setText( trUtf8( "Master output" ) ); m_pPeakLCD = new LCDDisplay( this, LCDDigit::SMALL_BLUE, 4 ); m_pPeakLCD->move( 2, MIXERLINE_LABEL_H ); m_pPeakLCD->setText( "0.00" ); }
void PlaylistDialog::editScript() { Preferences *pPref = Preferences::get_instance(); if( pPref->getDefaultEditor().isEmpty() ){ QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Default Editor Set. Please set your Default Editor\nDo not use a console based Editor\nSorry, but this will not work for the moment." ) ); static QString lastUsedDir = "/usr/bin/"; QFileDialog fd(this); fd.setFileMode ( QFileDialog::ExistingFile ); fd.setDirectory ( lastUsedDir ); fd.setWindowTitle ( trUtf8 ( "Set your Default Editor" ) ); QString filename; if ( fd.exec() == QDialog::Accepted ){ filename = fd.selectedFiles().first(); pPref->setDefaultEditor( filename ); } } QTreeWidgetItem* pPlaylistItem = m_pPlaylistTree->currentItem(); if ( pPlaylistItem == NULL ){ QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Song selected!" ) ); return; } QString selected; selected = pPlaylistItem->text ( 1 ); QString filename = pPref->getDefaultEditor() + " " + selected + "&"; if( !QFile( selected ).exists() ){ QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Script selected!" )); return; } char *file; file = new char[ filename.length() + 1 ]; strcpy( file , filename.toAscii() ); int ret = std::system( file ); delete [] file; return; }
QStringList writeKeyToFilename(const QString& filename, KeyFinder::key_t key, const Preferences & prefs) { QString dataToWrite = prefs.getKeyCode(key); QFile file(filename); QString path = file.fileName().left(file.fileName().lastIndexOf("/") + 1); QString extn = file.fileName().mid(file.fileName().lastIndexOf(".")); QString name = file.fileName().mid(file.fileName().lastIndexOf("/") + 1); name = name.left(name.length() - extn.length()); QStringList written; QString newName = prefs.newString(dataToWrite, name, METADATA_CHARLIMIT_FILENAME, prefs.getMetadataWriteFilename()); if (newName != "") { name = newName; } if (file.rename(path + name + extn)) { written << path << name << extn; } return written; }
/** * A layer has changed. This can mean that the layer visibility, opacity or * offset changed. */ void MapItem::layerChanged(Layer *layer) { Preferences *prefs = Preferences::instance(); QGraphicsItem *layerItem = mLayerItems.value(layer); Q_ASSERT(layerItem); layerItem->setVisible(layer->isVisible()); qreal multiplier = 1; if (prefs->highlightCurrentLayer() && isAbove(mapDocument()->currentLayer(), layer)) multiplier = opacityFactor; layerItem->setOpacity(layer->opacity() * multiplier); layerItem->setPos(layer->offset()); updateBoundingRect(); // possible layer offset change }
FolderTreeItem::FolderTreeItem( QTreeWidget* parent, Folder* folder, Preferences& prefs, PropertiesPanel* propsPanel ) : TreeItem( (QTreeWidget*) parent ), folder( folder ), prefs( prefs ), propsPanel( propsPanel ) { // It's important to setCheckState() first. Otherwise, if a change is made too soon, // it may reset the markedForStudy property by an event. setCheckState( 0, folder->isMarkedForStudy() ? Qt::Checked : Qt::Unchecked ); setText( 0, folder->getTitle() ); setOpen( prefs.isFolderOpen( folder->getId() ) ); }
/** * If we write a new networktables.ini with some sample values, test that * we get those same values back using the Preference class. */ TEST(PreferencesTest, ReadPreferencesFromFile) { NetworkTable::Shutdown(); std::remove(kFileName); std::ofstream preferencesFile(kFileName); preferencesFile << "[NetworkTables Storage 3.0]" << std::endl; preferencesFile << "string \"/Preferences/testFileGetString\"=\"Hello, preferences file\"" << std::endl; preferencesFile << "double \"/Preferences/testFileGetInt\"=1" << std::endl; preferencesFile << "double \"/Preferences/testFileGetDouble\"=0.5" << std::endl; preferencesFile << "double \"/Preferences/testFileGetFloat\"=0.25" << std::endl; preferencesFile << "boolean \"/Preferences/testFileGetBoolean\"=true" << std::endl; preferencesFile << "double \"/Preferences/testFileGetLong\"=1000000000000000000" << std::endl; preferencesFile.close(); NetworkTable::Initialize(); Preferences* preferences = Preferences::GetInstance(); EXPECT_EQ("Hello, preferences file", preferences->GetString("testFileGetString")); EXPECT_EQ(1, preferences->GetInt("testFileGetInt")); EXPECT_FLOAT_EQ(0.5, preferences->GetDouble("testFileGetDouble")); EXPECT_FLOAT_EQ(0.25f, preferences->GetFloat("testFileGetFloat")); EXPECT_TRUE(preferences->GetBoolean("testFileGetBoolean")); EXPECT_EQ(1000000000000000000ll, preferences->GetLong("testFileGetLong")); }
QString SpinCompiler::objFileName(QString f) { if (f.isEmpty()) return f; QFileInfo info(srcFileName); QString path = info.canonicalPath(); if (!path.isEmpty()) path = path + "/"; path = QDir::toNativeSeparators(path + f); if (QFile::exists(path)) return path; Preferences pref; QStringList paths = pref.getSearchPath(); for (int i=0; i < paths.size(); i++) { path = QDir::toNativeSeparators(paths[i] + "/" + f); if (QFile::exists(path)) return path; } return QDir::toNativeSeparators(f); }
void MapScene::drawForeground(QPainter *painter, const QRectF &rect) { if (!mMapDocument || !mGridVisible) return; QPointF offset; // Take into account the offset of the current layer if (Layer *layer = mMapDocument->currentLayer()) { offset = layer->offset(); painter->translate(offset); } Preferences *prefs = Preferences::instance(); mMapDocument->renderer()->drawGrid(painter, rect.translated(-offset), prefs->gridColor()); }
MapScene::MapScene(QObject *parent): QGraphicsScene(parent), mMapDocument(nullptr), mSelectedTool(nullptr), mActiveTool(nullptr), mUnderMouse(false), mCurrentModifiers(Qt::NoModifier), mDarkRectangle(new QGraphicsRectItem), mDefaultBackgroundColor(Qt::darkGray), mObjectSelectionItem(nullptr) { setBackgroundBrush(mDefaultBackgroundColor); TilesetManager *tilesetManager = TilesetManager::instance(); connect(tilesetManager, SIGNAL(tilesetChanged(Tileset*)), this, SLOT(tilesetChanged(Tileset*))); connect(tilesetManager, SIGNAL(repaintTileset(Tileset*)), this, SLOT(tilesetChanged(Tileset*))); Preferences *prefs = Preferences::instance(); connect(prefs, SIGNAL(showGridChanged(bool)), SLOT(setGridVisible(bool))); connect(prefs, SIGNAL(showTileObjectOutlinesChanged(bool)), SLOT(setShowTileObjectOutlines(bool))); connect(prefs, SIGNAL(objectTypesChanged()), SLOT(syncAllObjectItems())); connect(prefs, SIGNAL(highlightCurrentLayerChanged(bool)), SLOT(setHighlightCurrentLayer(bool))); connect(prefs, SIGNAL(gridColorChanged(QColor)), SLOT(update())); connect(prefs, SIGNAL(objectLineWidthChanged(qreal)), SLOT(setObjectLineWidth(qreal))); mDarkRectangle->setPen(Qt::NoPen); mDarkRectangle->setBrush(Qt::black); mDarkRectangle->setOpacity(darkeningFactor); addItem(mDarkRectangle); mGridVisible = prefs->showGrid(); mObjectLineWidth = prefs->objectLineWidth(); mShowTileObjectOutlines = prefs->showTileObjectOutlines(); mHighlightCurrentLayer = prefs->highlightCurrentLayer(); // Install an event filter so that we can get key events on behalf of the // active tool without having to have the current focus. qApp->installEventFilter(this); }
TilesetView::TilesetView(QWidget *parent) : QTableView(parent) , mZoomable(new Zoomable(this)) , mTilesetDocument(nullptr) , mMarkAnimatedTiles(true) , mEditTerrain(false) , mEraseTerrain(false) , mTerrain(nullptr) , mHoveredCorner(0) , mTerrainChanged(false) , mHandScrolling(false) , mImageMissingIcon(QStringLiteral("://images/32x32/image-missing.png")) { setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setItemDelegate(new TileDelegate(this, this)); setShowGrid(false); QHeaderView *hHeader = horizontalHeader(); QHeaderView *vHeader = verticalHeader(); hHeader->hide(); vHeader->hide(); hHeader->setSectionResizeMode(QHeaderView::ResizeToContents); vHeader->setSectionResizeMode(QHeaderView::ResizeToContents); hHeader->setMinimumSectionSize(1); vHeader->setMinimumSectionSize(1); // Hardcode this view on 'left to right' since it doesn't work properly // for 'right to left' languages. setLayoutDirection(Qt::LeftToRight); Preferences *prefs = Preferences::instance(); mDrawGrid = prefs->showTilesetGrid(); grabGesture(Qt::PinchGesture); connect(prefs, &Preferences::showTilesetGridChanged, this, &TilesetView::setDrawGrid); connect(StyleHelper::instance(), &StyleHelper::styleApplied, this, &TilesetView::updateBackgroundColor); connect(mZoomable, SIGNAL(scaleChanged(qreal)), SLOT(adjustScale())); }
// This function checks if the problem parameters are correct, then tells // Solver to solve the current problem. void solveProblem(const Description & description, const Parameters & parameters, Preferences & preferences, Solver & solver) { // The problem is ready to be solved if the parameters file contains all // the basic parameters. if (parameters.readyToSolve()) { // The parameters are captured and sent to Solver. parameters.capture(description.getGeneralConstraintsNumber(), description.getSurrogateUse(), solver); // The preferences are sent to Solver. preferences.capture(description.getName(), solver); // Data entry complete: Solver evaluates the starting point. if (solver.evaluateStartingPoint() > 0) { // 'fout' is the results file for the current run. ofstream fout(description.getResultsFile()); // The problem's input is written in 'fout'. solver.showInput(fout); // The problem is solved by the optimization module. solver.solveProblem(fout); // The results file is closed. fout.close(); // The 'Preferences' object must be alerted that the run is over. preferences.endOfRun(); } else { cerr << "The starting point is outside the bounds!\n"; cerr << "Please correct before running NOMAD.\n"; cerr << "See the program documentation in the 'DOC' directory.\n\n"; } } else { // We alert the user that something's wrong with the parameters. cerr << "Something is wrong with the parameters!\n"; cerr << "Please correct before running NOMAD.\n"; cerr << "See the program documentation in the 'DOC' directory.\n\n"; } }
void RecentFiles::addFile(QString name) { static QRegExp schemeRE("^[a-zA-Z]{2,5}://"); static QRegExp tempRE("[\\/][Tt]e?mp[\\/]"); if (schemeRE.indexIn(name) == 0) { add(name); } else { QString absPath = QFileInfo(name).absoluteFilePath(); if (tempRE.indexIn(absPath) != -1) { Preferences *prefs = Preferences::getInstance(); if (prefs && !prefs->getOmitTempsFromRecentFiles()) { add(absPath); } } else { add(absPath); } } }
static QString saveObjectTemplate(const MapObject *mapObject) { FormatHelper<ObjectTemplateFormat> helper(FileFormat::ReadWrite); QString filter = helper.filter(); QString selectedFilter = XmlObjectTemplateFormat().nameFilter(); Preferences *prefs = Preferences::instance(); QString suggestedFileName = prefs->lastPath(Preferences::ObjectTemplateFile); suggestedFileName += QLatin1Char('/'); if (!mapObject->name().isEmpty()) suggestedFileName += mapObject->name(); else suggestedFileName += QCoreApplication::translate("Tiled::Internal::MainWindow", "untitled"); suggestedFileName += QLatin1String(".tx"); QWidget *parent = DocumentManager::instance()->widget()->window(); QString fileName = QFileDialog::getSaveFileName(parent, QCoreApplication::translate("Tiled::Internal::MainWindow", "Save Template"), suggestedFileName, filter, &selectedFilter); if (fileName.isEmpty()) return QString(); ObjectTemplateFormat *format = helper.formatByNameFilter(selectedFilter); ObjectTemplate objectTemplate; objectTemplate.setObject(mapObject); if (!format->write(&objectTemplate, fileName)) { QMessageBox::critical(nullptr, QCoreApplication::translate("Tiled::Internal::MainWindow", "Error Saving Template"), format->errorString()); return QString(); } prefs->setLastPath(Preferences::ObjectTemplateFile, QFileInfo(fileName).path()); return fileName; }
TilesetView::TilesetView(QWidget *parent) : QTableView(parent) , mZoomable(0) , mMapDocument(0) , mEditTerrain(false) , mEraseTerrain(false) , mTerrainId(-1) , mHoveredCorner(0) , mTerrainChanged(false) { setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setItemDelegate(new TileDelegate(this, this)); setShowGrid(false); QHeaderView *hHeader = horizontalHeader(); QHeaderView *vHeader = verticalHeader(); hHeader->hide(); vHeader->hide(); #if QT_VERSION >= 0x050000 hHeader->setSectionResizeMode(QHeaderView::ResizeToContents); vHeader->setSectionResizeMode(QHeaderView::ResizeToContents); #else hHeader->setResizeMode(QHeaderView::ResizeToContents); vHeader->setResizeMode(QHeaderView::ResizeToContents); #endif hHeader->setMinimumSectionSize(1); vHeader->setMinimumSectionSize(1); // Hardcode this view on 'left to right' since it doesn't work properly // for 'right to left' languages. setLayoutDirection(Qt::LeftToRight); Preferences *prefs = Preferences::instance(); mDrawGrid = prefs->showTilesetGrid(); grabGesture(Qt::PinchGesture); connect(prefs, SIGNAL(showTilesetGridChanged(bool)), SLOT(setDrawGrid(bool))); }
void BatchRenderThread::start_rendering(char *config_path, char *batch_path) { BC_Hash *boot_defaults; Preferences *preferences; Render *render; ArrayList<PluginServer*> *plugindb; // Initialize stuff which MWindow does. MWindow::init_defaults(boot_defaults, config_path); load_defaults(boot_defaults); preferences = new Preferences; preferences->load_defaults(boot_defaults); MWindow::init_plugins(preferences, plugindb, 0); load_jobs(batch_path, preferences); save_jobs(batch_path); save_defaults(boot_defaults); // Test EDL files for existence if(test_edl_files()) return; // Predict all destination paths ArrayList<char*> paths; calculate_dest_paths(&paths, preferences, plugindb); int result = ConfirmSave::test_files(0, &paths); paths.remove_all_objects(); // Abort on any existing file because it's so hard to set this up. if(result) return; render = new Render(0); render->start_batches(&jobs, boot_defaults, preferences, plugindb); }
void ObjectTypesEditor::applyObjectTypes() { auto &objectTypes = mObjectTypesModel->objectTypes(); Preferences *prefs = Preferences::instance(); prefs->setObjectTypes(objectTypes); QString objectTypesFile = prefs->objectTypesFile(); QDir objectTypesDir = QFileInfo(objectTypesFile).dir(); if (!objectTypesDir.exists()) objectTypesDir.mkpath(QLatin1String(".")); ObjectTypesSerializer serializer; if (!serializer.writeObjectTypes(objectTypesFile, objectTypes)) { QMessageBox::critical(this, tr("Error Writing Object Types"), tr("Error writing to %1:\n%2") .arg(prefs->objectTypesFile(), serializer.errorString())); } }
void PreferencesDialog::setupColors() { Preferences* p = Preferences::getInstance(); setColor(ui->markedVertexColorFrame,p->getMarkedVertexColor()); setColor(ui->vertexColorFrame,p->getVertexColor()); setColor(ui->markedEdgeColorFrame,p->getMarkedEdgeColor()); setColor(ui->edgeColorFrame,p->getEdgeColor()); setColor(ui->markedFacetColorFrame,p->getMarkedFacetColor()); setColor(ui->facetColorFrame,p->getFacetColor()); }
void PreferencesDialog::on_selectMixerFontBtn_clicked() { Preferences *preferencesMng = Preferences::get_instance(); QString family = preferencesMng->getMixerFontFamily(); int pointSize = preferencesMng->getMixerFontPointSize(); bool ok; QFont font = QFontDialog::getFont( &ok, QFont( family, pointSize ), this ); if ( ok ) { // font is set to the font the user selected family = font.family(); pointSize = font.pointSize(); QString familyStr = family; preferencesMng->setMixerFontFamily(familyStr); preferencesMng->setMixerFontPointSize(pointSize); } QFont newFont(family, pointSize); mixerFontLbl->setFont(newFont); mixerFontLbl->setText(family + QString(" %1").arg(pointSize)); }
void QED2KSession::addTransferFromFile(const QString& filename) { if (QFile::exists(filename)) { Preferences pref; libed2k::emule_collection ecoll = libed2k::emule_collection::fromFile( filename.toLocal8Bit().constData()); foreach(const libed2k::emule_collection_entry& ece, ecoll.m_files) { QString filepath = QDir(pref.inputDir()).filePath( QString::fromUtf8(ece.m_filename.c_str(), ece.m_filename.size())); qDebug() << "add transfer " << filepath; libed2k::add_transfer_params atp; atp.file_hash = ece.m_filehash; atp.file_path = filepath.toUtf8().constData(); atp.file_size = ece.m_filesize; addTransfer(atp); } } }
/** handle application closing, WRT XPCE termination */ void pqMainWindow::closeEvent(QCloseEvent *event) { auto t = consoles(); if (t) { for (int c = 0; c < t->count(); ++c) if (!wid2con(t->widget(c))->can_close()) { event->ignore(); return; } } else if (!wid2con(centralWidget())->can_close()) { event->ignore(); return; } { Preferences p; p.saveGeometry(this); } if (!SwiPrologEngine::quit_request()) event->ignore(); }
MapView::MapView(QWidget *parent, Mode mode) : QGraphicsView(parent) , mHandScrolling(false) , mMode(mode) , mZoomable(new Zoomable(this)) { setTransformationAnchor(QGraphicsView::AnchorViewCenter); #ifdef Q_OS_MAC setFrameStyle(QFrame::NoFrame); #endif #ifndef QT_NO_OPENGL Preferences *prefs = Preferences::instance(); setUseOpenGL(prefs->useOpenGL()); connect(prefs, SIGNAL(useOpenGLChanged(bool)), SLOT(setUseOpenGL(bool))); #endif QWidget *v = viewport(); /* Since Qt 4.5, setting this attribute yields significant repaint * reduction when the view is being resized. */ if (mMode == StaticContents) v->setAttribute(Qt::WA_StaticContents); /* Since Qt 4.6, mouse tracking is disabled when no graphics item uses * hover events. We need to set it since our scene wants the events. */ v->setMouseTracking(true); // Adjustment for antialiasing is done by the items that need it setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing); grabGesture(Qt::PinchGesture); setVerticalScrollBar(new FlexibleScrollBar(Qt::Vertical, this)); setHorizontalScrollBar(new FlexibleScrollBar(Qt::Horizontal, this)); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); connect(mZoomable, &Zoomable::scaleChanged, this, &MapView::adjustScale); }
void Preferences::copy(const Preferences& preferences) { for (size_t i = 0; i < KEY_COUNT; ++i) { set_key(i, preferences.key(i)); } set_play_idle_music(preferences.play_idle_music()); set_play_music_in_game(preferences.play_music_in_game()); set_speech_on(preferences.speech_on()); set_volume(preferences.volume()); set_screen_size(preferences.screen_size()); set_scenario_identifier(preferences.scenario_identifier()); }
void MainWindow::openKhollo() { //Try to load directory preferences Preferences pref; QString pref_path = pref.dir(); //Get file name QString fileDB = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", pref_path + QDir::separator(), "KSCOPE (*.kscope)"); if(fileDB == "") { updateWindow(); return; } QString suffix = QFileInfo(fileDB).suffix().toUpper(); // Check the file suffix if(suffix == "KSCOPE") openKhollo(fileDB); // Try to open the file else QMessageBox::critical(this, "Fichier non pris en charge", "Erreur : Fichier " + QFileInfo(fileDB).suffix().toUpper() + " non pris en charge."); return; }
void CameraTest::Execute() { cameraLEDsSubsystem->GreenOn(); cameraLEDsSubsystem->BlueOff(); // Allow time for the LEDs to light up if(!timer->HasPeriodPassed(0.1)) { return; } // min tested was 80ms Preferences * prefs = Preferences::GetInstance(); // Capture an image from the camera and save it to flash timer->Reset(); ColorImage * image; if (prefs->GetInt("image_retain", 1) == 1) { cameraSubsystem->RetainImage("/cameratest.jpg"); image = cameraSubsystem->CaptureImage(); cameraSubsystem->RetainImage(NULL); // stop retaining printf("[CAMERA] Captured image and wrote to /cameratest.jpg in %.1f ms\n", timer->Get() * 1000); } else { image = cameraSubsystem->CaptureImage(); printf("[CAMERA] Captured image in %.1f ms\n", timer->Get() * 1000); } // Load preferences for filtering threshold image Threshold threshold = Threshold(prefs->GetInt("hue_low", 100), prefs->GetInt("hue_high", 140), prefs->GetInt("sat_low", 90), prefs->GetInt("sat_high", 255), prefs->GetInt("lum_low", 20), prefs->GetInt("lum_high", 255)); // Process the captured image timer->Reset(); ImageProcessor * ip = new ImageProcessor(); ip->SetThreshold(threshold); ip->Process(image); printf("[CAMERA] Image processed in %.1f ms\n", timer->Get() * 1000); // Write the processed images to flash if (prefs->GetInt("image_retain", 1) == 1) { timer->Reset(); ip->WriteImages("/cameratest"); printf("[CAMERA] Processed images written to /cameratest.*.bmp in %.1f ms\n", timer->Get() * 1000); } // Generate a target report timer->Reset(); TargetReport * tr = new TargetReport(ip->GetThresholdImage(), ip->GetFilteredImage()); tr->Generate(); printf("[CAMERA] Target report generated in %.1f ms\n", timer->Get() * 1000); tr->OutputScores(); finished = true; delete tr; delete ip; }
void ObjectTypesEditor::importObjectTypes() { Preferences *prefs = Preferences::instance(); const QString lastPath = prefs->lastPath(Preferences::ObjectTypesFile); const QString fileName = QFileDialog::getOpenFileName(this, tr("Import Object Types"), lastPath, tr("Object Types files (*.xml *.json)")); if (fileName.isEmpty()) return; prefs->setLastPath(Preferences::ObjectTypesFile, fileName); ObjectTypesSerializer serializer; ObjectTypes objectTypes; if (serializer.readObjectTypes(fileName, objectTypes)) { ObjectTypes currentTypes = mObjectTypesModel->objectTypes(); for (const ObjectType &type : objectTypes) { auto it = std::find_if(currentTypes.begin(), currentTypes.end(), [&type](ObjectType &existingType) { return existingType.name == type.name; }); if (it != currentTypes.end()) { it->color = type.color; it->defaultProperties.merge(type.defaultProperties); } else { currentTypes.append(type); } } mObjectTypesModel->setObjectTypes(currentTypes); } else { QMessageBox::critical(this, tr("Error Reading Object Types"), serializer.errorString()); } applyObjectTypes(); }
void SongEditorPanel::updatePlaybackFaderPeaks() { Sampler* pSampler = AudioEngine::get_instance()->get_sampler(); Preferences * pPref = Preferences::get_instance(); Instrument* pInstrument = pSampler->__playback_instrument; bool bShowPeaks = pPref->showInstrumentPeaks(); float fallOff = pPref->getMixerFalloffSpeed(); // fader float fOldPeak_L = m_pPlaybackTrackFader->getPeak_L(); float fOldPeak_R = m_pPlaybackTrackFader->getPeak_R(); float fNewPeak_L = pInstrument->get_peak_l(); pInstrument->set_peak_l( 0.0f ); // reset instrument peak float fNewPeak_R = pInstrument->get_peak_r(); pInstrument->set_peak_r( 0.0f ); // reset instrument peak if (!bShowPeaks) { fNewPeak_L = 0.0f; fNewPeak_R = 0.0f; } if ( fNewPeak_L >= fOldPeak_L) { // LEFT peak m_pPlaybackTrackFader->setPeak_L( fNewPeak_L ); } else { m_pPlaybackTrackFader->setPeak_L( fOldPeak_L / fallOff ); } if ( fNewPeak_R >= fOldPeak_R) { // Right peak m_pPlaybackTrackFader->setPeak_R( fNewPeak_R ); } else { m_pPlaybackTrackFader->setPeak_R( fOldPeak_R / fallOff ); } }