File indexing completed on 2024-05-19 16:07:55

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "VideoShapeConfigWidget.h"
0021 
0022 #include "VideoShape.h"
0023 #include "VideoDebug.h"
0024 
0025 #include <VideoData.h>
0026 #include <VideoCollection.h>
0027 #include <SelectVideoWidget.h>
0028 
0029 #include <QGridLayout>
0030 
0031 VideoShapeConfigWidget::VideoShapeConfigWidget()
0032     : KoShapeConfigWidgetBase()
0033     ,m_shape(0),
0034     m_fileSelectionWidget(0)
0035 {
0036 }
0037 
0038 VideoShapeConfigWidget::~VideoShapeConfigWidget()
0039 {
0040     delete m_fileSelectionWidget;
0041 }
0042 
0043 void VideoShapeConfigWidget::open(KoShape *shape)
0044 {
0045     m_shape = dynamic_cast<VideoShape*>(shape);
0046     Q_ASSERT(m_shape);
0047     if (!m_fileSelectionWidget) {
0048         QVBoxLayout *layout = new QVBoxLayout(this);
0049         m_fileSelectionWidget = new SelectVideoWidget(this);
0050         layout->addWidget(m_fileSelectionWidget);
0051         setLayout(layout);
0052     }
0053 }
0054 
0055 void VideoShapeConfigWidget::save()
0056 {
0057     if (!m_shape)
0058         return;
0059     m_fileSelectionWidget->accept();
0060     VideoData *data = m_shape->videoCollection()->createExternalVideoData(m_fileSelectionWidget->selectedUrl(),
0061                                                                           m_fileSelectionWidget->saveEmbedded());
0062     m_shape->setUserData(data);
0063 }
0064 
0065 bool VideoShapeConfigWidget::showOnShapeCreate()
0066 {
0067     return true;
0068 }
0069 
0070 bool VideoShapeConfigWidget::showOnShapeSelect()
0071 {
0072     return false;
0073 }