# Screenshot OCR Gallery

A Qt6-based image gallery application that allows you to search through OCR data from your screenshots with live preview and dynamic resizing.

## Features

- Fast visual navigation through your screenshot collection
- Ultra-responsive live search through OCR text as you type with optimized performance
- Dynamic grid layout that automatically reflows (1x, 2x, 3x, 4x, etc.) based on window width
- No horizontal scrollbars - content always fits the window width
- Filename overlay at the bottom of each image for easy identification
- Opens images in your default image viewer on click
- Minimal 2px spacing between images for a compact view
- Proper error handling for missing files and database issues

## Requirements

### Build Dependencies

- Qt6 (Core, Gui, Widgets, Sql modules)
- C++17 compatible compiler
- CMake (3.16+)
- SQLite3 support

### For Arch Linux users:
```
sudo pacman -S qt6-base qt6-tools cmake
```

### For Debian/Ubuntu users:
```
sudo apt install qt6-base-dev libqt6sql6-sqlite cmake
```

## Database Requirements

The application expects a SQLite database file at `/home/master/screenshot_ocr.db` with the following schema:

```sql
CREATE TABLE ocr_results (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    filename TEXT UNIQUE,
    full_path TEXT,
    ocr_text TEXT,
    file_size INTEGER,
    created_date TEXT,
    ocr_date TEXT
);
```

## Building the Project

1. Clone or download this repository
2. Navigate to the project directory
3. Run the build script:

```bash
cd screenshot-gallery
chmod +x build.sh
./build.sh
```

The build script will:
- Check for required dependencies
- Create a build directory
- Run CMake to configure the project
- Build the executable
- Ask if you want to run the application

## Manual Build

If you prefer to build manually:

```bash
mkdir -p build
cd build
cmake ..
make
```

## Running the Application

After building, run the application:

```bash
./build/screenshot-gallery
```

## Usage

1. When the application starts, it will display all screenshots found in the database
2. Type in the search bar to filter images by OCR text content
3. Results update instantly as you type with optimized search performance
4. When you clear the search bar, all images are immediately shown
5. Resize the application window to see the grid automatically reflow:
   - Wider windows show more columns (4x, 5x, etc.)
   - Narrower windows reduce to fewer columns (3x, 2x)
   - Very narrow windows show a single centered column (1x)
   - No horizontal scrolling - content always fits the available width
6. Each image displays its filename at the bottom for easy identification
7. Click on any image to open it in your default image viewer

## Troubleshooting

### Database Connection Issues

If the application cannot connect to the database:
- Ensure the database file exists at the expected location (`/home/master/screenshot_ocr.db`)
- Check file permissions
- Verify the database has the required schema

### Missing Images

If the gallery shows placeholders instead of images:
- Verify that the image files exist at the paths stored in the database
- Check file permissions
- Ensure the paths in the database are correct and accessible

### Build Issues

If the build fails:
- Make sure you have installed all required Qt6 packages
- Check that your CMake version is at least 3.16
- Ensure you have the necessary permissions in the build directory

## License

This project is released under the MIT License.

## Contributing

Contributions are welcome! Feel free to submit pull requests or open issues for bugs and feature requests.