1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

Applications: Create a display properties manager

An interactive application to modify the current display settings, such as
the current wallpaper as well as the screen resolution. Currently we're
adding the resolutions ourselves, because there's currently no way to
detect was resolutions the current display adapter supports (or at least
I can't see one... Maybe VBE does and I'm stupid). It even comes with
a very nice template'd `ItemList` that can support a vector of any type,
which makes life much simpler.
This commit is contained in:
Jesse Buhagiar 2019-09-03 21:45:02 +10:00 committed by Andreas Kling
parent af14b8dc59
commit ecbc0322c1
15 changed files with 329 additions and 1 deletions

View file

@ -0,0 +1,54 @@
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/Vector.h>
#include <LibGUI/GModel.h>
template<typename T>
class ItemListModel final : public GModel {
public:
static NonnullRefPtr<ItemListModel> create(Vector<T>& data) { return adopt(*new ItemListModel<T>(data)); }
virtual ~ItemListModel() override {}
virtual int row_count(const GModelIndex&) const override
{
return m_data.size();
}
virtual int column_count(const GModelIndex&) const override
{
return 1;
}
virtual String column_name(int) const override
{
return "Data";
}
virtual ColumnMetadata column_metadata(int) const override
{
return { 70, TextAlignment::CenterLeft };
}
virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override
{
if (role == Role::Display)
return m_data.at(index.row());
return {};
}
virtual void update() override
{
did_update();
}
private:
explicit ItemListModel(Vector<T>& data)
: m_data(data)
{
}
Vector<T>& m_data;
};