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

Remove obsolete widget based dialogs

parent 05fc0874
......@@ -102,10 +102,6 @@ set(artikulate_SRCS
main.cpp
mainwindow.cpp
artikulate_debug.cpp
ui/sounddevicedialogpage.cpp
)
ki18n_wrap_ui (artikulate_SRCS
ui/sounddevicedialogpage.ui
)
qt5_add_resources(artikulate_SRCS resources.qrc)
qt5_add_resources(artikulate_SRCS ../data/languages.qrc)
......@@ -115,12 +111,6 @@ set(artikulate_editor_SRCS
main_editor.cpp
mainwindow_editor.cpp
artikulate_debug.cpp
ui/sounddevicedialogpage.cpp
ui/exportghnsdialog.cpp
)
ki18n_wrap_ui(artikulate_editor_SRCS
ui/exportghnsdialog.ui
ui/sounddevicedialogpage.ui
)
qt5_add_resources(artikulate_editor_SRCS resources.qrc)
qt5_add_resources(artikulate_editor_SRCS ../data/languages.qrc)
......
......@@ -16,7 +16,6 @@
#include "libsound/src/outputdevicecontroller.h"
#include "models/languagemodel.h"
#include "settings.h"
#include "ui/sounddevicedialogpage.h"
#include <KAboutData>
#include <KActionCollection>
......@@ -86,11 +85,6 @@ KActionCollection *MainWindow::actionCollection()
void MainWindow::setupActions()
{
QAction *settingsAction = new QAction(i18nc("@item:inmenu", "Configure Artikulate"), this);
connect(settingsAction, &QAction::triggered, this, &MainWindow::showSettingsDialog);
actionCollection()->addAction(QStringLiteral("settings"), settingsAction);
settingsAction->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
QAction *configLearnerProfileAction = new QAction(i18nc("@item:inmenu", "Learner Profile"), this);
connect(configLearnerProfileAction, &QAction::triggered, this, &MainWindow::configLearnerProfile);
actionCollection()->addAction(QStringLiteral("config_learner_profile"), configLearnerProfileAction);
......@@ -99,28 +93,6 @@ void MainWindow::setupActions()
KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
}
void MainWindow::showSettingsDialog()
{
if (KConfigDialog::showDialog(QStringLiteral("settings"))) {
return;
}
QPointer<KConfigDialog> dialog = new KConfigDialog(nullptr, QStringLiteral("settings"), Settings::self());
SoundDeviceDialogPage *soundDialog = new SoundDeviceDialogPage();
soundDialog->loadSettings();
dialog->addPage(soundDialog, i18nc("@item:inmenu", "Sound Devices"), QStringLiteral("audio-headset"), i18nc("@title:tab", "Sound Device Settings"), true);
connect(dialog.data(), &QDialog::accepted, soundDialog, &SoundDeviceDialogPage::saveSettings);
connect(dialog.data(), &QDialog::accepted, this, &MainWindow::updateTrainingPhraseFont);
connect(dialog.data(), &QDialog::accepted, this, &MainWindow::updateKcfgUseContributorResources);
connect(dialog.data(), &QDialog::finished, soundDialog, &SoundDeviceDialogPage::stopPlaying);
connect(dialog.data(), &QDialog::finished, soundDialog, &SoundDeviceDialogPage::stopRecord);
dialog->exec();
}
void MainWindow::updateCourseResources()
{
artikulateApp->resourceRepository()->reloadCourses();
......
......@@ -41,7 +41,6 @@ public:
bool queryClose();
public Q_SLOTS:
void showSettingsDialog();
void updateCourseResources();
void updateTrainingPhraseFont();
void updateKcfgUseContributorResources();
......
......@@ -12,8 +12,6 @@
#include "libsound/src/outputdevicecontroller.h"
#include "models/languagemodel.h"
#include "settings.h"
#include "ui/exportghnsdialog.h"
#include "ui/sounddevicedialogpage.h"
#include <KAboutData>
#include <KActionCollection>
#include <KConfigDialog>
......@@ -88,24 +86,6 @@ void MainWindowEditor::setupActions()
// KStandardAction::quit(this, SLOT(quit()), actionCollection());
}
void MainWindowEditor::showSettingsDialog()
{
if (KConfigDialog::showDialog(QStringLiteral("settings"))) {
return;
}
QPointer<KConfigDialog> dialog = new KConfigDialog(nullptr, QStringLiteral("settings"), Settings::self());
SoundDeviceDialogPage *soundDialog = new SoundDeviceDialogPage();
soundDialog->loadSettings();
dialog->addPage(soundDialog, i18nc("@item:inmenu", "Sound Devices"), QStringLiteral("audio-headset"), i18nc("@title:tab", "Sound Device Settings"), true);
connect(dialog.data(), &QDialog::accepted, soundDialog, &SoundDeviceDialogPage::saveSettings);
dialog->exec();
}
void MainWindowEditor::save()
{
m_repository->sync();
......
......@@ -34,7 +34,6 @@ public:
void setupActions();
public Q_SLOTS:
void showSettingsDialog();
void save();
void quit();
......
/*
* Copyright 2013 Magdalena Konkiewicz <konkiewicz.m@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "appearencedialogpage.h"
#include "settings.h"
AppearenceDialogPage::AppearenceDialogPage()
: QWidget(nullptr)
{
ui = new Ui::AppearenceDialogPage;
ui->setupUi(this);
}
AppearenceDialogPage::~AppearenceDialogPage()
{
delete ui;
}
void AppearenceDialogPage::loadSettings()
{
ui->kcfg_TrainingPhraseFont->setFont(Settings::trainingPhraseFont());
}
void AppearenceDialogPage::saveSettings()
{
Settings::setTrainingPhraseFont(ui->kcfg_TrainingPhraseFont->font());
Settings::self()->save();
}
/*
* Copyright 2013 Magdalena Konkiewicz <konkiewicz.m@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef APPEARENCEDIALOGPAGE_H
#define APPEARENCEDIALOGPAGE_H
#include "ui_appearencedialogpage.h"
#include <QWidget>
class AppearenceDialogPage : public QWidget
{
Q_OBJECT
public:
AppearenceDialogPage();
~AppearenceDialogPage();
public slots:
void saveSettings();
void loadSettings();
private:
Ui::AppearenceDialogPage *ui;
};
#endif
<ui version="4.0" >
<class>AppearenceDialogPage</class>
<widget class="QWidget" name="AppearenceDialogPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>484</width>
<height>330</height>
</rect>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="KFontChooser" name="kcfg_TrainingPhraseFont" >
<property name="font" >
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*
* Copyright 2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "exportghnsdialog.h"
#include "artikulate_debug.h"
#include "core/icourse.h"
#include "core/iresourcerepository.h"
#include "core/language.h"
#include "core/resources/courseparser.h"
#include "core/resources/editablecourseresource.h"
#include <KLocalizedString>
#include <QFileDialog>
#include <QPushButton>
#include <QStandardPaths>
#include <QWidget>
ExportGhnsDialog::ExportGhnsDialog(IResourceRepository *repository)
{
ui = new Ui::ExportGhnsDialog;
ui->setupUi(this);
// require to set a proper directory
ui->buttonBox->button(QDialogButtonBox::Apply)->setDisabled(true);
ui->buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Export"));
connect(ui->exportDirectory, &QLineEdit::textChanged, this, [=]() {
const bool directorySet = !ui->exportDirectory->text().isEmpty();
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(directorySet);
});
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &ExportGhnsDialog::onExportCourse);
// directory selection dialog
connect(ui->selectDirectoryButton, &QToolButton::clicked, this, [=]() {
// TODO save last path in config file
const QString dir = QFileDialog::getExistingDirectory(this, i18n("Export Directory"), QString(), QFileDialog::ShowDirsOnly);
ui->exportDirectory->setText(dir);
});
// add courses to combo box
int counter = 0;
for (auto language : repository->languages()) {
for (auto course : repository->courses(language->id())) {
ui->courseListCombo->insertItem(counter, course->i18nTitle(), QVariant::fromValue<QObject *>(course.get()));
++counter;
}
}
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
}
ExportGhnsDialog::~ExportGhnsDialog()
{
delete ui;
}
void ExportGhnsDialog::onExportCourse()
{
IEditableCourse *res = qobject_cast<IEditableCourse *>(ui->courseListCombo->currentData().value<QObject *>());
qCDebug(ARTIKULATE_LOG) << res << "export GHNS file for" << res->i18nTitle();
CourseParser::exportCourseToGhnsPackage(res->self(), ui->exportDirectory->text());
}
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef EXPORTGHNSDIALOG_H
#define EXPORTGHNSDIALOG_H
#include "ui_exportghnsdialog.h"
#include <QDialog>
#include <QTemporaryFile>
class IResourceRepository;
class ExportGhnsDialog : public QDialog
{
Q_OBJECT
public:
explicit ExportGhnsDialog(IResourceRepository *repository);
~ExportGhnsDialog();
public Q_SLOTS:
void onExportCourse();
private:
Ui::ExportGhnsDialog *ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportGhnsDialog</class>
<widget class="QWidget" name="ExportGhnsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>150</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="exportDirectoryLabel">
<property name="text">
<string>Export Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="exportDirectory"/>
</item>
<item>
<widget class="QToolButton" name="selectDirectoryButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="document-open-folder">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="courseListCombo"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "sounddevicedialogpage.h"
#include "libsound/src/capturedevicecontroller.h"
#include "libsound/src/outputdevicecontroller.h"
#include "settings.h"
#include <KLocalizedString>
#include <QStandardPaths>
SoundDeviceDialogPage::SoundDeviceDialogPage()
: QWidget(nullptr)
{
ui = new Ui::SoundDeviceDialogPage;
ui->setupUi(this);
// set buttons
ui->buttonPlayTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
ui->buttonPlayRecordedTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
ui->buttonRecordTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-record")));
ui->buttonPlayRecordedTestSound->setEnabled(false);
// set input volume slider
// TODO Qt5.x port: reenable, since that we can set audioinput volume
// ui->kcfg_AudioInputVolume->setTickInterval(1);
// ui->kcfg_AudioInputVolume->setMinimum(1);
// ui->kcfg_AudioInputVolume->setMaximum(100);
// set output volume slider
ui->kcfg_AudioOutputVolume->setTickInterval(0);
ui->kcfg_AudioOutputVolume->setMinimum(0);
ui->kcfg_AudioOutputVolume->setMaximum(20);
// devices
QStringList devices = CaptureDeviceController::self().devices();
for (int i = 0; i < devices.length(); ++i) {
ui->kcfg_AudioInputDevice->insertItem(i, devices.at(i), i);
}
// TODO Gst::Device will allow selecting devices again with GStreamer 1.4
// temporary file for recording test
m_recordTestFile.open();
// connections
connect(ui->kcfg_AudioOutputVolume, &QAbstractSlider::valueChanged, this, &SoundDeviceDialogPage::setVolume);
connect(ui->buttonPlayTestSound, &QAbstractButton::clicked, this, &SoundDeviceDialogPage::playTestSound);
connect(ui->buttonPlayRecordedTestSound, &QAbstractButton::clicked, this, &SoundDeviceDialogPage::playRecordedSound);
connect(ui->buttonRecordTestSound, &QAbstractButton::clicked, this, &SoundDeviceDialogPage::recordSound);
connect(&OutputDeviceController::self(), &OutputDeviceController::started, this, &SoundDeviceDialogPage::updatePlayButtonIcons);
connect(&OutputDeviceController::self(), &OutputDeviceController::stopped, this, &SoundDeviceDialogPage::updatePlayButtonIcons);
}
SoundDeviceDialogPage::~SoundDeviceDialogPage()
{
CaptureDeviceController::self().stopCapture();
CaptureDeviceController::self().setDevice(Settings::audioInputDevice());
delete ui;
}
void SoundDeviceDialogPage::loadSettings()
{
ui->kcfg_AudioInputDevice->setCurrentIndex(ui->kcfg_AudioInputDevice->findText(Settings::audioInputDevice()));
// ui->kcfg_AudioInputVolume->setValue(Settings::audioInputVolume());
ui->kcfg_AudioOutputVolume->setValue(Settings::audioOutputVolume());
}
void SoundDeviceDialogPage::setVolume(int volume)
{
OutputDeviceController::self().setVolume(volume);
}
void SoundDeviceDialogPage::saveSettings()
{
Settings::setAudioInputDevice(ui->kcfg_AudioInputDevice->itemText(ui->kcfg_AudioInputDevice->currentIndex()));
// Settings::setAudioInputVolume(ui->kcfg_AudioInputVolume->value());
Settings::setAudioOutputVolume(static_cast<int>(ui->kcfg_AudioOutputVolume->value()));
OutputDeviceController::self().setVolume(ui->kcfg_AudioOutputVolume->value());
Settings::self()->save();
}
void SoundDeviceDialogPage::playTestSound()
{
if (OutputDeviceController::self().state() == OutputDeviceController::PlayingState) {
OutputDeviceController::self().stop();
return;
}
QString testsoundFile = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("sounds/testsound.ogg"));
OutputDeviceController::self().setVolume(ui->kcfg_AudioOutputVolume->value());
OutputDeviceController::self().play(QUrl::fromLocalFile(testsoundFile));
}
void SoundDeviceDialogPage::playRecordedSound()
{
if (OutputDeviceController::self().state() == OutputDeviceController::PlayingState) {
OutputDeviceController::self().stop();
return;
}
OutputDeviceController::self().setVolume(ui->kcfg_AudioOutputVolume->value());
OutputDeviceController::self().play(QUrl::fromLocalFile(m_recordTestFile.fileName()));
}
void SoundDeviceDialogPage::stopPlaying()
{
OutputDeviceController::self().stop();
}
void SoundDeviceDialogPage::recordSound()
{
if (CaptureDeviceController::self().state() == CaptureDeviceController::RecordingState) {
CaptureDeviceController::self().stopCapture();
ui->buttonRecordTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-record")));
ui->buttonPlayRecordedTestSound->setEnabled(true);
return;
}
ui->buttonRecordTestSound->setIcon(QIcon::fromTheme(QStringLiteral("artikulate-media-record-active")));
CaptureDeviceController::self().setDevice(ui->kcfg_AudioInputDevice->currentText());
CaptureDeviceController::self().startCapture(m_recordTestFile.fileName());
}
void SoundDeviceDialogPage::stopRecord()
{
if (CaptureDeviceController::self().state() == CaptureDeviceController::RecordingState) {
CaptureDeviceController::self().stopCapture();
ui->buttonRecordTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-record")));
ui->buttonPlayRecordedTestSound->setEnabled(true);
}
}
void SoundDeviceDialogPage::updatePlayButtonIcons()
{
// default sound output test
switch (OutputDeviceController::self().state()) {
case OutputDeviceController::PlayingState:
ui->buttonPlayTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-stop")));
break;
case OutputDeviceController::StoppedState:
ui->buttonPlayTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
break;
default:
ui->buttonPlayTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
}
// recorded sound output test
switch (OutputDeviceController::self().state()) {
case OutputDeviceController::PlayingState:
ui->buttonPlayRecordedTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-stop")));
break;
case OutputDeviceController::StoppedState:
ui->buttonPlayRecordedTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
break;
default:
ui->buttonPlayRecordedTestSound->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
}
}
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef SOUNDDEVICEDIALOGPAGE_H
#define SOUNDDEVICEDIALOGPAGE_H
#include "ui_sounddevicedialogpage.h"
#include <QTemporaryFile>
#include <QWidget>
class SoundDeviceDialogPage : public QWidget
{
Q_OBJECT
public:
SoundDeviceDialogPage();
~SoundDeviceDialogPage();
public slots:
void saveSettings();
void loadSettings();
void playTestSound();
void playRecordedSound();
void recordSound();
void updatePlayButtonIcons();
void stopPlaying();
void stopRecord();
void setVolume(int volume);
private:
Ui::SoundDeviceDialogPage *ui;
QList<QString> m_audioInputs;
QList<QString> m_audioOutputs;
QTemporaryFile m_recordTestFile;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SoundDeviceDialogPage</class>
<widget class="QWidget" name="SoundDeviceDialogPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>192</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Configure Microphone</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Input Device</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>