Commit d9c3504f authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Update resources when repository was added.

This fixes an issue where the user had to restart the application
when a new course repository (that is used for contributors working
on courses) was added to take effect.
parent 31a40feb
......@@ -55,6 +55,9 @@ ResourceManager::ResourceManager(QObject *parent)
void ResourceManager::loadCourseResources()
{
// reload config, could be changed in dialogs
Settings::self()->readConfig();
// register skeleton resources
QDir skeletonRepository = QDir(Settings::courseRepositoryPath());
skeletonRepository.setFilter(QDir::Files | QDir::Hidden);
......@@ -115,6 +118,10 @@ void ResourceManager::loadCourseResources()
QString directory = courseFile.directory().section('/', -1);
addCourse(courseFile);
}
//TODO this signal should only be emitted when repository was added/removed
// yet the call to this method is very seldom and emitting it too often is not that harmful
emit repositoryChanged();
}
void ResourceManager::loadLanguageResources()
......
......@@ -52,6 +52,7 @@ namespace LearnerProfile {
class ARTIKULATELIB_EXPORT ResourceManager : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isRepositoryManager READ isRepositoryManager NOTIFY repositoryChanged);
public:
explicit ResourceManager(QObject *parent = 0);
......@@ -78,7 +79,7 @@ public:
void registerLearningGoals(LearnerProfile::ProfileManager *profileManger);
/**
* returns true if a repository is used, else false
* \return \c true if a repository is used, else \c false
*/
Q_INVOKABLE bool isRepositoryManager() const;
......@@ -183,6 +184,7 @@ signals:
void languageResourceAboutToBeAdded(LanguageResource*,int);
void languageResourceRemoved();
void languageResourceAboutToBeRemoved(int);
void repositoryChanged();
void courseResourceAdded();
void courseResourceAboutToBeAdded(CourseResource*,int);
void courseResourceAboutToBeRemoved(int);
......
......@@ -289,7 +289,7 @@ Item
height: editor.height - breadcrumb.height - 80
spacing: 10
visible: globalResourceManager.isRepositoryManager()
visible: globalResourceManager.isRepositoryManager
EditorSelector {
id: editCourseSelector
......@@ -360,7 +360,7 @@ Item
bottomMargin: 10
}
spacing: 10
visible: !globalResourceManager.isRepositoryManager()
visible: !globalResourceManager.isRepositoryManager
Text {
text: i18n("No Course Repository Selected")
font.pointSize: 1.5 * theme.defaultFont.pointSize
......
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
* Copyright 2013-2014 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -35,12 +35,6 @@ ResourcesDialogPage::ResourcesDialogPage(ResourceManager *m_resourceManager)
{
ui = new Ui::ResourcesDialogPage;
ui->setupUi(this);
// activate path selector only if repository should be used
connect(ui->kcfg_UseCourseRepository, SIGNAL(toggled(bool)), this, SLOT(updateHints()));
connect(ui->kcfg_CourseRepositoryPath, SIGNAL(textChanged(QString)), this, SLOT(updateHints()));
updateHints();
}
ResourcesDialogPage::~ResourcesDialogPage()
......@@ -48,27 +42,11 @@ ResourcesDialogPage::~ResourcesDialogPage()
delete ui;
}
void ResourcesDialogPage::updateHints()
{
if (ui->kcfg_UseCourseRepository->isChecked() != Settings::useCourseRepository()
|| ui->kcfg_UseCourseRepository->text() != Settings::courseRepositoryPath() )
{
m_restartNeeded = true;
} else {
m_restartNeeded = false;
}
// TODO
// when doing this, a simple reload of the resource manager should be enough
// proper reload mechanism not implemented yet
// ui->restartInfo->setVisible(m_restartNeeded);//FIXME tell resource manager to reload
}
void ResourcesDialogPage::loadSettings()
{
// setup Ui with stored settings
ui->kcfg_CourseRepositoryPath->setText(Settings::courseRepositoryPath());
ui->kcfg_UseCourseRepository->setChecked(Settings::useCourseRepository());
// ui->restartInfo->setVisible(false); //FIXME tell resource manager
}
void ResourcesDialogPage::saveSettings()
......@@ -77,4 +55,7 @@ void ResourcesDialogPage::saveSettings()
Settings::setUseCourseRepository(ui->kcfg_UseCourseRepository->isChecked());
Settings::setCourseRepositoryPath(ui->kcfg_CourseRepositoryPath->text());
Settings::self()->writeConfig();
// reloading resources
m_resourceManager->loadCourseResources();
}
......@@ -39,7 +39,6 @@ public:
public slots:
void saveSettings();
void loadSettings();
void updateHints();
private:
Ui::ResourcesDialogPage *ui;
......
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