"Fossies" - the Fresh Open Source Software Archive

Member "ansifilter-2.18/src/qt-gui/mydialog.cpp" (30 Jan 2021, 20743 Bytes) of package /linux/privat/ansifilter-2.18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mydialog.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.17_vs_2.18.

    1 /***************************************************************************
    2                         mydialog.h  -  description
    3                              -------------------
    4     copyright            : (C) 2007-2020 by Andre Simon
    5     email                : andre.simon1@gmx.de
    6  ***************************************************************************/
    7 
    8 /*
    9 This file is part of ANSIFilter.
   10 
   11 ANSIFilter is free software: you can redistribute it and/or modify
   12 it under the terms of the GNU General Public License as published by
   13 the Free Software Foundation, either version 3 of the License, or
   14 (at your option) any later version.
   15 
   16 ANSIFilter is distributed in the hope that it will be useful,
   17 but WITHOUT ANY WARRANTY; without even the implied warranty of
   18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   19 GNU General Public License for more details.
   20 
   21 You should have received a copy of the GNU General Public License
   22 along with ANSIFilter.  If not, see <http://www.gnu.org/licenses/>.
   23 */
   24 
   25 #include "mydialog.h"
   26 
   27 #include <QtGlobal>
   28 
   29 
   30 #ifdef Q_OS_WIN
   31 #include <windows.h>
   32 #endif
   33 
   34 #if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
   35 #include <QtWidgets/QMessageBox>
   36 #include <QtWidgets/QFileDialog>
   37 #include <QScrollBar>
   38 #else
   39 #include <QtWidgets/QMessageBox>
   40 #include <QtWidgets/QFileDialog>
   41 #include <QtWidgets/QScrollBar>
   42 #endif
   43 
   44 #include "../version.h"
   45 #include <memory>
   46 #include <QClipboard>
   47 #include <QSettings>
   48 #include <QUrl>
   49 #include <QMimeData>
   50 #include <QMimeData>
   51 #include <QFileInfo>
   52 #include <QStyleFactory>
   53 
   54 MyDialog::MyDialog(QWidget * parent, Qt::WindowFlags f):QDialog(parent, f)
   55 {
   56 
   57 #ifdef Q_OS_WIN
   58 // https://forum.qt.io/topic/101391/windows-10-dark-theme/
   59 if (QSysInfo::productVersion()=="10") {
   60     QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",QSettings::NativeFormat);
   61     if(settings.value("AppsUseLightTheme")==0){
   62         qApp->setStyle(QStyleFactory::create("Fusion"));
   63         QPalette darkPalette;
   64         QColor darkColor = QColor(45,45,45);
   65         QColor disabledColor = QColor(127,127,127);
   66         darkPalette.setColor(QPalette::Window, darkColor);
   67         darkPalette.setColor(QPalette::WindowText, Qt::white);
   68         darkPalette.setColor(QPalette::Base, QColor(18,18,18));
   69         darkPalette.setColor(QPalette::AlternateBase, darkColor);
   70         darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
   71         darkPalette.setColor(QPalette::ToolTipText, Qt::white);
   72         darkPalette.setColor(QPalette::Text, Qt::white);
   73         darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
   74         darkPalette.setColor(QPalette::Button, darkColor);
   75         darkPalette.setColor(QPalette::ButtonText, Qt::white);
   76         darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
   77         darkPalette.setColor(QPalette::BrightText, Qt::red);
   78         darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
   79 
   80         darkPalette.setColor(QPalette::Highlight, QColor(153, 153, 153));
   81         darkPalette.setColor(QPalette::HighlightedText, Qt::black);
   82         darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
   83 
   84         qApp->setPalette(darkPalette);
   85         qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #404040; border: 1px solid white; }");
   86     }
   87 }
   88 #endif
   89 
   90 
   91 
   92     dlg.setupUi(this);
   93     QSettings settings("andre-simon.de", "ansifilter-gui");
   94     settings.beginGroup("format");
   95     dlg.leTitle->setText(settings.value("title").toString());
   96     dlg.leColorMapPath->setText(settings.value("map").toString());
   97     dlg.leStyleFile->setText(settings.value("stylefile").toString());
   98     dlg.cbFragment->setChecked(settings.value("fragment").toBool());
   99     dlg.cbIgnoreSequences->setChecked(settings.value("ignoreseq").toBool());
  100     dlg.cbParseAsciiArt->setChecked(settings.value("parseart").toBool());
  101     dlg.cbOmitVersion->setChecked(settings.value("cbOmitVersion").toBool());
  102     dlg.comboAnsiFormat->setCurrentIndex(settings.value("ansiformat").toInt());
  103     dlg.comboEncoding->setCurrentIndex(settings.value("encoding").toInt());
  104     dlg.comboFont->setCurrentIndex(settings.value("font").toInt());
  105     dlg.comboFormat->setCurrentIndex(settings.value("format").toInt());
  106     dlg.spinBoxWrap->setValue(settings.value("linewrap").toInt());
  107     dlg.sbWidth->setValue(settings.value("width").toInt());
  108     dlg.sbHeight->setValue(settings.value("height").toInt());
  109     dlg.cbIgnClearSeq->setChecked(settings.value("ignoreclearseq").toBool());
  110     dlg.cbIgnCSISeq->setChecked(settings.value("ignorecsiseq").toBool());
  111 
  112     dlg.cbDeriveStyles->setChecked(settings.value("derivestyles").toBool());
  113     dlg.leSvgWidth->setText(settings.value("svgwidth").toString());
  114     dlg.leSvgHeight->setText(settings.value("svgheight").toString());
  115 
  116     settings.endGroup();
  117     settings.beginGroup("paths");
  118     //inputFileName = settings.value("infile").toString();
  119     outputFileName = settings.value("outfile").toString();
  120     settings.endGroup();
  121     settings.beginGroup("window");
  122     resize(settings.value("size", QSize(400, 400)).toSize());
  123     move(settings.value("pos", QPoint(200, 200)).toPoint());
  124     settings.endGroup();
  125 
  126     this->setAcceptDrops(true);
  127     QObject::connect(&fileWatcher, SIGNAL(fileChanged(const QString &)), this, SLOT(onFileChanged(const QString &)));
  128     QObject::connect(dlg.comboFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(plausibility()));
  129 
  130     if (!inputFileName.isEmpty()) {
  131         showFile();
  132         dlg.cbWatchFile->setEnabled(true);
  133     }
  134 
  135 //avoid ugly buttons in MacOS
  136 #ifndef Q_OS_OSX
  137     dlg.pbSelectMapFile->setMaximumWidth(30);
  138 #endif
  139 
  140     plausibility();
  141 }
  142 
  143 void MyDialog::closeEvent(QCloseEvent *event)
  144 {
  145     QSettings settings("andre-simon.de", "ansifilter-gui");
  146     settings.beginGroup("format");
  147     settings.setValue("title", dlg.leTitle->text());
  148     settings.setValue("map", dlg.leColorMapPath->text());
  149     settings.setValue("stylefile", dlg.leStyleFile->text());
  150     settings.setValue("fragment", dlg.cbFragment->isChecked());
  151     settings.setValue("ignoreseq", dlg.cbIgnoreSequences->isChecked());
  152     settings.setValue("ignoreclearseq", dlg.cbIgnClearSeq->isChecked());
  153     settings.setValue("ignorecsiseq", dlg.cbIgnCSISeq->isChecked());
  154 
  155     settings.setValue("parseart", dlg.cbParseAsciiArt->isChecked());
  156     settings.setValue("cbOmitVersion", dlg.cbOmitVersion->isChecked());
  157     settings.setValue("derivestyles", dlg.cbDeriveStyles->isChecked());
  158 
  159     settings.setValue("ansiformat", dlg.comboAnsiFormat->currentIndex());
  160     settings.setValue("encoding", dlg.comboEncoding->currentIndex());
  161     settings.setValue("format", dlg.comboFormat->currentIndex());
  162     settings.setValue("font", dlg.comboFont->currentIndex());
  163     settings.setValue("linewrap", dlg.spinBoxWrap->value());
  164     settings.setValue("width", dlg.sbWidth->value());
  165     settings.setValue("height", dlg.sbHeight->value());
  166     settings.setValue("svgheight", dlg.leSvgHeight->text());
  167     settings.setValue("svgwidth", dlg.leSvgWidth->text());
  168 
  169     settings.endGroup();
  170     settings.beginGroup("paths");
  171     settings.setValue("infile", inputFileName);
  172     settings.setValue("outfile", outputFileName);
  173     settings.endGroup();
  174     settings.beginGroup("window");
  175     settings.setValue("size", size());
  176     settings.setValue("pos", pos());
  177     settings.endGroup();
  178 }
  179 
  180 void MyDialog::dragEnterEvent(QDragEnterEvent *event)
  181 {
  182     if ( event->mimeData()->hasFormat("text/uri-list")
  183             && event->mimeData()->urls().count()==1
  184        ) {
  185         event->acceptProposedAction();
  186         dlg.lblDrop->setEnabled(true);
  187     }
  188 }
  189 
  190 void MyDialog::dragLeaveEvent(QDragLeaveEvent* event)
  191 {
  192     dlg.lblDrop->setEnabled(false);
  193 }
  194 
  195 void MyDialog::dropEvent(QDropEvent* event)
  196 {
  197     dlg.lblDrop->setEnabled(false);
  198 
  199     QList<QUrl> urls = event->mimeData()->urls();
  200     if (urls.isEmpty())
  201         return;
  202     openFile(urls.first().toLocalFile());
  203 }
  204 
  205 void MyDialog::openFile(const QString & path){
  206     if (!path.isEmpty()) {
  207         inputFileName=path;
  208 
  209         if (!dlg.cbParseAsciiArt->isChecked()){
  210             dlg.cbWatchFile->setEnabled(true);
  211             dlg.cbWatchFile->setChecked(false);
  212         }
  213         showFile();
  214     }
  215 }
  216 
  217 void MyDialog::onFileChanged(const QString & path)
  218 {
  219     inputFileName  = path;
  220     showFile();
  221     QScrollBar *sb = dlg.textEdit->verticalScrollBar();
  222     sb->setValue(sb->maximum());
  223 }
  224 
  225 void MyDialog::plausibility()
  226 {
  227     int selIdx = dlg.comboFormat->currentIndex();
  228     dlg.cbIgnoreSequences->setEnabled(selIdx>0 && ! ((selIdx==1|| selIdx==2) && dlg.cbParseAsciiArt->isChecked() ));
  229     dlg.cbFragment->setEnabled(selIdx==1 || selIdx==3 || selIdx==4|| selIdx==6);
  230     dlg.cbParseAsciiArt->setEnabled(selIdx==1 || selIdx==2);
  231 
  232     dlg.lblEncoding->setEnabled(selIdx==1|| selIdx==2 || selIdx==3);
  233     dlg.comboEncoding->setEnabled(selIdx==1 || selIdx==2 ||selIdx==3);
  234     dlg.leTitle->setEnabled(selIdx==1||selIdx==3||selIdx==4|| selIdx==7);
  235     dlg.lblTitle->setEnabled(selIdx==1||selIdx==3||selIdx==4|| selIdx==7);
  236     dlg.cbDeriveStyles->setEnabled(selIdx==1|| selIdx==7);
  237 
  238     dlg.comboFont->setEnabled(selIdx==1||selIdx==2||selIdx==6|| selIdx==7);
  239     dlg.cbOmitVersion->setEnabled(selIdx==1|| selIdx==3 || selIdx==4|| selIdx==7);
  240     dlg.leStyleFile->setEnabled(selIdx==1|| selIdx==3 || selIdx==4|| selIdx==7);
  241     dlg.lblStyleFile->setEnabled(selIdx==1|| selIdx==3 || selIdx==4|| selIdx==7);
  242 
  243     dlg.comboAnsiFormat->setEnabled(dlg.cbParseAsciiArt->isEnabled() && dlg.cbParseAsciiArt->isChecked());
  244     dlg.artSizeFrame->setEnabled(dlg.cbParseAsciiArt->isEnabled() && dlg.cbParseAsciiArt->isChecked());
  245     dlg.lblHeight->setEnabled(dlg.gbAsciiArt->isEnabled());
  246     dlg.sbHeight->setEnabled(dlg.gbAsciiArt->isEnabled());
  247     dlg.lblWidth->setEnabled(dlg.gbAsciiArt->isEnabled());
  248     dlg.sbWidth->setEnabled(dlg.gbAsciiArt->isEnabled());
  249     dlg.cbIgnClearSeq->setEnabled(!dlg.cbParseAsciiArt->isChecked());
  250     dlg.cbIgnCSISeq->setEnabled(!dlg.cbParseAsciiArt->isChecked());
  251 
  252     dlg.cbWatchFile->setEnabled(!dlg.cbParseAsciiArt->isChecked());
  253 
  254     dlg.leSvgHeight->setEnabled(selIdx==7);
  255     dlg.leSvgWidth->setEnabled(selIdx==7);
  256     dlg.lblSvgDim->setEnabled(selIdx==7);
  257 }
  258 
  259 ansifilter::OutputType MyDialog::getOutputType()
  260 {
  261     switch (dlg.comboFormat->currentIndex()) {
  262 
  263     case 1:
  264         return ansifilter::HTML;
  265     case 2:
  266         return ansifilter::RTF;
  267     case 3:
  268         return ansifilter::LATEX;
  269     case 4:
  270         return ansifilter::TEX;
  271     case 5:
  272         return ansifilter::BBCODE;
  273     case 6:
  274         return ansifilter::PANGO;
  275     case 7:
  276         return ansifilter::SVG;
  277     }
  278     return ansifilter::TEXT;
  279 }
  280 
  281 QString MyDialog::getOutFileSuffix()
  282 {
  283     switch (dlg.comboFormat->currentIndex()) {
  284     case 1:
  285         return ".html";
  286     case 2:
  287         return ".rtf";
  288     case 3:
  289         return ".latex";
  290     case 4:
  291         return ".tex";
  292     case 5:
  293         return ".bbcode";
  294     case 6:
  295         return ".pango";
  296     case 7:
  297         return ".svg";
  298     }
  299     return ".txt";
  300 }
  301 
  302 void MyDialog::on_pbSaveAs_clicked()
  303 {
  304     if (inputFileName.isEmpty()) {
  305         QMessageBox::information(this, "Note", "Please select an input file.");
  306         return;
  307     }
  308 
  309     QFileInfo check_file(dlg.leColorMapPath->text());
  310     if (dlg.leColorMapPath->text().length() && (!check_file.exists() || !check_file.isFile())) {
  311         QMessageBox::information(this, "Note", "Please select a color map file.");
  312         dlg.leColorMapPath->setFocus();
  313         return;
  314     }
  315 
  316     QString outFileSuffix = getOutFileSuffix();
  317 
  318     QString outFileName =QFileDialog::getSaveFileName(this, tr("Save File"), outputFileName,
  319                          outFileSuffix.mid(1).toUpper() + " (*" + outFileSuffix+")" );
  320 
  321     QString title(QFileInfo(outFileName).fileName());
  322 
  323     unique_ptr<ansifilter::CodeGenerator> generator(ansifilter::CodeGenerator::getInstance(getOutputType()));
  324     generator->setTitle( (dlg.leTitle->text().isEmpty()? title : dlg.leTitle->text()).toStdString());
  325     generator->setEncoding(dlg.comboEncoding->currentText().toStdString());
  326     generator->setFragmentCode(dlg.cbFragment->isChecked());
  327     generator->setPlainOutput(dlg.cbIgnoreSequences->isChecked());
  328     generator->setOmitVersionInfo(dlg.cbOmitVersion->isChecked());
  329 
  330     generator->setIgnoreClearSeq(dlg.cbIgnClearSeq->isChecked());
  331     generator->setIgnoreCSISeq(dlg.cbIgnCSISeq->isChecked());
  332 
  333     generator->setApplyDynStyles(dlg.cbDeriveStyles->isChecked());
  334 
  335     generator->setSVGSize(dlg.leSvgWidth->text().toStdString(), dlg.leSvgHeight->text().toStdString());
  336 
  337 
  338     if (dlg.leStyleFile->text().isEmpty() && dlg.cbDeriveStyles->isChecked()&& (dlg.comboFormat->currentIndex()==1 || dlg.comboFormat->currentIndex()==7) )
  339         dlg.leStyleFile->setText("derived_styles.css");
  340 
  341     generator->setStyleSheet(dlg.leStyleFile->text().toStdString());
  342 
  343     if (dlg.cbParseAsciiArt->isChecked()){
  344         switch (dlg.comboAnsiFormat->currentIndex()){
  345             case 0:
  346                 generator->setParseCodePage437(true);
  347                 break;
  348             case 1:
  349                 generator->setParseAsciiBin(true);
  350                 break;
  351             case 2:
  352                 generator->setParseAsciiTundra(true);
  353                 break;
  354         }
  355         generator->setAsciiArtSize(dlg.sbWidth->value(), dlg.sbHeight->value());
  356     }
  357 
  358     generator->setFont(dlg.comboFont->currentFont().family().toStdString());
  359     generator->setPreformatting ( ansifilter::WRAP_SIMPLE, static_cast<unsigned int>(dlg.spinBoxWrap->value()) );
  360     generator->setFontSize("10pt"); //TODO TeX?
  361 
  362     if (!generator->setColorMap(dlg.leColorMapPath->text().toStdString())){
  363         QMessageBox::warning(this, "Color Mapping Error", "Could not read color map");
  364         return;
  365     }
  366 
  367     this->setCursor(Qt::WaitCursor);
  368 
  369     QString inputFileNameShort(inputFileName);
  370     QString outFileNameShort(outFileName);
  371 
  372 #ifdef Q_OS_WIN
  373     QFile file( outFileName );
  374     if ( file.open(QIODevice::ReadWrite) )
  375     {
  376         outFileNameShort = getWindowsShortPath(outFileName);
  377     }
  378     inputFileNameShort = getWindowsShortPath(inputFileName);
  379 #endif
  380 
  381     ansifilter::ParseError result= generator->generateFile( inputFileNameShort.toStdString (), outFileNameShort.toStdString () ) ;
  382     if (result==ansifilter::BAD_OUTPUT) {
  383         QMessageBox::warning(this, "IO Error", "Could not write output file");
  384     } else if (result==ansifilter::BAD_INPUT) {
  385         QMessageBox::warning(this, "IO Error", "Could not read input file");
  386     } else {
  387         outputFileName = outFileName;
  388 
  389         if (dlg.cbDeriveStyles->isChecked() && (dlg.comboFormat->currentIndex()==1 || dlg.comboFormat->currentIndex()==7) ) {
  390             QString styleStyleSheetPath =  QFileInfo(outFileName).absolutePath()  + QDir::separator() + "derived_styles.css";
  391             generator->printDynamicStyleFile(styleStyleSheetPath.toStdString());
  392         }
  393     }
  394     this->setCursor(Qt::ArrowCursor);
  395 
  396 }
  397 
  398 
  399 void MyDialog::on_pbClipboard_clicked()
  400 {
  401 
  402     if (inputFileName.isEmpty()) {
  403         QMessageBox::information(this, "Note", "Please select an input file.");
  404         return;
  405     }
  406 
  407     unique_ptr<ansifilter::CodeGenerator> generator(ansifilter::CodeGenerator::getInstance(ansifilter::TEXT));
  408     generator->setPreformatting ( ansifilter::WRAP_SIMPLE, static_cast<unsigned int>(dlg.spinBoxWrap->value()));
  409     generator->setIgnoreClearSeq(dlg.cbIgnClearSeq->isChecked());
  410     generator->setIgnoreCSISeq(dlg.cbIgnCSISeq->isChecked());
  411 
  412     QString inputFileNameShort(inputFileName);
  413 #ifdef Q_OS_WIN
  414     inputFileNameShort = getWindowsShortPath(inputFileName);
  415 #endif
  416     QString outString = QString(generator->generateStringFromFile( inputFileNameShort.toStdString ()).c_str() ) ;
  417 
  418     if(!outString.isEmpty()) {
  419         QClipboard *clipboard = QApplication::clipboard();
  420         clipboard->setText(outString);
  421     }
  422 }
  423 
  424 void MyDialog::on_pbSelectMapFile_clicked()
  425 {
  426   QString openFile = QFileDialog::getOpenFileName(this, tr("Open Map File"), "/home", tr("Text files (*.*)"));
  427     if (!openFile.isEmpty()) {
  428         dlg.leColorMapPath->setText(openFile);
  429         showFile();
  430     }
  431 }
  432 
  433 void MyDialog::on_pbFileOpen_clicked()
  434 {
  435     openFile (QFileDialog::getOpenFileName(this, tr("Open File"), inputFileName, tr("Text files (*.*)")));
  436 }
  437 
  438 void MyDialog::showFile()
  439 {
  440     if (inputFileName.isEmpty()) return;
  441 
  442     dlg.lblInFilePath->setText(inputFileName);
  443 
  444     unique_ptr<ansifilter::CodeGenerator> generator(ansifilter::CodeGenerator::getInstance(ansifilter::HTML));
  445 
  446     generator->setEncoding(dlg.comboEncoding->currentText().toStdString());
  447     generator->setFragmentCode(false);
  448     generator->setPlainOutput(dlg.cbIgnoreSequences->isChecked());
  449     generator->setIgnoreClearSeq(dlg.cbIgnClearSeq->isChecked());
  450     generator->setIgnoreCSISeq(dlg.cbIgnCSISeq->isChecked());
  451 
  452     if (dlg.cbParseAsciiArt->isChecked()){
  453         switch (dlg.comboAnsiFormat->currentIndex()){
  454             case 0:
  455                 generator->setParseCodePage437(true);
  456                 break;
  457             case 1:
  458                 generator->setParseAsciiBin(true);
  459                 break;
  460             case 2:
  461                 generator->setParseAsciiTundra(true);
  462                 break;
  463         }
  464         generator->setAsciiArtSize(dlg.sbWidth->value(), dlg.sbHeight->value());
  465     }
  466 
  467     generator->setFont(dlg.comboFont->currentFont().family().toStdString());
  468     generator->setPreformatting ( ansifilter::WRAP_SIMPLE, static_cast<unsigned int>(dlg.spinBoxWrap->value()) );
  469     generator->setFontSize("10pt");
  470     if (!generator->setColorMap(dlg.leColorMapPath->text().toStdString())){
  471         QMessageBox::warning(this, "Color Mapping Error", "Could not read color map");
  472         return;
  473     }
  474 
  475     this->setCursor(Qt::WaitCursor);
  476 
  477     QString inputFileNameShort(inputFileName);
  478 #ifdef Q_OS_WIN
  479     inputFileNameShort = getWindowsShortPath(inputFileName);
  480 #endif
  481     string htmlStdString=generator->generateStringFromFile(inputFileNameShort.toStdString ());
  482     QString htmlString( htmlStdString.c_str() );
  483     if (!htmlString.isEmpty()) {
  484 
  485         dlg.textEdit->setText(htmlString);
  486         this->setWindowTitle("ANSIFilter - " + inputFileName);
  487     }
  488     this->setCursor(Qt::ArrowCursor);
  489 }
  490 
  491 void MyDialog::on_pbAbout_clicked()
  492 {
  493     QMessageBox::about(this,
  494                        "ANSIFilter Information",
  495                        QString("ANSIFilter GUI %1\n"
  496                        "(c) 2007-2021 Andre Simon\n\n"
  497                        "Built with Qt version %2\n\n"
  498                        "Released under the terms of the GNU GPL license.\n\n"
  499                        "%3\n"
  500                        "See %4 for updates.").arg(QString::fromStdString(Info::getVersion())).arg(QString(qVersion())).arg(QString::fromStdString(Info::getEmail())).arg(QString::fromStdString(Info::getWebsite()))
  501                       );
  502 }
  503 
  504 void MyDialog::on_cbIgnoreSequences_stateChanged()
  505 {
  506     showFile();
  507 }
  508 
  509 void MyDialog::on_cbParseAsciiArt_clicked()
  510 {
  511     plausibility();
  512     showFile();
  513 }
  514 
  515 
  516 void MyDialog::on_sbWidth_valueChanged(int i)
  517 {
  518     showFile();
  519 }
  520 void MyDialog::on_sbHeight_valueChanged(int i)
  521 {
  522     showFile();
  523 }
  524 void MyDialog::on_comboAnsiFormat_currentIndexChanged(int idx)
  525 {
  526     showFile();
  527 }
  528 void MyDialog::on_comboFont_currentIndexChanged(int idx)
  529 {
  530     showFile();
  531 }
  532 void MyDialog::on_comboEncoding_currentIndexChanged(int idx)
  533 {
  534     showFile();
  535 }
  536 
  537 void MyDialog::on_cbIgnClearSeq_clicked()
  538 {
  539     showFile();
  540 }
  541 
  542 void MyDialog::on_cbIgnCSISeq_clicked()
  543 {
  544     showFile();
  545 }
  546 
  547 void MyDialog::on_cbWatchFile_stateChanged()
  548 {
  549     if (dlg.cbWatchFile->isChecked() && !inputFileName.isEmpty())
  550         fileWatcher.addPath(inputFileName);
  551     else
  552         fileWatcher.removePath(inputFileName);
  553 }
  554 
  555 QString MyDialog::getWindowsShortPath(const QString & path){
  556     QString shortPath(path);
  557 #ifdef Q_OS_WIN
  558         int length = GetShortPathName( (const wchar_t*)path.utf16(),0,0);
  559         wchar_t* buffer = new wchar_t[length];
  560 
  561         length = GetShortPathName( (const wchar_t*)path.utf16(), buffer, length);
  562         shortPath = QString::fromUtf16((const char16_t*)buffer, length);
  563         delete[] buffer;
  564 #endif
  565     return shortPath;
  566 }