Files
photog/desktop/mainwindow.h
T
puttaalu 504b96ed31 Qt desktop: add manage (edit/delete) and tag autocomplete
Brings the Qt uploader to parity with the web /manage page and the Android
app. Adds a stacked Manage page (reached from the post page) that lists
posts via GET /api/photos with thumbnails from GET /api/thumb/<slug>, edits
caption/date/tags in a QDialog via POST /api/edit, and deletes to trash via
POST /api/delete with a QMessageBox confirm. As a non-browser client it sends
no Origin and so passes the server's same-origin CSRF check.

Tag autocomplete now backs every tags field (post cards and the edit dialog)
via a per-token TagCompleter (QCompleter subclass, MatchContains) fed from
the unguarded GET /api/tags.json.

New files: managepostwidget.{h,cpp}, tagcompleter.{h,cpp}; network methods
and a RemotePhoto struct added to uploadclient. Built and linked clean; not
yet runtime-tested on a real display.
2026-11-04 22:04:06 +01:00

98 lines
2.9 KiB
C++

#pragma once
#include <QList>
#include <QMainWindow>
#include <QStringList>
#include "settings.h"
class QDateEdit;
class QLabel;
class QLineEdit;
class QPushButton;
class QSpinBox;
class QStackedWidget;
class QVBoxLayout;
class PhotoItemWidget;
class ManagePostWidget;
class UploadClient;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
private:
QWidget *buildSettingsPage();
QWidget *buildPostPage();
QWidget *buildManagePage();
void showSettings();
void showPost();
void showManage();
void saveAndTest();
void chooseImages();
void addItem(const QString &path);
void removeItem(PhotoItemWidget *item);
void clearItems();
void submit();
void pumpQueue(); // starts queued items up to the concurrency cap
void startItem(PhotoItemWidget *item);
int inFlightCount() const; // items currently preparing or uploading
void refreshPosting(); // updates the Post button + summary from item states
// Manage page.
UploadClient *manageClient(); // lazily-built, lives as long as the window
void loadManage(); // fetches the post list and thumbnails
void clearManageItems();
void editItem(ManagePostWidget *item);
void deleteItem(ManagePostWidget *item);
// Tag autocomplete.
void refreshTags(); // fetches /api/tags.json
void applyTagSuggestions(); // pushes the list onto every post card
Settings m_settings;
QStackedWidget *m_stack = nullptr;
// Settings page
QLineEdit *m_baseUrl = nullptr;
QLineEdit *m_username = nullptr;
QLineEdit *m_password = nullptr;
QSpinBox *m_concurrency = nullptr;
QPushButton *m_saveButton = nullptr;
QPushButton *m_settingsBack = nullptr;
QLabel *m_settingsStatus = nullptr;
// Post page
QVBoxLayout *m_itemsLayout = nullptr; // holds the PhotoItemWidgets
QList<PhotoItemWidget *> m_items;
QLabel *m_emptyHint = nullptr;
QPushButton *m_postButton = nullptr;
QLabel *m_postSummary = nullptr;
QLabel *m_lastPost = nullptr;
// Bulk-post state: items waiting for a free upload slot, plus the batch's
// credentials captured once at submit time.
QList<PhotoItemWidget *> m_queue;
QString m_batchBaseUrl;
QString m_batchUsername;
QString m_batchPassword;
QString m_batchCacheDir;
// Manage page
QVBoxLayout *m_manageLayout = nullptr; // holds the ManagePostWidgets
QList<ManagePostWidget *> m_manageItems;
QLabel *m_manageEmptyHint = nullptr;
QLabel *m_manageStatus = nullptr;
QPushButton *m_manageRefresh = nullptr;
UploadClient *m_manageClient = nullptr; // lazily created, reused for manage ops
// Known tag names for autocomplete, shared by the post cards and the edit
// dialog. Best-effort: empty until /api/tags.json arrives.
QStringList m_tagSuggestions;
};