Commit 3927d343 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr

Cleanup artifacts from QWidget integration

parent d6f2f86c
......@@ -16,16 +16,12 @@
#include "libsound/src/outputdevicecontroller.h"
#include "models/languagemodel.h"
#include "settings.h"
#include <KAboutData>
#include <KActionCollection>
#include <KConfigDialog>
#include <KHelpMenu>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <KNS3/DownloadDialog>
#include <KStandardAction>
#include <QAction>
#include <QIcon>
#include <QPointer>
......@@ -35,8 +31,7 @@
using namespace LearnerProfile;
MainWindow::MainWindow()
: m_actionCollection(new KActionCollection(this, QStringLiteral("artikulate")))
, m_profileManager(new LearnerProfile::ProfileManager(this))
: m_profileManager(new LearnerProfile::ProfileManager(this))
, m_trainingSession(new TrainingSession(m_profileManager, this))
{
rootContext()->setContextObject(new KLocalizedContext(this));
......@@ -44,9 +39,6 @@ MainWindow::MainWindow()
// load saved sound settings
OutputDeviceController::self().setVolume(Settings::audioOutputVolume());
// create menu
setupActions();
// set view
rootContext()->setContextProperty(QStringLiteral("g_trainingSession"), m_trainingSession);
rootContext()->setContextProperty(QStringLiteral("g_profileManager"), m_profileManager);
......@@ -62,13 +54,6 @@ MainWindow::MainWindow()
// connect to QML signals;
connect(rootObjects().constFirst(), SIGNAL(ghnsCourseDataStatusChanged()), this, SLOT(updateCourseResources()));
connect(rootObjects().constFirst(), SIGNAL(triggerAction(QString)), this, SLOT(triggerAction(QString)));
// set font for the phrase in trainer to default from kcfg file
QObject *phraseText = rootObjects().constFirst()->findChild<QObject *>(QStringLiteral("phraseText"));
if (phraseText) {
phraseText->setProperty("font", Settings::trainingPhraseFont());
}
}
MainWindow::~MainWindow()
......@@ -78,36 +63,11 @@ MainWindow::~MainWindow()
m_profileManager->sync();
}
KActionCollection *MainWindow::actionCollection()
{
return m_actionCollection;
}
void MainWindow::setupActions()
{
QAction *configLearnerProfileAction = new QAction(i18nc("@item:inmenu", "Learner Profile"), this);
connect(configLearnerProfileAction, &QAction::triggered, this, &MainWindow::configLearnerProfile);
actionCollection()->addAction(QStringLiteral("config_learner_profile"), configLearnerProfileAction);
configLearnerProfileAction->setIcon(QIcon::fromTheme(QStringLiteral("user-identity")));
KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
}
void MainWindow::updateCourseResources()
{
artikulateApp->resourceRepository()->reloadCourses();
}
void MainWindow::updateTrainingPhraseFont()
{
QObject *phraseText = rootObjects().constFirst()->findChild<QObject *>(QStringLiteral("phraseText"));
if (!phraseText) {
qCDebug(ARTIKULATE_LOG) << "no phraseText context object found, aborting";
return;
}
phraseText->setProperty("font", Settings::trainingPhraseFont());
}
void MainWindow::updateKcfgUseContributorResources()
{
rootContext()->setContextProperty(QStringLiteral("kcfg_UseContributorResources"), Settings::useCourseRepository());
......@@ -118,22 +78,6 @@ void MainWindow::configLearnerProfile()
qCritical() << "Not implemented"; // FIXME
}
void MainWindow::triggerAction(const QString &actionName)
{
QAction *action = actionCollection()->action(actionName);
if (action) {
action->trigger();
} else {
qCritical() << "Action is not registered:" << actionName;
}
}
void MainWindow::switchMenuBarVisibility()
{
Settings::setShowMenuBar(!Settings::showMenuBar());
rootContext()->setContextProperty(QStringLiteral("kcfg_ShowMenuBar"), Settings::showMenuBar());
}
bool MainWindow::queryClose()
{
Settings::self()->save();
......
......@@ -36,21 +36,15 @@ public:
const IResourceRepository *resourceRepository() const;
KActionCollection *actionCollection();
void setupActions();
bool queryClose();
public Q_SLOTS:
void updateCourseResources();
void updateTrainingPhraseFont();
void updateKcfgUseContributorResources();
void configLearnerProfile();
void switchMenuBarVisibility();
void triggerAction(const QString &);
private:
KActionCollection *m_actionCollection;
KHelpMenu *m_helpMenu;
LearnerProfile::ProfileManager *m_profileManager;
TrainingSession *m_trainingSession;
};
......
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