mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
ClipboardHistory: Use config file to set number of history items
The number of items in history was hardcoded to 20 earlier, now we try to load this value from a config file. The default if none is available is still 20.
This commit is contained in:
parent
b9979e9a59
commit
b1a3bb638b
4 changed files with 14 additions and 2 deletions
|
@ -10,4 +10,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(ClipboardHistory.Applet ICON edit-copy)
|
serenity_app(ClipboardHistory.Applet ICON edit-copy)
|
||||||
target_link_libraries(ClipboardHistory.Applet LibGUI LibCore LibGfx)
|
target_link_libraries(ClipboardHistory.Applet LibGUI LibCore LibGfx LibConfig)
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ClipboardHistoryModel.h"
|
#include "ClipboardHistoryModel.h"
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <AK/NumberFormat.h>
|
#include <AK/NumberFormat.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
|
||||||
|
@ -13,6 +15,11 @@ NonnullRefPtr<ClipboardHistoryModel> ClipboardHistoryModel::create()
|
||||||
return adopt_ref(*new ClipboardHistoryModel());
|
return adopt_ref(*new ClipboardHistoryModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClipboardHistoryModel::ClipboardHistoryModel()
|
||||||
|
: m_history_limit(Config::read_i32("ClipboardHistory", "ClipboardHistory", "NumHistoryItems", 20))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ClipboardHistoryModel::~ClipboardHistoryModel()
|
ClipboardHistoryModel::~ClipboardHistoryModel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +29,7 @@ public:
|
||||||
void remove_item(int index);
|
void remove_item(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ClipboardHistoryModel();
|
||||||
void add_item(const GUI::Clipboard::DataAndType& item);
|
void add_item(const GUI::Clipboard::DataAndType& item);
|
||||||
|
|
||||||
// ^GUI::Model
|
// ^GUI::Model
|
||||||
|
@ -40,5 +42,5 @@ private:
|
||||||
virtual void clipboard_content_did_change(const String&) override { add_item(GUI::Clipboard::the().data_and_type()); }
|
virtual void clipboard_content_did_change(const String&) override { add_item(GUI::Clipboard::the().data_and_type()); }
|
||||||
|
|
||||||
Vector<GUI::Clipboard::DataAndType> m_history_items;
|
Vector<GUI::Clipboard::DataAndType> m_history_items;
|
||||||
size_t m_history_limit { 20 };
|
size_t m_history_limit;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ClipboardHistoryModel.h"
|
#include "ClipboardHistoryModel.h"
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/ImageWidget.h>
|
#include <LibGUI/ImageWidget.h>
|
||||||
|
@ -23,6 +24,8 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
|
||||||
|
Config::pledge_domains("ClipboardHistory");
|
||||||
|
|
||||||
if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
|
if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue