23#include <tdefiledialog.h>
26#include "vimagetool.h"
27#include <karbon_part.h>
28#include <karbon_view.h>
29#include <core/vimage.h>
30#include <core/vselection.h>
31#include <core/vcursor.h>
33VImageTool::VImageTool( KarbonView *view ) :
VTool( view,
"tool_image_plugin" )
39VImageTool::~VImageTool()
47 TQString s = i18n(
"<qt><b>Image tool:</b><br>" );
54 view()->setCursor( *m_cursor );
61 return i18n(
"Image Tool" );
72 TQString fname = KFileDialog::getOpenFileName( TQString(),
"*.jpg *.gif *.png",
view(), i18n(
"Choose Image to Add" ) );
73 if( !fname.isEmpty() )
75 VImage *image =
new VImage( 0L, fname );
76 VInsertImageCmd *cmd =
new VInsertImageCmd( &
view()->part()->document(), i18n(
"Insert Image" ), image,
first() );
82VImageTool::VInsertImageCmd::VInsertImageCmd(
VDocument* doc,
const TQString& name, VImage *image, KoPoint pos )
83 :
VCommand( doc, name,
"frame_image" ), m_image( image ), m_pos( pos )
98 m_image->transform( TQWMatrix().translate( m_pos.x(), m_pos.y() ) );
113 document()->selection()->take( *m_image );
120VImageTool::setup( TDEActionCollection *collection )
122 m_action =
static_cast<TDERadioAction *
>(collection ->
action( name() ) );
126 m_action =
new TDERadioAction( i18n(
"Image Tool" ),
"14_image", TQt::SHIFT+TQt::Key_H,
this, TQ_SLOT(
activate() ), collection, name() );
127 m_action->setToolTip( i18n(
"Image" ) );
128 m_action->setExclusiveGroup(
"misc" );
void addCommand(VCommand *cmd, bool repaint=false)
insert a command into the undo/redo-history:
The base class for all karbon commands.
virtual void unexecute()
Unexecutes the command.
VDocument * document() const
Returns the document the command works on.
virtual void execute()=0
Executes the command.
@ CrossHair
unthemed crosshair cursor
static TQCursor createCursor(CursorType type)
Creates a predefined cursor of the specified type.
All non-visual, static doc info is in here.
VSelection * selection() const
Returns a pointer to the selection.
void append(VObject *object)
Appends a new object to the active layer.
@ deleted
deleted, nearly dead
@ normal
visible, not active
void append()
Adds all objects to the selection.
void clear()
Removes the references to all objects, not the objects themselves.
void setSuccess(bool success=true)
Set the success property.