QString FileReader::readFile(const QString &fileName) { qtTrace() << "FileReader::readFile" << "fileName" << fileName << "adjusted" << adjustPath(fileName); QString content; QFile file(adjustPath(fileName)); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); content = stream.readAll(); } return content; }
QmlWindow::QmlWindow(QUrl qmlSource, bool persistent, QWidget *parent, bool delayViewInit) : QWidget(parent) , m_view(0) , m_source(qmlSource) , m_lastSize(QSize()) , m_exiting(false) , m_persistent(persistent) { m_menuBar = new QMenuBar(0); m_view = new QQuickView(); m_view->connect(m_view->engine(), &QQmlEngine::quit, m_view, &QWindow::close); // Set the OpenGL version // QSurfaceFormat format; // format.setMajorVersion(3); // format.setMinorVersion(3); // format.setProfile(QSurfaceFormat::CoreProfile); // m_view->setFormat(format); // TODO: Remove this hack. Look at this post: // http://www.qtcentre.org/threads/43236-Loading-a-qmldir-from-a-qrc-file?p=198993#post198993 QString libpath = adjustPath(""); qDebug() << "Lib path:" << libpath; m_view->engine()->addImportPath(libpath); if (!delayViewInit) finalizeView(); }
void RDirNode::setParent(RDirNode* parent) { if(parent != 0 && this->parent == parent) return; this->parent = parent; adjustPath(); adjustDepth(); }
static int execute(char *info, FILE *fs, FILE *fh) { char temp[MAX_PATH_LEN]; char opt[256]; char id[50]; char fileIn[MAX_PATH_LEN]; int size; int nbElem; int timing; unsigned char *data; timing = -1; strcpy(opt, ""); nbElem = sscanf(info, "%s %s \"%[^\"]\" %d \"%[^\"]\"", temp, id, temp, &timing, opt); if (nbElem < 3) { printf("Wrong XGM definition\n"); printf("XGM name file [timing [options]]\n"); printf(" name\t\tXGM music variable name\n"); printf(" file\tpath of the .vgm or .xgm music file to convert to binary data array\n"); printf(" timing\tdefine the XGM base timing\n"); printf(" \t -1 (default) = AUTO (NTSC or PAL depending the information in source VGM file)\n"); printf(" \t 0 = NTSC (XGM is generated for NTSC system)\n"); printf(" \t 1 = PAL (XGM is generated for PAL system)\n"); printf(" options\toptionals parameters for xgmtool\n"); printf(" \t ex: \"-dr -di\" to disable some sample auto process (see xgmtool to get more info)\n"); return FALSE; } // adjust input file path adjustPath(resDir, temp, fileIn); strcpy(temp, fileIn); removeExtension(temp); strcat(temp, ".bin"); // convert VGM/XGM to bin if (!xgmtool(fileIn, temp, timing, opt)) { printf("Error while converting '%s' to BIN format\n", fileIn); return FALSE; } // read data from binary file data = in(temp, &size); // clean temp file remove(temp); // error while reading data if (!data) return FALSE; // EXPORT XGM outXGM(data, size, 256, fs, fh, id, TRUE); return TRUE; }
void ModuleMgr::setStoragePath(const std::string& storagePath) { if (_storagePath.size() > 0) _fileUtils->removeDirectory(_storagePath); _storagePath = storagePath; adjustPath(_storagePath); _fileUtils->createDirectory(_storagePath); }
void Kiosek::openQml(const QString &path) { QString new_path=adjustPath(path); QVariant returnedValue; QVariant msg(new_path); QMetaObject::invokeMethod(loader, "openView", Q_RETURN_ARG(QVariant, returnedValue), Q_ARG(QVariant, msg)); }
void AssetsManagerEx::setStoragePath(const std::string& storagePath) { _storagePath = storagePath; adjustPath(_storagePath); _fileUtils->createDirectory(_storagePath); _tempStoragePath = _storagePath; _tempStoragePath.insert(_storagePath.size() - 1, TEMP_PACKAGE_SUFFIX); _fileUtils->createDirectory(_tempStoragePath); }
DeclarativeView::DeclarativeView(QWindow *parent) : QQuickView(parent) { //auto client = new Vreen::Client(this); //auto con = new Vreen::OAuthConnection(1865463, client); //qutIM id //con->setConnectionOption(Vreen::Connection::ShowAuthDialog, true); //con->setDisplayType(Vreen::OAuthConnection::Popup); //client->setConnection(con); //rootContext()->setContextProperty("client", client); setSource(QUrl(adjustPath("qml/main.qml"))); setResizeMode(SizeRootObjectToView); }
void RDirNode::setParent(RDirNode* parent) { if(parent != 0 && this->parent == parent) return; this->parent = parent; adjustPath(); //set depth if(parent == 0) { depth = 1; } else { depth = parent->getDepth() + 1; } }
void Platform::setup() { // Load built-in fonts. QDirIterator it(adjustPath(QLatin1String("fonts"))); while (it.hasNext()) { it.next(); if (it.fileInfo().completeSuffix().toLower() == "ttf") { QFontDatabase::addApplicationFont(it.filePath()); } } // Setup of WebView. setAttribute(Qt::WA_InputMethodEnabled, true); view->setMinimumWidth(800); view->setMinimumHeight(600); QWebSettings *settings = view->settings(); settings->setDefaultTextEncoding("utf-8"); settings->setAttribute(QWebSettings::LocalStorageEnabled, true); settings->setLocalStoragePath(adjustPath(".")); view->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); if (!isDebugMode()) { view->setAcceptDrops(false); view->setContextMenuPolicy(Qt::PreventContextMenu); } else { settings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); } // Setup of Widget. setCentralWidget(view); resize(1000, 700); }
static int execute(char *info, FILE *fs, FILE *fh) { char temp[MAX_PATH_LEN]; char id[50]; char fileIn[MAX_PATH_LEN]; int size; int nbElem; unsigned char *data; nbElem = sscanf(info, "%s %s \"%[^\"]\"", temp, id, temp); if (nbElem < 3) { printf("Wrong VGM definition\n"); printf("VGM name file\n"); printf(" name\t\tVGM music variable name\n"); printf(" file\tpath of the .vgm music file to convert to binary data array\n"); return FALSE; } // adjust input file path adjustPath(resDir, temp, fileIn); strcpy(temp, fileIn); // removeExtension(temp); // strcat(temp, ".tfc"); // // // do TFM conversion // if (!tfmcom(fileIn, temp)) // { // printf("Error while doing VGM conversion on '%s'\n", fileIn); // // return FALSE; // } // read data from VGM file data = in(temp, &size); // error while reading data if (!data) return FALSE; // EXPORT VGM outVGM(data, size, 2, fs, fh, id, TRUE); return TRUE; }
static int execute(char *info, FILE *fs, FILE *fh) { char temp[MAX_PATH_LEN]; char id[50]; char fileIn[MAX_PATH_LEN]; char packedStr[256]; int w, h; int packed; int transInd; int nbElem; tilemap_ *result; packed = 0; transInd = 0; nbElem = sscanf(info, "%s %s \"%[^\"]\" %d %d %s", temp, id, temp, &w, &h, packedStr); if (nbElem < 5) { printf("Wrong MAP definition\n"); printf("MAP name \"file\" width height [packed]\n"); printf(" name Map variable name\n"); printf(" file the map file to convert to Map structure (.map Mappy file)\n"); printf(" width the map width\n"); printf(" height the map height\n"); printf(" packed compression type, accepted values:\n"); printf(" -1 / BEST / AUTO = use best compression\n"); printf(" 0 / NONE = no compression\n"); printf(" 1 / APLIB = aplib library (good compression ratio but slow)\n"); printf(" 2 / FAST / LZ4W = custom lz4 compression (average compression ratio but fast)\n"); return FALSE; } // adjust input file path adjustPath(resDir, temp, fileIn); // get packed value packed = getCompression(packedStr); printf("MAP resource not yet supported !\n"); return FALSE; }
void setupTranslations(QApplication *app, QTranslator *translator) { QString locale = QLocale::system().name(); QString translationsDir = adjustPath("i18n"); qDebug() << "Locale:" << locale << " translationsDir:" << translationsDir; // fall back to using English translation, if one specific to the current // setting of the device is not available. if (!(translator->load("tr_"+locale, translationsDir))) { qDebug() << "Translation for locale " << locale << " not found, loading default english"; if (!translator->load("tr_en", translationsDir)) { qWarning() << "Translation for default english not found either. Annoying."; } else { qDebug() << "Default english translation used for locale " << locale; } } else { qDebug() << "Found translation used for locale " << locale; } app->installTranslator(translator); }
void Platform::boot(const QString core) { QString app = adjustPath(core); if (!isDebugMode() && !QFile::exists(app)) { QMessageBox::critical(this, tr("ThinReportsEditor Booting Error"), "Unable to load application."); exit(0); } view->load(app); setup(); connect(view, SIGNAL(loadFinished(bool)), this, SLOT(init())); connect(view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScript())); connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(view, SIGNAL(linkClicked(QUrl)), this, SLOT(openUrl(QUrl))); show(); }
static int execute(char *info, FILE *fs, FILE *fh) { char temp[MAX_PATH_LEN]; char id[50]; char fileIn[MAX_PATH_LEN]; int ind, size; int w, h, bpp; int nbElem; short *palette; ind = 0; nbElem = sscanf(info, "%s %s \"%[^\"]\" %d", temp, id, temp, &ind); if (nbElem < 3) { printf("Wrong PALETTE definition\n"); printf("PALETTE name file [index]\n"); printf(" name\t\tPalette variable name\n"); printf(" file\tpath of the .pal or image file to convert to Palette structure (should be a 8bpp .bmp or .png)\n"); printf(" index\tstart index where to copy the palette in CRAM\n"); return FALSE; } // adjust input file path adjustPath(resDir, temp, fileIn); // PAL file ? if (!strcasecmp(getFileExtension(fileIn), "pal")) { // get palette data palette = (unsigned short*) readFile(fileIn, &size); size /= 2; } else { // retrieve basic infos about the image if (!Img_getInfos(fileIn, &w, &h, &bpp)) return FALSE; // retrieve palette data palette = Img_getPalette(fileIn, &size); // special case where we use the image as palette if (h == 1) { int i, imgSize; unsigned short *tmpPalette; unsigned char *data; tmpPalette = malloc(size * 2); data = Img_getData(fileIn, &imgSize, 1, 1); // set temp palette from pixel value for(i = 0; i < w; i++) tmpPalette[i] = palette[data[i]]; // then store in palette memcpy(palette, tmpPalette, size * 2); } } // EXPORT PALETTE outPalette(palette, 0, size, fs, fh, id, TRUE); return TRUE; }
static int execute(char *info, FILE *fs, FILE *fh) { char temp[MAX_PATH_LEN]; char id[50]; char fileIn[MAX_PATH_LEN]; int w, h, bpp; int isize, psize; int packed; int transInd; int nbElem; unsigned char *data; unsigned short *palette; unsigned char maxIndex; packed = 0; transInd = 0; nbElem = sscanf(info, "%s %s \"%[^\"]\" %d %d", temp, id, temp, &packed, &transInd); if (nbElem < 3) { printf("Wrong BITMAP definition\n"); printf("BITMAP name \"file\" [packed]\n"); printf(" name\t\tBitmap variable name\n"); printf(" file\tthe image to convert to Bitmap structure (should be a 8bpp .bmp or .png)\n"); printf(" packed\tset to 1 to pack the Bitmap data, by default 0 is assumed.\n\n"); return FALSE; } // adjust input file path adjustPath(resDir, temp, fileIn); // retrieve basic infos about the image if (!Img_getInfos(fileIn, &w, &h, &bpp)) return FALSE; // adjust bitmap size on pixel pair w = ((w + 1) / 2) * 2; // get image data (always 8bpp) data = Img_getData(fileIn, &isize, 2, 1); if (!data) return FALSE; // find max color index maxIndex = getMaxIndex(data, isize); // not allowed here if (maxIndex >= 16) { printf("Error: Image %s use color index >= 16\n", fileIn); printf("BITMAP resource require image with a maximum of 16 colors.\n"); printf("Use 4bpp image instead if you are unsure.\n"); return FALSE; } // convert to 4BPP data = to4bppAndFree(data, isize); isize /= 2; if (!data) return FALSE; // pack data if (packed) { data = pack(data, 0, isize, &isize, &packed); if (!data) return FALSE; } // get palette palette = Img_getPalette(fileIn, &psize); if (!palette) return FALSE; // we keep 16 colors max psize = MIN(16, psize); // EXPORT PALETTE strcpy(temp, id); strcat(temp, "_palette"); outPalette(palette, 0, psize, fs, fh, temp, FALSE); // EXPORT BITMAP outBitmap(data, packed, w, h, isize, fs, fh, id, TRUE); return TRUE; }