git repos / SagoImageBrowser

blame: src/mainwindow.h

normal view · raw

14cf904f Poul Sander 2026-06-22 18:18 1
/*
14cf904f Poul Sander 2026-06-22 18:18 2
MIT License
14cf904f Poul Sander 2026-06-22 18:18 3
14cf904f Poul Sander 2026-06-22 18:18 4
Copyright (c) 2026 Poul Sander
14cf904f Poul Sander 2026-06-22 18:18 5
14cf904f Poul Sander 2026-06-22 18:18 6
Permission is hereby granted, free of charge, to any person obtaining a copy
14cf904f Poul Sander 2026-06-22 18:18 7
of this software and associated documentation files (the "Software"), to deal
14cf904f Poul Sander 2026-06-22 18:18 8
in the Software without restriction, including without limitation the rights
14cf904f Poul Sander 2026-06-22 18:18 9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14cf904f Poul Sander 2026-06-22 18:18 10
copies of the Software, and to permit persons to whom the Software is
14cf904f Poul Sander 2026-06-22 18:18 11
furnished to do so, subject to the following conditions:
14cf904f Poul Sander 2026-06-22 18:18 12
14cf904f Poul Sander 2026-06-22 18:18 13
The above copyright notice and this permission notice shall be included in all
14cf904f Poul Sander 2026-06-22 18:18 14
copies or substantial portions of the Software.
14cf904f Poul Sander 2026-06-22 18:18 15
14cf904f Poul Sander 2026-06-22 18:18 16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14cf904f Poul Sander 2026-06-22 18:18 17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14cf904f Poul Sander 2026-06-22 18:18 18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14cf904f Poul Sander 2026-06-22 18:18 19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14cf904f Poul Sander 2026-06-22 18:18 20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14cf904f Poul Sander 2026-06-22 18:18 21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
14cf904f Poul Sander 2026-06-22 18:18 22
SOFTWARE.
14cf904f Poul Sander 2026-06-22 18:18 23
14cf904f Poul Sander 2026-06-22 18:18 24
*/
14cf904f Poul Sander 2026-06-22 18:18 25
032aa1e1 Poul Sander 2026-02-19 18:55 26
#pragma once
032aa1e1 Poul Sander 2026-02-19 18:55 27
80a9926d Poul Sander 2026-05-19 20:28 28
#include <QByteArray>
032aa1e1 Poul Sander 2026-02-19 18:55 29
#include <QMainWindow>
032aa1e1 Poul Sander 2026-02-19 18:55 30
032aa1e1 Poul Sander 2026-02-19 18:55 31
class QTreeView;
032aa1e1 Poul Sander 2026-02-19 18:55 32
class QListView;
032aa1e1 Poul Sander 2026-02-19 18:55 33
class QLabel;
61136b77 Poul Sander 2026-02-20 22:45 34
class QStackedWidget;
ccb726b8 Poul Sander 2026-02-23 22:43 35
class QMenuBar;
cbc7d22b Poul Sander 2026-02-24 19:23 36
class QDockWidget;
40efdfde Poul Sander 2026-05-19 21:24 37
class FsDirModel;
3bee3e3e Poul Sander 2026-03-05 17:07 38
class QListWidget;
53fdab93 Poul Sander 2026-05-18 18:45 39
class QTableWidget;
fd7f51cd Poul Sander 2026-05-22 15:30 40
class QLineEdit;
fd7f51cd Poul Sander 2026-05-22 15:30 41
class QPushButton;
fd7f51cd Poul Sander 2026-05-22 15:30 42
class QCompleter;
237d2c81 Poul Sander 2026-06-06 14:53 43
class QPoint;
032aa1e1 Poul Sander 2026-02-19 18:55 44
class ImageModel;
61136b77 Poul Sander 2026-02-20 22:45 45
class ImageViewWidget;
fd7f51cd Poul Sander 2026-05-22 15:30 46
class PathCompleterModel;
f61bf886 Poul Sander 2026-02-23 19:27 47
class PreferencesDialog;
032aa1e1 Poul Sander 2026-02-19 18:55 48
032aa1e1 Poul Sander 2026-02-19 18:55 49
class MainWindow : public QMainWindow
032aa1e1 Poul Sander 2026-02-19 18:55 50
{
032aa1e1 Poul Sander 2026-02-19 18:55 51
    Q_OBJECT
032aa1e1 Poul Sander 2026-02-19 18:55 52
032aa1e1 Poul Sander 2026-02-19 18:55 53
public:
032aa1e1 Poul Sander 2026-02-19 18:55 54
    explicit MainWindow(QWidget *parent = nullptr);
48607848 Poul Sander 2026-05-19 19:20 55
    void openPath(const QString &path);
032aa1e1 Poul Sander 2026-02-19 18:55 56
032aa1e1 Poul Sander 2026-02-19 18:55 57
private:
032aa1e1 Poul Sander 2026-02-19 18:55 58
    void setupUi();
032aa1e1 Poul Sander 2026-02-19 18:55 59
    void setupConnections();
f61bf886 Poul Sander 2026-02-23 19:27 60
    void setupMenuBar();
f61bf886 Poul Sander 2026-02-23 19:27 61
    void loadPreferences();
f61bf886 Poul Sander 2026-02-23 19:27 62
    void savePreferences();
f61bf886 Poul Sander 2026-02-23 19:27 63
    void onPreferencesTriggered();
7370f1c0 Poul Sander 2026-03-01 15:15 64
    void resetLayoutToDefault();
80a9926d Poul Sander 2026-05-19 20:28 65
    void navigateToFolder(const QByteArray &path);
80a9926d Poul Sander 2026-05-19 20:28 66
    void navigateToFolder(const QString &path);  // convenience: converts via QFile::encodeName
665ac308 Poul Sander 2026-02-23 19:34 67
    void selectPreviousFolderIfExists();
ccb726b8 Poul Sander 2026-02-23 22:43 68
    void setFullScreenMode(bool fullScreen);
6fcd6c90 Poul Sander 2026-02-19 21:12 69
    void loadVisibleThumbnails();
cfe4a67b Poul Sander 2026-02-19 23:06 70
    void showPreview(const QModelIndex &index);
80a9926d Poul Sander 2026-05-19 20:28 71
    void updateExifInfo(const QByteArray &path);
61136b77 Poul Sander 2026-02-20 22:45 72
    void enterSingleImageMode(const QModelIndex &index);
61136b77 Poul Sander 2026-02-20 22:45 73
    void leaveSingleImageMode();
beb4a823 Poul Sander 2026-05-19 21:53 74
    void onEditCaption();
237d2c81 Poul Sander 2026-06-06 14:53 75
    void showImageContextMenu(const QPoint &pos);
d93c1ab0 Poul Sander 2026-06-08 21:44 76
    void showImageViewContextMenu(const QPoint &pos);
d93c1ab0 Poul Sander 2026-06-08 21:44 77
    void executeContextMenu(const QPoint &globalPos, const QByteArray &path, const QModelIndex &index);
700d6f2d Poul Sander 2026-06-06 15:44 78
    void moveImageToTrash(const QByteArray &path);
a686d839 Poul Sander 2026-06-06 22:34 79
    void moveCurrentImageToTrash();
48534775 Poul Sander 2026-06-08 18:57 80
    void rotateImage(const QModelIndex &index, bool clockwise);
fd7f51cd Poul Sander 2026-05-22 15:30 81
    void onPathEntered();
fd7f51cd Poul Sander 2026-05-22 15:30 82
    void updatePathField(const QByteArray &path);
80a9926d Poul Sander 2026-05-19 20:28 83
    QList<QByteArray> computeNeighborPaths(const QModelIndex &index) const;
bf525669 Poul Sander 2026-05-30 23:18 84
    QByteArray siblingFolder(int delta) const;
bf525669 Poul Sander 2026-05-30 23:18 85
    void navigateToPrevFolder();
bf525669 Poul Sander 2026-05-30 23:18 86
    void navigateToNextFolder();
8cb93c2f Poul Sander 2026-06-28 19:31 87
    void updateRootList();
6fcd6c90 Poul Sander 2026-02-19 21:12 88
61136b77 Poul Sander 2026-02-20 22:45 89
    void keyPressEvent(QKeyEvent *event) override;
6fcd6c90 Poul Sander 2026-02-19 21:12 90
    bool eventFilter(QObject *obj, QEvent *event) override;
c9e5684a Poul Sander 2026-02-23 19:18 91
    void closeEvent(QCloseEvent *event) override;
032aa1e1 Poul Sander 2026-02-19 18:55 92
40efdfde Poul Sander 2026-05-19 21:24 93
    FsDirModel *m_dirModel;
032aa1e1 Poul Sander 2026-02-19 18:55 94
    ImageModel *m_imageModel;
032aa1e1 Poul Sander 2026-02-19 18:55 95
032aa1e1 Poul Sander 2026-02-19 18:55 96
    QTreeView *m_treeView;
3bee3e3e Poul Sander 2026-03-05 17:07 97
    QListWidget *m_rootList;
032aa1e1 Poul Sander 2026-02-19 18:55 98
    QListView *m_listView;
032aa1e1 Poul Sander 2026-02-19 18:55 99
    QLabel *m_previewLabel;
fd7f51cd Poul Sander 2026-05-22 15:30 100
    QLineEdit *m_pathEdit = nullptr;
fd7f51cd Poul Sander 2026-05-22 15:30 101
    QPushButton *m_goButton = nullptr;
bf525669 Poul Sander 2026-05-30 23:18 102
    QPushButton *m_prevFolderButton = nullptr;
bf525669 Poul Sander 2026-05-30 23:18 103
    QPushButton *m_nextFolderButton = nullptr;
fd7f51cd Poul Sander 2026-05-22 15:30 104
    PathCompleterModel *m_pathCompleterModel = nullptr;
fd7f51cd Poul Sander 2026-05-22 15:30 105
    QCompleter *m_pathCompleter = nullptr;
61136b77 Poul Sander 2026-02-20 22:45 106
61136b77 Poul Sander 2026-02-20 22:45 107
    QStackedWidget *m_stack;
f61bf886 Poul Sander 2026-02-23 19:27 108
    QString m_backgroundColorPreference = "black";
459bad0f Poul Sander 2026-05-17 14:11 109
    int m_folderCacheSizePreference = 4;
ac476ca8 Poul Sander 2026-05-18 16:47 110
    QString m_thumbnailCacheSizePreference = "normal";
8cb93c2f Poul Sander 2026-06-28 19:31 111
    QStringList m_rootLabelsPreference;
8cb93c2f Poul Sander 2026-06-28 19:31 112
    QStringList m_rootPathsPreference;
61136b77 Poul Sander 2026-02-20 22:45 113
    QWidget *m_browserPage;
61136b77 Poul Sander 2026-02-20 22:45 114
    ImageViewWidget *m_imageView;
3968465e Poul Sander 2026-02-23 19:13 115
    bool m_wasMaximized = false;
ccb726b8 Poul Sander 2026-02-23 22:43 116
    bool m_imageViewWasFullScreen = false;
80a9926d Poul Sander 2026-05-19 20:28 117
    QByteArray m_previousFolderPath;
cbc7d22b Poul Sander 2026-02-24 19:23 118
    QMenuBar *m_menuBar = nullptr;
3bee3e3e Poul Sander 2026-03-05 17:07 119
    QDockWidget *m_rootDock = nullptr;
cbc7d22b Poul Sander 2026-02-24 19:23 120
    QDockWidget *m_folderDock = nullptr;
cbc7d22b Poul Sander 2026-02-24 19:23 121
    QDockWidget *m_previewDock = nullptr;
53fdab93 Poul Sander 2026-05-18 18:45 122
    QDockWidget *m_exifDock = nullptr;
53fdab93 Poul Sander 2026-05-18 18:45 123
    QTableWidget *m_exifTable = nullptr;
3bee3e3e Poul Sander 2026-03-05 17:07 124
    bool m_rootDockWasVisible = true;
cbc7d22b Poul Sander 2026-02-24 19:23 125
    bool m_folderDockWasVisible = true;
cbc7d22b Poul Sander 2026-02-24 19:23 126
    bool m_previewDockWasVisible = true;
53fdab93 Poul Sander 2026-05-18 18:45 127
    bool m_exifDockWasVisible = true;
4ae57f60 Poul Sander 2026-02-25 21:35 128
    bool m_lockDockingPreference = false;
4ae57f60 Poul Sander 2026-02-25 21:35 129
4ae57f60 Poul Sander 2026-02-25 21:35 130
    void applyDockLocking(bool lock);
237d2c81 Poul Sander 2026-06-06 14:53 131
};
1970-01-01 00:00 132