@@ -28,8 +28,7 @@ namespace Nickvision::Application::Shared::Controllers
2828 : m_started{ false },
2929 m_args{ args },
3030 m_appInfo{ " org.nickvision.application" , " Nickvision Application" , " Application" },
31- m_dataFileManager{ m_appInfo.getName () },
32- m_logger{ UserDirectories::get (ApplicationUserDirectory::LocalData, m_appInfo.getName ()) / " log.txt" , Logging::LogLevel::Info, false }
31+ m_dataFileManager{ m_appInfo.getName () }
3332 {
3433 m_appInfo.setVersion ({ " 2025.1.0-next" });
3534 m_appInfo.setShortName (_ (" Application" ));
@@ -50,10 +49,6 @@ namespace Nickvision::Application::Shared::Controllers
5049#ifdef _WIN32
5150 m_updater = std::make_shared<Updater>(m_appInfo.getSourceRepo ());
5251#endif
53- m_dataFileManager.get <Configuration>(" config" ).saved () += [this ](const EventArgs&)
54- {
55- m_logger.log (Logging::LogLevel::Info, " Configuration saved." );
56- };
5752 }
5853
5954 Event<EventArgs>& MainWindowController::configurationSaved ()
@@ -122,27 +117,13 @@ namespace Nickvision::Application::Shared::Controllers
122117 info.setWindowGeometry (m_dataFileManager.get <Configuration>(" config" ).getWindowGeometry ());
123118 // Load taskbar item
124119#ifdef _WIN32
125- if (m_taskbar.connect (hwnd))
126- {
127- m_logger.log (Logging::LogLevel::Info, " Connected to Windows taskbar." );
128- }
129- else
130- {
131- m_logger.log (Logging::LogLevel::Error, " Unable to connect to Windows taskbar." );
132- }
120+ m_taskbar.connect (hwnd);
133121 if (m_dataFileManager.get <Configuration>(" config" ).getAutomaticallyCheckForUpdates ())
134122 {
135123 checkForUpdates ();
136124 }
137125#elif defined(__linux__)
138- if (m_taskbar.connect (desktopFile))
139- {
140- m_logger.log (Logging::LogLevel::Info, " Connected to Linux taskbar." );
141- }
142- else
143- {
144- m_logger.log (Logging::LogLevel::Error, " Unable to connect to Linux taskbar." );
145- }
126+ m_taskbar.connect (desktopFile);
146127#endif
147128 m_started = true ;
148129 return info;
@@ -161,25 +142,15 @@ namespace Nickvision::Application::Shared::Controllers
161142 {
162143 return ;
163144 }
164- m_logger.log (Logging::LogLevel::Info, " Checking for updates..." );
165145 std::thread worker{ [this ]()
166146 {
167147 Version latest{ m_updater->fetchCurrentVersion (VersionType::Stable) };
168- if (!latest.empty ())
148+ if (!latest.empty ())
169149 {
170- if (latest > m_appInfo.getVersion ())
150+ if (latest > m_appInfo.getVersion ())
171151 {
172- m_logger.log (Logging::LogLevel::Info, " Update found: " + latest.str ());
173152 m_notificationSent.invoke ({ _ (" New update available" ), NotificationSeverity::Success, " update" });
174153 }
175- else
176- {
177- m_logger.log (Logging::LogLevel::Info, " No updates found." );
178- }
179- }
180- else
181- {
182- m_logger.log (Logging::LogLevel::Warning, " Unable to fetch latest app version." );
183154 }
184155 } };
185156 worker.detach ();
@@ -192,28 +163,18 @@ namespace Nickvision::Application::Shared::Controllers
192163 {
193164 return ;
194165 }
195- m_logger. log (Logging::LogLevel::Info, " Fetching Windows app update... " );
166+ m_notificationSent. invoke ({ _ ( " The update is downloading in the background and will start once it finishes " ), NotificationSeverity::Informational } );
196167 std::thread worker{ [this ]()
197168 {
198- if (m_updater->windowsUpdate (VersionType::Stable))
199- {
200- m_logger.log (Logging::LogLevel::Info, " Windows app update started." );
201- }
202- else
169+ if (!m_updater->windowsUpdate (VersionType::Stable))
203170 {
204- m_logger.log (Logging::LogLevel::Error, " Unable to fetch Windows app update." );
205171 m_notificationSent.invoke ({ _ (" Unable to download and install update" ), NotificationSeverity::Error });
206172 }
207173 } };
208174 worker.detach ();
209175 }
210176#endif
211177
212- void MainWindowController::log (Logging::LogLevel level, const std::string& message, const std::source_location& source)
213- {
214- m_logger.log (level, message, source);
215- }
216-
217178 std::string MainWindowController::getGreeting () const
218179 {
219180 std::time_t now{ std::time (nullptr ) };
@@ -259,32 +220,12 @@ namespace Nickvision::Application::Shared::Controllers
259220
260221 bool MainWindowController::openFolder (const std::filesystem::path& path)
261222 {
262- if (std::filesystem::exists (path) && std::filesystem::is_directory (path))
223+ m_folderPath = path;
224+ if (!isFolderOpened ())
263225 {
264- m_folderPath = path;
265- loadFiles ();
266- m_notificationSent.invoke ({ std::vformat (_ (" Folder Opened: {}" ), std::make_format_args (CodeHelpers::unmove (m_folderPath.string ()))), NotificationSeverity::Success, " close" });
267- m_folderChanged.invoke ({});
268- m_taskbar.setCount (static_cast <long >(m_files.size ()));
269- m_taskbar.setCountVisible (true );
270- m_logger.log (Logging::LogLevel::Info, " Folder opened. (" + m_folderPath.string () + " )" );
271- return true ;
226+ return false ;
272227 }
273- return false ;
274- }
275-
276- void MainWindowController::closeFolder ()
277- {
278- m_logger.log (Logging::LogLevel::Info, " Folder closed. (" + m_folderPath.string () + " )" );
279- m_folderPath = std::filesystem::path ();
280- m_files.clear ();
281- m_notificationSent.invoke ({ _ (" Folder closed" ), NotificationSeverity::Warning });
282- m_folderChanged.invoke ({});
283- m_taskbar.setCountVisible (false );
284- }
285-
286- void MainWindowController::loadFiles ()
287- {
228+ // Load Files
288229 m_files.clear ();
289230 if (std::filesystem::exists (m_folderPath))
290231 {
@@ -296,6 +237,24 @@ namespace Nickvision::Application::Shared::Controllers
296237 }
297238 }
298239 }
299- m_logger.log (Logging::LogLevel::Info, " Loaded " + std::to_string (m_files.size ()) + " file(s). (" + m_folderPath.string () + " )" );
240+ // UI
241+ m_notificationSent.invoke ({ std::vformat (_ (" Folder Opened: {}" ), std::make_format_args (CodeHelpers::unmove (m_folderPath.string ()))), NotificationSeverity::Success, " close" });
242+ m_folderChanged.invoke ({});
243+ m_taskbar.setCount (static_cast <long >(m_files.size ()));
244+ m_taskbar.setCountVisible (true );
245+ return true ;
246+ }
247+
248+ void MainWindowController::closeFolder ()
249+ {
250+ if (!isFolderOpened ())
251+ {
252+ return ;
253+ }
254+ m_folderPath = std::filesystem::path ();
255+ m_files.clear ();
256+ m_notificationSent.invoke ({ _ (" Folder closed" ), NotificationSeverity::Warning });
257+ m_folderChanged.invoke ({});
258+ m_taskbar.setCountVisible (false );
300259 }
301260}
0 commit comments