/// QasTools: Desktop toolset for the Linux sound system ALSA.
/// \copyright See COPYING file.

#pragma once

#include "main_window_setup.hpp"
#include "tray/setup.hpp"
#include "utility/setup.hpp"
#include "views/settings_dialog_setup.hpp"
#include <QString>

/// @brief Desktop_Items_Setup
///
class Desktop_Items_Setup : public Utility::Setup
{
  public:
  // -- Public types

  enum Mixer_Device
  {
    MIXER_DEV_DEFAULT = 0,
    MIXER_DEV_PREVIOUS = 1,
    MIXER_DEV_USER = 2,
    MIXER_DEV_LAST = MIXER_DEV_USER
  };

  // -- Construction

  Desktop_Items_Setup ();

  ~Desktop_Items_Setup () override;

  // -- Attributes

  Tray::Setup tray;
  Main_Window_Setup main_window;
  Views::Settings_Dialog_Setup settings_dialog;

  // -- Start device mode

  Mixer_Device
  start_device_mode () const
  {
    return _start_device_mode;
  }

  bool
  set_start_device_mode ( Mixer_Device mode_n );

  // -- Start user device

  const QString &
  start_user_device () const
  {
    return _start_user_device;
  }

  bool
  set_start_user_device ( const QString & device_n );

  // -- Tray on close

  bool
  tray_on_close () const
  {
    return _tray_on_close;
  }

  bool
  set_tray_on_close ( bool flag_n );

  // -- Tray show icon

  bool
  tray_show_icon () const
  {
    return _tray_show_icon;
  }

  bool
  set_tray_show_icon ( bool flag_n );

  // -- Tray is minimized

  bool
  tray_is_minimized () const
  {
    return _tray_is_minimized;
  }

  bool
  set_tray_is_minimized ( bool flag_n );

  // -- Storage

  /// @brief Returns true if changes were made since the last
  ///        read_from_storage () or write_to_storage ()
  bool
  differs_from_storage () const
  {
    return ( _storage_change_id != change_id () );
  }

  /// @brief Read the settings from the storage (file)
  void
  read_from_storage ();

  /// @brief Writes the settings to the storage (file)
  void
  write_to_storage ();

  private:
  // -- Attributes
  Mixer_Device _start_device_mode = Mixer_Device::MIXER_DEV_DEFAULT;
  QString _start_user_device;
  bool _tray_on_close = true;
  bool _tray_show_icon = true;
  bool _tray_is_minimized = false;
  // Storage settings
  std::size_t _storage_change_id = 0;
};
