keditbookmars: use KConfig instance to save column sizes

no functional change, no reason to use kcfg files for it either

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-29 19:56:45 +03:00
parent de64f8e332
commit 1a2cc4e2ba
5 changed files with 15 additions and 59 deletions

View file

@ -45,8 +45,6 @@ qt4_add_dbus_interface(keditbookmarks_SRCS
favicon_interface
)
kde4_add_kcfg_files(keditbookmarks_SRCS settings.kcfgc)
add_executable(keditbookmarks ${keditbookmarks_SRCS})
target_link_libraries(keditbookmarks

View file

@ -21,7 +21,6 @@
#include "globalbookmarkmanager.h"
#include "kbookmarkmodel/model.h"
#include "toplevel.h" // for KEBApp
#include "settings.h"
#include "kbookmarkmodel/commands.h"
#include <QHeaderView>
@ -31,8 +30,12 @@
#include <QBrush>
#include <QPalette>
#include <kglobal.h>
#include <kconfiggroup.h>
#include <kdebug.h>
static const int s_defaultcolumnsize = 300;
BookmarkFolderView::BookmarkFolderView( BookmarkListView * view, QWidget * parent )
: KBookmarkView(parent), mview(view)
{
@ -131,19 +134,21 @@ void BookmarkListView::contextMenuEvent ( QContextMenuEvent * e )
void BookmarkListView::loadColumnSetting()
{
header()->resizeSection(KEBApp::NameColumn, KEBSettings::name());
header()->resizeSection(KEBApp::UrlColumn, KEBSettings::uRL());
header()->resizeSection(KEBApp::CommentColumn, KEBSettings::comment());
header()->resizeSection(KEBApp::StatusColumn, KEBSettings::status());
KConfigGroup columngroup = KConfigGroup(KGlobal::config(), "Column");
header()->resizeSection(KEBApp::NameColumn, columngroup.readEntry("Name", s_defaultcolumnsize));
header()->resizeSection(KEBApp::UrlColumn, columngroup.readEntry("URL", s_defaultcolumnsize));
header()->resizeSection(KEBApp::CommentColumn, columngroup.readEntry("Comment", s_defaultcolumnsize));
header()->resizeSection(KEBApp::StatusColumn, columngroup.readEntry("Status", s_defaultcolumnsize));
}
void BookmarkListView::saveColumnSetting()
{
KEBSettings::setName( header()->sectionSize(KEBApp::NameColumn));
KEBSettings::setURL( header()->sectionSize(KEBApp::UrlColumn));
KEBSettings::setComment( header()->sectionSize(KEBApp::CommentColumn));
KEBSettings::setStatus( header()->sectionSize(KEBApp::StatusColumn));
KEBSettings::self()->writeConfig();
KConfigGroup columngroup = KConfigGroup(KGlobal::config(), "Column");
columngroup.writeEntry("Name", header()->sectionSize(KEBApp::NameColumn));
columngroup.writeEntry("URL", header()->sectionSize(KEBApp::UrlColumn));
columngroup.writeEntry("Comment", header()->sectionSize(KEBApp::CommentColumn));
columngroup.writeEntry("Status", header()->sectionSize(KEBApp::StatusColumn));
KGlobal::config()->sync();
}
/************/

View file

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="keditbookmarksrc" />
<group name="Columns">
<entry key="Name" type="Int">
<default>300</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="URL" type="Int">
<default>300</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="Comment" type="Int">
<default>300</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="Status" type="Int">
<default>300</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="Address" type="Int">
<default>300</default>
<label></label>
<whatsthis></whatsthis>
</entry>
</group>
<group name="General">
<entry name="SaveOnClose" key="Save On Close" type="Bool">
<label></label>
<whatsthis></whatsthis>
</entry>
</group>
</kcfg>

View file

@ -1,4 +0,0 @@
File=keditbookmarks.kcfg
ClassName=KEBSettings
Singleton=true
Mutators=true

View file

@ -26,7 +26,6 @@
#include "bookmarkinfowidget.h"
#include "actionsimpl.h"
#include "settings.h"
#include "kbookmarkmodel/commands.h"
#include "kbookmarkmodel/commandhistory.h"
#include "kebsearchline.h"