Skip to content

Commit 275ae37

Browse files
committed
Version 1.0.15
2 parents f6dadc3 + 38f114e commit 275ae37

File tree

852 files changed

+72800
-69851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

852 files changed

+72800
-69851
lines changed

.clang-format

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
BasedOnStyle: Chromium
3+
AccessModifierOffset: -1
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: Left
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: false
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: Inline
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: true
19+
AlwaysBreakTemplateDeclarations: true
20+
BinPackArguments: true
21+
BinPackParameters: false
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: false
27+
AfterNamespace: false
28+
AfterObjCDeclaration: false
29+
AfterStruct: false
30+
AfterUnion: false
31+
AfterExternBlock: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
SplitEmptyFunction: true
36+
SplitEmptyRecord: true
37+
SplitEmptyNamespace: true
38+
BreakBeforeBinaryOperators: All
39+
BreakBeforeBraces: Attach
40+
BreakBeforeInheritanceComma: false
41+
BreakBeforeTernaryOperators: true
42+
BreakConstructorInitializersBeforeComma: false
43+
BreakConstructorInitializers: BeforeColon
44+
BreakAfterJavaFieldAnnotations: false
45+
BreakStringLiterals: true
46+
ColumnLimit: 120
47+
CommentPragmas: '^ IWYU pragma:'
48+
CompactNamespaces: false
49+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
50+
ConstructorInitializerIndentWidth: 4
51+
ContinuationIndentWidth: 4
52+
Cpp11BracedListStyle: true
53+
DerivePointerAlignment: false
54+
DisableFormat: false
55+
ExperimentalAutoDetectBinPacking: false
56+
FixNamespaceComments: true
57+
IndentCaseLabels: true
58+
IndentPPDirectives: None
59+
IndentWidth: 2
60+
IndentWrappedFunctionNames: false
61+
JavaScriptQuotes: Leave
62+
JavaScriptWrapImports: true
63+
KeepEmptyLinesAtTheStartOfBlocks: false
64+
MacroBlockBegin: ''
65+
MacroBlockEnd: ''
66+
MaxEmptyLinesToKeep: 2
67+
NamespaceIndentation: None
68+
ObjCBlockIndentWidth: 2
69+
ObjCSpaceAfterProperty: false
70+
ObjCSpaceBeforeProtocolList: false
71+
PenaltyBreakAssignment: 2
72+
PenaltyBreakBeforeFirstCallParameter: 1
73+
PenaltyBreakComment: 300
74+
PenaltyBreakFirstLessLess: 120
75+
PenaltyBreakString: 1000
76+
PenaltyExcessCharacter: 1000000
77+
PenaltyReturnTypeOnItsOwnLine: 200
78+
PointerAlignment: Left
79+
ReflowComments: true
80+
SortIncludes: true
81+
SortUsingDeclarations: true
82+
SpaceAfterCStyleCast: true
83+
SpaceAfterTemplateKeyword: true
84+
SpaceBeforeAssignmentOperators: true
85+
SpaceBeforeParens: ControlStatements
86+
SpaceInEmptyParentheses: false
87+
SpacesBeforeTrailingComments: 2
88+
SpacesInAngles: false
89+
SpacesInContainerLiterals: true
90+
SpacesInCStyleCastParentheses: false
91+
SpacesInParentheses: false
92+
SpacesInSquareBrackets: false
93+
Standard: Cpp11
94+
TabWidth: 8
95+
UseTab: Never
96+
...

AbstractCommand.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
#ifndef ABSTRACTCOMMAND_H_
2020
#define ABSTRACTCOMMAND_H_
2121

22-
#include "ref_countable.h"
2322
#include "intrusive_ptr.h"
23+
#include "ref_countable.h"
2424

25-
template<typename Res, typename... ArgTypes>
25+
template <typename Res, typename... ArgTypes>
2626
class AbstractCommand : public ref_countable {
27-
public:
28-
typedef intrusive_ptr<AbstractCommand> Ptr;
27+
public:
28+
typedef intrusive_ptr<AbstractCommand> Ptr;
2929

30-
virtual Res operator()(ArgTypes... args) = 0;
30+
virtual Res operator()(ArgTypes... args) = 0;
3131
};
3232

3333
#endif // ifndef ABSTRACTCOMMAND_H_

AbstractFilter.h

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#ifndef ABSTRACTFILTER_H_
2020
#define ABSTRACTFILTER_H_
2121

22-
#include "ref_countable.h"
23-
#include "PageView.h"
24-
#include "PageOrderOption.h"
2522
#include <vector>
23+
#include "PageOrderOption.h"
24+
#include "PageView.h"
25+
#include "ref_countable.h"
2626

2727
class FilterUiInterface;
2828
class PageInfo;
@@ -37,36 +37,30 @@ class QDomElement;
3737
* Filters represent processing stages, like "Deskew", "Margins" and "Output".
3838
*/
3939
class AbstractFilter : public ref_countable {
40-
public:
41-
~AbstractFilter() override = default;
40+
public:
41+
~AbstractFilter() override = default;
4242

43-
virtual QString getName() const = 0;
43+
virtual QString getName() const = 0;
4444

45-
virtual PageView getView() const = 0;
45+
virtual PageView getView() const = 0;
4646

47-
virtual void selected() {
48-
}
47+
virtual void selected() {}
4948

50-
virtual int selectedPageOrder() const {
51-
return -1;
52-
}
49+
virtual int selectedPageOrder() const { return -1; }
5350

54-
virtual void selectPageOrder(int option) {
55-
}
51+
virtual void selectPageOrder(int option) {}
5652

57-
virtual std::vector<PageOrderOption> pageOrderOptions() const {
58-
return std::vector<PageOrderOption>();
59-
}
53+
virtual std::vector<PageOrderOption> pageOrderOptions() const { return std::vector<PageOrderOption>(); }
6054

61-
virtual void performRelinking(const AbstractRelinker& relinker) = 0;
55+
virtual void performRelinking(const AbstractRelinker& relinker) = 0;
6256

63-
virtual void preUpdateUI(FilterUiInterface* ui, const PageInfo& page_info) = 0;
57+
virtual void preUpdateUI(FilterUiInterface* ui, const PageInfo& page_info) = 0;
6458

65-
virtual QDomElement saveSettings(const ProjectWriter& writer, QDomDocument& doc) const = 0;
59+
virtual QDomElement saveSettings(const ProjectWriter& writer, QDomDocument& doc) const = 0;
6660

67-
virtual void loadSettings(const ProjectReader& reader, const QDomElement& filters_el) = 0;
61+
virtual void loadSettings(const ProjectReader& reader, const QDomElement& filters_el) = 0;
6862

69-
virtual void loadDefaultSettings(const PageInfo& page_info) = 0;
63+
virtual void loadDefaultSettings(const PageInfo& page_info) = 0;
7064
};
7165

7266

AbstractRelinker.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ class RelinkablePath;
2525
class QString;
2626

2727
class AbstractRelinker : public ref_countable {
28-
public:
29-
~AbstractRelinker() override = default;
30-
31-
/**
32-
* Returns the path to be used instead of the given path.
33-
* The same path will be returned if no substitution is to be made.
34-
*/
35-
virtual QString substitutionPathFor(const RelinkablePath& orig_path) const = 0;
28+
public:
29+
~AbstractRelinker() override = default;
30+
31+
/**
32+
* Returns the path to be used instead of the given path.
33+
* The same path will be returned if no substitution is to be made.
34+
*/
35+
virtual QString substitutionPathFor(const RelinkablePath& orig_path) const = 0;
3636
};
3737

3838

Application.cpp

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,83 +16,106 @@
1616
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#include "RelinkingDialog.h"
20-
#include "LoadFilesStatusDialog.h"
19+
#include "Application.h"
20+
#include <config.h>
21+
#include <QDir>
22+
#include <QTemporaryDir>
23+
#include "DebugImages.h"
24+
#include "ErrorWidget.h"
2125
#include "FixDpiDialog.h"
2226
#include "ImageMetadataLoader.h"
27+
#include "LoadFilesStatusDialog.h"
28+
#include "MainWindow.h"
29+
#include "NewOpenProjectPanel.h"
30+
#include "OutOfMemoryHandler.h"
2331
#include "ProcessingIndicationWidget.h"
2432
#include "ProjectOpeningContext.h"
25-
#include "DebugImages.h"
26-
#include "ErrorWidget.h"
27-
#include "Utils.h"
33+
#include "RelinkingDialog.h"
2834
#include "StageSequence.h"
29-
#include "NewOpenProjectPanel.h"
30-
#include "MainWindow.h"
31-
#include "Application.h"
32-
#include "OutOfMemoryHandler.h"
33-
#include <config.h>
34-
#include <QtCore/QDir>
35+
#include "Utils.h"
3536

3637
Application::Application(int& argc, char** argv) : QApplication(argc, argv), m_currentLocale("en") {
37-
initTranslations();
38+
initTranslations();
39+
initPortableVersion();
3840
}
3941

4042
bool Application::notify(QObject* receiver, QEvent* e) {
41-
try {
42-
return QApplication::notify(receiver, e);
43-
} catch (const std::bad_alloc&) {
44-
OutOfMemoryHandler::instance().handleOutOfMemorySituation();
43+
try {
44+
return QApplication::notify(receiver, e);
45+
} catch (const std::bad_alloc&) {
46+
OutOfMemoryHandler::instance().handleOutOfMemorySituation();
4547

46-
return false;
47-
}
48+
return false;
49+
}
4850
}
4951

5052
void Application::installLanguage(const QString& locale) {
51-
if (m_currentLocale == locale) {
52-
return;
53-
}
53+
if (m_currentLocale == locale) {
54+
return;
55+
}
5456

55-
if (m_translationsMap.find(locale) != m_translationsMap.end()) {
56-
bool loaded = m_translator.load(m_translationsMap[locale]);
57+
if (m_translationsMap.find(locale) != m_translationsMap.end()) {
58+
bool loaded = m_translator.load(m_translationsMap[locale]);
5759

58-
this->removeTranslator(&m_translator);
59-
this->installTranslator(&m_translator);
60+
this->removeTranslator(&m_translator);
61+
this->installTranslator(&m_translator);
6062

61-
m_currentLocale = (loaded) ? locale : "en";
62-
} else {
63-
this->removeTranslator(&m_translator);
63+
m_currentLocale = (loaded) ? locale : "en";
64+
} else {
65+
this->removeTranslator(&m_translator);
6466

65-
m_currentLocale = "en";
66-
}
67+
m_currentLocale = "en";
68+
}
6769
}
6870

6971
const QString& Application::getCurrentLocale() const {
70-
return m_currentLocale;
72+
return m_currentLocale;
7173
}
7274

7375
std::list<QString> Application::getLanguagesList() const {
74-
std::list<QString> list{"en"};
75-
std::transform(m_translationsMap.begin(), m_translationsMap.end(), std::back_inserter(list),
76-
[](const std::pair<QString, QString>& val) { return val.first; });
76+
std::list<QString> list{"en"};
77+
std::transform(m_translationsMap.begin(), m_translationsMap.end(), std::back_inserter(list),
78+
[](const std::pair<QString, QString>& val) { return val.first; });
7779

78-
return list;
80+
return list;
7981
}
8082

8183
void Application::initTranslations() {
82-
const QStringList translation_dirs(QString::fromUtf8(TRANSLATION_DIRS).split(QChar(':'), QString::SkipEmptyParts));
83-
84-
const QStringList language_file_filter("scantailor_*.qm");
85-
for (const QString& path : translation_dirs) {
86-
QDir dir(QDir::cleanPath(applicationDirPath() + '/' + path));
87-
if (dir.exists()) {
88-
QStringList translationFileNames = QDir(dir.path()).entryList(language_file_filter);
89-
for (const QString& fileName : translationFileNames) {
90-
QString locale(fileName);
91-
locale.truncate(locale.lastIndexOf('.'));
92-
locale.remove(0, locale.indexOf('_') + 1);
93-
94-
m_translationsMap[locale] = dir.absoluteFilePath(fileName);
95-
}
96-
}
84+
const QStringList translation_dirs(QString::fromUtf8(TRANSLATION_DIRS).split(QChar(':'), QString::SkipEmptyParts));
85+
86+
const QStringList language_file_filter("scantailor_*.qm");
87+
for (const QString& path : translation_dirs) {
88+
QDir dir = (QDir::isAbsolutePath(path)) ? QDir(path) : QDir::cleanPath(applicationDirPath() + '/' + path);
89+
if (dir.exists()) {
90+
QStringList translationFileNames = QDir(dir.path()).entryList(language_file_filter);
91+
for (const QString& fileName : translationFileNames) {
92+
QString locale(fileName);
93+
locale.truncate(locale.lastIndexOf('.'));
94+
locale.remove(0, locale.indexOf('_') + 1);
95+
96+
m_translationsMap[locale] = dir.absoluteFilePath(fileName);
97+
}
9798
}
99+
}
100+
}
101+
102+
void Application::initPortableVersion() {
103+
const QString portableConfigDirName = QString::fromUtf8(PORTABLE_CONFIG_DIR);
104+
if (portableConfigDirName.isEmpty()) {
105+
return;
106+
}
107+
108+
const QDir portableConfigPath(applicationDirPath() + '/' + portableConfigDirName);
109+
if ((portableConfigPath.exists() && QTemporaryDir(portableConfigPath.absolutePath()).isValid())
110+
|| (!portableConfigPath.exists() && portableConfigPath.mkpath("."))) {
111+
m_portableConfigPath = portableConfigPath.absolutePath();
112+
}
113+
}
114+
115+
bool Application::isPortableVersion() const {
116+
return !m_portableConfigPath.isNull();
117+
}
118+
119+
const QString& Application::getPortableConfigPath() const {
120+
return m_portableConfigPath;
98121
}

0 commit comments

Comments
 (0)