1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-17 15:05:07 +00:00
serenity/Userland/Applications/MouseSettings/ThemeWidget.h
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

81 lines
2.3 KiB
C++

/*
* Copyright (c) 2021-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "DoubleClickArrowWidget.h"
#include <LibGUI/Model.h>
#include <LibGUI/SettingsWindow.h>
#include <LibGfx/CursorParams.h>
class MouseCursorModel final : public GUI::Model {
public:
static NonnullRefPtr<MouseCursorModel> create() { return adopt_ref(*new MouseCursorModel); }
virtual ~MouseCursorModel() override = default;
enum Column {
Bitmap,
Name,
__Count,
};
virtual int row_count(const GUI::ModelIndex&) const override { return m_cursors.size(); }
virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; }
virtual ErrorOr<String> column_name(int column_index) const override;
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
virtual void invalidate() override;
void change_theme(ByteString const& name)
{
m_theme_name = name;
invalidate();
}
private:
MouseCursorModel() = default;
struct Cursor {
RefPtr<Gfx::Bitmap> bitmap;
ByteString path;
ByteString name;
Gfx::CursorParams params;
};
Vector<Cursor> m_cursors;
ByteString m_theme_name;
};
class ThemeModel final : public GUI::Model {
public:
static NonnullRefPtr<ThemeModel> create() { return adopt_ref(*new ThemeModel); }
virtual int row_count(const GUI::ModelIndex&) const override { return m_themes.size(); }
virtual int column_count(const GUI::ModelIndex&) const override { return 1; }
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
virtual void invalidate() override;
private:
Vector<ByteString> m_themes;
};
class ThemeWidget final : public GUI::SettingsWindow::Tab {
C_OBJECT_ABSTRACT(ThemeWidget)
public:
static ErrorOr<NonnullRefPtr<ThemeWidget>> try_create();
virtual ~ThemeWidget() override = default;
virtual void apply_settings() override;
virtual void reset_default_values() override;
private:
ThemeWidget() = default;
ErrorOr<void> setup();
RefPtr<GUI::TableView> m_cursors_tableview;
RefPtr<GUI::ComboBox> m_theme_name_box;
RefPtr<MouseCursorModel> m_mouse_cursor_model;
};