void SettingsGeneral::loadLanguage()
{
    QStringList langList;
    QFile resLanguage(":/Resources/Language/LangList.ini");
    resLanguage.open(QIODevice::ReadOnly);
    QStringList resourceLanguages=QString(resLanguage.readAll().replace("\r","")).split("\n");
    for(int n=0;n<resourceLanguages.count();n++)if(!resourceLanguages.at(n).isEmpty())langList<<":/Resources/Language/"+resourceLanguages.at(n);
    QStringList folderLangList=QDir(appDataDir+"Language","*.lng").entryList();
    folderLangList.sort();
    for(int n=0;n<folderLangList.count();n++)langList<<appDataDir+"Language/"+folderLangList.at(n);
    int selectedLangId=-1;

    QString preferedLangFile=julyTranslator.lastFile();
    if(!QFile::exists(preferedLangFile))preferedLangFile.clear();
    if(preferedLangFile.isEmpty())preferedLangFile=baseValues.defaultLangFile;

    ui.languageComboBox->clear();
    for(int n=0;n<langList.count();n++)
    {
        JulyTranslator translateName;
        translateName.loadFromFile(langList.at(n));
        QString langName=translateName.translateString("LANGUAGE_NAME","");
        if(langName.isEmpty())continue;
        if(preferedLangFile==langList.at(n))selectedLangId=n;
        ui.languageComboBox->insertItem(ui.languageComboBox->count(),langName,langList.at(n));
    }
    if(selectedLangId>-1)ui.languageComboBox->setCurrentIndex(selectedLangId);
}
TranslationDialog::TranslationDialog(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	ui.buttonSaveAs->setEnabled(false);
	setWindowFlags(Qt::Window);
	setAttribute(Qt::WA_DeleteOnClose,true);
	//setFixedSize(size());

#ifdef GENERATE_LANGUAGE_FILE
	julyTranslator->loadMapFromUi(this);
	julyTranslator->saveToFile("LanguageDefault.lng");
#endif

#ifdef Q_OS_WIN
	if(QtWin::isCompositionEnabled())QtWin::extendFrameIntoClientArea(this);
#endif

	julyTranslator->translateUi(this);

	ui.deleteTranslationButton->setEnabled(!julyTranslator->lastFile().startsWith(":/Resource"));

	ui.languageName->setText(julyTr("LANGUAGE_NAME","Invalid"));
	authorAbout=new TranslationLine;
	ui.authorLayout->addWidget(authorAbout);
	authorAbout->setItemText(julyTr("LANGUAGE_AUTHOR","Invalid"));

	gridLayout=new QGridLayout;
	fonWidget.setLayout(gridLayout);
	ui.scrollArea->setWidget(&fonWidget);

	JulyTranslator defaultTranslation;
	defaultTranslation.loadFromFile(":/Resources/Language/English.lng");

	fillLayoutByMap(&(julyTranslator->labelMap),"Label_",&(defaultTranslation.labelMap));
	fillLayoutByMap(&(julyTranslator->groupBoxMap),"GroupBox_",&(defaultTranslation.groupBoxMap));
	fillLayoutByMap(&(julyTranslator->checkBoxMap),"CheckBox_",&(defaultTranslation.checkBoxMap));
	fillLayoutByMap(&(julyTranslator->buttonMap),"Button_",&(defaultTranslation.buttonMap));
	fillLayoutByMap(&(julyTranslator->spinBoxMap),"SpinBox_",&(defaultTranslation.spinBoxMap));
	fillLayoutByMap(&(julyTranslator->stringMap),"String_",&(defaultTranslation.stringMap));

	setTabOrder(ui.languageName,authorAbout);

	int currentRow=0;
	QWidget *lastWidget=authorAbout;
	for(int n=0;n<lineEdits.count();n++)
		if(lineEdits[n]->isChanged()==false)
		{
			TranslationLine *nextWidget=lineEdits[n];
			gridLayout->addWidget(nextWidget, currentRow++, 0);
			setTabOrder(lastWidget,nextWidget);
			lastWidget=nextWidget;
		}

	for(int n=0;n<lineEdits.count();n++)
		if(lineEdits[n]->isChanged()==true)
		{
			TranslationLine *nextWidget=lineEdits[n];
			gridLayout->addWidget(nextWidget, currentRow++, 0);
			setTabOrder(lastWidget,nextWidget);
			lastWidget=nextWidget;
		}
		setTabOrder(lastWidget,ui.searchLineEdit);

        resize(640,640);
        fixLayout();
	if(mainWindow_)mainWindow.ui.aboutTranslationButton->setEnabled(false);

    QTimer::singleShot(100,this,SLOT(fixLayout()));
}