Commit 9a50ecad authored by Sergio Martins's avatar Sergio Martins
Browse files

korg: Port away from KComponentData

Fixes korg showing empty about dialog, because KComponentData
would reset it.

BUG: 352046
parent 99ca65e0
......@@ -213,7 +213,7 @@ void ActionManager::createCalendarAkonadi()
{
Q_ASSERT(calendar());
KConfig *config = KOGlobals::self()->config();
KSharedConfig::Ptr config = KSharedConfig::openConfig();
mCollectionSelectionModelStateSaver =
new KViewStateMaintainer<Akonadi::ETMViewStateSaver>(
config->group("GlobalCollectionSelection"));
......@@ -656,7 +656,8 @@ void ActionManager::initActions()
mEventViewerShowAction = new KToggleAction(i18n("Show Item Viewer"), this);
mACollection->addAction(QStringLiteral("show_eventviewer"), mEventViewerShowAction);
connect(mEventViewerShowAction, &KToggleAction::triggered, this, &ActionManager::toggleEventViewer);
KConfigGroup config(KOGlobals::self()->config(), "Settings");
KConfigGroup config(KSharedConfig::openConfig(), "Settings");
mDateNavigatorShowAction->setChecked(config.readEntry("DateNavigatorVisible", true));
// if we are a kpart, then let's not show the todo in the left pane by
// default since there's also a Todo part and we'll assume they'll be
......@@ -794,33 +795,34 @@ void ActionManager::restoreCollectionViewSetting()
void ActionManager::writeSettings()
{
KConfigGroup config = KOGlobals::self()->config()->group("Settings");
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup group = config->group("Settings");
mCalendarView->writeSettings();
if (mDateNavigatorShowAction) {
config.writeEntry("DateNavigatorVisible", mDateNavigatorShowAction->isChecked());
group.writeEntry("DateNavigatorVisible", mDateNavigatorShowAction->isChecked());
}
if (mTodoViewShowAction) {
config.writeEntry("TodoViewVisible", mTodoViewShowAction->isChecked());
group.writeEntry("TodoViewVisible", mTodoViewShowAction->isChecked());
}
if (mCollectionViewShowAction) {
config.writeEntry("ResourceViewVisible", mCollectionViewShowAction->isChecked());
group.writeEntry("ResourceViewVisible", mCollectionViewShowAction->isChecked());
}
if (mEventViewerShowAction) {
config.writeEntry("EventViewerVisible", mEventViewerShowAction->isChecked());
group.writeEntry("EventViewerVisible", mEventViewerShowAction->isChecked());
}
mCollectionViewStateSaver->saveState();
mCollectionSelectionModelStateSaver->saveState();
KConfigGroup selectionViewGroup = KOGlobals::self()->config()->group("GlobalCollectionView");
KConfigGroup selectionGroup = KOGlobals::self()->config()->group("GlobalCollectionSelection");
KConfigGroup selectionViewGroup = config->group("GlobalCollectionView");
KConfigGroup selectionGroup = config->group("GlobalCollectionSelection");
selectionGroup.sync();
selectionViewGroup.sync();
config.sync();
config->sync();
}
/*
......
......@@ -203,7 +203,8 @@ private:
void saveTreeState()
{
Akonadi::ETMViewStateSaver treeStateSaver;
KConfigGroup group(KOGlobals::self()->config(), mTreeStateConfig);
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup group = config->group(mTreeStateConfig);
treeStateSaver.setView(mTreeView);
treeStateSaver.setSelectionModel(0); // we only save expand state
treeStateSaver.saveState(group);
......@@ -223,7 +224,7 @@ private:
}
qCDebug(KORGANIZER_LOG) << "Restore tree state";
treeStateRestorer = new Akonadi::ETMViewStateSaver(); // not a leak
KConfigGroup group(KOGlobals::self()->config(), mTreeStateConfig);
KConfigGroup group(KSharedConfig::openConfig(), mTreeStateConfig);
treeStateRestorer->setView(mTreeView);
treeStateRestorer->setSelectionModel(0); // we only restore expand state
treeStateRestorer->restoreState(group);
......
......@@ -413,8 +413,7 @@ void CalendarView::readSettings()
// read settings from the KConfig, supplying reasonable
// defaults where none are to be found
KConfig *config = KOGlobals::self()->config();
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup geometryConfig(config, "KOrganizer Geometry");
QList<int> sizes = geometryConfig.readEntry("Separator1", QList<int>());
......@@ -429,10 +428,10 @@ void CalendarView::readSettings()
mLeftSplitter->setSizes(sizes);
}
mViewManager->readSettings(config);
mTodoList->restoreLayout(config, QStringLiteral("Sidebar Todo View"), true);
mViewManager->readSettings(config.data());
mTodoList->restoreLayout(config.data(), QStringLiteral("Sidebar Todo View"), true);
readFilterSettings(config);
readFilterSettings(config.data());
KConfigGroup viewConfig(config, "Views");
int dateCount = viewConfig.readEntry("ShownDatesCount", 7);
......@@ -445,8 +444,7 @@ void CalendarView::readSettings()
void CalendarView::writeSettings()
{
KConfig *config = KOGlobals::self()->config();
auto config = KSharedConfig::openConfig();
KConfigGroup geometryConfig(config, "KOrganizer Geometry");
QList<int> list = mMainSplitterSizes.isEmpty() ? mPanner->sizes() : mMainSplitterSizes;
......@@ -460,14 +458,14 @@ void CalendarView::writeSettings()
geometryConfig.writeEntry("Separator2", list);
}
mViewManager->writeSettings(config);
mTodoList->saveLayout(config, QStringLiteral("Sidebar Todo View"));
mViewManager->writeSettings(config.data());
mTodoList->saveLayout(config.data(), QStringLiteral("Sidebar Todo View"));
Akonadi::CalendarSettings::self()->save();
KOPrefs::instance()->save();
CalendarSupport::KCalPrefs::instance()->save();
writeFilterSettings(config);
writeFilterSettings(config.data());
KConfigGroup viewConfig(config, "Views");
viewConfig.writeEntry("ShownDatesCount", mDateNavigator->selectedDates().count());
......
......@@ -246,7 +246,7 @@ void SearchDialog::search(const QRegExp &re)
void SearchDialog::readConfig()
{
KConfigGroup group(KOGlobals::self()->config(), QStringLiteral("SearchDialog"));
KConfigGroup group = KSharedConfig::openConfig()->group(QStringLiteral("SearchDialog"));
const QSize size = group.readEntry("Size", QSize(775, 600));
if (size.isValid()) {
resize(size);
......@@ -255,7 +255,7 @@ void SearchDialog::readConfig()
void SearchDialog::writeConfig()
{
KConfigGroup group(KOGlobals::self()->config(), QStringLiteral("SearchDialog"));
KConfigGroup group = KSharedConfig::openConfig()->group(QStringLiteral("SearchDialog"));
group.writeEntry("Size", size());
group.sync();
}
......
......@@ -45,17 +45,10 @@ KOGlobals *KOGlobals::self()
return &sKOGlobalsSingletonPrivate->instance;
}
KOGlobals::KOGlobals()
: mOwnInstance("korganizer"), mHolidays(Q_NULLPTR)
KOGlobals::KOGlobals() : mHolidays(Q_NULLPTR)
{
}
KConfig *KOGlobals::config() const
{
KSharedConfig::Ptr c = mOwnInstance.config();
return c.data();
}
KOGlobals::~KOGlobals()
{
delete mHolidays;
......
......@@ -27,7 +27,11 @@
#include "korganizerprivate_export.h"
#include <KComponentData>
#include <QPixmap>
#include <QString>
#include <QDate>
#include <QMap>
#include <QList>
namespace KHolidays
{
......@@ -43,8 +47,6 @@ class KORGANIZERPRIVATE_EXPORT KOGlobals
public:
static KOGlobals *self();
KConfig *config() const;
static bool reverseLayout();
const KCalendarSystem *calendarSystem() const;
......@@ -79,7 +81,6 @@ protected:
KOGlobals();
private:
KComponentData mOwnInstance;
KHolidays::HolidayRegion *mHolidays;
};
......
......@@ -42,6 +42,7 @@
#include "korganizer_debug.h"
#include <KShortcutsDialog>
#include <KStandardAction>
#include <KSharedConfig>
#include <QLabel>
#include <QStatusBar>
......@@ -74,7 +75,6 @@ void KOrganizer::init(bool document)
{
setHasDocument(document);
setComponentData(KComponentData::mainComponent());
// Create calendar object, which manages all calendar information associated
// with this calendar view window.
......@@ -125,10 +125,8 @@ void KOrganizer::readSettings()
// read settings from the KConfig, supplying reasonable
// defaults where none are to be found
KConfig *config = KOGlobals::self()->config();
KSharedConfig::Ptr config = KSharedConfig::openConfig();
mActionManager->readSettings();
config->sync();
}
......@@ -136,8 +134,7 @@ void KOrganizer::writeSettings()
{
qCDebug(KORGANIZER_LOG);
KConfig *config = KOGlobals::self()->config();
KSharedConfig::Ptr config = KSharedConfig::openConfig();
mActionManager->writeSettings();
config->sync();
}
......
......@@ -477,8 +477,7 @@ void KOViewManager::showAgendaView()
this, SLOT(currentAgendaViewTabChanged(QWidget*)));
mMainView->viewStack()->addWidget(mAgendaViewTabs);
KConfig *config = KOGlobals::self()->config();
KConfigGroup viewConfig(config, "Views");
KConfigGroup viewConfig = KSharedConfig::openConfig()->group(QStringLiteral("Views"));
mAgendaViewTabIndex = viewConfig.readEntry("Agenda View Tab Index", 0);
}
parent = mAgendaViewTabs;
......@@ -494,7 +493,8 @@ void KOViewManager::showAgendaView()
connect(mAgendaView, SIGNAL(zoomViewHorizontally(QDate,int)),
mMainView->dateNavigator(), SLOT(selectDates(QDate,int)));
mAgendaView->readSettings(KOGlobals::self()->config());
auto config = KSharedConfig::openConfig();
mAgendaView->readSettings(config.data());
}
if (showBoth && mAgendaViewTabs->indexOf(mAgendaView) < 0) {
mAgendaViewTabs->addTab(mAgendaView, i18n("Merged calendar"));
......@@ -579,8 +579,8 @@ void KOViewManager::showTodoView()
addView(mTodoView);
connectTodoView(mTodoView);
KConfig *config = KOGlobals::self()->config();
mTodoView->restoreLayout(config, QStringLiteral("Todo View"), false);
KSharedConfig::Ptr config = KSharedConfig::openConfig();
mTodoView->restoreLayout(config.data(), QStringLiteral("Todo View"), false);
}
goMenu(false);
showView(mTodoView);
......@@ -663,7 +663,7 @@ QWidget *KOViewManager::widgetForView(KOrg::BaseView *view) const
void KOViewManager::currentAgendaViewTabChanged(QWidget *widget)
{
KConfig *config = KOGlobals::self()->config();
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup viewConfig(config, "Views");
viewConfig.writeEntry("Agenda View Tab Index", mAgendaViewTabs->currentIndex());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment