Esempio n. 1
0
void MainWindow::on_option_clicked()
{
	OptionDialog dlg;
	if (dlg.exec())
	{
		*config = dlg.get_configurations();
		if (!save_options())
			QMessageBox::warning(this, "I/O Error ... ",
			"Please note that the changes could not be save\non the disk, as a result, the next time that the\napplication is loaded, all the current configurations\n will get reset. The new configuration will last by the\n end of the current session", "Ok", NULL, NULL
			,0,0);

	}
}
Esempio n. 2
0
void InitTrain()
{
	int i;
	OptionDialog dlg;

	dlg.m_size = gStartingNode;
	dlg.m_fs = gTrain_Method;
	dlg.m_lc = linear_classifier;
	dlg.m_ratio = asym_ratio;
	if(dlg.DoModal()!=IDOK)
	{
		AfxMessageBox("Training canceled.");
		return;
	}
	else
	{
		gTrain_Method = TRAIN_ADA;
		linear_classifier = LC_ORIGINAL;
		asym_ratio = REAL(1);
	}

	i = gStartingNode;
	if(i!=1 && i<=gMaxNumNodes)
	{
		ofstream f;
		if(!BoostingInputFiles(true))
		{
			AfxMessageBox("All bootstrapping file used! Training finished! (finally...)");
			return;
		}
		f.open(FileUsage_log_filename);
		for(int j=0;j<gMaxNumFiles;j++) f<<gFileUsed[j]<<" ";
		f.close();
	}
	AfxGetApp()->BeginWaitCursor();
	WriteRangeFile();
	while(i<=gMaxNumNodes)
	{
		bool result;

		result = gCascade->OneRound(i);
		if(result==false)
		{
			AfxGetApp()->EndWaitCursor();
			AfxMessageBox("All bootstrapping file used! Training finished! (finally...)");
			return;
		}
		i++;
	}
	AfxGetApp()->EndWaitCursor();
}
Esempio n. 3
0
extern "C" __declspec(dllexport) void setInfo(NppData notpadPlusData)
{
    nppData = notpadPlusData;

    AboutDlg.init((HINSTANCE)g_hModule, nppData);
    OptionDlg.init((HINSTANCE)g_hModule, nppData);
    NavDlg.init((HINSTANCE)g_hModule, nppData);
}
Esempio n. 4
0
void openOptionDlg(void)
{
    if (OptionDlg.doDialog(&Settings) == IDOK)
    {
        saveSettings();
        if (active)
        {
            setStyles(Settings);
            
            NavDlg.SetColor(
                Settings.ColorSettings.added, 
                Settings.ColorSettings.deleted, 
                Settings.ColorSettings.changed, 
                Settings.ColorSettings.moved, 
                Settings.ColorSettings.blank);

            NavDlg.CreateBitmap();
        }
    }
}
Esempio n. 5
0
/*!
  \param argc Number of parameter
  \param argv parameter values
*/
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
#ifdef STATICPLUGINS
    Q_INIT_RESOURCE(silenteye);
#endif

    Controller::instance()->appPath = qApp->applicationDirPath()+"/";
    Controller::instance()->config = Config(Controller::instance()->appPath, "silenteye");
    Controller::instance()->tmpPath = Controller::instance()->appPath + "tmp/";
    Controller::instance()->translationsPath = Controller::instance()->appPath + "translations/";

    Logger::setFileName(Controller::instance()->appPath + "silenteye.log");
    Logger::setLevel(Controller::instance()->config.get("loglevel"));

    Logger logger("main");

    if (Controller::instance()->config.get("language") != "" && Controller::instance()->config.get("language") != "en")
    {
        QString languageName = "silenteye_" + Controller::instance()->config.get("language");
        QString languageFile = Controller::instance()->translationsPath + languageName + ".qm" ;

        if (QFile::exists(languageFile))
        {
            QTranslator qtTranslator;
            if(qtTranslator.load(languageName, Controller::instance()->translationsPath))
            {
                app.installTranslator(&qtTranslator);
                logger.info("Language '" + languageName + "' loaded.");
            }
            else {
                logger.info("Cannot load language file '" + languageFile + "'.");
            }
        } else {
            logger.info("Cannot find language file " + languageFile);
        }
    }

    ModuleManager::load();

    if (app.argc() <= 1)
    {
        /* Normal mode */
        if( !Controller::instance()->config.contains("output") || Controller::instance()->config.get("output").trimmed() == "")
            // default output is the user home
            Controller::instance()->config.set("output", QDir::homePath()+"/");

        Controller::instance()->updateProxySettings();

        MainWindow mainWin;
        mainWin.show();
        return app.exec();
    }
    else
    {
        /* Quick mode */
        for (int i = 0; i < app.argc(); i++)
            logger.debug("Parameter " + QString::number(i) + ": " + QString(app.argv()[i]));

        QString action(app.argv()[1]);
        QString filePath(app.argv()[2]);

        if(app.argc() == 2) {
            action = "open";
            filePath = app.argv()[1];
        } else if(app.argc() == 3) {
            action = app.argv()[1];
            filePath = app.argv()[2];
        } else {
            showMessage("Usage: " + QString(app.argv()[0])
                        + " <action> [file_path]\n"
                        + "action: encode/decode\n"
                        + "file_path: absolute path to media", logger);
            return 1;
        }

        if( !Controller::instance()->config.contains("output") || Controller::instance()->config.get("output").trimmed() == "")
            // default output is the current directory
            Controller::instance()->config.set("output", QDir::currentPath());

        if (!QFile::exists(filePath)) {
            showMessage("Cannot load '" + filePath
                        + "'\n file: file not found.", logger);
            return 2;
        }
        if(action == "open") {
            Controller::instance()->updateProxySettings();

            MainWindow mainWin(filePath);
            mainWin.show();
            return app.exec();
        }

        // Load Media
        QPointer<Media> md;
        if (filePath.endsWith(".wav", Qt::CaseInsensitive)) {

            try {
                md = new Audio(filePath);
            } catch (SilentEyeException e) {
                showMessage("Cannot load '" + filePath
                            + "'\n file: unsupported media type. ("
                            + e.details() + ")", logger);
                return 2;
            }
        } else {
            md = new Image(filePath);
            if(((Image*)md.data())->isNull())
            {
                showMessage("Cannot load '" + filePath
                            + "'\n file: unsupported media type.", logger);
                return 2;
            }
        }

        // create the specified dialog
        OptionDialog* dialog = NULL;
        if (action == "encode") {
            dialog = new EncodeDialog();
        } else if(action == "decode") {
            dialog = new DecodeDialog();
        } else {
            showMessage("Specified action not recognised: " + action, logger);
            return 3;
        }

        // setup dialog
        dialog->setMedia(md);

        int return_code = dialog->exec();
        delete dialog;
        return return_code;
    }
}
Esempio n. 6
0
BOOL APIENTRY DllMain(HANDLE hModule, DWORD  reasonForCall, LPVOID /*lpReserved*/)
 {
    g_hModule = hModule;

    switch (reasonForCall)
    {
    case DLL_PROCESS_ATTACH:
        {
            funcItem[CMD_COMPARE]._pFunc = compare;
            lstrcpy(funcItem[CMD_COMPARE]._itemName, TEXT("Compare"));
            funcItem[CMD_COMPARE]._pShKey = new ShortcutKey;
            funcItem[CMD_COMPARE]._pShKey->_isAlt = true;
            funcItem[CMD_COMPARE]._pShKey->_isCtrl = false;
            funcItem[CMD_COMPARE]._pShKey->_isShift = false;
            funcItem[CMD_COMPARE]._pShKey->_key = 'D';
            funcItem[CMD_COMPARE]._init2Check = false;

            funcItem[CMD_CLEAR_RESULTS]._pFunc = reset;
            lstrcpy(funcItem[CMD_CLEAR_RESULTS]._itemName, TEXT("Clear Results"));
            funcItem[CMD_CLEAR_RESULTS]._pShKey = new ShortcutKey;
            funcItem[CMD_CLEAR_RESULTS]._pShKey->_isAlt = true;
            funcItem[CMD_CLEAR_RESULTS]._pShKey->_isCtrl = true;
            funcItem[CMD_CLEAR_RESULTS]._pShKey->_isShift = false;
            funcItem[CMD_CLEAR_RESULTS]._pShKey->_key = 'D';
            funcItem[CMD_CLEAR_RESULTS]._init2Check = false;

            funcItem[CMD_SEPARATOR_1]._pFunc = NULL;
            lstrcpy(funcItem[CMD_SEPARATOR_1]._itemName, TEXT("-----------"));
            funcItem[CMD_SEPARATOR_1]._pShKey = NULL;

            funcItem[CMD_COMPARE_LAST_SAVE]._pFunc = compareLocal;
            lstrcpy(funcItem[CMD_COMPARE_LAST_SAVE]._itemName, TEXT("Compare to last save"));
            funcItem[CMD_COMPARE_LAST_SAVE]._pShKey = new ShortcutKey;
            funcItem[CMD_COMPARE_LAST_SAVE]._pShKey->_isAlt = true;
            funcItem[CMD_COMPARE_LAST_SAVE]._pShKey->_isCtrl = false;
            funcItem[CMD_COMPARE_LAST_SAVE]._pShKey->_isShift = false;
            funcItem[CMD_COMPARE_LAST_SAVE]._pShKey->_key = 'S';
            funcItem[CMD_COMPARE_LAST_SAVE]._init2Check = false;

            funcItem[CMD_COMAPRE_SVN_BASE]._pFunc = compareBase;
            lstrcpy(funcItem[CMD_COMAPRE_SVN_BASE]._itemName, TEXT("Compare against SVN base"));
            funcItem[CMD_COMAPRE_SVN_BASE]._pShKey = new ShortcutKey;
            funcItem[CMD_COMAPRE_SVN_BASE]._pShKey->_isAlt = true;
            funcItem[CMD_COMAPRE_SVN_BASE]._pShKey->_isCtrl = false;
            funcItem[CMD_COMAPRE_SVN_BASE]._pShKey->_isShift = false;
            funcItem[CMD_COMAPRE_SVN_BASE]._pShKey->_key = 'B';
            funcItem[CMD_COMAPRE_SVN_BASE]._init2Check = false;

            funcItem[CMD_SEPARATOR_2]._pFunc = NULL;
            lstrcpy(funcItem[CMD_SEPARATOR_2]._itemName, TEXT("------------"));
            funcItem[CMD_SEPARATOR_2]._pShKey = NULL;

            funcItem[CMD_ALIGN_MATCHES]._pFunc = alignMatches;
            lstrcpy(funcItem[CMD_ALIGN_MATCHES]._itemName, TEXT("Align Matches"));
            funcItem[CMD_ALIGN_MATCHES]._pShKey = NULL;
            funcItem[CMD_ALIGN_MATCHES]._init2Check = false;

            funcItem[CMD_IGNORE_SPACING]._pFunc = includeSpacing;
            lstrcpy(funcItem[CMD_IGNORE_SPACING]._itemName, TEXT("Ignore Spacing"));
            funcItem[CMD_IGNORE_SPACING]._pShKey = NULL;
            funcItem[CMD_IGNORE_SPACING]._init2Check = false;

            funcItem[CMD_DETECT_MOVES]._pFunc = detectMoves;
            lstrcpy(funcItem[CMD_DETECT_MOVES]._itemName, TEXT("Detect Moves"));
            funcItem[CMD_DETECT_MOVES]._pShKey = NULL;
            funcItem[CMD_DETECT_MOVES]._init2Check = false;

            funcItem[CMD_USE_NAV_BAR]._pFunc = ViewNavigationBar;
            lstrcpy(funcItem[CMD_USE_NAV_BAR]._itemName, TEXT("Navigation bar"));
            funcItem[CMD_USE_NAV_BAR]._pShKey = NULL;
            funcItem[CMD_USE_NAV_BAR]._init2Check = false;

            funcItem[CMD_SEPARATOR_3]._pFunc = NULL;
            lstrcpy(funcItem[CMD_SEPARATOR_3]._itemName, TEXT("-----------"));
            funcItem[CMD_SEPARATOR_3]._pShKey = NULL;

            funcItem[CMD_PREV]._pFunc = Prev;
            lstrcpy(funcItem[CMD_PREV]._itemName, TEXT("Previous"));
            funcItem[CMD_PREV]._pShKey = new ShortcutKey;
            funcItem[CMD_PREV]._pShKey->_isAlt = false;
            funcItem[CMD_PREV]._pShKey->_isCtrl = true;
            funcItem[CMD_PREV]._pShKey->_isShift = false;
            funcItem[CMD_PREV]._pShKey->_key = VK_PRIOR;
            funcItem[CMD_PREV]._init2Check = false;

            funcItem[CMD_NEXT]._pFunc = Next;
            lstrcpy(funcItem[CMD_NEXT]._itemName, TEXT("Next"));
            funcItem[CMD_NEXT]._pShKey = new ShortcutKey;
            funcItem[CMD_NEXT]._pShKey->_isAlt = false;
            funcItem[CMD_NEXT]._pShKey->_isCtrl = true;
            funcItem[CMD_NEXT]._pShKey->_isShift = false;
            funcItem[CMD_NEXT]._pShKey->_key = VK_NEXT;
            funcItem[CMD_NEXT]._init2Check = false;

            funcItem[CMD_FIRST]._pFunc = First;
            lstrcpy(funcItem[CMD_FIRST]._itemName, TEXT("First"));
            funcItem[CMD_FIRST]._pShKey = new ShortcutKey;
            funcItem[CMD_FIRST]._pShKey->_isAlt = false;
            funcItem[CMD_FIRST]._pShKey->_isCtrl = true;
            funcItem[CMD_FIRST]._pShKey->_isShift = true;
            funcItem[CMD_FIRST]._pShKey->_key = VK_PRIOR;
            funcItem[CMD_FIRST]._init2Check = false;

            funcItem[CMD_LAST]._pFunc = Last;
            lstrcpy(funcItem[CMD_LAST]._itemName, TEXT("Last"));
            funcItem[CMD_LAST]._pShKey = new ShortcutKey;
            funcItem[CMD_LAST]._pShKey->_isAlt = false;
            funcItem[CMD_LAST]._pShKey->_isCtrl = true;
            funcItem[CMD_LAST]._pShKey->_isShift = true;
            funcItem[CMD_LAST]._pShKey->_key = VK_NEXT;
            funcItem[CMD_LAST]._init2Check = false;

            funcItem[CMD_SEPARATOR_4]._pFunc = NULL;
            lstrcpy(funcItem[CMD_SEPARATOR_4]._itemName, TEXT("-----------"));
            funcItem[CMD_SEPARATOR_4]._pShKey = NULL;

            funcItem[CMD_OPTION]._pFunc = openOptionDlg;
            lstrcpy(funcItem[CMD_OPTION]._itemName, TEXT("Option"));
            funcItem[CMD_OPTION]._pShKey = NULL;
            funcItem[CMD_OPTION]._init2Check = false;

            funcItem[CMD_ABOUT]._pFunc = openAboutDlg;
            lstrcpy(funcItem[CMD_ABOUT]._itemName, TEXT("About"));
            funcItem[CMD_ABOUT]._pShKey = NULL;
            funcItem[CMD_ABOUT]._init2Check = false;

            for(int i = 0; i < MAXCOMPARE; i++)
            {
                compareDocs[i]=-1;
            }

            TCHAR nppPath[MAX_PATH];
            GetModuleFileName((HMODULE)hModule, nppPath, sizeof(nppPath));

            // remove the module name : get plugins directory path
            PathRemoveFileSpec(nppPath);

            // cd .. : get npp executable path
            PathRemoveFileSpec(nppPath);

            // Make localConf.xml path
            TCHAR localConfPath[MAX_PATH];
            lstrcpy(localConfPath, nppPath);
            PathAppend(localConfPath, localConfFile);

            // Test if localConf.xml exist
            bool isLocal = (PathFileExists(localConfPath) == TRUE);

            if (isLocal) 
            {
                lstrcpy(iniFilePath, nppPath);
                lstrcpy(compareFilePath, nppPath);

                PathAppend(iniFilePath, TEXT("plugins\\config\\Compare.ini"));
            }
            else 
            {
                ITEMIDLIST *pidl;
                SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
                SHGetPathFromIDList(pidl, iniFilePath);
                SHGetPathFromIDList(pidl, compareFilePath);

                PathAppend(iniFilePath, TEXT("Notepad++\\Compare.ini"));
            }

            loadSettings();
        }
        break;

    case DLL_PROCESS_DETACH:

        if (tbNext.hToolbarBmp)  ::DeleteObject(tbNext.hToolbarBmp);
        if (tbPrev.hToolbarBmp)  ::DeleteObject(tbPrev.hToolbarBmp);
        if (tbFirst.hToolbarBmp) ::DeleteObject(tbFirst.hToolbarBmp);
        if (tbLast.hToolbarBmp)  ::DeleteObject(tbLast.hToolbarBmp);

        saveSettings();
        OptionDlg.destroy();
        AboutDlg.destroy();
        NavDlg.destroy();

        // Don't forget to deallocate your shortcut here
		delete funcItem[CMD_COMPARE]._pShKey;
		delete funcItem[CMD_CLEAR_RESULTS]._pShKey;
		delete funcItem[CMD_COMPARE_LAST_SAVE]._pShKey;
		delete funcItem[CMD_COMAPRE_SVN_BASE]._pShKey;
		delete funcItem[CMD_PREV]._pShKey;
		delete funcItem[CMD_NEXT]._pShKey;
		delete funcItem[CMD_FIRST]._pShKey;
		delete funcItem[CMD_LAST]._pShKey;

        break;

    case DLL_THREAD_ATTACH:
        break;

    case DLL_THREAD_DETACH:
        break;
    }

    return TRUE;
}