Skip to content

Commit

Permalink
implemented quiet batch mode - fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
krzemin committed Nov 22, 2015
1 parent ac3e951 commit 590f7f5
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 83 deletions.
3 changes: 2 additions & 1 deletion doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
QNapi ChangeLog:
================

2015-11-?? v0.2.0:
2015-11-22 v0.2.0:
* możliwość wyboru cichego trybu wsadowego - #13
* poprawki bledow w silniku Napisy24 - #23
* umieszczenie ikon w katalogach opisujacych ich rozmiar - #24 (thx Fisiu)
* wsparcie dla ekranow retina (OSX) - #27
Expand Down
16 changes: 13 additions & 3 deletions src/forms/frmoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ frmOptions::frmOptions(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f)
{
ui.setupUi(this);

#ifdef Q_OS_MAC
ui.cbQuietBatch->hide();
#endif

#ifndef Q_OS_MAC
ui.cbShowDockIcon->hide();
#endif


#ifdef Q_OS_WIN
// Pod Windowsami chowamy kontrolki odpowiadajace za zmiane uprawnien - i tak sie nie przydadza
ui.cbChangePermissions->hide();
Expand Down Expand Up @@ -333,6 +338,9 @@ void frmOptions::writeConfig()
GlobalConfig().setLanguage(ui.cbLang->itemData(ui.cbLang->currentIndex()).toString());
GlobalConfig().setLanguageBackup(ui.cbLangBackup->itemData(ui.cbLangBackup->currentIndex()).toString());
GlobalConfig().setNoBackup(ui.cbNoBackup->isChecked());
#ifndef Q_OS_MAC
GlobalConfig().setQuietBatch(ui.cbQuietBatch->isChecked());
#endif

#ifdef Q_OS_MAC
GlobalConfig().setShowDockIcon(ui.cbShowDockIcon->isChecked());
Expand Down Expand Up @@ -375,16 +383,17 @@ void frmOptions::writeConfig()

void frmOptions::readConfig()
{
GlobalConfig().reload();
GlobalConfig().load(QCoreApplication::applicationDirPath());

ui.le7zPath->setText(GlobalConfig().p7zipPath());
ui.leFfprobePath->setText(GlobalConfig().ffProbePath());
ui.leTmpPath->setText(GlobalConfig().tmpPath());
ui.cbLang->setCurrentIndex(ui.cbLang->findData(QNapiLanguage(GlobalConfig().language()).toTwoLetter()));
ui.cbLangBackup->setCurrentIndex(ui.cbLangBackup->findData(QNapiLanguage(GlobalConfig().languageBackup()).toTwoLetter()));

ui.cbNoBackup->setChecked(GlobalConfig().noBackup());

#ifndef Q_OS_MAC
ui.cbQuietBatch->setChecked(GlobalConfig().quietBatch());
#endif
#ifdef Q_OS_MAC
ui.cbShowDockIcon->setChecked(GlobalConfig().showDockIcon());
#endif
Expand Down Expand Up @@ -460,6 +469,7 @@ void frmOptions::restoreDefaults()
GlobalConfig().setLanguage("pl");
GlobalConfig().setLanguageBackup("en");
GlobalConfig().setNoBackup(false);
GlobalConfig().setQuietBatch(false);
GlobalConfig().setChangePermissions(false);
GlobalConfig().setChangePermissionsTo("644");

Expand Down
13 changes: 9 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "qnapiconfig.h"
#include "qnapiapp.h"
#include "qnapicli.h"

#include <signal.h>

QStringList parseArgs(int argc, char **argv);
Expand All @@ -33,16 +32,22 @@ void sigHandler(int);

int main(int argc, char **argv)
{
bool useGui = !QNapiCli::isCliCall(argc, argv);
bool isCliCall = QNapiCli::isCliCall(argc, argv);

QStringList pathList = parseArgs(argc, argv);

regSignal();

QFileInfo appExe(argv[0]);
GlobalConfig().load(appExe.absoluteDir().path());

bool quietBatch = GlobalConfig().quietBatch();
bool useGui = !isCliCall && !(quietBatch && !pathList.isEmpty());

if(useGui)
{
QNapiApp app(argc, argv, true, "QNapi");

QStringList pathList = parseArgs(argc, argv);

QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
QTranslator cuteTranslator;
cuteTranslator.load("qt_" + QLocale::system().name(), resourceDir);
Expand Down
7 changes: 7 additions & 0 deletions src/qnapicli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ bool QNapiCli::analyze()
}
}

bool quietBatch = GlobalConfig().quietBatch();
if(quietBatch && !movieList.isEmpty())
{
mode = CM_QUIET;
return true;
}

#if (defined(Q_OS_UNIX) || defined(Q_OS_LINUX))
if((getenv("DISPLAY") == 0) && (mode == CM_UNSET))
mode = CM_CONSOLE;
Expand Down
21 changes: 18 additions & 3 deletions src/qnapiconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@

QNapiConfig::QNapiConfig()
{
reload();
}

QNapiConfig::~QNapiConfig()
{
if(settings) delete settings;
}

void QNapiConfig::reload()
void QNapiConfig::load(QString appDirPath)
{
if(settings) delete settings;

QString localQNapiIniPath = QCoreApplication::applicationDirPath() + QDir::separator() + "qnapi.ini";
QString localQNapiIniPath = appDirPath + QDir::separator() + "qnapi.ini";
isPortableMode = QFileInfo(localQNapiIniPath).exists();

if(isPortableMode)
Expand Down Expand Up @@ -250,6 +249,22 @@ void QNapiConfig::setNoBackup(bool noBackup)
settings->setValue("qnapi/no_backup", noBackup);
}

bool QNapiConfig::quietBatch()
{
#ifdef Q_OS_MAC
return false;
#else
return settings->value("qnapi/quiet_batch", false).toBool();
#endif
}

void QNapiConfig::setQuietBatch(bool quietBatch)
{
#ifndef Q_OS_MAC
settings->setValue("qnapi/quiet_batch", quietBatch);
#endif
}

#ifdef Q_OS_MAC
bool QNapiConfig::showDockIcon()
{
Expand Down
5 changes: 4 additions & 1 deletion src/qnapiconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum ChangeEncodingMethod
class QNapiConfig
{
public:
void reload();
void load(QString appDirPath);
void save();

bool firstRun();
Expand Down Expand Up @@ -86,6 +86,9 @@ class QNapiConfig
bool noBackup();
void setNoBackup(bool noBackup);

bool quietBatch();
void setQuietBatch(bool quietBatch);

#ifdef Q_OS_MAC
bool showDockIcon();
void setShowDockIcon(bool show);
Expand Down
Loading

0 comments on commit 590f7f5

Please sign in to comment.