From 903cf1f1e596e3bcee9da7ed3c8a10c617027356 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 8 Oct 2010 13:34:58 +0200 Subject: [PATCH] Added EditResourceLocationDialog The EditResourceLocationDialog class provides a dialog for editing a certain ResourceLocation. --- include/EditResourceLocationDialog.h | 69 ++++++++++ .../Dialogs/EditResourceLocationDialog.cpp | 82 +++++++++++ src/gui/Forms/EditResourceLocationDialog.ui | 127 ++++++++++++++++++ 3 files changed, 278 insertions(+) create mode 100644 include/EditResourceLocationDialog.h create mode 100644 src/gui/Dialogs/EditResourceLocationDialog.cpp create mode 100644 src/gui/Forms/EditResourceLocationDialog.ui diff --git a/include/EditResourceLocationDialog.h b/include/EditResourceLocationDialog.h new file mode 100644 index 000000000..fffd61182 --- /dev/null +++ b/include/EditResourceLocationDialog.h @@ -0,0 +1,69 @@ +/* + * EditResourceLocationDialog.h - header file for EditResourceLocationDialog + * + * Copyright (c) 2010 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * 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) any later version. + * + * 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 (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef _EDIT_RESOURCE_LOCATION_DIALOG_H +#define _EDIT_RESOURCE_LOCATION_DIALOG_H + +#include + +#include "ResourceLocation.h" + +namespace Ui { class EditResourceLocationDialog; } + +/*! \brief The EditResourceLocationDialog class provides a dialog for editing + * a certain ResourceLocation. + */ + +class EditResourceLocationDialog : public QDialog +{ + Q_OBJECT +public: + /*! \brief Constructs an EditResourceLocationDialog. + * \param location A ResourceLocation object + */ + EditResourceLocationDialog( + const ResourceLocation & location = ResourceLocation() ); + + /*! \brief Destroys the EditResourceLocationDialog. */ + virtual ~EditResourceLocationDialog(); + + /*! \brief Returns a ResourceLocation object based on user input. */ + const ResourceLocation & location() const + { + return m_location; + } + + +private slots: + void updateAndCheckInput(); + + +private: + Ui::EditResourceLocationDialog * ui; + ResourceLocation m_location; + +} ; + + +#endif diff --git a/src/gui/Dialogs/EditResourceLocationDialog.cpp b/src/gui/Dialogs/EditResourceLocationDialog.cpp new file mode 100644 index 000000000..8dabb525e --- /dev/null +++ b/src/gui/Dialogs/EditResourceLocationDialog.cpp @@ -0,0 +1,82 @@ +/* + * EditResourceLocationDialog.cpp - implementation of EditResourceLocationDialog + * + * Copyright (c) 2010 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * 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) any later version. + * + * 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 (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include + +#include "EditResourceLocationDialog.h" +#include "MainWindow.h" +#include "engine.h" + +#include "ui_EditResourceLocationDialog.h" + + + +EditResourceLocationDialog::EditResourceLocationDialog( + const ResourceLocation & location ) : + QDialog( engine::mainWindow() ), + ui( new Ui::EditResourceLocationDialog ), + m_location( location ) +{ + ui->setupUi( this ); + + ui->nameEdit->setText( m_location.name() ); + ui->typeComboBox->setCurrentIndex( + m_location.type() != ResourceLocation::Unknown ? + m_location.type() : ResourceLocation::LocalDirectory ); + ui->addressEdit->setText( m_location.address() ); + + connect( ui->nameEdit, SIGNAL( textChanged( const QString & ) ), + this, SLOT( updateAndCheckInput() ) ); + connect( ui->typeComboBox, SIGNAL( currentIndexChanged( int ) ), + this, SLOT( updateAndCheckInput() ) ); + connect( ui->addressEdit, SIGNAL( textChanged( const QString & ) ), + this, SLOT( updateAndCheckInput() ) ); + + updateAndCheckInput(); +} + + + + +EditResourceLocationDialog::~EditResourceLocationDialog() +{ +} + + + +void EditResourceLocationDialog::updateAndCheckInput() +{ + m_location.setName( ui->nameEdit->text() ); + m_location.setType( static_cast( + ui->typeComboBox->currentIndex() ) ); + m_location.setAddress( ui->addressEdit->text() ); + + ui->buttonBox-> + button( QDialogButtonBox::Ok )->setEnabled( m_location.isValid() ); +} + + + +#include "moc_EditResourceLocationDialog.cxx" + diff --git a/src/gui/Forms/EditResourceLocationDialog.ui b/src/gui/Forms/EditResourceLocationDialog.ui new file mode 100644 index 000000000..93a91174e --- /dev/null +++ b/src/gui/Forms/EditResourceLocationDialog.ui @@ -0,0 +1,127 @@ + + + EditResourceLocationDialog + + + + 0 + 0 + 324 + 138 + + + + Edit resource location + + + + + + Name + + + + + + + + + + Type + + + + + + + 1 + + + + Unknown + + + + + Local directory + + + + + Web resource + + + + + + + + Address + + + + + + + + + + ... + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Horizontal + + + + + + + + + buttonBox + accepted() + EditResourceLocationDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EditResourceLocationDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +