Settings.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
  3. * Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
  4. * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <AK/ByteString.h>
  10. #include <AK/OwnPtr.h>
  11. #include <LibWebView/SearchEngine.h>
  12. #include <QPoint>
  13. #include <QSettings>
  14. #include <QSize>
  15. namespace Ladybird {
  16. class Settings : public QObject {
  17. Q_OBJECT
  18. public:
  19. Settings(Settings const&) = delete;
  20. Settings& operator=(Settings const&) = delete;
  21. static Settings* the()
  22. {
  23. static Settings instance;
  24. return &instance;
  25. }
  26. ByteString directory();
  27. Optional<QPoint> last_position();
  28. void set_last_position(QPoint const& last_position);
  29. QSize last_size();
  30. void set_last_size(QSize const& last_size);
  31. bool is_maximized();
  32. void set_is_maximized(bool is_maximized);
  33. QString new_tab_page();
  34. void set_new_tab_page(QString const& page);
  35. WebView::SearchEngine search_engine() const { return m_search_engine; }
  36. void set_search_engine(WebView::SearchEngine engine);
  37. QStringList preferred_languages();
  38. void set_preferred_languages(QStringList const& languages);
  39. struct EngineProvider {
  40. QString name;
  41. QString url;
  42. };
  43. EngineProvider autocomplete_engine();
  44. void set_autocomplete_engine(EngineProvider const& engine);
  45. bool enable_autocomplete();
  46. void set_enable_autocomplete(bool enable);
  47. bool enable_search();
  48. void set_enable_search(bool enable);
  49. bool enable_do_not_track();
  50. void set_enable_do_not_track(bool enable);
  51. bool enable_autoplay();
  52. void set_enable_autoplay(bool enable);
  53. int scrolling_speed();
  54. void set_scrolling_speed(int value);
  55. bool invert_vertical_scrolling();
  56. void set_invert_vertical_scrolling(bool enable);
  57. bool invert_horizontal_scrolling();
  58. void set_invert_horizontal_scrolling(bool enable);
  59. bool show_menubar();
  60. void set_show_menubar(bool show_menubar);
  61. signals:
  62. void show_menubar_changed(bool show_menubar);
  63. void enable_search_changed(bool enable);
  64. void search_engine_changed(WebView::SearchEngine engine);
  65. void preferred_languages_changed(QStringList const& languages);
  66. void enable_do_not_track_changed(bool enable);
  67. void enable_autoplay_changed(bool enable);
  68. protected:
  69. Settings();
  70. private:
  71. OwnPtr<QSettings> m_qsettings;
  72. WebView::SearchEngine m_search_engine;
  73. };
  74. }