ORE Studio 0.0.4
Loading...
Searching...
No Matches
FlagSelectorDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_FLAG_SELECTOR_DIALOG_HPP
21#define ORES_QT_FLAG_SELECTOR_DIALOG_HPP
22
23#include <QDialog>
24#include <QListWidget>
25#include <QPushButton>
26#include <QLineEdit>
27#include <QLabel>
28#include <QString>
29#include "ores.qt/ImageCache.hpp"
30#include "ores.logging/make_logger.hpp"
31
32namespace ores::qt {
33
39class FlagSelectorDialog final : public QDialog {
40 Q_OBJECT
41
42private:
43 inline static std::string_view logger_name = "ores.qt.flag_selector_dialog";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::logging;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
59 explicit FlagSelectorDialog(ImageCache* imageCache,
60 const QString& currentImageId = QString(),
61 QWidget* parent = nullptr);
62
68 QString selectedImageId() const { return selectedImageId_; }
69
70private slots:
71 void onImageListLoaded();
72 void onImageLoaded(const QString& image_id);
73 void onAllImagesLoaded();
74 void onSearchTextChanged(const QString& text);
75 void onItemSelectionChanged();
76 void onClearClicked();
77 void onSelectClicked();
78
79private:
80 void setupUi();
81 void populateList();
82 void filterList(const QString& filter);
83 void loadVisibleIcons();
84
85 ImageCache* imageCache_;
86 QString selectedImageId_;
87 QString currentImageId_;
88
89 QLineEdit* searchEdit_;
90 QListWidget* listWidget_;
91 QLabel* previewLabel_;
92 QLabel* previewDescLabel_;
93 QPushButton* clearButton_;
94 QPushButton* selectButton_;
95 QPushButton* cancelButton_;
96};
97
98}
99
100#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Dialog for selecting a flag/image to associate with a currency.
Definition FlagSelectorDialog.hpp:39
QString selectedImageId() const
Get the selected image ID.
Definition FlagSelectorDialog.hpp:68
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:52