#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H

#include <QDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QGridLayout>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QSettings>
#include <QDir>
#include <QMessageBox>

class SettingsDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SettingsDialog(QWidget *parent = nullptr);
    ~SettingsDialog();

    // Get settings values
    QString getScreenshotsDir() const;
    QString getDatabasePath() const;
    int getImagePreloadCount() const;

    // Load settings from persistent storage
    void loadSettings();
    
    // Save settings to persistent storage
    void saveSettings();

private slots:
    // Button click handlers
    void handleBrowseScreenshotsDir();
    void handleBrowseDatabase();
    void handleAccepted();
    
private:
    // UI Elements
    QLineEdit *m_screenshotsDirEdit;
    QLineEdit *m_databasePathEdit;
    QLineEdit *m_imagePreloadCountEdit;
    QPushButton *m_browseScreenshotsDirBtn;
    QPushButton *m_browseDatabaseBtn;
    QDialogButtonBox *m_buttonBox;
    
    // Helper methods
    void createLayout();
    QString ensureDatabaseFilename(const QString &path);
    
    // Default settings
    static const QString DEFAULT_SCREENSHOTS_DIR;
    static const QString DEFAULT_DATABASE_FILENAME;
    static const QString CONFIG_FILE_PATH;
    static const int DEFAULT_PRELOAD_COUNT = 20;
};

#endif // SETTINGSDIALOG_H