Skip to content

Commit d543003

Browse files
committed
feat: Blank template
1 parent 2a5d367 commit d543003

File tree

8 files changed

+243
-233
lines changed

8 files changed

+243
-233
lines changed

org.nickvision.miniera.gnome/blueprints/main_window.blp

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Adw 1;
44
menu mainMenu {
55
item(_("Preferences"), "win.preferences")
66
item(_("Keyboard Shortcuts"), "win.keyboardShortcuts")
7-
item(_("About Application"), "win.about")
7+
item(_("About Miniera"), "win.about")
88
}
99

1010
Adw.ApplicationWindow root {
@@ -16,26 +16,6 @@ Adw.ApplicationWindow root {
1616
Adw.HeaderBar headerBar {
1717
title-widget: Adw.WindowTitle title {};
1818

19-
[start]
20-
Gtk.Button btnOpenFolder {
21-
tooltip-text: _("Open Folder (Ctrl+O)");
22-
visible: false;
23-
action-name: "win.openFolder";
24-
25-
Adw.ButtonContent {
26-
label: _("Open");
27-
icon-name: "folder-open-symbolic";
28-
}
29-
}
30-
31-
[start]
32-
Gtk.Button btnCloseFolder {
33-
icon-name: "window-close-symbolic";
34-
tooltip-text: _("Close Folder (Ctrl+W)");
35-
action-name: "win.closeFolder";
36-
visible: false;
37-
}
38-
3919
[end]
4020
Gtk.MenuButton {
4121
direction: none;
@@ -50,30 +30,6 @@ Adw.ApplicationWindow root {
5030
vexpand: true;
5131

5232
Adw.ViewStack viewStack {
53-
Adw.ViewStackPage {
54-
name: "NoFolder";
55-
child: Adw.StatusPage pageGreeting {
56-
icon-name: "org.nickvision.miniera";
57-
description: _("Open a folder (or drag one into the app) to get started");
58-
child: Gtk.Button {
59-
label: _("Open");
60-
halign: center;
61-
action-name: "win.openFolder";
62-
styles ["pill", "suggested-action"]
63-
};
64-
65-
styles ["icon-dropshadow"]
66-
};
67-
}
68-
69-
Adw.ViewStackPage {
70-
name: "Folder";
71-
child: Adw.StatusPage pageFiles {
72-
icon-name: "folder-documents-symbolic";
73-
74-
styles ["compact"]
75-
};
76-
}
7733
}
7834
};
7935
}

org.nickvision.miniera.gnome/include/views/mainwindow.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ namespace Nickvision::Miniera::GNOME::Views
3535
* @return True to prevent closing, else false
3636
*/
3737
bool onCloseRequested();
38-
/**
39-
* @brief Handles when a file is dropped on the window.
40-
* @param value The GValue dropped on the window
41-
* @return True if drop was accepted, else false
42-
*/
43-
bool onDrop(const GValue* value);
4438
/**
4539
* @brief Handles when a notification is sent to the window.
4640
* @param args Nickvision::Notifications::NotificationSentEventArgs
@@ -51,23 +45,10 @@ namespace Nickvision::Miniera::GNOME::Views
5145
* @param args Nickvision::Notifications::ShellNotificationSentEventArgs
5246
*/
5347
void onShellNotificationSent(const Nickvision::Notifications::ShellNotificationSentEventArgs& args);
54-
/**
55-
* @brief Handles when the open folder is changed (including closed).
56-
* @param args Nickvision::Events::EventArgs
57-
*/
58-
void onFolderChanged(const Nickvision::Events::EventArgs& args);
5948
/**
6049
* @brief Quits the application.
6150
*/
6251
void quit();
63-
/**
64-
* @brief Opens a folder.
65-
*/
66-
void openFolder();
67-
/**
68-
* @brief Closes the folder if one is open.
69-
*/
70-
void closeFolder();
7152
/**
7253
* @brief Opens the application's preferences dialog.
7354
*/
File renamed without changes.

org.nickvision.miniera.gnome/src/views/mainwindow.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,11 @@ namespace Nickvision::Miniera::GNOME::Views
4141
m_controller->notificationSent() += [&](const NotificationSentEventArgs& args) { GtkHelpers::dispatchToMainThread([this, args]() { onNotificationSent(args); }); };
4242
m_controller->shellNotificationSent() += [&](const ShellNotificationSentEventArgs& args) { onShellNotificationSent(args); };
4343
m_controller->folderChanged() += [&](const EventArgs& args) { onFolderChanged(args); };
44-
//Drop Target
45-
GtkDropTarget* dropTarget{ gtk_drop_target_new(G_TYPE_FILE, GDK_ACTION_COPY) };
46-
g_signal_connect(dropTarget, "drop", G_CALLBACK(+[](GtkDropTarget*, const GValue* value, double, double, gpointer data) -> bool { return reinterpret_cast<MainWindow*>(data)->onDrop(value); }), this);
47-
gtk_widget_add_controller(GTK_WIDGET(m_window), GTK_EVENT_CONTROLLER(dropTarget));
4844
//Quit Action
4945
GSimpleAction* actQuit{ g_simple_action_new("quit", nullptr) };
5046
g_signal_connect(actQuit, "activate", G_CALLBACK(+[](GSimpleAction*, GVariant*, gpointer data){ reinterpret_cast<MainWindow*>(data)->quit(); }), this);
5147
g_action_map_add_action(G_ACTION_MAP(m_window), G_ACTION(actQuit));
5248
GtkHelpers::setAccelForAction(m_app, "win.quit", "<Ctrl>Q");
53-
//Open Folder Action
54-
GSimpleAction* actOpenFolder{ g_simple_action_new("openFolder", nullptr) };
55-
g_signal_connect(actOpenFolder, "activate", G_CALLBACK(+[](GSimpleAction*, GVariant*, gpointer data){ reinterpret_cast<MainWindow*>(data)->openFolder(); }), this);
56-
g_action_map_add_action(G_ACTION_MAP(m_window), G_ACTION(actOpenFolder));
57-
GtkHelpers::setAccelForAction(m_app, "win.openFolder", "<Ctrl>O");
58-
//Close Folder Action
59-
GSimpleAction* actCloseFolder{ g_simple_action_new("closeFolder", nullptr) };
60-
g_signal_connect(actCloseFolder, "activate", G_CALLBACK(+[](GSimpleAction*, GVariant*, gpointer data){ reinterpret_cast<MainWindow*>(data)->closeFolder(); }), this);
61-
g_action_map_add_action(G_ACTION_MAP(m_window), G_ACTION(actCloseFolder));
62-
GtkHelpers::setAccelForAction(m_app, "win.closeFolder", "<Ctrl>W");
6349
//Preferences Action
6450
GSimpleAction* actPreferences{ g_simple_action_new("preferences", nullptr) };
6551
g_signal_connect(actPreferences, "activate", G_CALLBACK(+[](GSimpleAction*, GVariant*, gpointer data){ reinterpret_cast<MainWindow*>(data)->preferences(); }), this);
@@ -110,24 +96,9 @@ namespace Nickvision::Miniera::GNOME::Views
11096
return false;
11197
}
11298

113-
bool MainWindow::onDrop(const GValue* value)
114-
{
115-
if(G_VALUE_HOLDS(value, G_TYPE_FILE))
116-
{
117-
m_controller->openFolder(g_file_get_path(G_FILE(g_value_get_object(value))));
118-
return true;
119-
}
120-
return false;
121-
}
122-
12399
void MainWindow::onNotificationSent(const NotificationSentEventArgs& args)
124100
{
125101
AdwToast* toast{ adw_toast_new(args.getMessage().c_str()) };
126-
if(args.getAction() == "close")
127-
{
128-
adw_toast_set_button_label(toast, _("Close"));
129-
g_signal_connect(toast, "button-clicked", G_CALLBACK(+[](AdwToast*, gpointer data){ reinterpret_cast<MainWindow*>(data)->closeFolder(); }), this);
130-
}
131102
adw_toast_overlay_add_toast(m_builder.get<AdwToastOverlay>("toastOverlay"), toast);
132103
}
133104

@@ -140,15 +111,6 @@ namespace Nickvision::Miniera::GNOME::Views
140111
#endif
141112
}
142113

143-
void MainWindow::onFolderChanged(const EventArgs& args)
144-
{
145-
adw_window_title_set_subtitle(m_builder.get<AdwWindowTitle>("title"), m_controller->isFolderOpened() ? m_controller->getFolderPath().c_str() : "");
146-
gtk_widget_set_visible(m_builder.get<GtkWidget>("btnOpenFolder"), m_controller->isFolderOpened());
147-
gtk_widget_set_visible(m_builder.get<GtkWidget>("btnCloseFolder"), m_controller->isFolderOpened());
148-
adw_view_stack_set_visible_child_name(m_builder.get<AdwViewStack>("viewStack"), m_controller->isFolderOpened() ? "Folder" : "NoFolder");
149-
adw_status_page_set_description(m_builder.get<AdwStatusPage>("pageFiles"), std::vformat(_n("There is {} file in the folder.", "There are {} files in the folder.", m_controller->getFiles().size()), std::make_format_args(CodeHelpers::unmove(m_controller->getFiles().size()))).c_str());
150-
}
151-
152114
void MainWindow::quit()
153115
{
154116
if(!onCloseRequested())
@@ -157,25 +119,6 @@ namespace Nickvision::Miniera::GNOME::Views
157119
}
158120
}
159121

160-
void MainWindow::openFolder()
161-
{
162-
GtkFileDialog* folderDialog{ gtk_file_dialog_new() };
163-
gtk_file_dialog_set_title(folderDialog, _("Open Folder"));
164-
gtk_file_dialog_select_folder(folderDialog, GTK_WINDOW(m_window), nullptr, GAsyncReadyCallback(+[](GObject* self, GAsyncResult* res, gpointer data)
165-
{
166-
GFile* folder{ gtk_file_dialog_select_folder_finish(GTK_FILE_DIALOG(self), res, nullptr) };
167-
if(folder)
168-
{
169-
reinterpret_cast<MainWindow*>(data)->m_controller->openFolder(g_file_get_path(folder));
170-
}
171-
}), this);
172-
}
173-
174-
void MainWindow::closeFolder()
175-
{
176-
m_controller->closeFolder();
177-
}
178-
179122
void MainWindow::preferences()
180123
{
181124
DialogPtr<PreferencesDialog> dialog{ m_controller->createPreferencesViewController(), GTK_WINDOW(m_window) };

org.nickvision.miniera.qt/include/views/mainwindow.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,8 @@ namespace Nickvision::Miniera::Qt::Views
4343
* @param event QCloseEvent
4444
*/
4545
void closeEvent(QCloseEvent* event) override;
46-
/**
47-
* @brief Handles when a file is dragged into the window.
48-
* @param event QDragEnterEvent
49-
*/
50-
void dragEnterEvent(QDragEnterEvent* event) override;
51-
/**
52-
* @brief Handles when a file is dropped into the window.
53-
* @param event QDropEvent
54-
*/
55-
void dropEvent(QDropEvent* event) override;
5646

5747
private Q_SLOTS:
58-
/**
59-
* @brief Prompts the user to open a folder.
60-
*/
61-
void openFolder();
62-
/**
63-
* @brief Closes the folder if one is open.
64-
*/
65-
void closeFolder();
6648
/**
6749
* @brief Opens the application's settings dialog.
6850
*/
@@ -105,11 +87,6 @@ namespace Nickvision::Miniera::Qt::Views
10587
* @param args The ShellNotificationSentEventArgs
10688
*/
10789
void onShellNotificationSent(const Notifications::ShellNotificationSentEventArgs& args);
108-
/**
109-
* @brief Handles when the folder is changed.
110-
* @param args The EventArgs
111-
*/
112-
void onFolderChanged(const Events::EventArgs& args);
11390
Ui::MainWindow* m_ui;
11491
std::shared_ptr<Shared::Controllers::MainWindowController> m_controller;
11592
oclero::qlementine::ThemeManager* m_themeManager;

org.nickvision.miniera.qt/src/views/mainwindow.cpp

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ namespace Ui
3939
void setupUi(Nickvision::Miniera::Qt::Views::MainWindow* parent)
4040
{
4141
//Actions
42-
actionOpenFolder = new QAction(parent);
43-
actionOpenFolder->setText(_("Open Folder"));
44-
actionOpenFolder->setIcon(QLEMENTINE_ICON(File_FolderOpen));
45-
actionOpenFolder->setShortcut(Qt::CTRL | Qt::Key_O);
46-
actionCloseFolder = new QAction(parent);
47-
actionCloseFolder->setText(_("Close Folder"));
48-
actionCloseFolder->setIcon(QLEMENTINE_ICON(File_Folder));
49-
actionCloseFolder->setShortcut(Qt::CTRL | Qt::Key_W);
5042
actionExit = new QAction(parent);
5143
actionExit->setText(_("Exit"));
5244
actionExit->setIcon(QLEMENTINE_ICON(Action_Close));
@@ -77,9 +69,6 @@ namespace Ui
7769
//MenuBar
7870
QMenu* menuFile{ new QMenu(parent) };
7971
menuFile->setTitle(_("File"));
80-
menuFile->addAction(actionOpenFolder);
81-
menuFile->addAction(actionCloseFolder);
82-
menuFile->addSeparator();
8372
menuFile->addAction(actionExit);
8473
QMenu* menuEdit{ new QMenu(parent) };
8574
menuEdit->setTitle(_("Edit"));
@@ -96,29 +85,9 @@ namespace Ui
9685
parent->menuBar()->addMenu(menuFile);
9786
parent->menuBar()->addMenu(menuEdit);
9887
parent->menuBar()->addMenu(menuHelp);
99-
//ToolBar
100-
QToolBar* toolBar{ new QToolBar(parent) };
101-
toolBar->setAllowedAreas(::Qt::ToolBarArea::TopToolBarArea);
102-
toolBar->setMovable(false);
103-
toolBar->setFloatable(false);
104-
toolBar->addAction(actionOpenFolder);
105-
toolBar->addAction(actionCloseFolder);
106-
parent->addToolBar(toolBar);
107-
//Files View
108-
listFiles = new QListWidget(parent);
109-
listFiles->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
110-
lblFiles = new QLabel(parent);
111-
lblFiles->setAlignment(::Qt::AlignmentFlag::AlignCenter);
112-
lblFiles->setText(_("No Folder Opened"));
11388
//Main Layout
11489
QWidget* centralWidget{ new QWidget(parent) };
115-
QHBoxLayout* layoutMain{ new QHBoxLayout(parent) };
116-
QScrollArea* scrollFiles{ new QScrollArea(parent) };
117-
scrollFiles->setMaximumWidth(300);
118-
scrollFiles->setWidgetResizable(true);
119-
scrollFiles->setWidget(listFiles);
120-
layoutMain->addWidget(scrollFiles);
121-
layoutMain->addWidget(lblFiles);
90+
QVBoxLayout* layoutMain{ new QVBoxLayout(parent) };
12291
centralWidget->setLayout(layoutMain);
12392
parent->setCentralWidget(centralWidget);
12493
}
@@ -133,8 +102,6 @@ namespace Ui
133102
QAction* actionDiscussions;
134103
QAction* actionAbout;
135104
Nickvision::Miniera::Qt::Controls::InfoBar* infoBar;
136-
QListWidget* listFiles;
137-
QLabel* lblFiles;
138105
};
139106
}
140107

@@ -148,14 +115,12 @@ namespace Nickvision::Miniera::Qt::Views
148115
{
149116
//Window Settings
150117
bool stable{ m_controller->getAppInfo().getVersion().getVersionType() == VersionType::Stable };
151-
setWindowTitle(stable ? _("Application") : _("Application (Preview)"));
118+
setWindowTitle(stable ? _("Miniera") : _("Miniera (Preview)"));
152119
setWindowIcon(QIcon(":/icon.svg"));
153120
setAcceptDrops(true);
154121
//Load Ui
155122
m_ui->setupUi(this);
156123
//Signals
157-
connect(m_ui->actionOpenFolder, &QAction::triggered, this, &MainWindow::openFolder);
158-
connect(m_ui->actionCloseFolder, &QAction::triggered, this, &MainWindow::closeFolder);
159124
connect(m_ui->actionExit, &QAction::triggered, this, &MainWindow::close);
160125
connect(m_ui->actionSettings, &QAction::triggered, this, &MainWindow::settings);
161126
connect(m_ui->actionCheckForUpdates, &QAction::triggered, this, &MainWindow::checkForUpdates);
@@ -165,7 +130,6 @@ namespace Nickvision::Miniera::Qt::Views
165130
connect(m_ui->actionAbout, &QAction::triggered, this, &MainWindow::about);
166131
m_controller->notificationSent() += [&](const NotificationSentEventArgs& args) { QtHelpers::dispatchToMainThread([this, args]() { onNotificationSent(args); }); };
167132
m_controller->shellNotificationSent() += [&](const ShellNotificationSentEventArgs& args) { onShellNotificationSent(args); };
168-
m_controller->folderChanged() += [&](const EventArgs& args) { onFolderChanged(args); };
169133
}
170134

171135
MainWindow::~MainWindow()
@@ -200,33 +164,6 @@ namespace Nickvision::Miniera::Qt::Views
200164
event->accept();
201165
}
202166

203-
void MainWindow::dragEnterEvent(QDragEnterEvent* event)
204-
{
205-
if(event->mimeData()->hasUrls())
206-
{
207-
event->acceptProposedAction();
208-
}
209-
}
210-
211-
void MainWindow::dropEvent(QDropEvent* event)
212-
{
213-
if(event->mimeData()->hasUrls())
214-
{
215-
m_controller->openFolder(event->mimeData()->urls()[0].toLocalFile().toStdString());
216-
}
217-
}
218-
219-
void MainWindow::openFolder()
220-
{
221-
QString path{ QFileDialog::getExistingDirectory(this, _("Open Folder"), {}, QFileDialog::ShowDirsOnly) };
222-
m_controller->openFolder(path.toStdString());
223-
}
224-
225-
void MainWindow::closeFolder()
226-
{
227-
m_controller->closeFolder();
228-
}
229-
230167
void MainWindow::settings()
231168
{
232169
SettingsDialog dialog{ m_controller->createPreferencesViewController(), m_themeManager, this };
@@ -272,13 +209,8 @@ namespace Nickvision::Miniera::Qt::Views
272209
{
273210
QString actionText;
274211
std::function<void()> actionCallback;
275-
if(args.getAction() == "close")
276-
{
277-
actionText = _("Close");
278-
actionCallback = [this]() { closeFolder(); };
279-
}
280212
#ifdef _WIN32
281-
else if(args.getAction() == "update")
213+
if(args.getAction() == "update")
282214
{
283215
actionText = _("Update");
284216
actionCallback = [this]() { windowsUpdate(); };
@@ -297,21 +229,4 @@ namespace Nickvision::Miniera::Qt::Views
297229
ShellNotification::send(args);
298230
#endif
299231
}
300-
301-
void MainWindow::onFolderChanged(const EventArgs& args)
302-
{
303-
if(m_controller->isFolderOpened())
304-
{
305-
m_ui->lblFiles->setText(QString::fromStdString(std::vformat(_n("There is {} file in the folder.", "There are {} files in the folder.", m_controller->getFiles().size()), std::make_format_args(CodeHelpers::unmove(m_controller->getFiles().size())))));
306-
for(const std::filesystem::path& file : m_controller->getFiles())
307-
{
308-
m_ui->listFiles->addItem(QString::fromStdString(file.filename().string()));
309-
}
310-
}
311-
else
312-
{
313-
m_ui->listFiles->clear();
314-
m_ui->lblFiles->setText(_("No Folder Opened"));
315-
}
316-
}
317232
}

0 commit comments

Comments
 (0)