本文整理汇总了C++中Preferences类的典型用法代码示例。如果您正苦于以下问题:C++ Preferences类的具体用法?C++ Preferences怎么用?C++ Preferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Preferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
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;
}
示例2: PixmapWidget
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 );
}
示例3: editScript
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;
}
示例4: writeKeyToFilename
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;
}
示例5: layerChanged
/**
* 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
}
示例6: TreeItem
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() ) );
}
示例7: TEST
/**
* 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"));
}
示例8: info
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);
}
示例9: drawForeground
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());
}
示例10: QGraphicsScene
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);
}
示例11: QTableView
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()));
}
示例12: solveProblem
// 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";
}
}
示例13: schemeRE
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);
}
}
}
示例14: saveObjectTemplate
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;
}
示例15: QTableView
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)));
}