Allow to define where store video.
Ok'ed by Lubos svn path=/trunk/KDE/kdebase/workspace/; revision=770697
This commit is contained in:
parent
de19077399
commit
88bf12376d
5 changed files with 54 additions and 8 deletions
|
@ -21,7 +21,7 @@ macro(KWIN4_ADD_EFFECT_CONFIG name)
|
|||
endforeach(file)
|
||||
kde4_add_ui_files(kwin4_effect_src ${kwin4_effect_ui})
|
||||
kde4_add_plugin(kcm_kwin4_effect_${name} ${kwin4_effect_src})
|
||||
target_link_libraries(kcm_kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS})
|
||||
target_link_libraries(kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS})
|
||||
install(TARGETS kcm_kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
endmacro(KWIN4_ADD_EFFECT_CONFIG)
|
||||
|
||||
|
@ -205,7 +205,7 @@ macro_bool_to_01( CAPTURY_FOUND HAVE_CAPTURY )
|
|||
if( HAVE_CAPTURY )
|
||||
KWIN4_ADD_EFFECT(videorecord videorecord.cpp)
|
||||
KWIN4_ADD_EFFECT_CONFIG(videorecord videorecord_config.cpp)
|
||||
target_link_libraries(kwin4_effect_videorecord ${CAPTURY_LDFLAGS})
|
||||
target_link_libraries(kwin4_effect_videorecord ${KDE4_KIO_LIBS} ${CAPTURY_LDFLAGS})
|
||||
install( FILES videorecord.desktop videorecord_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
endif( HAVE_CAPTURY )
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/*
|
||||
|
||||
This effect allows recording a video from the session.
|
||||
|
||||
|
||||
Requires libcaptury:
|
||||
|
||||
|
||||
- svn co svn://77.74.232.49/captury/trunk/capseo
|
||||
- you may want to remove 1.10 from AUTOMAKE_OPTIONS in Makefile.am
|
||||
- ./autogen.sh
|
||||
|
@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
- you may want to remove 1.10 from AUTOMAKE_OPTIONS in Makefile.am
|
||||
- ./autogen.sh
|
||||
- the usual configure && make && make install procedure
|
||||
|
||||
|
||||
Video is saved to $HOME/kwin_video.cps, use
|
||||
"cpsrecode -i kwin_video.cps -o - | mplayer -" to play,
|
||||
use mencoder the same way to create a video.
|
||||
|
@ -49,6 +49,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <klocale.h>
|
||||
#include <qdir.h>
|
||||
#include <qfile.h>
|
||||
#include <kio/netaccess.h>
|
||||
#include <KConfigGroup>
|
||||
#include <KGlobalSettings>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -122,9 +125,13 @@ void VideoRecordEffect::startRecording()
|
|||
kDebug( 1212 ) << "Video recording init failed";
|
||||
return;
|
||||
}
|
||||
// TODO
|
||||
if( CapturySetOutputFileName( client, QFile::encodeName(QDir::homePath()+
|
||||
"/kwin_video.cps").constData() ) != CAPTURY_SUCCESS )
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
|
||||
QString videoPath =conf.readEntry( "videopath", KGlobalSettings::documentPath() );
|
||||
QString videoName(videoPath +"/kwin_video1.cps" );
|
||||
while(QFile::exists( videoName )) {
|
||||
autoincFilename( videoName );
|
||||
}
|
||||
if( CapturySetOutputFileName( client, QFile::encodeName( videoName ).constData() ) != CAPTURY_SUCCESS )
|
||||
{
|
||||
kDebug( 1212 ) << "Video recording file open failed";
|
||||
return;
|
||||
|
@ -133,6 +140,21 @@ void VideoRecordEffect::startRecording()
|
|||
kDebug( 1212 ) << "Video recording start";
|
||||
}
|
||||
|
||||
void VideoRecordEffect::autoincFilename(QString & name)
|
||||
{
|
||||
// If the name contains a number then increment it
|
||||
QRegExp numSearch( "(^|[^\\d])(\\d+)" ); // we want to match as far left as possible, and when the number is at the start of the name
|
||||
// Does it have a number?
|
||||
int start = numSearch.lastIndexIn( name );
|
||||
if (start != -1) {
|
||||
// It has a number, increment it
|
||||
start = numSearch.pos( 2 ); // we are only interested in the second group
|
||||
QString numAsStr = numSearch.capturedTexts()[ 2 ];
|
||||
QString number = QString::number( numAsStr.toInt() + 1 );
|
||||
number = number.rightJustified( numAsStr.length(), '0' );
|
||||
name.replace( start, number.length(), number );
|
||||
}
|
||||
}
|
||||
void VideoRecordEffect::stopRecording()
|
||||
{
|
||||
if( client == NULL )
|
||||
|
|
|
@ -42,6 +42,7 @@ class VideoRecordEffect
|
|||
private:
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
void autoincFilename(QString & url);
|
||||
captury_config_t config;
|
||||
captury_t* client;
|
||||
QRect area;
|
||||
|
|
|
@ -28,8 +28,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kaction.h>
|
||||
#include <KShortcutsEditor>
|
||||
#include <KGlobalAccel>
|
||||
#include <KUrlRequester>
|
||||
#include <QLabel>
|
||||
#include <KGlobalSettings>
|
||||
#include <KConfigGroup>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#ifndef KDE_USE_FINAL
|
||||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
#endif
|
||||
|
@ -48,6 +53,13 @@ VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariant
|
|||
kDebug() ;
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
QHBoxLayout* hlayout = new QHBoxLayout( this );
|
||||
QLabel *label = new QLabel( i18n( "Path to save video:" ), this );
|
||||
hlayout->addWidget( label );
|
||||
saveVideo = new KUrlRequester( this );
|
||||
saveVideo->setMode( KFile::Directory | KFile::LocalOnly );
|
||||
hlayout->addWidget( saveVideo );
|
||||
layout->addLayout( hlayout );
|
||||
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
|
||||
KAction* a = static_cast<KAction*>(actionCollection->addAction( "VideoRecord" ));
|
||||
a->setText( i18n("Toggle Video Recording" ));
|
||||
|
@ -73,6 +85,8 @@ void VideoRecordEffectConfig::load()
|
|||
kDebug() ;
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
|
||||
saveVideo->setPath( conf.readEntry( "videopath", KGlobalSettings::documentPath() ) );
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
|
@ -81,6 +95,12 @@ void VideoRecordEffectConfig::save()
|
|||
kDebug() ;
|
||||
KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
|
||||
|
||||
conf.writeEntry("videopath", saveVideo->url().path());
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "videorecord" );
|
||||
}
|
||||
|
@ -88,6 +108,7 @@ void VideoRecordEffectConfig::save()
|
|||
void VideoRecordEffectConfig::defaults()
|
||||
{
|
||||
kDebug() ;
|
||||
saveVideo->setPath(KGlobalSettings::documentPath() );
|
||||
mShortcutEditor->allDefault();
|
||||
emit changed(true);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#undef KDE3_SUPPORT
|
||||
|
||||
class KShortcutsEditor;
|
||||
class KUrlRequester;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -44,6 +45,7 @@ class VideoRecordEffectConfig : public KCModule
|
|||
|
||||
private:
|
||||
KShortcutsEditor* mShortcutEditor;
|
||||
KUrlRequester *saveVideo;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue