Skip to content

Commit 0ab5702

Browse files
authored
Qt Redesign (#103)
* feat: Add `InfoBar` Control * feat: Add MenuBar to Qt * feat: Update helpers + controller implementation * fix: GNOME allowEllipse * feat: Windows Update notification * fix: Flathub GitHub Action * fix: Flatpak Qt GitHub Action * feat: New Qt `AboutDialog` * feat: New Qt `SettingsDialog` * feat: Remove logging * feat: Qt Files Page
1 parent 4cb7fd2 commit 0ab5702

File tree

33 files changed

+1004
-1015
lines changed

33 files changed

+1004
-1015
lines changed

.github/workflows/flatpak.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ jobs:
1515
runs-on: ubuntu-latest
1616
if: ${{ github.event.pull_request.user.login != 'weblate' }}
1717
container:
18-
image: bilelmoussaoui/flatpak-github-actions:gnome-46
18+
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-47
1919
options: --privileged
2020
strategy:
2121
matrix:
2222
arch: [x86_64]
2323
fail-fast: false
2424
steps:
2525
- uses: actions/checkout@v4
26-
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.3
26+
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
2727
with:
2828
bundle: org.nickvision.application.gnome.flatpak
2929
manifest-path: flatpak/org.nickvision.application.gnome.json
@@ -35,15 +35,15 @@ jobs:
3535
runs-on: ubuntu-latest
3636
if: ${{ github.event.pull_request.user.login != 'weblate' }}
3737
container:
38-
image: bilelmoussaoui/flatpak-github-actions:kde-6.7
38+
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.8
3939
options: --privileged
4040
strategy:
4141
matrix:
4242
arch: [x86_64]
4343
fail-fast: false
4444
steps:
4545
- uses: actions/checkout@v4
46-
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.3
46+
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
4747
with:
4848
bundle: org.nickvision.application.qt.flatpak
4949
manifest-path: flatpak/org.nickvision.application.qt.json

Application.doap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<bug-database rdf:resource="https://github.com/NickvisionApps/Application/issues"/>
1111
<download-page rdf:resource="https://github.com/NickvisionApps/Application" /> <!-- replace with flathub link -->
1212
<category rdf:resource="http://api.gnome.org/doap-extensions#apps" />
13-
<programming-language>C#</programming-language>
13+
<programming-language>C++</programming-language>
1414

1515
<maintainer>
1616
<foaf:Person>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Ensure both `vcpkg` and `cmake` are installed on your system before building.
2222

2323
A C++20 compiler is also required to build Application.
2424

25+
**If building the GNOME version, `blueprint-compiler` must be installed from your system package manager as it is not available on `vcpkg`.**
26+
2527
### Configuring vcpkg
2628
1. Set the `VCPKG_ROOT` environment variable to the path of your vcpkg installation's root directory.
2729
#### Windows

flatpak/org.nickvision.application.gnome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
{
7575
"type": "git",
7676
"url": "https://gitlab.gnome.org/jwestman/blueprint-compiler",
77-
"tag": "v0.14.0"
77+
"tag": "v0.16.0"
7878
}
7979
]
8080
},

libapplication/include/controllers/mainwindowcontroller.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <libnick/app/datafilemanager.h>
1414
#include <libnick/app/windowgeometry.h>
1515
#include <libnick/events/event.h>
16-
#include <libnick/logging/logger.h>
1716
#include <libnick/notifications/notificationsenteventargs.h>
1817
#include <libnick/notifications/shellnotificationsenteventargs.h>
1918
#include <libnick/taskbar/taskbaritem.h>
@@ -105,13 +104,6 @@ namespace Nickvision::Application::Shared::Controllers
105104
*/
106105
void windowsUpdate();
107106
#endif
108-
/**
109-
* @brief Logs a system message.
110-
* @param level The severity level of the message
111-
* @param message The message to log
112-
* @param source The source location of the log message
113-
*/
114-
void log(Logging::LogLevel level, const std::string& message, const std::source_location& source = std::source_location::current());
115107
/**
116108
* @brief Gets the string for greeting on the home page.
117109
* @return The greeting string
@@ -149,17 +141,10 @@ namespace Nickvision::Application::Shared::Controllers
149141
void closeFolder();
150142

151143
private:
152-
/**
153-
* @brief Obtains the paths of files in an open folder for the files list.
154-
* @brief This method only scans the top-level directory for files.
155-
* @brief Other sub-directory paths are not added to the files list.
156-
*/
157-
void loadFiles();
158144
bool m_started;
159145
std::vector<std::string> m_args;
160146
Nickvision::App::AppInfo m_appInfo;
161147
Nickvision::App::DataFileManager m_dataFileManager;
162-
Nickvision::Logging::Logger m_logger;
163148
std::shared_ptr<Nickvision::Update::Updater> m_updater;
164149
Nickvision::Taskbar::TaskbarItem m_taskbar;
165150
Nickvision::Events::Event<Nickvision::Notifications::NotificationSentEventArgs> m_notificationSent;

libapplication/src/controllers/mainwindowcontroller.cpp

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

org.nickvision.application.gnome/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if(NOT WIN32)
3232
if(BLUEPRINT_COMPILER_EXECUTABLE)
3333
add_custom_command(TARGET gnome_commands PRE_BUILD COMMAND "${BLUEPRINT_COMPILER_EXECUTABLE}" batch-compile "${CMAKE_CURRENT_BINARY_DIR}/ui" "${CMAKE_CURRENT_SOURCE_DIR}/blueprints" "${CMAKE_CURRENT_SOURCE_DIR}/blueprints/*.blp")
3434
else()
35-
message(ERROR "blueprint-compiler not found, UI will not be compiled")
35+
message(FATAL_ERROR "blueprint-compiler not found, UI will not be compiled")
3636
endif()
3737

3838
if(HAS_GETTEXT)
@@ -66,4 +66,4 @@ if(NOT WIN32)
6666
else()
6767
message(WARNING "update-desktop-database not found, desktop database will not be updated")
6868
endif()
69-
endif()
69+
endif()

org.nickvision.application.gnome/include/helpers/gtkhelpers.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,26 @@
88

99
namespace Nickvision::Application::GNOME::Helpers::GtkHelpers
1010
{
11+
/**
12+
* @brief Adds a widget to a GtkBox.
13+
* @param box The box to add the widget to
14+
* @param widget The widget to add
15+
* @param addSeparator Whether or not to add a separator between the widgets
16+
*/
17+
void addToBox(GtkBox* box, GtkWidget* widget, bool addSeparator = false);
1118
/**
1219
* @brief Runs the function on the main UI thread.
13-
* @param function The function to run
20+
* @param function The function to run
1421
*/
1522
void dispatchToMainThread(const std::function<void()>& function);
23+
/**
24+
* @brief Moves a widget from one box to another.
25+
* @param oldBox The old box
26+
* @param newBox The new box
27+
* @param widget The widget to move
28+
* @param addSeparator Whether or not to add a separator between the widgets
29+
*/
30+
void moveFromBox(GtkBox* oldBox, GtkBox* newBox, GtkWidget* widget, bool addSeparator = false);
1631
/**
1732
* @brief Sets the accelerator for an action.
1833
* @param app The GtkApplication
@@ -24,8 +39,10 @@ namespace Nickvision::Application::GNOME::Helpers::GtkHelpers
2439
* @brief Sets the model for a combo row.
2540
* @param row The combo row
2641
* @param strs The strings to set
42+
* @param selected An option string that should be selected
43+
* @param allowEllipse Whether or not to allow ellipses in the combo row
2744
*/
28-
void setComboRowModel(AdwComboRow* row, const std::vector<std::string>& strs);
45+
void setComboRowModel(AdwComboRow* row, const std::vector<std::string>& strs, const std::string& selected = "", bool allowEllipse = true);
2946
}
3047

31-
#endif //GTKHELPERS_H
48+
#endif //GTKHELPERS_H

org.nickvision.application.gnome/src/application.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace Nickvision::Application::GNOME
2020
GResource* resource{ g_resource_load(resources.string().c_str(), &resourceLoadError) };
2121
if(resourceLoadError)
2222
{
23-
m_controller->log(Logging::LogLevel::Critical, "Unable to load GResource. " + std::string(resourceLoadError->message));
2423
throw std::runtime_error(resourceLoadError->message);
2524
}
2625
g_resources_register(resource);
@@ -35,7 +34,6 @@ namespace Nickvision::Application::GNOME
3534

3635
void Application::onStartup(GtkApplication* app)
3736
{
38-
m_controller->log(Logging::LogLevel::Info, "Started GTK application.");
3937
switch (m_controller->getTheme())
4038
{
4139
case Theme::Light:
@@ -58,4 +56,4 @@ namespace Nickvision::Application::GNOME
5856
{
5957
m_mainWindow->show();
6058
}
61-
}
59+
}

0 commit comments

Comments
 (0)