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

Remove obsolete dialog.

parent dc99bba9
......@@ -55,14 +55,9 @@ set(artikulateCore_SRCS
core/resources/skeletonresource.cpp
core/player.cpp
core/recorder.cpp
ui/newcoursedialog.cpp
artikulate_debug.cpp
)
# compile UI files
ki18n_wrap_ui(artikulateCore_SRCS
ui/newcoursedialog.ui
)
kconfig_add_kcfg_files (artikulateCore_SRCS settings.kcfgc)
add_library(artikulatecore SHARED ${artikulateCore_SRCS})
generate_export_header(artikulatecore BASE_NAME artikulatecore)
......@@ -73,7 +68,6 @@ target_link_libraries(artikulatecore
Qt5::XmlPatterns
KF5::Archive
KF5::ConfigGui
KF5::WidgetsAddons
)
# internal library without any API or ABI guarantee
set(GENERIC_LIB_VERSION "0")
......@@ -152,10 +146,10 @@ set(artikulate_editor_SRCS
ui/exportghnsdialog.cpp
)
ki18n_wrap_ui (artikulate_editor_SRCS
ui/resourcesdialogpage.ui
ui/sounddevicedialogpage.ui
ui/appearencedialogpage.ui
ui/exportghnsdialog.ui
ui/resourcesdialogpage.ui
ui/sounddevicedialogpage.ui
)
qt5_add_resources(artikulate_editor_SRCS qml/qml.qrc)
kconfig_add_kcfg_files (artikulate_editor_SRCS settings.kcfgc)
......
......@@ -29,7 +29,6 @@
#include "resources/languageresource.h"
#include "resources/courseresource.h"
#include "resources/skeletonresource.h"
#include <ui/newcoursedialog.h>
#include "settings.h"
#include "liblearnerprofile/src/profilemanager.h"
#include "liblearnerprofile/src/learninggoal.h"
......@@ -443,20 +442,6 @@ Course * ResourceManager::createCourse(Language *language, Skeleton *skeleton)
return course;
}
void ResourceManager::newCourseDialog(Language *language)
{
QPointer<NewCourseDialog> dialog = new NewCourseDialog(this);
if (language != nullptr) {
dialog->setLanguage(language);
}
if (dialog->exec() == QDialog::Accepted) {
CourseResource *tempCourse = dialog->courseResource();
tempCourse->setContributorResource(true);
addCourseResource(dialog->courseResource());
emit languageCoursesChanged();
}
}
void ResourceManager::addSkeleton(const QUrl &skeletonFile)
{
SkeletonResource *resource = new SkeletonResource(this, skeletonFile);
......
......@@ -197,8 +197,6 @@ public:
*/
QList<SkeletonResource *> skeletonResources();
Q_INVOKABLE void newCourseDialog(Language* language = nullptr);
Q_SIGNALS:
void languageResourceAdded();
void languageResourceAboutToBeAdded(LanguageResource*,int);
......
/*
* Copyright 2013 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
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "newcoursedialog.h"
#include "core/resourcemanager.h"
#include "core/language.h"
#include "core/skeleton.h"
#include "core/course.h"
#include "core/resources/languageresource.h"
#include "core/resources/courseresource.h"
#include "core/resources/skeletonresource.h"
#include "artikulate_debug.h"
#include "settings.h"
#include <KLocalizedString>
#include <KStandardGuiItem>
#include <QPushButton>
#include <QUuid>
#include <QDialogButtonBox>
NewCourseDialog::NewCourseDialog(ResourceManager *m_resourceManager)
: QDialog(0)
, m_fixedLanguage(0)
, m_resourceManager(m_resourceManager)
, m_createdCourse(0)
{
setWindowTitle(i18n("Create New Course"));
QWidget *widget = new QWidget(this);
ui = new Ui::NewCourseDialog;
ui->setupUi(widget);
QDialogButtonBox *buttons = new QDialogButtonBox(this);
QPushButton *okButton = new QPushButton;
KGuiItem::assign(okButton, KStandardGuiItem::ok());
okButton->setShortcut(Qt::Key_Return);
buttons->addButton(okButton, QDialogButtonBox::AcceptRole);
widget->layout()->addWidget(buttons);
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
QPushButton *cancelButton = new QPushButton;
KGuiItem::assign(cancelButton, KStandardGuiItem::cancel());
okButton->setShortcut(Qt::Key_Cancel);
buttons->addButton(cancelButton, QDialogButtonBox::RejectRole);
//FIXME only allow creation when data repository is set
//FIXME only allow creation when unique ID is given: check this and give feedback
// add languages
foreach (LanguageResource *resource, m_resourceManager->languageResources()) {
ui->language->addItem(resource->title(), resource->identifier());
}
// add skeletons
ui->skeletonSelector->addItem(i18n("none"), "");
foreach (SkeletonResource *resource, m_resourceManager->skeletonResources()) {
ui->skeletonSelector->addItem(resource->skeleton()->title(), resource->identifier());
}
ui->title->setText(i18n("New Course"));
connect(this, SIGNAL(okClicked()), this, SLOT(createCourse()));
}
NewCourseDialog::~NewCourseDialog()
{
delete ui;
}
void NewCourseDialog::setLanguage(Language *language)
{
ui->language->setVisible(false);
ui->labelLanguage->setVisible(false);
m_fixedLanguage = language;
}
void NewCourseDialog::createCourse()
{
// set language from dialog if not set yet
Language * language = m_fixedLanguage;
if (!language) {
QString selectedLanguage = ui->language->itemData(ui->language->currentIndex()).toString();
foreach (LanguageResource *resource, m_resourceManager->languageResources()) {
if (resource->identifier() == selectedLanguage) {
language = resource->language();
break;
}
}
if (!language) {
qCCritical(ARTIKULATE_LOG) << "Could not find any language resource.";
return;
}
}
// set path
QString path = QString("%1/%2/%3/%4/%4.xml")
.arg(Settings::courseRepositoryPath())
.arg("courses")
.arg(ui->identifier->text())
.arg(language->id());
m_createdCourse = new CourseResource(m_resourceManager, QUrl::fromLocalFile(path));
Q_ASSERT(m_createdCourse);
Course *course = m_createdCourse->course();
Q_ASSERT(course);
course->setId(QUuid::createUuid().toString());
course->setTitle(ui->title->text());
course->setDescription(ui->description->toHtml());
course->setFile(QUrl::fromLocalFile(path));
course->setLanguage(language);
// set skeleton
QString skeletonId = ui->skeletonSelector->itemData(ui->skeletonSelector->currentIndex()).toString();
course->setForeignId(skeletonId);
}
CourseResource * NewCourseDialog::courseResource() const
{
return m_createdCourse;
}
/*
* Copyright 2013 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
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NEWCOURSEDIALOG_H
#define NEWCOURSEDIALOG_H
#include "ui_newcoursedialog.h"
#include <QDialog>
class ResourceManager;
class CourseResource;
class Language;
class NewCourseDialog : public QDialog
{
Q_OBJECT
public:
explicit NewCourseDialog(ResourceManager *resourceMgr);
virtual ~NewCourseDialog();
void setLanguage(Language *language);
CourseResource * courseResource() const;
public slots:
void createCourse();
private:
Ui::NewCourseDialog *ui;
Language *m_fixedLanguage;
ResourceManager *m_resourceManager;
CourseResource *m_createdCourse;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewCourseDialog</class>
<widget class="QWidget" name="NewCourseDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="labelLanguage">
<property name="text">
<string>Language:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="language"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="title"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelTitle">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelDescription">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QTextEdit" name="description"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Use Skeleton</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="skeletonSelector"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelIdentifier">
<property name="text">
<string>Identifier</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="identifier"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</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