Skip to content

Commit

Permalink
Version 1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
4lex4 committed Jul 5, 2018
2 parents f6dadc3 + 38f114e commit 275ae37
Show file tree
Hide file tree
Showing 852 changed files with 72,800 additions and 69,851 deletions.
96 changes: 96 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
BasedOnStyle: Chromium
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
10 changes: 5 additions & 5 deletions AbstractCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
#ifndef ABSTRACTCOMMAND_H_
#define ABSTRACTCOMMAND_H_

#include "ref_countable.h"
#include "intrusive_ptr.h"
#include "ref_countable.h"

template<typename Res, typename... ArgTypes>
template <typename Res, typename... ArgTypes>
class AbstractCommand : public ref_countable {
public:
typedef intrusive_ptr<AbstractCommand> Ptr;
public:
typedef intrusive_ptr<AbstractCommand> Ptr;

virtual Res operator()(ArgTypes... args) = 0;
virtual Res operator()(ArgTypes... args) = 0;
};

#endif // ifndef ABSTRACTCOMMAND_H_
38 changes: 16 additions & 22 deletions AbstractFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#ifndef ABSTRACTFILTER_H_
#define ABSTRACTFILTER_H_

#include "ref_countable.h"
#include "PageView.h"
#include "PageOrderOption.h"
#include <vector>
#include "PageOrderOption.h"
#include "PageView.h"
#include "ref_countable.h"

class FilterUiInterface;
class PageInfo;
Expand All @@ -37,36 +37,30 @@ class QDomElement;
* Filters represent processing stages, like "Deskew", "Margins" and "Output".
*/
class AbstractFilter : public ref_countable {
public:
~AbstractFilter() override = default;
public:
~AbstractFilter() override = default;

virtual QString getName() const = 0;
virtual QString getName() const = 0;

virtual PageView getView() const = 0;
virtual PageView getView() const = 0;

virtual void selected() {
}
virtual void selected() {}

virtual int selectedPageOrder() const {
return -1;
}
virtual int selectedPageOrder() const { return -1; }

virtual void selectPageOrder(int option) {
}
virtual void selectPageOrder(int option) {}

virtual std::vector<PageOrderOption> pageOrderOptions() const {
return std::vector<PageOrderOption>();
}
virtual std::vector<PageOrderOption> pageOrderOptions() const { return std::vector<PageOrderOption>(); }

virtual void performRelinking(const AbstractRelinker& relinker) = 0;
virtual void performRelinking(const AbstractRelinker& relinker) = 0;

virtual void preUpdateUI(FilterUiInterface* ui, const PageInfo& page_info) = 0;
virtual void preUpdateUI(FilterUiInterface* ui, const PageInfo& page_info) = 0;

virtual QDomElement saveSettings(const ProjectWriter& writer, QDomDocument& doc) const = 0;
virtual QDomElement saveSettings(const ProjectWriter& writer, QDomDocument& doc) const = 0;

virtual void loadSettings(const ProjectReader& reader, const QDomElement& filters_el) = 0;
virtual void loadSettings(const ProjectReader& reader, const QDomElement& filters_el) = 0;

virtual void loadDefaultSettings(const PageInfo& page_info) = 0;
virtual void loadDefaultSettings(const PageInfo& page_info) = 0;
};


Expand Down
16 changes: 8 additions & 8 deletions AbstractRelinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class RelinkablePath;
class QString;

class AbstractRelinker : public ref_countable {
public:
~AbstractRelinker() override = default;

/**
* Returns the path to be used instead of the given path.
* The same path will be returned if no substitution is to be made.
*/
virtual QString substitutionPathFor(const RelinkablePath& orig_path) const = 0;
public:
~AbstractRelinker() override = default;

/**
* Returns the path to be used instead of the given path.
* The same path will be returned if no substitution is to be made.
*/
virtual QString substitutionPathFor(const RelinkablePath& orig_path) const = 0;
};


Expand Down
123 changes: 73 additions & 50 deletions Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,83 +16,106 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "RelinkingDialog.h"
#include "LoadFilesStatusDialog.h"
#include "Application.h"
#include <config.h>
#include <QDir>
#include <QTemporaryDir>
#include "DebugImages.h"
#include "ErrorWidget.h"
#include "FixDpiDialog.h"
#include "ImageMetadataLoader.h"
#include "LoadFilesStatusDialog.h"
#include "MainWindow.h"
#include "NewOpenProjectPanel.h"
#include "OutOfMemoryHandler.h"
#include "ProcessingIndicationWidget.h"
#include "ProjectOpeningContext.h"
#include "DebugImages.h"
#include "ErrorWidget.h"
#include "Utils.h"
#include "RelinkingDialog.h"
#include "StageSequence.h"
#include "NewOpenProjectPanel.h"
#include "MainWindow.h"
#include "Application.h"
#include "OutOfMemoryHandler.h"
#include <config.h>
#include <QtCore/QDir>
#include "Utils.h"

Application::Application(int& argc, char** argv) : QApplication(argc, argv), m_currentLocale("en") {
initTranslations();
initTranslations();
initPortableVersion();
}

bool Application::notify(QObject* receiver, QEvent* e) {
try {
return QApplication::notify(receiver, e);
} catch (const std::bad_alloc&) {
OutOfMemoryHandler::instance().handleOutOfMemorySituation();
try {
return QApplication::notify(receiver, e);
} catch (const std::bad_alloc&) {
OutOfMemoryHandler::instance().handleOutOfMemorySituation();

return false;
}
return false;
}
}

void Application::installLanguage(const QString& locale) {
if (m_currentLocale == locale) {
return;
}
if (m_currentLocale == locale) {
return;
}

if (m_translationsMap.find(locale) != m_translationsMap.end()) {
bool loaded = m_translator.load(m_translationsMap[locale]);
if (m_translationsMap.find(locale) != m_translationsMap.end()) {
bool loaded = m_translator.load(m_translationsMap[locale]);

this->removeTranslator(&m_translator);
this->installTranslator(&m_translator);
this->removeTranslator(&m_translator);
this->installTranslator(&m_translator);

m_currentLocale = (loaded) ? locale : "en";
} else {
this->removeTranslator(&m_translator);
m_currentLocale = (loaded) ? locale : "en";
} else {
this->removeTranslator(&m_translator);

m_currentLocale = "en";
}
m_currentLocale = "en";
}
}

const QString& Application::getCurrentLocale() const {
return m_currentLocale;
return m_currentLocale;
}

std::list<QString> Application::getLanguagesList() const {
std::list<QString> list{"en"};
std::transform(m_translationsMap.begin(), m_translationsMap.end(), std::back_inserter(list),
[](const std::pair<QString, QString>& val) { return val.first; });
std::list<QString> list{"en"};
std::transform(m_translationsMap.begin(), m_translationsMap.end(), std::back_inserter(list),
[](const std::pair<QString, QString>& val) { return val.first; });

return list;
return list;
}

void Application::initTranslations() {
const QStringList translation_dirs(QString::fromUtf8(TRANSLATION_DIRS).split(QChar(':'), QString::SkipEmptyParts));

const QStringList language_file_filter("scantailor_*.qm");
for (const QString& path : translation_dirs) {
QDir dir(QDir::cleanPath(applicationDirPath() + '/' + path));
if (dir.exists()) {
QStringList translationFileNames = QDir(dir.path()).entryList(language_file_filter);
for (const QString& fileName : translationFileNames) {
QString locale(fileName);
locale.truncate(locale.lastIndexOf('.'));
locale.remove(0, locale.indexOf('_') + 1);

m_translationsMap[locale] = dir.absoluteFilePath(fileName);
}
}
const QStringList translation_dirs(QString::fromUtf8(TRANSLATION_DIRS).split(QChar(':'), QString::SkipEmptyParts));

const QStringList language_file_filter("scantailor_*.qm");
for (const QString& path : translation_dirs) {
QDir dir = (QDir::isAbsolutePath(path)) ? QDir(path) : QDir::cleanPath(applicationDirPath() + '/' + path);
if (dir.exists()) {
QStringList translationFileNames = QDir(dir.path()).entryList(language_file_filter);
for (const QString& fileName : translationFileNames) {
QString locale(fileName);
locale.truncate(locale.lastIndexOf('.'));
locale.remove(0, locale.indexOf('_') + 1);

m_translationsMap[locale] = dir.absoluteFilePath(fileName);
}
}
}
}

void Application::initPortableVersion() {
const QString portableConfigDirName = QString::fromUtf8(PORTABLE_CONFIG_DIR);
if (portableConfigDirName.isEmpty()) {
return;
}

const QDir portableConfigPath(applicationDirPath() + '/' + portableConfigDirName);
if ((portableConfigPath.exists() && QTemporaryDir(portableConfigPath.absolutePath()).isValid())
|| (!portableConfigPath.exists() && portableConfigPath.mkpath("."))) {
m_portableConfigPath = portableConfigPath.absolutePath();
}
}

bool Application::isPortableVersion() const {
return !m_portableConfigPath.isNull();
}

const QString& Application::getPortableConfigPath() const {
return m_portableConfigPath;
}
Loading

0 comments on commit 275ae37

Please sign in to comment.