Exemplo n.º 1
0
/// \brief Construct the object
HelpDialog::HelpDialog() :
	ui(new Ui::HelpDialog)
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
	ui->setupUi(this);
	reloadTextValue();
	#ifdef ULTRACOPIER_DEBUG
	connect(debug_engine_instance,SIGNAL(newDebugInformation()),this,SLOT(addDebugText()));
	connect(ui->pushButtonSaveBugReport,SIGNAL(clicked()),debug_engine_instance,SLOT(saveBugReport()));
	#else // ULTRACOPIER_DEBUG
	ui->lineEditInsertDebug->hide();
	ui->debugView->hide();
	ui->pushButtonSaveBugReport->hide();
	ui->pushButtonCrash->hide();
	this->setMaximumSize(QSize(500,128));
	/*timeToSetText.setInterval(250);
	timeToSetText.setSingleShot(true);
	connect(&timeToSetText,SIGNAL(timeout()),this,SLOT(showDebugText()));*/
	ui->pushButtonClose->hide();
	#endif // ULTRACOPIER_DEBUG
	//connect the about Qt
	connect(ui->pushButtonAboutQt,SIGNAL(toggled(bool)),qApp,SLOT(aboutQt()));
}
Exemplo n.º 2
0
/// \brief initiate the ultracopier event dispatcher and check if no other session is running
DebugEngine::DebugEngine()
{
    addDebugInformationCallNumber=0;
    //Load the first content
    debugHtmlContent+="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
    debugHtmlContent+="<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">";
    debugHtmlContent+="<head>";
    debugHtmlContent+="<meta name=\"Language\" content=\"en\" />";
    debugHtmlContent+="<meta http-equiv=\"content-language\" content=\"english\" />";
    debugHtmlContent+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
    debugHtmlContent+="<style type=\"text/css\">";
    debugHtmlContent+="body{font-family:\"DejaVu Sans Mono\";font-size:9pt;}";
    debugHtmlContent+=".Information td{color:#7485df;}";
    debugHtmlContent+=".Critical td{color:#ff0c00;background-color:#FFFE8C;}";
    debugHtmlContent+=".Warning td{color:#efa200;}";
    debugHtmlContent+=".Notice td{color:#999;}";
    debugHtmlContent+=".time{font-weight:bold;}";
    debugHtmlContent+=".Note{font-weight:bold;font-size:1.5em}";
    debugHtmlContent+=".function{font-style:italic;text-decoration:underline}";
    debugHtmlContent+=".location{padding-right:15px;}";
    debugHtmlContent+="td {white-space:nowrap;}";
    debugHtmlContent+="</style>";
    debugHtmlContent+="<title>Ultracopier "+QString(ULTRACOPIER_VERSION)+" "+QString(ULTRACOPIER_PLATFORM_NAME)+", debug report</title>";
    debugHtmlContent+="</head>";
    debugHtmlContent+="<body>";
    debugHtmlContent+="<table>";
    //Load the start time at now
    startTime.start();
    //Load the log file end
    endOfLogFile="</table></body></html>";
    //check if other instance is running, then switch to memory backend
    if(tryConnect())
    {
        ULTRACOPIER_DEBUGCONSOLE(DebugLevel_custom_Notice,"currentBackend: File because other session is runing");
        currentBackend=Memory;
        return;
    }
    //The lock and log file path is not defined
    bool fileNameIsLoaded=false;
    #ifdef ULTRACOPIER_VERSION_PORTABLE
        #ifdef ULTRACOPIER_VERSION_PORTABLEAPPS
            //Load the data folder path
            QDir dir(QCoreApplication::applicationDirPath());
            dir.cdUp();
            dir.cdUp();
            dir.cd("Data");
            logFile.setFileName(dir.absolutePath()+QDir::separator()+"log.html");
            lockFile.setFileName(dir.absolutePath()+QDir::separator()+"ultracopier.lock");
            fileNameIsLoaded=true;
        #else
            //Load the ultracopier path
            QDir dir(QCoreApplication::applicationDirPath());
            logFile.setFileName(dir.absolutePath()+QDir::separator()+"log.html");
            lockFile.setFileName(dir.absolutePath()+QDir::separator()+"ultracopier.lock");
            fileNameIsLoaded=true;
        #endif
    #else
        #ifdef Q_OS_WIN32
            #define EXTRA_HOME_PATH "\\ultracopier\\"
        #else
            #define EXTRA_HOME_PATH "/.config/Ultracopier/"
        #endif
        //Load the user path only if exists and writable
        QDir dir(QDir::homePath()+EXTRA_HOME_PATH);
        bool errorFound=false;
        //If user's directory not exists create it
        if(!dir.exists())
        {
            //If failed not load the file
            if(!dir.mkpath(dir.absolutePath()))
            {
                errorFound=true;
                puts(qPrintable("Unable to make path: "+dir.absolutePath()+", disable file log"));
            }
        }
        //If no error found set the file name
        if(errorFound==false)
        {
            fileNameIsLoaded=true;
            logFile.setFileName(dir.absolutePath()+QDir::separator()+"log.html");
            lockFile.setFileName(dir.absolutePath()+QDir::separator()+"ultracopier.lock");
        }
        errorFound=false;
    #endif
    //If the file name is loaded
    if(fileNameIsLoaded)
    {
        //If the previous file is here, then crash previous, ask if the user want to save
        if(lockFile.exists() && logFile.exists())
        {
            //Try open the file as read only to propose save it as the user
            //Don't ask it if unable to write, because unable to remove, then alert at all start
            if(removeTheLockFile())
            {
                //Ask to the user
                QMessageBox::StandardButton reply = QMessageBox::question(NULL,"Save the previous report","Ultracopier seam have crashed, do you want save the previous report for report it to the forum?",QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
                if(reply==QMessageBox::Yes)
                    saveBugReport();
            }
            else
                puts(qPrintable(logFile.fileName()+" unable to open it as read"));
        }
        //Now try to create and open the log file and lock file
        if(!lockFile.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Unbuffered))
        {
            currentBackend=Memory;
            puts(qPrintable(lockFile.fileName()+" unable to open it as write, log into file disabled"));
        }
        else
        {
            if(!logFile.open(QIODevice::ReadWrite|QIODevice::Truncate|QIODevice::Unbuffered))
            {
                currentBackend=Memory;
                puts(qPrintable(logFile.fileName()+" unable to open it as write, log into file disabled"));
                removeTheLockFile();
            }
            else
            {
                currentBackend=File;
                logFile.write(debugHtmlContent.toUtf8());
            }
        }
    }
    if(currentBackend==File)
        ULTRACOPIER_DEBUGCONSOLE(DebugLevel_custom_Notice,"currentBackend: File");
    else
        ULTRACOPIER_DEBUGCONSOLE(DebugLevel_custom_Notice,"currentBackend: Memory");
}