QString MenuContentItem::loadDescription(int startPara, int nrPara) { QString result; QFile readme(this->readmePath); if (!readme.open(QFile::ReadOnly)){ if (Colors::verbose) qDebug() << "- MenuContentItem::loadDescription: Could not load:" << this->readmePath; return ""; } QTextStream in(&readme); // Skip a certain number of paragraphs: while (startPara) if (in.readLine().isEmpty()) --startPara; // Read in the number of wanted paragraphs: QString line = in.readLine(); do { result += line + " "; line = in.readLine(); if (line.isEmpty()){ --nrPara; line = "<br><br>" + in.readLine(); } } while (nrPara && !in.atEnd()); return Colors::contentColor + result; }
void Window::createActions(void) { saveAct = new QAction(tr("&Save..."), this); saveAct->setShortcut(QKeySequence::Save); saveAct->setStatusTip(tr("Save rendered image")); saveAct->setDisabled(true); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcut(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); rsAct = new QAction(tr("&Read scene"), this); rsAct->setStatusTip(tr("Read serialized scene")); connect(rsAct, SIGNAL(triggered()), this, SLOT(readScene())); wsAct = new QAction(tr("&Write scene"), this); wsAct->setStatusTip(tr("Write serialized scene")); connect(wsAct, SIGNAL(triggered()), this, SLOT(writeScene())); readmeAct = new QAction(tr("&ReadMe"), this); readmeAct->setStatusTip(tr("Show ReadMe information")); readmeAct->setDisabled(true); connect(readmeAct, SIGNAL(triggered()), this, SLOT(readme())); aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); }
void ScriptManager::slotAboutScript() { const QString name = m_gui->listView->currentItem()->text( 0 ); QFile readme( m_scripts[name].url.directory( false ) + "README" ); QFile license( m_scripts[name].url.directory( false ) + "COPYING" ); if( !readme.open( IO_ReadOnly ) ) { KMessageBox::sorry( 0, i18n( "There is no information available for this script." ) ); return; } KAboutDialog* about = new KAboutDialog( KAboutDialog::AbtTabbed|KAboutDialog::AbtProduct, QString::null, KDialogBase::Ok, KDialogBase::Ok, this ); kapp->setTopWidget( about ); about->setCaption( kapp->makeStdCaption( i18n( "About %1" ).arg( name ) ) ); about->setProduct( "", "", "", "" ); // Get rid of the confusing KDE version text QLabel* product = static_cast<QLabel*>( about->mainWidget()->child( "version" ) ); if( product ) product->setText( i18n( "%1 Amarok Script" ).arg( name ) ); about->addTextPage( i18n( "About" ), readme.readAll(), true ); if( license.open( IO_ReadOnly ) ) about->addLicensePage( i18n( "License" ), license.readAll() ); about->setInitialSize( QSize( 500, 350 ) ); about->show(); }
void Application::startScripting() { //this should be defined in some kind of text file, which should be different depending on what game you're playing (like deeds) try { //load the bootstrap script which will load all other scripts mServices->getScriptingService().loadScript("lua/Bootstrap.lua"); } catch (const std::exception& e) { S_LOG_FAILURE("Error when loading bootstrap script." << e); } //load any user defined scripts const std::string userScriptDirectoryPath = mServices->getConfigService().getHomeDirectory() + "/scripts"; oslink::directory scriptDir(userScriptDirectoryPath); if (scriptDir.isExisting()) { static const std::string luaSuffix = ".lua"; std::list<std::string> luaFiles; while (scriptDir) { std::string fileName = scriptDir.next(); if (fileName != "." && fileName != "..") { std::string lowerCaseFileName = fileName; std::transform(lowerCaseFileName.begin(), lowerCaseFileName.end(), lowerCaseFileName.begin(), ::tolower); if (lowerCaseFileName.compare(lowerCaseFileName.length() - luaSuffix.length(), luaSuffix.length(), luaSuffix) == 0) { luaFiles.push_back(fileName); } } } //Sorting, because we want to load the scripts in a deterministic order. luaFiles.sort(); for (auto& fileName : luaFiles) { std::ifstream stream(userScriptDirectoryPath + "/" + fileName, std::ios::in); if (stream) { std::stringstream ss; ss << stream.rdbuf(); stream.close(); //It's important that we inform the user that we're loading a script (in case it provides any confusing behaviour). ConsoleBackend::getSingleton().pushMessage("Loading user Lua script from '" + fileName + "'.", "info"); mServices->getScriptingService().executeCode(ss.str(), "LuaScriptingProvider"); } } } else { try { //Create the script user script directory oslink::directory::mkdir(userScriptDirectoryPath.c_str()); std::ofstream readme(userScriptDirectoryPath + "/README", std::ios::out); readme << "Any script files placed here will be executed as long as they have a supported file suffix.\nScripts are executed in alphabetical order.\nEmber currently supports lua scripts (ending with '.lua')."; readme.close(); S_LOG_INFO("Created user user scripting directory (" + userScriptDirectoryPath + ")."); } catch (const std::exception& e) { S_LOG_INFO("Could not create user scripting directory."); } } }
int CDlgAbout::AppendFile(QTextEdit* pEdit, const QString &szFile) { QFile readme(szFile); if(readme.open(QFile::ReadOnly)) { pEdit->append(readme.readAll()); //把光标移动文档开始处 QTextCursor cursor = pEdit->textCursor(); cursor.movePosition(QTextCursor::Start); pEdit->setTextCursor(cursor); readme.close(); } return 0; }
int main (int argc, char **argv) { user = argv[1]; if (!user) usage(); loguser = argv[2]; if (!loguser) usage(); dir = argv[3]; if (!dir) usage(); if (dir[0] != '/') usage(); ip = argv[4]; if (!ip) ip = "0"; pw = getpwnam(loguser); if (!pw) strerr_die3x(TEMP, FATAL, "unknown account ", loguser); if (!readme(&me)) strerr_die1(TEMP, FATAL, &readme_err); init(dir, FATAL); makelogdir(loguser, pw->pw_uid, -1); makedir("env"); perm(02755); start("env/DATALIMIT"); outs("250000\n"); finish(); perm(0644); tcpserver_env(ip, PORT, me.s); makemakefile(); maketcp(1); makeaddclient(); start("run"); outs("#!/bin/sh\n"); tcpserver_run(user, PORT); outs(" "); outs(auto_qmail); outs("/bin/qmail-qmqpd\n"); outs("'\n"); finish(); perm(0755); _exit(0); return 0; }
About::About(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) { // stuff setWindowTitle("About LibreLibreCell"); QLabel *versionLabel = new QLabel(QString("Git revision: %1").arg(LIBRELIBRECELL_VERSION)); QPlainTextEdit *aboutBox = new QPlainTextEdit; QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); QVBoxLayout *vLayout = new QVBoxLayout; vLayout->addWidget(versionLabel); vLayout->addWidget(aboutBox, 1); vLayout->addSpacing(10); vLayout->addWidget(buttonBox); setLayout(vLayout); aboutBox->setReadOnly(true); aboutBox->setTabChangesFocus(true); aboutBox->setWordWrapMode(QTextOption::NoWrap); aboutBox->setLineWrapMode(QPlainTextEdit::NoWrap); aboutBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); aboutBox->setFont(QFont("Monospace", 10)); QFile readme(":/README.txt"); if (readme.open(QIODevice::ReadOnly)) { QTextStream stream(&readme); aboutBox->setPlainText(stream.readAll()); readme.close(); } else { aboutBox->setPlainText("Could not open README.txt."); } QFontMetrics fm(aboutBox->font()); aboutBox->setMinimumSize(fm.width(QLatin1Char('m')) * 76, 450); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); }
int main(int argc, char **argv) { if(argc < 5) { readme(); return 1; } int i=1; while(i<argc) { if(strcmp(argv[i],"-file")==0) { imageFileName = argv[++i]; } if(strcmp(argv[i],"-map")==0) { xmlFileName = argv[++i]; } i++; } imgMat = cv::imread(imageFileName, 1); OpenCvUtils *cvUtils = new OpenCvUtils(); ImageMapParserCallback *parserCallback = new ImageMapParserCallback(); parserCallback->setImgMat(&imgMat); parserCallback->setCvUtils(cvUtils); ImageMapParser *parser = new ImageMapParser(); parser->setParserCallback(parserCallback); parser->setXmlFileName(xmlFileName); parser->Parse(); std::list<DataModel::AreaElementResult*> parsingResult = parserCallback->getResult(); std::list<DataModel::AreaElementResult*>::iterator it; it = parsingResult.begin(); while (it != parsingResult.end()) { std::cout << (**it).id << ":" << (**it).value << " " << (**it).x << " " << (**it).y << std::endl; it++; } return 0; }
int loadbmp(char *filename, unsigned char **buf, int *w, int *h, enum BMPPIXELFORMAT f, int align, int dstbottomup) { int fd=-1, bytesread, srcpitch, srcbottomup=1, srcps, dstpitch, retcode=0; unsigned char *tempbuf=NULL; bmphdr bh; int flags=O_RDONLY; dstbottomup=dstbottomup? 1:0; #ifdef _WIN32 flags|=O_BINARY; #endif if(!filename || !buf || !w || !h || f<0 || f>BMPPIXELFORMATS-1 || align<1) _throw("invalid argument to loadbmp()"); if((align&(align-1))!=0) _throw("Alignment must be a power of 2"); _unix(fd=open(filename, flags)); readme(fd, &bh.bfType, sizeof(unsigned short)); if(!littleendian()) bh.bfType=byteswap16(bh.bfType); if(bh.bfType==0x3650) { _catch(loadppm(&fd, buf, w, h, f, align, dstbottomup, 0)); goto finally; } if(bh.bfType==0x3350) { _catch(loadppm(&fd, buf, w, h, f, align, dstbottomup, 1)); goto finally; } readme(fd, &bh.bfSize, sizeof(unsigned int)); readme(fd, &bh.bfReserved1, sizeof(unsigned short)); readme(fd, &bh.bfReserved2, sizeof(unsigned short)); readme(fd, &bh.bfOffBits, sizeof(unsigned int)); readme(fd, &bh.biSize, sizeof(unsigned int)); readme(fd, &bh.biWidth, sizeof(int)); readme(fd, &bh.biHeight, sizeof(int)); readme(fd, &bh.biPlanes, sizeof(unsigned short)); readme(fd, &bh.biBitCount, sizeof(unsigned short)); readme(fd, &bh.biCompression, sizeof(unsigned int)); readme(fd, &bh.biSizeImage, sizeof(unsigned int)); readme(fd, &bh.biXPelsPerMeter, sizeof(int)); readme(fd, &bh.biYPelsPerMeter, sizeof(int)); readme(fd, &bh.biClrUsed, sizeof(unsigned int)); readme(fd, &bh.biClrImportant, sizeof(unsigned int)); if(!littleendian()) { bh.bfSize=byteswap(bh.bfSize); bh.bfOffBits=byteswap(bh.bfOffBits); bh.biSize=byteswap(bh.biSize); bh.biWidth=byteswap(bh.biWidth); bh.biHeight=byteswap(bh.biHeight); bh.biPlanes=byteswap16(bh.biPlanes); bh.biBitCount=byteswap16(bh.biBitCount); bh.biCompression=byteswap(bh.biCompression); bh.biSizeImage=byteswap(bh.biSizeImage); bh.biXPelsPerMeter=byteswap(bh.biXPelsPerMeter); bh.biYPelsPerMeter=byteswap(bh.biYPelsPerMeter); bh.biClrUsed=byteswap(bh.biClrUsed); bh.biClrImportant=byteswap(bh.biClrImportant); } if(bh.bfType!=0x4d42 || bh.bfOffBits<BMPHDRSIZE || bh.biWidth<1 || bh.biHeight==0) _throw("Corrupt bitmap header"); if((bh.biBitCount!=24 && bh.biBitCount!=32) || bh.biCompression!=BI_RGB) _throw("Only uncompessed RGB bitmaps are supported"); *w=bh.biWidth; *h=bh.biHeight; srcps=bh.biBitCount/8; if(*h<0) {*h=-(*h); srcbottomup=0;} srcpitch=(((*w)*srcps)+3)&(~3); dstpitch=(((*w)*ps[f])+(align-1))&(~(align-1)); if(srcpitch*(*h)+bh.bfOffBits!=bh.bfSize) _throw("Corrupt bitmap header"); if((tempbuf=(unsigned char *)malloc(srcpitch*(*h)))==NULL || (*buf=(unsigned char *)malloc(dstpitch*(*h)))==NULL) _throw("Memory allocation error"); if(lseek(fd, (long)bh.bfOffBits, SEEK_SET)!=(long)bh.bfOffBits) _throw(strerror(errno)); _unix(bytesread=read(fd, tempbuf, srcpitch*(*h))); if(bytesread!=srcpitch*(*h)) _throw("Read error"); pixelconvert(tempbuf, BMP_BGR, srcpitch, *buf, f, dstpitch, *w, *h, srcbottomup!=dstbottomup); finally: if(tempbuf) free(tempbuf); if(fd!=-1) close(fd); return retcode; }
//------------------------------------------------------------------------------------- // Name: main() // Desc: The application's entry point //------------------------------------------------------------------------------------- void __cdecl main() { CSimpleIniA ini(true, true, true); std::map<std::string, bool> Settings; Utilities u; // Try mounting the game directory; at console startup it's not mounted u.MountGameDirectory(); if (ini.LoadFile("g:\\settings.ini") < 0) { ini.Reset(); std::string IniText( " LaunchCode was created by CLK.\n\n" \ " What can this app do?\n" \ " - Remove console signature checks\n" \ " - Remove RSA signature checks\n" \ " - Set RoL LEDs\n" \ " - Remove profile breakpoints (freezing when viewing some profiles)\n"\ " - Remove XampHeapAllocExplicit breakpoints (some bullshit)\n" \ " - Enable hidden partitions for Xbox 360 Neighborhood\n" \ " - Add additional, customizable partitions to Neighborhood\n" \ " - Set the default account password for PartnerNet accounts\n" \ " - Set the display gamertag\n" \ " - Make the console think you have a gold membership\n" \ " -> Instructions/Limitations:\n" \ " - Account password length must not exceed 11 characters.\n"\ " - Each Neighborhood partition should match the following" \ "criteria, otherwise it will not be mounted:\n" \ " ~ NeighborhoodName must not exceed 35 characters\n" \ " ~ DevicePath must not exceed 61 characters\n" \ " ~ DevicePath must be formatted as so:\n" \ " - \"\\Device\\Harddisk0\\Partition1\\Devikit\"\n" \ " - The following are all valid basic paths:\n" \ " - \\Device\n" \ " - \\Device\\Harddisk0\\SystemPartition\n" \ " - \\Device\\Harddisk0\\Partition1\n" \ " - \\Device\\Flash\n" \ " - \\Device\\Mu0System\n" \ " - \\Device\\Mu1System\n" \ " - \\Device\\Mass0\n" \ " - \\Device\\Mass1\n" \ " - \\Device\\Mass2\n" \ " - \\Device\\BuiltInMuSfcSystem\n" \ " - \\Device\\Harddisk\\SystemExtPartition\n" \ " - \\Device\\Harddisk\\SystemAuxPartition\n" \ " - \\Device\\BuiltInMuUsb\\Storage\n" \ " - \\Device\\BuiltInMuUsb\\StorageSystem\n" \ " - \\Device\\BuiltInMuUsb\\SystemExtPartition\n" \ " - \\Device\\BuiltInMuUsb\\SystemAuxPartition\n" \ " - \\Device\\BuiltInMuMmc\\Storage\n" \ " - \\Device\\BuiltInMuMmc\\StorageSystem\n" \ " - \\Device\\BuiltInMuMmc\\SystemExtPartition\n" \ " - \\Device\\BuiltInMuMmc\\SystemAuxPartition\n" \ " - \\Device\\HdDvdRom\n" \ " - \\Device\\HdDvdStorage\n" \ " - \\Device\\HdDvdPlayer\n" \ " - \\Device\\TransferCable\n" \ " - \\Device\\Mass0PartitionFile\\Storage\n" \ " - \\Device\\Mass1PartitionFile\\Storage\n" \ " - \\Device\\Mass0PartitionFile\\StorageSystem\n" \ " - \\Device\\Mass1PartitionFile\\StorageSystem\n" \ " - \\Device\\Harddisk0\\Cache0\n" \ " - \\Device\\Harddisk0\\Cache1\n" \ " - \\Device\\NetworkStorageCache\n" \ " - \\Device\\UpdateStorage\n" \ " - \\Device\\Harddisk0\\TitleURLCachePartition\n" \ " - \\Device\\DeviceAuth\n" \ " - \\Device\\BuiltInMuUsb\\ReservationPartition\n" \ " - \\Device\\LauncherData\n" \ "\n\n\n\nGreets to the following people:\n" \ "gabe_k, Xenon.7 (Xenomega), paul (British dude), rickshaw, skitzo, kiwi, dual\n" \ "yolo." ); std::fstream readme("g:\\readme.txt", std::ios::trunc | std::ios::in | std::ios::out); readme << IniText; readme.close(); ini.SetBoolValue("settings", "SetLeds", true); ini.SetBoolValue("settings", "PatchRsaPubCrypt", true); ini.SetBoolValue("settings", "RemoveConsoleSignatureChecks", true); ini.SetBoolValue("settings", "RemovePackageRsaChecks", true); ini.SetBoolValue("settings", "RemoveProfileBreakpoints", true); ini.SetBoolValue("settings", "RemoveXampHeapAllocExplicitBreakpoints", true); ini.SetBoolValue("settings", "SetAsStartupApplication", true); ini.SetBoolValue("settings", "EnableHiddenPartitions", true); ini.SetBoolValue("settings", "EnableExtraNeighborhoodDrives", true); ini.SetBoolValue("settings", "SetGamertag", true); ini.SetBoolValue("settings", "SetGoldMembership", true); ini.SetBoolValue("settings", "EnableXamWatsonOutput", true); ini.SetValue("Network", "AccountCreatePassword", "meth=friend"); ini.SetValue("Network", "OnlineGamertag", "[test]DRUG DEALER"); // MODIFY THIS LINE TO YOUR DEFAULT GAMERTAG //ini.SetBoolValue("xshell", "WriteCustomBackground", false); //ini.SetValue("xshell", "DevKitBackground", "bg_image_blue.png"); //ini.SetValue("xshell", "TestKitBackground", "bg_image_gray.png"); ini.SetValue("LEDs", "TopLeft", "Inverted"); ini.SetValue("LEDs", "TopRight", "Normal"); ini.SetValue("LEDs", "BottomLeft", "Mix"); ini.SetValue("LEDs", "BottomRight", "Off"); ini.SetValue("NeighborhoodDrive1", "DevicePath", ""); ini.SetValue("NeighborhoodDrive1", "NeighborhoodName", ""); ini.SetValue("NeighborhoodDrive2", "DevicePath", ""); ini.SetValue("NeighborhoodDrive2", "NeighborhoodName", ""); ini.SetValue("NeighborhoodDrive3", "DevicePath", ""); ini.SetValue("NeighborhoodDrive3", "NeighborhoodName", ""); ini.SetValue("NeighborhoodDrive4", "DevicePath", ""); ini.SetValue("NeighborhoodDrive4", "NeighborhoodName", ""); ini.SaveFile("g:\\settings.ini"); ini.LoadFile("g:\\settings.ini"); } CSimpleIniA::TNamesDepend keys; ini.GetAllKeys("settings", keys); CSimpleIniA::TNamesDepend::iterator it; for (it = keys.begin(); it != keys.end(); it++) { const char *key = ((*it).pItem); bool Enabled = ini.GetBoolValue("settings", key, NULL); Settings[std::string(key)] = Enabled; } keys.clear(); ini.GetAllKeys("Network", keys); NetworkSettings ns; for (it = keys.begin(); it != keys.end(); it++) { std::string key((*it).pItem); std::string value = ini.GetValue("Network", key.c_str(), NULL); if (key == "AccountCreatePassword") ns.AccountCreationPassword = value; else if (key == "OnlineGamertag") ns.Gamertag = value; } std::vector<Utilities::Drive> drl; char Section[20] = {0}; for (int i = 1; i < 5; i++) { keys.clear(); sprintf(Section, "NeighborhoodDrive%d", i); ini.GetAllKeys(Section, keys); Utilities::Drive d; for (it = keys.begin(); it != keys.end(); it++) { std::string key = ((*it).pItem); std::string value = ini.GetValue(Section, key.c_str(), NULL); if (key == "NeighborhoodName") d.NeighborhoodName = value; else if(key == "DevicePath") d.Path = value; } if (!d.NeighborhoodName.size() || !d.Path.size()) continue; else drl.push_back(d); } if (Settings[std::string("SetLeds")]) { LEDState TL = LEDState::ORANGE, TR = LEDState::RED, BL = LEDState::ORANGE, BR = LEDState::RED; keys.clear(); ini.GetAllKeys("LEDs", keys); for (it = keys.begin(); it != keys.end(); it++) { std::string key(((*it).pItem)); std::string value(ini.GetValue("LEDs", key.c_str(), NULL)); LEDState *CurrentLed = nullptr; if (key == "TopLeft") CurrentLed = &TL; else if (key == "TopRight") CurrentLed = &TR; else if (key == "BottomLeft") CurrentLed = &BL; else if (key == "BottomRight") CurrentLed = &BR; if (CurrentLed == nullptr) continue; if (value == "Inverted") *CurrentLed = LEDState::RED; else if (value == "Normal") *CurrentLed = LEDState::GREEN; else if (value == "Mix") *CurrentLed = LEDState::ORANGE; else if (value == "Off") *CurrentLed = LEDState::OFF; } u.SetLeds(TL, TR, BL, BR); } if (Settings[std::string("PatchRsaPubCrypt")]) u.PatchRsaPubCrypt(); if (Settings[std::string("RemoveConsoleSignatureChecks")]) u.RemoveConsoleSignatureChecks(); if (Settings[std::string("RemovePackageRsaChecks")]) u.RemovePackageRsaChecks(); if (Settings[std::string("RemoveProfileBreakpoints")]) u.RemoveProfileBreakpoints(); if (Settings[std::string("RemoveXampHeapAllocExplicitBreakpoints")]) u.RemoveXampHeapAllocExplicitBreakpoints(); if (Settings[std::string("EnableXamWatsonOutput")]) u.EnableXamWatsonOutput(); if (ns.AccountCreationPassword != "") u.SetDefaultAccountPassword(ns.AccountCreationPassword); if (Settings[std::string("SetGamertag")] && ns.Gamertag != "") u.SetGamertag(ns.Gamertag); if (Settings[std::string("SetGoldMembership")]) u.SetGold(); if (Settings[std::string("EnableExtraNeighborhoodDrives")]) u.AddExtraDrives(drl); else if (Settings[std::string("EnableHiddenPartitions")]) u.EnableHiddenDrives(); if (Settings[std::string("SetAsStartupApplication")]) u.EnableApplicationStartup(); u.PatchControllerDisconnect(); // Return to launcher u.LaunchXshell(); }