using Gtk 4.0;
using Adw 1;

template $GradiaPreferencesWindow: Adw.PreferencesDialog {
  content-width: 600;
  content-height: 500;
  title: _("Preferences");

  Adw.PreferencesPage {
    name: "preferences";
    title: _("General");

    Adw.PreferencesGroup {
      title: _("Screenshots");

      Adw.ActionRow {
        title: _("_Recent Directory");
        use-underline: true;
        subtitle: _("Used for home screen");
        activatable: true;
        activated => $on_folder_row_clicked();

        [suffix]
        Box {
          spacing: 6;
          valign: center;

          Label folder_label {
            label: "-";

            styles [
              "dim-label",
            ]
          }

          Gtk.Image {
            icon-name: "go-next-symbolic";
          }
        }
      }
    }

    Adw.PreferencesGroup {
      Adw.ButtonRow help_button {
        title: _("_Screenshot Shortcut");
        use-underline: true;
      }
    }

    Adw.PreferencesGroup save_format_group {
      title: _("Save Options");

      Adw.ComboRow save_format_combo {
        title: _("_Image Format");
        use-underline: true;
        subtitle: _("Default format for saved screenshots");
      }
    }

    Adw.PreferencesGroup {
      title: _("Closing");

      Adw.ComboRow exiting_combo {
        title: _("_When Exiting");
        use-underline: true;
      }

      Adw.SwitchRow overwrite_screenshot_switch {
        title: _("_Overwrite Last Screenshot on Close");
        use-underline: true;
        subtitle: _("Replace it with the annotated version");
        tooltip-text: _("Replace last screenshot file with annotated version on close");
        activatable: true;
      }

      Adw.SwitchRow delete_screenshot_switch {
        title: _("_Trash Screenshots on Close");
        use-underline: true;
        subtitle: _("Automatically move screenshots taken from within the app to trash");
        tooltip-text: _("Trash screenshots on app close");
        activatable: true;
      }
    }

    Adw.PreferencesGroup {
      title: _("Image Upload Providers");
      description: _("Connect to your favorite upload providers, or create a link yourself");

      Adw.ActionRow provider_row {
        title: _("_Provider");
        use-underline: true;
        activatable: true;
        activated => $on_choose_provider_clicked();

        [suffix]
        Gtk.Box {
          spacing: 6;
          valign: center;

          Gtk.Label provider_name {
            label: _("None Selected");

            styles [
              "dim-label",
            ]
          }

          Gtk.Image {
            icon-name: "go-next-symbolic";
          }
        }
      }

      Adw.SwitchRow confirm_upload_switch {
        title: _("_Confirm on Upload");
        use-underline: true;
        subtitle: _("Ask for confirmation before running the upload command");
        tooltip-text: _("Ask for confirmation before running the upload command");
        activatable: true;
      }
    }

    Adw.PreferencesGroup {
      title: _("Text Extraction");
      visible: bind template.ocr_enabled;

      Adw.ActionRow {
        title: _("_Language Models");
        use-underline: true;
        subtitle: _("Download Models to improve per-language accuracy");
        activatable: true;
        activated => $on_manage_language_models_clicked();

        [suffix]
        Gtk.Image {
          icon-name: "go-next-symbolic";
        }
      }
    }
  }
}

