Compare commits
258 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ccc892d6a | ||
|
|
d7cacea843 | ||
|
|
e30233ac74 | ||
|
|
7c57631fcf | ||
|
|
0adc084dad | ||
|
|
e22199817c | ||
|
|
78f691d006 | ||
|
|
749bae1f16 | ||
|
|
1043e24322 | ||
|
|
a6d10b1fa7 | ||
|
|
a3159423f8 | ||
|
|
ecb5ca321b | ||
|
|
fd827fdfd8 | ||
|
|
92d77b14d5 | ||
|
|
be67d89d8b | ||
|
|
ddd1ce732a | ||
|
|
012d82183c | ||
|
|
f9c98ebcb3 | ||
|
|
10fe861dde | ||
|
|
16c027ecab | ||
|
|
cc578e7cc5 | ||
|
|
6972d3c4f9 | ||
|
|
46b164f2fb | ||
|
|
5431307527 | ||
|
|
79bf194ed6 | ||
|
|
506e670aa7 | ||
|
|
fdfe164dd1 | ||
|
|
af37056179 | ||
|
|
b0fc7187cf | ||
|
|
33ad1a7a86 | ||
|
|
dd72fb4ca5 | ||
|
|
e6c5f76872 | ||
|
|
14aa22d590 | ||
|
|
5ed4293641 | ||
|
|
f9fefcda57 | ||
|
|
99b40293db | ||
|
|
9b06e85f94 | ||
|
|
93d1d40ea5 | ||
|
|
98597c047a | ||
|
|
a5c1f4b0ee | ||
|
|
3d4c98d981 | ||
|
|
384e7dedb5 | ||
|
|
7df4453560 | ||
|
|
d406a1c341 | ||
|
|
6671d97b4a | ||
|
|
d02de72830 | ||
|
|
08f5172028 | ||
|
|
04f062547d | ||
|
|
4717d783dc | ||
|
|
93af064b36 | ||
|
|
c78d73d727 | ||
|
|
b69b3228be | ||
|
|
377f54700d | ||
|
|
d276339c80 | ||
|
|
b982a6a762 | ||
|
|
536fe637aa | ||
|
|
69f36eaa25 | ||
|
|
d6927a70bb | ||
|
|
1b1892a187 | ||
|
|
5bea71cd5c | ||
|
|
bb8d4e70ae | ||
|
|
8d8c7e8b7b | ||
|
|
9ff1f4d7b4 | ||
|
|
3a60dfe025 | ||
|
|
d358854e16 | ||
|
|
129587e94a | ||
|
|
0f575f4639 | ||
|
|
7aac741571 | ||
|
|
b8a9da8a4e | ||
|
|
be6b974334 | ||
|
|
194e81205b | ||
|
|
d711dcc99d | ||
|
|
3b72a12540 | ||
|
|
38a1b7765a | ||
|
|
02f2b8b6f0 | ||
|
|
7bfa75102c | ||
|
|
b0f3e7351c | ||
|
|
b5fa401db9 | ||
|
|
41f2710dea | ||
|
|
f19dda57f0 | ||
|
|
cc4a99ad80 | ||
|
|
1c1a3fc417 | ||
|
|
e97be5850b | ||
|
|
2c302654b7 | ||
|
|
3ee4dc77b2 | ||
|
|
db55f314c9 | ||
|
|
0b536b287f | ||
|
|
6f298a9917 | ||
|
|
70f829a2e5 | ||
|
|
1dfe07003f | ||
|
|
286b908062 | ||
|
|
4ec028e736 | ||
|
|
35a6d1437a | ||
|
|
7e3cb3de89 | ||
|
|
bd945039f1 | ||
|
|
46743c8f15 | ||
|
|
9b75284447 | ||
|
|
dca3b0052a | ||
|
|
6d05bb2de5 | ||
|
|
8b2e8d3804 | ||
|
|
1a2ab19ab4 | ||
|
|
04f010aa7b | ||
|
|
25323b4a3a | ||
|
|
f353c022f6 | ||
|
|
9d8b3d3428 | ||
|
|
e4b06772c0 | ||
|
|
a2b5c3ea08 | ||
|
|
f632e95600 | ||
|
|
4b5da8c6d4 | ||
|
|
77d7ffd10a | ||
|
|
d2f720011a | ||
|
|
6329a7711d | ||
|
|
fd14d044e3 | ||
|
|
6368d507e1 | ||
|
|
205b7f2401 | ||
|
|
f7d10f9530 | ||
|
|
66154bb51e | ||
|
|
fac4ad5313 | ||
|
|
fee63891ac | ||
|
|
efa979ee03 | ||
|
|
c756346357 | ||
|
|
cc95db25cc | ||
|
|
44970c3321 | ||
|
|
43c7934af7 | ||
|
|
3e7b51163c | ||
|
|
4d5f8a53f0 | ||
|
|
0b73ca8318 | ||
|
|
754cfc3bfd | ||
|
|
2ed1a5c06a | ||
|
|
b2073df3c3 | ||
|
|
6267edaa81 | ||
|
|
292f2de3e6 | ||
|
|
7803dc8be3 | ||
|
|
2a1260b79e | ||
|
|
f9ec438b7f | ||
|
|
de544c4856 | ||
|
|
55e04dd520 | ||
|
|
b2d06f900b | ||
|
|
b92ec71810 | ||
|
|
3a4199240e | ||
|
|
157de12bdf | ||
|
|
7c0c9fccdb | ||
|
|
2cb29d06b3 | ||
|
|
1fdeb50d93 | ||
|
|
f59632ae59 | ||
|
|
67b503da44 | ||
|
|
a351de6904 | ||
|
|
f94742abd5 | ||
|
|
891182637e | ||
|
|
086681c915 | ||
|
|
3970d2d02b | ||
|
|
2b3fddd015 | ||
|
|
30fa0480a3 | ||
|
|
320a81ce69 | ||
|
|
950411ef56 | ||
|
|
cb9cf084c0 | ||
|
|
bb18af09ae | ||
|
|
049bf0c7f9 | ||
|
|
ebc73ef775 | ||
|
|
1bd6f59355 | ||
|
|
c16396a690 | ||
|
|
32a9fe3e9c | ||
|
|
f48d133bc6 | ||
|
|
0678526d7d | ||
|
|
26d3e8371f | ||
|
|
6768f614c7 | ||
|
|
171dc84df1 | ||
|
|
5ca6513c04 | ||
|
|
41aeb0ac80 | ||
|
|
f871c4adef | ||
|
|
ad4d0e89b1 | ||
|
|
0d0c49caa1 | ||
|
|
7cbc7bdcfb | ||
|
|
6b46c8ed4a | ||
|
|
e33ffd1c8a | ||
|
|
8dce9cc938 | ||
|
|
f06218f8e3 | ||
|
|
5711eef2be | ||
|
|
db6aac603c | ||
|
|
f10e928106 | ||
|
|
99d963b99c | ||
|
|
5d35c22238 | ||
|
|
54fc11a235 | ||
|
|
ec99df3144 | ||
|
|
d722035883 | ||
|
|
52139fbaa0 | ||
|
|
88854eb558 | ||
|
|
c82bba01ee | ||
|
|
eaa33a03d7 | ||
|
|
89e8518f31 | ||
|
|
c7bf2e1da8 | ||
|
|
bf904a6afa | ||
|
|
43c14ae71b | ||
|
|
4abb8ef3c9 | ||
|
|
e46b92dd7d | ||
|
|
1a25faa5b9 | ||
|
|
3f4bf5f512 | ||
|
|
ae7dbf15ed | ||
|
|
b22320c48f | ||
|
|
61204e8d35 | ||
|
|
b0704c654c | ||
|
|
f40f8a8873 | ||
|
|
560a7db506 | ||
|
|
15baa8f70e | ||
|
|
97a7637294 | ||
|
|
3454656207 | ||
|
|
7dff6f26bc | ||
|
|
9e835a23fd | ||
|
|
c0259fb6ce | ||
|
|
acf106220b | ||
|
|
5d4dc9c907 | ||
|
|
2b9a56af7f | ||
|
|
f1e3ac65ac | ||
|
|
143f72cf6b | ||
|
|
5c8e49296c | ||
|
|
b2558b703c | ||
|
|
bf9d87106e | ||
|
|
5b7f507d9b | ||
|
|
59a7835ace | ||
|
|
2495838fe3 | ||
|
|
bab687bedf | ||
|
|
6467c3c8ee | ||
|
|
66c2b7aaa6 | ||
|
|
ab72c52661 | ||
|
|
f0bf1b8a54 | ||
|
|
119251719f | ||
|
|
0348400132 | ||
|
|
813473805b | ||
|
|
fe6368561b | ||
|
|
7ff06f424d | ||
|
|
31958592c7 | ||
|
|
adc21f4f75 | ||
|
|
9cecd89d6f | ||
|
|
d866b9b4d4 | ||
|
|
93f12baf51 | ||
|
|
78d6fd634b | ||
|
|
b5fc19f08a | ||
|
|
2dae6a6546 | ||
|
|
b6bba46391 | ||
|
|
b791d97116 | ||
|
|
6aa8255f34 | ||
|
|
98e2140761 | ||
|
|
a59e064778 | ||
|
|
655c4c66a7 | ||
|
|
407c128f65 | ||
|
|
59a261a5be | ||
|
|
ba4e1afefe | ||
|
|
98b53b81d8 | ||
|
|
8270cc0aa2 | ||
|
|
74207b1a87 | ||
|
|
77983445ce | ||
|
|
162190bcb8 | ||
|
|
86b92b20b7 | ||
|
|
2f5b60d548 | ||
|
|
c19661c977 | ||
|
|
82d101ca27 | ||
|
|
32f9c4e670 | ||
|
|
34c7225ab7 |
213
.clang-format
213
.clang-format
@@ -1,105 +1,216 @@
|
||||
BasedOnStyle: Chromium
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: true
|
||||
AlignEscapedNewlines: true
|
||||
AlignOperands: false
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: true
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLambdasOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: No
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BreakBeforeBraces: false
|
||||
BreakBeforeBinaryOperators: false
|
||||
BreakBeforeBraces: Stroustrup
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 0
|
||||
ColumnLimit: 0
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 2
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: BinPack
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: true
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 2
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 100
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 0
|
||||
PenaltyBreakBeforeFirstCallParameter: 0
|
||||
PenaltyBreakComment: 0
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 0
|
||||
PenaltyBreakTemplateDeclaration: 0
|
||||
PenaltyExcessCharacter: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 0
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: false
|
||||
RemoveBracesLLVM: false
|
||||
RequiresClausePosition: OwnLine
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: false
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterFunction: false
|
||||
AfterCaseLabel: false
|
||||
AfterStruct: false
|
||||
AfterClass: false
|
||||
AfterEnum: false
|
||||
AfterUnion: false
|
||||
AfterControlStatement: Never
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
|
||||
|
||||
8
.github/ISSUE_TEMPLATE.md
vendored
8
.github/ISSUE_TEMPLATE.md
vendored
@@ -7,11 +7,9 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
See the FAQ before opening an issue: https://wiki.strawberrymusicplayer.org/wiki/FAQ
|
||||
Check the Changelog to see if the issue is already fixed: https://github.com/strawberrymusicplayer/strawberry/blob/master/Changelog
|
||||
If it's already fixed, try the latest development build from: https://builds.strawberrymusicplayer.org/
|
||||
For technical issues, questions and discussion please use the forum on https://forum.strawberrymusicplayer.org/
|
||||
Any issues related to feature requests will be closed. See the README for more details.
|
||||
- [ ] I have checked the [FAQ](https://wiki.strawberrymusicplayer.org/wiki/FAQ) for answers.
|
||||
- [ ] I have checked the [Changelog](https://github.com/strawberrymusicplayer/strawberry/blob/master/Changelog) that the issue is not already fixed.
|
||||
- [ ] I believe this issue is a bug, and not a general technical issue, question or feature requests that can be discussed on the [forum](https://forum.strawberrymusicplayer.org/).
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
1051
.github/workflows/build.yml
vendored
Normal file
1051
.github/workflows/build.yml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2914
.github/workflows/ccpp.yml
vendored
2914
.github/workflows/ccpp.yml
vendored
File diff suppressed because it is too large
Load Diff
88
.github/workflows/codeql.yml
vendored
Normal file
88
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
name: CodeQL
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
codeql:
|
||||
name: CodeQL Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
image: opensuse/tumbleweed
|
||||
|
||||
steps:
|
||||
|
||||
- name: Refresh repositories
|
||||
run: zypper -n --gpg-auto-import-keys ref
|
||||
|
||||
- name: Upgrade packages
|
||||
run: zypper -n --gpg-auto-import-keys dup
|
||||
|
||||
- name: Install packages
|
||||
run: >
|
||||
zypper -n --gpg-auto-import-keys in
|
||||
lsb-release
|
||||
rpm-build
|
||||
git
|
||||
tar
|
||||
gcc
|
||||
gcc-c++
|
||||
make
|
||||
cmake
|
||||
gettext-tools
|
||||
glibc-devel
|
||||
libboost_headers-devel
|
||||
boost-devel
|
||||
glib2-devel
|
||||
glib2-tools
|
||||
dbus-1-devel
|
||||
alsa-devel
|
||||
libnotify-devel
|
||||
libgnutls-devel
|
||||
protobuf-devel
|
||||
sqlite3-devel
|
||||
libpulse-devel
|
||||
gstreamer-devel
|
||||
gstreamer-plugins-base-devel
|
||||
vlc-devel
|
||||
taglib-devel
|
||||
libicu-devel
|
||||
libcdio-devel
|
||||
libgpod-devel
|
||||
libmtp-devel
|
||||
libchromaprint-devel
|
||||
qt6-core-devel
|
||||
qt6-gui-devel
|
||||
qt6-widgets-devel
|
||||
qt6-concurrent-devel
|
||||
qt6-network-devel
|
||||
qt6-sql-devel
|
||||
qt6-dbus-devel
|
||||
qt6-test-devel
|
||||
qt6-base-common-devel
|
||||
qt6-sql-sqlite
|
||||
qt6-linguist-devel
|
||||
desktop-file-utils
|
||||
update-desktop-files
|
||||
appstream-glib
|
||||
hicolor-icon-theme
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Add safe git directory
|
||||
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: cpp
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: "/language:cpp"
|
||||
34
3rdparty/macdeployqt/shared.cpp
vendored
34
3rdparty/macdeployqt/shared.cpp
vendored
@@ -40,6 +40,8 @@
|
||||
#include <QDir>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QVariantMap>
|
||||
#include <QStack>
|
||||
#include <QDirIterator>
|
||||
#include <QLibraryInfo>
|
||||
@@ -187,9 +189,7 @@ OtoolInfo findDependencyInfo(const QString &binaryPath)
|
||||
return info;
|
||||
}
|
||||
|
||||
static const QRegularExpression regexp(QStringLiteral(
|
||||
"^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), "
|
||||
"current version (\\d+\\.\\d+\\.\\d+)(, weak)?\\)$"));
|
||||
static const QRegularExpression regexp(QStringLiteral("^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), current version (\\d+\\.\\d+\\.\\d+)(, weak|, reexport)?\\)$"));
|
||||
|
||||
QString output = otool.readAllStandardOutput();
|
||||
QStringList outputLines = output.split("\n", Qt::SkipEmptyParts);
|
||||
@@ -220,6 +220,8 @@ OtoolInfo findDependencyInfo(const QString &binaryPath)
|
||||
for (const QString &outputLine : outputLines) {
|
||||
const auto match = regexp.match(outputLine);
|
||||
if (match.hasMatch()) {
|
||||
if (match.captured(1) == info.installName)
|
||||
continue; // Another arch reference to the same binary
|
||||
DylibInfo dylib;
|
||||
dylib.binaryPath = match.captured(1);
|
||||
dylib.compatibilityVersion = QVersionNumber::fromString(match.captured(2));
|
||||
@@ -300,11 +302,11 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundl
|
||||
if (state == QtPath) {
|
||||
// Check for library name part
|
||||
if (part < parts.count() && parts.at(part).contains(".dylib")) {
|
||||
info.frameworkDirectory += "/" + (qtPath + currentPart + "/").simplified();
|
||||
info.frameworkDirectory += "/" + QString(qtPath + currentPart + "/").simplified();
|
||||
state = DylibName;
|
||||
continue;
|
||||
} else if (part < parts.count() && parts.at(part).endsWith(".framework")) {
|
||||
info.frameworkDirectory += "/" + (qtPath + "lib/").simplified();
|
||||
info.frameworkDirectory += "/" + QString(qtPath + "lib/").simplified();
|
||||
state = FrameworkName;
|
||||
continue;
|
||||
} else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package.
|
||||
@@ -865,6 +867,18 @@ void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework
|
||||
if (!framework.installName.isEmpty() && framework.installName != framework.sourceFilePath) {
|
||||
changeInstallName(framework.installName, deployedInstallName, binary);
|
||||
}
|
||||
// Workaround for the case when the library ID name is a symlink, while the dependencies
|
||||
// specified using the canonical path to the library (QTBUG-56814)
|
||||
QFileInfo fileInfo= QFileInfo(framework.installName);
|
||||
QString canonicalInstallName = fileInfo.canonicalFilePath();
|
||||
if (!canonicalInstallName.isEmpty() && canonicalInstallName != framework.installName) {
|
||||
changeInstallName(canonicalInstallName, deployedInstallName, binary);
|
||||
// some libraries' inner dependencies (such as ffmpeg, nettle) use symbol link (QTBUG-100093)
|
||||
QString innerDependency = fileInfo.canonicalPath() + "/" + fileInfo.fileName();
|
||||
if (innerDependency != canonicalInstallName && innerDependency != framework.installName) {
|
||||
changeInstallName(innerDependency, deployedInstallName, binary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1078,7 +1092,7 @@ QString getLibInfix(const QStringList &deployedFrameworks)
|
||||
{
|
||||
QString libInfix;
|
||||
for (const QString &framework : deployedFrameworks) {
|
||||
if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework"))) {
|
||||
if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework")) && !framework.contains(QStringLiteral("5Compat"))) {
|
||||
Q_ASSERT(framework.length() >= 16);
|
||||
// 16 == "QtCore" + ".framework"
|
||||
const int lengthOfLibInfix = framework.length() - 16;
|
||||
@@ -1301,7 +1315,7 @@ void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pl
|
||||
<< "libgstfdkaac.dylib"
|
||||
<< "libgstflac.dylib"
|
||||
<< "libgstgio.dylib"
|
||||
<< "libgstgme.dylib"
|
||||
//<< "libgstgme.dylib"
|
||||
<< "libgsthls.dylib"
|
||||
<< "libgsticydemux.dylib"
|
||||
<< "libgstid3demux.dylib"
|
||||
@@ -1474,9 +1488,9 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
|
||||
for (const QString &importPath : qmlImportPaths)
|
||||
argumentList << "-importPath" << importPath;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath);
|
||||
QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
|
||||
#else
|
||||
QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
|
||||
QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::QmlImportsPath);
|
||||
#endif
|
||||
argumentList.append( "-importPath");
|
||||
argumentList.append(qmlImportsPath);
|
||||
@@ -1488,7 +1502,7 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
|
||||
LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString();
|
||||
return false;
|
||||
}
|
||||
qmlImportScanner.waitForFinished();
|
||||
qmlImportScanner.waitForFinished(-1);
|
||||
|
||||
// log qmlimportscanner errors
|
||||
qmlImportScanner.setReadChannel(QProcess::StandardError);
|
||||
|
||||
13
3rdparty/singleapplication/singleapplication.cpp
vendored
13
3rdparty/singleapplication/singleapplication.cpp
vendored
@@ -42,6 +42,9 @@
|
||||
#include <QByteArray>
|
||||
#include <QElapsedTimer>
|
||||
#include <QtDebug>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
# include <QNativeIpcKey>
|
||||
#endif
|
||||
|
||||
#include "singleapplication.h"
|
||||
#include "singleapplication_p.h"
|
||||
@@ -71,13 +74,21 @@ SingleApplication::SingleApplication(int &argc, char *argv[], const bool allowSe
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
// By explicitly attaching it and then deleting it we make sure that the memory is deleted even after the process has crashed on Unix.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_));
|
||||
#else
|
||||
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||
#endif
|
||||
d->memory_->attach();
|
||||
delete d->memory_;
|
||||
#endif
|
||||
|
||||
// Guarantee thread safe behaviour with a shared memory block.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_));
|
||||
#else
|
||||
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||
#endif
|
||||
|
||||
// Create a shared memory block
|
||||
if (d->memory_->create(sizeof(InstancesInfo))) {
|
||||
@@ -165,8 +176,6 @@ SingleApplication::SingleApplication(int &argc, char *argv[], const bool allowSe
|
||||
|
||||
delete d;
|
||||
|
||||
::exit(EXIT_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
SingleApplication::~SingleApplication() {
|
||||
|
||||
@@ -61,7 +61,7 @@ class SingleApplication : public QApplication { // clazy:exclude=ctor-missing-p
|
||||
* block will be user wide.
|
||||
* @enum
|
||||
*/
|
||||
enum Mode {
|
||||
enum class Mode {
|
||||
User = 1 << 0,
|
||||
System = 1 << 1,
|
||||
SecondaryNotification = 1 << 2,
|
||||
|
||||
@@ -161,7 +161,7 @@ void SingleApplicationPrivate::genBlockServerName() {
|
||||
}
|
||||
else {
|
||||
appData.addData(appImagePath);
|
||||
};
|
||||
}
|
||||
#elif defined(Q_OS_WIN)
|
||||
appData.addData(SingleApplication::app_t::applicationFilePath().toLower().toUtf8());
|
||||
#else
|
||||
@@ -391,7 +391,7 @@ void SingleApplicationPrivate::slotConnectionEstablished() {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@@ -449,10 +449,9 @@ void SingleApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
|
||||
readStream >> latin1Name;
|
||||
|
||||
// connection type
|
||||
ConnectionType connectionType = InvalidConnection;
|
||||
quint8 connTypeVal = InvalidConnection;
|
||||
readStream >> connTypeVal;
|
||||
connectionType = static_cast<ConnectionType>(connTypeVal);
|
||||
const ConnectionType connectionType = static_cast<ConnectionType>(connTypeVal);
|
||||
|
||||
// instance id
|
||||
quint32 instanceId = 0;
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
#include <QByteArray>
|
||||
#include <QElapsedTimer>
|
||||
#include <QtDebug>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
# include <QNativeIpcKey>
|
||||
#endif
|
||||
|
||||
#include "singlecoreapplication.h"
|
||||
#include "singlecoreapplication_p.h"
|
||||
@@ -71,13 +74,21 @@ SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], const bool
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
// By explicitly attaching it and then deleting it we make sure that the memory is deleted even after the process has crashed on Unix.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_));
|
||||
#else
|
||||
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||
#endif
|
||||
d->memory_->attach();
|
||||
delete d->memory_;
|
||||
#endif
|
||||
|
||||
// Guarantee thread safe behaviour with a shared memory block.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
d->memory_ = new QSharedMemory(QNativeIpcKey(d->blockServerName_));
|
||||
#else
|
||||
d->memory_ = new QSharedMemory(d->blockServerName_);
|
||||
#endif
|
||||
|
||||
// Create a shared memory block
|
||||
if (d->memory_->create(sizeof(InstancesInfo))) {
|
||||
@@ -165,8 +176,6 @@ SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], const bool
|
||||
|
||||
delete d;
|
||||
|
||||
::exit(EXIT_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
SingleCoreApplication::~SingleCoreApplication() {
|
||||
|
||||
@@ -61,7 +61,7 @@ class SingleCoreApplication : public QCoreApplication { // clazy:exclude=ctor-m
|
||||
* block will be user wide.
|
||||
* @enum
|
||||
*/
|
||||
enum Mode {
|
||||
enum class Mode {
|
||||
User = 1 << 0,
|
||||
System = 1 << 1,
|
||||
SecondaryNotification = 1 << 2,
|
||||
|
||||
@@ -161,7 +161,7 @@ void SingleCoreApplicationPrivate::genBlockServerName() {
|
||||
}
|
||||
else {
|
||||
appData.addData(appImagePath);
|
||||
};
|
||||
}
|
||||
#elif defined(Q_OS_WIN)
|
||||
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toLower().toUtf8());
|
||||
#else
|
||||
@@ -391,7 +391,7 @@ void SingleCoreApplicationPrivate::slotConnectionEstablished() {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@@ -449,10 +449,9 @@ void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
|
||||
readStream >> latin1Name;
|
||||
|
||||
// connection type
|
||||
ConnectionType connectionType = InvalidConnection;
|
||||
quint8 connTypeVal = InvalidConnection;
|
||||
readStream >> connTypeVal;
|
||||
connectionType = static_cast<ConnectionType>(connTypeVal);
|
||||
const ConnectionType connectionType = static_cast<ConnectionType>(connTypeVal);
|
||||
|
||||
// instance id
|
||||
quint32 instanceId = 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
|
||||
project(strawberry)
|
||||
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
@@ -15,13 +16,13 @@ include(cmake/Summary.cmake)
|
||||
include(cmake/OptionalSource.cmake)
|
||||
include(cmake/ParseArguments.cmake)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(LINUX ON)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
set(FREEBSD ON)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
set(OPENBSD ON)
|
||||
endif()
|
||||
|
||||
@@ -71,23 +72,22 @@ else()
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
|
||||
)
|
||||
endif()
|
||||
|
||||
option(BUILD_WERROR "Build with -Werror" OFF)
|
||||
if(BUILD_WERROR)
|
||||
list(APPEND COMPILE_OPTIONS -Werror)
|
||||
option(BUILD_WERROR "Build with -Werror" OFF)
|
||||
if(BUILD_WERROR)
|
||||
list(APPEND COMPILE_OPTIONS -Werror)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_compile_options(${COMPILE_OPTIONS})
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
add_definitions(-DNDEBUG)
|
||||
add_definitions(-DQT_NO_DEBUG_OUTPUT)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks")
|
||||
option(USE_RPATH "Use RPATH" APPLE)
|
||||
if(USE_RPATH)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif()
|
||||
|
||||
find_program(CCACHE_EXECUTABLE NAMES ccache)
|
||||
@@ -512,9 +512,12 @@ endif()
|
||||
add_definitions(
|
||||
-DBOOST_BIND_NO_PLACEHOLDERS
|
||||
-DQT_STRICT_ITERATORS
|
||||
-DQT_NO_CAST_FROM_BYTEARRAY
|
||||
-DQT_USE_QSTRINGBUILDER
|
||||
-DQT_NO_URL_CAST_FROM_STRING
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
|
||||
-DQT_NO_FOREACH
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
104
Changelog
104
Changelog
@@ -2,6 +2,102 @@ Strawberry Music Player
|
||||
=======================
|
||||
ChangeLog
|
||||
|
||||
Version 1.0.15 (2023.03.04):
|
||||
|
||||
Bugfixes:
|
||||
* Fixed playlist column showing invalid last played date for streams.
|
||||
* Fixed crash when the audio bin failed to initialize (#1123, #1133).
|
||||
* Fixed duplicated filename when organizing files using dot in the filename (#1136).
|
||||
* Fixed tag inline editing for streams (#1130).
|
||||
* Fixed resetting play statistics using tag edit dialog (#1124).
|
||||
* Fixed compilation songs not showing if group by was set to other than (Album) Artist / Album (#1140).
|
||||
|
||||
Enhancements:
|
||||
* Added lyrics from stands4 (lyrics.com).
|
||||
* Added Sonogram analyzer.
|
||||
* Use GStreamer playbin3 with GStreamer 1.22.0 and higher.
|
||||
|
||||
Code improvements:
|
||||
* Made use of C++11 enum class where possible.
|
||||
* Use new QNativeIpcKey based QSharedMemory constructor with Qt 6.6 and higher.
|
||||
|
||||
Version 1.0.14 (2023.01.13):
|
||||
|
||||
Bugfixes:
|
||||
* Fix initial volume not set when using Auto as output (#1104).
|
||||
* Fix saving moodbar if the URL contains host, ie.: UNC paths for SMB (#1101).
|
||||
* Fix CollectionBackendTest compile error (#1100).
|
||||
* Remove explicitly enabling debug messages (#1106).
|
||||
|
||||
Version 1.0.13 (2023.01.09):
|
||||
|
||||
Bugfixes:
|
||||
* Fixed volume synchronization leading to infinite loop resulting in crash when adjusting volume while playing (#1089).
|
||||
* Fixed incorrect volume.
|
||||
* Fixed collection organizing incorrectly handling slashes inside {} brackets for variables (#1091).
|
||||
* Fixed saving relative playlists to non-existing playlist files (#1092).
|
||||
* Fixed intermittent crash on collection model query (#1095).
|
||||
* Require system icons for fancy tabbar and settings sidebar to be larger than 22x22 (#1084).
|
||||
|
||||
Version 1.0.12 (2023.01.02):
|
||||
|
||||
Bugfixes:
|
||||
* Fixed crash when adjusting volume with mouse wheel (#1089).
|
||||
* Fixed playback stopping in certain cases where the next track was unavailable (#958).
|
||||
* (Windows) Apply patch for fonts too large on High DPI screen (QTBUG-108593).
|
||||
|
||||
Removed features:
|
||||
* Removed appearance settings for changing palette colors, it was never properly implemented.
|
||||
|
||||
Version 1.0.11 (2022.12.30):
|
||||
|
||||
Bugfixes:
|
||||
* Capitalize GLib application name so it appears nicely in GNOME and PulseAudio Volume Control (#1066).
|
||||
* Fixed missing application icon for PulseAudio Volume Control (#1066).
|
||||
* Ignore errors for missing albums when updating Tidal collection if there are results (#1061).
|
||||
* Only run periodic collection scan when moitoring collection setting is on.
|
||||
* Fixed an edge case where the context headline text was being cut short (#1067).
|
||||
* Made "Show in file browser" support SpaceFM filemanager (#1073).
|
||||
* Fixed incorrect tab order in edit tag dialog (#1075).
|
||||
* Changed "FMPS_PlayCount" to "FMPS_Playcount" when saving tag (#1074).
|
||||
* Fixed compilation tag read and write for MP4 (#1076).
|
||||
* Removed incorrect use of "TPE1" for performer when reading ID3 tags (#1076).
|
||||
* Disable tag fields for unsupported tags in tag editor.
|
||||
* Don't allow organizing files without unique tags (track or title) for filename (#1077).
|
||||
* Don't remove disc from album title when creating cover hash to allow different covers for each disc on an album (#1069).
|
||||
* Fixed incorrect relative paths for song filenames when saving playlists if the saved playlist location is a symablic link to the song filename (#1071).
|
||||
* Scrobble "Various Artists" as album artist (#1082).
|
||||
|
||||
Enhancements:
|
||||
* Use system volume instead of own software volume when available (#1037).
|
||||
* Improved Tidal and Qobuz support with timed requests.
|
||||
* Support MPRIS2 xesam:userRating.
|
||||
|
||||
Version 1.0.10 (2022.10.21):
|
||||
|
||||
Bugfixes:
|
||||
* Fixed "Could not open settings file for writing: No such file or directory" error before settings file is created.
|
||||
* Fixed visual glitch on currently playing track (#1051).
|
||||
* Fixed "Unknown error" on Tidal search (#1047).
|
||||
* Fixed incomplete lyrics from Genius.
|
||||
* Fixed icons not showing in the file view on some systems (#1024).
|
||||
* Fixed issues with context and playing widget stopping when using VLC (#1054).
|
||||
* (macOS) Fixed search field related crash when playlist toolbar is turned off.
|
||||
|
||||
Enhancements:
|
||||
* Fixed narrowing conversions in connects.
|
||||
* Fixed casts from QByteArray.
|
||||
* Removed subdir for generated dbus files
|
||||
* Removed use of fixed font in context (#1040).
|
||||
* Improve Musixmatch lyrics search.
|
||||
|
||||
Version 1.0.9 (2022.09.03):
|
||||
|
||||
Bugfixes:
|
||||
* Fixed parsing album title from radio stream metadata (#1023).
|
||||
* (macOS) Fixed Strawberry not starting, incorrect rpath for libgcc_s.1.1.dylib (#1025).
|
||||
* (macOS) Fixed HTTP streaming.
|
||||
|
||||
Version 1.0.8 (2022.08.29):
|
||||
|
||||
Bugfixes:
|
||||
@@ -225,7 +321,7 @@ Version 0.9.3 (2021.04.18)
|
||||
Bugfixes:
|
||||
* Fix "Show in file browser" to work with thunar.
|
||||
* Check that the clicked rating position is to the right or left of the rectangle.
|
||||
* Fix rescan when collection directory is removed and readded.
|
||||
* Fix rescan when collection directory is removed and re-added.
|
||||
* Create GLib main event loop on non-glib systems to fix stream discoverer.
|
||||
* (macOS) Fix intermittent abort on startup.
|
||||
* (macOS) Fix Tidal and Qobuz search field not showing.
|
||||
@@ -562,7 +658,7 @@ Version 0.6.10 (2020.05.01)
|
||||
* Made font and font sizes in context configurable.
|
||||
* Splitting artist and song title to the relevant metadata when artist and song title is sent as title separated by a dash in streams.
|
||||
* Added label to show collection pixmap disk cache used in settings.
|
||||
* Icreased default collection pixmap disk cache to 360.
|
||||
* Increased default collection pixmap disk cache to 360.
|
||||
|
||||
New features:
|
||||
* Added back Tidal streaming support.
|
||||
@@ -630,7 +726,7 @@ Version 0.6.7 (2019.11.27)
|
||||
* Fixed "Pressing Previous in player" behaviour setting
|
||||
* Fixed updating compilations where there are spaces or special characters in filenames
|
||||
* Fixed cases where songs were stuck in "Various Artists" because not all songs in
|
||||
the same compilation was removed from the model before readded with actual artist.
|
||||
the same compilation was removed from the model before re-added with actual artist.
|
||||
* Fixed a bug when importing playlists where metadata was reset
|
||||
* Fixed scrobbler to also scrobble songs without album title
|
||||
* Fixed text for replay gain setting not loading in backend setting
|
||||
@@ -983,7 +1079,7 @@ Version 0.1.5 (2018.05.16)
|
||||
|
||||
|
||||
Version 0.1.4 (2018.05.14)
|
||||
* Fixed compliation with clang compiler
|
||||
* Fixed compilation with clang compiler
|
||||
* This release is mainly to get it working on openbsd and freebsd.
|
||||
|
||||
|
||||
|
||||
14
README.md
14
README.md
@@ -1,4 +1,4 @@
|
||||
:strawberry: Strawberry Music Player [](https://github.com/strawberrymusicplayer/strawberry/actions)
|
||||
:strawberry: Strawberry Music Player [](https://github.com/strawberrymusicplayer/strawberry/actions)
|
||||
=======================
|
||||
[](https://github.com/sponsors/jonaski)
|
||||
[](https://patreon.com/jonaskvinge)
|
||||
@@ -69,10 +69,11 @@ It has so far been tested to work on Linux, OpenBSD, FreeBSD, macOS and Windows.
|
||||
To build Strawberry from source you need the following installed on your system with the additional development packages/headers:
|
||||
|
||||
* [CMake](https://cmake.org/)
|
||||
* [GCC](https://gcc.gnu.org/), [Clang](https://clang.llvm.org/) or [MSVC](https://visualstudio.microsoft.com/vs/features/cplusplus/) compiler
|
||||
* C/C++ compiler ([GCC](https://gcc.gnu.org/), [Clang](https://clang.llvm.org/) or [MSVC](https://visualstudio.microsoft.com/vs/features/cplusplus/))
|
||||
* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) or [pkgconf](https://github.com/pkgconf/pkgconf)
|
||||
* [Boost](https://www.boost.org/)
|
||||
* [GLib](https://developer.gnome.org/glib/)
|
||||
* [Qt 5.9 or higher (or Qt 6) with components Core, Gui, Widgets, Concurrent, Network and Sql](https://www.qt.io/)
|
||||
* [Qt 6 or Qt 5.9 or higher with components Core, Gui, Widgets, Concurrent, Network and Sql](https://www.qt.io/)
|
||||
* [SQLite 3.9 or newer with FTS5](https://www.sqlite.org)
|
||||
* [Protobuf](https://developers.google.com/protocol-buffers/)
|
||||
* [ALSA (Required on Linux)](https://www.alsa-project.org/)
|
||||
@@ -102,15 +103,18 @@ You should also install the gstreamer plugins base and good, and optionally bad,
|
||||
### Compile and install:
|
||||
|
||||
cd strawberry
|
||||
mkdir build && cd build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DBUILD_WITH_QT6=ON
|
||||
make -j$(nproc)
|
||||
make -j $(nproc)
|
||||
sudo make install
|
||||
|
||||
Strawberry is backwards compatible with Qt 5, to compile with Qt 5 use:
|
||||
|
||||
cmake .. -DBUILD_WITH_QT5=ON
|
||||
|
||||
To compile on Windows with Visual Studio 2019 or 2022, see https://github.com/strawberrymusicplayer/strawberry-msvc
|
||||
|
||||
### :penguin: Packaging status
|
||||
|
||||
[](https://repology.org/metapackage/strawberry/versions)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(STRAWBERRY_VERSION_MAJOR 1)
|
||||
set(STRAWBERRY_VERSION_MINOR 0)
|
||||
set(STRAWBERRY_VERSION_PATCH 8)
|
||||
set(STRAWBERRY_VERSION_PATCH 15)
|
||||
#set(STRAWBERRY_VERSION_PRERELEASE rc1)
|
||||
|
||||
set(INCLUDE_GIT_REVISION OFF)
|
||||
@@ -14,10 +14,6 @@ set(STRAWBERRY_VERSION_RPM_R "1")
|
||||
set(STRAWBERRY_VERSION_PAC_V "${majorminorpatch}")
|
||||
set(STRAWBERRY_VERSION_PAC_R "1")
|
||||
|
||||
if(${STRAWBERRY_VERSION_PATCH} EQUAL "0")
|
||||
set(STRAWBERRY_VERSION_DISPLAY "${STRAWBERRY_VERSION_MAJOR}.${STRAWBERRY_VERSION_MINOR}")
|
||||
endif(${STRAWBERRY_VERSION_PATCH} EQUAL "0")
|
||||
|
||||
if(STRAWBERRY_VERSION_PRERELEASE)
|
||||
set(STRAWBERRY_VERSION_DISPLAY "${STRAWBERRY_VERSION_DISPLAY} ${STRAWBERRY_VERSION_PRERELEASE}")
|
||||
set(STRAWBERRY_VERSION_RPM_R "0.${STRAWBERRY_VERSION_PRERELEASE}")
|
||||
|
||||
2
debian/control.in
vendored
2
debian/control.in
vendored
@@ -17,7 +17,7 @@ Build-Depends: debhelper (>= 11),
|
||||
libasound2-dev,
|
||||
libpulse-dev,
|
||||
libtag1-dev,
|
||||
libicu-devel,
|
||||
libicu-dev,
|
||||
@DEBIAN_BUILD_DEPENDS_QT_PACKAGES@,
|
||||
libgstreamer1.0-dev,
|
||||
libgstreamer-plugins-base1.0-dev,
|
||||
|
||||
20
debian/copyright
vendored
20
debian/copyright
vendored
@@ -5,10 +5,10 @@ Source: https://github.com/strawberrymusicplayer/strawberry
|
||||
|
||||
Files: *
|
||||
Copyright: 2010-2015, David Sansome <me@davidsansome.com>
|
||||
2012-2014, 2017-2022 Jonas Kvinge <jonas@jkvinge.net>
|
||||
2012-2014, 2017-2023 Jonas Kvinge <jonas@jkvinge.net>
|
||||
License: GPL-3+
|
||||
|
||||
Files: src/core/timeconstants.h
|
||||
Files: src/utilities/timeconstants.h
|
||||
ext/libstrawberry-common/core/logging.cpp
|
||||
ext/libstrawberry-common/core/logging.h
|
||||
ext/libstrawberry-common/core/messagehandler.cpp
|
||||
@@ -98,7 +98,7 @@ Files: src/core/main.h
|
||||
ext/macdeploycheck/*
|
||||
src/widgets/resizabletextedit.cpp
|
||||
src/widgets/resizabletextedit.h
|
||||
Copyright: 2012-2014, 2017-2022, Jonas Kvinge <jonas@jkvinge.net>
|
||||
Copyright: 2012-2014, 2017-2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
License: GPL-3+
|
||||
|
||||
Files: src/engine/enginebase.cpp
|
||||
@@ -130,11 +130,6 @@ Copyright: 2012, David Sansome <me@davidsansome.com>
|
||||
2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
License: GPL-3+
|
||||
|
||||
Files: src/core/appearance.cpp
|
||||
src/core/appearance.h
|
||||
Copyright: 2012, Arnaud Bienner <arnaud.bienner@gmail.com>
|
||||
License: GPL-3+
|
||||
|
||||
Files: src/covermanager/discogscoverprovider.cpp
|
||||
src/covermanager/discogscoverprovider.h
|
||||
Copyright: 2012, Martin Björklund <mbj4668@gmail.com>
|
||||
@@ -232,9 +227,14 @@ Files: src/widgets/clickablelabel.cpp
|
||||
Copyright: 2010, 2011, Andrea Decorte <adecorte@gmail.com>
|
||||
License: GPL-3+
|
||||
|
||||
Files: src/widgets/volumeslider.cpp
|
||||
Files: src/widgets/sliderslider.cpp
|
||||
src/widgets/sliderslider.h
|
||||
src/widgets/prettyslider.cpp
|
||||
src/widgets/prettyslider.h
|
||||
src/widgets/volumeslider.cpp
|
||||
src/widgets/volumeslider.h
|
||||
Copyright: 2005, Gábor Lehel
|
||||
Copyright: 2018-2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
2005, Gábor Lehel
|
||||
2003, Mark Kretschmann <markey@web.de>
|
||||
License: GPL-2+
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ TryExec=strawberry
|
||||
Icon=strawberry
|
||||
Terminal=false
|
||||
Categories=AudioVideo;Player;Qt;Audio;
|
||||
Keywords=Audio;Player;
|
||||
StartupNotify=false
|
||||
MimeType=x-content/audio-player;application/ogg;application/x-ogg;application/x-ogm-audio;audio/flac;audio/ogg;audio/vorbis;audio/aac;audio/mp4;audio/mpeg;audio/mpegurl;audio/vnd.rn-realaudio;audio/x-flac;audio/x-oggflac;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-speex;audio/x-wav;audio/x-wavpack;audio/x-ape;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-pn-realaudio;audio/x-scpls;video/x-ms-asf;x-scheme-handler/tidal;
|
||||
StartupWMClass=strawberry
|
||||
|
||||
54
dist/windows/strawberry.nsi.in
vendored
54
dist/windows/strawberry.nsi.in
vendored
@@ -245,7 +245,7 @@ Section "Strawberry" Strawberry
|
||||
File "avfilter-8.dll"
|
||||
File "avformat-59.dll"
|
||||
File "avutil-57.dll"
|
||||
File "libFLAC-8.dll"
|
||||
File "libFLAC-12.dll"
|
||||
File "libbrotlicommon.dll"
|
||||
File "libbrotlidec.dll"
|
||||
File "libbrotlienc.dll"
|
||||
@@ -301,7 +301,6 @@ Section "Strawberry" Strawberry
|
||||
File "libopus-0.dll"
|
||||
File "liborc-0.4-0.dll"
|
||||
File "libpng16-16.dll"
|
||||
File "libprotobuf-32.dll"
|
||||
File "libpsl-5.dll"
|
||||
File "libqtsparkle-qt6.dll"
|
||||
File "libsoup-3.0-0.dll"
|
||||
@@ -312,7 +311,7 @@ Section "Strawberry" Strawberry
|
||||
File "libtag.dll"
|
||||
File "libtasn1-6.dll"
|
||||
File "libtwolame-0.dll"
|
||||
File "libunistring-2.dll"
|
||||
File "libunistring-5.dll"
|
||||
File "libvorbis-0.dll"
|
||||
File "libvorbisenc-2.dll"
|
||||
File "libvorbisfile-3.dll"
|
||||
@@ -358,7 +357,6 @@ Section "Strawberry" Strawberry
|
||||
File "avcodec-58.dll"
|
||||
File "avfilter-7.dll"
|
||||
File "avformat-58.dll"
|
||||
File "avresample-4.dll"
|
||||
File "avutil-56.dll"
|
||||
File "brotlicommon.dll"
|
||||
File "brotlidec.dll"
|
||||
@@ -391,9 +389,9 @@ Section "Strawberry" Strawberry
|
||||
File "gstvideo-1.0-0.dll"
|
||||
File "harfbuzz.dll"
|
||||
File "intl-8.dll"
|
||||
File "jpeg62.dll"
|
||||
File "libbs2b.dll"
|
||||
File "libfaac_dll.dll"
|
||||
File "libiconv.dll"
|
||||
File "liblzma.dll"
|
||||
File "libmp3lame.dll"
|
||||
File "libopenmpt.dll"
|
||||
@@ -418,8 +416,8 @@ Section "Strawberry" Strawberry
|
||||
|
||||
!ifdef release
|
||||
File "freetype.dll"
|
||||
File "libiconv.dll"
|
||||
File "libpng16.dll"
|
||||
File "libprotobuf.dll"
|
||||
File "libxml2.dll"
|
||||
File "pcre2-8.dll"
|
||||
File "pcre2-16.dll"
|
||||
@@ -428,8 +426,8 @@ Section "Strawberry" Strawberry
|
||||
!endif
|
||||
!ifdef debug
|
||||
File "freetyped.dll"
|
||||
File "libiconvd.dll"
|
||||
File "libpng16d.dll"
|
||||
File "libprotobufd.dll"
|
||||
File "libxml2d.dll"
|
||||
File "pcre2-8d.dll"
|
||||
File "pcre2-16d.dll"
|
||||
@@ -441,11 +439,16 @@ Section "Strawberry" Strawberry
|
||||
|
||||
; Common files
|
||||
|
||||
File "icudt71.dll"
|
||||
File "icudt72.dll"
|
||||
File "libfftw3-3.dll"
|
||||
!ifdef debug
|
||||
File "libprotobufd.dll"
|
||||
!else
|
||||
File "libprotobuf.dll"
|
||||
!endif
|
||||
!ifdef msvc && debug
|
||||
File "icuin71d.dll"
|
||||
File "icuuc71d.dll"
|
||||
File "icuin72d.dll"
|
||||
File "icuuc72d.dll"
|
||||
File "Qt6Concurrentd.dll"
|
||||
File "Qt6Cored.dll"
|
||||
File "Qt6Guid.dll"
|
||||
@@ -453,8 +456,8 @@ Section "Strawberry" Strawberry
|
||||
File "Qt6Sqld.dll"
|
||||
File "Qt6Widgetsd.dll"
|
||||
!else
|
||||
File "icuin71.dll"
|
||||
File "icuuc71.dll"
|
||||
File "icuin72.dll"
|
||||
File "icuuc72.dll"
|
||||
File "Qt6Concurrent.dll"
|
||||
File "Qt6Core.dll"
|
||||
File "Qt6Gui.dll"
|
||||
@@ -747,7 +750,7 @@ Section "Uninstall"
|
||||
Delete "$INSTDIR\avfilter-8.dll"
|
||||
Delete "$INSTDIR\avformat-59.dll"
|
||||
Delete "$INSTDIR\avutil-57.dll"
|
||||
Delete "$INSTDIR\libFLAC-8.dll"
|
||||
Delete "$INSTDIR\libFLAC-12.dll"
|
||||
Delete "$INSTDIR\libbrotlicommon.dll"
|
||||
Delete "$INSTDIR\libbrotlidec.dll"
|
||||
Delete "$INSTDIR\libbrotlienc.dll"
|
||||
@@ -803,7 +806,6 @@ Section "Uninstall"
|
||||
Delete "$INSTDIR\libopus-0.dll"
|
||||
Delete "$INSTDIR\liborc-0.4-0.dll"
|
||||
Delete "$INSTDIR\libpng16-16.dll"
|
||||
Delete "$INSTDIR\libprotobuf-32.dll"
|
||||
Delete "$INSTDIR\libpsl-5.dll"
|
||||
Delete "$INSTDIR\libqtsparkle-qt6.dll"
|
||||
Delete "$INSTDIR\libsoup-3.0-0.dll"
|
||||
@@ -814,7 +816,7 @@ Section "Uninstall"
|
||||
Delete "$INSTDIR\libtag.dll"
|
||||
Delete "$INSTDIR\libtasn1-6.dll"
|
||||
Delete "$INSTDIR\libtwolame-0.dll"
|
||||
Delete "$INSTDIR\libunistring-2.dll"
|
||||
Delete "$INSTDIR\libunistring-5.dll"
|
||||
Delete "$INSTDIR\libvorbis-0.dll"
|
||||
Delete "$INSTDIR\libvorbisenc-2.dll"
|
||||
Delete "$INSTDIR\libvorbisfile-3.dll"
|
||||
@@ -860,7 +862,6 @@ Section "Uninstall"
|
||||
Delete "$INSTDIR\avcodec-58.dll"
|
||||
Delete "$INSTDIR\avfilter-7.dll"
|
||||
Delete "$INSTDIR\avformat-58.dll"
|
||||
Delete "$INSTDIR\avresample-4.dll"
|
||||
Delete "$INSTDIR\avutil-56.dll"
|
||||
Delete "$INSTDIR\brotlicommon.dll"
|
||||
Delete "$INSTDIR\brotlidec.dll"
|
||||
@@ -893,9 +894,9 @@ Section "Uninstall"
|
||||
Delete "$INSTDIR\gstvideo-1.0-0.dll"
|
||||
Delete "$INSTDIR\harfbuzz.dll"
|
||||
Delete "$INSTDIR\intl-8.dll"
|
||||
Delete "$INSTDIR\jpeg62.dll"
|
||||
Delete "$INSTDIR\libbs2b.dll"
|
||||
Delete "$INSTDIR\libfaac_dll.dll"
|
||||
Delete "$INSTDIR\libiconv.dll"
|
||||
Delete "$INSTDIR\liblzma.dll"
|
||||
Delete "$INSTDIR\libmp3lame.dll"
|
||||
Delete "$INSTDIR\libopenmpt.dll"
|
||||
@@ -920,8 +921,8 @@ Section "Uninstall"
|
||||
|
||||
!ifdef release
|
||||
Delete "$INSTDIR\freetype.dll"
|
||||
Delete "$INSTDIR\libiconv.dll"
|
||||
Delete "$INSTDIR\libpng16.dll"
|
||||
Delete "$INSTDIR\libprotobuf.dll"
|
||||
Delete "$INSTDIR\libxml2.dll"
|
||||
Delete "$INSTDIR\pcre2-8.dll"
|
||||
Delete "$INSTDIR\pcre2-16.dll"
|
||||
@@ -930,8 +931,8 @@ Section "Uninstall"
|
||||
!endif
|
||||
!ifdef debug
|
||||
Delete "$INSTDIR\freetyped.dll"
|
||||
Delete "$INSTDIR\libiconvd.dll"
|
||||
Delete "$INSTDIR\libpng16d.dll"
|
||||
Delete "$INSTDIR\libprotobufd.dll"
|
||||
Delete "$INSTDIR\libxml2d.dll"
|
||||
Delete "$INSTDIR\pcre2-8d.dll"
|
||||
Delete "$INSTDIR\pcre2-16d.dll"
|
||||
@@ -943,11 +944,16 @@ Section "Uninstall"
|
||||
|
||||
; Common files
|
||||
|
||||
Delete "$INSTDIR\icudt71.dll"
|
||||
Delete "$INSTDIR\icudt72.dll"
|
||||
Delete "$INSTDIR\libfftw3-3.dll"
|
||||
!ifdef debug
|
||||
Delete "$INSTDIR\libprotobufd.dll"
|
||||
!else
|
||||
Delete "$INSTDIR\libprotobuf.dll"
|
||||
!endif
|
||||
!ifdef msvc && debug
|
||||
Delete "$INSTDIR\icuin71d.dll"
|
||||
Delete "$INSTDIR\icuuc71d.dll"
|
||||
Delete "$INSTDIR\icuin72d.dll"
|
||||
Delete "$INSTDIR\icuuc72d.dll"
|
||||
Delete "$INSTDIR\Qt6Concurrentd.dll"
|
||||
Delete "$INSTDIR\Qt6Cored.dll"
|
||||
Delete "$INSTDIR\Qt6Guid.dll"
|
||||
@@ -955,8 +961,8 @@ Section "Uninstall"
|
||||
Delete "$INSTDIR\Qt6Sqld.dll"
|
||||
Delete "$INSTDIR\Qt6Widgetsd.dll"
|
||||
!else
|
||||
Delete "$INSTDIR\icuin71.dll"
|
||||
Delete "$INSTDIR\icuuc71.dll"
|
||||
Delete "$INSTDIR\icuin72.dll"
|
||||
Delete "$INSTDIR\icuuc72.dll"
|
||||
Delete "$INSTDIR\Qt6Concurrent.dll"
|
||||
Delete "$INSTDIR\Qt6Core.dll"
|
||||
Delete "$INSTDIR\Qt6Gui.dll"
|
||||
|
||||
@@ -82,9 +82,9 @@ static void gst_fastspectrum_class_init(GstFastSpectrumClass *klass) {
|
||||
|
||||
filter_class->setup = GST_DEBUG_FUNCPTR(gst_fastspectrum_setup);
|
||||
|
||||
g_object_class_install_property(gobject_class, PROP_INTERVAL, g_param_spec_uint64("interval", "Interval", "Interval of time between message posts (in nanoseconds)", 1, G_MAXUINT64, DEFAULT_INTERVAL, GParamFlags(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property(gobject_class, PROP_INTERVAL, g_param_spec_uint64("interval", "Interval", "Interval of time between message posts (in nanoseconds)", 1, G_MAXUINT64, DEFAULT_INTERVAL, static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property(gobject_class, PROP_BANDS, g_param_spec_uint("bands", "Bands", "Number of frequency bands", 0, G_MAXUINT, DEFAULT_BANDS, GParamFlags(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property(gobject_class, PROP_BANDS, g_param_spec_uint("bands", "Bands", "Number of frequency bands", 0, G_MAXUINT, DEFAULT_BANDS, static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT(gst_fastspectrum_debug, "spectrum", 0, "audio spectrum analyser element");
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class QMutex;
|
||||
|
||||
typedef void (*GstFastSpectrumInputData)(const guint8 *in, double *out, guint len, double max_value, guint op, guint nfft);
|
||||
|
||||
typedef std::function<void(double *magnitudes, int size)> OutputCallback;
|
||||
using OutputCallback = std::function<void(double *magnitudes, int size)>;
|
||||
|
||||
struct GstFastSpectrum {
|
||||
GstAudioFilter parent;
|
||||
|
||||
@@ -126,7 +126,8 @@ class LoggedDebug : public DebugBase<LoggedDebug> {
|
||||
static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QString &message) {
|
||||
|
||||
if (message.startsWith(kMessageHandlerMagic)) {
|
||||
fprintf(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout, "%s\n", message.toUtf8().data() + kMessageHandlerMagicLength);
|
||||
QByteArray message_data = message.toUtf8();
|
||||
fprintf(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout, "%s\n", message_data.constData() + kMessageHandlerMagicLength);
|
||||
fflush(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ class AbstractMessageHandler : public _MessageHandlerBase {
|
||||
AbstractMessageHandler(QIODevice *device, QObject *parent);
|
||||
~AbstractMessageHandler() override { AbstractMessageHandler::AbortAll(); }
|
||||
|
||||
typedef MT MessageType;
|
||||
typedef MessageReply<MT> ReplyType;
|
||||
using MessageType = MT;
|
||||
using ReplyType = MessageReply<MT>;
|
||||
|
||||
// Serialises the message and writes it to the socket.
|
||||
// This version MUST be called from the thread in which the AbstractMessageHandler was created.
|
||||
|
||||
@@ -76,8 +76,8 @@ class WorkerPool : public _WorkerPoolBase {
|
||||
explicit WorkerPool(QObject *parent = nullptr);
|
||||
~WorkerPool() override;
|
||||
|
||||
typedef typename HandlerType::MessageType MessageType;
|
||||
typedef typename HandlerType::ReplyType ReplyType;
|
||||
using MessageType = typename HandlerType::MessageType;
|
||||
using ReplyType = typename HandlerType::ReplyType;
|
||||
|
||||
// Sets the name of the worker executable. This is looked for first in the current directory, and then in $PATH.
|
||||
// You must call this before calling Start().
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "core/messagehandler.h"
|
||||
#include "tagreaderbase.h"
|
||||
#include "tagreadertaglib.h"
|
||||
@@ -200,7 +200,7 @@ void GME::VGM::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so
|
||||
QByteArray gd3_head = file.read(4);
|
||||
if (gd3_head.size() < 4) return;
|
||||
|
||||
quint64 pt = GME::UnpackBytes32(gd3_head, gd3_head.size());
|
||||
quint64 pt = GME::UnpackBytes32(gd3_head.constData(), gd3_head.size());
|
||||
|
||||
file.seek(SAMPLE_COUNT);
|
||||
QByteArray sample_count_bytes = file.read(4);
|
||||
@@ -215,7 +215,7 @@ void GME::VGM::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so
|
||||
|
||||
file.seek(file.pos() + 4);
|
||||
QByteArray gd3_length_bytes = file.read(4);
|
||||
quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes, gd3_length_bytes.size());
|
||||
quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes.constData(), gd3_length_bytes.size());
|
||||
|
||||
QByteArray gd3Data = file.read(gd3_length);
|
||||
QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly);
|
||||
@@ -246,11 +246,11 @@ bool GME::VGM::GetPlaybackLength(const QByteArray &sample_count_bytes, const QBy
|
||||
if (sample_count_bytes.size() != 4) return false;
|
||||
if (loop_count_bytes.size() != 4) return false;
|
||||
|
||||
quint64 sample_count = GME::UnpackBytes32(sample_count_bytes, sample_count_bytes.size());
|
||||
quint64 sample_count = GME::UnpackBytes32(sample_count_bytes.constData(), sample_count_bytes.size());
|
||||
|
||||
if (sample_count <= 0) return false;
|
||||
|
||||
quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes, loop_count_bytes.size());
|
||||
quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes.constData(), loop_count_bytes.size());
|
||||
|
||||
if (loop_sample_count <= 0) {
|
||||
out_length = sample_count * 1000 / SAMPLE_TIMEBASE;
|
||||
|
||||
@@ -55,14 +55,22 @@ constexpr int XID6_OFFSET = (0x101C0 + 64);
|
||||
|
||||
constexpr int NANO_PER_MS = 1000000;
|
||||
|
||||
enum xID6_STATUS {
|
||||
enum class xID6_STATUS {
|
||||
ON = 0x26,
|
||||
OFF = 0x27,
|
||||
OFF = 0x27
|
||||
};
|
||||
|
||||
enum xID6_ID { SongName = 0x01, GameName = 0x02, ArtistName = 0x03 };
|
||||
enum class xID6_ID {
|
||||
SongName = 0x01,
|
||||
GameName = 0x02,
|
||||
ArtistName = 0x03
|
||||
};
|
||||
|
||||
enum xID6_TYPE { Length = 0x0, String = 0x1, Integer = 0x4 };
|
||||
enum class xID6_TYPE {
|
||||
Length = 0x0,
|
||||
String = 0x1,
|
||||
Integer = 0x4
|
||||
};
|
||||
|
||||
void Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *song_info);
|
||||
qint16 GetNextMemAddressAlign32bit(qint16 input);
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/messagehandler.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
class FileRefFactory {
|
||||
public:
|
||||
@@ -297,15 +297,11 @@ bool TagReaderTagLib::ReadFile(const QString &filename, spb::tagreader::SongMeta
|
||||
// content group
|
||||
if (!map["TIT1"].isEmpty()) Decode(map["TIT1"].front()->toString(), song->mutable_grouping());
|
||||
|
||||
// ID3v2: lead performer/soloist
|
||||
if (!map["TPE1"].isEmpty()) Decode(map["TPE1"].front()->toString(), song->mutable_performer());
|
||||
|
||||
// original artist/performer
|
||||
if (!map["TOPE"].isEmpty()) Decode(map["TOPE"].front()->toString(), song->mutable_performer());
|
||||
|
||||
// Skip TPE1 (which is the artist) here because we already fetched it
|
||||
|
||||
|
||||
// non-standard: Apple, Microsoft
|
||||
if (!map["TPE2"].isEmpty()) Decode(map["TPE2"].front()->toString(), song->mutable_albumartist());
|
||||
|
||||
@@ -400,6 +396,10 @@ bool TagReaderTagLib::ReadFile(const QString &filename, spb::tagreader::SongMeta
|
||||
song->set_originalyear(TStringToQString(mp4_tag->item(kMP4_OriginalYear_ID).toStringList().toString('\n')).left(4).toInt());
|
||||
}
|
||||
|
||||
if (mp4_tag->item("cpil").isValid()) {
|
||||
song->set_compilation(mp4_tag->item("cpil").toBool());
|
||||
}
|
||||
|
||||
{
|
||||
TagLib::MP4::Item item = mp4_tag->item(kMP4_FMPS_Playcount_ID);
|
||||
if (item.isValid()) {
|
||||
@@ -687,7 +687,7 @@ bool TagReaderTagLib::SaveFile(const QString &filename, const spb::tagreader::So
|
||||
tag->setItem("\251grp", TagLib::StringList(TagLib::String(song.grouping(), TagLib::String::UTF8)));
|
||||
tag->setItem("\251lyr", TagLib::StringList(TagLib::String(song.lyrics(), TagLib::String::UTF8)));
|
||||
tag->setItem("aART", TagLib::StringList(TagLib::String(song.albumartist(), TagLib::String::UTF8)));
|
||||
tag->setItem("cpil", TagLib::StringList(song.compilation() ? "1" : "0"));
|
||||
tag->setItem("cpil", TagLib::MP4::Item(song.compilation()));
|
||||
}
|
||||
|
||||
// Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same way;
|
||||
@@ -1064,14 +1064,14 @@ bool TagReaderTagLib::SaveSongPlaycountToFile(const QString &filename, const spb
|
||||
TagLib::APE::Tag *tag = wavpack_file->APETag(true);
|
||||
if (!tag) return false;
|
||||
if (song.playcount() > 0) {
|
||||
tag->setItem("FMPS_PlayCount", TagLib::APE::Item("FMPS_PlayCount", TagLib::String::number(static_cast<int>(song.playcount()))));
|
||||
tag->setItem("FMPS_Playcount", TagLib::APE::Item("FMPS_Playcount", TagLib::String::number(static_cast<int>(song.playcount()))));
|
||||
}
|
||||
}
|
||||
else if (TagLib::APE::File *ape_file = dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
||||
TagLib::APE::Tag *tag = ape_file->APETag(true);
|
||||
if (!tag) return false;
|
||||
if (song.playcount() > 0) {
|
||||
tag->setItem("FMPS_PlayCount", TagLib::APE::Item("FMPS_PlayCount", TagLib::String::number(static_cast<int>(song.playcount()))));
|
||||
tag->setItem("FMPS_Playcount", TagLib::APE::Item("FMPS_Playcount", TagLib::String::number(static_cast<int>(song.playcount()))));
|
||||
}
|
||||
}
|
||||
else if (TagLib::Ogg::XiphComment *xiph_comment = dynamic_cast<TagLib::Ogg::XiphComment*>(fileref->file()->tag())) {
|
||||
@@ -1086,7 +1086,7 @@ bool TagReaderTagLib::SaveSongPlaycountToFile(const QString &filename, const spb
|
||||
TagLib::ID3v2::Tag *tag = mpeg_file->ID3v2Tag(true);
|
||||
if (!tag) return false;
|
||||
if (song.playcount() > 0) {
|
||||
SetUserTextFrame("FMPS_PlayCount", QString::number(song.playcount()), tag);
|
||||
SetUserTextFrame("FMPS_Playcount", QString::number(song.playcount()), tag);
|
||||
TagLib::ID3v2::PopularimeterFrame *frame = GetPOPMFrameFromTag(tag);
|
||||
if (frame) {
|
||||
frame->setCounter(song.playcount());
|
||||
@@ -1105,7 +1105,7 @@ bool TagReaderTagLib::SaveSongPlaycountToFile(const QString &filename, const spb
|
||||
TagLib::APE::Tag *tag = mpc_file->APETag(true);
|
||||
if (!tag) return false;
|
||||
if (song.playcount() > 0) {
|
||||
tag->setItem("FMPS_PlayCount", TagLib::APE::Item("FMPS_PlayCount", TagLib::String::number(static_cast<int>(song.playcount()))));
|
||||
tag->setItem("FMPS_Playcount", TagLib::APE::Item("FMPS_Playcount", TagLib::String::number(static_cast<int>(song.playcount()))));
|
||||
}
|
||||
}
|
||||
else if (TagLib::ASF::File *asf_file = dynamic_cast<TagLib::ASF::File*>(fileref->file())) {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/messagehandler.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
TagReaderTagParser::TagReaderTagParser() = default;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
|
||||
qLog(Error) << "First line" << first_line << "does not match" << filepath;
|
||||
success = false;
|
||||
}
|
||||
QRegularExpression regexp(QStringLiteral("^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), current version (\\d+\\.\\d+\\.\\d+)(, weak)?\\)$"));
|
||||
QRegularExpression regexp(QStringLiteral("^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), current version (\\d+\\.\\d+\\.\\d+)(, weak|, reexport)?\\)$"));
|
||||
for (const QString &output_line : output_lines) {
|
||||
|
||||
//qDebug() << "Final check on" << filepath << output_line;
|
||||
@@ -130,9 +130,6 @@ int main(int argc, char **argv) {
|
||||
else if (library.startsWith("/System/Library/") || library.startsWith("/usr/lib/")) { // System library
|
||||
continue;
|
||||
}
|
||||
else if (library.endsWith("libgcc_s.1.dylib")) { // fftw points to it for some reason.
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
qLog(Error) << "File" << filepath << "points to" << library;
|
||||
success = false;
|
||||
@@ -140,7 +137,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
else {
|
||||
qLog(Error) << "Could not parse otool output line:" << output_line;
|
||||
continue;
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ endif()
|
||||
set(SOURCES
|
||||
core/mainwindow.cpp
|
||||
core/application.cpp
|
||||
core/appearance.cpp
|
||||
core/player.cpp
|
||||
core/commandlineoptions.cpp
|
||||
core/database.cpp
|
||||
@@ -35,14 +34,28 @@ set(SOURCES
|
||||
core/taskmanager.cpp
|
||||
core/thread.cpp
|
||||
core/urlhandler.cpp
|
||||
core/utilities.cpp
|
||||
core/imageutils.cpp
|
||||
core/iconloader.cpp
|
||||
core/standarditemiconloader.cpp
|
||||
core/scopedtransaction.cpp
|
||||
core/translations.cpp
|
||||
core/systemtrayicon.cpp
|
||||
|
||||
utilities/strutils.cpp
|
||||
utilities/envutils.cpp
|
||||
utilities/colorutils.cpp
|
||||
utilities/cryptutils.cpp
|
||||
utilities/fileutils.cpp
|
||||
utilities/diskutils.cpp
|
||||
utilities/imageutils.cpp
|
||||
utilities/macaddrutils.cpp
|
||||
utilities/mimeutils.cpp
|
||||
utilities/randutils.cpp
|
||||
utilities/threadutils.cpp
|
||||
utilities/timeutils.cpp
|
||||
utilities/transliterate.cpp
|
||||
utilities/xmlutils.cpp
|
||||
utilities/filemanagerutils.cpp
|
||||
|
||||
engine/enginetype.cpp
|
||||
engine/enginebase.cpp
|
||||
engine/devicefinders.cpp
|
||||
@@ -54,6 +67,7 @@ set(SOURCES
|
||||
analyzer/blockanalyzer.cpp
|
||||
analyzer/boomanalyzer.cpp
|
||||
analyzer/rainbowanalyzer.cpp
|
||||
analyzer/sonogram.cpp
|
||||
|
||||
equalizer/equalizer.cpp
|
||||
equalizer/equalizerslider.cpp
|
||||
@@ -69,9 +83,11 @@ set(SOURCES
|
||||
collection/collectionitemdelegate.cpp
|
||||
collection/collectionviewcontainer.cpp
|
||||
collection/collectiondirectorymodel.cpp
|
||||
collection/collectionfilteroptions.cpp
|
||||
collection/collectionfilterwidget.cpp
|
||||
collection/collectionplaylistitem.cpp
|
||||
collection/collectionquery.cpp
|
||||
collection/collectionqueryoptions.cpp
|
||||
collection/savedgroupingmanager.cpp
|
||||
collection/groupbydialog.cpp
|
||||
collection/collectiontask.cpp
|
||||
@@ -161,6 +177,9 @@ set(SOURCES
|
||||
lyrics/geniuslyricsprovider.cpp
|
||||
lyrics/musixmatchlyricsprovider.cpp
|
||||
lyrics/chartlyricsprovider.cpp
|
||||
lyrics/stands4lyricsprovider.cpp
|
||||
|
||||
providers/musixmatchprovider.cpp
|
||||
|
||||
settings/settingsdialog.cpp
|
||||
settings/settingspage.cpp
|
||||
@@ -203,6 +222,8 @@ set(SOURCES
|
||||
widgets/multiloadingindicator.cpp
|
||||
widgets/playingwidget.cpp
|
||||
widgets/renametablineedit.cpp
|
||||
widgets/sliderslider.cpp
|
||||
widgets/prettyslider.cpp
|
||||
widgets/volumeslider.cpp
|
||||
widgets/stickyslider.cpp
|
||||
widgets/stretchheaderview.cpp
|
||||
@@ -262,7 +283,6 @@ set(SOURCES
|
||||
set(HEADERS
|
||||
core/mainwindow.h
|
||||
core/application.h
|
||||
core/appearance.h
|
||||
core/player.h
|
||||
core/database.h
|
||||
core/deletefiles.h
|
||||
@@ -292,6 +312,7 @@ set(HEADERS
|
||||
analyzer/blockanalyzer.h
|
||||
analyzer/boomanalyzer.h
|
||||
analyzer/rainbowanalyzer.h
|
||||
analyzer/sonogram.h
|
||||
|
||||
equalizer/equalizer.h
|
||||
equalizer/equalizerslider.h
|
||||
@@ -393,6 +414,7 @@ set(HEADERS
|
||||
lyrics/geniuslyricsprovider.h
|
||||
lyrics/musixmatchlyricsprovider.h
|
||||
lyrics/chartlyricsprovider.h
|
||||
lyrics/stands4lyricsprovider.h
|
||||
|
||||
settings/settingsdialog.h
|
||||
settings/settingspage.h
|
||||
@@ -434,6 +456,8 @@ set(HEADERS
|
||||
widgets/multiloadingindicator.h
|
||||
widgets/playingwidget.h
|
||||
widgets/renametablineedit.h
|
||||
widgets/sliderslider.h
|
||||
widgets/prettyslider.h
|
||||
widgets/volumeslider.h
|
||||
widgets/stickyslider.h
|
||||
widgets/stretchheaderview.h
|
||||
@@ -444,7 +468,6 @@ set(HEADERS
|
||||
widgets/qsearchfield.h
|
||||
widgets/ratingwidget.h
|
||||
widgets/forcescrollperpixel.h
|
||||
widgets/resizabletextedit.h
|
||||
|
||||
osd/osdbase.h
|
||||
osd/osdpretty.h
|
||||
@@ -570,7 +593,7 @@ option(USE_INSTALL_PREFIX "Look for data in CMAKE_INSTALL_PREFIX" ON)
|
||||
|
||||
if(NOT APPLE)
|
||||
set(NOT_APPLE ON)
|
||||
optional_source(NOT_APPLE SOURCES widgets/qsearchfield_nonmac.cpp core/qtsystemtrayicon.cpp HEADERS core/qtsystemtrayicon.h)
|
||||
optional_source(NOT_APPLE SOURCES widgets/qsearchfield_qt.cpp core/qtsystemtrayicon.cpp HEADERS core/qtsystemtrayicon.h)
|
||||
endif()
|
||||
|
||||
if(HAVE_GLOBALSHORTCUTS)
|
||||
@@ -610,43 +633,42 @@ optional_source(HAVE_VLC SOURCES engine/vlcengine.cpp HEADERS engine/vlcengine.h
|
||||
|
||||
# DBUS and MPRIS - Unix specific
|
||||
if(UNIX AND HAVE_DBUS)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dbus)
|
||||
|
||||
optional_source(HAVE_DBUS SOURCES core/mpris2.cpp HEADERS core/mpris2.h)
|
||||
optional_source(HAVE_UDISKS2 SOURCES device/udisks2lister.cpp HEADERS device/udisks2lister.h)
|
||||
|
||||
# MPRIS 2.0 DBUS interfaces
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.Player.xml core/mpris2.h mpris::Mpris2 core/mpris2_player Mpris2Player)
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.xml core/mpris2.h mpris::Mpris2 core/mpris2_root Mpris2Root)
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.TrackList.xml core/mpris2.h mpris::Mpris2 core/mpris2_tracklist Mpris2TrackList)
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.Player.xml core/mpris2.h mpris::Mpris2 mpris2_player Mpris2Player)
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.xml core/mpris2.h mpris::Mpris2 mpris2_root Mpris2Root)
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.TrackList.xml core/mpris2.h mpris::Mpris2 mpris2_tracklist Mpris2TrackList)
|
||||
|
||||
# MPRIS 2.1 DBUS interfaces
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.Playlists.xml core/mpris2.h mpris::Mpris2 core/mpris2_playlists Mpris2Playlists)
|
||||
qt_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.Playlists.xml core/mpris2.h mpris::Mpris2 mpris2_playlists Mpris2Playlists)
|
||||
|
||||
# org.freedesktop.Notifications DBUS interface
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.Notifications.xml dbus/notification)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.Notifications.xml notification)
|
||||
|
||||
# org.gnome.SettingsDaemon interface
|
||||
qt_add_dbus_interface(SOURCES dbus/org.gnome.SettingsDaemon.MediaKeys.xml dbus/gnomesettingsdaemon)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.gnome.SettingsDaemon.MediaKeys.xml gnomesettingsdaemon)
|
||||
|
||||
# org.mate.SettingsDaemon interface
|
||||
qt_add_dbus_interface(SOURCES dbus/org.mate.SettingsDaemon.MediaKeys.xml dbus/matesettingsdaemon)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.mate.SettingsDaemon.MediaKeys.xml matesettingsdaemon)
|
||||
|
||||
# org.kde.KGlobalAccel interface
|
||||
qt_add_dbus_interface(SOURCES dbus/org.kde.KGlobalAccel.xml dbus/kglobalaccel)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.kde.KGlobalAccel.Component.xml dbus/kglobalaccelcomponent)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.kde.KGlobalAccel.xml kglobalaccel)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.kde.KGlobalAccel.Component.xml kglobalaccelcomponent)
|
||||
|
||||
if(HAVE_UDISKS2)
|
||||
set_source_files_properties(dbus/org.freedesktop.DBus.ObjectManager.xml PROPERTIES NO_NAMESPACE dbus/objectmanager INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Filesystem.xml PROPERTIES NO_NAMESPACE dbus/udisks2filesystem INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Block.xml PROPERTIES NO_NAMESPACE dbus/udisks2block INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Drive.xml PROPERTIES NO_NAMESPACE dbus/udisks2drive INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Job.xml PROPERTIES NO_NAMESPACE dbus/udisks2job INCLUDE dbus/metatypes.h)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.DBus.ObjectManager.xml dbus/objectmanager)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Filesystem.xml dbus/udisks2filesystem)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Block.xml dbus/udisks2block)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Drive.xml dbus/udisks2drive)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Job.xml dbus/udisks2job)
|
||||
set_source_files_properties(dbus/org.freedesktop.DBus.ObjectManager.xml PROPERTIES NO_NAMESPACE objectmanager INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Filesystem.xml PROPERTIES NO_NAMESPACE udisks2filesystem INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Block.xml PROPERTIES NO_NAMESPACE udisks2block INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Drive.xml PROPERTIES NO_NAMESPACE udisks2drive INCLUDE dbus/metatypes.h)
|
||||
set_source_files_properties(dbus/org.freedesktop.UDisks2.Job.xml PROPERTIES NO_NAMESPACE udisks2job INCLUDE dbus/metatypes.h)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.DBus.ObjectManager.xml objectmanager)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Filesystem.xml udisks2filesystem)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Block.xml udisks2block)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Drive.xml udisks2drive)
|
||||
qt_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks2.Job.xml udisks2job)
|
||||
endif(HAVE_UDISKS2)
|
||||
|
||||
endif(UNIX AND HAVE_DBUS)
|
||||
@@ -782,8 +804,8 @@ optional_source(HAVE_AUDIOCD
|
||||
# Platform specific - macOS
|
||||
optional_source(APPLE
|
||||
SOURCES
|
||||
utilities/macosutils.mm
|
||||
core/scoped_nsautorelease_pool.mm
|
||||
core/mac_utilities.mm
|
||||
core/mac_startup.mm
|
||||
core/macsystemtrayicon.mm
|
||||
core/macfslistener.mm
|
||||
@@ -804,8 +826,10 @@ optional_source(APPLE
|
||||
# Platform specific - Windows
|
||||
optional_source(WIN32
|
||||
SOURCES
|
||||
utilities/winutils.cpp
|
||||
engine/directsounddevicefinder.cpp
|
||||
engine/mmdevicefinder.cpp
|
||||
core/scopedwchararray.cpp
|
||||
core/windows7thumbbar.cpp
|
||||
HEADERS
|
||||
core/windows7thumbbar.h
|
||||
|
||||
@@ -108,7 +108,7 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) {
|
||||
p.fillRect(e->rect(), palette().color(QPalette::Window));
|
||||
|
||||
switch (engine_->state()) {
|
||||
case Engine::Playing: {
|
||||
case Engine::State::Playing: {
|
||||
const Engine::Scope &thescope = engine_->scope(timeout_);
|
||||
int i = 0;
|
||||
|
||||
@@ -126,7 +126,7 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) {
|
||||
|
||||
break;
|
||||
}
|
||||
case Engine::Paused:
|
||||
case Engine::State::Paused:
|
||||
is_playing_ = false;
|
||||
analyze(p, lastscope_, new_frame_);
|
||||
break;
|
||||
|
||||
@@ -49,7 +49,7 @@ class QTimerEvent;
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
typedef std::vector<float> Scope;
|
||||
using Scope = std::vector<float>;
|
||||
|
||||
class Base : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "blockanalyzer.h"
|
||||
#include "boomanalyzer.h"
|
||||
#include "rainbowanalyzer.h"
|
||||
#include "sonogram.h"
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "engine/enginebase.h"
|
||||
@@ -85,6 +86,7 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent)
|
||||
AddAnalyzerType<BoomAnalyzer>();
|
||||
AddAnalyzerType<Rainbow::NyanCatAnalyzer>();
|
||||
AddAnalyzerType<Rainbow::RainbowDashAnalyzer>();
|
||||
AddAnalyzerType<Sonogram>();
|
||||
|
||||
disable_action_ = context_menu_->addAction(tr("No analyzer"), this, &AnalyzerContainer::DisableAnalyzer);
|
||||
disable_action_->setCheckable(true);
|
||||
|
||||
@@ -110,7 +110,7 @@ void BoomAnalyzer::transform(Scope &s) {
|
||||
|
||||
void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame) {
|
||||
|
||||
if (!new_frame || engine_->state() == Engine::Paused) {
|
||||
if (!new_frame || engine_->state() == Engine::State::Paused) {
|
||||
p.drawPixmap(0, 0, canvas_);
|
||||
return;
|
||||
}
|
||||
|
||||
94
src/analyzer/sonogram.cpp
Normal file
94
src/analyzer/sonogram.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Strawberry Music Player
|
||||
This file was part of Clementine.
|
||||
Copyright 2004, Melchior FRANZ <mfranz@kde.org>
|
||||
Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
|
||||
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
|
||||
Copyright 2014-2015, Mark Furneaux <mark@furneaux.ca>
|
||||
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
||||
|
||||
Strawberry is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Strawberry is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
|
||||
#include "sonogram.h"
|
||||
|
||||
const char *Sonogram::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Sonogram");
|
||||
|
||||
Sonogram::Sonogram(QWidget *parent)
|
||||
: Analyzer::Base(parent, 9) {}
|
||||
|
||||
Sonogram::~Sonogram() {}
|
||||
|
||||
void Sonogram::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
Q_UNUSED(e)
|
||||
|
||||
canvas_ = QPixmap(size());
|
||||
canvas_.fill(palette().color(QPalette::Window));
|
||||
|
||||
}
|
||||
|
||||
void Sonogram::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
|
||||
|
||||
if (!new_frame || engine_->state() == Engine::State::Paused) {
|
||||
p.drawPixmap(0, 0, canvas_);
|
||||
return;
|
||||
}
|
||||
|
||||
QPainter canvas_painter(&canvas_);
|
||||
canvas_painter.drawPixmap(0, 0, canvas_, 1, 0, width() - 1, -1);
|
||||
|
||||
Analyzer::Scope::const_iterator it = s.begin(), end = s.end();
|
||||
|
||||
for (int y = height() - 1; y;) {
|
||||
QColor c;
|
||||
if (it >= end || *it < .005) {
|
||||
c = palette().color(QPalette::Window);
|
||||
}
|
||||
else if (*it < .05) {
|
||||
c.setHsv(95, 255, 255 - static_cast<int>(*it * 4000.0));
|
||||
}
|
||||
else if (*it < 1.0) {
|
||||
c.setHsv(95 - static_cast<int>(*it * 90.0), 255, 255);
|
||||
}
|
||||
else {
|
||||
c = Qt::red;
|
||||
}
|
||||
|
||||
canvas_painter.setPen(c);
|
||||
canvas_painter.drawPoint(width() - 1, y--);
|
||||
|
||||
if (it < end) ++it;
|
||||
}
|
||||
|
||||
canvas_painter.end();
|
||||
|
||||
p.drawPixmap(0, 0, canvas_);
|
||||
|
||||
}
|
||||
|
||||
void Sonogram::transform(Analyzer::Scope &scope) {
|
||||
|
||||
fht_->power2(scope.data());
|
||||
fht_->scale(scope.data(), 1.0 / 256);
|
||||
scope.resize(fht_->size() / 2);
|
||||
|
||||
}
|
||||
|
||||
void Sonogram::demo(QPainter &p) {
|
||||
analyze(p, Analyzer::Scope(fht_->size(), 0), new_frame_);
|
||||
}
|
||||
50
src/analyzer/sonogram.h
Normal file
50
src/analyzer/sonogram.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Strawberry Music Player
|
||||
This file was part of Clementine.
|
||||
Copyright 2004, Melchior FRANZ <mfranz@kde.org>
|
||||
Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
|
||||
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
||||
Copyright 2014, John Maguire <john.maguire@gmail.com>
|
||||
Copyright 2015, Mark Furneaux <mark@furneaux.ca>
|
||||
|
||||
Strawberry is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Strawberry is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SONOGRAM_H
|
||||
#define SONOGRAM_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
|
||||
#include "analyzerbase.h"
|
||||
|
||||
class Sonogram : public Analyzer::Base {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_INVOKABLE explicit Sonogram(QWidget *parent);
|
||||
~Sonogram();
|
||||
|
||||
static const char *kName;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) override;
|
||||
void transform(Analyzer::Scope &scope) override;
|
||||
void demo(QPainter &p) override;
|
||||
|
||||
private:
|
||||
QPixmap canvas_;
|
||||
};
|
||||
|
||||
#endif // SONOGRAM_H
|
||||
@@ -34,9 +34,9 @@
|
||||
#include "core/player.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "core/thread.h"
|
||||
#include "core/utilities.h"
|
||||
#include "core/song.h"
|
||||
#include "core/logging.h"
|
||||
#include "utilities/threadutils.h"
|
||||
#include "collection.h"
|
||||
#include "collectionwatcher.h"
|
||||
#include "collectionbackend.h"
|
||||
@@ -69,7 +69,7 @@ SCollection::SCollection(Application *app, QObject *parent)
|
||||
backend()->moveToThread(app->database()->thread());
|
||||
qLog(Debug) << backend_ << "moved to thread" << app->database()->thread();
|
||||
|
||||
backend_->Init(app->database(), app->task_manager(), Song::Source_Collection, kSongsTable, kFtsTable, kDirsTable, kSubdirsTable);
|
||||
backend_->Init(app->database(), app->task_manager(), Song::Source::Collection, kSongsTable, kFtsTable, kDirsTable, kSubdirsTable);
|
||||
|
||||
model_ = new CollectionModel(backend_, app_, this);
|
||||
|
||||
@@ -93,7 +93,7 @@ SCollection::~SCollection() {
|
||||
|
||||
void SCollection::Init() {
|
||||
|
||||
watcher_ = new CollectionWatcher(Song::Source_Collection);
|
||||
watcher_ = new CollectionWatcher(Song::Source::Collection);
|
||||
watcher_thread_ = new Thread(this);
|
||||
|
||||
#ifndef Q_OS_WIN32
|
||||
@@ -104,7 +104,7 @@ void SCollection::Init() {
|
||||
|
||||
watcher_->moveToThread(watcher_thread_);
|
||||
|
||||
qLog(Debug) << watcher_ << "moved to thread" << watcher_thread_ << "with I/O priority" << io_priority_ << "and thread priority" << thread_priority_;
|
||||
qLog(Debug) << watcher_ << "moved to thread" << watcher_thread_ << "with I/O priority" << static_cast<int>(io_priority_) << "and thread priority" << thread_priority_;
|
||||
|
||||
watcher_thread_->start(thread_priority_);
|
||||
|
||||
@@ -184,7 +184,7 @@ void SCollection::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
|
||||
io_priority_ = static_cast<Utilities::IoPriority>(s.value("io_priority", Utilities::IOPRIO_CLASS_IDLE).toInt());
|
||||
io_priority_ = static_cast<Utilities::IoPriority>(s.value("io_priority", static_cast<int>(Utilities::IoPriority::IOPRIO_CLASS_IDLE)).toInt());
|
||||
thread_priority_ = static_cast<QThread::Priority>(s.value("thread_priority", QThread::Priority::IdlePriority).toInt());
|
||||
save_playcounts_to_files_ = s.value("save_playcounts", false).toBool();
|
||||
save_ratings_to_files_ = s.value("save_ratings", false).toBool();
|
||||
@@ -219,9 +219,9 @@ void SCollection::SyncPlaycountAndRatingToFiles() {
|
||||
|
||||
}
|
||||
|
||||
void SCollection::SongsPlaycountChanged(const SongList &songs) {
|
||||
void SCollection::SongsPlaycountChanged(const SongList &songs, const bool save_tags) {
|
||||
|
||||
if (save_playcounts_to_files_) {
|
||||
if (save_tags || save_playcounts_to_files_) {
|
||||
app_->tag_reader_client()->UpdateSongsPlaycount(songs);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <QThread>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "core/utilities.h"
|
||||
#include "utilities/threadutils.h"
|
||||
|
||||
class Application;
|
||||
class Thread;
|
||||
@@ -78,7 +78,7 @@ class SCollection : public QObject {
|
||||
|
||||
private slots:
|
||||
void ExitReceived();
|
||||
void SongsPlaycountChanged(const SongList &songs);
|
||||
void SongsPlaycountChanged(const SongList &songs, const bool save_tags = false);
|
||||
void SongsRatingChanged(const SongList &songs, const bool save_tags = false);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -50,8 +50,9 @@
|
||||
#include "core/sqlrow.h"
|
||||
#include "smartplaylists/smartplaylistsearch.h"
|
||||
|
||||
#include "directory.h"
|
||||
#include "collectiondirectory.h"
|
||||
#include "collectionbackend.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionquery.h"
|
||||
#include "collectiontask.h"
|
||||
|
||||
@@ -59,7 +60,7 @@ CollectionBackend::CollectionBackend(QObject *parent)
|
||||
: CollectionBackendInterface(parent),
|
||||
db_(nullptr),
|
||||
task_manager_(nullptr),
|
||||
source_(Song::Source_Unknown),
|
||||
source_(Song::Source::Unknown),
|
||||
original_thread_(nullptr) {
|
||||
|
||||
original_thread_ = thread();
|
||||
@@ -139,18 +140,18 @@ void CollectionBackend::IncrementSkipCountAsync(const int id, const float progre
|
||||
QMetaObject::invokeMethod(this, "IncrementSkipCount", Qt::QueuedConnection, Q_ARG(int, id), Q_ARG(float, progress));
|
||||
}
|
||||
|
||||
void CollectionBackend::ResetStatisticsAsync(const int id) {
|
||||
QMetaObject::invokeMethod(this, "ResetStatistics", Qt::QueuedConnection, Q_ARG(int, id));
|
||||
void CollectionBackend::ResetStatisticsAsync(const int id, const bool save_tags) {
|
||||
QMetaObject::invokeMethod(this, "ResetStatistics", Qt::QueuedConnection, Q_ARG(int, id), Q_ARG(bool, save_tags));
|
||||
}
|
||||
|
||||
void CollectionBackend::LoadDirectories() {
|
||||
|
||||
DirectoryList dirs = GetAllDirectories();
|
||||
CollectionDirectoryList dirs = GetAllDirectories();
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
for (const Directory &dir : dirs) {
|
||||
for (const CollectionDirectory &dir : dirs) {
|
||||
emit DirectoryDiscovered(dir, SubdirsInDirectory(dir.id, db));
|
||||
}
|
||||
|
||||
@@ -207,12 +208,12 @@ void CollectionBackend::ChangeDirPath(const int id, const QString &old_path, con
|
||||
|
||||
}
|
||||
|
||||
DirectoryList CollectionBackend::GetAllDirectories() {
|
||||
CollectionDirectoryList CollectionBackend::GetAllDirectories() {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
DirectoryList ret;
|
||||
CollectionDirectoryList ret;
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("SELECT ROWID, path FROM %1").arg(dirs_table_));
|
||||
@@ -222,7 +223,7 @@ DirectoryList CollectionBackend::GetAllDirectories() {
|
||||
}
|
||||
|
||||
while (q.next()) {
|
||||
Directory dir;
|
||||
CollectionDirectory dir;
|
||||
dir.id = q.value(0).toInt();
|
||||
dir.path = q.value(1).toString();
|
||||
|
||||
@@ -232,7 +233,7 @@ DirectoryList CollectionBackend::GetAllDirectories() {
|
||||
|
||||
}
|
||||
|
||||
SubdirectoryList CollectionBackend::SubdirsInDirectory(const int id) {
|
||||
CollectionSubdirectoryList CollectionBackend::SubdirsInDirectory(const int id) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db = db_->Connect();
|
||||
@@ -240,19 +241,19 @@ SubdirectoryList CollectionBackend::SubdirsInDirectory(const int id) {
|
||||
|
||||
}
|
||||
|
||||
SubdirectoryList CollectionBackend::SubdirsInDirectory(const int id, QSqlDatabase &db) {
|
||||
CollectionSubdirectoryList CollectionBackend::SubdirsInDirectory(const int id, QSqlDatabase &db) {
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("SELECT path, mtime FROM %1 WHERE directory_id = :dir").arg(subdirs_table_));
|
||||
q.BindValue(":dir", id);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return SubdirectoryList();
|
||||
return CollectionSubdirectoryList();
|
||||
}
|
||||
|
||||
SubdirectoryList subdirs;
|
||||
CollectionSubdirectoryList subdirs;
|
||||
while (q.next()) {
|
||||
Subdirectory subdir;
|
||||
CollectionSubdirectory subdir;
|
||||
subdir.directory_id = id;
|
||||
subdir.path = q.value(0).toString();
|
||||
subdir.mtime = q.value(1).toLongLong();
|
||||
@@ -339,15 +340,15 @@ void CollectionBackend::AddDirectory(const QString &path) {
|
||||
return;
|
||||
}
|
||||
|
||||
Directory dir;
|
||||
CollectionDirectory dir;
|
||||
dir.path = canonical_path;
|
||||
dir.id = q.lastInsertId().toInt();
|
||||
|
||||
emit DirectoryDiscovered(dir, SubdirectoryList());
|
||||
emit DirectoryDiscovered(dir, CollectionSubdirectoryList());
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::RemoveDirectory(const Directory &dir) {
|
||||
void CollectionBackend::RemoveDirectory(const CollectionDirectory &dir) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
@@ -447,13 +448,13 @@ void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_f
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::AddOrUpdateSubdirs(const SubdirectoryList &subdirs) {
|
||||
void CollectionBackend::AddOrUpdateSubdirs(const CollectionSubdirectoryList &subdirs) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
ScopedTransaction transaction(&db);
|
||||
for (const Subdirectory &subdir : subdirs) {
|
||||
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||
if (subdir.mtime == 0) {
|
||||
// Delete the subdirectory
|
||||
SqlQuery q(db);
|
||||
@@ -713,7 +714,7 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
|
||||
|
||||
Song old_song = old_songs[new_song.song_id()];
|
||||
|
||||
if (!new_song.IsMetadataEqual(old_song)) { // Update existing song.
|
||||
if (!new_song.IsAllMetadataEqual(old_song)) { // Update existing song.
|
||||
|
||||
{
|
||||
SqlQuery q(db);
|
||||
@@ -900,12 +901,12 @@ void CollectionBackend::MarkSongsUnavailable(const SongList &songs, const bool u
|
||||
|
||||
}
|
||||
|
||||
QStringList CollectionBackend::GetAll(const QString &column, const QueryOptions &opt) {
|
||||
QStringList CollectionBackend::GetAll(const QString &column, const CollectionFilterOptions &filter_options) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
CollectionQuery query(db, songs_table_, fts_table_, opt);
|
||||
CollectionQuery query(db, songs_table_, fts_table_, filter_options);
|
||||
query.SetColumnSpec("DISTINCT " + column);
|
||||
query.AddCompilationRequirement(false);
|
||||
|
||||
@@ -922,12 +923,12 @@ QStringList CollectionBackend::GetAll(const QString &column, const QueryOptions
|
||||
|
||||
}
|
||||
|
||||
QStringList CollectionBackend::GetAllArtists(const QueryOptions &opt) {
|
||||
QStringList CollectionBackend::GetAllArtists(const CollectionFilterOptions &opt) {
|
||||
|
||||
return GetAll("artist", opt);
|
||||
}
|
||||
|
||||
QStringList CollectionBackend::GetAllArtistsWithAlbums(const QueryOptions &opt) {
|
||||
QStringList CollectionBackend::GetAllArtistsWithAlbums(const CollectionFilterOptions &opt) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
@@ -967,15 +968,15 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const QueryOptions &opt)
|
||||
|
||||
}
|
||||
|
||||
CollectionBackend::AlbumList CollectionBackend::GetAllAlbums(const QueryOptions &opt) {
|
||||
CollectionBackend::AlbumList CollectionBackend::GetAllAlbums(const CollectionFilterOptions &opt) {
|
||||
return GetAlbums(QString(), false, opt);
|
||||
}
|
||||
|
||||
CollectionBackend::AlbumList CollectionBackend::GetAlbumsByArtist(const QString &artist, const QueryOptions &opt) {
|
||||
CollectionBackend::AlbumList CollectionBackend::GetAlbumsByArtist(const QString &artist, const CollectionFilterOptions &opt) {
|
||||
return GetAlbums(artist, false, opt);
|
||||
}
|
||||
|
||||
SongList CollectionBackend::GetArtistSongs(const QString &effective_albumartist, const QueryOptions &opt) {
|
||||
SongList CollectionBackend::GetArtistSongs(const QString &effective_albumartist, const CollectionFilterOptions &opt) {
|
||||
|
||||
QSqlDatabase db(db_->Connect());
|
||||
QMutexLocker l(db_->Mutex());
|
||||
@@ -993,7 +994,7 @@ SongList CollectionBackend::GetArtistSongs(const QString &effective_albumartist,
|
||||
|
||||
}
|
||||
|
||||
SongList CollectionBackend::GetAlbumSongs(const QString &effective_albumartist, const QString &album, const QueryOptions &opt) {
|
||||
SongList CollectionBackend::GetAlbumSongs(const QString &effective_albumartist, const QString &album, const CollectionFilterOptions &opt) {
|
||||
|
||||
QSqlDatabase db(db_->Connect());
|
||||
QMutexLocker l(db_->Mutex());
|
||||
@@ -1012,7 +1013,7 @@ SongList CollectionBackend::GetAlbumSongs(const QString &effective_albumartist,
|
||||
|
||||
}
|
||||
|
||||
SongList CollectionBackend::GetSongsByAlbum(const QString &album, const QueryOptions &opt) {
|
||||
SongList CollectionBackend::GetSongsByAlbum(const QString &album, const CollectionFilterOptions &opt) {
|
||||
|
||||
QSqlDatabase db(db_->Connect());
|
||||
QMutexLocker l(db_->Mutex());
|
||||
@@ -1285,11 +1286,11 @@ SongList CollectionBackend::GetSongsByFingerprint(const QString &fingerprint) {
|
||||
}
|
||||
|
||||
|
||||
CollectionBackend::AlbumList CollectionBackend::GetCompilationAlbums(const QueryOptions &opt) {
|
||||
CollectionBackend::AlbumList CollectionBackend::GetCompilationAlbums(const CollectionFilterOptions &opt) {
|
||||
return GetAlbums(QString(), true, opt);
|
||||
}
|
||||
|
||||
SongList CollectionBackend::GetCompilationSongs(const QString &album, const QueryOptions &opt) {
|
||||
SongList CollectionBackend::GetCompilationSongs(const QString &album, const CollectionFilterOptions &opt) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
@@ -1314,10 +1315,6 @@ SongList CollectionBackend::GetCompilationSongs(const QString &album, const Quer
|
||||
|
||||
}
|
||||
|
||||
Song::Source CollectionBackend::Source() const {
|
||||
return source_;
|
||||
}
|
||||
|
||||
void CollectionBackend::CompilationsNeedUpdating() {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
@@ -1430,7 +1427,7 @@ bool CollectionBackend::UpdateCompilations(const QSqlDatabase &db, SongList &del
|
||||
|
||||
}
|
||||
|
||||
CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, const bool compilation_required, const QueryOptions &opt) {
|
||||
CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, const bool compilation_required, const CollectionFilterOptions &opt) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
@@ -1520,7 +1517,7 @@ CollectionBackend::Album CollectionBackend::GetAlbumArt(const QString &effective
|
||||
ret.album = album;
|
||||
ret.album_artist = effective_albumartist;
|
||||
|
||||
CollectionQuery query(db, songs_table_, fts_table_, QueryOptions());
|
||||
CollectionQuery query(db, songs_table_, fts_table_);
|
||||
query.SetColumnSpec("art_automatic, art_manual, url");
|
||||
if (!effective_albumartist.isEmpty()) {
|
||||
query.AddWhere("effective_albumartist", effective_albumartist);
|
||||
@@ -1779,7 +1776,7 @@ void CollectionBackend::IncrementSkipCount(const int id, const float progress) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::ResetStatistics(const int id) {
|
||||
void CollectionBackend::ResetStatistics(const int id, const bool save_tags) {
|
||||
|
||||
if (id == -1) return;
|
||||
|
||||
@@ -1795,7 +1792,7 @@ void CollectionBackend::ResetStatistics(const int id) {
|
||||
}
|
||||
|
||||
Song new_song = GetSongById(id, db);
|
||||
emit SongsStatisticsChanged(SongList() << new_song);
|
||||
emit SongsStatisticsChanged(SongList() << new_song, save_tags);
|
||||
|
||||
}
|
||||
|
||||
@@ -1867,7 +1864,7 @@ SongList CollectionBackend::SmartPlaylistsFindSongs(const SmartPlaylistSearch &s
|
||||
SongList CollectionBackend::SmartPlaylistsGetAllSongs() {
|
||||
|
||||
// Get all the songs!
|
||||
return SmartPlaylistsFindSongs(SmartPlaylistSearch(SmartPlaylistSearch::Type_All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::Sort_FieldAsc, SmartPlaylistSearchTerm::Field_Artist, -1));
|
||||
return SmartPlaylistsFindSongs(SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldAsc, SmartPlaylistSearchTerm::Field::Artist, -1));
|
||||
|
||||
}
|
||||
|
||||
@@ -1930,7 +1927,7 @@ void CollectionBackend::UpdateLastPlayed(const QString &artist, const QString &a
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::UpdatePlayCount(const QString &artist, const QString &title, const int playcount) {
|
||||
void CollectionBackend::UpdatePlayCount(const QString &artist, const QString &title, const int playcount, const bool save_tags) {
|
||||
|
||||
SongList songs = GetSongsBy(artist, QString(), title);
|
||||
if (songs.isEmpty()) {
|
||||
@@ -1952,7 +1949,7 @@ void CollectionBackend::UpdatePlayCount(const QString &artist, const QString &ti
|
||||
}
|
||||
}
|
||||
|
||||
emit SongsStatisticsChanged(SongList() << songs);
|
||||
emit SongsStatisticsChanged(SongList() << songs, save_tags);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,9 @@
|
||||
|
||||
#include "core/song.h"
|
||||
#include "core/sqlquery.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionquery.h"
|
||||
#include "directory.h"
|
||||
#include "collectiondirectory.h"
|
||||
|
||||
class QThread;
|
||||
class TaskManager;
|
||||
@@ -53,7 +54,7 @@ class CollectionBackendInterface : public QObject {
|
||||
explicit CollectionBackendInterface(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
struct Album {
|
||||
Album() {}
|
||||
Album() : filetype(Song::FileType::Unknown) {}
|
||||
Album(const QString &_album_artist, const QString &_album, const QUrl &_art_automatic, const QUrl &_art_manual, const QList<QUrl> &_urls, const Song::FileType _filetype, const QString &_cue_path)
|
||||
: album_artist(_album_artist),
|
||||
album(_album),
|
||||
@@ -72,11 +73,13 @@ class CollectionBackendInterface : public QObject {
|
||||
Song::FileType filetype;
|
||||
QString cue_path;
|
||||
};
|
||||
typedef QList<Album> AlbumList;
|
||||
using AlbumList = QList<Album>;
|
||||
|
||||
virtual QString songs_table() const = 0;
|
||||
virtual QString fts_table() const = 0;
|
||||
|
||||
virtual Song::Source source() const = 0;
|
||||
|
||||
virtual Database *db() const = 0;
|
||||
|
||||
// Get a list of directories in the collection. Emits DirectoriesDiscovered.
|
||||
@@ -88,23 +91,23 @@ class CollectionBackendInterface : public QObject {
|
||||
|
||||
virtual SongList FindSongsInDirectory(const int id) = 0;
|
||||
virtual SongList SongsWithMissingFingerprint(const int id) = 0;
|
||||
virtual SubdirectoryList SubdirsInDirectory(const int id) = 0;
|
||||
virtual DirectoryList GetAllDirectories() = 0;
|
||||
virtual CollectionSubdirectoryList SubdirsInDirectory(const int id) = 0;
|
||||
virtual CollectionDirectoryList GetAllDirectories() = 0;
|
||||
virtual void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) = 0;
|
||||
|
||||
virtual SongList GetAllSongs() = 0;
|
||||
|
||||
virtual QStringList GetAllArtists(const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual QStringList GetAllArtistsWithAlbums(const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual SongList GetArtistSongs(const QString &effective_albumartist, const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual SongList GetAlbumSongs(const QString &effective_albumartist, const QString &album, const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual SongList GetSongsByAlbum(const QString &album, const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual QStringList GetAllArtists(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
virtual QStringList GetAllArtistsWithAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
virtual SongList GetArtistSongs(const QString &effective_albumartist, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
virtual SongList GetAlbumSongs(const QString &effective_albumartist, const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
virtual SongList GetSongsByAlbum(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
|
||||
virtual SongList GetCompilationSongs(const QString &album, const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual SongList GetCompilationSongs(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
|
||||
virtual AlbumList GetAllAlbums(const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual AlbumList GetAlbumsByArtist(const QString &artist, const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual AlbumList GetCompilationAlbums(const QueryOptions &opt = QueryOptions()) = 0;
|
||||
virtual AlbumList GetAllAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
virtual AlbumList GetAlbumsByArtist(const QString &artist, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
virtual AlbumList GetCompilationAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
||||
|
||||
virtual void UpdateManualAlbumArtAsync(const QString &effective_albumartist, const QString &album, const QUrl &cover_url, const bool clear_art_automatic = false) = 0;
|
||||
virtual void UpdateAutomaticAlbumArtAsync(const QString &effective_albumartist, const QString &album, const QUrl &cover_url, const bool clear_art_manual = false) = 0;
|
||||
@@ -122,7 +125,7 @@ class CollectionBackendInterface : public QObject {
|
||||
virtual Song GetSongByUrl(const QUrl &url, const qint64 beginning = 0) = 0;
|
||||
|
||||
virtual void AddDirectory(const QString &path) = 0;
|
||||
virtual void RemoveDirectory(const Directory &dir) = 0;
|
||||
virtual void RemoveDirectory(const CollectionDirectory &dir) = 0;
|
||||
};
|
||||
|
||||
class CollectionBackend : public CollectionBackendInterface {
|
||||
@@ -139,6 +142,8 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
|
||||
void ReportErrors(const CollectionQuery &query);
|
||||
|
||||
Song::Source source() const override { return source_; }
|
||||
|
||||
Database *db() const override { return db_; }
|
||||
|
||||
QString songs_table() const override { return songs_table_; }
|
||||
@@ -155,24 +160,24 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
|
||||
SongList FindSongsInDirectory(const int id) override;
|
||||
SongList SongsWithMissingFingerprint(const int id) override;
|
||||
SubdirectoryList SubdirsInDirectory(const int id) override;
|
||||
DirectoryList GetAllDirectories() override;
|
||||
CollectionSubdirectoryList SubdirsInDirectory(const int id) override;
|
||||
CollectionDirectoryList GetAllDirectories() override;
|
||||
void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) override;
|
||||
|
||||
SongList GetAllSongs() override;
|
||||
|
||||
QStringList GetAll(const QString &column, const QueryOptions &opt = QueryOptions());
|
||||
QStringList GetAllArtists(const QueryOptions &opt = QueryOptions()) override;
|
||||
QStringList GetAllArtistsWithAlbums(const QueryOptions &opt = QueryOptions()) override;
|
||||
SongList GetArtistSongs(const QString &effective_albumartist, const QueryOptions &opt = QueryOptions()) override;
|
||||
SongList GetAlbumSongs(const QString &effective_albumartist, const QString &album, const QueryOptions &opt = QueryOptions()) override;
|
||||
SongList GetSongsByAlbum(const QString &album, const QueryOptions &opt = QueryOptions()) override;
|
||||
QStringList GetAll(const QString &column, const CollectionFilterOptions &filter_options = CollectionFilterOptions());
|
||||
QStringList GetAllArtists(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
QStringList GetAllArtistsWithAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
SongList GetArtistSongs(const QString &effective_albumartist, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
SongList GetAlbumSongs(const QString &effective_albumartist, const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
SongList GetSongsByAlbum(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
|
||||
SongList GetCompilationSongs(const QString &album, const QueryOptions &opt = QueryOptions()) override;
|
||||
SongList GetCompilationSongs(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
|
||||
AlbumList GetAllAlbums(const QueryOptions &opt = QueryOptions()) override;
|
||||
AlbumList GetCompilationAlbums(const QueryOptions &opt = QueryOptions()) override;
|
||||
AlbumList GetAlbumsByArtist(const QString &artist, const QueryOptions &opt = QueryOptions()) override;
|
||||
AlbumList GetAllAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
AlbumList GetCompilationAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
AlbumList GetAlbumsByArtist(const QString &artist, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
||||
|
||||
void UpdateManualAlbumArtAsync(const QString &effective_albumartist, const QString &album, const QUrl &cover_url, const bool clear_art_automatic = false) override;
|
||||
void UpdateAutomaticAlbumArtAsync(const QString &effective_albumartist, const QString &album, const QUrl &cover_url, const bool clear_art_manual = false) override;
|
||||
@@ -188,14 +193,14 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
Song GetSongByUrl(const QUrl &url, qint64 beginning = 0) override;
|
||||
|
||||
void AddDirectory(const QString &path) override;
|
||||
void RemoveDirectory(const Directory &dir) override;
|
||||
void RemoveDirectory(const CollectionDirectory &dir) override;
|
||||
|
||||
bool ExecCollectionQuery(CollectionQuery *query, SongList &songs);
|
||||
bool ExecCollectionQuery(CollectionQuery *query, SongMap &songs);
|
||||
|
||||
void IncrementPlayCountAsync(const int id);
|
||||
void IncrementSkipCountAsync(const int id, const float progress);
|
||||
void ResetStatisticsAsync(const int id);
|
||||
void ResetStatisticsAsync(const int id, const bool save_tags = false);
|
||||
|
||||
void DeleteAllAsync();
|
||||
|
||||
@@ -207,8 +212,6 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
SongList SmartPlaylistsGetAllSongs();
|
||||
SongList SmartPlaylistsFindSongs(const SmartPlaylistSearch &search);
|
||||
|
||||
Song::Source Source() const;
|
||||
|
||||
void AddOrUpdateSongsAsync(const SongList &songs);
|
||||
void UpdateSongsBySongIDAsync(const SongMap &new_songs);
|
||||
|
||||
@@ -226,20 +229,20 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
void UpdateMTimesOnly(const SongList &songs);
|
||||
void DeleteSongs(const SongList &songs);
|
||||
void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true);
|
||||
void AddOrUpdateSubdirs(const SubdirectoryList &subdirs);
|
||||
void AddOrUpdateSubdirs(const CollectionSubdirectoryList &subdirs);
|
||||
void CompilationsNeedUpdating();
|
||||
void UpdateManualAlbumArt(const QString &effective_albumartist, const QString &album, const QUrl &cover_url, const bool clear_art_automatic = false);
|
||||
void UpdateAutomaticAlbumArt(const QString &effective_albumartist, const QString &album, const QUrl &cover_url, const bool clear_art_manual = false);
|
||||
void ForceCompilation(const QString &album, const QList<QString> &artists, const bool on);
|
||||
void IncrementPlayCount(const int id);
|
||||
void IncrementSkipCount(const int id, const float progress);
|
||||
void ResetStatistics(const int id);
|
||||
void ResetStatistics(const int id, const bool save_tags);
|
||||
void DeleteAll();
|
||||
void SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id);
|
||||
|
||||
SongList GetSongsBy(const QString &artist, const QString &album, const QString &title);
|
||||
void UpdateLastPlayed(const QString &artist, const QString &album, const QString &title, const qint64 lastplayed);
|
||||
void UpdatePlayCount(const QString &artist, const QString &title, const int playcount);
|
||||
void UpdatePlayCount(const QString &artist, const QString &title, const int playcount, const bool save_tags = false);
|
||||
|
||||
void UpdateSongRating(const int id, const float rating, const bool save_tags = false);
|
||||
void UpdateSongsRating(const QList<int> &id_list, const float rating, const bool save_tags = false);
|
||||
@@ -248,12 +251,12 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
void ExpireSongs(const int directory_id, const int expire_unavailable_songs_days);
|
||||
|
||||
signals:
|
||||
void DirectoryDiscovered(Directory, SubdirectoryList);
|
||||
void DirectoryDeleted(Directory);
|
||||
void DirectoryDiscovered(CollectionDirectory, CollectionSubdirectoryList);
|
||||
void DirectoryDeleted(CollectionDirectory);
|
||||
|
||||
void SongsDiscovered(SongList);
|
||||
void SongsDeleted(SongList);
|
||||
void SongsStatisticsChanged(SongList);
|
||||
void SongsStatisticsChanged(SongList, bool = false);
|
||||
|
||||
void DatabaseReset();
|
||||
|
||||
@@ -278,9 +281,9 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
};
|
||||
|
||||
bool UpdateCompilations(const QSqlDatabase &db, SongList &deleted_songs, SongList &added_songs, const QUrl &url, const bool compilation_detected);
|
||||
AlbumList GetAlbums(const QString &artist, const QString &album_artist, const bool compilation_required = false, const QueryOptions &opt = QueryOptions());
|
||||
AlbumList GetAlbums(const QString &artist, const bool compilation_required, const QueryOptions &opt = QueryOptions());
|
||||
SubdirectoryList SubdirsInDirectory(const int id, QSqlDatabase &db);
|
||||
AlbumList GetAlbums(const QString &artist, const QString &album_artist, const bool compilation_required = false, const CollectionFilterOptions &opt = CollectionFilterOptions());
|
||||
AlbumList GetAlbums(const QString &artist, const bool compilation_required, const CollectionFilterOptions &opt = CollectionFilterOptions());
|
||||
CollectionSubdirectoryList SubdirsInDirectory(const int id, QSqlDatabase &db);
|
||||
|
||||
Song GetSongById(const int id, QSqlDatabase &db);
|
||||
SongList GetSongsById(const QStringList &ids, QSqlDatabase &db);
|
||||
|
||||
57
src/collection/collectiondirectory.h
Normal file
57
src/collection/collectiondirectory.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLLECTIONDIRECTORY_H
|
||||
#define COLLECTIONDIRECTORY_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
struct CollectionDirectory {
|
||||
CollectionDirectory() : id(-1) {}
|
||||
|
||||
bool operator==(const CollectionDirectory &other) const {
|
||||
return path == other.path && id == other.id;
|
||||
}
|
||||
|
||||
QString path;
|
||||
int id;
|
||||
};
|
||||
Q_DECLARE_METATYPE(CollectionDirectory)
|
||||
|
||||
using CollectionDirectoryList = QList<CollectionDirectory>;
|
||||
Q_DECLARE_METATYPE(CollectionDirectoryList)
|
||||
|
||||
struct CollectionSubdirectory {
|
||||
CollectionSubdirectory() : directory_id(-1), mtime(0) {}
|
||||
|
||||
int directory_id;
|
||||
QString path;
|
||||
qint64 mtime;
|
||||
};
|
||||
Q_DECLARE_METATYPE(CollectionSubdirectory)
|
||||
|
||||
using CollectionSubdirectoryList = QList<CollectionSubdirectory>;
|
||||
Q_DECLARE_METATYPE(CollectionSubdirectoryList)
|
||||
|
||||
#endif // COLLECTIONDIRECTORY_H
|
||||
@@ -29,8 +29,8 @@
|
||||
#include "core/filesystemmusicstorage.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/utilities.h"
|
||||
#include "directory.h"
|
||||
#include "utilities/diskutils.h"
|
||||
#include "collectiondirectory.h"
|
||||
#include "collectionbackend.h"
|
||||
#include "collectiondirectorymodel.h"
|
||||
|
||||
@@ -46,17 +46,17 @@ CollectionDirectoryModel::CollectionDirectoryModel(CollectionBackend *backend, Q
|
||||
|
||||
CollectionDirectoryModel::~CollectionDirectoryModel() = default;
|
||||
|
||||
void CollectionDirectoryModel::DirectoryDiscovered(const Directory &dir) {
|
||||
void CollectionDirectoryModel::DirectoryDiscovered(const CollectionDirectory &dir) {
|
||||
|
||||
QStandardItem *item = new QStandardItem(dir.path);
|
||||
item->setData(dir.id, kIdRole);
|
||||
item->setIcon(dir_icon_);
|
||||
storage_ << std::make_shared<FilesystemMusicStorage>(dir.path, dir.id);
|
||||
storage_ << std::make_shared<FilesystemMusicStorage>(backend_->source(), dir.path, dir.id);
|
||||
appendRow(item);
|
||||
|
||||
}
|
||||
|
||||
void CollectionDirectoryModel::DirectoryDeleted(const Directory &dir) {
|
||||
void CollectionDirectoryModel::DirectoryDeleted(const CollectionDirectory &dir) {
|
||||
|
||||
for (int i = 0; i < rowCount(); ++i) {
|
||||
if (item(i, 0)->data(kIdRole).toInt() == dir.id) {
|
||||
@@ -80,7 +80,7 @@ void CollectionDirectoryModel::RemoveDirectory(const QModelIndex &idx) {
|
||||
|
||||
if (!backend_ || !idx.isValid()) return;
|
||||
|
||||
Directory dir;
|
||||
CollectionDirectory dir;
|
||||
dir.path = idx.data().toString();
|
||||
dir.id = idx.data(kIdRole).toInt();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
class QModelIndex;
|
||||
|
||||
struct Directory;
|
||||
struct CollectionDirectory;
|
||||
class CollectionBackend;
|
||||
class MusicStorage;
|
||||
|
||||
@@ -53,8 +53,8 @@ class CollectionDirectoryModel : public QStandardItemModel {
|
||||
|
||||
private slots:
|
||||
// To be called by the backend
|
||||
void DirectoryDiscovered(const Directory &directories);
|
||||
void DirectoryDeleted(const Directory &directories);
|
||||
void DirectoryDiscovered(const CollectionDirectory &directories);
|
||||
void DirectoryDeleted(const CollectionDirectory &directories);
|
||||
|
||||
private:
|
||||
static const int kIdRole = Qt::UserRole + 1;
|
||||
|
||||
42
src/collection/collectionfilteroptions.cpp
Normal file
42
src/collection/collectionfilteroptions.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
#include "collectionfilteroptions.h"
|
||||
|
||||
CollectionFilterOptions::CollectionFilterOptions() : filter_mode_(FilterMode::All), max_age_(-1) {}
|
||||
|
||||
bool CollectionFilterOptions::Matches(const Song &song) const {
|
||||
|
||||
if (max_age_ != -1) {
|
||||
const qint64 cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - max_age_;
|
||||
if (song.ctime() <= cutoff) return false;
|
||||
}
|
||||
|
||||
if (!filter_text_.isNull()) {
|
||||
return song.albumartist().contains(filter_text_, Qt::CaseInsensitive) || song.artist().contains(filter_text_, Qt::CaseInsensitive) || song.album().contains(filter_text_, Qt::CaseInsensitive) || song.title().contains(filter_text_, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
65
src/collection/collectionfilteroptions.h
Normal file
65
src/collection/collectionfilteroptions.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLLECTIONFILTEROPTIONS_H
|
||||
#define COLLECTIONFILTEROPTIONS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class CollectionFilterOptions {
|
||||
public:
|
||||
|
||||
explicit CollectionFilterOptions();
|
||||
|
||||
// Filter mode:
|
||||
// - use the all songs table
|
||||
// - use the duplicated songs view; by duplicated we mean those songs for which the (artist, album, title) tuple is found more than once in the songs table
|
||||
// - use the untagged songs view; by untagged we mean those for which at least one of the (artist, album, title) tags is empty
|
||||
// Please note that additional filtering based on FTS table (the filter attribute) won't work in Duplicates and Untagged modes.
|
||||
enum class FilterMode {
|
||||
All,
|
||||
Duplicates,
|
||||
Untagged
|
||||
};
|
||||
|
||||
FilterMode filter_mode() const { return filter_mode_; }
|
||||
int max_age() const { return max_age_; }
|
||||
QString filter_text() const { return filter_text_; }
|
||||
|
||||
void set_filter_mode(const FilterMode filter_mode) {
|
||||
filter_mode_ = filter_mode;
|
||||
filter_text_.clear();
|
||||
}
|
||||
void set_max_age(const int max_age) { max_age_ = max_age; }
|
||||
void set_filter_text(const QString &filter_text) {
|
||||
filter_mode_ = FilterMode::All;
|
||||
filter_text_ = filter_text;
|
||||
}
|
||||
|
||||
bool Matches(const Song &song) const;
|
||||
|
||||
private:
|
||||
FilterMode filter_mode_;
|
||||
int max_age_;
|
||||
QString filter_text_;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONFILTEROPTIONS_H
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "core/iconloader.h"
|
||||
#include "core/song.h"
|
||||
#include "core/logging.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionmodel.h"
|
||||
#include "collectionquery.h"
|
||||
#include "savedgroupingmanager.h"
|
||||
@@ -67,7 +68,7 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
|
||||
group_by_group_(nullptr),
|
||||
filter_delay_(new QTimer(this)),
|
||||
filter_applies_to_model_(true),
|
||||
delay_behaviour_(DelayedOnLargeLibraries) {
|
||||
delay_behaviour_(DelayBehaviour::DelayedOnLargeLibraries) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
@@ -177,12 +178,13 @@ void CollectionFilterWidget::Init(CollectionModel *model) {
|
||||
if (s.contains(group_by_version())) version = s.value(group_by_version(), 0).toInt();
|
||||
if (version == 1) {
|
||||
model_->SetGroupBy(CollectionModel::Grouping(
|
||||
CollectionModel::GroupBy(s.value(group_by_key(1), static_cast<int>(CollectionModel::GroupBy_AlbumArtist)).toInt()),
|
||||
CollectionModel::GroupBy(s.value(group_by_key(2), static_cast<int>(CollectionModel::GroupBy_AlbumDisc)).toInt()),
|
||||
CollectionModel::GroupBy(s.value(group_by_key(3), static_cast<int>(CollectionModel::GroupBy_None)).toInt())), s.value(separate_albums_by_grouping_key(), false).toBool());
|
||||
static_cast<CollectionModel::GroupBy>(s.value(group_by_key(1), static_cast<int>(CollectionModel::GroupBy::AlbumArtist)).toInt()),
|
||||
static_cast<CollectionModel::GroupBy>(s.value(group_by_key(2), static_cast<int>(CollectionModel::GroupBy::AlbumDisc)).toInt()),
|
||||
static_cast<CollectionModel::GroupBy>(s.value(group_by_key(3), static_cast<int>(CollectionModel::GroupBy::None)).toInt())),
|
||||
s.value(separate_albums_by_grouping_key(), false).toBool());
|
||||
}
|
||||
else {
|
||||
model_->SetGroupBy(CollectionModel::Grouping(CollectionModel::GroupBy_AlbumArtist, CollectionModel::GroupBy_AlbumDisc, CollectionModel::GroupBy_None), false);
|
||||
model_->SetGroupBy(CollectionModel::Grouping(CollectionModel::GroupBy::AlbumArtist, CollectionModel::GroupBy::AlbumDisc, CollectionModel::GroupBy::None), false);
|
||||
}
|
||||
s.endGroup();
|
||||
}
|
||||
@@ -271,24 +273,24 @@ QActionGroup *CollectionFilterWidget::CreateGroupByActions(const QString &saved_
|
||||
|
||||
QActionGroup *ret = new QActionGroup(parent);
|
||||
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_AlbumArtist, CollectionModel::GroupBy_Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_AlbumArtist, CollectionModel::GroupBy_AlbumDisc)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Year - Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_AlbumArtist, CollectionModel::GroupBy_YearAlbum)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Year - Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_AlbumArtist, CollectionModel::GroupBy_YearAlbumDisc)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::AlbumArtist, CollectionModel::GroupBy::Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::AlbumArtist, CollectionModel::GroupBy::AlbumDisc)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Year - Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::AlbumArtist, CollectionModel::GroupBy::YearAlbum)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album artist/Year - Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::AlbumArtist, CollectionModel::GroupBy::YearAlbumDisc)));
|
||||
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Artist, CollectionModel::GroupBy_Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Artist, CollectionModel::GroupBy_AlbumDisc)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Year - Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Artist, CollectionModel::GroupBy_YearAlbum)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Year - Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Artist, CollectionModel::GroupBy_YearAlbumDisc)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Artist, CollectionModel::GroupBy::Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Artist, CollectionModel::GroupBy::AlbumDisc)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Year - Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Artist, CollectionModel::GroupBy::YearAlbum)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist/Year - Album - Disc"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Artist, CollectionModel::GroupBy::YearAlbumDisc)));
|
||||
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Genre/Album artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Genre, CollectionModel::GroupBy_AlbumArtist, CollectionModel::GroupBy_Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Genre/Artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Genre, CollectionModel::GroupBy_Artist, CollectionModel::GroupBy_Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Genre/Album artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Genre, CollectionModel::GroupBy::AlbumArtist, CollectionModel::GroupBy::Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Genre/Artist/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Genre, CollectionModel::GroupBy::Artist, CollectionModel::GroupBy::Album)));
|
||||
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album Artist"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_AlbumArtist)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Artist)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album Artist"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::AlbumArtist)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Artist"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Artist)));
|
||||
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Genre/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy_Genre, CollectionModel::GroupBy_Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Album)));
|
||||
ret->addAction(CreateGroupByAction(tr("Group by Genre/Album"), parent, CollectionModel::Grouping(CollectionModel::GroupBy::Genre, CollectionModel::GroupBy::Album)));
|
||||
|
||||
QAction *sep1 = new QAction(parent);
|
||||
sep1->setSeparator(true);
|
||||
@@ -333,7 +335,7 @@ QAction *CollectionFilterWidget::CreateGroupByAction(const QString &text, QObjec
|
||||
QAction *ret = new QAction(text, parent);
|
||||
ret->setCheckable(true);
|
||||
|
||||
if (grouping.first != CollectionModel::GroupBy_None) {
|
||||
if (grouping.first != CollectionModel::GroupBy::None) {
|
||||
ret->setProperty("group_by", QVariant::fromValue(grouping));
|
||||
}
|
||||
|
||||
@@ -455,12 +457,12 @@ void CollectionFilterWidget::SetFilterHint(const QString &hint) {
|
||||
ui_->search_field->setPlaceholderText(hint);
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::SetQueryMode(QueryOptions::QueryMode query_mode) {
|
||||
void CollectionFilterWidget::SetFilterMode(CollectionFilterOptions::FilterMode filter_mode) {
|
||||
|
||||
ui_->search_field->clear();
|
||||
ui_->search_field->setEnabled(query_mode == QueryOptions::QueryMode_All);
|
||||
ui_->search_field->setEnabled(filter_mode == CollectionFilterOptions::FilterMode::All);
|
||||
|
||||
model_->SetFilterQueryMode(query_mode);
|
||||
model_->SetFilterMode(filter_mode);
|
||||
|
||||
}
|
||||
|
||||
@@ -508,7 +510,7 @@ void CollectionFilterWidget::FilterTextChanged(const QString &text) {
|
||||
// Searching with one or two characters can be very expensive on the database even with FTS,
|
||||
// so if there are a large number of songs in the database introduce a small delay before actually filtering the model,
|
||||
// so if the user is typing the first few characters of something it will be quicker.
|
||||
const bool delay = (delay_behaviour_ == AlwaysDelayed) || (delay_behaviour_ == DelayedOnLargeLibraries && !text.isEmpty() && text.length() < 3 && model_->total_song_count() >= 100000);
|
||||
const bool delay = (delay_behaviour_ == DelayBehaviour::AlwaysDelayed) || (delay_behaviour_ == DelayBehaviour::DelayedOnLargeLibraries && !text.isEmpty() && text.length() < 3 && model_->total_song_count() >= 100000);
|
||||
|
||||
if (delay) {
|
||||
filter_delay_->start();
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include "collectionquery.h"
|
||||
#include "collectionqueryoptions.h"
|
||||
#include "collectionmodel.h"
|
||||
|
||||
class QTimer;
|
||||
@@ -53,7 +54,7 @@ class CollectionFilterWidget : public QWidget {
|
||||
|
||||
static const int kFilterDelay = 500; // msec
|
||||
|
||||
enum DelayBehaviour {
|
||||
enum class DelayBehaviour {
|
||||
AlwaysInstant,
|
||||
DelayedOnLargeLibraries,
|
||||
AlwaysDelayed,
|
||||
@@ -88,7 +89,7 @@ class CollectionFilterWidget : public QWidget {
|
||||
|
||||
public slots:
|
||||
void UpdateGroupByActions();
|
||||
void SetQueryMode(QueryOptions::QueryMode query_mode);
|
||||
void SetFilterMode(CollectionFilterOptions::FilterMode filter_mode);
|
||||
void FocusOnFilter(QKeyEvent *e);
|
||||
|
||||
signals:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,7 +49,9 @@
|
||||
#include "core/song.h"
|
||||
#include "core/sqlrow.h"
|
||||
#include "covermanager/albumcoverloader.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionquery.h"
|
||||
#include "collectionqueryoptions.h"
|
||||
#include "collectionitem.h"
|
||||
#include "covermanager/albumcoverloaderoptions.h"
|
||||
|
||||
@@ -81,34 +83,34 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
};
|
||||
|
||||
// These values get saved in QSettings - don't change them
|
||||
enum GroupBy {
|
||||
GroupBy_None = 0,
|
||||
GroupBy_AlbumArtist = 1,
|
||||
GroupBy_Artist = 2,
|
||||
GroupBy_Album = 3,
|
||||
GroupBy_AlbumDisc = 4,
|
||||
GroupBy_YearAlbum = 5,
|
||||
GroupBy_YearAlbumDisc = 6,
|
||||
GroupBy_OriginalYearAlbum = 7,
|
||||
GroupBy_OriginalYearAlbumDisc = 8,
|
||||
GroupBy_Disc = 9,
|
||||
GroupBy_Year = 10,
|
||||
GroupBy_OriginalYear = 11,
|
||||
GroupBy_Genre = 12,
|
||||
GroupBy_Composer = 13,
|
||||
GroupBy_Performer = 14,
|
||||
GroupBy_Grouping = 15,
|
||||
GroupBy_FileType = 16,
|
||||
GroupBy_Format = 17,
|
||||
GroupBy_Samplerate = 18,
|
||||
GroupBy_Bitdepth = 19,
|
||||
GroupBy_Bitrate = 20,
|
||||
enum class GroupBy {
|
||||
None = 0,
|
||||
AlbumArtist = 1,
|
||||
Artist = 2,
|
||||
Album = 3,
|
||||
AlbumDisc = 4,
|
||||
YearAlbum = 5,
|
||||
YearAlbumDisc = 6,
|
||||
OriginalYearAlbum = 7,
|
||||
OriginalYearAlbumDisc = 8,
|
||||
Disc = 9,
|
||||
Year = 10,
|
||||
OriginalYear = 11,
|
||||
Genre = 12,
|
||||
Composer = 13,
|
||||
Performer = 14,
|
||||
Grouping = 15,
|
||||
FileType = 16,
|
||||
Format = 17,
|
||||
Samplerate = 18,
|
||||
Bitdepth = 19,
|
||||
Bitrate = 20,
|
||||
GroupByCount = 21,
|
||||
};
|
||||
Q_ENUM(GroupBy)
|
||||
|
||||
struct Grouping {
|
||||
explicit Grouping(GroupBy f = GroupBy_None, GroupBy s = GroupBy_None, GroupBy t = GroupBy_None)
|
||||
explicit Grouping(GroupBy f = GroupBy::None, GroupBy s = GroupBy::None, GroupBy t = GroupBy::None)
|
||||
: first(f), second(s), third(t) {}
|
||||
|
||||
GroupBy first;
|
||||
@@ -179,9 +181,9 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
quint64 icon_cache_disk_size() { return sIconCache->cacheSize(); }
|
||||
|
||||
static bool IsArtistGroupBy(const GroupBy group_by) {
|
||||
return group_by == CollectionModel::GroupBy_Artist || group_by == CollectionModel::GroupBy_AlbumArtist;
|
||||
return group_by == CollectionModel::GroupBy::Artist || group_by == CollectionModel::GroupBy::AlbumArtist;
|
||||
}
|
||||
static bool IsAlbumGroupBy(const GroupBy group_by) { return group_by == GroupBy_Album || group_by == GroupBy_YearAlbum || group_by == GroupBy_AlbumDisc || group_by == GroupBy_YearAlbumDisc || group_by == GroupBy_OriginalYearAlbum || group_by == GroupBy_OriginalYearAlbumDisc; }
|
||||
static bool IsAlbumGroupBy(const GroupBy group_by) { return group_by == GroupBy::Album || group_by == GroupBy::YearAlbum || group_by == GroupBy::AlbumDisc || group_by == GroupBy::YearAlbumDisc || group_by == GroupBy::OriginalYearAlbum || group_by == GroupBy::OriginalYearAlbumDisc; }
|
||||
|
||||
void set_use_lazy_loading(const bool value) { use_lazy_loading_ = value; }
|
||||
|
||||
@@ -203,9 +205,9 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
void GroupingChanged(CollectionModel::Grouping g, bool separate_albums_by_grouping);
|
||||
|
||||
public slots:
|
||||
void SetFilterAge(const int age);
|
||||
void SetFilterText(const QString &text);
|
||||
void SetFilterQueryMode(QueryOptions::QueryMode query_mode);
|
||||
void SetFilterMode(CollectionFilterOptions::FilterMode filter_mode);
|
||||
void SetFilterAge(const int filter_age);
|
||||
void SetFilterText(const QString &filter_text);
|
||||
|
||||
void Init(const bool async = true);
|
||||
void Reset();
|
||||
@@ -232,20 +234,21 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result);
|
||||
|
||||
private:
|
||||
// Provides some optimisations for loading the list of items in the root.
|
||||
// Provides some optimizations for loading the list of items in the root.
|
||||
// This gets called a lot when filtering the playlist, so it's nice to be able to do it in a background thread.
|
||||
QueryResult RunQuery(CollectionItem *parent);
|
||||
CollectionQueryOptions PrepareQuery(CollectionItem *parent);
|
||||
QueryResult RunQuery(const CollectionFilterOptions &filter_options = CollectionFilterOptions(), const CollectionQueryOptions &query_options = CollectionQueryOptions());
|
||||
void PostQuery(CollectionItem *parent, const QueryResult &result, const bool signal);
|
||||
|
||||
bool HasCompilations(const QSqlDatabase &db, const CollectionQuery &query);
|
||||
bool HasCompilations(const QSqlDatabase &db, const CollectionFilterOptions &filter_options, const CollectionQueryOptions &query_options);
|
||||
|
||||
void BeginReset();
|
||||
|
||||
// Functions for working with queries and creating items.
|
||||
// When the model is reset or when a node is lazy-loaded the Collection constructs a database query to populate the items.
|
||||
// Filters are added for each parent item, restricting the songs returned to a particular album or artist for example.
|
||||
static void InitQuery(const GroupBy group_by, const bool separate_albums_by_grouping, CollectionQuery *q);
|
||||
static void FilterQuery(const GroupBy group_by, const bool separate_albums_by_grouping, CollectionItem *item, CollectionQuery *q);
|
||||
static void SetQueryColumnSpec(const GroupBy group_by, const bool separate_albums_by_grouping, CollectionQueryOptions *query_options);
|
||||
static void AddQueryWhere(const GroupBy group_by, const bool separate_albums_by_grouping, CollectionItem *item, CollectionQueryOptions *query_options);
|
||||
|
||||
// Items can be created either from a query that's been run to populate a node, or by a spontaneous SongsDiscovered emission from the backend.
|
||||
CollectionItem *ItemFromQuery(const GroupBy group_by, const bool separate_albums_by_grouping, const bool signal, const bool create_divider, CollectionItem *parent, const SqlRow &row, const int container_level);
|
||||
@@ -279,7 +282,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
int total_artist_count_;
|
||||
int total_album_count_;
|
||||
|
||||
QueryOptions query_options_;
|
||||
CollectionFilterOptions filter_options_;
|
||||
Grouping group_by_;
|
||||
bool separate_albums_by_grouping_;
|
||||
|
||||
@@ -308,7 +311,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
AlbumCoverLoaderOptions cover_loader_options_;
|
||||
|
||||
typedef QPair<CollectionItem*, QString> ItemAndCacheKey;
|
||||
using ItemAndCacheKey = QPair<CollectionItem*, QString>;
|
||||
QMap<quint64, ItemAndCacheKey> pending_art_;
|
||||
QSet<QString> pending_cache_keys_;
|
||||
};
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
class SqlRow;
|
||||
|
||||
CollectionPlaylistItem::CollectionPlaylistItem() : PlaylistItem(Song::Source_Collection) {
|
||||
song_.set_source(Song::Source_Collection);
|
||||
CollectionPlaylistItem::CollectionPlaylistItem() : PlaylistItem(Song::Source::Collection) {
|
||||
song_.set_source(Song::Source::Collection);
|
||||
}
|
||||
|
||||
CollectionPlaylistItem::CollectionPlaylistItem(const Song &song) : PlaylistItem(Song::Source_Collection), song_(song) {
|
||||
song_.set_source(Song::Source_Collection);
|
||||
CollectionPlaylistItem::CollectionPlaylistItem(const Song &song) : PlaylistItem(Song::Source::Collection), song_(song) {
|
||||
song_.set_source(Song::Source::Collection);
|
||||
}
|
||||
|
||||
QUrl CollectionPlaylistItem::Url() const { return song_.url(); }
|
||||
@@ -50,7 +50,7 @@ bool CollectionPlaylistItem::InitFromQuery(const SqlRow &query) {
|
||||
|
||||
// Rows from the songs tables come first
|
||||
song_.InitFromQuery(query, true);
|
||||
song_.set_source(Song::Source_Collection);
|
||||
song_.set_source(Song::Source::Collection);
|
||||
return song_.is_valid();
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class CollectionPlaylistItem : public PlaylistItem {
|
||||
|
||||
protected:
|
||||
QVariant DatabaseValue(DatabaseColumn column) const override;
|
||||
Song DatabaseSongMetadata() const override { return Song(Song::Source_Collection); }
|
||||
Song DatabaseSongMetadata() const override { return Song(Song::Source::Collection); }
|
||||
|
||||
protected:
|
||||
Song song_;
|
||||
|
||||
@@ -31,16 +31,16 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/sqlquery.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include "collectionquery.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionqueryoptions.h"
|
||||
|
||||
QueryOptions::QueryOptions() : max_age_(-1), query_mode_(QueryMode_All) {}
|
||||
|
||||
CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_table, const QString &fts_table, const QueryOptions &options)
|
||||
CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_table, const QString &fts_table, const CollectionFilterOptions &filter_options)
|
||||
: QSqlQuery(db),
|
||||
songs_table_(songs_table),
|
||||
fts_table_(fts_table),
|
||||
@@ -49,7 +49,7 @@ CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_ta
|
||||
duplicates_only_(false),
|
||||
limit_(-1) {
|
||||
|
||||
if (!options.filter().isEmpty()) {
|
||||
if (!filter_options.filter_text().isEmpty()) {
|
||||
// We need to munge the filter text a little bit to get it to work as expected with sqlite's FTS5:
|
||||
// 1) Append * to all tokens.
|
||||
// 2) Prefix "fts" to column names.
|
||||
@@ -57,9 +57,9 @@ CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_ta
|
||||
|
||||
// Split on whitespace
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList tokens(options.filter().split(QRegularExpression("\\s+"), Qt::SkipEmptyParts));
|
||||
QStringList tokens(filter_options.filter_text().split(QRegularExpression("\\s+"), Qt::SkipEmptyParts));
|
||||
#else
|
||||
QStringList tokens(options.filter().split(QRegularExpression("\\s+"), QString::SkipEmptyParts));
|
||||
QStringList tokens(filter_options.filter_text().split(QRegularExpression("\\s+"), QString::SkipEmptyParts));
|
||||
#endif
|
||||
QString query;
|
||||
for (QString token : tokens) {
|
||||
@@ -100,49 +100,40 @@ CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_ta
|
||||
}
|
||||
}
|
||||
|
||||
if (options.max_age() != -1) {
|
||||
qint64 cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - options.max_age();
|
||||
if (filter_options.max_age() != -1) {
|
||||
qint64 cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - filter_options.max_age();
|
||||
|
||||
where_clauses_ << "ctime > ?";
|
||||
bound_values_ << cutoff;
|
||||
}
|
||||
|
||||
// TODO: Currently you cannot use any QueryMode other than All and FTS at the same time.
|
||||
// TODO: Currently you cannot use any FilterMode other than All and FTS at the same time.
|
||||
// Joining songs, duplicated_songs and songs_fts all together takes a huge amount of time.
|
||||
// The query takes about 20 seconds on my machine then. Why?
|
||||
// Untagged mode could work with additional filtering but I'm disabling it just to be consistent
|
||||
// this way filtering is available only in the All mode.
|
||||
// Remember though that when you fix the Duplicates + FTS cooperation, enable the filtering in both Duplicates and Untagged modes.
|
||||
duplicates_only_ = options.query_mode() == QueryOptions::QueryMode_Duplicates;
|
||||
duplicates_only_ = filter_options.filter_mode() == CollectionFilterOptions::FilterMode::Duplicates;
|
||||
|
||||
if (options.query_mode() == QueryOptions::QueryMode_Untagged) {
|
||||
if (filter_options.filter_mode() == CollectionFilterOptions::FilterMode::Untagged) {
|
||||
where_clauses_ << "(artist = '' OR album = '' OR title ='')";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString CollectionQuery::GetInnerQuery() const {
|
||||
return duplicates_only_
|
||||
? QString(" INNER JOIN (select * from duplicated_songs) dsongs "
|
||||
"ON (%songs_table.artist = dsongs.dup_artist "
|
||||
"AND %songs_table.album = dsongs.dup_album "
|
||||
"AND %songs_table.title = dsongs.dup_title) ")
|
||||
: QString();
|
||||
}
|
||||
|
||||
void CollectionQuery::AddWhere(const QString &column, const QVariant &value, const QString &op) {
|
||||
|
||||
// Ignore 'literal' for IN
|
||||
if (op.compare("IN", Qt::CaseInsensitive) == 0) {
|
||||
QStringList values = value.toStringList();
|
||||
QStringList final;
|
||||
final.reserve(values.count());
|
||||
QStringList final_values;
|
||||
final_values.reserve(values.count());
|
||||
for (const QString &single_value : values) {
|
||||
final.append("?");
|
||||
final_values.append("?");
|
||||
bound_values_ << single_value;
|
||||
}
|
||||
|
||||
where_clauses_ << QString("%1 IN (" + final.join(",") + ")").arg(column);
|
||||
where_clauses_ << QString("%1 IN (" + final_values.join(",") + ")").arg(column);
|
||||
}
|
||||
else {
|
||||
// Do integers inline - sqlite seems to get confused when you pass integers to bound parameters
|
||||
@@ -187,6 +178,15 @@ void CollectionQuery::AddCompilationRequirement(const bool compilation) {
|
||||
|
||||
}
|
||||
|
||||
QString CollectionQuery::GetInnerQuery() const {
|
||||
return duplicates_only_
|
||||
? QString(" INNER JOIN (select * from duplicated_songs) dsongs "
|
||||
"ON (%songs_table.artist = dsongs.dup_artist "
|
||||
"AND %songs_table.album = dsongs.dup_album "
|
||||
"AND %songs_table.title = dsongs.dup_title) ")
|
||||
: QString();
|
||||
}
|
||||
|
||||
bool CollectionQuery::Exec() {
|
||||
|
||||
QString sql;
|
||||
@@ -213,32 +213,17 @@ bool CollectionQuery::Exec() {
|
||||
sql.replace("%fts_table_noprefix", fts_table_.section('.', -1, -1));
|
||||
sql.replace("%fts_table", fts_table_);
|
||||
|
||||
prepare(sql);
|
||||
QSqlQuery::prepare(sql);
|
||||
|
||||
// Bind values
|
||||
for (const QVariant &value : bound_values_) {
|
||||
addBindValue(value);
|
||||
QSqlQuery::addBindValue(value);
|
||||
}
|
||||
|
||||
return exec();
|
||||
return QSqlQuery::exec();
|
||||
|
||||
}
|
||||
|
||||
bool CollectionQuery::Next() { return next(); }
|
||||
bool CollectionQuery::Next() { return QSqlQuery::next(); }
|
||||
|
||||
QVariant CollectionQuery::Value(const int column) const { return value(column); }
|
||||
|
||||
bool QueryOptions::Matches(const Song &song) const {
|
||||
|
||||
if (max_age_ != -1) {
|
||||
const qint64 cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - max_age_;
|
||||
if (song.ctime() <= cutoff) return false;
|
||||
}
|
||||
|
||||
if (!filter_.isNull()) {
|
||||
return song.artist().contains(filter_, Qt::CaseInsensitive) || song.album().contains(filter_, Qt::CaseInsensitive) || song.title().contains(filter_, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
QVariant CollectionQuery::Value(const int column) const { return QSqlQuery::value(column); }
|
||||
|
||||
@@ -28,75 +28,23 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
|
||||
class Song;
|
||||
|
||||
// This structure let's you customize behaviour of any CollectionQuery.
|
||||
struct QueryOptions {
|
||||
// Modes of CollectionQuery:
|
||||
// - use the all songs table
|
||||
// - use the duplicated songs view; by duplicated we mean those songs for which the (artist, album, title) tuple is found more than once in the songs table
|
||||
// - use the untagged songs view; by untagged we mean those for which at least one of the (artist, album, title) tags is empty
|
||||
// Please note that additional filtering based on FTS table (the filter attribute) won't work in Duplicates and Untagged modes.
|
||||
enum QueryMode {
|
||||
QueryMode_All,
|
||||
QueryMode_Duplicates,
|
||||
QueryMode_Untagged
|
||||
};
|
||||
|
||||
QueryOptions();
|
||||
|
||||
bool Matches(const Song &song) const;
|
||||
|
||||
QString filter() const { return filter_; }
|
||||
void set_filter(const QString &filter) {
|
||||
filter_ = filter;
|
||||
query_mode_ = QueryMode_All;
|
||||
}
|
||||
|
||||
int max_age() const { return max_age_; }
|
||||
void set_max_age(int max_age) { max_age_ = max_age; }
|
||||
|
||||
QueryMode query_mode() const { return query_mode_; }
|
||||
void set_query_mode(QueryMode query_mode) {
|
||||
query_mode_ = query_mode;
|
||||
filter_ = QString();
|
||||
}
|
||||
|
||||
private:
|
||||
QString filter_;
|
||||
int max_age_;
|
||||
QueryMode query_mode_;
|
||||
};
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionqueryoptions.h"
|
||||
|
||||
class CollectionQuery : public QSqlQuery {
|
||||
public:
|
||||
explicit CollectionQuery(const QSqlDatabase &db, const QString &songs_table, const QString &fts_table, const QueryOptions &options = QueryOptions());
|
||||
explicit CollectionQuery(const QSqlDatabase &db, const QString &songs_table, const QString &fts_table, const CollectionFilterOptions &filter_options = CollectionFilterOptions());
|
||||
|
||||
// Sets contents of SELECT clause on the query (list of columns to get).
|
||||
void SetColumnSpec(const QString &spec) { column_spec_ = spec; }
|
||||
|
||||
// Sets an ORDER BY clause on the query.
|
||||
void SetOrderBy(const QString &order_by) { order_by_ = order_by; }
|
||||
|
||||
// Adds a fragment of WHERE clause. When executed, this Query will connect all the fragments with AND operator.
|
||||
// Please note that IN operator expects a QStringList as value.
|
||||
void AddWhere(const QString &column, const QVariant &value, const QString &op = "=");
|
||||
void AddWhereArtist(const QVariant &value);
|
||||
|
||||
void SetWhereClauses(const QStringList &where_clauses) { where_clauses_ = where_clauses; }
|
||||
void SetBoundValues(const QVariantList &bound_values) { bound_values_ = bound_values; }
|
||||
void SetDuplicatesOnly(const bool duplicates_only) { duplicates_only_ = duplicates_only; }
|
||||
void SetIncludeUnavailable(const bool include_unavailable) { include_unavailable_ = include_unavailable; }
|
||||
void SetLimit(const int limit) { limit_ = limit; }
|
||||
void AddCompilationRequirement(const bool compilation);
|
||||
QVariant Value(const int column) const;
|
||||
QVariant value(const int column) const { return Value(column); }
|
||||
|
||||
bool Exec();
|
||||
bool exec() { return QSqlQuery::exec(); }
|
||||
|
||||
bool Next();
|
||||
QVariant Value(const int column) const;
|
||||
|
||||
QString column_spec() const { return column_spec_; }
|
||||
QString order_by() const { return order_by_; }
|
||||
@@ -107,6 +55,24 @@ class CollectionQuery : public QSqlQuery {
|
||||
bool duplicates_only() const { return duplicates_only_; }
|
||||
int limit() const { return limit_; }
|
||||
|
||||
// Sets contents of SELECT clause on the query (list of columns to get).
|
||||
void SetColumnSpec(const QString &column_spec) { column_spec_ = column_spec; }
|
||||
|
||||
// Sets an ORDER BY clause on the query.
|
||||
void SetOrderBy(const QString &order_by) { order_by_ = order_by; }
|
||||
|
||||
void SetWhereClauses(const QStringList &where_clauses) { where_clauses_ = where_clauses; }
|
||||
// Adds a fragment of WHERE clause. When executed, this Query will connect all the fragments with AND operator.
|
||||
// Please note that IN operator expects a QStringList as value.
|
||||
void AddWhere(const QString &column, const QVariant &value, const QString &op = "=");
|
||||
void AddWhereArtist(const QVariant &value);
|
||||
|
||||
void SetBoundValues(const QVariantList &bound_values) { bound_values_ = bound_values; }
|
||||
void SetDuplicatesOnly(const bool duplicates_only) { duplicates_only_ = duplicates_only; }
|
||||
void SetIncludeUnavailable(const bool include_unavailable) { include_unavailable_ = include_unavailable; }
|
||||
void SetLimit(const int limit) { limit_ = limit; }
|
||||
void AddCompilationRequirement(const bool compilation);
|
||||
|
||||
private:
|
||||
QString GetInnerQuery() const;
|
||||
|
||||
|
||||
34
src/collection/collectionqueryoptions.cpp
Normal file
34
src/collection/collectionqueryoptions.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "collectionqueryoptions.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
|
||||
CollectionQueryOptions::CollectionQueryOptions()
|
||||
: compilation_requirement_(CollectionQueryOptions::CompilationRequirement::None),
|
||||
query_have_compilations_(false) {}
|
||||
|
||||
void CollectionQueryOptions::AddWhere(const QString &column, const QVariant &value, const QString &op) {
|
||||
|
||||
where_clauses_ << Where(column, value, op);
|
||||
|
||||
}
|
||||
63
src/collection/collectionqueryoptions.h
Normal file
63
src/collection/collectionqueryoptions.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLLECTIONQUERYOPTIONS_H
|
||||
#define COLLECTIONQUERYOPTIONS_H
|
||||
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
class CollectionQueryOptions {
|
||||
public:
|
||||
|
||||
explicit CollectionQueryOptions();
|
||||
|
||||
struct Where {
|
||||
explicit Where(const QString _column = QString(), const QVariant _value = QString(), const QString _op = QString()) : column(_column), value(_value), op(_op) {}
|
||||
QString column;
|
||||
QVariant value;
|
||||
QString op;
|
||||
};
|
||||
|
||||
enum class CompilationRequirement {
|
||||
None,
|
||||
On,
|
||||
Off
|
||||
};
|
||||
|
||||
QString column_spec() const { return column_spec_; }
|
||||
CompilationRequirement compilation_requirement() const { return compilation_requirement_; }
|
||||
bool query_have_compilations() const { return query_have_compilations_; }
|
||||
|
||||
void set_column_spec(const QString &column_spec) { column_spec_ = column_spec; }
|
||||
void set_compilation_requirement(const CompilationRequirement compilation_requirement) { compilation_requirement_ = compilation_requirement; }
|
||||
void set_query_have_compilations(const bool query_have_compilations) { query_have_compilations_ = query_have_compilations; }
|
||||
|
||||
QList<Where> where_clauses() const { return where_clauses_; }
|
||||
void AddWhere(const QString &column, const QVariant &value, const QString &op = "=");
|
||||
|
||||
private:
|
||||
QString column_spec_;
|
||||
CompilationRequirement compilation_requirement_;
|
||||
bool query_have_compilations_;
|
||||
QList<Where> where_clauses_;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONQUERYOPTIONS_H
|
||||
@@ -50,9 +50,9 @@
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "core/utilities.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/deletefiles.h"
|
||||
#include "utilities/filemanagerutils.h"
|
||||
#include "collection.h"
|
||||
#include "collectionbackend.h"
|
||||
#include "collectiondirectorymodel.h"
|
||||
@@ -699,7 +699,7 @@ void CollectionView::DeleteFilesFinished(const SongList &songs_with_errors) {
|
||||
if (songs_with_errors.isEmpty()) return;
|
||||
|
||||
OrganizeErrorDialog *dialog = new OrganizeErrorDialog(this);
|
||||
dialog->Show(OrganizeErrorDialog::Type_Delete, songs_with_errors);
|
||||
dialog->Show(OrganizeErrorDialog::OperationType::Delete, songs_with_errors);
|
||||
// It deletes itself when the user closes it
|
||||
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
|
||||
#include "core/filesystemwatcherinterface.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/imageutils.h"
|
||||
#include "directory.h"
|
||||
#include "utilities/imageutils.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "collectiondirectory.h"
|
||||
#include "collectionbackend.h"
|
||||
#include "collectionwatcher.h"
|
||||
#include "playlistparsers/cueparser.h"
|
||||
@@ -78,7 +78,7 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
|
||||
scan_on_startup_(true),
|
||||
monitor_(true),
|
||||
song_tracking_(false),
|
||||
mark_songs_unavailable_(source_ == Song::Source_Collection),
|
||||
mark_songs_unavailable_(source_ == Song::Source::Collection),
|
||||
expire_unavailable_songs_days_(60),
|
||||
overwrite_playcount_(false),
|
||||
overwrite_rating_(false),
|
||||
@@ -143,7 +143,7 @@ void CollectionWatcher::ReloadSettings() {
|
||||
scan_on_startup_ = s.value("startup_scan", true).toBool();
|
||||
monitor_ = s.value("monitor", true).toBool();
|
||||
QStringList filters = s.value("cover_art_patterns", QStringList() << "front" << "cover").toStringList();
|
||||
if (source_ == Song::Source_Collection) {
|
||||
if (source_ == Song::Source::Collection) {
|
||||
song_tracking_ = s.value("song_tracking", false).toBool();
|
||||
mark_songs_unavailable_ = song_tracking_ ? true : s.value("mark_songs_unavailable", true).toBool();
|
||||
}
|
||||
@@ -167,15 +167,15 @@ void CollectionWatcher::ReloadSettings() {
|
||||
}
|
||||
else if (monitor_ && !was_monitoring_before) {
|
||||
// Add all directories to all QFileSystemWatchers again
|
||||
for (const Directory &dir : std::as_const(watched_dirs_)) {
|
||||
SubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id);
|
||||
for (const Subdirectory &subdir : subdirs) {
|
||||
for (const CollectionDirectory &dir : std::as_const(watched_dirs_)) {
|
||||
CollectionSubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id);
|
||||
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||
AddWatch(dir, subdir.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mark_songs_unavailable_ && !periodic_scan_timer_->isActive()) {
|
||||
if (monitor_ && scan_on_startup_ && mark_songs_unavailable_ && !periodic_scan_timer_->isActive()) {
|
||||
periodic_scan_timer_->start();
|
||||
}
|
||||
else if (!mark_songs_unavailable_ && periodic_scan_timer_->isActive()) {
|
||||
@@ -239,7 +239,7 @@ void CollectionWatcher::ScanTransaction::AddToProgressMax(const quint64 n) {
|
||||
void CollectionWatcher::ScanTransaction::CommitNewOrUpdatedSongs() {
|
||||
|
||||
if (!deleted_songs.isEmpty()) {
|
||||
if (mark_songs_unavailable_ && watcher_->source() == Song::Source_Collection) {
|
||||
if (mark_songs_unavailable_ && watcher_->source() == Song::Source::Collection) {
|
||||
emit watcher_->SongsUnavailable(deleted_songs);
|
||||
}
|
||||
else {
|
||||
@@ -272,7 +272,7 @@ void CollectionWatcher::ScanTransaction::CommitNewOrUpdatedSongs() {
|
||||
touched_subdirs.clear();
|
||||
}
|
||||
|
||||
for (const Subdirectory &subdir : deleted_subdirs) {
|
||||
for (const CollectionSubdirectory &subdir : deleted_subdirs) {
|
||||
if (watcher_->watched_dirs_.contains(dir_)) {
|
||||
watcher_->RemoveWatch(watcher_->watched_dirs_[dir_], subdir);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ void CollectionWatcher::ScanTransaction::CommitNewOrUpdatedSongs() {
|
||||
|
||||
if (watcher_->monitor_) {
|
||||
// Watch the new subdirectories
|
||||
for (const Subdirectory &subdir : new_subdirs) {
|
||||
for (const CollectionSubdirectory &subdir : new_subdirs) {
|
||||
if (watcher_->watched_dirs_.contains(dir_)) {
|
||||
watcher_->AddWatch(watcher_->watched_dirs_[dir_], subdir.path);
|
||||
}
|
||||
@@ -329,7 +329,7 @@ bool CollectionWatcher::ScanTransaction::HasSongsWithMissingFingerprint(const QS
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::ScanTransaction::SetKnownSubdirs(const SubdirectoryList &subdirs) {
|
||||
void CollectionWatcher::ScanTransaction::SetKnownSubdirs(const CollectionSubdirectoryList &subdirs) {
|
||||
|
||||
known_subdirs_ = subdirs;
|
||||
known_subdirs_dirty_ = false;
|
||||
@@ -342,18 +342,18 @@ bool CollectionWatcher::ScanTransaction::HasSeenSubdir(const QString &path) {
|
||||
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
||||
}
|
||||
|
||||
return std::any_of(known_subdirs_.begin(), known_subdirs_.end(), [path](const Subdirectory &subdir) { return subdir.path == path && subdir.mtime != 0; });
|
||||
return std::any_of(known_subdirs_.begin(), known_subdirs_.end(), [path](const CollectionSubdirectory &subdir) { return subdir.path == path && subdir.mtime != 0; });
|
||||
|
||||
}
|
||||
|
||||
SubdirectoryList CollectionWatcher::ScanTransaction::GetImmediateSubdirs(const QString &path) {
|
||||
CollectionSubdirectoryList CollectionWatcher::ScanTransaction::GetImmediateSubdirs(const QString &path) {
|
||||
|
||||
if (known_subdirs_dirty_) {
|
||||
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
||||
}
|
||||
|
||||
SubdirectoryList ret;
|
||||
for (const Subdirectory &subdir : known_subdirs_) {
|
||||
CollectionSubdirectoryList ret;
|
||||
for (const CollectionSubdirectory &subdir : known_subdirs_) {
|
||||
if (subdir.path.left(subdir.path.lastIndexOf(QDir::separator())) == path && subdir.mtime != 0) {
|
||||
ret << subdir;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ SubdirectoryList CollectionWatcher::ScanTransaction::GetImmediateSubdirs(const Q
|
||||
|
||||
}
|
||||
|
||||
SubdirectoryList CollectionWatcher::ScanTransaction::GetAllSubdirs() {
|
||||
CollectionSubdirectoryList CollectionWatcher::ScanTransaction::GetAllSubdirs() {
|
||||
|
||||
if (known_subdirs_dirty_) {
|
||||
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
||||
@@ -373,7 +373,7 @@ SubdirectoryList CollectionWatcher::ScanTransaction::GetAllSubdirs() {
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::AddDirectory(const Directory &dir, const SubdirectoryList &subdirs) {
|
||||
void CollectionWatcher::AddDirectory(const CollectionDirectory &dir, const CollectionSubdirectoryList &subdirs) {
|
||||
|
||||
stop_requested_ = false;
|
||||
|
||||
@@ -385,7 +385,7 @@ void CollectionWatcher::AddDirectory(const Directory &dir, const SubdirectoryLis
|
||||
const quint64 files_count = FilesCountForPath(&transaction, dir.path);
|
||||
transaction.SetKnownSubdirs(subdirs);
|
||||
transaction.AddToProgressMax(files_count);
|
||||
ScanSubdirectory(dir.path, Subdirectory(), files_count, &transaction);
|
||||
ScanSubdirectory(dir.path, CollectionSubdirectory(), files_count, &transaction);
|
||||
last_scan_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
}
|
||||
else {
|
||||
@@ -395,7 +395,7 @@ void CollectionWatcher::AddDirectory(const Directory &dir, const SubdirectoryLis
|
||||
const quint64 files_count = FilesCountForSubdirs(&transaction, subdirs, subdir_files_count);
|
||||
transaction.SetKnownSubdirs(subdirs);
|
||||
transaction.AddToProgressMax(files_count);
|
||||
for (const Subdirectory &subdir : subdirs) {
|
||||
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||
if (stop_requested_ || abort_requested_) break;
|
||||
|
||||
if (scan_on_startup_) ScanSubdirectory(subdir.path, subdir, subdir_files_count[subdir.path], &transaction);
|
||||
@@ -411,14 +411,14 @@ void CollectionWatcher::AddDirectory(const Directory &dir, const SubdirectoryLis
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory &subdir, const quint64 files_count, ScanTransaction *t, const bool force_noincremental) {
|
||||
void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSubdirectory &subdir, const quint64 files_count, ScanTransaction *t, const bool force_noincremental) {
|
||||
|
||||
QFileInfo path_info(path);
|
||||
|
||||
// Do not scan symlinked dirs that are already in collection
|
||||
if (path_info.isSymLink()) {
|
||||
QString real_path = path_info.symLinkTarget();
|
||||
for (const Directory &dir : std::as_const(watched_dirs_)) {
|
||||
for (const CollectionDirectory &dir : std::as_const(watched_dirs_)) {
|
||||
if (real_path.startsWith(dir.path)) {
|
||||
return;
|
||||
}
|
||||
@@ -440,12 +440,12 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
||||
|
||||
QMap<QString, QStringList> album_art;
|
||||
QStringList files_on_disk;
|
||||
SubdirectoryList my_new_subdirs;
|
||||
CollectionSubdirectoryList my_new_subdirs;
|
||||
|
||||
// If a directory is moved then only its parent gets a changed notification, so we need to look and see if any of our children don't exist anymore.
|
||||
// If one has been removed, "rescan" it to get the deleted songs
|
||||
SubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path);
|
||||
for (const Subdirectory &prev_subdir : previous_subdirs) {
|
||||
CollectionSubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path);
|
||||
for (const CollectionSubdirectory &prev_subdir : previous_subdirs) {
|
||||
if (!QFile::exists(prev_subdir.path) && prev_subdir.path != path) {
|
||||
ScanSubdirectory(prev_subdir.path, prev_subdir, 0, t, true);
|
||||
}
|
||||
@@ -463,7 +463,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
||||
if (child_info.isDir()) {
|
||||
if (!t->HasSeenSubdir(child)) {
|
||||
// We haven't seen this subdirectory before - add it to a list, and later we'll tell the backend about it and scan it.
|
||||
Subdirectory new_subdir;
|
||||
CollectionSubdirectory new_subdir;
|
||||
new_subdir.directory_id = -1;
|
||||
new_subdir.path = child;
|
||||
new_subdir.mtime = child_info.lastModified().toSecsSinceEpoch();
|
||||
@@ -676,7 +676,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
||||
}
|
||||
|
||||
// Add this subdir to the new or touched list
|
||||
Subdirectory updated_subdir;
|
||||
CollectionSubdirectory updated_subdir;
|
||||
updated_subdir.directory_id = t->dir();
|
||||
updated_subdir.mtime = path_info.exists() ? path_info.lastModified().toSecsSinceEpoch() : 0;
|
||||
updated_subdir.path = path;
|
||||
@@ -688,12 +688,12 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
||||
t->touched_subdirs << updated_subdir;
|
||||
}
|
||||
|
||||
if (updated_subdir.mtime == 0) { // Subdirectory deleted, mark it for removal from the watcher.
|
||||
if (updated_subdir.mtime == 0) { // CollectionSubdirectory deleted, mark it for removal from the watcher.
|
||||
t->deleted_subdirs << updated_subdir;
|
||||
}
|
||||
|
||||
// Recurse into the new subdirs that we found
|
||||
for (const Subdirectory &my_new_subdir : my_new_subdirs) {
|
||||
for (const CollectionSubdirectory &my_new_subdir : my_new_subdirs) {
|
||||
if (stop_requested_ || abort_requested_) return;
|
||||
ScanSubdirectory(my_new_subdir.path, my_new_subdir, 0, t, true);
|
||||
}
|
||||
@@ -763,7 +763,7 @@ void CollectionWatcher::UpdateNonCueAssociatedSong(const QString &file,
|
||||
const Song &matching_song = matching_songs.first();
|
||||
if (cue_deleted) {
|
||||
for (const Song &song : matching_songs) {
|
||||
if (!song.IsMetadataAndMoreEqual(matching_song)) {
|
||||
if (!song.IsAllMetadataEqual(matching_song)) {
|
||||
t->deleted_songs << song;
|
||||
}
|
||||
}
|
||||
@@ -855,6 +855,14 @@ void CollectionWatcher::AddChangedSong(const QString &file, const Song &matching
|
||||
changes << "metadata";
|
||||
notify_new = true;
|
||||
}
|
||||
if (!matching_song.IsStatisticsEqual(new_song)) {
|
||||
changes << "statistics";
|
||||
notify_new = true;
|
||||
}
|
||||
if (!matching_song.IsRatingEqual(new_song)) {
|
||||
changes << "rating";
|
||||
notify_new = true;
|
||||
}
|
||||
if (matching_song.art_automatic() != new_song.art_automatic() || matching_song.art_manual() != new_song.art_manual()) {
|
||||
changes << "album art";
|
||||
notify_new = true;
|
||||
@@ -897,7 +905,7 @@ quint64 CollectionWatcher::GetMtimeForCue(const QString &cue_path) {
|
||||
return cue_last_modified.isValid() ? cue_last_modified.toSecsSinceEpoch() : 0;
|
||||
}
|
||||
|
||||
void CollectionWatcher::AddWatch(const Directory &dir, const QString &path) {
|
||||
void CollectionWatcher::AddWatch(const CollectionDirectory &dir, const QString &path) {
|
||||
|
||||
if (!QFile::exists(path)) return;
|
||||
|
||||
@@ -907,7 +915,7 @@ void CollectionWatcher::AddWatch(const Directory &dir, const QString &path) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::RemoveWatch(const Directory &dir, const Subdirectory &subdir) {
|
||||
void CollectionWatcher::RemoveWatch(const CollectionDirectory &dir, const CollectionSubdirectory &subdir) {
|
||||
|
||||
QStringList subdir_paths = subdir_mapping_.keys(dir);
|
||||
for (const QString &subdir_path : subdir_paths) {
|
||||
@@ -919,7 +927,7 @@ void CollectionWatcher::RemoveWatch(const Directory &dir, const Subdirectory &su
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::RemoveDirectory(const Directory &dir) {
|
||||
void CollectionWatcher::RemoveDirectory(const CollectionDirectory &dir) {
|
||||
|
||||
rescan_queue_.remove(dir.id);
|
||||
watched_dirs_.remove(dir.id);
|
||||
@@ -979,11 +987,11 @@ bool CollectionWatcher::FindSongsByFingerprint(const QString &file, const SongLi
|
||||
void CollectionWatcher::DirectoryChanged(const QString &subdir) {
|
||||
|
||||
// Find what dir it was in
|
||||
QHash<QString, Directory>::const_iterator it = subdir_mapping_.constFind(subdir);
|
||||
QHash<QString, CollectionDirectory>::const_iterator it = subdir_mapping_.constFind(subdir);
|
||||
if (it == subdir_mapping_.constEnd()) {
|
||||
return;
|
||||
}
|
||||
Directory dir = *it;
|
||||
CollectionDirectory dir = *it;
|
||||
|
||||
qLog(Debug) << "Subdir" << subdir << "changed under directory" << dir.path << "id" << dir.id;
|
||||
|
||||
@@ -1010,7 +1018,7 @@ void CollectionWatcher::RescanPathsNow() {
|
||||
|
||||
for (const QString &path : rescan_queue_[dir]) {
|
||||
if (stop_requested_ || abort_requested_) break;
|
||||
Subdirectory subdir;
|
||||
CollectionSubdirectory subdir;
|
||||
subdir.directory_id = dir;
|
||||
subdir.mtime = 0;
|
||||
subdir.path = path;
|
||||
@@ -1154,7 +1162,7 @@ void CollectionWatcher::RescanTracksNow() {
|
||||
qLog(Debug) << "Song" << song.title() << "dir id" << song.directory_id() << "dir" << songdir;
|
||||
ScanTransaction transaction(this, song.directory_id(), false, false, mark_songs_unavailable_);
|
||||
quint64 files_count = FilesCountForPath(&transaction, songdir);
|
||||
ScanSubdirectory(songdir, Subdirectory(), files_count, &transaction);
|
||||
ScanSubdirectory(songdir, CollectionSubdirectory(), files_count, &transaction);
|
||||
scanned_dirs << songdir;
|
||||
emit CompilationsNeedUpdating();
|
||||
}
|
||||
@@ -1171,16 +1179,16 @@ void CollectionWatcher::PerformScan(const bool incremental, const bool ignore_mt
|
||||
|
||||
stop_requested_ = false;
|
||||
|
||||
for (const Directory &dir : std::as_const(watched_dirs_)) {
|
||||
for (const CollectionDirectory &dir : std::as_const(watched_dirs_)) {
|
||||
|
||||
if (stop_requested_ || abort_requested_) break;
|
||||
|
||||
ScanTransaction transaction(this, dir.id, incremental, ignore_mtimes, mark_songs_unavailable_);
|
||||
SubdirectoryList subdirs(transaction.GetAllSubdirs());
|
||||
CollectionSubdirectoryList subdirs(transaction.GetAllSubdirs());
|
||||
|
||||
if (subdirs.isEmpty()) {
|
||||
qLog(Debug) << "Collection directory wasn't in subdir list.";
|
||||
Subdirectory subdir;
|
||||
CollectionSubdirectory subdir;
|
||||
subdir.path = dir.path;
|
||||
subdir.directory_id = dir.id;
|
||||
subdirs << subdir;
|
||||
@@ -1190,7 +1198,7 @@ void CollectionWatcher::PerformScan(const bool incremental, const bool ignore_mt
|
||||
quint64 files_count = FilesCountForSubdirs(&transaction, subdirs, subdir_files_count);
|
||||
transaction.AddToProgressMax(files_count);
|
||||
|
||||
for (const Subdirectory &subdir : subdirs) {
|
||||
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||
if (stop_requested_ || abort_requested_) break;
|
||||
ScanSubdirectory(subdir.path, subdir, subdir_files_count[subdir.path], &transaction);
|
||||
}
|
||||
@@ -1217,7 +1225,7 @@ quint64 CollectionWatcher::FilesCountForPath(ScanTransaction *t, const QString &
|
||||
if (path_info.isDir()) {
|
||||
if (path_info.isSymLink()) {
|
||||
QString real_path = path_info.symLinkTarget();
|
||||
for (const Directory &dir : std::as_const(watched_dirs_)) {
|
||||
for (const CollectionDirectory &dir : std::as_const(watched_dirs_)) {
|
||||
if (real_path.startsWith(dir.path)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1239,10 +1247,10 @@ quint64 CollectionWatcher::FilesCountForPath(ScanTransaction *t, const QString &
|
||||
|
||||
}
|
||||
|
||||
quint64 CollectionWatcher::FilesCountForSubdirs(ScanTransaction *t, const SubdirectoryList &subdirs, QMap<QString, quint64> &subdir_files_count) {
|
||||
quint64 CollectionWatcher::FilesCountForSubdirs(ScanTransaction *t, const CollectionSubdirectoryList &subdirs, QMap<QString, quint64> &subdir_files_count) {
|
||||
|
||||
quint64 i = 0;
|
||||
for (const Subdirectory &subdir : subdirs) {
|
||||
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||
if (stop_requested_ || abort_requested_) break;
|
||||
const quint64 files_count = FilesCountForPath(t, subdir.path);
|
||||
subdir_files_count[subdir.path] = files_count;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "directory.h"
|
||||
#include "collectiondirectory.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QThread;
|
||||
@@ -74,8 +74,8 @@ class CollectionWatcher : public QObject {
|
||||
void SongsDeleted(SongList);
|
||||
void SongsUnavailable(SongList songs, bool unavailable = true);
|
||||
void SongsReadded(SongList songs, bool unavailable = false);
|
||||
void SubdirsDiscovered(SubdirectoryList subdirs);
|
||||
void SubdirsMTimeUpdated(SubdirectoryList subdirs);
|
||||
void SubdirsDiscovered(CollectionSubdirectoryList subdirs);
|
||||
void SubdirsMTimeUpdated(CollectionSubdirectoryList subdirs);
|
||||
void CompilationsNeedUpdating();
|
||||
void UpdateLastSeen(int directory_id, int expire_unavailable_songs_days);
|
||||
void ExitFinished();
|
||||
@@ -83,8 +83,8 @@ class CollectionWatcher : public QObject {
|
||||
void ScanStarted(int task_id);
|
||||
|
||||
public slots:
|
||||
void AddDirectory(const Directory &dir, const SubdirectoryList &subdirs);
|
||||
void RemoveDirectory(const Directory &dir);
|
||||
void AddDirectory(const CollectionDirectory &dir, const CollectionSubdirectoryList &subdirs);
|
||||
void RemoveDirectory(const CollectionDirectory &dir);
|
||||
void SetRescanPaused(bool pause);
|
||||
|
||||
private:
|
||||
@@ -102,9 +102,9 @@ class CollectionWatcher : public QObject {
|
||||
SongList FindSongsInSubdirectory(const QString &path);
|
||||
bool HasSongsWithMissingFingerprint(const QString &path);
|
||||
bool HasSeenSubdir(const QString &path);
|
||||
void SetKnownSubdirs(const SubdirectoryList &subdirs);
|
||||
SubdirectoryList GetImmediateSubdirs(const QString &path);
|
||||
SubdirectoryList GetAllSubdirs();
|
||||
void SetKnownSubdirs(const CollectionSubdirectoryList &subdirs);
|
||||
CollectionSubdirectoryList GetImmediateSubdirs(const QString &path);
|
||||
CollectionSubdirectoryList GetAllSubdirs();
|
||||
|
||||
void AddToProgress(const quint64 n = 1);
|
||||
void AddToProgressMax(const quint64 n);
|
||||
@@ -120,9 +120,9 @@ class CollectionWatcher : public QObject {
|
||||
SongList readded_songs;
|
||||
SongList new_songs;
|
||||
SongList touched_songs;
|
||||
SubdirectoryList new_subdirs;
|
||||
SubdirectoryList touched_subdirs;
|
||||
SubdirectoryList deleted_subdirs;
|
||||
CollectionSubdirectoryList new_subdirs;
|
||||
CollectionSubdirectoryList touched_subdirs;
|
||||
CollectionSubdirectoryList deleted_subdirs;
|
||||
|
||||
QStringList files_changed_path_;
|
||||
|
||||
@@ -155,7 +155,7 @@ class CollectionWatcher : public QObject {
|
||||
QMultiMap<QString, Song> cached_songs_missing_fingerprint_;
|
||||
bool cached_songs_missing_fingerprint_dirty_;
|
||||
|
||||
SubdirectoryList known_subdirs_;
|
||||
CollectionSubdirectoryList known_subdirs_;
|
||||
bool known_subdirs_dirty_;
|
||||
};
|
||||
|
||||
@@ -168,7 +168,7 @@ class CollectionWatcher : public QObject {
|
||||
void FullScanNow();
|
||||
void RescanTracksNow();
|
||||
void RescanPathsNow();
|
||||
void ScanSubdirectory(const QString &path, const Subdirectory &subdir, const quint64 files_count, CollectionWatcher::ScanTransaction *t, const bool force_noincremental = false);
|
||||
void ScanSubdirectory(const QString &path, const CollectionSubdirectory &subdir, const quint64 files_count, CollectionWatcher::ScanTransaction *t, const bool force_noincremental = false);
|
||||
|
||||
private:
|
||||
static bool FindSongsByPath(const SongList &songs, const QString &path, SongList *out);
|
||||
@@ -179,8 +179,8 @@ class CollectionWatcher : public QObject {
|
||||
inline static QString DirectoryPart(const QString &fileName);
|
||||
QString PickBestImage(const QStringList &images);
|
||||
QUrl ImageForSong(const QString &path, QMap<QString, QStringList> &album_art);
|
||||
void AddWatch(const Directory &dir, const QString &path);
|
||||
void RemoveWatch(const Directory &dir, const Subdirectory &subdir);
|
||||
void AddWatch(const CollectionDirectory &dir, const QString &path);
|
||||
void RemoveWatch(const CollectionDirectory &dir, const CollectionSubdirectory &subdir);
|
||||
static quint64 GetMtimeForCue(const QString &cue_path);
|
||||
void PerformScan(const bool incremental, const bool ignore_mtimes);
|
||||
|
||||
@@ -195,7 +195,7 @@ class CollectionWatcher : public QObject {
|
||||
static void AddChangedSong(const QString &file, const Song &matching_song, const Song &new_song, ScanTransaction *t);
|
||||
|
||||
quint64 FilesCountForPath(ScanTransaction *t, const QString &path);
|
||||
quint64 FilesCountForSubdirs(ScanTransaction *t, const SubdirectoryList &subdirs, QMap<QString, quint64> &subdir_files_count);
|
||||
quint64 FilesCountForSubdirs(ScanTransaction *t, const CollectionSubdirectoryList &subdirs, QMap<QString, quint64> &subdir_files_count);
|
||||
|
||||
QString FindCueFilename(const QString &filename);
|
||||
|
||||
@@ -207,7 +207,7 @@ class CollectionWatcher : public QObject {
|
||||
|
||||
FileSystemWatcherInterface *fs_watcher_;
|
||||
QThread *original_thread_;
|
||||
QHash<QString, Directory> subdir_mapping_;
|
||||
QHash<QString, CollectionDirectory> subdir_mapping_;
|
||||
|
||||
// A list of words use to try to identify the (likely) best image found in an directory to use as cover artwork.
|
||||
// e.g. using ["front", "cover"] would identify front.jpg and exclude back.jpg.
|
||||
@@ -225,7 +225,7 @@ class CollectionWatcher : public QObject {
|
||||
bool abort_requested_;
|
||||
bool rescan_in_progress_; // True if RescanTracksNow() has been called and is working.
|
||||
|
||||
QMap<int, Directory> watched_dirs_;
|
||||
QMap<int, CollectionDirectory> watched_dirs_;
|
||||
QTimer *rescan_timer_;
|
||||
QTimer *periodic_scan_timer_;
|
||||
QMap<int, QStringList> rescan_queue_; // dir id -> list of subdirs to be scanned
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DIRECTORY_H
|
||||
#define DIRECTORY_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QSqlQuery>
|
||||
|
||||
struct Directory {
|
||||
Directory() : id(-1) {}
|
||||
|
||||
bool operator==(const Directory &other) const {
|
||||
return path == other.path && id == other.id;
|
||||
}
|
||||
|
||||
QString path;
|
||||
int id;
|
||||
};
|
||||
Q_DECLARE_METATYPE(Directory)
|
||||
|
||||
typedef QList<Directory> DirectoryList;
|
||||
Q_DECLARE_METATYPE(DirectoryList)
|
||||
|
||||
|
||||
struct Subdirectory {
|
||||
Subdirectory() : directory_id(-1), mtime(0) {}
|
||||
|
||||
int directory_id;
|
||||
QString path;
|
||||
qint64 mtime;
|
||||
};
|
||||
Q_DECLARE_METATYPE(Subdirectory)
|
||||
|
||||
typedef QList<Subdirectory> SubdirectoryList;
|
||||
Q_DECLARE_METATYPE(SubdirectoryList)
|
||||
|
||||
#endif // DIRECTORY_H
|
||||
|
||||
|
||||
@@ -63,11 +63,7 @@ struct tag_group_by {};
|
||||
|
||||
class GroupByDialogPrivate {
|
||||
private:
|
||||
typedef multi_index_container<
|
||||
Mapping,
|
||||
indexed_by<
|
||||
ordered_unique<tag<tag_index>, member<Mapping, int, &Mapping::combo_box_index> >,
|
||||
ordered_unique<tag<tag_group_by>, member<Mapping, CollectionModel::GroupBy, &Mapping::group_by> > > > MappingContainer;
|
||||
using MappingContainer = multi_index_container<Mapping, indexed_by<ordered_unique<tag<tag_index>, member<Mapping, int, &Mapping::combo_box_index>>, ordered_unique<tag<tag_group_by>, member<Mapping, CollectionModel::GroupBy, &Mapping::group_by>>>>;
|
||||
|
||||
public:
|
||||
MappingContainer mapping_;
|
||||
@@ -78,26 +74,26 @@ GroupByDialog::GroupByDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_Grou
|
||||
ui_->setupUi(this);
|
||||
Reset();
|
||||
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_None, 0));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Artist, 1));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_AlbumArtist, 2));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Album, 3));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_AlbumDisc, 4));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Disc, 5));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Format, 6));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Genre, 7));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Year, 8));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_YearAlbum, 9));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_YearAlbumDisc, 10));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_OriginalYear, 11));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_OriginalYearAlbum, 12));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Composer, 13));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Performer, 14));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Grouping, 15));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_FileType, 16));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Samplerate, 17));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Bitdepth, 18));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Bitrate, 19));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::None, 0));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Artist, 1));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::AlbumArtist, 2));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Album, 3));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::AlbumDisc, 4));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Disc, 5));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Format, 6));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Genre, 7));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Year, 8));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::YearAlbum, 9));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::YearAlbumDisc, 10));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::OriginalYear, 11));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::OriginalYearAlbum, 12));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Composer, 13));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Performer, 14));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Grouping, 15));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::FileType, 16));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Samplerate, 17));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Bitdepth, 18));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy::Bitrate, 19));
|
||||
|
||||
QObject::connect(ui_->buttonbox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &GroupByDialog::Reset);
|
||||
|
||||
|
||||
@@ -83,68 +83,68 @@ QString SavedGroupingManager::GetSavedGroupingsSettingsGroup(const QString &sett
|
||||
QString SavedGroupingManager::GroupByToString(const CollectionModel::GroupBy g) {
|
||||
|
||||
switch (g) {
|
||||
case CollectionModel::GroupBy_None:
|
||||
case CollectionModel::GroupByCount: {
|
||||
case CollectionModel::GroupBy::None:
|
||||
case CollectionModel::GroupBy::GroupByCount: {
|
||||
return tr("None");
|
||||
}
|
||||
case CollectionModel::GroupBy_AlbumArtist: {
|
||||
case CollectionModel::GroupBy::AlbumArtist: {
|
||||
return tr("Album artist");
|
||||
}
|
||||
case CollectionModel::GroupBy_Artist: {
|
||||
case CollectionModel::GroupBy::Artist: {
|
||||
return tr("Artist");
|
||||
}
|
||||
case CollectionModel::GroupBy_Album: {
|
||||
case CollectionModel::GroupBy::Album: {
|
||||
return tr("Album");
|
||||
}
|
||||
case CollectionModel::GroupBy_AlbumDisc: {
|
||||
case CollectionModel::GroupBy::AlbumDisc: {
|
||||
return tr("Album - Disc");
|
||||
}
|
||||
case CollectionModel::GroupBy_YearAlbum: {
|
||||
case CollectionModel::GroupBy::YearAlbum: {
|
||||
return tr("Year - Album");
|
||||
}
|
||||
case CollectionModel::GroupBy_YearAlbumDisc: {
|
||||
case CollectionModel::GroupBy::YearAlbumDisc: {
|
||||
return tr("Year - Album - Disc");
|
||||
}
|
||||
case CollectionModel::GroupBy_OriginalYearAlbum: {
|
||||
case CollectionModel::GroupBy::OriginalYearAlbum: {
|
||||
return tr("Original year - Album");
|
||||
}
|
||||
case CollectionModel::GroupBy_OriginalYearAlbumDisc: {
|
||||
case CollectionModel::GroupBy::OriginalYearAlbumDisc: {
|
||||
return tr("Original year - Album - Disc");
|
||||
}
|
||||
case CollectionModel::GroupBy_Disc: {
|
||||
case CollectionModel::GroupBy::Disc: {
|
||||
return tr("Disc");
|
||||
}
|
||||
case CollectionModel::GroupBy_Year: {
|
||||
case CollectionModel::GroupBy::Year: {
|
||||
return tr("Year");
|
||||
}
|
||||
case CollectionModel::GroupBy_OriginalYear: {
|
||||
case CollectionModel::GroupBy::OriginalYear: {
|
||||
return tr("Original year");
|
||||
}
|
||||
case CollectionModel::GroupBy_Genre: {
|
||||
case CollectionModel::GroupBy::Genre: {
|
||||
return tr("Genre");
|
||||
}
|
||||
case CollectionModel::GroupBy_Composer: {
|
||||
case CollectionModel::GroupBy::Composer: {
|
||||
return tr("Composer");
|
||||
}
|
||||
case CollectionModel::GroupBy_Performer: {
|
||||
case CollectionModel::GroupBy::Performer: {
|
||||
return tr("Performer");
|
||||
}
|
||||
case CollectionModel::GroupBy_Grouping: {
|
||||
case CollectionModel::GroupBy::Grouping: {
|
||||
return tr("Grouping");
|
||||
}
|
||||
case CollectionModel::GroupBy_FileType: {
|
||||
case CollectionModel::GroupBy::FileType: {
|
||||
return tr("File type");
|
||||
}
|
||||
case CollectionModel::GroupBy_Format: {
|
||||
case CollectionModel::GroupBy::Format: {
|
||||
return tr("Format");
|
||||
}
|
||||
case CollectionModel::GroupBy_Samplerate: {
|
||||
case CollectionModel::GroupBy::Samplerate: {
|
||||
return tr("Sample rate");
|
||||
}
|
||||
case CollectionModel::GroupBy_Bitdepth: {
|
||||
case CollectionModel::GroupBy::Bitdepth: {
|
||||
return tr("Bit depth");
|
||||
}
|
||||
case CollectionModel::GroupBy_Bitrate: {
|
||||
case CollectionModel::GroupBy::Bitrate: {
|
||||
return tr("Bitrate");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <QContextMenuEvent>
|
||||
#include <QPaintEvent>
|
||||
|
||||
#include "core/imageutils.h"
|
||||
#include "utilities/imageutils.h"
|
||||
#include "covermanager/albumcoverchoicecontroller.h"
|
||||
|
||||
#include "contextview.h"
|
||||
|
||||
@@ -51,8 +51,9 @@
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/song.h"
|
||||
#include "core/utilities.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "utilities/timeutils.h"
|
||||
#include "widgets/resizabletextedit.h"
|
||||
#include "engine/engine_fwd.h"
|
||||
#include "engine/enginebase.h"
|
||||
@@ -337,11 +338,11 @@ void ContextView::ReloadSettings() {
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
title_fmt_ = s.value(ContextSettingsPage::kSettingsTitleFmt, "%title% - %artist%").toString();
|
||||
summary_fmt_ = s.value(ContextSettingsPage::kSettingsSummaryFmt, "%album%").toString();
|
||||
action_show_album_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ALBUM], true).toBool());
|
||||
action_show_data_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA], false).toBool());
|
||||
action_show_output_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE], false).toBool());
|
||||
action_show_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS], true).toBool());
|
||||
action_search_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS], true).toBool());
|
||||
action_show_album_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ALBUM)], true).toBool());
|
||||
action_show_data_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA)], false).toBool());
|
||||
action_show_output_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE)], false).toBool());
|
||||
action_show_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS)], true).toBool());
|
||||
action_search_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS)], true).toBool());
|
||||
font_headline_ = s.value("font_headline", font().family()).toString();
|
||||
font_normal_ = s.value("font_normal", font().family()).toString();
|
||||
font_size_headline_ = s.value("font_size_headline", ContextSettingsPage::kDefaultFontSizeHeadline).toReal();
|
||||
@@ -434,8 +435,8 @@ void ContextView::NoSong() {
|
||||
widget_album_->show();
|
||||
}
|
||||
|
||||
textedit_top_->setStyleSheet("font: 20pt 'Open Sans', 'FreeSans', 'FreeSerif', 'Liberation Serif'; font-weight: Regular;");
|
||||
textedit_top_->setText(tr("No song playing"));
|
||||
textedit_top_->setFont(QFont(font_headline_, font_size_headline_ * 1.6));
|
||||
textedit_top_->SetText(tr("No song playing"));
|
||||
|
||||
QString html;
|
||||
if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs());
|
||||
@@ -450,27 +451,28 @@ void ContextView::NoSong() {
|
||||
else html += tr("%1 albums").arg(collectionview_->TotalAlbums());
|
||||
html += "<br />";
|
||||
|
||||
label_stop_summary_->setStyleSheet(QString("font: %1pt \"%2\"; font-weight: regular;").arg(font_size_normal_).arg(font_normal_));
|
||||
label_stop_summary_->setFont(QFont(font_normal_, font_size_normal_));
|
||||
label_stop_summary_->setText(html);
|
||||
|
||||
}
|
||||
|
||||
void ContextView::UpdateFonts() {
|
||||
|
||||
QString font_style = QString("font: %2pt \"%1\"; font-weight: regular;").arg(font_normal_).arg(font_size_normal_);
|
||||
QFont font(font_normal_, font_size_normal_);
|
||||
font.setBold(false);
|
||||
for (QLabel *l : labels_play_all_) {
|
||||
l->setStyleSheet(font_style);
|
||||
l->setFont(font);
|
||||
}
|
||||
for (QTextEdit *e : textedit_play_) {
|
||||
e->setStyleSheet(font_style);
|
||||
e->setFont(font);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ContextView::SetSong() {
|
||||
|
||||
textedit_top_->setStyleSheet(QString("font: %2pt \"%1\"; font-weight: regular;").arg(font_headline_).arg(font_size_headline_));
|
||||
textedit_top_->setText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "<br />", true)));
|
||||
textedit_top_->setFont(QFont(font_headline_, font_size_headline_));
|
||||
textedit_top_->SetText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "<br />", true)));
|
||||
|
||||
label_stop_summary_->clear();
|
||||
|
||||
@@ -542,9 +544,9 @@ void ContextView::SetSong() {
|
||||
|
||||
if (action_show_output_->isChecked()) {
|
||||
widget_play_output_->show();
|
||||
Engine::EngineType enginetype(Engine::None);
|
||||
Engine::EngineType enginetype(Engine::EngineType::None);
|
||||
if (app_->player()->engine()) enginetype = app_->player()->engine()->type();
|
||||
QIcon icon_engine = IconLoader::Load(EngineName(enginetype), 32);
|
||||
QIcon icon_engine = IconLoader::Load(EngineName(enginetype), true, 32);
|
||||
|
||||
label_engine_icon_->setPixmap(icon_engine.pixmap(QSize(32, 32)));
|
||||
label_engine_->setText(EngineDescription(enginetype));
|
||||
@@ -562,7 +564,7 @@ void ContextView::SetSong() {
|
||||
label_device_title_->show();
|
||||
label_device_icon_->show();
|
||||
label_device_->show();
|
||||
QIcon icon_device = IconLoader::Load(device.iconname, 32);
|
||||
QIcon icon_device = IconLoader::Load(device.iconname, true, 32);
|
||||
label_device_icon_->setPixmap(icon_device.pixmap(QSize(32, 32)));
|
||||
label_device_->setText(device.description);
|
||||
}
|
||||
@@ -584,7 +586,7 @@ void ContextView::SetSong() {
|
||||
}
|
||||
|
||||
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
|
||||
textedit_play_lyrics_->setText(lyrics_);
|
||||
textedit_play_lyrics_->SetText(lyrics_);
|
||||
textedit_play_lyrics_->show();
|
||||
}
|
||||
else {
|
||||
@@ -599,7 +601,7 @@ void ContextView::SetSong() {
|
||||
|
||||
void ContextView::UpdateSong(const Song &song) {
|
||||
|
||||
textedit_top_->setText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song, "<br />", true)));
|
||||
textedit_top_->SetText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song, "<br />", true)));
|
||||
|
||||
if (action_show_data_->isChecked()) {
|
||||
if (song.filetype() != song_playing_.filetype()) label_filetype_->setText(song.TextForFiletype());
|
||||
@@ -655,6 +657,8 @@ void ContextView::UpdateSong(const Song &song) {
|
||||
|
||||
song_playing_ = song;
|
||||
|
||||
widget_stacked_->updateGeometry();
|
||||
|
||||
}
|
||||
|
||||
void ContextView::ResetSong() {
|
||||
@@ -681,7 +685,7 @@ void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const
|
||||
lyrics_id_ = -1;
|
||||
|
||||
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
|
||||
textedit_play_lyrics_->setText(lyrics_);
|
||||
textedit_play_lyrics_->SetText(lyrics_);
|
||||
textedit_play_lyrics_->show();
|
||||
}
|
||||
else {
|
||||
@@ -735,7 +739,7 @@ void ContextView::ActionShowAlbum() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ALBUM], action_show_album_->isChecked());
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ALBUM)], action_show_album_->isChecked());
|
||||
s.endGroup();
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
@@ -745,7 +749,7 @@ void ContextView::ActionShowData() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA], action_show_data_->isChecked());
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA)], action_show_data_->isChecked());
|
||||
s.endGroup();
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
@@ -755,7 +759,7 @@ void ContextView::ActionShowOutput() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE], action_show_output_->isChecked());
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE)], action_show_output_->isChecked());
|
||||
s.endGroup();
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
@@ -765,7 +769,7 @@ void ContextView::ActionShowLyrics() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS], action_show_lyrics_->isChecked());
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS)], action_show_lyrics_->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
@@ -778,7 +782,7 @@ void ContextView::ActionSearchLyrics() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS], action_search_lyrics_->isChecked());
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS)], action_search_lyrics_->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, Arnaud Bienner <arnaud.bienner@gmail.com>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QObject>
|
||||
#include <QPalette>
|
||||
#include <QColor>
|
||||
#include <QSettings>
|
||||
|
||||
#include "appearance.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
|
||||
const QPalette Appearance::kDefaultPalette = QPalette();
|
||||
|
||||
Appearance::Appearance(QObject *parent) : QObject(parent) {
|
||||
|
||||
QPalette p = QApplication::palette();
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
background_color_ = s.value(AppearanceSettingsPage::kBackgroundColor, p.color(QPalette::WindowText)).value<QColor>();
|
||||
foreground_color_ = s.value(AppearanceSettingsPage::kForegroundColor, p.color(QPalette::Window)).value<QColor>();
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
void Appearance::LoadUserTheme() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
bool use_a_custom_color_set = s.value(AppearanceSettingsPage::kUseCustomColorSet).toBool();
|
||||
s.endGroup();
|
||||
|
||||
if (use_a_custom_color_set) {
|
||||
ChangeForegroundColor(foreground_color_);
|
||||
ChangeBackgroundColor(background_color_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Appearance::ResetToSystemDefaultTheme() {
|
||||
QApplication::setPalette(kDefaultPalette);
|
||||
}
|
||||
|
||||
void Appearance::ChangeForegroundColor(const QColor &color) {
|
||||
|
||||
// Get the application palette
|
||||
QPalette p = QApplication::palette();
|
||||
|
||||
// Modify the palette
|
||||
p.setColor(QPalette::WindowText, color);
|
||||
p.setColor(QPalette::Text, color);
|
||||
|
||||
// Make the modified palette the new application's palette
|
||||
QApplication::setPalette(p);
|
||||
foreground_color_ = color;
|
||||
|
||||
}
|
||||
|
||||
void Appearance::ChangeBackgroundColor(const QColor &color) {
|
||||
|
||||
// Get the application palette
|
||||
QPalette p = QApplication::palette();
|
||||
|
||||
// Modify the palette
|
||||
p.setColor(QPalette::Window, color);
|
||||
p.setColor(QPalette::Base, color);
|
||||
|
||||
// Make the modified palette the new application's palette
|
||||
QApplication::setPalette(p);
|
||||
background_color_ = color;
|
||||
|
||||
}
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "database.h"
|
||||
#include "taskmanager.h"
|
||||
#include "player.h"
|
||||
#include "appearance.h"
|
||||
|
||||
#include "engine/devicefinders.h"
|
||||
#ifndef Q_OS_WIN
|
||||
@@ -64,6 +63,7 @@
|
||||
#include "lyrics/lololyricsprovider.h"
|
||||
#include "lyrics/musixmatchlyricsprovider.h"
|
||||
#include "lyrics/chartlyricsprovider.h"
|
||||
#include "lyrics/stands4lyricsprovider.h"
|
||||
|
||||
#include "scrobbler/audioscrobbler.h"
|
||||
#include "scrobbler/lastfmimport.h"
|
||||
@@ -109,7 +109,6 @@ class ApplicationImpl {
|
||||
QTimer::singleShot(30s, db, &Database::DoBackup);
|
||||
return db;
|
||||
}),
|
||||
appearance_([app]() { return new Appearance(app); }),
|
||||
task_manager_([app]() { return new TaskManager(app); }),
|
||||
player_([app]() { return new Player(app, app); }),
|
||||
device_finders_([app]() { return new DeviceFinders(app); }),
|
||||
@@ -156,6 +155,7 @@ class ApplicationImpl {
|
||||
lyrics_providers->AddProvider(new LoloLyricsProvider(lyrics_providers->network(), app));
|
||||
lyrics_providers->AddProvider(new MusixmatchLyricsProvider(lyrics_providers->network(), app));
|
||||
lyrics_providers->AddProvider(new ChartLyricsProvider(lyrics_providers->network(), app));
|
||||
lyrics_providers->AddProvider(new Stands4LyricsProvider(lyrics_providers->network(), app));
|
||||
lyrics_providers->ReloadSettings();
|
||||
return lyrics_providers;
|
||||
}),
|
||||
@@ -183,7 +183,6 @@ class ApplicationImpl {
|
||||
|
||||
Lazy<TagReaderClient> tag_reader_client_;
|
||||
Lazy<Database> database_;
|
||||
Lazy<Appearance> appearance_;
|
||||
Lazy<TaskManager> task_manager_;
|
||||
Lazy<Player> player_;
|
||||
Lazy<DeviceFinders> device_finders_;
|
||||
@@ -315,7 +314,6 @@ void Application::ReloadSettings() { emit SettingsChanged(); }
|
||||
void Application::OpenSettingsDialogAtPage(SettingsDialog::Page page) { emit SettingsDialogRequested(page); }
|
||||
|
||||
TagReaderClient *Application::tag_reader_client() const { return p_->tag_reader_client_.get(); }
|
||||
Appearance *Application::appearance() const { return p_->appearance_.get(); }
|
||||
Database *Application::database() const { return p_->database_.get(); }
|
||||
TaskManager *Application::task_manager() const { return p_->task_manager_.get(); }
|
||||
Player *Application::player() const { return p_->player_.get(); }
|
||||
|
||||
@@ -41,7 +41,6 @@ class TagReaderClient;
|
||||
class Database;
|
||||
class DeviceFinders;
|
||||
class Player;
|
||||
class Appearance;
|
||||
class SCollection;
|
||||
class CollectionBackend;
|
||||
class CollectionModel;
|
||||
@@ -73,7 +72,6 @@ class Application : public QObject {
|
||||
|
||||
TagReaderClient *tag_reader_client() const;
|
||||
Database *database() const;
|
||||
Appearance *appearance() const;
|
||||
TaskManager *task_manager() const;
|
||||
Player *player() const;
|
||||
DeviceFinders *device_finders() const;
|
||||
|
||||
@@ -81,8 +81,8 @@ const char *CommandlineOptions::kVersionText = "Strawberry %1";
|
||||
CommandlineOptions::CommandlineOptions(int argc, char **argv)
|
||||
: argc_(argc),
|
||||
argv_(argv),
|
||||
url_list_action_(UrlList_None),
|
||||
player_action_(Player_None),
|
||||
url_list_action_(UrlListAction::None),
|
||||
player_action_(PlayerAction::None),
|
||||
set_volume_(-1),
|
||||
volume_modifier_(0),
|
||||
seek_to_(-1),
|
||||
@@ -128,13 +128,13 @@ bool CommandlineOptions::Parse() {
|
||||
{"previous", no_argument, nullptr, 'r'},
|
||||
{"next", no_argument, nullptr, 'f'},
|
||||
{"volume", required_argument, nullptr, 'v'},
|
||||
{"volume-up", no_argument, nullptr, VolumeUp},
|
||||
{"volume-down", no_argument, nullptr, VolumeDown},
|
||||
{"volume-increase-by", required_argument, nullptr, VolumeIncreaseBy},
|
||||
{"volume-decrease-by", required_argument, nullptr, VolumeDecreaseBy},
|
||||
{"seek-to", required_argument, nullptr, SeekTo},
|
||||
{"seek-by", required_argument, nullptr, SeekBy},
|
||||
{"restart-or-previous", no_argument, nullptr, RestartOrPrevious},
|
||||
{"volume-up", no_argument, nullptr, LongOptions::VolumeUp},
|
||||
{"volume-down", no_argument, nullptr, LongOptions::VolumeDown},
|
||||
{"volume-increase-by", required_argument, nullptr, LongOptions::VolumeIncreaseBy},
|
||||
{"volume-decrease-by", required_argument, nullptr, LongOptions::VolumeDecreaseBy},
|
||||
{"seek-to", required_argument, nullptr, LongOptions::SeekTo},
|
||||
{"seek-by", required_argument, nullptr, LongOptions::SeekBy},
|
||||
{"restart-or-previous", no_argument, nullptr, LongOptions::RestartOrPrevious},
|
||||
{"create", required_argument, nullptr, 'c'},
|
||||
{"append", no_argument, nullptr, 'a'},
|
||||
{"load", no_argument, nullptr, 'l'},
|
||||
@@ -144,10 +144,10 @@ bool CommandlineOptions::Parse() {
|
||||
{"toggle-pretty-osd", no_argument, nullptr, 'y'},
|
||||
{"language", required_argument, nullptr, 'g'},
|
||||
{"resize-window", required_argument, nullptr, 'w'},
|
||||
{"quiet", no_argument, nullptr, Quiet},
|
||||
{"verbose", no_argument, nullptr, Verbose},
|
||||
{"log-levels", required_argument, nullptr, LogLevels},
|
||||
{"version", no_argument, nullptr, Version},
|
||||
{"quiet", no_argument, nullptr, LongOptions::Quiet},
|
||||
{"verbose", no_argument, nullptr, LongOptions::Verbose},
|
||||
{"log-levels", required_argument, nullptr, LongOptions::LogLevels},
|
||||
{"version", no_argument, nullptr, LongOptions::Version},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
|
||||
// Parse the arguments
|
||||
@@ -198,39 +198,39 @@ bool CommandlineOptions::Parse() {
|
||||
}
|
||||
|
||||
case 'p':
|
||||
player_action_ = Player_Play;
|
||||
player_action_ = PlayerAction::Play;
|
||||
break;
|
||||
case 't':
|
||||
player_action_ = Player_PlayPause;
|
||||
player_action_ = PlayerAction::PlayPause;
|
||||
break;
|
||||
case 'u':
|
||||
player_action_ = Player_Pause;
|
||||
player_action_ = PlayerAction::Pause;
|
||||
break;
|
||||
case 's':
|
||||
player_action_ = Player_Stop;
|
||||
player_action_ = PlayerAction::Stop;
|
||||
break;
|
||||
case 'q':
|
||||
player_action_ = Player_StopAfterCurrent;
|
||||
player_action_ = PlayerAction::StopAfterCurrent;
|
||||
break;
|
||||
case 'r':
|
||||
player_action_ = Player_Previous;
|
||||
player_action_ = PlayerAction::Previous;
|
||||
break;
|
||||
case 'f':
|
||||
player_action_ = Player_Next;
|
||||
player_action_ = PlayerAction::Next;
|
||||
break;
|
||||
case 'i':
|
||||
player_action_ = Player_PlayPlaylist;
|
||||
player_action_ = PlayerAction::PlayPlaylist;
|
||||
playlist_name_ = QString(optarg);
|
||||
break;
|
||||
case 'c':
|
||||
url_list_action_ = UrlList_CreateNew;
|
||||
url_list_action_ = UrlListAction::CreateNew;
|
||||
playlist_name_ = QString(optarg);
|
||||
break;
|
||||
case 'a':
|
||||
url_list_action_ = UrlList_Append;
|
||||
url_list_action_ = UrlListAction::Append;
|
||||
break;
|
||||
case 'l':
|
||||
url_list_action_ = UrlList_Load;
|
||||
url_list_action_ = UrlListAction::Load;
|
||||
break;
|
||||
case 'o':
|
||||
show_osd_ = true;
|
||||
@@ -241,22 +241,22 @@ bool CommandlineOptions::Parse() {
|
||||
case 'g':
|
||||
language_ = QString(optarg);
|
||||
break;
|
||||
case VolumeUp:
|
||||
case LongOptions::VolumeUp:
|
||||
volume_modifier_ = +4;
|
||||
break;
|
||||
case VolumeDown:
|
||||
case LongOptions::VolumeDown:
|
||||
volume_modifier_ = -4;
|
||||
break;
|
||||
case Quiet:
|
||||
case LongOptions::Quiet:
|
||||
log_levels_ = "1";
|
||||
break;
|
||||
case Verbose:
|
||||
case LongOptions::Verbose:
|
||||
log_levels_ = "3";
|
||||
break;
|
||||
case LogLevels:
|
||||
case LongOptions::LogLevels:
|
||||
log_levels_ = QString(optarg);
|
||||
break;
|
||||
case Version: {
|
||||
case LongOptions::Version: {
|
||||
QString version_text = QString(kVersionText).arg(STRAWBERRY_VERSION_DISPLAY);
|
||||
std::cout << version_text.toLocal8Bit().constData() << std::endl;
|
||||
std::exit(0);
|
||||
@@ -266,28 +266,28 @@ bool CommandlineOptions::Parse() {
|
||||
if (!ok) set_volume_ = -1;
|
||||
break;
|
||||
|
||||
case VolumeIncreaseBy:
|
||||
case LongOptions::VolumeIncreaseBy:
|
||||
volume_modifier_ = QString(optarg).toInt(&ok);
|
||||
if (!ok) volume_modifier_ = 0;
|
||||
break;
|
||||
|
||||
case VolumeDecreaseBy:
|
||||
case LongOptions::VolumeDecreaseBy:
|
||||
volume_modifier_ = -QString(optarg).toInt(&ok);
|
||||
if (!ok) volume_modifier_ = 0;
|
||||
break;
|
||||
|
||||
case SeekTo:
|
||||
case LongOptions::SeekTo:
|
||||
seek_to_ = QString(optarg).toInt(&ok);
|
||||
if (!ok) seek_to_ = -1;
|
||||
break;
|
||||
|
||||
case SeekBy:
|
||||
case LongOptions::SeekBy:
|
||||
seek_by_ = QString(optarg).toInt(&ok);
|
||||
if (!ok) seek_by_ = 0;
|
||||
break;
|
||||
|
||||
case RestartOrPrevious:
|
||||
player_action_ = Player_RestartOrPrevious;
|
||||
case LongOptions::RestartOrPrevious:
|
||||
player_action_ = PlayerAction::RestartOrPrevious;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
@@ -297,7 +297,7 @@ bool CommandlineOptions::Parse() {
|
||||
|
||||
case 'w':
|
||||
window_size_ = QString(optarg);
|
||||
player_action_ = Player_ResizeWindow;
|
||||
player_action_ = PlayerAction::ResizeWindow;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
@@ -323,7 +323,7 @@ bool CommandlineOptions::Parse() {
|
||||
}
|
||||
|
||||
bool CommandlineOptions::is_empty() const {
|
||||
return player_action_ == Player_None &&
|
||||
return player_action_ == PlayerAction::None &&
|
||||
set_volume_ == -1 &&
|
||||
volume_modifier_ == 0 &&
|
||||
seek_to_ == -1 &&
|
||||
@@ -335,7 +335,7 @@ bool CommandlineOptions::is_empty() const {
|
||||
}
|
||||
|
||||
bool CommandlineOptions::contains_play_options() const {
|
||||
return player_action_ != Player_None || play_track_at_ != -1 || !urls_.isEmpty();
|
||||
return player_action_ != PlayerAction::None || play_track_at_ != -1 || !urls_.isEmpty();
|
||||
}
|
||||
|
||||
QByteArray CommandlineOptions::Serialize() const {
|
||||
|
||||
@@ -41,24 +41,24 @@ class CommandlineOptions {
|
||||
|
||||
// Don't change the values or order, these get serialised and sent to
|
||||
// possibly a different version of Strawberry
|
||||
enum UrlListAction {
|
||||
UrlList_Append = 0,
|
||||
UrlList_Load = 1,
|
||||
UrlList_None = 2,
|
||||
UrlList_CreateNew = 3,
|
||||
enum class UrlListAction {
|
||||
Append = 0,
|
||||
Load = 1,
|
||||
None = 2,
|
||||
CreateNew = 3
|
||||
};
|
||||
enum PlayerAction {
|
||||
Player_None = 0,
|
||||
Player_Play = 1,
|
||||
Player_PlayPause = 2,
|
||||
Player_Pause = 3,
|
||||
Player_Stop = 4,
|
||||
Player_Previous = 5,
|
||||
Player_Next = 6,
|
||||
Player_RestartOrPrevious = 7,
|
||||
Player_StopAfterCurrent = 8,
|
||||
Player_PlayPlaylist = 9,
|
||||
Player_ResizeWindow = 10
|
||||
enum class PlayerAction {
|
||||
None = 0,
|
||||
Play = 1,
|
||||
PlayPause = 2,
|
||||
Pause = 3,
|
||||
Stop = 4,
|
||||
Previous = 5,
|
||||
Next = 6,
|
||||
RestartOrPrevious = 7,
|
||||
StopAfterCurrent = 8,
|
||||
PlayPlaylist = 9,
|
||||
ResizeWindow = 10
|
||||
};
|
||||
|
||||
bool Parse();
|
||||
|
||||
@@ -536,7 +536,8 @@ void Database::DoBackup() {
|
||||
|
||||
bool Database::OpenDatabase(const QString &filename, sqlite3 **connection) {
|
||||
|
||||
int ret = sqlite3_open(filename.toUtf8(), connection);
|
||||
const QByteArray filename_data = filename.toUtf8();
|
||||
int ret = sqlite3_open(filename_data.constData(), connection);
|
||||
if (ret != 0) {
|
||||
if (*connection) {
|
||||
const char *error_message = sqlite3_errmsg(*connection);
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
#include <QString>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "utilities.h"
|
||||
#include "utilities/fileutils.h"
|
||||
#include "musicstorage.h"
|
||||
|
||||
#include "filesystemmusicstorage.h"
|
||||
|
||||
FilesystemMusicStorage::FilesystemMusicStorage(const QString &root, const std::optional<int> collection_directory_id) : root_(root), collection_directory_id_(collection_directory_id) {}
|
||||
FilesystemMusicStorage::FilesystemMusicStorage(const Song::Source source, const QString &root, const std::optional<int> collection_directory_id) : source_(source), root_(root), collection_directory_id_(collection_directory_id) {}
|
||||
|
||||
bool FilesystemMusicStorage::CopyToStorage(const CopyJob &job) {
|
||||
|
||||
@@ -106,12 +106,7 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
|
||||
|
||||
if (job.use_trash_) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
if (fileInfo.isDir()) {
|
||||
return Utilities::MoveToTrashRecursive(path);
|
||||
}
|
||||
else {
|
||||
return QFile::moveToTrash(path);
|
||||
}
|
||||
return QFile::moveToTrash(path);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -28,12 +28,14 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "song.h"
|
||||
#include "musicstorage.h"
|
||||
|
||||
class FilesystemMusicStorage : public virtual MusicStorage {
|
||||
public:
|
||||
explicit FilesystemMusicStorage(const QString &root, const std::optional<int> collection_directory_id = std::optional<int>());
|
||||
explicit FilesystemMusicStorage(const Song::Source source, const QString &root, const std::optional<int> collection_directory_id = std::optional<int>());
|
||||
|
||||
Song::Source source() const override { return source_; }
|
||||
QString LocalPath() const override { return root_; }
|
||||
std::optional<int> collection_directory_id() const override { return collection_directory_id_; }
|
||||
|
||||
@@ -41,6 +43,7 @@ class FilesystemMusicStorage : public virtual MusicStorage {
|
||||
bool DeleteFromStorage(const DeleteJob &job) override;
|
||||
|
||||
private:
|
||||
Song::Source source_;
|
||||
QString root_;
|
||||
std::optional<int> collection_directory_id_;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ void IconLoader::Init() {
|
||||
|
||||
}
|
||||
|
||||
QIcon IconLoader::Load(const QString &name, const int fixed_size, const int min_size, const int max_size) {
|
||||
QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fixed_size, const int min_size, const int max_size) {
|
||||
|
||||
QIcon ret;
|
||||
|
||||
@@ -69,7 +69,7 @@ QIcon IconLoader::Load(const QString &name, const int fixed_size, const int min_
|
||||
sizes << fixed_size;
|
||||
}
|
||||
|
||||
if (system_icons_) {
|
||||
if (system_icon && system_icons_) {
|
||||
IconMapper::IconProperties icon_prop;
|
||||
if (IconMapper::iconmapper_.contains(name)) {
|
||||
icon_prop = IconMapper::iconmapper_[name];
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
class IconLoader {
|
||||
public:
|
||||
static void Init();
|
||||
static QIcon Load(const QString &name, const int fixed_size = 0, const int min_size = 0, const int max_size = 0);
|
||||
static QIcon Load(const QString &name, const bool system_icon = true, const int fixed_size = 0, const int min_size = 0, const int max_size = 0);
|
||||
private:
|
||||
explicit IconLoader() {}
|
||||
static bool system_icons_;
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef ICONMAPPER_H
|
||||
#define ICONMAPPER_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -135,3 +136,6 @@ static const QMap<QString, IconProperties> iconmapper_ = { // clazy:exclude=non
|
||||
};
|
||||
|
||||
} // namespace IconMapper
|
||||
|
||||
#endif // ICONMAPPER_H
|
||||
|
||||
|
||||
@@ -1,29 +1,44 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MAC_STARTUP_H
|
||||
#define MAC_STARTUP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <CoreFoundation/CFDictionary.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QKeySequence>
|
||||
|
||||
class QObject;
|
||||
class QWidget;
|
||||
#ifdef __OBJC__
|
||||
@class NSEvent;
|
||||
#else
|
||||
class NSEvent;
|
||||
#endif
|
||||
|
||||
class PlatformInterface;
|
||||
class GlobalShortcutsBackendMacOS;
|
||||
|
||||
class PlatformInterface {
|
||||
public:
|
||||
PlatformInterface() = default;
|
||||
virtual ~PlatformInterface() {}
|
||||
|
||||
// Called when the application should show itself.
|
||||
virtual void Activate() = 0;
|
||||
virtual bool LoadUrl(const QString &url) = 0;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(PlatformInterface)
|
||||
};
|
||||
|
||||
namespace mac {
|
||||
|
||||
void MacMain();
|
||||
@@ -32,6 +47,9 @@ void SetApplicationHandler(PlatformInterface *handler);
|
||||
|
||||
void EnableFullScreen(const QWidget &main_window);
|
||||
|
||||
QKeySequence KeySequenceFromNSEvent(NSEvent *event);
|
||||
void DumpDictionary(CFDictionaryRef dict);
|
||||
|
||||
} // namespace mac
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,13 +45,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "platforminterface.h"
|
||||
#include "mac_delegate.h"
|
||||
#include "mac_startup.h"
|
||||
#include "mac_utilities.h"
|
||||
#include "utilities.h"
|
||||
#include "scoped_cftyperef.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/scoped_nsautorelease_pool.h"
|
||||
#include "scoped_nsautorelease_pool.h"
|
||||
#include "globalshortcuts/globalshortcutsmanager.h"
|
||||
#include "globalshortcuts/globalshortcutsbackend-macos.h"
|
||||
|
||||
|
||||
@@ -74,13 +74,10 @@
|
||||
#include <QClipboard>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "utilities.h"
|
||||
#include "timeconstants.h"
|
||||
#include "commandlineoptions.h"
|
||||
#include "mimedata.h"
|
||||
#include "iconloader.h"
|
||||
@@ -91,14 +88,18 @@
|
||||
#include "application.h"
|
||||
#include "database.h"
|
||||
#include "player.h"
|
||||
#include "appearance.h"
|
||||
#include "filesystemmusicstorage.h"
|
||||
#include "deletefiles.h"
|
||||
#ifdef Q_OS_MACOS
|
||||
# include "mac_startup.h"
|
||||
# include "macsystemtrayicon.h"
|
||||
#else
|
||||
# include "qtsystemtrayicon.h"
|
||||
#endif
|
||||
#include "networkaccessmanager.h"
|
||||
#include "utilities/envutils.h"
|
||||
#include "utilities/filemanagerutils.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "engine/enginetype.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "engine/engine_fwd.h"
|
||||
@@ -292,13 +293,13 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
}),
|
||||
smartplaylists_view_(new SmartPlaylistsViewContainer(app, this)),
|
||||
#ifdef HAVE_SUBSONIC
|
||||
subsonic_view_(new InternetSongsView(app_, app->internet_services()->ServiceBySource(Song::Source_Subsonic), SubsonicSettingsPage::kSettingsGroup, SettingsDialog::Page_Subsonic, this)),
|
||||
subsonic_view_(new InternetSongsView(app_, app->internet_services()->ServiceBySource(Song::Source::Subsonic), SubsonicSettingsPage::kSettingsGroup, SettingsDialog::Page::Subsonic, this)),
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
tidal_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source_Tidal), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, this)),
|
||||
tidal_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source::Tidal), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page::Tidal, this)),
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
qobuz_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source_Qobuz), QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page_Qobuz, this)),
|
||||
qobuz_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source::Qobuz), QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page::Qobuz, this)),
|
||||
#endif
|
||||
radio_view_(new RadioViewContainer(this)),
|
||||
lastfm_import_dialog_(new LastFMImportDialog(app_->lastfm_import(), this)),
|
||||
@@ -330,10 +331,10 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
track_slider_timer_(new QTimer(this)),
|
||||
keep_running_(false),
|
||||
playing_widget_(true),
|
||||
doubleclick_addmode_(BehaviourSettingsPage::AddBehaviour_Append),
|
||||
doubleclick_playmode_(BehaviourSettingsPage::PlayBehaviour_Never),
|
||||
doubleclick_playlist_addmode_(BehaviourSettingsPage::PlaylistAddBehaviour_Play),
|
||||
menu_playmode_(BehaviourSettingsPage::PlayBehaviour_Never),
|
||||
doubleclick_addmode_(BehaviourSettingsPage::AddBehaviour::Append),
|
||||
doubleclick_playmode_(BehaviourSettingsPage::PlayBehaviour::Never),
|
||||
doubleclick_playlist_addmode_(BehaviourSettingsPage::PlaylistAddBehaviour::Play),
|
||||
menu_playmode_(BehaviourSettingsPage::PlayBehaviour::Never),
|
||||
initialized_(false),
|
||||
was_maximized_(true),
|
||||
was_minimized_(false),
|
||||
@@ -363,24 +364,24 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
StyleHelper::setBaseColor(palette().color(QPalette::Highlight).darker());
|
||||
|
||||
// Add tabs to the fancy tab widget
|
||||
ui_->tabs->AddTab(context_view_, "context", IconLoader::Load("strawberry"), tr("Context"));
|
||||
ui_->tabs->AddTab(collection_view_, "collection", IconLoader::Load("library-music"), tr("Collection"));
|
||||
ui_->tabs->AddTab(queue_view_, "queue", IconLoader::Load("footsteps"), tr("Queue"));
|
||||
ui_->tabs->AddTab(playlist_list_, "playlists", IconLoader::Load("view-media-playlist"), tr("Playlists"));
|
||||
ui_->tabs->AddTab(smartplaylists_view_, "smartplaylists", IconLoader::Load("view-media-playlist"), tr("Smart playlists"));
|
||||
ui_->tabs->AddTab(file_view_, "files", IconLoader::Load("document-open"), tr("Files"));
|
||||
ui_->tabs->AddTab(radio_view_, "radios", IconLoader::Load("radio"), tr("Radios"));
|
||||
ui_->tabs->AddTab(context_view_, "context", IconLoader::Load("strawberry", true, 0, 32), tr("Context"));
|
||||
ui_->tabs->AddTab(collection_view_, "collection", IconLoader::Load("library-music", true, 0, 32), tr("Collection"));
|
||||
ui_->tabs->AddTab(queue_view_, "queue", IconLoader::Load("footsteps", true, 0, 32), tr("Queue"));
|
||||
ui_->tabs->AddTab(playlist_list_, "playlists", IconLoader::Load("view-media-playlist", true, 0, 32), tr("Playlists"));
|
||||
ui_->tabs->AddTab(smartplaylists_view_, "smartplaylists", IconLoader::Load("view-media-playlist", true, 0, 32), tr("Smart playlists"));
|
||||
ui_->tabs->AddTab(file_view_, "files", IconLoader::Load("document-open", true, 0, 32), tr("Files"));
|
||||
ui_->tabs->AddTab(radio_view_, "radios", IconLoader::Load("radio", true, 0, 32), tr("Radios"));
|
||||
#ifndef Q_OS_WIN
|
||||
ui_->tabs->AddTab(device_view_, "devices", IconLoader::Load("device"), tr("Devices"));
|
||||
ui_->tabs->AddTab(device_view_, "devices", IconLoader::Load("device", true, 0, 32), tr("Devices"));
|
||||
#endif
|
||||
#ifdef HAVE_SUBSONIC
|
||||
ui_->tabs->AddTab(subsonic_view_, "subsonic", IconLoader::Load("subsonic"), tr("Subsonic"));
|
||||
ui_->tabs->AddTab(subsonic_view_, "subsonic", IconLoader::Load("subsonic", true, 0, 32), tr("Subsonic"));
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
ui_->tabs->AddTab(tidal_view_, "tidal", IconLoader::Load("tidal"), tr("Tidal"));
|
||||
ui_->tabs->AddTab(tidal_view_, "tidal", IconLoader::Load("tidal", true, 0, 32), tr("Tidal"));
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
ui_->tabs->AddTab(qobuz_view_, "qobuz", IconLoader::Load("qobuz"), tr("Qobuz"));
|
||||
ui_->tabs->AddTab(qobuz_view_, "qobuz", IconLoader::Load("qobuz", true, 0, 32), tr("Qobuz"));
|
||||
#endif
|
||||
|
||||
// Add the playing widget to the fancy tab widget
|
||||
@@ -399,8 +400,8 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
app_->player()->SetEqualizer(equalizer_.get());
|
||||
app_->player()->Init();
|
||||
EngineChanged(app_->player()->engine()->type());
|
||||
int volume = static_cast<int>(app_->player()->GetVolume());
|
||||
ui_->volume->setValue(volume);
|
||||
const uint volume = app_->player()->GetVolume();
|
||||
ui_->volume->SetValue(volume);
|
||||
VolumeChanged(volume);
|
||||
|
||||
// Models
|
||||
@@ -583,7 +584,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->stop_button->setMenu(stop_menu);
|
||||
|
||||
// Player connections
|
||||
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, app_->player(), &Player::SetVolume);
|
||||
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, app_->player(), &Player::SetVolumeFromSlider);
|
||||
|
||||
QObject::connect(app_->player(), &Player::EngineChanged, this, &MainWindow::EngineChanged);
|
||||
QObject::connect(app_->player(), &Player::Error, this, &MainWindow::ShowErrorDialog);
|
||||
@@ -606,7 +607,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(app_->player(), &Player::Stopped, osd_, &OSDBase::Stopped);
|
||||
QObject::connect(app_->player(), &Player::PlaylistFinished, osd_, &OSDBase::PlaylistFinished);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, osd_, &OSDBase::VolumeChanged);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::setValue);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::SetValue);
|
||||
QObject::connect(app_->player(), &Player::ForceShowOSD, this, &MainWindow::ForceShowOSD);
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MainWindow::SongChanged);
|
||||
@@ -674,7 +675,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
collection_show_untagged_->setCheckable(true);
|
||||
collection_show_all_->setChecked(true);
|
||||
|
||||
QObject::connect(collection_view_group, &QActionGroup::triggered, this, &MainWindow::ChangeCollectionQueryMode);
|
||||
QObject::connect(collection_view_group, &QActionGroup::triggered, this, &MainWindow::ChangeCollectionFilterMode);
|
||||
|
||||
QAction *collection_config_action = new QAction(IconLoader::Load("configure"), tr("Configure collection..."), this);
|
||||
QObject::connect(collection_config_action, &QAction::triggered, this, &MainWindow::ShowCollectionConfig);
|
||||
@@ -699,7 +700,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(tidal_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||
QObject::connect(tidal_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||
QObject::connect(tidal_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
|
||||
if (TidalService *tidalservice = qobject_cast<TidalService*>(app_->internet_services()->ServiceBySource(Song::Source_Tidal))) {
|
||||
if (TidalService *tidalservice = qobject_cast<TidalService*>(app_->internet_services()->ServiceBySource(Song::Source::Tidal))) {
|
||||
QObject::connect(this, &MainWindow::AuthorizationUrlReceived, tidalservice, &TidalService::AuthorizationUrlReceived);
|
||||
}
|
||||
#endif
|
||||
@@ -872,11 +873,6 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(ui_->action_console, &QAction::triggered, this, &MainWindow::ShowConsole);
|
||||
PlayingWidgetPositionChanged(ui_->widget_playing->show_above_status_bar());
|
||||
|
||||
// Load theme
|
||||
// This is tricky: we need to save the default/system palette now,
|
||||
// before loading user preferred theme (which will override it), to be able to restore it later
|
||||
const_cast<QPalette&>(Appearance::kDefaultPalette) = QApplication::palette();
|
||||
app_->appearance()->LoadUserTheme();
|
||||
StyleSheetLoader *css_loader = new StyleSheetLoader(this);
|
||||
css_loader->SetStyleSheet(this, ":/style/strawberry.css");
|
||||
|
||||
@@ -924,10 +920,9 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
}
|
||||
|
||||
ui_->tabs->setCurrentIndex(settings_.value("current_tab", 1).toInt());
|
||||
FancyTabWidget::Mode default_mode = FancyTabWidget::Mode_LargeSidebar;
|
||||
int tab_mode_int = settings_.value("tab_mode", default_mode).toInt();
|
||||
FancyTabWidget::Mode tab_mode = static_cast<FancyTabWidget::Mode>(tab_mode_int);
|
||||
if (tab_mode == FancyTabWidget::Mode_None) tab_mode = default_mode;
|
||||
FancyTabWidget::Mode default_mode = FancyTabWidget::Mode::LargeSidebar;
|
||||
FancyTabWidget::Mode tab_mode = static_cast<FancyTabWidget::Mode>(settings_.value("tab_mode", static_cast<int>(default_mode)).toInt());
|
||||
if (tab_mode == FancyTabWidget::Mode::None) tab_mode = default_mode;
|
||||
ui_->tabs->SetMode(tab_mode);
|
||||
|
||||
TabSwitched();
|
||||
@@ -950,26 +945,26 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
#else
|
||||
QSettings s;
|
||||
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
||||
BehaviourSettingsPage::StartupBehaviour behaviour = BehaviourSettingsPage::StartupBehaviour(s.value("startupbehaviour", BehaviourSettingsPage::Startup_Remember).toInt());
|
||||
const BehaviourSettingsPage::StartupBehaviour startupbehaviour = static_cast<BehaviourSettingsPage::StartupBehaviour>(s.value("startupbehaviour", static_cast<int>(BehaviourSettingsPage::StartupBehaviour::Remember)).toInt());
|
||||
s.endGroup();
|
||||
switch (behaviour) {
|
||||
case BehaviourSettingsPage::Startup_Show:
|
||||
switch (startupbehaviour) {
|
||||
case BehaviourSettingsPage::StartupBehaviour::Show:
|
||||
show();
|
||||
break;
|
||||
case BehaviourSettingsPage::Startup_ShowMaximized:
|
||||
case BehaviourSettingsPage::StartupBehaviour::ShowMaximized:
|
||||
setWindowState(windowState() | Qt::WindowMaximized);
|
||||
show();
|
||||
break;
|
||||
case BehaviourSettingsPage::Startup_ShowMinimized:
|
||||
case BehaviourSettingsPage::StartupBehaviour::ShowMinimized:
|
||||
setWindowState(windowState() | Qt::WindowMinimized);
|
||||
show();
|
||||
break;
|
||||
case BehaviourSettingsPage::Startup_Hide:
|
||||
case BehaviourSettingsPage::StartupBehaviour::Hide:
|
||||
if (tray_icon_->IsSystemTrayAvailable() && tray_icon_->isVisible()) {
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case BehaviourSettingsPage::Startup_Remember:
|
||||
case BehaviourSettingsPage::StartupBehaviour::Remember:
|
||||
default: {
|
||||
|
||||
was_maximized_ = settings_.value("maximized", true).toBool();
|
||||
@@ -1071,10 +1066,10 @@ void MainWindow::ReloadSettings() {
|
||||
playing_widget_ = s.value("playing_widget", true).toBool();
|
||||
bool trayicon_progress = s.value("trayicon_progress", false).toBool();
|
||||
if (playing_widget_ != ui_->widget_playing->IsEnabled()) TabSwitched();
|
||||
doubleclick_addmode_ = BehaviourSettingsPage::AddBehaviour(s.value("doubleclick_addmode", BehaviourSettingsPage::AddBehaviour_Append).toInt());
|
||||
doubleclick_playmode_ = BehaviourSettingsPage::PlayBehaviour(s.value("doubleclick_playmode", BehaviourSettingsPage::PlayBehaviour_Never).toInt());
|
||||
doubleclick_playlist_addmode_ = BehaviourSettingsPage::PlaylistAddBehaviour(s.value("doubleclick_playlist_addmode", BehaviourSettingsPage::PlayBehaviour_Never).toInt());
|
||||
menu_playmode_ = BehaviourSettingsPage::PlayBehaviour(s.value("menu_playmode", BehaviourSettingsPage::PlayBehaviour_Never).toInt());
|
||||
doubleclick_addmode_ = static_cast<BehaviourSettingsPage::AddBehaviour>(s.value("doubleclick_addmode", static_cast<int>(BehaviourSettingsPage::AddBehaviour::Append)).toInt());
|
||||
doubleclick_playmode_ = static_cast<BehaviourSettingsPage::PlayBehaviour>(s.value("doubleclick_playmode", static_cast<int>(BehaviourSettingsPage::PlayBehaviour::Never)).toInt());
|
||||
doubleclick_playlist_addmode_ = static_cast<BehaviourSettingsPage::PlaylistAddBehaviour>(s.value("doubleclick_playlist_addmode", static_cast<int>(BehaviourSettingsPage::PlayBehaviour::Never)).toInt());
|
||||
menu_playmode_ = static_cast<BehaviourSettingsPage::PlayBehaviour>(s.value("menu_playmode", static_cast<int>(BehaviourSettingsPage::PlayBehaviour::Never)).toInt());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
@@ -1201,6 +1196,7 @@ void MainWindow::SaveSettings() {
|
||||
|
||||
SaveGeometry();
|
||||
SavePlaybackStatus();
|
||||
app_->player()->SaveVolume();
|
||||
ui_->tabs->SaveSettings(kSettingsGroup);
|
||||
ui_->playlist->view()->SaveSettings();
|
||||
app_->scrobbler()->WriteCache();
|
||||
@@ -1227,7 +1223,7 @@ void MainWindow::Exit() {
|
||||
if (app_->player()->engine()->is_fadeout_enabled()) {
|
||||
// To shut down the application when fadeout will be finished
|
||||
QObject::connect(app_->player()->engine(), &EngineBase::FadeoutFinishedSignal, this, &MainWindow::DoExit);
|
||||
if (app_->player()->GetState() == Engine::Playing) {
|
||||
if (app_->player()->GetState() == Engine::State::Playing) {
|
||||
app_->player()->Stop();
|
||||
ignore_close_ = true;
|
||||
close();
|
||||
@@ -1325,8 +1321,8 @@ void MainWindow::MediaPlaying() {
|
||||
|
||||
PlaylistItemPtr item(app_->player()->GetCurrentItem());
|
||||
if (item) {
|
||||
enable_play_pause = !(item->options() & PlaylistItem::PauseDisabled);
|
||||
can_seek = !(item->options() & PlaylistItem::SeekDisabled);
|
||||
enable_play_pause = !(item->options() & PlaylistItem::Option::PauseDisabled);
|
||||
can_seek = !(item->options() & PlaylistItem::Option::SeekDisabled);
|
||||
}
|
||||
ui_->action_play_pause->setEnabled(enable_play_pause);
|
||||
ui_->track_slider->SetCanSeek(can_seek);
|
||||
@@ -1351,7 +1347,7 @@ void MainWindow::SendNowPlaying() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::VolumeChanged(const int volume) {
|
||||
void MainWindow::VolumeChanged(const uint volume) {
|
||||
ui_->action_mute->setChecked(volume == 0);
|
||||
tray_icon_->MuteButtonStateChanged(volume == 0);
|
||||
}
|
||||
@@ -1440,8 +1436,8 @@ void MainWindow::SavePlaybackStatus() {
|
||||
QSettings s;
|
||||
|
||||
s.beginGroup(Player::kSettingsGroup);
|
||||
s.setValue("playback_state", app_->player()->GetState());
|
||||
if (app_->player()->GetState() == Engine::Playing || app_->player()->GetState() == Engine::Paused) {
|
||||
s.setValue("playback_state", static_cast<int>(app_->player()->GetState()));
|
||||
if (app_->player()->GetState() == Engine::State::Playing || app_->player()->GetState() == Engine::State::Paused) {
|
||||
s.setValue("playback_playlist", app_->playlist_manager()->active()->id());
|
||||
s.setValue("playback_position", app_->player()->engine()->position_nanosec() / kNsecPerSec);
|
||||
}
|
||||
@@ -1459,14 +1455,14 @@ void MainWindow::LoadPlaybackStatus() {
|
||||
QSettings s;
|
||||
|
||||
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
||||
bool resume_playback = s.value("resumeplayback", false).toBool();
|
||||
const bool resume_playback = s.value("resumeplayback", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(Player::kSettingsGroup);
|
||||
Engine::State playback_state = static_cast<Engine::State>(s.value("playback_state", Engine::Empty).toInt());
|
||||
const Engine::State playback_state = static_cast<Engine::State>(s.value("playback_state", static_cast<int>(Engine::State::Empty)).toInt());
|
||||
s.endGroup();
|
||||
|
||||
if (resume_playback && playback_state != Engine::Empty && playback_state != Engine::Idle) {
|
||||
if (resume_playback && playback_state != Engine::State::Empty && playback_state != Engine::State::Idle) {
|
||||
std::shared_ptr<QMetaObject::Connection> connection = std::make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, [this, connection]() {
|
||||
QObject::disconnect(*connection);
|
||||
@@ -1482,7 +1478,7 @@ void MainWindow::ResumePlayback() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(Player::kSettingsGroup);
|
||||
Engine::State playback_state = static_cast<Engine::State>(s.value("playback_state", Engine::Empty).toInt());
|
||||
const Engine::State playback_state = static_cast<Engine::State>(s.value("playback_state", static_cast<int>(Engine::State::Empty)).toInt());
|
||||
int playback_playlist = s.value("playback_playlist", -1).toInt();
|
||||
int playback_position = s.value("playback_position", 0).toInt();
|
||||
s.endGroup();
|
||||
@@ -1490,7 +1486,7 @@ void MainWindow::ResumePlayback() {
|
||||
if (playback_playlist == app_->playlist_manager()->current()->id()) {
|
||||
// Set active to current to resume playback on correct playlist.
|
||||
app_->playlist_manager()->SetActiveToCurrent();
|
||||
if (playback_state == Engine::Paused) {
|
||||
if (playback_state == Engine::State::Paused) {
|
||||
std::shared_ptr<QMetaObject::Connection> connection = std::make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(app_->player(), &Player::Playing, app_->player(), [this, connection]() {
|
||||
QObject::disconnect(*connection);
|
||||
@@ -1502,7 +1498,7 @@ void MainWindow::ResumePlayback() {
|
||||
|
||||
// Reset saved playback status so we don't resume again from the same position.
|
||||
s.beginGroup(Player::kSettingsGroup);
|
||||
s.setValue("playback_state", Engine::Empty);
|
||||
s.setValue("playback_state", static_cast<int>(Engine::State::Empty));
|
||||
s.setValue("playback_playlist", -1);
|
||||
s.setValue("playback_position", 0);
|
||||
s.endGroup();
|
||||
@@ -1520,7 +1516,7 @@ void MainWindow::PlayIndex(const QModelIndex &idx, Playlist::AutoScroll autoscro
|
||||
}
|
||||
|
||||
app_->playlist_manager()->SetActiveToCurrent();
|
||||
app_->player()->PlayAt(row, 0, Engine::Manual, autoscroll, true);
|
||||
app_->player()->PlayAt(row, 0, Engine::TrackChangeType::Manual, autoscroll, true);
|
||||
|
||||
}
|
||||
|
||||
@@ -1535,16 +1531,16 @@ void MainWindow::PlaylistDoubleClick(const QModelIndex &idx) {
|
||||
}
|
||||
|
||||
switch (doubleclick_playlist_addmode_) {
|
||||
case BehaviourSettingsPage::PlaylistAddBehaviour_Play:
|
||||
case BehaviourSettingsPage::PlaylistAddBehaviour::Play:
|
||||
app_->playlist_manager()->SetActiveToCurrent();
|
||||
app_->player()->PlayAt(source_idx.row(), 0, Engine::Manual, Playlist::AutoScroll_Never, true, true);
|
||||
app_->player()->PlayAt(source_idx.row(), 0, Engine::TrackChangeType::Manual, Playlist::AutoScroll::Never, true, true);
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::PlaylistAddBehaviour_Enqueue:
|
||||
case BehaviourSettingsPage::PlaylistAddBehaviour::Enqueue:
|
||||
app_->playlist_manager()->current()->queue()->ToggleTracks(QModelIndexList() << source_idx);
|
||||
if (app_->player()->GetState() != Engine::Playing) {
|
||||
if (app_->player()->GetState() != Engine::State::Playing) {
|
||||
app_->playlist_manager()->SetActiveToCurrent();
|
||||
app_->player()->PlayAt(app_->playlist_manager()->current()->queue()->TakeNext(), 0, Engine::Manual, Playlist::AutoScroll_Never, true);
|
||||
app_->player()->PlayAt(app_->playlist_manager()->current()->queue()->TakeNext(), 0, Engine::TrackChangeType::Manual, Playlist::AutoScroll::Never, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1697,22 +1693,22 @@ void MainWindow::UpdateTrackSliderPosition() {
|
||||
void MainWindow::ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) {
|
||||
|
||||
switch (b) {
|
||||
case BehaviourSettingsPage::AddBehaviour_Append:
|
||||
case BehaviourSettingsPage::AddBehaviour::Append:
|
||||
mimedata->clear_first_ = false;
|
||||
mimedata->enqueue_now_ = false;
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::AddBehaviour_Enqueue:
|
||||
case BehaviourSettingsPage::AddBehaviour::Enqueue:
|
||||
mimedata->clear_first_ = false;
|
||||
mimedata->enqueue_now_ = true;
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::AddBehaviour_Load:
|
||||
case BehaviourSettingsPage::AddBehaviour::Load:
|
||||
mimedata->clear_first_ = true;
|
||||
mimedata->enqueue_now_ = false;
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::AddBehaviour_OpenInNew:
|
||||
case BehaviourSettingsPage::AddBehaviour::OpenInNew:
|
||||
mimedata->open_in_new_playlist_ = true;
|
||||
break;
|
||||
}
|
||||
@@ -1721,16 +1717,16 @@ void MainWindow::ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b,
|
||||
void MainWindow::ApplyPlayBehaviour(const BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const {
|
||||
|
||||
switch (b) {
|
||||
case BehaviourSettingsPage::PlayBehaviour_Always:
|
||||
case BehaviourSettingsPage::PlayBehaviour::Always:
|
||||
mimedata->play_now_ = true;
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::PlayBehaviour_Never:
|
||||
case BehaviourSettingsPage::PlayBehaviour::Never:
|
||||
mimedata->play_now_ = false;
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::PlayBehaviour_IfStopped:
|
||||
mimedata->play_now_ = !(app_->player()->GetState() == Engine::Playing);
|
||||
case BehaviourSettingsPage::PlayBehaviour::IfStopped:
|
||||
mimedata->play_now_ = !(app_->player()->GetState() == Engine::State::Playing);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1765,7 +1761,7 @@ void MainWindow::AddToPlaylist(QMimeData *q_mimedata) {
|
||||
void MainWindow::AddToPlaylistFromAction(QAction *action) {
|
||||
|
||||
const int destination = action->data().toInt();
|
||||
PlaylistItemList items;
|
||||
PlaylistItemPtrList items;
|
||||
SongList songs;
|
||||
|
||||
// Get the selected playlist items
|
||||
@@ -1816,7 +1812,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
||||
playlist_menu_index_ = source_index;
|
||||
|
||||
// Is this song currently playing?
|
||||
if (app_->playlist_manager()->current()->current_row() == source_index.row() && app_->player()->GetState() == Engine::Playing) {
|
||||
if (app_->playlist_manager()->current()->current_row() == source_index.row() && app_->player()->GetState() == Engine::State::Playing) {
|
||||
playlist_play_pause_->setText(tr("Pause"));
|
||||
playlist_play_pause_->setIcon(IconLoader::Load("media-playback-pause"));
|
||||
}
|
||||
@@ -1827,7 +1823,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
||||
|
||||
// Are we allowed to pause?
|
||||
if (source_index.isValid()) {
|
||||
playlist_play_pause_->setEnabled(app_->playlist_manager()->current()->current_row() != source_index.row() || !(app_->playlist_manager()->current()->item_at(source_index.row())->options() & PlaylistItem::PauseDisabled));
|
||||
playlist_play_pause_->setEnabled(app_->playlist_manager()->current()->current_row() != source_index.row() || !(app_->playlist_manager()->current()->item_at(source_index.row())->options() & PlaylistItem::Option::PauseDisabled));
|
||||
}
|
||||
else {
|
||||
playlist_play_pause_->setEnabled(false);
|
||||
@@ -1856,7 +1852,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
||||
if (!item) continue;
|
||||
|
||||
if (item->Metadata().url().isLocalFile()) ++local_songs;
|
||||
if (item->Metadata().source() == Song::Source_Collection) ++collection_songs;
|
||||
if (item->Metadata().source() == Song::Source::Collection) ++collection_songs;
|
||||
|
||||
if (item->Metadata().has_cue()) {
|
||||
cue_selected = true;
|
||||
@@ -2036,10 +2032,10 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
||||
void MainWindow::PlaylistPlay() {
|
||||
|
||||
if (app_->playlist_manager()->current()->current_row() == playlist_menu_index_.row()) {
|
||||
app_->player()->PlayPause(Playlist::AutoScroll_Never);
|
||||
app_->player()->PlayPause(0, Playlist::AutoScroll::Never);
|
||||
}
|
||||
else {
|
||||
PlayIndex(playlist_menu_index_, Playlist::AutoScroll_Never);
|
||||
PlayIndex(playlist_menu_index_, Playlist::AutoScroll::Never);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2060,7 +2056,7 @@ void MainWindow::RescanSongs() {
|
||||
if (item->IsLocalCollectionItem()) {
|
||||
songs << item->Metadata();
|
||||
}
|
||||
else if (item->Metadata().source() == Song::Source_LocalFile) {
|
||||
else if (item->Metadata().source() == Song::Source::LocalFile) {
|
||||
QPersistentModelIndex persistent_index = QPersistentModelIndex(source_index);
|
||||
app_->playlist_manager()->current()->ItemReload(persistent_index, item->OriginalMetadata(), false);
|
||||
}
|
||||
@@ -2075,7 +2071,7 @@ void MainWindow::RescanSongs() {
|
||||
void MainWindow::EditTracks() {
|
||||
|
||||
SongList songs;
|
||||
PlaylistItemList items;
|
||||
PlaylistItemPtrList items;
|
||||
|
||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||
@@ -2167,7 +2163,7 @@ void MainWindow::SelectionSetValue() {
|
||||
QPersistentModelIndex persistent_index = QPersistentModelIndex(source_index);
|
||||
QObject::connect(reply, &TagReaderReply::Finished, this, [this, reply, persistent_index]() { SongSaveComplete(reply, persistent_index); }, Qt::QueuedConnection);
|
||||
}
|
||||
else if (song.source() == Song::Source_Stream) {
|
||||
else if (song.source() == Song::Source::Stream) {
|
||||
app_->playlist_manager()->current()->setData(source_index, column_value, 0);
|
||||
}
|
||||
}
|
||||
@@ -2202,7 +2198,7 @@ void MainWindow::AddFile() {
|
||||
PlaylistParser parser(app_->collection_backend());
|
||||
|
||||
// Show dialog
|
||||
QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QString("%1 (%2);;%3;;%4").arg(tr("Music"), FileView::kFileFilter, parser.filters(PlaylistParser::Type_Load), tr(kAllFilesFilterSpec)));
|
||||
QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QString("%1 (%2);;%3;;%4").arg(tr("Music"), FileView::kFileFilter, parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
|
||||
|
||||
if (file_names.isEmpty()) return;
|
||||
|
||||
@@ -2338,30 +2334,30 @@ void MainWindow::CommandlineOptionsReceived(const quint32 instanceId, const QByt
|
||||
void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
|
||||
switch (options.player_action()) {
|
||||
case CommandlineOptions::Player_Play:
|
||||
case CommandlineOptions::PlayerAction::Play:
|
||||
if (options.urls().empty()) {
|
||||
app_->player()->Play();
|
||||
}
|
||||
break;
|
||||
case CommandlineOptions::Player_PlayPause:
|
||||
app_->player()->PlayPause(Playlist::AutoScroll_Maybe);
|
||||
case CommandlineOptions::PlayerAction::PlayPause:
|
||||
app_->player()->PlayPause(0, Playlist::AutoScroll::Maybe);
|
||||
break;
|
||||
case CommandlineOptions::Player_Pause:
|
||||
case CommandlineOptions::PlayerAction::Pause:
|
||||
app_->player()->Pause();
|
||||
break;
|
||||
case CommandlineOptions::Player_Stop:
|
||||
case CommandlineOptions::PlayerAction::Stop:
|
||||
app_->player()->Stop();
|
||||
break;
|
||||
case CommandlineOptions::Player_StopAfterCurrent:
|
||||
case CommandlineOptions::PlayerAction::StopAfterCurrent:
|
||||
app_->player()->StopAfterCurrent();
|
||||
break;
|
||||
case CommandlineOptions::Player_Previous:
|
||||
case CommandlineOptions::PlayerAction::Previous:
|
||||
app_->player()->Previous();
|
||||
break;
|
||||
case CommandlineOptions::Player_Next:
|
||||
case CommandlineOptions::PlayerAction::Next:
|
||||
app_->player()->Next();
|
||||
break;
|
||||
case CommandlineOptions::Player_PlayPlaylist:
|
||||
case CommandlineOptions::PlayerAction::PlayPlaylist:
|
||||
if (options.playlist_name().isEmpty()) {
|
||||
qLog(Error) << "ERROR: playlist name missing";
|
||||
}
|
||||
@@ -2369,11 +2365,11 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
app_->player()->PlayPlaylist(options.playlist_name());
|
||||
}
|
||||
break;
|
||||
case CommandlineOptions::Player_RestartOrPrevious:
|
||||
case CommandlineOptions::PlayerAction::RestartOrPrevious:
|
||||
app_->player()->RestartOrPrevious();
|
||||
break;
|
||||
|
||||
case CommandlineOptions::Player_ResizeWindow:{
|
||||
case CommandlineOptions::PlayerAction::ResizeWindow:{
|
||||
if (options.window_size().contains('x') && options.window_size().length() >= 4) {
|
||||
QString str_w = options.window_size().left(options.window_size().indexOf('x'));
|
||||
QString str_h = options.window_size().right(options.window_size().length() - options.window_size().indexOf('x') - 1);
|
||||
@@ -2410,7 +2406,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandlineOptions::Player_None:
|
||||
case CommandlineOptions::PlayerAction::None:
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -2430,22 +2426,22 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
// Behaviour depends on command line options, so set it here
|
||||
mimedata->override_user_settings_ = true;
|
||||
|
||||
if (options.player_action() == CommandlineOptions::Player_Play) mimedata->play_now_ = true;
|
||||
if (options.player_action() == CommandlineOptions::PlayerAction::Play) mimedata->play_now_ = true;
|
||||
else ApplyPlayBehaviour(doubleclick_playmode_, mimedata);
|
||||
|
||||
switch (options.url_list_action()) {
|
||||
case CommandlineOptions::UrlList_Load:
|
||||
case CommandlineOptions::UrlListAction::Load:
|
||||
mimedata->clear_first_ = true;
|
||||
break;
|
||||
case CommandlineOptions::UrlList_Append:
|
||||
case CommandlineOptions::UrlListAction::Append:
|
||||
// Nothing to do
|
||||
break;
|
||||
case CommandlineOptions::UrlList_None:
|
||||
case CommandlineOptions::UrlListAction::None:
|
||||
ApplyAddBehaviour(doubleclick_addmode_, mimedata);
|
||||
break;
|
||||
case CommandlineOptions::UrlList_CreateNew:
|
||||
case CommandlineOptions::UrlListAction::CreateNew:
|
||||
mimedata->name_for_new_playlist_ = options.playlist_name();
|
||||
ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour_OpenInNew, mimedata);
|
||||
ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour::OpenInNew, mimedata);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2465,7 +2461,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
app_->player()->SeekTo(app_->player()->engine()->position_nanosec() / kNsecPerSec + options.seek_by());
|
||||
}
|
||||
|
||||
if (options.play_track_at() != -1) app_->player()->PlayAt(options.play_track_at(), 0, Engine::Manual, Playlist::AutoScroll_Maybe, true);
|
||||
if (options.play_track_at() != -1) app_->player()->PlayAt(options.play_track_at(), 0, Engine::TrackChangeType::Manual, Playlist::AutoScroll::Maybe, true);
|
||||
|
||||
if (options.show_osd()) app_->player()->ShowOSD();
|
||||
|
||||
@@ -2543,7 +2539,7 @@ void MainWindow::AddFilesToTranscoder() {
|
||||
}
|
||||
|
||||
void MainWindow::ShowCollectionConfig() {
|
||||
settings_dialog_->OpenAtPage(SettingsDialog::Page_Collection);
|
||||
settings_dialog_->OpenAtPage(SettingsDialog::Page::Collection);
|
||||
}
|
||||
|
||||
void MainWindow::TaskCountChanged(const int count) {
|
||||
@@ -2613,7 +2609,7 @@ void MainWindow::EditFileTags(const QList<QUrl> &urls) {
|
||||
Song song;
|
||||
song.set_url(url);
|
||||
song.set_valid(true);
|
||||
song.set_filetype(Song::FileType_MPEG);
|
||||
song.set_filetype(Song::FileType::MPEG);
|
||||
songs << song;
|
||||
}
|
||||
|
||||
@@ -2755,16 +2751,16 @@ void MainWindow::PlaylistCopyToDevice() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::ChangeCollectionQueryMode(QAction *action) {
|
||||
void MainWindow::ChangeCollectionFilterMode(QAction *action) {
|
||||
|
||||
if (action == collection_show_duplicates_) {
|
||||
collection_view_->filter_widget()->SetQueryMode(QueryOptions::QueryMode_Duplicates);
|
||||
collection_view_->filter_widget()->SetFilterMode(CollectionFilterOptions::FilterMode::Duplicates);
|
||||
}
|
||||
else if (action == collection_show_untagged_) {
|
||||
collection_view_->filter_widget()->SetQueryMode(QueryOptions::QueryMode_Untagged);
|
||||
collection_view_->filter_widget()->SetFilterMode(CollectionFilterOptions::FilterMode::Untagged);
|
||||
}
|
||||
else {
|
||||
collection_view_->filter_widget()->SetQueryMode(QueryOptions::QueryMode_All);
|
||||
collection_view_->filter_widget()->SetFilterMode(CollectionFilterOptions::FilterMode::All);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2975,7 +2971,7 @@ void MainWindow::HandleNotificationPreview(const OSDBase::Behaviour type, const
|
||||
else {
|
||||
qLog(Debug) << "The current playlist is empty, showing a fake song";
|
||||
// Create a fake song
|
||||
Song fake(Song::Source_LocalFile);
|
||||
Song fake(Song::Source::LocalFile);
|
||||
fake.Init("Title", "Artist", "Album", 123);
|
||||
fake.set_genre("Classical");
|
||||
fake.set_composer("Anonymous");
|
||||
@@ -2999,7 +2995,7 @@ void MainWindow::ShowConsole() {
|
||||
void MainWindow::keyPressEvent(QKeyEvent *e) {
|
||||
|
||||
if (e->key() == Qt::Key_Space) {
|
||||
app_->player()->PlayPause(Playlist::AutoScroll_Never);
|
||||
app_->player()->PlayPause(0, Playlist::AutoScroll::Never);
|
||||
e->accept();
|
||||
}
|
||||
else if (e->key() == Qt::Key_Left) {
|
||||
@@ -3122,12 +3118,12 @@ void MainWindow::SetToggleScrobblingIcon(const bool value) {
|
||||
|
||||
if (value) {
|
||||
if (app_->playlist_manager()->active() && app_->playlist_manager()->active()->scrobbled())
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22));
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", true, 22));
|
||||
else
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22)); // TODO: Create a faint version of the icon
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", true, 22)); // TODO: Create a faint version of the icon
|
||||
}
|
||||
else {
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble-disabled", 22));
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble-disabled", true, 22));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3162,17 +3158,17 @@ void MainWindow::PlaylistDelete() {
|
||||
|
||||
if (DeleteConfirmationDialog::warning(files) != QDialogButtonBox::Yes) return;
|
||||
|
||||
if (app_->player()->GetState() == Engine::Playing && app_->playlist_manager()->current()->rowCount() == selected_songs.count()) {
|
||||
if (app_->player()->GetState() == Engine::State::Playing && app_->playlist_manager()->current()->rowCount() == selected_songs.count()) {
|
||||
app_->player()->Stop();
|
||||
}
|
||||
|
||||
ui_->playlist->view()->RemoveSelected();
|
||||
|
||||
if (app_->player()->GetState() == Engine::Playing && is_current_item) {
|
||||
if (app_->player()->GetState() == Engine::State::Playing && is_current_item) {
|
||||
app_->player()->Next();
|
||||
}
|
||||
|
||||
std::shared_ptr<MusicStorage> storage = std::make_shared<FilesystemMusicStorage>("/");
|
||||
std::shared_ptr<MusicStorage> storage = std::make_shared<FilesystemMusicStorage>(Song::Source::LocalFile, "/");
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
||||
//QObject::connect(delete_files, &DeleteFiles::Finished, this, &MainWindow::DeleteFinished);
|
||||
delete_files->Start(selected_songs);
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
#include <QSettings>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/lazy.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "core/song.h"
|
||||
#include "lazy.h"
|
||||
#include "platforminterface.h"
|
||||
#include "song.h"
|
||||
#include "tagreaderclient.h"
|
||||
#include "engine/enginetype.h"
|
||||
#include "engine/engine_fwd.h"
|
||||
#include "mac_startup.h"
|
||||
#include "osd/osdbase.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "playlist/playlist.h"
|
||||
@@ -180,14 +180,14 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void PlaylistCopyUrl();
|
||||
void ShowInCollection();
|
||||
|
||||
void ChangeCollectionQueryMode(QAction *action);
|
||||
void ChangeCollectionFilterMode(QAction *action);
|
||||
|
||||
void PlayIndex(const QModelIndex &idx, Playlist::AutoScroll autoscroll);
|
||||
void PlaylistDoubleClick(const QModelIndex &idx);
|
||||
void StopAfterCurrent();
|
||||
|
||||
void SongChanged(const Song &song);
|
||||
void VolumeChanged(const int volume);
|
||||
void VolumeChanged(const uint volume);
|
||||
|
||||
void CopyFilesToCollection(const QList<QUrl> &urls);
|
||||
void MoveFilesToCollection(const QList<QUrl> &urls);
|
||||
@@ -331,7 +331,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
std::unique_ptr<TagFetcher> tag_fetcher_;
|
||||
#endif
|
||||
std::unique_ptr<TrackSelectionDialog> track_selection_dialog_;
|
||||
PlaylistItemList autocomplete_tag_items_;
|
||||
PlaylistItemPtrList autocomplete_tag_items_;
|
||||
|
||||
SmartPlaylistsViewContainer *smartplaylists_view_;
|
||||
|
||||
|
||||
@@ -71,13 +71,7 @@ struct tag_by_pointer {};
|
||||
|
||||
class MergedProxyModelPrivate {
|
||||
private:
|
||||
typedef multi_index_container<
|
||||
Mapping*,
|
||||
indexed_by<
|
||||
hashed_unique<tag<tag_by_source>,
|
||||
member<Mapping, QModelIndex, &Mapping::source_index> >,
|
||||
ordered_unique<tag<tag_by_pointer>, identity<Mapping*> > > >
|
||||
MappingContainer;
|
||||
using MappingContainer = multi_index_container<Mapping *, indexed_by<hashed_unique<tag<tag_by_source>, member<Mapping, QModelIndex, &Mapping::source_index>>, ordered_unique<tag<tag_by_pointer>, identity<Mapping *>>>>;
|
||||
|
||||
public:
|
||||
MappingContainer mappings_;
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <QByteArray>
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
#include <QNetworkCookie>
|
||||
#include <QNetworkReply>
|
||||
#include <QItemSelection>
|
||||
#ifdef HAVE_DBUS
|
||||
@@ -54,7 +53,7 @@
|
||||
#ifdef HAVE_GSTREAMER
|
||||
# include "engine/gstenginepipeline.h"
|
||||
#endif
|
||||
#include "collection/directory.h"
|
||||
#include "collection/collectiondirectory.h"
|
||||
#include "playlist/playlistitem.h"
|
||||
#include "playlist/playlistsequence.h"
|
||||
#include "covermanager/albumcoverloaderresult.h"
|
||||
@@ -78,17 +77,18 @@
|
||||
# include "device/mtpconnection.h"
|
||||
#endif
|
||||
|
||||
#include "settings/playlistsettingspage.h"
|
||||
|
||||
#include "smartplaylists/smartplaylistsearchterm.h"
|
||||
#include "smartplaylists/smartplaylistsitem.h"
|
||||
|
||||
void RegisterMetaTypes() {
|
||||
|
||||
qRegisterMetaType<const char*>("const char*");
|
||||
qRegisterMetaType<QList<int>>("QList<int>");
|
||||
qRegisterMetaType<QList<QUrl>>("QList<QUrl>");
|
||||
qRegisterMetaType<QVector<int>>("QVector<int>");
|
||||
qRegisterMetaType<QList<QUrl>>("QList<QUrl>");
|
||||
qRegisterMetaType<QFileInfo>("QFileInfo");
|
||||
qRegisterMetaType<QAbstractSocket::SocketState>();
|
||||
qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
|
||||
qRegisterMetaType<QNetworkCookie>("QNetworkCookie");
|
||||
qRegisterMetaType<QList<QNetworkCookie>>("QList<QNetworkCookie>");
|
||||
qRegisterMetaType<QNetworkReply*>("QNetworkReply*");
|
||||
qRegisterMetaType<QNetworkReply**>("QNetworkReply**");
|
||||
qRegisterMetaType<QItemSelection>("QItemSelection");
|
||||
@@ -98,16 +98,12 @@ void RegisterMetaTypes() {
|
||||
qRegisterMetaTypeStreamOperators<QMap<int, Qt::Alignment>>("ColumnAlignmentMap");
|
||||
qRegisterMetaTypeStreamOperators<QMap<int, int>>("ColumnAlignmentIntMap");
|
||||
#endif
|
||||
qRegisterMetaType<Directory>("Directory");
|
||||
qRegisterMetaType<DirectoryList>("DirectoryList");
|
||||
qRegisterMetaType<Subdirectory>("Subdirectory");
|
||||
qRegisterMetaType<SubdirectoryList>("SubdirectoryList");
|
||||
qRegisterMetaType<Song>("Song");
|
||||
qRegisterMetaType<SongList>("SongList");
|
||||
qRegisterMetaType<SongMap>("SongMap");
|
||||
qRegisterMetaType<QList<Song>>("QList<Song>");
|
||||
qRegisterMetaType<QMap<QString, Song>>("QMap<QString, Song>");
|
||||
qRegisterMetaType<Engine::EngineType>("EngineType");
|
||||
qRegisterMetaType<Song::Source>("Song::Source");
|
||||
qRegisterMetaType<Song::FileType>("Song::FileType");
|
||||
qRegisterMetaType<Engine::EngineType>("Engine::EngineType");
|
||||
qRegisterMetaType<Engine::SimpleMetaBundle>("Engine::SimpleMetaBundle");
|
||||
qRegisterMetaType<Engine::State>("Engine::State");
|
||||
qRegisterMetaType<Engine::TrackChangeFlags>("Engine::TrackChangeFlags");
|
||||
@@ -117,23 +113,29 @@ void RegisterMetaTypes() {
|
||||
qRegisterMetaType<GstElement*>("GstElement*");
|
||||
qRegisterMetaType<GstEnginePipeline*>("GstEnginePipeline*");
|
||||
#endif
|
||||
qRegisterMetaType<CollectionDirectory>("CollectionDirectory");
|
||||
qRegisterMetaType<CollectionDirectoryList>("CollectionDirectoryList");
|
||||
qRegisterMetaType<CollectionSubdirectory>("CollectionSubdirectory");
|
||||
qRegisterMetaType<CollectionSubdirectoryList>("CollectionSubdirectoryList");
|
||||
qRegisterMetaType<CollectionModel::Grouping>("CollectionModel::Grouping");
|
||||
qRegisterMetaType<PlaylistItemPtr>("PlaylistItemPtr");
|
||||
qRegisterMetaType<PlaylistItemList>("PlaylistItemList");
|
||||
qRegisterMetaType<QList<PlaylistItemPtr>>("QList<PlaylistItemPtr>");
|
||||
qRegisterMetaType<PlaylistItemPtrList>("PlaylistItemPtrList");
|
||||
qRegisterMetaType<PlaylistSequence::RepeatMode>("PlaylistSequence::RepeatMode");
|
||||
qRegisterMetaType<PlaylistSequence::ShuffleMode>("PlaylistSequence::ShuffleMode");
|
||||
qRegisterMetaType<AlbumCoverLoaderResult>("AlbumCoverLoaderResult");
|
||||
qRegisterMetaType<AlbumCoverLoaderResult::Type>("AlbumCoverLoaderResult::Type");
|
||||
qRegisterMetaType<CoverProviderSearchResult>("CoverProviderSearchResult");
|
||||
qRegisterMetaType<CoverSearchStatistics>("CoverSearchStatistics");
|
||||
qRegisterMetaType<QList<CoverProviderSearchResult>>("QList<CoverProviderSearchResult>");
|
||||
qRegisterMetaType<CoverProviderSearchResults>("CoverProviderSearchResults");
|
||||
qRegisterMetaType<CoverSearchStatistics>("CoverSearchStatistics");
|
||||
|
||||
qRegisterMetaType<Equalizer::Params>("Equalizer::Params");
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
qRegisterMetaTypeStreamOperators<Equalizer::Params>("Equalizer::Params");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
qDBusRegisterMetaType<QList<QByteArray>>();
|
||||
qDBusRegisterMetaType<QByteArrayList>();
|
||||
qDBusRegisterMetaType<QImage>();
|
||||
qDBusRegisterMetaType<TrackMetadata>();
|
||||
qDBusRegisterMetaType<Track_Ids>();
|
||||
@@ -144,15 +146,21 @@ void RegisterMetaTypes() {
|
||||
qDBusRegisterMetaType<ManagedObjectList>();
|
||||
#endif
|
||||
|
||||
qRegisterMetaType<InternetSearchView::ResultList>("InternetSearchView::ResultList");
|
||||
qRegisterMetaType<InternetSearchView::Result>("InternetSearchView::Result");
|
||||
qRegisterMetaType<InternetSearchView::ResultList>("InternetSearchView::ResultList");
|
||||
|
||||
qRegisterMetaType<PlaylistGeneratorPtr>("PlaylistGeneratorPtr");
|
||||
|
||||
qRegisterMetaType<RadioChannel>("RadioChannel");
|
||||
qRegisterMetaType<RadioChannelList>("RadioChannelList");
|
||||
|
||||
#ifdef HAVE_LIBMTP
|
||||
qRegisterMetaType<MtpConnection*>("MtpConnection*");
|
||||
#endif
|
||||
|
||||
qRegisterMetaType<PlaylistSettingsPage::PathType>("PlaylistSettingsPage::PathType");
|
||||
|
||||
qRegisterMetaType<PlaylistGeneratorPtr>("PlaylistGeneratorPtr");
|
||||
qRegisterMetaType<SmartPlaylistSearchTerm::Operator>("SmartPlaylistSearchTerm::Operator");
|
||||
qRegisterMetaType<SmartPlaylistSearchTerm::OperatorList>("SmartPlaylistSearchTerm::OperatorList");
|
||||
qRegisterMetaType<SmartPlaylistsItem::Type>("SmartPlaylistsItem::Type");
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
@@ -45,10 +46,10 @@
|
||||
#include "mpris_common.h"
|
||||
#include "mpris2.h"
|
||||
|
||||
#include "timeconstants.h"
|
||||
#include "song.h"
|
||||
#include "application.h"
|
||||
#include "player.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "playlist/playlist.h"
|
||||
#include "playlist/playlistitem.h"
|
||||
@@ -57,10 +58,10 @@
|
||||
#include "covermanager/currentalbumcoverloader.h"
|
||||
#include "covermanager/albumcoverloaderresult.h"
|
||||
|
||||
#include <core/mpris2_player.h>
|
||||
#include <core/mpris2_playlists.h>
|
||||
#include <core/mpris2_root.h>
|
||||
#include <core/mpris2_tracklist.h>
|
||||
#include "mpris2_player.h"
|
||||
#include "mpris2_playlists.h"
|
||||
#include "mpris2_root.h"
|
||||
#include "mpris2_tracklist.h"
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &arg, const MprisPlaylist &playlist) {
|
||||
arg.beginStructure();
|
||||
@@ -163,7 +164,7 @@ void Mpris2::PlaylistManagerInitialized() {
|
||||
|
||||
void Mpris2::EngineStateChanged(Engine::State newState) {
|
||||
|
||||
if (newState != Engine::Playing && newState != Engine::Paused) {
|
||||
if (newState != Engine::State::Playing && newState != Engine::State::Paused) {
|
||||
last_metadata_ = QVariantMap();
|
||||
EmitNotification("Metadata");
|
||||
}
|
||||
@@ -171,11 +172,13 @@ void Mpris2::EngineStateChanged(Engine::State newState) {
|
||||
EmitNotification("CanPlay");
|
||||
EmitNotification("CanPause");
|
||||
EmitNotification("PlaybackStatus", PlaybackStatus(newState));
|
||||
if (newState == Engine::Playing) EmitNotification("CanSeek", CanSeek(newState));
|
||||
if (newState == Engine::State::Playing) EmitNotification("CanSeek", CanSeek(newState));
|
||||
|
||||
}
|
||||
|
||||
void Mpris2::VolumeChanged() { EmitNotification("Volume"); }
|
||||
void Mpris2::VolumeChanged() {
|
||||
EmitNotification("Volume");
|
||||
}
|
||||
|
||||
void Mpris2::ShuffleModeChanged() { EmitNotification("Shuffle"); }
|
||||
|
||||
@@ -187,15 +190,15 @@ void Mpris2::RepeatModeChanged() {
|
||||
|
||||
}
|
||||
|
||||
void Mpris2::EmitNotification(const QString &name, const QVariant &val) {
|
||||
EmitNotification(name, val, "org.mpris.MediaPlayer2.Player");
|
||||
void Mpris2::EmitNotification(const QString &name, const QVariant &value) {
|
||||
EmitNotification(name, value, "org.mpris.MediaPlayer2.Player");
|
||||
}
|
||||
|
||||
void Mpris2::EmitNotification(const QString &name, const QVariant &val, const QString &mprisEntity) {
|
||||
void Mpris2::EmitNotification(const QString &name, const QVariant &value, const QString &mprisEntity) {
|
||||
|
||||
QDBusMessage msg = QDBusMessage::createSignal(kMprisObjectPath, kFreedesktopPath, "PropertiesChanged");
|
||||
QVariantMap map;
|
||||
map.insert(name, val);
|
||||
map.insert(name, value);
|
||||
QVariantList args = QVariantList() << mprisEntity << map << QStringList();
|
||||
msg.setArguments(args);
|
||||
QDBusConnection::sessionBus().send(msg);
|
||||
@@ -304,8 +307,8 @@ QString Mpris2::PlaybackStatus() const {
|
||||
QString Mpris2::PlaybackStatus(Engine::State state) const {
|
||||
|
||||
switch (state) {
|
||||
case Engine::Playing: return "Playing";
|
||||
case Engine::Paused: return "Paused";
|
||||
case Engine::State::Playing: return "Playing";
|
||||
case Engine::State::Paused: return "Paused";
|
||||
default: return "Stopped";
|
||||
}
|
||||
|
||||
@@ -318,9 +321,9 @@ QString Mpris2::LoopStatus() const {
|
||||
}
|
||||
|
||||
switch (app_->playlist_manager()->sequence()->repeat_mode()) {
|
||||
case PlaylistSequence::Repeat_Album:
|
||||
case PlaylistSequence::Repeat_Playlist: return "Playlist";
|
||||
case PlaylistSequence::Repeat_Track: return "Track";
|
||||
case PlaylistSequence::RepeatMode::Album:
|
||||
case PlaylistSequence::RepeatMode::Playlist: return "Playlist";
|
||||
case PlaylistSequence::RepeatMode::Track: return "Track";
|
||||
default: return "None";
|
||||
}
|
||||
|
||||
@@ -328,16 +331,16 @@ QString Mpris2::LoopStatus() const {
|
||||
|
||||
void Mpris2::SetLoopStatus(const QString &value) {
|
||||
|
||||
PlaylistSequence::RepeatMode mode = PlaylistSequence::Repeat_Off;
|
||||
PlaylistSequence::RepeatMode mode = PlaylistSequence::RepeatMode::Off;
|
||||
|
||||
if (value == "None") {
|
||||
mode = PlaylistSequence::Repeat_Off;
|
||||
mode = PlaylistSequence::RepeatMode::Off;
|
||||
}
|
||||
else if (value == "Track") {
|
||||
mode = PlaylistSequence::Repeat_Track;
|
||||
mode = PlaylistSequence::RepeatMode::Track;
|
||||
}
|
||||
else if (value == "Playlist") {
|
||||
mode = PlaylistSequence::Repeat_Playlist;
|
||||
mode = PlaylistSequence::RepeatMode::Playlist;
|
||||
}
|
||||
|
||||
app_->playlist_manager()->active()->sequence()->SetRepeatMode(mode);
|
||||
@@ -356,12 +359,12 @@ void Mpris2::SetRate(double rate) {
|
||||
|
||||
bool Mpris2::Shuffle() const {
|
||||
|
||||
return app_->playlist_manager()->sequence()->shuffle_mode() != PlaylistSequence::Shuffle_Off;
|
||||
return app_->playlist_manager()->sequence()->shuffle_mode() != PlaylistSequence::ShuffleMode::Off;
|
||||
|
||||
}
|
||||
|
||||
void Mpris2::SetShuffle(bool enable) {
|
||||
app_->playlist_manager()->active()->sequence()->SetShuffleMode(enable ? PlaylistSequence::Shuffle_All : PlaylistSequence::Shuffle_Off);
|
||||
app_->playlist_manager()->active()->sequence()->SetShuffleMode(enable ? PlaylistSequence::ShuffleMode::All : PlaylistSequence::ShuffleMode::Off);
|
||||
}
|
||||
|
||||
QVariantMap Mpris2::Metadata() const { return last_metadata_; }
|
||||
@@ -398,6 +401,13 @@ void Mpris2::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &re
|
||||
else if (result.temp_cover_url.isValid() && result.temp_cover_url.isLocalFile()) {
|
||||
cover_url = result.temp_cover_url;
|
||||
}
|
||||
else if (song.art_manual().isValid() && song.art_manual().isLocalFile() && song.art_manual().path() != Song::kManuallyUnsetCover && song.art_manual().path() != Song::kEmbeddedCover) {
|
||||
cover_url = song.art_manual();
|
||||
}
|
||||
else if (song.art_automatic().isValid() && song.art_automatic().isLocalFile() && song.art_automatic().path() != Song::kManuallyUnsetCover && song.art_automatic().path() != Song::kEmbeddedCover) {
|
||||
cover_url = song.art_automatic();
|
||||
}
|
||||
|
||||
if (cover_url.isValid()) AddMetadata("mpris:artUrl", cover_url.toString(), &last_metadata_);
|
||||
|
||||
AddMetadata("year", song.year(), &last_metadata_);
|
||||
@@ -411,8 +421,8 @@ double Mpris2::Volume() const {
|
||||
return app_->player()->GetVolume() / 100.0;
|
||||
}
|
||||
|
||||
void Mpris2::SetVolume(const double value) {
|
||||
app_->player()->SetVolume(static_cast<uint>(std::max(std::min(lround(value * 100.0), 100L), 0L)));
|
||||
void Mpris2::SetVolume(const double volume) {
|
||||
app_->player()->SetVolume(static_cast<uint>(qBound(0L, lround(volume * 100.0), 100L)));
|
||||
}
|
||||
|
||||
qint64 Mpris2::Position() const {
|
||||
@@ -437,13 +447,13 @@ bool Mpris2::CanPlay() const {
|
||||
|
||||
// This one's a bit different than MPRIS 1 - we want this to be true even when the song is already paused or stopped.
|
||||
bool Mpris2::CanPause() const {
|
||||
return (app_->player()->GetCurrentItem() && app_->player()->GetState() == Engine::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::PauseDisabled)) || PlaybackStatus() == "Paused" || PlaybackStatus() == "Stopped";
|
||||
return (app_->player()->GetCurrentItem() && app_->player()->GetState() == Engine::State::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::Option::PauseDisabled)) || PlaybackStatus() == "Paused" || PlaybackStatus() == "Stopped";
|
||||
}
|
||||
|
||||
bool Mpris2::CanSeek() const { return CanSeek(app_->player()->GetState()); }
|
||||
|
||||
bool Mpris2::CanSeek(Engine::State state) const {
|
||||
return app_->player()->GetCurrentItem() && state != Engine::Empty && !app_->player()->GetCurrentItem()->Metadata().is_stream();
|
||||
return app_->player()->GetCurrentItem() && state != Engine::State::Empty && !app_->player()->GetCurrentItem()->Metadata().is_stream();
|
||||
}
|
||||
|
||||
bool Mpris2::CanControl() const { return true; }
|
||||
@@ -461,7 +471,7 @@ void Mpris2::Previous() {
|
||||
}
|
||||
|
||||
void Mpris2::Pause() {
|
||||
if (CanPause() && app_->player()->GetState() != Engine::Paused) {
|
||||
if (CanPause() && app_->player()->GetState() != Engine::State::Paused) {
|
||||
app_->player()->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ class Application;
|
||||
class Song;
|
||||
class Playlist;
|
||||
|
||||
typedef QList<QVariantMap> TrackMetadata;
|
||||
typedef QList<QDBusObjectPath> Track_Ids;
|
||||
using TrackMetadata = QList<QVariantMap>;
|
||||
using Track_Ids = QList<QDBusObjectPath>;
|
||||
Q_DECLARE_METATYPE(TrackMetadata)
|
||||
|
||||
struct MprisPlaylist {
|
||||
@@ -54,7 +54,7 @@ struct MprisPlaylist {
|
||||
QString name;
|
||||
QString icon; // Uri
|
||||
};
|
||||
typedef QList<MprisPlaylist> MprisPlaylistList;
|
||||
using MprisPlaylistList = QList<MprisPlaylist>;
|
||||
Q_DECLARE_METATYPE(MprisPlaylist)
|
||||
Q_DECLARE_METATYPE(MprisPlaylistList)
|
||||
|
||||
@@ -145,7 +145,7 @@ class Mpris2 : public QObject {
|
||||
void SetShuffle(bool enable);
|
||||
QVariantMap Metadata() const;
|
||||
double Volume() const;
|
||||
void SetVolume(const double value);
|
||||
void SetVolume(const double volume);
|
||||
qint64 Position() const;
|
||||
double MaximumRate() const;
|
||||
double MinimumRate() const;
|
||||
@@ -215,8 +215,8 @@ class Mpris2 : public QObject {
|
||||
|
||||
private:
|
||||
void EmitNotification(const QString &name);
|
||||
void EmitNotification(const QString &name, const QVariant &val);
|
||||
void EmitNotification(const QString &name, const QVariant &val, const QString &mprisEntity);
|
||||
void EmitNotification(const QString &name, const QVariant &value);
|
||||
void EmitNotification(const QString &name, const QVariant &value, const QString &mprisEntity);
|
||||
|
||||
QString PlaybackStatus(Engine::State state) const;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class MultiSortFilterProxy : public QSortFilterProxyModel {
|
||||
private:
|
||||
int Compare(const QVariant &left, const QVariant &right) const;
|
||||
|
||||
typedef QPair<int, Qt::SortOrder> SortSpec;
|
||||
using SortSpec = QPair<int, Qt::SortOrder>;
|
||||
QList<SortSpec> sorting_;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QImage>
|
||||
|
||||
#include "song.h"
|
||||
|
||||
@@ -49,13 +50,13 @@ class MusicStorage {
|
||||
};
|
||||
|
||||
// Values are saved in the database - don't change
|
||||
enum TranscodeMode {
|
||||
enum class TranscodeMode {
|
||||
Transcode_Always = 1,
|
||||
Transcode_Never = 2,
|
||||
Transcode_Unsupported = 3,
|
||||
};
|
||||
|
||||
typedef std::function<void(float progress)> ProgressFunction;
|
||||
using ProgressFunction = std::function<void(float progress)>;
|
||||
|
||||
struct CopyJob {
|
||||
CopyJob() : overwrite_(false), remove_original_(false), albumcover_(false) {}
|
||||
@@ -67,6 +68,7 @@ class MusicStorage {
|
||||
bool albumcover_;
|
||||
QString cover_source_;
|
||||
QString cover_dest_;
|
||||
QImage cover_image_;
|
||||
ProgressFunction progress_;
|
||||
QString playlist_;
|
||||
};
|
||||
@@ -77,11 +79,12 @@ class MusicStorage {
|
||||
bool use_trash_;
|
||||
};
|
||||
|
||||
virtual Song::Source source() const = 0;
|
||||
virtual QString LocalPath() const { return QString(); }
|
||||
virtual std::optional<int> collection_directory_id() const { return std::optional<int>(); }
|
||||
|
||||
virtual TranscodeMode GetTranscodeMode() const { return Transcode_Never; }
|
||||
virtual Song::FileType GetTranscodeFormat() const { return Song::FileType_Unknown; }
|
||||
virtual TranscodeMode GetTranscodeMode() const { return TranscodeMode::Transcode_Never; }
|
||||
virtual Song::FileType GetTranscodeFormat() const { return Song::FileType::Unknown; }
|
||||
virtual bool GetSupportedFiletypes(QList<Song::FileType> *ret) { Q_UNUSED(ret); return true; }
|
||||
|
||||
virtual bool StartCopy(QList<Song::FileType> *supported_types) { Q_UNUSED(supported_types); return true; }
|
||||
|
||||
@@ -35,7 +35,7 @@ NetworkProxyFactory *NetworkProxyFactory::sInstance = nullptr;
|
||||
const char *NetworkProxyFactory::kSettingsGroup = "NetworkProxy";
|
||||
|
||||
NetworkProxyFactory::NetworkProxyFactory()
|
||||
: mode_(Mode_System),
|
||||
: mode_(Mode::System),
|
||||
type_(QNetworkProxy::HttpProxy),
|
||||
port_(8080),
|
||||
use_authentication_(false) {
|
||||
@@ -81,7 +81,7 @@ void NetworkProxyFactory::ReloadSettings() {
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
mode_ = Mode(s.value("mode", Mode_System).toInt());
|
||||
mode_ = static_cast<Mode>(s.value("mode", static_cast<int>(Mode::System)).toInt());
|
||||
type_ = QNetworkProxy::ProxyType(s.value("type", QNetworkProxy::HttpProxy).toInt());
|
||||
hostname_ = s.value("hostname").toString();
|
||||
port_ = s.value("port", 8080).toInt();
|
||||
@@ -100,7 +100,7 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
|
||||
QNetworkProxy ret;
|
||||
|
||||
switch (mode_) {
|
||||
case Mode_System:
|
||||
case Mode::System:
|
||||
#ifdef Q_OS_LINUX
|
||||
Q_UNUSED(query);
|
||||
|
||||
@@ -125,11 +125,11 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
|
||||
return systemProxyForQuery(query);
|
||||
#endif
|
||||
|
||||
case Mode_Direct:
|
||||
case Mode::Direct:
|
||||
ret.setType(QNetworkProxy::NoProxy);
|
||||
break;
|
||||
|
||||
case Mode_Manual:
|
||||
case Mode::Manual:
|
||||
ret.setType(type_);
|
||||
ret.setHostName(hostname_);
|
||||
ret.setPort(port_);
|
||||
|
||||
@@ -34,7 +34,11 @@
|
||||
class NetworkProxyFactory : public QNetworkProxyFactory {
|
||||
public:
|
||||
// These values are persisted
|
||||
enum Mode { Mode_System = 0, Mode_Direct = 1, Mode_Manual = 2, };
|
||||
enum class Mode {
|
||||
System = 0,
|
||||
Direct = 1,
|
||||
Manual = 2
|
||||
};
|
||||
|
||||
static NetworkProxyFactory *Instance();
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, Arnaud Bienner <arnaud.bienner@gmail.com>
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,31 +18,23 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef APPEARANCE_H
|
||||
#define APPEARANCE_H
|
||||
|
||||
#include "config.h"
|
||||
#ifndef PLATFORMINTERFACE_H
|
||||
#define PLATFORMINTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QColor>
|
||||
#include <QPalette>
|
||||
|
||||
class Appearance : public QObject {
|
||||
Q_OBJECT
|
||||
#include <QString>
|
||||
|
||||
class PlatformInterface {
|
||||
public:
|
||||
explicit Appearance(QObject *parent = nullptr);
|
||||
PlatformInterface() = default;
|
||||
virtual ~PlatformInterface() {}
|
||||
|
||||
static const QPalette kDefaultPalette;
|
||||
|
||||
void LoadUserTheme();
|
||||
static void ResetToSystemDefaultTheme();
|
||||
void ChangeForegroundColor(const QColor &color);
|
||||
void ChangeBackgroundColor(const QColor &color);
|
||||
// Called when the application should show itself.
|
||||
virtual void Activate() = 0;
|
||||
virtual bool LoadUrl(const QString &url) = 0;
|
||||
|
||||
private:
|
||||
QColor foreground_color_;
|
||||
QColor background_color_;
|
||||
Q_DISABLE_COPY(PlatformInterface)
|
||||
};
|
||||
|
||||
#endif // APPEARANCE_H
|
||||
#endif // PLATFORMINTERFACE_H
|
||||
@@ -36,9 +36,9 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
#include "song.h"
|
||||
#include "timeconstants.h"
|
||||
#include "urlhandler.h"
|
||||
#include "application.h"
|
||||
|
||||
@@ -79,43 +79,38 @@ Player::Player(Application *app, QObject *parent)
|
||||
#endif
|
||||
analyzer_(nullptr),
|
||||
equalizer_(nullptr),
|
||||
stream_change_type_(Engine::First),
|
||||
autoscroll_(Playlist::AutoScroll_Maybe),
|
||||
last_state_(Engine::Empty),
|
||||
stream_change_type_(Engine::TrackChangeType::First),
|
||||
autoscroll_(Playlist::AutoScroll::Maybe),
|
||||
last_state_(Engine::State::Empty),
|
||||
nb_errors_received_(0),
|
||||
volume_(100),
|
||||
volume_before_mute_(100),
|
||||
last_pressed_previous_(QDateTime::currentDateTime()),
|
||||
continue_on_error_(false),
|
||||
greyout_(true),
|
||||
menu_previousmode_(BehaviourSettingsPage::PreviousBehaviour_DontRestart),
|
||||
menu_previousmode_(BehaviourSettingsPage::PreviousBehaviour::DontRestart),
|
||||
seek_step_sec_(10),
|
||||
volume_control_(true),
|
||||
play_offset_nanosec_(0) {
|
||||
|
||||
settings_.beginGroup(kSettingsGroup);
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", EngineName(Engine::GStreamer)).toString().toLower());
|
||||
Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", EngineName(Engine::EngineType::GStreamer)).toString().toLower());
|
||||
s.endGroup();
|
||||
|
||||
CreateEngine(enginetype);
|
||||
|
||||
}
|
||||
|
||||
Player::~Player() {
|
||||
settings_.endGroup();
|
||||
}
|
||||
|
||||
Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
||||
|
||||
Engine::EngineType use_enginetype(Engine::None);
|
||||
Engine::EngineType use_enginetype(Engine::EngineType::None);
|
||||
|
||||
for (int i = 0; use_enginetype == Engine::None; i++) {
|
||||
for (int i = 0; use_enginetype == Engine::EngineType::None; i++) {
|
||||
switch (enginetype) {
|
||||
case Engine::None:
|
||||
case Engine::EngineType::None:
|
||||
#ifdef HAVE_GSTREAMER
|
||||
case Engine::GStreamer:{
|
||||
use_enginetype=Engine::GStreamer;
|
||||
case Engine::EngineType::GStreamer:{
|
||||
use_enginetype=Engine::EngineType::GStreamer;
|
||||
std::unique_ptr<GstEngine> gst_engine(new GstEngine(app_->task_manager()));
|
||||
gst_engine->SetStartup(gst_startup_);
|
||||
engine_.reset(gst_engine.release());
|
||||
@@ -123,8 +118,8 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_VLC
|
||||
case Engine::VLC:
|
||||
use_enginetype = Engine::VLC;
|
||||
case Engine::EngineType::VLC:
|
||||
use_enginetype = Engine::EngineType::VLC;
|
||||
engine_ = std::make_shared<VLCEngine>(app_->task_manager());
|
||||
break;
|
||||
#endif
|
||||
@@ -132,7 +127,7 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
||||
if (i > 0) {
|
||||
qFatal("No engine available!");
|
||||
}
|
||||
enginetype = Engine::None;
|
||||
enginetype = Engine::EngineType::None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +157,7 @@ void Player::Init() {
|
||||
|
||||
if (!engine_) {
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", EngineName(Engine::GStreamer)).toString().toLower());
|
||||
Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", EngineName(Engine::EngineType::GStreamer)).toString().toLower());
|
||||
s.endGroup();
|
||||
CreateEngine(enginetype);
|
||||
}
|
||||
@@ -181,6 +176,7 @@ void Player::Init() {
|
||||
QObject::connect(engine_.get(), &EngineBase::TrackAboutToEnd, this, &Player::TrackAboutToEnd);
|
||||
QObject::connect(engine_.get(), &EngineBase::TrackEnded, this, &Player::TrackEnded);
|
||||
QObject::connect(engine_.get(), &EngineBase::MetaData, this, &Player::EngineMetadataReceived);
|
||||
QObject::connect(engine_.get(), &EngineBase::VolumeChanged, this, &Player::SetVolumeFromEngine);
|
||||
|
||||
// Equalizer
|
||||
QObject::connect(equalizer_, &Equalizer::StereoBalancerEnabledChanged, app_->player()->engine(), &EngineBase::SetStereoBalancerEnabled);
|
||||
@@ -193,17 +189,10 @@ void Player::Init() {
|
||||
engine_->SetEqualizerEnabled(equalizer_->is_equalizer_enabled());
|
||||
engine_->SetEqualizerParameters(equalizer_->preamp_value(), equalizer_->gain_values());
|
||||
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
volume_control_ = s.value("volume_control", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
if (volume_control_) {
|
||||
int volume = settings_.value("volume", 100).toInt();
|
||||
SetVolume(volume);
|
||||
}
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
LoadVolume();
|
||||
|
||||
}
|
||||
|
||||
void Player::ReloadSettings() {
|
||||
@@ -216,16 +205,31 @@ void Player::ReloadSettings() {
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
||||
menu_previousmode_ = BehaviourSettingsPage::PreviousBehaviour(s.value("menu_previousmode", BehaviourSettingsPage::PreviousBehaviour_DontRestart).toInt());
|
||||
menu_previousmode_ = static_cast<BehaviourSettingsPage::PreviousBehaviour>(s.value("menu_previousmode", static_cast<int>(BehaviourSettingsPage::PreviousBehaviour::DontRestart)).toInt());
|
||||
seek_step_sec_ = s.value("seek_step_sec", 10).toInt();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
bool volume_control = s.value("volume_control", true).toBool();
|
||||
if (!volume_control && GetVolume() != 100) SetVolume(100);
|
||||
engine_->ReloadSettings();
|
||||
|
||||
}
|
||||
|
||||
void Player::LoadVolume() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const uint volume = s.value("volume", 100).toInt();
|
||||
s.endGroup();
|
||||
|
||||
engine_->ReloadSettings();
|
||||
SetVolume(volume);
|
||||
|
||||
}
|
||||
|
||||
void Player::SaveVolume() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("volume", volume_);
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -261,19 +265,19 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
}
|
||||
|
||||
switch (result.type_) {
|
||||
case UrlHandler::LoadResult::Error:
|
||||
case UrlHandler::LoadResult::Type::Error:
|
||||
if (is_current) {
|
||||
InvalidSongRequested(result.original_url_);
|
||||
}
|
||||
emit Error(result.error_);
|
||||
break;
|
||||
|
||||
case UrlHandler::LoadResult::NoMoreTracks:
|
||||
case UrlHandler::LoadResult::Type::NoMoreTracks:
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "said no more tracks" << is_current;
|
||||
if (is_current) NextItem(stream_change_type_, autoscroll_);
|
||||
break;
|
||||
|
||||
case UrlHandler::LoadResult::TrackAvailable: {
|
||||
case UrlHandler::LoadResult::Type::TrackAvailable: {
|
||||
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "returned" << result.stream_url_;
|
||||
|
||||
@@ -296,9 +300,9 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
|
||||
// If there was no filetype in the song's metadata, use the one provided by URL handler, if there is one.
|
||||
if (
|
||||
(song.filetype() == Song::FileType_Unknown && result.filetype_ != Song::FileType_Unknown)
|
||||
(song.filetype() == Song::FileType::Unknown && result.filetype_ != Song::FileType::Unknown)
|
||||
||
|
||||
(song.filetype() == Song::FileType_Stream && result.filetype_ != Song::FileType_Stream)
|
||||
(song.filetype() == Song::FileType::Stream && result.filetype_ != Song::FileType::Stream)
|
||||
)
|
||||
{
|
||||
song.set_filetype(result.filetype_);
|
||||
@@ -349,7 +353,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
break;
|
||||
}
|
||||
|
||||
case UrlHandler::LoadResult::WillLoadAsynchronously:
|
||||
case UrlHandler::LoadResult::Type::WillLoadAsynchronously:
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "is loading asynchronously";
|
||||
|
||||
// We'll get called again later with either NoMoreTracks or TrackAvailable
|
||||
@@ -359,7 +363,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
|
||||
}
|
||||
|
||||
void Player::Next() { NextInternal(Engine::Manual, Playlist::AutoScroll_Always); }
|
||||
void Player::Next() { NextInternal(Engine::TrackChangeType::Manual, Playlist::AutoScroll::Always); }
|
||||
|
||||
void Player::NextInternal(const Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll) {
|
||||
|
||||
@@ -380,10 +384,10 @@ void Player::NextItem(const Engine::TrackChangeFlags change, const Playlist::Aut
|
||||
Playlist *active_playlist = app_->playlist_manager()->active();
|
||||
|
||||
// If we received too many errors in auto change, with repeat enabled, we stop
|
||||
if (change == Engine::Auto) {
|
||||
if (change == Engine::TrackChangeType::Auto) {
|
||||
const PlaylistSequence::RepeatMode repeat_mode = active_playlist->sequence()->repeat_mode();
|
||||
if (repeat_mode != PlaylistSequence::Repeat_Off) {
|
||||
if ((repeat_mode == PlaylistSequence::Repeat_Track && nb_errors_received_ >= 3) || (nb_errors_received_ >= app_->playlist_manager()->active()->filter()->rowCount())) {
|
||||
if (repeat_mode != PlaylistSequence::RepeatMode::Off) {
|
||||
if ((repeat_mode == PlaylistSequence::RepeatMode::Track && nb_errors_received_ >= 3) || (nb_errors_received_ >= app_->playlist_manager()->active()->filter()->rowCount())) {
|
||||
// We received too many "Error" state changes: probably looping over a playlist which contains only unavailable elements: stop now.
|
||||
nb_errors_received_ = 0;
|
||||
Stop();
|
||||
@@ -393,7 +397,7 @@ void Player::NextItem(const Engine::TrackChangeFlags change, const Playlist::Aut
|
||||
}
|
||||
|
||||
// Manual track changes override "Repeat track"
|
||||
const bool ignore_repeat_track = change & Engine::Manual;
|
||||
const bool ignore_repeat_track = change & Engine::TrackChangeType::Manual;
|
||||
|
||||
int i = active_playlist->next_row(ignore_repeat_track);
|
||||
if (i == -1) {
|
||||
@@ -409,7 +413,7 @@ void Player::NextItem(const Engine::TrackChangeFlags change, const Playlist::Aut
|
||||
}
|
||||
|
||||
void Player::PlayPlaylist(const QString &playlist_name) {
|
||||
PlayPlaylistInternal(Engine::Manual, Playlist::AutoScroll_Always, playlist_name);
|
||||
PlayPlaylistInternal(Engine::TrackChangeType::Manual, Playlist::AutoScroll::Always, playlist_name);
|
||||
}
|
||||
|
||||
void Player::PlayPlaylistInternal(const Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const QString &playlist_name) {
|
||||
@@ -468,22 +472,22 @@ void Player::TrackEnded() {
|
||||
app_->playlist_manager()->collection_backend()->IncrementPlayCountAsync(current_item_->Metadata().id());
|
||||
}
|
||||
|
||||
if (HandleStopAfter(Playlist::AutoScroll_Maybe)) return;
|
||||
if (HandleStopAfter(Playlist::AutoScroll::Maybe)) return;
|
||||
|
||||
NextInternal(Engine::Auto, Playlist::AutoScroll_Maybe);
|
||||
NextInternal(Engine::TrackChangeType::Auto, Playlist::AutoScroll::Maybe);
|
||||
|
||||
}
|
||||
|
||||
void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll autoscroll) {
|
||||
|
||||
switch (engine_->state()) {
|
||||
case Engine::Paused:
|
||||
case Engine::State::Paused:
|
||||
UnPause();
|
||||
emit Resumed();
|
||||
break;
|
||||
|
||||
case Engine::Playing: {
|
||||
if (current_item_->options() & PlaylistItem::PauseDisabled) {
|
||||
case Engine::State::Playing: {
|
||||
if (current_item_->options() & PlaylistItem::Option::PauseDisabled) {
|
||||
Stop();
|
||||
}
|
||||
else {
|
||||
@@ -494,9 +498,9 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll
|
||||
break;
|
||||
}
|
||||
|
||||
case Engine::Empty:
|
||||
case Engine::Error:
|
||||
case Engine::Idle: {
|
||||
case Engine::State::Empty:
|
||||
case Engine::State::Error:
|
||||
case Engine::State::Idle: {
|
||||
pause_time_ = QDateTime();
|
||||
play_offset_nanosec_ = offset_nanosec;
|
||||
app_->playlist_manager()->SetActivePlaylist(app_->playlist_manager()->current_id());
|
||||
@@ -504,7 +508,7 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll
|
||||
int i = app_->playlist_manager()->active()->current_row();
|
||||
if (i == -1) i = app_->playlist_manager()->active()->last_played_row();
|
||||
if (i == -1) i = 0;
|
||||
PlayAt(i, offset_nanosec, Engine::First, autoscroll, true);
|
||||
PlayAt(i, offset_nanosec, Engine::TrackChangeType::First, autoscroll, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -564,45 +568,45 @@ void Player::StopAfterCurrent() {
|
||||
bool Player::PreviousWouldRestartTrack() const {
|
||||
|
||||
// Check if it has been over two seconds since previous button was pressed
|
||||
return menu_previousmode_ == BehaviourSettingsPage::PreviousBehaviour_Restart && last_pressed_previous_.isValid() && last_pressed_previous_.secsTo(QDateTime::currentDateTime()) >= 2;
|
||||
return menu_previousmode_ == BehaviourSettingsPage::PreviousBehaviour::Restart && last_pressed_previous_.isValid() && last_pressed_previous_.secsTo(QDateTime::currentDateTime()) >= 2;
|
||||
|
||||
}
|
||||
|
||||
void Player::Previous() { PreviousItem(Engine::Manual); }
|
||||
void Player::Previous() { PreviousItem(Engine::TrackChangeType::Manual); }
|
||||
|
||||
void Player::PreviousItem(const Engine::TrackChangeFlags change) {
|
||||
|
||||
pause_time_ = QDateTime();
|
||||
play_offset_nanosec_ = 0;
|
||||
|
||||
const bool ignore_repeat_track = change & Engine::Manual;
|
||||
const bool ignore_repeat_track = change & Engine::TrackChangeType::Manual;
|
||||
|
||||
if (menu_previousmode_ == BehaviourSettingsPage::PreviousBehaviour_Restart) {
|
||||
if (menu_previousmode_ == BehaviourSettingsPage::PreviousBehaviour::Restart) {
|
||||
// Check if it has been over two seconds since previous button was pressed
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
if (last_pressed_previous_.isValid() && last_pressed_previous_.secsTo(now) >= 2) {
|
||||
last_pressed_previous_ = now;
|
||||
PlayAt(app_->playlist_manager()->active()->current_row(), 0, change, Playlist::AutoScroll_Always, false, true);
|
||||
PlayAt(app_->playlist_manager()->active()->current_row(), 0, change, Playlist::AutoScroll::Always, false, true);
|
||||
return;
|
||||
}
|
||||
last_pressed_previous_ = now;
|
||||
}
|
||||
|
||||
int i = app_->playlist_manager()->active()->previous_row(ignore_repeat_track);
|
||||
app_->playlist_manager()->active()->set_current_row(i, Playlist::AutoScroll_Always, false);
|
||||
app_->playlist_manager()->active()->set_current_row(i, Playlist::AutoScroll::Always, false);
|
||||
if (i == -1) {
|
||||
Stop();
|
||||
PlayAt(i, 0, change, Playlist::AutoScroll_Always, true);
|
||||
PlayAt(i, 0, change, Playlist::AutoScroll::Always, true);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayAt(i, 0, change, Playlist::AutoScroll_Always, false);
|
||||
PlayAt(i, 0, change, Playlist::AutoScroll::Always, false);
|
||||
|
||||
}
|
||||
|
||||
void Player::EngineStateChanged(const Engine::State state) {
|
||||
|
||||
if (Engine::Error == state) {
|
||||
if (state == Engine::State::Error) {
|
||||
nb_errors_received_++;
|
||||
}
|
||||
else {
|
||||
@@ -610,21 +614,21 @@ void Player::EngineStateChanged(const Engine::State state) {
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case Engine::Paused:
|
||||
case Engine::State::Paused:
|
||||
pause_time_ = QDateTime::currentDateTime();
|
||||
play_offset_nanosec_ = engine_->position_nanosec();
|
||||
emit Paused();
|
||||
break;
|
||||
case Engine::Playing:
|
||||
case Engine::State::Playing:
|
||||
pause_time_ = QDateTime();
|
||||
play_offset_nanosec_ = 0;
|
||||
emit Playing();
|
||||
break;
|
||||
case Engine::Error:
|
||||
case Engine::State::Error:
|
||||
emit Error();
|
||||
[[fallthrough]];
|
||||
case Engine::Empty:
|
||||
case Engine::Idle:
|
||||
case Engine::State::Empty:
|
||||
case Engine::State::Idle:
|
||||
pause_time_ = QDateTime();
|
||||
play_offset_nanosec_ = 0;
|
||||
emit Stopped();
|
||||
@@ -641,20 +645,38 @@ uint Player::GetVolume() const {
|
||||
|
||||
}
|
||||
|
||||
void Player::SetVolume(const uint value) {
|
||||
void Player::SetVolumeFromSlider(const int value) {
|
||||
|
||||
uint old_volume = engine_->volume();
|
||||
|
||||
uint volume = qBound(0U, value, 100U);
|
||||
settings_.setValue("volume", volume);
|
||||
engine_->SetVolume(volume);
|
||||
|
||||
if (volume != old_volume) {
|
||||
const uint volume = static_cast<uint>(qBound(0, value, 100));
|
||||
if (volume != volume_) {
|
||||
volume_ = volume;
|
||||
engine_->SetVolume(volume);
|
||||
emit VolumeChanged(volume);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Player::SetVolumeFromEngine(const uint volume) {
|
||||
|
||||
const uint new_volume = qBound(0U, volume, 100U);
|
||||
if (new_volume != volume_) {
|
||||
volume_ = new_volume;
|
||||
emit VolumeChanged(new_volume);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Player::SetVolume(const uint volume) {
|
||||
|
||||
const uint new_volume = qBound(0U, volume, 100U);
|
||||
if (new_volume != volume_) {
|
||||
volume_ = new_volume;
|
||||
engine_->SetVolume(new_volume);
|
||||
emit VolumeChanged(new_volume);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Player::VolumeUp() {
|
||||
|
||||
uint old_volume = GetVolume();
|
||||
@@ -678,12 +700,12 @@ void Player::PlayAt(const int index, const quint64 offset_nanosec, Engine::Track
|
||||
pause_time_ = QDateTime();
|
||||
play_offset_nanosec_ = offset_nanosec;
|
||||
|
||||
if (current_item_ && change == Engine::Manual && engine_->position_nanosec() != engine_->length_nanosec()) {
|
||||
if (current_item_ && change == Engine::TrackChangeType::Manual && engine_->position_nanosec() != engine_->length_nanosec()) {
|
||||
emit TrackSkipped(current_item_);
|
||||
}
|
||||
|
||||
if (current_item_ && app_->playlist_manager()->active()->has_item_at(index) && current_item_->Metadata().IsOnSameAlbum(app_->playlist_manager()->active()->item_at(index)->Metadata())) {
|
||||
change |= Engine::SameAlbum;
|
||||
change |= Engine::TrackChangeType::SameAlbum;
|
||||
}
|
||||
|
||||
if (reshuffle) app_->playlist_manager()->active()->ReshuffleIndices();
|
||||
@@ -739,7 +761,7 @@ void Player::SeekTo(const quint64 seconds) {
|
||||
emit Seeked(nanosec / 1000);
|
||||
|
||||
if (seconds == 0) {
|
||||
app_->playlist_manager()->active()->InformOfCurrentSongChange(Playlist::AutoScroll_Maybe, false);
|
||||
app_->playlist_manager()->active()->InformOfCurrentSongChange(Playlist::AutoScroll::Maybe, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -754,7 +776,7 @@ void Player::SeekBackward() {
|
||||
|
||||
void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) {
|
||||
|
||||
if (bundle.type == Engine::SimpleMetaBundle::Type_Any || bundle.type == Engine::SimpleMetaBundle::Type_Current) {
|
||||
if (bundle.type == Engine::SimpleMetaBundle::Type::Any || bundle.type == Engine::SimpleMetaBundle::Type::Current) {
|
||||
PlaylistItemPtr item = app_->playlist_manager()->active()->current_item();
|
||||
if (item && bundle.url == item->Url()) {
|
||||
Song song = item->Metadata();
|
||||
@@ -764,7 +786,7 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.type == Engine::SimpleMetaBundle::Type_Any || bundle.type == Engine::SimpleMetaBundle::Type_Next) {
|
||||
if (bundle.type == Engine::SimpleMetaBundle::Type::Any || bundle.type == Engine::SimpleMetaBundle::Type::Next) {
|
||||
int next_row = app_->playlist_manager()->active()->next_row();
|
||||
if (next_row != -1) {
|
||||
PlaylistItemPtr next_item = app_->playlist_manager()->active()->item_at(next_row);
|
||||
@@ -789,8 +811,6 @@ PlaylistItemPtr Player::GetItemAt(const int pos) const {
|
||||
|
||||
void Player::Mute() {
|
||||
|
||||
if (!volume_control_) return;
|
||||
|
||||
const uint current_volume = engine_->volume();
|
||||
|
||||
if (current_volume == 0) {
|
||||
@@ -808,10 +828,10 @@ void Player::Pause() { engine_->Pause(); }
|
||||
void Player::Play(const quint64 offset_nanosec) {
|
||||
|
||||
switch (GetState()) {
|
||||
case Engine::Playing:
|
||||
case Engine::State::Playing:
|
||||
SeekTo(offset_nanosec);
|
||||
break;
|
||||
case Engine::Paused:
|
||||
case Engine::State::Paused:
|
||||
UnPause();
|
||||
break;
|
||||
default:
|
||||
@@ -860,18 +880,18 @@ void Player::TrackAboutToEnd() {
|
||||
// Get the actual track URL rather than the stream URL.
|
||||
if (url_handlers_.contains(url.scheme())) {
|
||||
if (loading_async_.contains(url)) return;
|
||||
autoscroll_ = Playlist::AutoScroll_Maybe;
|
||||
autoscroll_ = Playlist::AutoScroll::Maybe;
|
||||
UrlHandler::LoadResult result = url_handlers_[url.scheme()]->StartLoading(url);
|
||||
switch (result.type_) {
|
||||
case UrlHandler::LoadResult::Error:
|
||||
case UrlHandler::LoadResult::Type::Error:
|
||||
emit Error(result.error_);
|
||||
return;
|
||||
case UrlHandler::LoadResult::NoMoreTracks:
|
||||
case UrlHandler::LoadResult::Type::NoMoreTracks:
|
||||
return;
|
||||
case UrlHandler::LoadResult::WillLoadAsynchronously:
|
||||
case UrlHandler::LoadResult::Type::WillLoadAsynchronously:
|
||||
loading_async_ << url;
|
||||
return;
|
||||
case UrlHandler::LoadResult::TrackAvailable:
|
||||
case UrlHandler::LoadResult::Type::TrackAvailable:
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "returned" << result.stream_url_;
|
||||
url = result.stream_url_;
|
||||
Song song = next_item->Metadata();
|
||||
@@ -909,7 +929,7 @@ void Player::InvalidSongRequested(const QUrl &url) {
|
||||
return;
|
||||
}
|
||||
|
||||
NextItem(Engine::Auto, Playlist::AutoScroll_Maybe);
|
||||
NextItem(Engine::TrackChangeType::Auto, Playlist::AutoScroll::Maybe);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QSettings>
|
||||
|
||||
#include "urlhandler.h"
|
||||
#include "engine/engine_fwd.h"
|
||||
@@ -71,12 +70,14 @@ class PlayerInterface : public QObject {
|
||||
|
||||
public slots:
|
||||
virtual void ReloadSettings() = 0;
|
||||
virtual void LoadVolume() = 0;
|
||||
virtual void SaveVolume() = 0;
|
||||
|
||||
// Manual track change to the specified track
|
||||
virtual void PlayAt(const int index, const quint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) = 0;
|
||||
|
||||
// If there's currently a song playing, pause it, otherwise play the track that was playing last, or the first one on the playlist
|
||||
virtual void PlayPause(const quint64 offset_nanosec = 0, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Always) = 0;
|
||||
virtual void PlayPause(const quint64 offset_nanosec = 0, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll::Always) = 0;
|
||||
virtual void PlayPauseHelper() = 0;
|
||||
virtual void RestartOrPrevious() = 0;
|
||||
|
||||
@@ -84,7 +85,9 @@ class PlayerInterface : public QObject {
|
||||
virtual void Next() = 0;
|
||||
virtual void Previous() = 0;
|
||||
virtual void PlayPlaylist(const QString &playlist_name) = 0;
|
||||
virtual void SetVolume(const uint value) = 0;
|
||||
virtual void SetVolumeFromEngine(const uint volume) = 0;
|
||||
virtual void SetVolumeFromSlider(const int value) = 0;
|
||||
virtual void SetVolume(const uint volume) = 0;
|
||||
virtual void VolumeUp() = 0;
|
||||
virtual void VolumeDown() = 0;
|
||||
virtual void SeekTo(const quint64 seconds) = 0;
|
||||
@@ -132,7 +135,6 @@ class Player : public PlayerInterface {
|
||||
|
||||
public:
|
||||
explicit Player(Application *app, QObject *parent);
|
||||
~Player() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
@@ -158,15 +160,19 @@ class Player : public PlayerInterface {
|
||||
|
||||
public slots:
|
||||
void ReloadSettings() override;
|
||||
void LoadVolume() override;
|
||||
void SaveVolume() override;
|
||||
|
||||
void PlayAt(const int index, const quint64 offset_nanosec, Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const bool reshuffle, const bool force_inform = false) override;
|
||||
void PlayPause(const quint64 offset_nanosec = 0, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Always) override;
|
||||
void PlayPause(const quint64 offset_nanosec = 0, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll::Always) override;
|
||||
void PlayPauseHelper() override { PlayPause(play_offset_nanosec_); }
|
||||
void RestartOrPrevious() override;
|
||||
void Next() override;
|
||||
void Previous() override;
|
||||
void PlayPlaylist(const QString &playlist_name) override;
|
||||
void SetVolume(const uint value) override;
|
||||
void SetVolumeFromSlider(const int value) override;
|
||||
void SetVolumeFromEngine(const uint volume) override;
|
||||
void SetVolume(const uint volume) override;
|
||||
void VolumeUp() override;
|
||||
void VolumeDown() override;
|
||||
void SeekTo(const quint64 seconds) override;
|
||||
@@ -223,8 +229,6 @@ class Player : public PlayerInterface {
|
||||
AnalyzerContainer *analyzer_;
|
||||
Equalizer *equalizer_;
|
||||
|
||||
QSettings settings_;
|
||||
|
||||
PlaylistItemPtr current_item_;
|
||||
|
||||
Engine::TrackChangeFlags stream_change_type_;
|
||||
@@ -235,6 +239,7 @@ class Player : public PlayerInterface {
|
||||
QMap<QString, UrlHandler*> url_handlers_;
|
||||
|
||||
QList<QUrl> loading_async_;
|
||||
uint volume_;
|
||||
uint volume_before_mute_;
|
||||
QDateTime last_pressed_previous_;
|
||||
|
||||
@@ -243,8 +248,6 @@ class Player : public PlayerInterface {
|
||||
BehaviourSettingsPage::PreviousBehaviour menu_previousmode_;
|
||||
int seek_step_sec_;
|
||||
|
||||
bool volume_control_;
|
||||
|
||||
QDateTime pause_time_;
|
||||
quint64 play_offset_nanosec_;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
template<typename CFT>
|
||||
class ScopedCFTypeRef {
|
||||
public:
|
||||
typedef CFT element_type;
|
||||
using element_type = CFT;
|
||||
|
||||
explicit ScopedCFTypeRef(CFT object = nullptr) : object_(object) {}
|
||||
|
||||
|
||||
29
src/core/scopedwchararray.cpp
Normal file
29
src/core/scopedwchararray.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "scopedwchararray.h"
|
||||
|
||||
ScopedWCharArray::ScopedWCharArray(const QString &str)
|
||||
: chars_(str.length()), data_(new wchar_t[chars_ + 1]) {
|
||||
str.toWCharArray(data_.get());
|
||||
data_[chars_] = '\0';
|
||||
}
|
||||
48
src/core/scopedwchararray.h
Normal file
48
src/core/scopedwchararray.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SCOPEDWCHARARRAY_H
|
||||
#define SCOPEDWCHARARRAY_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class ScopedWCharArray {
|
||||
public:
|
||||
explicit ScopedWCharArray(const QString &str);
|
||||
|
||||
QString ToString() const { return QString::fromWCharArray(data_.get()); }
|
||||
|
||||
wchar_t *get() const { return data_.get(); }
|
||||
explicit operator wchar_t *() const { return get(); }
|
||||
|
||||
qint64 characters() const { return chars_; }
|
||||
qint64 bytes() const { return (chars_ + 1) * sizeof(wchar_t); }
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ScopedWCharArray)
|
||||
|
||||
qint64 chars_;
|
||||
std::unique_ptr<wchar_t[]> data_;
|
||||
};
|
||||
|
||||
#endif // SCOPEDWCHARARRAY_H
|
||||
@@ -44,15 +44,16 @@
|
||||
#include <QStringList>
|
||||
#include <QRegularExpression>
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
#include <QIcon>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "core/iconloader.h"
|
||||
|
||||
#include "engine/enginebase.h"
|
||||
#include "timeconstants.h"
|
||||
#include "utilities.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "utilities/timeutils.h"
|
||||
#include "utilities/cryptutils.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "song.h"
|
||||
#include "application.h"
|
||||
#include "sqlquery.h"
|
||||
@@ -147,7 +148,6 @@ const QString Song::kEmbeddedCover = "(embedded)";
|
||||
const QRegularExpression Song::kAlbumRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
||||
const QRegularExpression Song::kAlbumRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|([0-9]{1,4}) *Remaster|Explicit) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
||||
const QRegularExpression Song::kTitleRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|Remastered Version|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
||||
const QString Song::kVariousArtists("various artists");
|
||||
|
||||
const QStringList Song::kArticles = QStringList() << "the " << "a " << "an ";
|
||||
|
||||
@@ -158,7 +158,7 @@ const QStringList Song::kAcceptedExtensions = QStringList() << "wav" << "flac" <
|
||||
|
||||
struct Song::Private : public QSharedData {
|
||||
|
||||
explicit Private(Source source = Source_Unknown);
|
||||
explicit Private(Source source = Source::Unknown);
|
||||
|
||||
bool valid_;
|
||||
int id_;
|
||||
@@ -224,13 +224,12 @@ struct Song::Private : public QSharedData {
|
||||
float rating_; // Database rating, initial rating read from tag.
|
||||
|
||||
QUrl stream_url_; // Temporary stream url set by url handler.
|
||||
QImage image_; // Album Cover image set by album cover loader.
|
||||
bool init_from_file_; // Whether this song was loaded from a file using taglib.
|
||||
bool suspicious_tags_; // Whether our encoding guesser thinks these tags might be incorrectly encoded.
|
||||
|
||||
};
|
||||
|
||||
Song::Private::Private(Song::Source source)
|
||||
Song::Private::Private(const Source source)
|
||||
: valid_(false),
|
||||
id_(-1),
|
||||
|
||||
@@ -249,7 +248,7 @@ Song::Private::Private(Song::Source source)
|
||||
|
||||
source_(source),
|
||||
directory_id_(-1),
|
||||
filetype_(FileType_Unknown),
|
||||
filetype_(FileType::Unknown),
|
||||
filesize_(-1),
|
||||
mtime_(-1),
|
||||
ctime_(-1),
|
||||
@@ -271,7 +270,7 @@ Song::Private::Private(Song::Source source)
|
||||
|
||||
{}
|
||||
|
||||
Song::Song(Song::Source source) : d(new Private(source)) {}
|
||||
Song::Song(const Source source) : d(new Private(source)) {}
|
||||
Song::Song(const Song &other) = default;
|
||||
Song::~Song() = default;
|
||||
|
||||
@@ -353,19 +352,85 @@ void Song::set_embedded_cover() { d->art_automatic_ = QUrl::fromLocalFile(kEmbed
|
||||
void Song::clear_art_automatic() { d->art_automatic_.clear(); }
|
||||
void Song::clear_art_manual() { d->art_manual_.clear(); }
|
||||
|
||||
bool Song::additional_tags_supported() const {
|
||||
return d->filetype_ == FileType::FLAC ||
|
||||
d->filetype_ == FileType::WavPack ||
|
||||
d->filetype_ == FileType::OggFlac ||
|
||||
d->filetype_ == FileType::OggVorbis ||
|
||||
d->filetype_ == FileType::OggOpus ||
|
||||
d->filetype_ == FileType::OggSpeex ||
|
||||
d->filetype_ == FileType::MPEG ||
|
||||
d->filetype_ == FileType::MP4 ||
|
||||
d->filetype_ == FileType::MPC ||
|
||||
d->filetype_ == FileType::APE;
|
||||
}
|
||||
|
||||
bool Song::albumartist_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::composer_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::performer_supported() const {
|
||||
return d->filetype_ == FileType::FLAC ||
|
||||
d->filetype_ == FileType::WavPack ||
|
||||
d->filetype_ == FileType::OggFlac ||
|
||||
d->filetype_ == FileType::OggVorbis ||
|
||||
d->filetype_ == FileType::OggOpus ||
|
||||
d->filetype_ == FileType::OggSpeex ||
|
||||
d->filetype_ == FileType::MPEG ||
|
||||
d->filetype_ == FileType::MPC ||
|
||||
d->filetype_ == FileType::APE;
|
||||
}
|
||||
|
||||
bool Song::grouping_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::genre_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::compilation_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::rating_supported() const {
|
||||
return d->filetype_ == FileType::FLAC ||
|
||||
d->filetype_ == FileType::WavPack ||
|
||||
d->filetype_ == FileType::OggFlac ||
|
||||
d->filetype_ == FileType::OggVorbis ||
|
||||
d->filetype_ == FileType::OggOpus ||
|
||||
d->filetype_ == FileType::OggSpeex ||
|
||||
d->filetype_ == FileType::MPEG ||
|
||||
d->filetype_ == FileType::MP4 ||
|
||||
d->filetype_ == FileType::ASF ||
|
||||
d->filetype_ == FileType::MPC ||
|
||||
d->filetype_ == FileType::APE;
|
||||
}
|
||||
|
||||
bool Song::comment_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::lyrics_supported() const {
|
||||
return additional_tags_supported();
|
||||
}
|
||||
|
||||
bool Song::save_embedded_cover_supported(const FileType filetype) {
|
||||
|
||||
return filetype == FileType_FLAC ||
|
||||
filetype == FileType_OggVorbis ||
|
||||
filetype == FileType_OggOpus ||
|
||||
filetype == FileType_MPEG ||
|
||||
filetype == FileType_MP4;
|
||||
return filetype == FileType::FLAC ||
|
||||
filetype == FileType::OggVorbis ||
|
||||
filetype == FileType::OggOpus ||
|
||||
filetype == FileType::MPEG ||
|
||||
filetype == FileType::MP4;
|
||||
|
||||
}
|
||||
|
||||
const QUrl &Song::stream_url() const { return d->stream_url_; }
|
||||
const QUrl &Song::effective_stream_url() const { return !d->stream_url_.isEmpty() && d->stream_url_.isValid() ? d->stream_url_ : d->url_; }
|
||||
const QImage &Song::image() const { return d->image_; }
|
||||
bool Song::init_from_file() const { return d->init_from_file_; }
|
||||
|
||||
const QString &Song::cue_path() const { return d->cue_path_; }
|
||||
@@ -373,14 +438,14 @@ bool Song::has_cue() const { return !d->cue_path_.isEmpty(); }
|
||||
|
||||
float Song::rating() const { return d->rating_; }
|
||||
|
||||
bool Song::is_collection_song() const { return d->source_ == Source_Collection; }
|
||||
bool Song::is_collection_song() const { return d->source_ == Source::Collection; }
|
||||
bool Song::is_metadata_good() const { return !d->url_.isEmpty() && !d->artist_.isEmpty() && !d->title_.isEmpty(); }
|
||||
bool Song::is_stream() const { return is_radio() || d->source_ == Source_Tidal || d->source_ == Source_Subsonic || d->source_ == Source_Qobuz; }
|
||||
bool Song::is_radio() const { return d->source_ == Source_Stream || d->source_ == Source_SomaFM || d->source_ == Source_RadioParadise; }
|
||||
bool Song::is_cdda() const { return d->source_ == Source_CDDA; }
|
||||
bool Song::is_stream() const { return is_radio() || d->source_ == Source::Tidal || d->source_ == Source::Subsonic || d->source_ == Source::Qobuz; }
|
||||
bool Song::is_radio() const { return d->source_ == Source::Stream || d->source_ == Source::SomaFM || d->source_ == Source::RadioParadise; }
|
||||
bool Song::is_cdda() const { return d->source_ == Source::CDDA; }
|
||||
bool Song::is_compilation() const { return (d->compilation_ || d->compilation_detected_ || d->compilation_on_) && !d->compilation_off_; }
|
||||
bool Song::stream_url_can_expire() const { return d->source_ == Song::Source_Tidal || d->source_ == Song::Source_Qobuz; }
|
||||
bool Song::is_module_music() const { return d->filetype_ == Song::FileType_MOD || d->filetype_ == Song::FileType_S3M || d->filetype_ == Song::FileType_XM || d->filetype_ == Song::FileType_IT; }
|
||||
bool Song::stream_url_can_expire() const { return d->source_ == Source::Tidal || d->source_ == Source::Qobuz; }
|
||||
bool Song::is_module_music() const { return d->filetype_ == FileType::MOD || d->filetype_ == FileType::S3M || d->filetype_ == FileType::XM || d->filetype_ == FileType::IT; }
|
||||
|
||||
bool Song::art_automatic_is_valid() const {
|
||||
return !d->art_automatic_.isEmpty() &&
|
||||
@@ -479,7 +544,6 @@ void Song::set_cue_path(const QString &v) { d->cue_path_ = v; }
|
||||
void Song::set_rating(const float v) { d->rating_ = v; }
|
||||
|
||||
void Song::set_stream_url(const QUrl &v) { d->stream_url_ = v; }
|
||||
void Song::set_image(const QImage &i) { d->image_ = i; }
|
||||
|
||||
QString Song::JoinSpec(const QString &table) {
|
||||
return Utilities::Prepend(table + ".", kColumns).join(", ");
|
||||
@@ -487,55 +551,55 @@ QString Song::JoinSpec(const QString &table) {
|
||||
|
||||
Song::Source Song::SourceFromURL(const QUrl &url) {
|
||||
|
||||
if (url.isLocalFile()) return Source_LocalFile;
|
||||
else if (url.scheme() == "cdda") return Source_CDDA;
|
||||
else if (url.scheme() == "tidal") return Source_Tidal;
|
||||
else if (url.scheme() == "subsonic") return Source_Subsonic;
|
||||
else if (url.scheme() == "qobuz") return Source_Qobuz;
|
||||
if (url.isLocalFile()) return Source::LocalFile;
|
||||
else if (url.scheme() == "cdda") return Source::CDDA;
|
||||
else if (url.scheme() == "tidal") return Source::Tidal;
|
||||
else if (url.scheme() == "subsonic") return Source::Subsonic;
|
||||
else if (url.scheme() == "qobuz") return Source::Qobuz;
|
||||
else if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "rtsp") {
|
||||
if (url.host().endsWith("tidal.com", Qt::CaseInsensitive)) { return Source_Tidal; }
|
||||
if (url.host().endsWith("qobuz.com", Qt::CaseInsensitive)) { return Source_Qobuz; }
|
||||
if (url.host().endsWith("somafm.com", Qt::CaseInsensitive)) { return Source_SomaFM; }
|
||||
if (url.host().endsWith("radioparadise.com", Qt::CaseInsensitive)) { return Source_RadioParadise; }
|
||||
return Source_Stream;
|
||||
if (url.host().endsWith("tidal.com", Qt::CaseInsensitive)) { return Source::Tidal; }
|
||||
if (url.host().endsWith("qobuz.com", Qt::CaseInsensitive)) { return Source::Qobuz; }
|
||||
if (url.host().endsWith("somafm.com", Qt::CaseInsensitive)) { return Source::SomaFM; }
|
||||
if (url.host().endsWith("radioparadise.com", Qt::CaseInsensitive)) { return Source::RadioParadise; }
|
||||
return Source::Stream;
|
||||
}
|
||||
else return Source_Unknown;
|
||||
else return Source::Unknown;
|
||||
|
||||
}
|
||||
|
||||
QString Song::TextForSource(Source source) {
|
||||
QString Song::TextForSource(const Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source_LocalFile: return "file";
|
||||
case Song::Source_Collection: return "collection";
|
||||
case Song::Source_CDDA: return "cd";
|
||||
case Song::Source_Device: return "device";
|
||||
case Song::Source_Stream: return "stream";
|
||||
case Song::Source_Tidal: return "tidal";
|
||||
case Song::Source_Subsonic: return "subsonic";
|
||||
case Song::Source_Qobuz: return "qobuz";
|
||||
case Song::Source_SomaFM: return "somafm";
|
||||
case Song::Source_RadioParadise: return "radioparadise";
|
||||
case Song::Source_Unknown: return "unknown";
|
||||
case Source::LocalFile: return "file";
|
||||
case Source::Collection: return "collection";
|
||||
case Source::CDDA: return "cd";
|
||||
case Source::Device: return "device";
|
||||
case Source::Stream: return "stream";
|
||||
case Source::Tidal: return "tidal";
|
||||
case Source::Subsonic: return "subsonic";
|
||||
case Source::Qobuz: return "qobuz";
|
||||
case Source::SomaFM: return "somafm";
|
||||
case Source::RadioParadise: return "radioparadise";
|
||||
case Source::Unknown: return "unknown";
|
||||
}
|
||||
return "unknown";
|
||||
|
||||
}
|
||||
|
||||
QString Song::DescriptionForSource(Source source) {
|
||||
QString Song::DescriptionForSource(const Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source_LocalFile: return "File";
|
||||
case Song::Source_Collection: return "Collection";
|
||||
case Song::Source_CDDA: return "CD";
|
||||
case Song::Source_Device: return "Device";
|
||||
case Song::Source_Stream: return "Stream";
|
||||
case Song::Source_Tidal: return "Tidal";
|
||||
case Song::Source_Subsonic: return "Subsonic";
|
||||
case Song::Source_Qobuz: return "Qobuz";
|
||||
case Song::Source_SomaFM: return "SomaFM";
|
||||
case Song::Source_RadioParadise: return "Radio Paradise";
|
||||
case Song::Source_Unknown: return "Unknown";
|
||||
case Source::LocalFile: return "File";
|
||||
case Source::Collection: return "Collection";
|
||||
case Source::CDDA: return "CD";
|
||||
case Source::Device: return "Device";
|
||||
case Source::Stream: return "Stream";
|
||||
case Source::Tidal: return "Tidal";
|
||||
case Source::Subsonic: return "Subsonic";
|
||||
case Source::Qobuz: return "Qobuz";
|
||||
case Source::SomaFM: return "SomaFM";
|
||||
case Source::RadioParadise: return "Radio Paradise";
|
||||
case Source::Unknown: return "Unknown";
|
||||
}
|
||||
return "unknown";
|
||||
|
||||
@@ -543,132 +607,132 @@ QString Song::DescriptionForSource(Source source) {
|
||||
|
||||
Song::Source Song::SourceFromText(const QString &source) {
|
||||
|
||||
if (source.compare("file", Qt::CaseInsensitive) == 0) return Source_LocalFile;
|
||||
if (source.compare("collection", Qt::CaseInsensitive) == 0) return Source_Collection;
|
||||
if (source.compare("cd", Qt::CaseInsensitive) == 0) return Source_CDDA;
|
||||
if (source.compare("device", Qt::CaseInsensitive) == 0) return Source_Device;
|
||||
if (source.compare("stream", Qt::CaseInsensitive) == 0) return Source_Stream;
|
||||
if (source.compare("tidal", Qt::CaseInsensitive) == 0) return Source_Tidal;
|
||||
if (source.compare("subsonic", Qt::CaseInsensitive) == 0) return Source_Subsonic;
|
||||
if (source.compare("qobuz", Qt::CaseInsensitive) == 0) return Source_Qobuz;
|
||||
if (source.compare("somafm", Qt::CaseInsensitive) == 0) return Source_SomaFM;
|
||||
if (source.compare("radioparadise", Qt::CaseInsensitive) == 0) return Source_RadioParadise;
|
||||
if (source.compare("file", Qt::CaseInsensitive) == 0) return Source::LocalFile;
|
||||
if (source.compare("collection", Qt::CaseInsensitive) == 0) return Source::Collection;
|
||||
if (source.compare("cd", Qt::CaseInsensitive) == 0) return Source::CDDA;
|
||||
if (source.compare("device", Qt::CaseInsensitive) == 0) return Source::Device;
|
||||
if (source.compare("stream", Qt::CaseInsensitive) == 0) return Source::Stream;
|
||||
if (source.compare("tidal", Qt::CaseInsensitive) == 0) return Source::Tidal;
|
||||
if (source.compare("subsonic", Qt::CaseInsensitive) == 0) return Source::Subsonic;
|
||||
if (source.compare("qobuz", Qt::CaseInsensitive) == 0) return Source::Qobuz;
|
||||
if (source.compare("somafm", Qt::CaseInsensitive) == 0) return Source::SomaFM;
|
||||
if (source.compare("radioparadise", Qt::CaseInsensitive) == 0) return Source::RadioParadise;
|
||||
|
||||
return Source_Unknown;
|
||||
return Source::Unknown;
|
||||
|
||||
}
|
||||
|
||||
QIcon Song::IconForSource(Source source) {
|
||||
QIcon Song::IconForSource(const Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source_LocalFile: return IconLoader::Load("folder-sound");
|
||||
case Song::Source_Collection: return IconLoader::Load("library-music");
|
||||
case Song::Source_CDDA: return IconLoader::Load("media-optical");
|
||||
case Song::Source_Device: return IconLoader::Load("device");
|
||||
case Song::Source_Stream: return IconLoader::Load("applications-internet");
|
||||
case Song::Source_Tidal: return IconLoader::Load("tidal");
|
||||
case Song::Source_Subsonic: return IconLoader::Load("subsonic");
|
||||
case Song::Source_Qobuz: return IconLoader::Load("qobuz");
|
||||
case Song::Source_SomaFM: return IconLoader::Load("somafm");
|
||||
case Song::Source_RadioParadise: return IconLoader::Load("radioparadise");
|
||||
case Song::Source_Unknown: return IconLoader::Load("edit-delete");
|
||||
case Source::LocalFile: return IconLoader::Load("folder-sound");
|
||||
case Source::Collection: return IconLoader::Load("library-music");
|
||||
case Source::CDDA: return IconLoader::Load("media-optical");
|
||||
case Source::Device: return IconLoader::Load("device");
|
||||
case Source::Stream: return IconLoader::Load("applications-internet");
|
||||
case Source::Tidal: return IconLoader::Load("tidal");
|
||||
case Source::Subsonic: return IconLoader::Load("subsonic");
|
||||
case Source::Qobuz: return IconLoader::Load("qobuz");
|
||||
case Source::SomaFM: return IconLoader::Load("somafm");
|
||||
case Source::RadioParadise: return IconLoader::Load("radioparadise");
|
||||
case Source::Unknown: return IconLoader::Load("edit-delete");
|
||||
}
|
||||
return IconLoader::Load("edit-delete");
|
||||
|
||||
}
|
||||
|
||||
QString Song::TextForFiletype(FileType filetype) {
|
||||
QString Song::TextForFiletype(const FileType filetype) {
|
||||
|
||||
switch (filetype) {
|
||||
case Song::FileType_WAV: return "Wav";
|
||||
case Song::FileType_FLAC: return "FLAC";
|
||||
case Song::FileType_WavPack: return "WavPack";
|
||||
case Song::FileType_OggFlac: return "Ogg FLAC";
|
||||
case Song::FileType_OggVorbis: return "Ogg Vorbis";
|
||||
case Song::FileType_OggOpus: return "Ogg Opus";
|
||||
case Song::FileType_OggSpeex: return "Ogg Speex";
|
||||
case Song::FileType_MPEG: return "MP3";
|
||||
case Song::FileType_MP4: return "MP4 AAC";
|
||||
case Song::FileType_ASF: return "Windows Media audio";
|
||||
case Song::FileType_AIFF: return "AIFF";
|
||||
case Song::FileType_MPC: return "MPC";
|
||||
case Song::FileType_TrueAudio: return "TrueAudio";
|
||||
case Song::FileType_DSF: return "DSF";
|
||||
case Song::FileType_DSDIFF: return "DSDIFF";
|
||||
case Song::FileType_PCM: return "PCM";
|
||||
case Song::FileType_APE: return "Monkey's Audio";
|
||||
case Song::FileType_MOD: return "Module Music Format";
|
||||
case Song::FileType_S3M: return "Module Music Format";
|
||||
case Song::FileType_XM: return "Module Music Format";
|
||||
case Song::FileType_IT: return "Module Music Format";
|
||||
case Song::FileType_CDDA: return "CDDA";
|
||||
case Song::FileType_SPC: return "SNES SPC700";
|
||||
case Song::FileType_VGM: return "VGM";
|
||||
case Song::FileType_Stream: return "Stream";
|
||||
case Song::FileType_Unknown:
|
||||
case FileType::WAV: return "Wav";
|
||||
case FileType::FLAC: return "FLAC";
|
||||
case FileType::WavPack: return "WavPack";
|
||||
case FileType::OggFlac: return "Ogg FLAC";
|
||||
case FileType::OggVorbis: return "Ogg Vorbis";
|
||||
case FileType::OggOpus: return "Ogg Opus";
|
||||
case FileType::OggSpeex: return "Ogg Speex";
|
||||
case FileType::MPEG: return "MP3";
|
||||
case FileType::MP4: return "MP4 AAC";
|
||||
case FileType::ASF: return "Windows Media audio";
|
||||
case FileType::AIFF: return "AIFF";
|
||||
case FileType::MPC: return "MPC";
|
||||
case FileType::TrueAudio: return "TrueAudio";
|
||||
case FileType::DSF: return "DSF";
|
||||
case FileType::DSDIFF: return "DSDIFF";
|
||||
case FileType::PCM: return "PCM";
|
||||
case FileType::APE: return "Monkey's Audio";
|
||||
case FileType::MOD: return "Module Music Format";
|
||||
case FileType::S3M: return "Module Music Format";
|
||||
case FileType::XM: return "Module Music Format";
|
||||
case FileType::IT: return "Module Music Format";
|
||||
case FileType::CDDA: return "CDDA";
|
||||
case FileType::SPC: return "SNES SPC700";
|
||||
case FileType::VGM: return "VGM";
|
||||
case FileType::Stream: return "Stream";
|
||||
case FileType::Unknown:
|
||||
default: return QObject::tr("Unknown");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString Song::ExtensionForFiletype(FileType filetype) {
|
||||
QString Song::ExtensionForFiletype(const FileType filetype) {
|
||||
|
||||
switch (filetype) {
|
||||
case Song::FileType_WAV: return "wav";
|
||||
case Song::FileType_FLAC: return "flac";
|
||||
case Song::FileType_WavPack: return "wv";
|
||||
case Song::FileType_OggFlac: return "flac";
|
||||
case Song::FileType_OggVorbis: return "ogg";
|
||||
case Song::FileType_OggOpus: return "opus";
|
||||
case Song::FileType_OggSpeex: return "spx";
|
||||
case Song::FileType_MPEG: return "mp3";
|
||||
case Song::FileType_MP4: return "mp4";
|
||||
case Song::FileType_ASF: return "wma";
|
||||
case Song::FileType_AIFF: return "aiff";
|
||||
case Song::FileType_MPC: return "mpc";
|
||||
case Song::FileType_TrueAudio: return "tta";
|
||||
case Song::FileType_DSF: return "dsf";
|
||||
case Song::FileType_DSDIFF: return "dsd";
|
||||
case Song::FileType_APE: return "ape";
|
||||
case Song::FileType_MOD: return "mod";
|
||||
case Song::FileType_S3M: return "s3m";
|
||||
case Song::FileType_XM: return "xm";
|
||||
case Song::FileType_IT: return "it";
|
||||
case Song::FileType_SPC: return "spc";
|
||||
case Song::FileType_VGM: return "vgm";
|
||||
case Song::FileType_Unknown:
|
||||
case FileType::WAV: return "wav";
|
||||
case FileType::FLAC: return "flac";
|
||||
case FileType::WavPack: return "wv";
|
||||
case FileType::OggFlac: return "flac";
|
||||
case FileType::OggVorbis: return "ogg";
|
||||
case FileType::OggOpus: return "opus";
|
||||
case FileType::OggSpeex: return "spx";
|
||||
case FileType::MPEG: return "mp3";
|
||||
case FileType::MP4: return "mp4";
|
||||
case FileType::ASF: return "wma";
|
||||
case FileType::AIFF: return "aiff";
|
||||
case FileType::MPC: return "mpc";
|
||||
case FileType::TrueAudio: return "tta";
|
||||
case FileType::DSF: return "dsf";
|
||||
case FileType::DSDIFF: return "dsd";
|
||||
case FileType::APE: return "ape";
|
||||
case FileType::MOD: return "mod";
|
||||
case FileType::S3M: return "s3m";
|
||||
case FileType::XM: return "xm";
|
||||
case FileType::IT: return "it";
|
||||
case FileType::SPC: return "spc";
|
||||
case FileType::VGM: return "vgm";
|
||||
case FileType::Unknown:
|
||||
default: return "dat";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QIcon Song::IconForFiletype(FileType filetype) {
|
||||
QIcon Song::IconForFiletype(const FileType filetype) {
|
||||
|
||||
switch (filetype) {
|
||||
case Song::FileType_WAV: return IconLoader::Load("wav");
|
||||
case Song::FileType_FLAC: return IconLoader::Load("flac");
|
||||
case Song::FileType_WavPack: return IconLoader::Load("wavpack");
|
||||
case Song::FileType_OggFlac: return IconLoader::Load("flac");
|
||||
case Song::FileType_OggVorbis: return IconLoader::Load("vorbis");
|
||||
case Song::FileType_OggOpus: return IconLoader::Load("opus");
|
||||
case Song::FileType_OggSpeex: return IconLoader::Load("speex");
|
||||
case Song::FileType_MPEG: return IconLoader::Load("mp3");
|
||||
case Song::FileType_MP4: return IconLoader::Load("mp4");
|
||||
case Song::FileType_ASF: return IconLoader::Load("wma");
|
||||
case Song::FileType_AIFF: return IconLoader::Load("aiff");
|
||||
case Song::FileType_MPC: return IconLoader::Load("mpc");
|
||||
case Song::FileType_TrueAudio: return IconLoader::Load("trueaudio");
|
||||
case Song::FileType_DSF: return IconLoader::Load("dsf");
|
||||
case Song::FileType_DSDIFF: return IconLoader::Load("dsd");
|
||||
case Song::FileType_PCM: return IconLoader::Load("pcm");
|
||||
case Song::FileType_APE: return IconLoader::Load("ape");
|
||||
case Song::FileType_MOD: return IconLoader::Load("mod");
|
||||
case Song::FileType_S3M: return IconLoader::Load("s3m");
|
||||
case Song::FileType_XM: return IconLoader::Load("xm");
|
||||
case Song::FileType_IT: return IconLoader::Load("it");
|
||||
case Song::FileType_CDDA: return IconLoader::Load("cd");
|
||||
case Song::FileType_Stream: return IconLoader::Load("applications-internet");
|
||||
case Song::FileType_Unknown:
|
||||
case FileType::WAV: return IconLoader::Load("wav");
|
||||
case FileType::FLAC: return IconLoader::Load("flac");
|
||||
case FileType::WavPack: return IconLoader::Load("wavpack");
|
||||
case FileType::OggFlac: return IconLoader::Load("flac");
|
||||
case FileType::OggVorbis: return IconLoader::Load("vorbis");
|
||||
case FileType::OggOpus: return IconLoader::Load("opus");
|
||||
case FileType::OggSpeex: return IconLoader::Load("speex");
|
||||
case FileType::MPEG: return IconLoader::Load("mp3");
|
||||
case FileType::MP4: return IconLoader::Load("mp4");
|
||||
case FileType::ASF: return IconLoader::Load("wma");
|
||||
case FileType::AIFF: return IconLoader::Load("aiff");
|
||||
case FileType::MPC: return IconLoader::Load("mpc");
|
||||
case FileType::TrueAudio: return IconLoader::Load("trueaudio");
|
||||
case FileType::DSF: return IconLoader::Load("dsf");
|
||||
case FileType::DSDIFF: return IconLoader::Load("dsd");
|
||||
case FileType::PCM: return IconLoader::Load("pcm");
|
||||
case FileType::APE: return IconLoader::Load("ape");
|
||||
case FileType::MOD: return IconLoader::Load("mod");
|
||||
case FileType::S3M: return IconLoader::Load("s3m");
|
||||
case FileType::XM: return IconLoader::Load("xm");
|
||||
case FileType::IT: return IconLoader::Load("it");
|
||||
case FileType::CDDA: return IconLoader::Load("cd");
|
||||
case FileType::Stream: return IconLoader::Load("applications-internet");
|
||||
case FileType::Unknown:
|
||||
default: return IconLoader::Load("edit-delete");
|
||||
}
|
||||
|
||||
@@ -676,17 +740,17 @@ QIcon Song::IconForFiletype(FileType filetype) {
|
||||
|
||||
bool Song::IsFileLossless() const {
|
||||
switch (filetype()) {
|
||||
case Song::FileType_WAV:
|
||||
case Song::FileType_FLAC:
|
||||
case Song::FileType_OggFlac:
|
||||
case Song::FileType_WavPack:
|
||||
case Song::FileType_AIFF:
|
||||
case Song::FileType_DSF:
|
||||
case Song::FileType_DSDIFF:
|
||||
case Song::FileType_APE:
|
||||
case Song::FileType_TrueAudio:
|
||||
case Song::FileType_PCM:
|
||||
case Song::FileType_CDDA:
|
||||
case FileType::WAV:
|
||||
case FileType::FLAC:
|
||||
case FileType::OggFlac:
|
||||
case FileType::WavPack:
|
||||
case FileType::AIFF:
|
||||
case FileType::DSF:
|
||||
case FileType::DSDIFF:
|
||||
case FileType::APE:
|
||||
case FileType::TrueAudio:
|
||||
case FileType::PCM:
|
||||
case FileType::CDDA:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -695,103 +759,103 @@ bool Song::IsFileLossless() const {
|
||||
|
||||
Song::FileType Song::FiletypeByMimetype(const QString &mimetype) {
|
||||
|
||||
if (mimetype.compare("audio/wav", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-wav", Qt::CaseInsensitive) == 0) return Song::FileType_WAV;
|
||||
else if (mimetype.compare("audio/x-flac", Qt::CaseInsensitive) == 0) return Song::FileType_FLAC;
|
||||
else if (mimetype.compare("audio/x-wavpack", Qt::CaseInsensitive) == 0) return Song::FileType_WavPack;
|
||||
else if (mimetype.compare("audio/x-vorbis", Qt::CaseInsensitive) == 0) return Song::FileType_OggVorbis;
|
||||
else if (mimetype.compare("audio/x-opus", Qt::CaseInsensitive) == 0) return Song::FileType_OggOpus;
|
||||
else if (mimetype.compare("audio/x-speex", Qt::CaseInsensitive) == 0) return Song::FileType_OggSpeex;
|
||||
if (mimetype.compare("audio/wav", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-wav", Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
else if (mimetype.compare("audio/x-flac", Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
else if (mimetype.compare("audio/x-wavpack", Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
else if (mimetype.compare("audio/x-vorbis", Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
else if (mimetype.compare("audio/x-opus", Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
else if (mimetype.compare("audio/x-speex", Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
// Gstreamer returns audio/mpeg for both MP3 and MP4/AAC.
|
||||
// else if (mimetype.compare("audio/mpeg", Qt::CaseInsensitive) == 0) return Song::FileType_MPEG;
|
||||
else if (mimetype.compare("audio/aac", Qt::CaseInsensitive) == 0) return Song::FileType_MP4;
|
||||
else if (mimetype.compare("audio/x-wma", Qt::CaseInsensitive) == 0) return Song::FileType_ASF;
|
||||
else if (mimetype.compare("audio/aiff", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-aiff", Qt::CaseInsensitive) == 0) return Song::FileType_AIFF;
|
||||
else if (mimetype.compare("application/x-project", Qt::CaseInsensitive) == 0) return Song::FileType_MPC;
|
||||
else if (mimetype.compare("audio/x-dsf", Qt::CaseInsensitive) == 0) return Song::FileType_DSF;
|
||||
else if (mimetype.compare("audio/x-dsd", Qt::CaseInsensitive) == 0) return Song::FileType_DSDIFF;
|
||||
else if (mimetype.compare("audio/x-ape", Qt::CaseInsensitive) == 0 || mimetype.compare("application/x-ape", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-ffmpeg-parsed-ape", Qt::CaseInsensitive) == 0) return Song::FileType_APE;
|
||||
else if (mimetype.compare("audio/x-mod", Qt::CaseInsensitive) == 0) return Song::FileType_MOD;
|
||||
else if (mimetype.compare("audio/x-s3m", Qt::CaseInsensitive) == 0) return Song::FileType_S3M;
|
||||
else if (mimetype.compare("audio/x-spc", Qt::CaseInsensitive) == 0) return Song::FileType_SPC;
|
||||
else if (mimetype.compare("audio/x-vgm", Qt::CaseInsensitive) == 0) return Song::FileType_VGM;
|
||||
// else if (mimetype.compare("audio/mpeg", Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
else if (mimetype.compare("audio/aac", Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
else if (mimetype.compare("audio/x-wma", Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
else if (mimetype.compare("audio/aiff", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-aiff", Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
else if (mimetype.compare("application/x-project", Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
else if (mimetype.compare("audio/x-dsf", Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
else if (mimetype.compare("audio/x-dsd", Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
else if (mimetype.compare("audio/x-ape", Qt::CaseInsensitive) == 0 || mimetype.compare("application/x-ape", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-ffmpeg-parsed-ape", Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
else if (mimetype.compare("audio/x-mod", Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
else if (mimetype.compare("audio/x-s3m", Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
else if (mimetype.compare("audio/x-spc", Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
else if (mimetype.compare("audio/x-vgm", Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
|
||||
else return Song::FileType_Unknown;
|
||||
else return FileType::Unknown;
|
||||
|
||||
}
|
||||
|
||||
Song::FileType Song::FiletypeByDescription(const QString &text) {
|
||||
|
||||
if (text.compare("WAV", Qt::CaseInsensitive) == 0) return Song::FileType_WAV;
|
||||
else if (text.compare("Free Lossless Audio Codec (FLAC)", Qt::CaseInsensitive) == 0) return Song::FileType_FLAC;
|
||||
else if (text.compare("Wavpack", Qt::CaseInsensitive) == 0) return Song::FileType_WavPack;
|
||||
else if (text.compare("Vorbis", Qt::CaseInsensitive) == 0) return Song::FileType_OggVorbis;
|
||||
else if (text.compare("Opus", Qt::CaseInsensitive) == 0) return Song::FileType_OggOpus;
|
||||
else if (text.compare("Speex", Qt::CaseInsensitive) == 0) return Song::FileType_OggSpeex;
|
||||
else if (text.compare("MPEG-1 Layer 3 (MP3)", Qt::CaseInsensitive) == 0) return Song::FileType_MPEG;
|
||||
else if (text.compare("MPEG-4 AAC", Qt::CaseInsensitive) == 0) return Song::FileType_MP4;
|
||||
else if (text.compare("WMA", Qt::CaseInsensitive) == 0) return Song::FileType_ASF;
|
||||
else if (text.compare("Audio Interchange File Format", Qt::CaseInsensitive) == 0) return Song::FileType_AIFF;
|
||||
else if (text.compare("MPC", Qt::CaseInsensitive) == 0) return Song::FileType_MPC;
|
||||
else if (text.compare("audio/x-dsf", Qt::CaseInsensitive) == 0) return Song::FileType_DSF;
|
||||
else if (text.compare("audio/x-dsd", Qt::CaseInsensitive) == 0) return Song::FileType_DSDIFF;
|
||||
else if (text.compare("audio/x-ffmpeg-parsed-ape", Qt::CaseInsensitive) == 0) return Song::FileType_APE;
|
||||
else if (text.compare("Module Music Format (MOD)", Qt::CaseInsensitive) == 0) return Song::FileType_MOD;
|
||||
else if (text.compare("Module Music Format (MOD)", Qt::CaseInsensitive) == 0) return Song::FileType_S3M;
|
||||
else if (text.compare("SNES SPC700", Qt::CaseInsensitive) == 0) return Song::FileType_SPC;
|
||||
else if (text.compare("VGM", Qt::CaseInsensitive) == 0) return Song::FileType_VGM;
|
||||
else return Song::FileType_Unknown;
|
||||
if (text.compare("WAV", Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
else if (text.compare("Free Lossless Audio Codec (FLAC)", Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
else if (text.compare("Wavpack", Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
else if (text.compare("Vorbis", Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
else if (text.compare("Opus", Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
else if (text.compare("Speex", Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
else if (text.compare("MPEG-1 Layer 3 (MP3)", Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
else if (text.compare("MPEG-4 AAC", Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
else if (text.compare("WMA", Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
else if (text.compare("Audio Interchange File Format", Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
else if (text.compare("MPC", Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
else if (text.compare("audio/x-dsf", Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
else if (text.compare("audio/x-dsd", Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
else if (text.compare("audio/x-ffmpeg-parsed-ape", Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
else if (text.compare("Module Music Format (MOD)", Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
else if (text.compare("Module Music Format (MOD)", Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
else if (text.compare("SNES SPC700", Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
else if (text.compare("VGM", Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
else return FileType::Unknown;
|
||||
|
||||
}
|
||||
|
||||
Song::FileType Song::FiletypeByExtension(const QString &ext) {
|
||||
|
||||
if (ext.compare("wav", Qt::CaseInsensitive) == 0 || ext.compare("wave", Qt::CaseInsensitive) == 0) return Song::FileType_WAV;
|
||||
else if (ext.compare("flac", Qt::CaseInsensitive) == 0) return Song::FileType_FLAC;
|
||||
else if (ext.compare("wavpack", Qt::CaseInsensitive) == 0 || ext.compare("wv", Qt::CaseInsensitive) == 0) return Song::FileType_WavPack;
|
||||
else if (ext.compare("ogg", Qt::CaseInsensitive) == 0 || ext.compare("oga", Qt::CaseInsensitive) == 0) return Song::FileType_OggVorbis;
|
||||
else if (ext.compare("opus", Qt::CaseInsensitive) == 0) return Song::FileType_OggOpus;
|
||||
else if (ext.compare("speex", Qt::CaseInsensitive) == 0 || ext.compare("spx", Qt::CaseInsensitive) == 0) return Song::FileType_OggSpeex;
|
||||
else if (ext.compare("mp3", Qt::CaseInsensitive) == 0) return Song::FileType_MPEG;
|
||||
else if (ext.compare("mp4", Qt::CaseInsensitive) == 0 || ext.compare("m4a", Qt::CaseInsensitive) == 0 || ext.compare("aac", Qt::CaseInsensitive) == 0) return Song::FileType_MP4;
|
||||
else if (ext.compare("asf", Qt::CaseInsensitive) == 0 || ext.compare("wma", Qt::CaseInsensitive) == 0) return Song::FileType_ASF;
|
||||
else if (ext.compare("aiff", Qt::CaseInsensitive) == 0 || ext.compare("aif", Qt::CaseInsensitive) == 0 || ext.compare("aifc", Qt::CaseInsensitive) == 0) return Song::FileType_AIFF;
|
||||
else if (ext.compare("mpc", Qt::CaseInsensitive) == 0 || ext.compare("mp+", Qt::CaseInsensitive) == 0 || ext.compare("mpp", Qt::CaseInsensitive) == 0) return Song::FileType_MPC;
|
||||
else if (ext.compare("dsf", Qt::CaseInsensitive) == 0) return Song::FileType_DSF;
|
||||
else if (ext.compare("dsd", Qt::CaseInsensitive) == 0 || ext.compare("dff", Qt::CaseInsensitive) == 0) return Song::FileType_DSDIFF;
|
||||
else if (ext.compare("ape", Qt::CaseInsensitive) == 0) return Song::FileType_APE;
|
||||
if (ext.compare("wav", Qt::CaseInsensitive) == 0 || ext.compare("wave", Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
else if (ext.compare("flac", Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
else if (ext.compare("wavpack", Qt::CaseInsensitive) == 0 || ext.compare("wv", Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
else if (ext.compare("ogg", Qt::CaseInsensitive) == 0 || ext.compare("oga", Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
else if (ext.compare("opus", Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
else if (ext.compare("speex", Qt::CaseInsensitive) == 0 || ext.compare("spx", Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
else if (ext.compare("mp3", Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
else if (ext.compare("mp4", Qt::CaseInsensitive) == 0 || ext.compare("m4a", Qt::CaseInsensitive) == 0 || ext.compare("aac", Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
else if (ext.compare("asf", Qt::CaseInsensitive) == 0 || ext.compare("wma", Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
else if (ext.compare("aiff", Qt::CaseInsensitive) == 0 || ext.compare("aif", Qt::CaseInsensitive) == 0 || ext.compare("aifc", Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
else if (ext.compare("mpc", Qt::CaseInsensitive) == 0 || ext.compare("mp+", Qt::CaseInsensitive) == 0 || ext.compare("mpp", Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
else if (ext.compare("dsf", Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
else if (ext.compare("dsd", Qt::CaseInsensitive) == 0 || ext.compare("dff", Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
else if (ext.compare("ape", Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
else if (ext.compare("mod", Qt::CaseInsensitive) == 0 ||
|
||||
ext.compare("module", Qt::CaseInsensitive) == 0 ||
|
||||
ext.compare("nst", Qt::CaseInsensitive) == 0||
|
||||
ext.compare("wow", Qt::CaseInsensitive) == 0) return Song::FileType_MOD;
|
||||
else if (ext.compare("s3m", Qt::CaseInsensitive) == 0) return Song::FileType_S3M;
|
||||
else if (ext.compare("xm", Qt::CaseInsensitive) == 0) return Song::FileType_XM;
|
||||
else if (ext.compare("it", Qt::CaseInsensitive) == 0) return Song::FileType_IT;
|
||||
else if (ext.compare("spc", Qt::CaseInsensitive) == 0) return Song::FileType_SPC;
|
||||
else if (ext.compare("vgm", Qt::CaseInsensitive) == 0) return Song::FileType_VGM;
|
||||
ext.compare("wow", Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
else if (ext.compare("s3m", Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
else if (ext.compare("xm", Qt::CaseInsensitive) == 0) return FileType::XM;
|
||||
else if (ext.compare("it", Qt::CaseInsensitive) == 0) return FileType::IT;
|
||||
else if (ext.compare("spc", Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
else if (ext.compare("vgm", Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
|
||||
else return Song::FileType_Unknown;
|
||||
else return FileType::Unknown;
|
||||
|
||||
}
|
||||
|
||||
QString Song::ImageCacheDir(const Song::Source source) {
|
||||
QString Song::ImageCacheDir(const Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source_Collection:
|
||||
case Source::Collection:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/collectionalbumcovers";
|
||||
case Song::Source_Subsonic:
|
||||
case Source::Subsonic:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/subsonicalbumcovers";
|
||||
case Song::Source_Tidal:
|
||||
case Source::Tidal:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/tidalalbumcovers";
|
||||
case Song::Source_Qobuz:
|
||||
case Source::Qobuz:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/qobuzalbumcovers";
|
||||
case Song::Source_Device:
|
||||
case Source::Device:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/devicealbumcovers";
|
||||
case Song::Source_LocalFile:
|
||||
case Song::Source_CDDA:
|
||||
case Song::Source_Stream:
|
||||
case Song::Source_SomaFM:
|
||||
case Song::Source_RadioParadise:
|
||||
case Song::Source_Unknown:
|
||||
case Source::LocalFile:
|
||||
case Source::CDDA:
|
||||
case Source::Stream:
|
||||
case Source::SomaFM:
|
||||
case Source::RadioParadise:
|
||||
case Source::Unknown:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/albumcovers";
|
||||
}
|
||||
|
||||
@@ -835,7 +899,7 @@ void Song::Init(const QString &title, const QString &artist, const QString &albu
|
||||
|
||||
void Song::InitFromProtobuf(const spb::tagreader::SongMetadata &pb) {
|
||||
|
||||
if (d->source_ == Source_Unknown) d->source_ = Source_LocalFile;
|
||||
if (d->source_ == Source::Unknown) d->source_ = Source::LocalFile;
|
||||
|
||||
d->init_from_file_ = true;
|
||||
d->valid_ = pb.valid();
|
||||
@@ -1004,7 +1068,7 @@ void Song::InitFromFilePartial(const QString &filename, const QFileInfo &fileinf
|
||||
|
||||
set_url(QUrl::fromLocalFile(filename));
|
||||
d->valid_ = true;
|
||||
d->source_ = Source_LocalFile;
|
||||
d->source_ = Source::LocalFile;
|
||||
d->filetype_ = FiletypeByExtension(fileinfo.suffix());
|
||||
d->basefilename_ = fileinfo.fileName();
|
||||
d->title_ = fileinfo.fileName();
|
||||
@@ -1014,12 +1078,9 @@ void Song::InitFromFilePartial(const QString &filename, const QFileInfo &fileinf
|
||||
|
||||
void Song::InitArtManual() {
|
||||
|
||||
QString album = effective_album();
|
||||
album.remove(Song::kAlbumRemoveDisc);
|
||||
|
||||
// If we don't have an art, check if we have one in the cache
|
||||
if (d->art_manual_.isEmpty() && d->art_automatic_.isEmpty() && !effective_albumartist().isEmpty() && !album.isEmpty()) {
|
||||
QString filename(Utilities::Sha1CoverHash(effective_albumartist(), album).toHex() + ".jpg");
|
||||
if (d->art_manual_.isEmpty() && d->art_automatic_.isEmpty() && !effective_albumartist().isEmpty() && !effective_album().isEmpty()) {
|
||||
QString filename(Utilities::Sha1CoverHash(effective_albumartist(), effective_album()).toHex() + ".jpg");
|
||||
QString path(ImageCacheDir(d->source_) + "/" + filename);
|
||||
if (QFile::exists(path)) {
|
||||
d->art_manual_ = QUrl::fromLocalFile(path);
|
||||
@@ -1030,7 +1091,7 @@ void Song::InitArtManual() {
|
||||
|
||||
void Song::InitArtAutomatic() {
|
||||
|
||||
if (d->source_ == Source_LocalFile && d->url_.isLocalFile() && d->art_automatic_.isEmpty()) {
|
||||
if (d->source_ == Source::LocalFile && d->url_.isLocalFile() && d->art_automatic_.isEmpty()) {
|
||||
// Pick the first image file in the album directory.
|
||||
QFileInfo file(d->url_.toLocalFile());
|
||||
QDir dir(file.path());
|
||||
@@ -1066,7 +1127,7 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
d->samplerate_ = track->samplerate;
|
||||
d->bitdepth_ = -1; //track->bitdepth;
|
||||
|
||||
d->source_ = Source_Device;
|
||||
d->source_ = Source::Device;
|
||||
QString filename = QString::fromLocal8Bit(track->ipod_path);
|
||||
filename.replace(':', '/');
|
||||
if (prefix.contains("://")) {
|
||||
@@ -1077,7 +1138,7 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
}
|
||||
d->basefilename_ = QFileInfo(filename).fileName();
|
||||
|
||||
d->filetype_ = track->type2 ? FileType_MPEG : FileType_MP4;
|
||||
d->filetype_ = track->type2 ? FileType::MPEG : FileType::MP4;
|
||||
d->filesize_ = track->size;
|
||||
d->mtime_ = track->time_modified;
|
||||
d->ctime_ = track->time_added;
|
||||
@@ -1089,7 +1150,7 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
if (itdb_track_has_thumbnails(track) && !d->artist_.isEmpty() && !d->title_.isEmpty()) {
|
||||
GdkPixbuf *pixbuf = static_cast<GdkPixbuf*>(itdb_track_get_thumbnail(track, -1, -1));
|
||||
if (pixbuf) {
|
||||
QString cover_path = ImageCacheDir(Source_Device);
|
||||
QString cover_path = ImageCacheDir(Source::Device);
|
||||
QDir dir(cover_path);
|
||||
if (!dir.exists()) dir.mkpath(cover_path);
|
||||
QString cover_file = cover_path + "/" + Utilities::Sha1CoverHash(effective_albumartist(), effective_album()).toHex() + ".jpg";
|
||||
@@ -1123,8 +1184,8 @@ void Song::ToItdb(Itdb_Track *track) const {
|
||||
track->bitrate = d->bitrate_;
|
||||
track->samplerate = d->samplerate_;
|
||||
|
||||
track->type1 = (d->filetype_ == FileType_MPEG ? 1 : 0);
|
||||
track->type2 = (d->filetype_ == FileType_MPEG ? 1 : 0);
|
||||
track->type1 = (d->filetype_ == FileType::MPEG ? 1 : 0);
|
||||
track->type2 = (d->filetype_ == FileType::MPEG ? 1 : 0);
|
||||
track->mediatype = 1; // Audio
|
||||
track->size = static_cast<uint>(d->filesize_);
|
||||
track->time_modified = d->mtime_;
|
||||
@@ -1141,7 +1202,7 @@ void Song::ToItdb(Itdb_Track *track) const {
|
||||
void Song::InitFromMTP(const LIBMTP_track_t *track, const QString &host) {
|
||||
|
||||
d->valid_ = true;
|
||||
d->source_ = Source_Device;
|
||||
d->source_ = Source::Device;
|
||||
|
||||
set_title(QString::fromUtf8(track->title));
|
||||
set_artist(QString::fromUtf8(track->artist));
|
||||
@@ -1165,19 +1226,19 @@ void Song::InitFromMTP(const LIBMTP_track_t *track, const QString &host) {
|
||||
d->playcount_ = track->usecount;
|
||||
|
||||
switch (track->filetype) {
|
||||
case LIBMTP_FILETYPE_WAV: d->filetype_ = FileType_WAV; break;
|
||||
case LIBMTP_FILETYPE_MP3: d->filetype_ = FileType_MPEG; break;
|
||||
case LIBMTP_FILETYPE_WMA: d->filetype_ = FileType_ASF; break;
|
||||
case LIBMTP_FILETYPE_OGG: d->filetype_ = FileType_OggVorbis; break;
|
||||
case LIBMTP_FILETYPE_MP4: d->filetype_ = FileType_MP4; break;
|
||||
case LIBMTP_FILETYPE_AAC: d->filetype_ = FileType_MP4; break;
|
||||
case LIBMTP_FILETYPE_FLAC: d->filetype_ = FileType_OggFlac; break;
|
||||
case LIBMTP_FILETYPE_MP2: d->filetype_ = FileType_MPEG; break;
|
||||
case LIBMTP_FILETYPE_M4A: d->filetype_ = FileType_MP4; break;
|
||||
default:
|
||||
d->filetype_ = FileType_Unknown;
|
||||
d->valid_ = false;
|
||||
break;
|
||||
case LIBMTP_FILETYPE_WAV: d->filetype_ = FileType::WAV; break;
|
||||
case LIBMTP_FILETYPE_MP3: d->filetype_ = FileType::MPEG; break;
|
||||
case LIBMTP_FILETYPE_WMA: d->filetype_ = FileType::ASF; break;
|
||||
case LIBMTP_FILETYPE_OGG: d->filetype_ = FileType::OggVorbis; break;
|
||||
case LIBMTP_FILETYPE_MP4: d->filetype_ = FileType::MP4; break;
|
||||
case LIBMTP_FILETYPE_AAC: d->filetype_ = FileType::MP4; break;
|
||||
case LIBMTP_FILETYPE_FLAC: d->filetype_ = FileType::OggFlac; break;
|
||||
case LIBMTP_FILETYPE_MP2: d->filetype_ = FileType::MPEG; break;
|
||||
case LIBMTP_FILETYPE_M4A: d->filetype_ = FileType::MP4; break;
|
||||
default:
|
||||
d->filetype_ = FileType::Unknown;
|
||||
d->valid_ = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1215,14 +1276,14 @@ void Song::ToMTP(LIBMTP_track_t *track) const {
|
||||
track->usecount = d->playcount_;
|
||||
|
||||
switch (d->filetype_) {
|
||||
case FileType_ASF: track->filetype = LIBMTP_FILETYPE_ASF; break;
|
||||
case FileType_MP4: track->filetype = LIBMTP_FILETYPE_MP4; break;
|
||||
case FileType_MPEG: track->filetype = LIBMTP_FILETYPE_MP3; break;
|
||||
case FileType_FLAC:
|
||||
case FileType_OggFlac: track->filetype = LIBMTP_FILETYPE_FLAC; break;
|
||||
case FileType_OggSpeex:
|
||||
case FileType_OggVorbis: track->filetype = LIBMTP_FILETYPE_OGG; break;
|
||||
case FileType_WAV: track->filetype = LIBMTP_FILETYPE_WAV; break;
|
||||
case FileType::ASF: track->filetype = LIBMTP_FILETYPE_ASF; break;
|
||||
case FileType::MP4: track->filetype = LIBMTP_FILETYPE_MP4; break;
|
||||
case FileType::MPEG: track->filetype = LIBMTP_FILETYPE_MP3; break;
|
||||
case FileType::FLAC:
|
||||
case FileType::OggFlac: track->filetype = LIBMTP_FILETYPE_FLAC; break;
|
||||
case FileType::OggSpeex:
|
||||
case FileType::OggVorbis: track->filetype = LIBMTP_FILETYPE_OGG; break;
|
||||
case FileType::WAV: track->filetype = LIBMTP_FILETYPE_WAV; break;
|
||||
default: track->filetype = LIBMTP_FILETYPE_UNDEF_AUDIO; break;
|
||||
}
|
||||
|
||||
@@ -1274,7 +1335,7 @@ bool Song::MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) {
|
||||
if (bundle.length > 0) set_length_nanosec(bundle.length);
|
||||
if (bundle.year > 0) d->year_ = bundle.year;
|
||||
if (bundle.track > 0) d->track_ = bundle.track;
|
||||
if (bundle.filetype != FileType_Unknown) d->filetype_ = bundle.filetype;
|
||||
if (bundle.filetype != FileType::Unknown) d->filetype_ = bundle.filetype;
|
||||
if (bundle.samplerate > 0) d->samplerate_ = bundle.samplerate;
|
||||
if (bundle.bitdepth > 0) d->bitdepth_ = bundle.bitdepth;
|
||||
if (bundle.bitrate > 0) d->bitrate_ = bundle.bitrate;
|
||||
@@ -1314,10 +1375,10 @@ void Song::BindToQuery(SqlQuery *query) const {
|
||||
query->BindIntValue(":samplerate", d->samplerate_);
|
||||
query->BindIntValue(":bitdepth", d->bitdepth_);
|
||||
|
||||
query->BindValue(":source", d->source_);
|
||||
query->BindValue(":source", static_cast<int>(d->source_));
|
||||
query->BindNotNullIntValue(":directory_id", d->directory_id_);
|
||||
query->BindUrlValue(":url", d->url_);
|
||||
query->BindValue(":filetype", d->filetype_);
|
||||
query->BindValue(":filetype", static_cast<int>(d->filetype_));
|
||||
query->BindLongLongValueOrZero(":filesize", d->filesize_);
|
||||
query->BindLongLongValueOrZero(":mtime", d->mtime_);
|
||||
query->BindLongLongValueOrZero(":ctime", d->ctime_);
|
||||
@@ -1462,22 +1523,48 @@ bool Song::IsMetadataEqual(const Song &other) const {
|
||||
d->bitrate_ == other.d->bitrate_ &&
|
||||
d->samplerate_ == other.d->samplerate_ &&
|
||||
d->bitdepth_ == other.d->bitdepth_ &&
|
||||
d->cue_path_ == other.d->cue_path_ &&
|
||||
d->playcount_ == other.d->playcount_ &&
|
||||
d->rating_ == other.d->rating_;
|
||||
d->cue_path_ == other.d->cue_path_;
|
||||
}
|
||||
|
||||
bool Song::IsMetadataAndMoreEqual(const Song &other) const {
|
||||
bool Song::IsStatisticsEqual(const Song &other) const {
|
||||
|
||||
return IsMetadataEqual(other) &&
|
||||
d->fingerprint_ == other.d->fingerprint_ &&
|
||||
d->art_automatic_ == other.d->art_automatic_ &&
|
||||
return d->playcount_ == other.d->playcount_ &&
|
||||
d->skipcount_ == other.d->skipcount_ &&
|
||||
d->lastplayed_ == other.d->lastplayed_;
|
||||
|
||||
}
|
||||
|
||||
bool Song::IsRatingEqual(const Song &other) const {
|
||||
|
||||
return d->rating_ == other.d->rating_;
|
||||
|
||||
}
|
||||
|
||||
bool Song::IsFingerprintEqual(const Song &other) const {
|
||||
|
||||
return d->fingerprint_ == other.d->fingerprint_;
|
||||
|
||||
}
|
||||
|
||||
bool Song::IsArtEqual(const Song &other) const {
|
||||
|
||||
return d->art_automatic_ == other.d->art_automatic_ &&
|
||||
d->art_manual_ == other.d->art_manual_;
|
||||
|
||||
}
|
||||
|
||||
bool Song::IsAllMetadataEqual(const Song &other) const {
|
||||
|
||||
return IsMetadataEqual(other) &&
|
||||
IsStatisticsEqual(other) &&
|
||||
IsRatingEqual(other) &&
|
||||
IsFingerprintEqual(other) &&
|
||||
IsArtEqual(other);
|
||||
|
||||
}
|
||||
|
||||
bool Song::IsEditable() const {
|
||||
return d->valid_ && d->url_.isValid() && (d->url_.isLocalFile() || d->source_ == Source_Stream) && !has_cue();
|
||||
return d->valid_ && d->url_.isValid() && (d->url_.isLocalFile() || d->source_ == Source::Stream) && !has_cue();
|
||||
}
|
||||
|
||||
bool Song::operator==(const Song &other) const {
|
||||
@@ -1547,6 +1634,10 @@ void Song::ToXesam(QVariantMap *map) const {
|
||||
AddMetadataAsList("xesam:composer", composer(), map);
|
||||
AddMetadata("xesam:useCount", static_cast<int>(playcount()), map);
|
||||
|
||||
if (rating() != -1.0) {
|
||||
AddMetadata("xesam:userRating", rating(), map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Song::MergeUserSetData(const Song &other, const bool merge_playcount, const bool merge_rating) {
|
||||
|
||||
125
src/core/song.h
125
src/core/song.h
@@ -37,7 +37,6 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <QImage>
|
||||
#include <QIcon>
|
||||
|
||||
class SqlQuery;
|
||||
@@ -66,53 +65,53 @@ class Song {
|
||||
|
||||
public:
|
||||
|
||||
enum Source {
|
||||
Source_Unknown = 0,
|
||||
Source_LocalFile = 1,
|
||||
Source_Collection = 2,
|
||||
Source_CDDA = 3,
|
||||
Source_Device = 4,
|
||||
Source_Stream = 5,
|
||||
Source_Tidal = 6,
|
||||
Source_Subsonic = 7,
|
||||
Source_Qobuz = 8,
|
||||
Source_SomaFM = 9,
|
||||
Source_RadioParadise = 10
|
||||
enum class Source {
|
||||
Unknown = 0,
|
||||
LocalFile = 1,
|
||||
Collection = 2,
|
||||
CDDA = 3,
|
||||
Device = 4,
|
||||
Stream = 5,
|
||||
Tidal = 6,
|
||||
Subsonic = 7,
|
||||
Qobuz = 8,
|
||||
SomaFM = 9,
|
||||
RadioParadise = 10
|
||||
};
|
||||
|
||||
// Don't change these values - they're stored in the database, and defined in the tag reader protobuf.
|
||||
// If a new lossless file is added, also add it to IsFileLossless().
|
||||
|
||||
enum FileType {
|
||||
FileType_Unknown = 0,
|
||||
FileType_WAV = 1,
|
||||
FileType_FLAC = 2,
|
||||
FileType_WavPack = 3,
|
||||
FileType_OggFlac = 4,
|
||||
FileType_OggVorbis = 5,
|
||||
FileType_OggOpus = 6,
|
||||
FileType_OggSpeex = 7,
|
||||
FileType_MPEG = 8,
|
||||
FileType_MP4 = 9,
|
||||
FileType_ASF = 10,
|
||||
FileType_AIFF = 11,
|
||||
FileType_MPC = 12,
|
||||
FileType_TrueAudio = 13,
|
||||
FileType_DSF = 14,
|
||||
FileType_DSDIFF = 15,
|
||||
FileType_PCM = 16,
|
||||
FileType_APE = 17,
|
||||
FileType_MOD = 18,
|
||||
FileType_S3M = 19,
|
||||
FileType_XM = 20,
|
||||
FileType_IT = 21,
|
||||
FileType_SPC = 22,
|
||||
FileType_VGM = 23,
|
||||
FileType_CDDA = 90,
|
||||
FileType_Stream = 91,
|
||||
enum class FileType {
|
||||
Unknown = 0,
|
||||
WAV = 1,
|
||||
FLAC = 2,
|
||||
WavPack = 3,
|
||||
OggFlac = 4,
|
||||
OggVorbis = 5,
|
||||
OggOpus = 6,
|
||||
OggSpeex = 7,
|
||||
MPEG = 8,
|
||||
MP4 = 9,
|
||||
ASF = 10,
|
||||
AIFF = 11,
|
||||
MPC = 12,
|
||||
TrueAudio = 13,
|
||||
DSF = 14,
|
||||
DSDIFF = 15,
|
||||
PCM = 16,
|
||||
APE = 17,
|
||||
MOD = 18,
|
||||
S3M = 19,
|
||||
XM = 20,
|
||||
IT = 21,
|
||||
SPC = 22,
|
||||
VGM = 23,
|
||||
CDDA = 90,
|
||||
Stream = 91
|
||||
};
|
||||
|
||||
Song(Song::Source source = Song::Source_Unknown);
|
||||
Song(Source source = Source::Unknown);
|
||||
Song(const Song &other);
|
||||
~Song();
|
||||
|
||||
@@ -133,8 +132,6 @@ class Song {
|
||||
static const QRegularExpression kAlbumRemoveMisc;
|
||||
static const QRegularExpression kTitleRemoveMisc;
|
||||
|
||||
static const QString kVariousArtists;
|
||||
|
||||
static const QStringList kArticles;
|
||||
|
||||
static const QStringList kAcceptedExtensions;
|
||||
@@ -142,13 +139,13 @@ class Song {
|
||||
static QString JoinSpec(const QString &table);
|
||||
|
||||
static Source SourceFromURL(const QUrl &url);
|
||||
static QString TextForSource(Source source);
|
||||
static QString DescriptionForSource(Source source);
|
||||
static Song::Source SourceFromText(const QString &source);
|
||||
static QIcon IconForSource(Source source);
|
||||
static QString TextForFiletype(FileType filetype);
|
||||
static QString ExtensionForFiletype(FileType filetype);
|
||||
static QIcon IconForFiletype(FileType filetype);
|
||||
static QString TextForSource(const Source source);
|
||||
static QString DescriptionForSource(const Source source);
|
||||
static Source SourceFromText(const QString &source);
|
||||
static QIcon IconForSource(const Source source);
|
||||
static QString TextForFiletype(const FileType filetype);
|
||||
static QString ExtensionForFiletype(const FileType filetype);
|
||||
static QIcon IconForFiletype(const FileType filetype);
|
||||
|
||||
QString TextForSource() const { return TextForSource(source()); }
|
||||
QString DescriptionForSource() const { return DescriptionForSource(source()); }
|
||||
@@ -160,7 +157,7 @@ class Song {
|
||||
static FileType FiletypeByMimetype(const QString &mimetype);
|
||||
static FileType FiletypeByDescription(const QString &text);
|
||||
static FileType FiletypeByExtension(const QString &ext);
|
||||
static QString ImageCacheDir(const Song::Source source);
|
||||
static QString ImageCacheDir(const Source source);
|
||||
|
||||
// Sort songs alphabetically using their pretty title
|
||||
static int CompareSongsName(const Song &song1, const Song &song2);
|
||||
@@ -299,9 +296,19 @@ class Song {
|
||||
static bool save_embedded_cover_supported(const FileType filetype);
|
||||
bool save_embedded_cover_supported() const { return url().isLocalFile() && save_embedded_cover_supported(filetype()) && !has_cue(); };
|
||||
|
||||
bool additional_tags_supported() const;
|
||||
bool albumartist_supported() const;
|
||||
bool composer_supported() const;
|
||||
bool performer_supported() const;
|
||||
bool grouping_supported() const;
|
||||
bool genre_supported() const;
|
||||
bool compilation_supported() const;
|
||||
bool rating_supported() const;
|
||||
bool comment_supported() const;
|
||||
bool lyrics_supported() const;
|
||||
|
||||
const QUrl &stream_url() const;
|
||||
const QUrl &effective_stream_url() const;
|
||||
const QImage &image() const;
|
||||
bool init_from_file() const;
|
||||
|
||||
// Pretty accessors
|
||||
@@ -380,11 +387,15 @@ class Song {
|
||||
void set_rating(const float v);
|
||||
|
||||
void set_stream_url(const QUrl &v);
|
||||
void set_image(const QImage &i);
|
||||
|
||||
// Comparison functions
|
||||
bool IsMetadataEqual(const Song &other) const;
|
||||
bool IsMetadataAndMoreEqual(const Song &other) const;
|
||||
bool IsStatisticsEqual(const Song &other) const;
|
||||
bool IsRatingEqual(const Song &other) const;
|
||||
bool IsFingerprintEqual(const Song &other) const;
|
||||
bool IsArtEqual(const Song &other) const;
|
||||
bool IsAllMetadataEqual(const Song &other) const;
|
||||
|
||||
bool IsOnSameAlbum(const Song &other) const;
|
||||
bool IsSimilar(const Song &other) const;
|
||||
|
||||
@@ -405,12 +416,14 @@ class Song {
|
||||
QSharedDataPointer<Private> d;
|
||||
};
|
||||
|
||||
typedef QList<Song> SongList;
|
||||
typedef QMap<QString, Song> SongMap;
|
||||
using SongList = QList<Song>;
|
||||
using SongMap = QMap<QString, Song>;
|
||||
|
||||
Q_DECLARE_METATYPE(Song)
|
||||
Q_DECLARE_METATYPE(SongList)
|
||||
Q_DECLARE_METATYPE(SongMap)
|
||||
Q_DECLARE_METATYPE(Song::Source)
|
||||
Q_DECLARE_METATYPE(Song::FileType)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
size_t qHash(const Song &song);
|
||||
|
||||
@@ -72,7 +72,7 @@ SongLoader::SongLoader(CollectionBackendInterface *collection, const Player *pla
|
||||
playlist_parser_(new PlaylistParser(collection, this)),
|
||||
cue_parser_(new CueParser(collection, this)),
|
||||
timeout_(kDefaultTimeout),
|
||||
state_(WaitingForType),
|
||||
state_(State::WaitingForType),
|
||||
success_(false),
|
||||
parser_(nullptr),
|
||||
collection_(collection),
|
||||
@@ -100,7 +100,7 @@ SongLoader::~SongLoader() {
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
if (pipeline_) {
|
||||
state_ = Finished;
|
||||
state_ = State::Finished;
|
||||
gst_element_set_state(pipeline_.get(), GST_STATE_NULL);
|
||||
}
|
||||
#endif
|
||||
@@ -109,7 +109,7 @@ SongLoader::~SongLoader() {
|
||||
|
||||
SongLoader::Result SongLoader::Load(const QUrl &url) {
|
||||
|
||||
if (url.isEmpty()) return Error;
|
||||
if (url.isEmpty()) return Result::Error;
|
||||
|
||||
url_ = url;
|
||||
|
||||
@@ -121,13 +121,13 @@ SongLoader::Result SongLoader::Load(const QUrl &url) {
|
||||
// The URI scheme indicates that it can't possibly be a playlist,
|
||||
// or we have a custom handler for the URL, so add it as a raw stream.
|
||||
AddAsRawStream();
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
if (player_->engine()->type() == Engine::GStreamer) {
|
||||
if (player_->engine()->type() == Engine::EngineType::GStreamer) {
|
||||
#ifdef HAVE_GSTREAMER
|
||||
preload_func_ = std::bind(&SongLoader::LoadRemote, this);
|
||||
return BlockingLoadRequired;
|
||||
return Result::BlockingLoadRequired;
|
||||
#else
|
||||
errors_ << tr("You need GStreamer for this URL.");
|
||||
return Error;
|
||||
@@ -135,10 +135,10 @@ SongLoader::Result SongLoader::Load(const QUrl &url) {
|
||||
}
|
||||
else {
|
||||
errors_ << tr("You need GStreamer for this URL.");
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
|
||||
return Success;
|
||||
return Result::Success;
|
||||
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ SongLoader::Result SongLoader::LoadFilenamesBlocking() {
|
||||
}
|
||||
else {
|
||||
errors_ << tr("Preload function was not set for blocking operation.");
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -162,44 +162,44 @@ SongLoader::Result SongLoader::LoadLocalPartial(const QString &filename) {
|
||||
|
||||
if (!fileinfo.exists()) {
|
||||
errors_ << tr("File %1 does not exist.").arg(filename);
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
|
||||
// First check to see if it's a directory - if so we can load all the songs inside right away.
|
||||
if (fileinfo.isDir()) {
|
||||
LoadLocalDirectory(filename);
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
// Assume it's just a normal file
|
||||
if (TagReaderClient::Instance()->IsMediaFileBlocking(filename) || Song::kAcceptedExtensions.contains(fileinfo.suffix(), Qt::CaseInsensitive)) {
|
||||
Song song(Song::Source_LocalFile);
|
||||
Song song(Song::Source::LocalFile);
|
||||
song.InitFromFilePartial(filename, fileinfo);
|
||||
if (song.is_valid()) {
|
||||
songs_ << song;
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
}
|
||||
|
||||
errors_ << QObject::tr("File %1 is not recognized as a valid audio file.").arg(filename);
|
||||
return Error;
|
||||
return Result::Error;
|
||||
|
||||
}
|
||||
|
||||
SongLoader::Result SongLoader::LoadAudioCD() {
|
||||
|
||||
#if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER)
|
||||
if (player_->engine()->type() == Engine::GStreamer) {
|
||||
if (player_->engine()->type() == Engine::EngineType::GStreamer) {
|
||||
CddaSongLoader *cdda_song_loader = new CddaSongLoader(QUrl(), this);
|
||||
QObject::connect(cdda_song_loader, &CddaSongLoader::SongsDurationLoaded, this, &SongLoader::AudioCDTracksLoadFinishedSlot);
|
||||
QObject::connect(cdda_song_loader, &CddaSongLoader::SongsMetadataLoaded, this, &SongLoader::AudioCDTracksTagsLoaded);
|
||||
cdda_song_loader->LoadSongs();
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
errors_ << tr("CD playback is only available with the GStreamer engine.");
|
||||
return Error;
|
||||
return Result::Error;
|
||||
#if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER)
|
||||
}
|
||||
#endif
|
||||
@@ -243,7 +243,7 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) {
|
||||
if (query.Exec() && query.Next()) {
|
||||
// We may have many results when the file has many sections
|
||||
do {
|
||||
Song song(Song::Source_Collection);
|
||||
Song song(Song::Source::Collection);
|
||||
song.InitFromQuery(query, true);
|
||||
|
||||
if (song.is_valid()) {
|
||||
@@ -251,12 +251,12 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) {
|
||||
}
|
||||
} while (query.Next());
|
||||
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
// It's not in the database, load it asynchronously.
|
||||
preload_func_ = std::bind(&SongLoader::LoadLocalAsync, this, filename);
|
||||
return BlockingLoadRequired;
|
||||
return Result::BlockingLoadRequired;
|
||||
|
||||
}
|
||||
|
||||
@@ -266,20 +266,20 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
||||
|
||||
if (!fileinfo.exists()) {
|
||||
errors_ << tr("File %1 does not exist.").arg(filename);
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
|
||||
// First check to see if it's a directory - if so we will load all the songs inside right away.
|
||||
if (fileinfo.isDir()) {
|
||||
LoadLocalDirectory(filename);
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
// It's a local file, so check if it looks like a playlist. Read the first few bytes.
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
errors_ << tr("Could not open file %1 for reading: %2").arg(filename, file.errorString());
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
QByteArray data(file.read(PlaylistParser::kMagicSize));
|
||||
file.close();
|
||||
@@ -287,13 +287,13 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
||||
ParserBase *parser = playlist_parser_->ParserForMagic(data);
|
||||
if (!parser) {
|
||||
// Check the file extension as well, maybe the magic failed, or it was a basic M3U file which is just a plain list of filenames.
|
||||
parser = playlist_parser_->ParserForExtension(PlaylistParser::Type_Load, fileinfo.suffix().toLower());
|
||||
parser = playlist_parser_->ParserForExtension(PlaylistParser::Type::Load, fileinfo.suffix().toLower());
|
||||
}
|
||||
|
||||
if (parser) { // It's a playlist!
|
||||
qLog(Debug) << "Parsing using" << parser->name();
|
||||
LoadPlaylist(parser, filename);
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
// Check if it's a CUE file
|
||||
@@ -307,26 +307,26 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
||||
for (const Song &song : songs) {
|
||||
if (song.is_valid()) songs_ << song;
|
||||
}
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
else {
|
||||
errors_ << tr("Could not open CUE file %1 for reading: %2").arg(matching_cue, cue.errorString());
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
}
|
||||
|
||||
// Assume it's just a normal file
|
||||
if (TagReaderClient::Instance()->IsMediaFileBlocking(filename) || Song::kAcceptedExtensions.contains(fileinfo.suffix(), Qt::CaseInsensitive)) {
|
||||
Song song(Song::Source_LocalFile);
|
||||
Song song(Song::Source::LocalFile);
|
||||
song.InitFromFilePartial(filename, fileinfo);
|
||||
if (song.is_valid()) {
|
||||
songs_ << song;
|
||||
return Success;
|
||||
return Result::Success;
|
||||
}
|
||||
}
|
||||
|
||||
errors_ << QObject::tr("File %1 is not recognized as a valid audio file.").arg(filename);
|
||||
return Error;
|
||||
return Result::Error;
|
||||
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ void SongLoader::EffectiveSongLoad(Song *song) {
|
||||
|
||||
if (!song || !song->url().isLocalFile()) return;
|
||||
|
||||
if (song->init_from_file() && song->filetype() != Song::FileType_Unknown) {
|
||||
if (song->init_from_file() && song->filetype() != Song::FileType::Unknown) {
|
||||
// Maybe we loaded the metadata already, for example from a cuesheet.
|
||||
return;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ void SongLoader::AddAsRawStream() {
|
||||
|
||||
Song song(Song::SourceFromURL(url_));
|
||||
song.set_valid(true);
|
||||
song.set_filetype(Song::FileType_Stream);
|
||||
song.set_filetype(Song::FileType::Stream);
|
||||
song.set_url(url_);
|
||||
song.set_title(url_.toString());
|
||||
songs_ << song;
|
||||
@@ -417,7 +417,7 @@ void SongLoader::AddAsRawStream() {
|
||||
}
|
||||
|
||||
void SongLoader::Timeout() {
|
||||
state_ = Finished;
|
||||
state_ = State::Finished;
|
||||
success_ = false;
|
||||
StopTypefind();
|
||||
}
|
||||
@@ -475,7 +475,7 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
GstElement *source = gst_element_make_from_uri(GST_URI_SRC, url_.toEncoded().constData(), nullptr, nullptr);
|
||||
if (!source) {
|
||||
errors_ << tr("Couldn't create GStreamer source element for %1").arg(url_.toString());
|
||||
return Error;
|
||||
return Result::Error;
|
||||
}
|
||||
g_object_set(source, "ssl-strict", FALSE, nullptr);
|
||||
|
||||
@@ -508,7 +508,7 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
// Wait until loading is finished
|
||||
loop.exec();
|
||||
|
||||
return Success;
|
||||
return Result::Success;
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -518,14 +518,14 @@ void SongLoader::TypeFound(GstElement*, uint, GstCaps *caps, void *self) {
|
||||
|
||||
SongLoader *instance = static_cast<SongLoader*>(self);
|
||||
|
||||
if (instance->state_ != WaitingForType) return;
|
||||
if (instance->state_ != State::WaitingForType) return;
|
||||
|
||||
// Check the mimetype
|
||||
instance->mime_type_ = gst_structure_get_name(gst_caps_get_structure(caps, 0));
|
||||
qLog(Debug) << "Mime type is" << instance->mime_type_;
|
||||
if (instance->mime_type_ == "text/plain" || instance->mime_type_ == "text/uri-list") {
|
||||
// Yeah it might be a playlist, let's get some data and have a better look
|
||||
instance->state_ = WaitingForMagic;
|
||||
instance->state_ = State::WaitingForMagic;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo *info, gpointer
|
||||
|
||||
SongLoader *instance = reinterpret_cast<SongLoader*>(self);
|
||||
|
||||
if (instance->state_ == Finished) {
|
||||
if (instance->state_ == State::Finished) {
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo *info, gpointer
|
||||
qLog(Debug) << "Received total" << instance->buffer_.size() << "bytes";
|
||||
gst_buffer_unmap(buffer, &map);
|
||||
|
||||
if (instance->state_ == WaitingForMagic && (instance->buffer_.size() >= PlaylistParser::kMagicSize || !instance->IsPipelinePlaying())) {
|
||||
if (instance->state_ == State::WaitingForMagic && (instance->buffer_.size() >= PlaylistParser::kMagicSize || !instance->IsPipelinePlaying())) {
|
||||
// Got enough that we can test the magic
|
||||
instance->MagicReady();
|
||||
}
|
||||
@@ -604,7 +604,7 @@ GstBusSyncReply SongLoader::BusCallbackSync(GstBus*, GstMessage *msg, gpointer s
|
||||
#ifdef HAVE_GSTREAMER
|
||||
void SongLoader::ErrorMessageReceived(GstMessage *msg) {
|
||||
|
||||
if (state_ == Finished) return;
|
||||
if (state_ == State::Finished) return;
|
||||
|
||||
GError *error = nullptr;
|
||||
gchar *debugs = nullptr;
|
||||
@@ -618,9 +618,9 @@ void SongLoader::ErrorMessageReceived(GstMessage *msg) {
|
||||
g_error_free(error);
|
||||
g_free(debugs);
|
||||
|
||||
if (state_ == WaitingForType && message_str == gst_error_get_message(GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND)) {
|
||||
if (state_ == State::WaitingForType && message_str == gst_error_get_message(GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND)) {
|
||||
// Don't give up - assume it's a playlist and see if one of our parsers can read it.
|
||||
state_ = WaitingForMagic;
|
||||
state_ = State::WaitingForMagic;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -632,24 +632,24 @@ void SongLoader::ErrorMessageReceived(GstMessage *msg) {
|
||||
#ifdef HAVE_GSTREAMER
|
||||
void SongLoader::EndOfStreamReached() {
|
||||
|
||||
qLog(Debug) << Q_FUNC_INFO << state_;
|
||||
qLog(Debug) << Q_FUNC_INFO << static_cast<int>(state_);
|
||||
switch (state_) {
|
||||
case Finished:
|
||||
case State::Finished:
|
||||
break;
|
||||
|
||||
case WaitingForMagic:
|
||||
case State::WaitingForMagic:
|
||||
// Do the magic on the data we have already
|
||||
MagicReady();
|
||||
if (state_ == Finished) break;
|
||||
if (state_ == State::Finished) break;
|
||||
// It looks like a playlist, so parse it
|
||||
|
||||
[[fallthrough]];
|
||||
case WaitingForData:
|
||||
case State::WaitingForData:
|
||||
// It's a playlist and we've got all the data - finish and parse it
|
||||
StopTypefindAsync(true);
|
||||
break;
|
||||
|
||||
case WaitingForType:
|
||||
case State::WaitingForType:
|
||||
StopTypefindAsync(false);
|
||||
break;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ void SongLoader::MagicReady() {
|
||||
StopTypefindAsync(true);
|
||||
}
|
||||
|
||||
state_ = WaitingForData;
|
||||
state_ = State::WaitingForData;
|
||||
|
||||
if (!IsPipelinePlaying()) {
|
||||
EndOfStreamReached();
|
||||
@@ -708,7 +708,7 @@ bool SongLoader::IsPipelinePlaying() {
|
||||
#ifdef HAVE_GSTREAMER
|
||||
void SongLoader::StopTypefindAsync(bool success) {
|
||||
|
||||
state_ = Finished;
|
||||
state_ = State::Finished;
|
||||
success_ = success;
|
||||
|
||||
QMetaObject::invokeMethod(this, "StopTypefind", Qt::QueuedConnection);
|
||||
|
||||
@@ -60,10 +60,10 @@ class SongLoader : public QObject {
|
||||
explicit SongLoader(CollectionBackendInterface *collection, const Player *player, QObject *parent = nullptr);
|
||||
~SongLoader() override;
|
||||
|
||||
enum Result {
|
||||
enum class Result {
|
||||
Success,
|
||||
Error,
|
||||
BlockingLoadRequired,
|
||||
BlockingLoadRequired
|
||||
};
|
||||
|
||||
static const int kDefaultTimeout;
|
||||
@@ -101,7 +101,12 @@ class SongLoader : public QObject {
|
||||
#endif // HAVE_AUDIOCD && HAVE_GSTREAMER
|
||||
|
||||
private:
|
||||
enum State { WaitingForType, WaitingForMagic, WaitingForData, Finished };
|
||||
enum class State {
|
||||
WaitingForType,
|
||||
WaitingForMagic,
|
||||
WaitingForData,
|
||||
Finished
|
||||
};
|
||||
|
||||
Result LoadLocal(const QString &filename);
|
||||
SongLoader::Result LoadLocalAsync(const QString &filename);
|
||||
|
||||
@@ -53,6 +53,6 @@ class SqlRow {
|
||||
|
||||
};
|
||||
|
||||
typedef QList<SqlRow> SqlRowList;
|
||||
using SqlRowList = QList<SqlRow>;
|
||||
|
||||
#endif // SQLROW_H
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//#pragma once
|
||||
#ifndef STYLEHELPER_H
|
||||
#define STYLEHELPER_H
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user