void MountTray::programInit() { DCheck = new DevCheck(); //initialize class for checking devices qDebug() << "pc-mounttray: starting up"; MTINIT=true; //set the flag that the mount tray is initializing; //getInitialUsername(); //try to detect the non-root user who is running the program with root permissions getFileManager(); loadSavedSettings(); trayIcon = new QSystemTrayIcon(this); trayIconMenu = new QMenu(); //Generate the system menu options (these don't change) sysMenu = new QMenu( tr("More Options") ); sysMenu->setIcon( QIcon(":icons/config.png") ); //Add the additional options sysMenu->addAction( QIcon(":icons/folder.png"), tr("Open Media Directory"), this, SLOT(slotOpenMediaDir()) ); sysMenu->addAction( QIcon(":icons/harddrive.png"), tr("View Disk Usage"),this,SLOT(slotOpenFSDialog()) ); sysMenu->addAction( QIcon(":icons/refresh.png"),tr("Rescan Devices"), this, SLOT(slotRescan()) ); //Add the setting dialog option seperately sysMenu->addSeparator(); sysMenu->addAction( QIcon(":icons/dvd.png"), tr("Load ISO File"), this, SLOT(slotOpenISO()) ); sysMenu->addAction( QIcon(":icons/config.png"), tr("Change Settings"), this, SLOT(slotOpenSettings()) ); //Add the Close button seperately sysMenu->addSeparator(); sysMenu->addAction( QIcon(":icons/application-exit.png"), tr("Close Tray"), this, SLOT(closeTray()) ); // Tie the left-click signal to open the context menu connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayActivated(QSystemTrayIcon::ActivationReason)) ); //Connect the message clicked slot connect(trayIcon,SIGNAL(messageClicked()),this,SLOT(slotPopupClicked()) ); //Set the default Tray Icon (will change once tray menus are set) trayIcon->setIcon(QIcon(":icons/CDdevices-inactive.png")); trayIcon->show(); //Do an initial scan of the devices with dmesg qDebug() << "-Performing initial device scan"; scanInitialDevices(); //Startup the devd watching process qDebug() << "-Starting up the DEVD watcher"; devdTimer = new QTimer(); devdTimer->setSingleShot(TRUE); connect(devdTimer,SIGNAL(timeout()),this,SLOT(slotDevChanges())); startupDevdProc(); //Start up the filesystem watcher diskWatcher = new FSWatcher(); connect(diskWatcher,SIGNAL(FSWarning(QString,QString)),this,SLOT(slotDisplayWarning(QString,QString))); if(useDiskWatcher){ qDebug() << "-Starting up the disk space alert system"; diskWatcher->start(diskTimerMaxMS); } //Update the tray menu and icons updateMenu(); qDebug() << "-Program now ready for use"; QTimer::singleShot(500, this, SLOT(slotDoneWithInit()) ); //give it 1/2 a second to settle }
void Texture::LoadFromFile( const std::string& texturePath ) { REQUIRES( !IsLoaded() ); REQUIRES( !texturePath.empty() ); m_filePath = texturePath; int bufferSize; const unsigned char* textureBuffer = reinterpret_cast< const unsigned char* >( getFileManager().readDataFromFile( texturePath, bufferSize ) ); if( textureBuffer != nullptr ) m_texels = stbi_load_from_memory( textureBuffer, bufferSize, &m_width, &m_height, &m_channels, 0 ); SAFE_DELETE( textureBuffer ); LoadToOpenGL(); PROMISES( IsLoaded() ); PROMISES( GetFilePath() == texturePath ); }
std::unique_ptr<CompilerInstance> BuildCompilerInstance(ArrayRef<const char *> ClangArgv) { auto Ins = llvm::make_unique<CompilerInstance>(); auto DC = llvm::make_unique<TestDiagnosticConsumer>(); const bool ShouldOwnClient = true; Ins->createDiagnostics(DC.release(), ShouldOwnClient); auto Inv = llvm::make_unique<CompilerInvocation>(); CompilerInvocation::CreateFromArgs(*Inv, ClangArgv.data(), &ClangArgv.data()[ClangArgv.size()], Ins->getDiagnostics()); Inv->getLangOpts()->CPlusPlus = true; Inv->getLangOpts()->CPlusPlus11 = true; Inv->getHeaderSearchOpts().UseLibcxx = true; Inv->getLangOpts()->Bool = true; Inv->getLangOpts()->WChar = true; Inv->getLangOpts()->Blocks = true; Inv->getLangOpts()->DebuggerSupport = true; Inv->getLangOpts()->SpellChecking = false; Inv->getLangOpts()->ThreadsafeStatics = false; Inv->getLangOpts()->AccessControl = false; Inv->getLangOpts()->DollarIdents = true; Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo); Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); Ins->setInvocation(Inv.release()); TargetInfo *TI = TargetInfo::CreateTargetInfo( Ins->getDiagnostics(), Ins->getInvocation().TargetOpts); Ins->setTarget(TI); Ins->getTarget().adjust(Ins->getLangOpts()); Ins->createFileManager(); Ins->createSourceManager(Ins->getFileManager()); Ins->createPreprocessor(TU_Complete); return Ins; }
//-------------------------------------------------------------------------------- void Shader::loadShaderFromFile( const char* fileName, GLenum shaderType ) { GLuint shaderID = 0; std::string shaderString; //std::ifstream shaderFile( fileName ); int shaderBufferSize = -1; const char* shaderBuffer = nullptr; shaderBuffer = getFileManager().readDataFromFile( fileName, shaderBufferSize ); if( shaderBuffer != nullptr ) { std::string shaderString; shaderString.assign( shaderBuffer, shaderBufferSize ); //shaderString.assign( std::istreambuf_iterator< char >( shaderFile ), std::istreambuf_iterator< char >() ); shaderID = glCreateShader( shaderType ); const GLchar* shaderSource = shaderString.c_str(); glShaderSource( shaderID, 1, reinterpret_cast< const GLchar** >( &shaderSource ), nullptr ); glCompileShader( shaderID ); GLint compiled = GL_FALSE; glGetShaderiv( shaderID, GL_COMPILE_STATUS, &compiled ); if( compiled != GL_TRUE ) { handleShaderCompilerError( shaderID, fileName, shaderSource ); } m_shaderID = shaderID; } else { std::string errorMessage = "Could not open shader file: " + std::string( fileName ); MonkyException::fatalErrorMessageBox( "Shader file open error", errorMessage.c_str() ); } SAFE_DELETE( shaderBuffer ); }