Changeset View
Changeset View
Standalone View
Standalone View
src/main.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
78 | QUrl resolvedImagePath = parser.positionalArguments().isEmpty() | 78 | QUrl resolvedImagePath = parser.positionalArguments().isEmpty() | ||
79 | ? QUrl() | 79 | ? QUrl() | ||
80 | : currentDirPath.resolved( parser.positionalArguments().first()); | 80 | : currentDirPath.resolved( parser.positionalArguments().first()); | ||
81 | 81 | | |||
82 | if( !resolvedImagePath.isLocalFile()) { | 82 | if( !resolvedImagePath.isLocalFile()) { | ||
83 | resolvedImagePath = QUrl() ; | 83 | resolvedImagePath = QUrl() ; | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | QStringList directoryUrls; | ||||
87 | if( !resolvedImagePath.isEmpty()) { | ||||
mart: again, coding style:
if () {
}
https://techbase.kde.org/Policies/Kdelibs_Coding_Style | |||||
88 | QString tempImagePath = resolvedImagePath.toString(); | ||||
89 | | ||||
90 | if( resolvedImagePath.toString().startsWith( QUrl::fromLocalFile(locations.first()).toString()) ) { | ||||
91 | directoryUrls << tempImagePath; | ||||
92 | while( tempImagePath != QUrl::fromLocalFile(locations.first()).toString()) { | ||||
93 | tempImagePath = tempImagePath.left( tempImagePath.lastIndexOf('/')); | ||||
94 | directoryUrls.prepend(tempImagePath); | ||||
95 | } | ||||
96 | } else if ( resolvedImagePath.toString().startsWith( QUrl::fromLocalFile( QStandardPaths::standardLocations( QStandardPaths::HomeLocation).first()).toString()) ) { | ||||
just manage the first if, is fine to manage the cases of foreign paths like now mart: just manage the first if, is fine to manage the cases of foreign paths like now | |||||
97 | directoryUrls << tempImagePath; | ||||
98 | while( tempImagePath != QUrl::fromLocalFile( QStandardPaths::standardLocations( QStandardPaths::HomeLocation).first()).toString() ) { | ||||
99 | tempImagePath = tempImagePath.left( tempImagePath.lastIndexOf('/')); | ||||
100 | directoryUrls.prepend(tempImagePath); | ||||
101 | } | ||||
102 | } else { | ||||
103 | while( tempImagePath != "file://" ) { | ||||
104 | directoryUrls.prepend(tempImagePath); | ||||
105 | tempImagePath = tempImagePath.left( tempImagePath.lastIndexOf('/')); | ||||
106 | } | ||||
107 | } | ||||
108 | } | ||||
109 | | ||||
86 | FileSystemTracker tracker; | 110 | FileSystemTracker tracker; | ||
87 | tracker.setFolder(locations.first()); | 111 | tracker.setFolder(locations.first()); | ||
88 | tracker.moveToThread(&trackerThread); | 112 | tracker.moveToThread(&trackerThread); | ||
89 | 113 | | |||
90 | Koko::Processor processor; | 114 | Koko::Processor processor; | ||
91 | QObject::connect(&tracker, &FileSystemTracker::imageAdded, &processor, &Koko::Processor::addFile); | 115 | QObject::connect(&tracker, &FileSystemTracker::imageAdded, &processor, &Koko::Processor::addFile); | ||
92 | QObject::connect(&tracker, &FileSystemTracker::imageRemoved, &processor, &Koko::Processor::removeFile); | 116 | QObject::connect(&tracker, &FileSystemTracker::imageRemoved, &processor, &Koko::Processor::removeFile); | ||
93 | QObject::connect(&tracker, &FileSystemTracker::initialScanComplete, &processor, &Koko::Processor::initialScanCompleted); | 117 | QObject::connect(&tracker, &FileSystemTracker::initialScanComplete, &processor, &Koko::Processor::initialScanCompleted); | ||
94 | 118 | | |||
95 | trackerThread.start(); | 119 | trackerThread.start(); | ||
96 | tracker.setSubFolder(tracker.folder()); | 120 | tracker.setSubFolder(tracker.folder()); | ||
97 | 121 | | |||
98 | KokoConfig config; | 122 | KokoConfig config; | ||
99 | 123 | | |||
100 | QQmlEngine engine; | 124 | QQmlEngine engine; | ||
101 | QQmlContext* objectContext = engine.rootContext(); | 125 | QQmlContext* objectContext = engine.rootContext(); | ||
102 | objectContext->setContextProperty("kokoProcessor", &processor); | 126 | objectContext->setContextProperty("kokoProcessor", &processor); | ||
103 | objectContext->setContextProperty("kokoConfig", &config); | 127 | objectContext->setContextProperty("kokoConfig", &config); | ||
104 | objectContext->setContextProperty("imagePathArgument", resolvedImagePath.toString()); | 128 | objectContext->setContextProperty("imagePathArgument", directoryUrls); | ||
105 | 129 | | |||
106 | QString path; | 130 | QString path; | ||
107 | //we want different main files on desktop or mobile | 131 | //we want different main files on desktop or mobile | ||
108 | //very small difference as they as they are subclasses of the same thing | 132 | //very small difference as they as they are subclasses of the same thing | ||
109 | if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE") && | 133 | if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE") && | ||
110 | (QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("1") || | 134 | (QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("1") || | ||
111 | QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("true"))) { | 135 | QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("true"))) { | ||
112 | path = QStandardPaths::locate(QStandardPaths::DataLocation, "ui/mobileMain.qml"); | 136 | path = QStandardPaths::locate(QStandardPaths::DataLocation, "ui/mobileMain.qml"); | ||
Show All 21 Lines |
again, coding style:
if () {
}
https://techbase.kde.org/Policies/Kdelibs_Coding_Style