diff options
Diffstat (limited to 'src/app/ActionMan')
-rw-r--r-- | src/app/ActionMan/Makefile.am | 14 | ||||
-rw-r--r-- | src/app/ActionMan/actionman.cpp | 60 | ||||
-rw-r--r-- | src/app/ActionMan/actionman.h | 37 | ||||
-rw-r--r-- | src/app/ActionMan/actionproperty.cpp | 470 | ||||
-rw-r--r-- | src/app/ActionMan/actionproperty.h | 147 | ||||
-rw-r--r-- | src/app/ActionMan/actionpropertybase.cpp | 463 | ||||
-rw-r--r-- | src/app/ActionMan/actionpropertybase.ui | 1116 | ||||
-rw-r--r-- | src/app/ActionMan/addplaceholderpopup.cpp | 582 | ||||
-rw-r--r-- | src/app/ActionMan/addplaceholderpopup.h | 322 | ||||
-rw-r--r-- | src/app/ActionMan/useractionlistview.cpp | 232 | ||||
-rw-r--r-- | src/app/ActionMan/useractionlistview.h | 81 | ||||
-rw-r--r-- | src/app/ActionMan/useractionpage.cpp | 317 | ||||
-rw-r--r-- | src/app/ActionMan/useractionpage.h | 74 |
13 files changed, 3915 insertions, 0 deletions
diff --git a/src/app/ActionMan/Makefile.am b/src/app/ActionMan/Makefile.am new file mode 100644 index 0000000..e71563a --- /dev/null +++ b/src/app/ActionMan/Makefile.am @@ -0,0 +1,14 @@ +noinst_LIBRARIES = libActionMan.a + +INCLUDES = $(all_includes) + +libActionMan_a_METASOURCES = AUTO + +libActionMan_a_SOURCES = \ + actionman.cpp \ + actionpropertybase.ui \ + actionproperty.cpp \ + addplaceholderpopup.cpp \ + useractionlistview.cpp \ + useractionpage.cpp +noinst_HEADERS = useractionpage.h diff --git a/src/app/ActionMan/actionman.cpp b/src/app/ActionMan/actionman.cpp new file mode 100644 index 0000000..080ece3 --- /dev/null +++ b/src/app/ActionMan/actionman.cpp @@ -0,0 +1,60 @@ +// +// C++ Implementation: actionman +// +// Description: This manages all useractions +// +// +// Author: Jonas Bähr (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "actionman.h" + +#include <tdelocale.h> +#include <tdemessagebox.h> + +#include "useractionpage.h" +#include "../krusader.h" +#include "../UserAction/useraction.h" + + +ActionMan::ActionMan( TQWidget * parent ) + : KDialogBase( parent, "ActionMan", true /*modal*/, "ActionMan - Manage your useractions", KDialogBase::Apply | KDialogBase::Close ) +{ + setPlainCaption(i18n("ActionMan - Manage Your Useractions")); + + userActionPage = new UserActionPage( this ); + setMainWidget( userActionPage ); + + connect( userActionPage, TQ_SIGNAL( changed() ), TQ_SLOT( slotEnableApplyButton() ) ); + connect( userActionPage, TQ_SIGNAL( applied() ), TQ_SLOT( slotDisableApplyButton() ) ); + enableButtonApply( false ); + + exec(); +} + +ActionMan::~ActionMan() { +} + +void ActionMan::slotClose() { + if ( userActionPage->readyToQuit() ) + reject(); +} + +void ActionMan::slotApply() { + userActionPage->applyChanges(); +} + +void ActionMan::slotEnableApplyButton() { + enableButtonApply( true ); +} + +void ActionMan::slotDisableApplyButton() { + enableButtonApply( false ); +} + + + +#include "actionman.moc" diff --git a/src/app/ActionMan/actionman.h b/src/app/ActionMan/actionman.h new file mode 100644 index 0000000..29ab30b --- /dev/null +++ b/src/app/ActionMan/actionman.h @@ -0,0 +1,37 @@ +// +// C++ Interface: actionman +// +// Description: This manages all useractions +// +// +// Author: Jonas B�r (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef ACTIONMAN_H +#define ACTIONMAN_H + +#include <kdialogbase.h> + +class UserActionPage; + +class ActionMan : public KDialogBase { +TQ_OBJECT + +public: + ActionMan( TQWidget* parent=0 ); + ~ActionMan(); + +protected slots: + void slotClose(); + void slotApply(); + void slotEnableApplyButton(); + void slotDisableApplyButton(); + +private: + UserActionPage* userActionPage; +}; + +#endif // ifndef ACTIONMAN_H diff --git a/src/app/ActionMan/actionproperty.cpp b/src/app/ActionMan/actionproperty.cpp new file mode 100644 index 0000000..361f0a9 --- /dev/null +++ b/src/app/ActionMan/actionproperty.cpp @@ -0,0 +1,470 @@ +// +// C++ Implementation: actionproperty +// +// Description: +// +// +// Author: Jonas B�r (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "actionproperty.h" +#include "addplaceholderpopup.h" + +#include "../UserAction/useraction.h" +#include "../UserAction/kraction.h" +#include "../krusader.h" + +#include <tqtoolbutton.h> +#include <tqcheckbox.h> +#include <tqradiobutton.h> +#include <tqbuttongroup.h> +#include <tdelocale.h> +#include <tdefiledialog.h> +#include <klineedit.h> +#include <kdebug.h> +#include <tdemessagebox.h> +#include <kinputdialog.h> +#include <kkeybutton.h> +#include <kcombobox.h> +#include <kicondialog.h> +#include <ktextedit.h> +#include <kiconloader.h> + +#define ICON(N) TDEGlobal::iconLoader()->loadIcon(N, TDEIcon::Small) + +ActionProperty::ActionProperty( TQWidget *parent, const char *name, KrAction *action ) + : ActionPropertyBase( parent, name ), _modified(false) + { + if ( action ) { + _action = action; + updateGUI( _action ); + } + + ButtonAddPlaceholder->setPixmap( ICON("add") ); + ButtonAddStartpath->setPixmap( ICON("document-open") ); + + // fill with all existing categories + cbCategory->insertStringList( krUserAction->allCategories() ); + + connect( ButtonAddPlaceholder, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addPlaceholder() ) ); + connect( ButtonAddStartpath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addStartpath() ) ); + connect( ButtonNewProtocol, TQ_SIGNAL( clicked() ), this, TQ_SLOT( newProtocol() ) ); + connect( ButtonEditProtocol, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editProtocol() ) ); + connect( ButtonRemoveProtocol, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removeProtocol() ) ); + connect( ButtonAddPath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addPath() ) ); + connect( ButtonEditPath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editPath() ) ); + connect( ButtonRemovePath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removePath() ) ); + connect( ButtonAddMime, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addMime() ) ); + connect( ButtonEditMime, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editMime() ) ); + connect( ButtonRemoveMime, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removeMime() ) ); + connect( ButtonNewFile, TQ_SIGNAL( clicked() ), this, TQ_SLOT( newFile() ) ); + connect( ButtonEditFile, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editFile() ) ); + connect( ButtonRemoveFile, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removeFile() ) ); + connect( KeyButtonShortcut, TQ_SIGNAL( capturedShortcut(const TDEShortcut&) ), this, TQ_SLOT( changedShortcut(const TDEShortcut&) ) ); + // track modifications: + connect( leDistinctName, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leTitle, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( ButtonIcon, TQ_SIGNAL( iconChanged(TQString) ), TQ_SLOT( setModified() ) ); + connect( cbCategory, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leTooltip, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( textDescription, TQ_SIGNAL( textChanged() ), TQ_SLOT( setModified() ) ); + connect( leDistinctName, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leCommandline, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leStartpath, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( bgExecType, TQ_SIGNAL( clicked(int) ), TQ_SLOT( setModified() ) ); + connect( bgAccept, TQ_SIGNAL( clicked(int) ), TQ_SLOT( setModified() ) ); + connect( KeyButtonShortcut, TQ_SIGNAL( capturedShortcut(const TDEShortcut&) ), TQ_SLOT( setModified() ) ); + connect( leDifferentUser, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( chkDifferentUser, TQ_SIGNAL( clicked() ), TQ_SLOT( setModified() ) ); + connect( chkConfirmExecution, TQ_SIGNAL( clicked() ), TQ_SLOT( setModified() ) ); + // The modified-state of the ShowOnly-lists is tracked in the access-functions below +} + +ActionProperty::~ActionProperty() { +} + +void ActionProperty::changedShortcut( const TDEShortcut& shortcut ) { + KeyButtonShortcut->setShortcut( shortcut, false ); +} + + +void ActionProperty::clear() { + _action = 0; + + // This prevents the changed-signal from being emited during the GUI-update + _modified = true; // The real state is set at the end of this function. + + leDistinctName->clear(); + cbCategory->clearEdit(); + leTitle->clear(); + leTooltip->clear(); + textDescription->clear(); + leCommandline->clear(); + leStartpath->clear(); + KeyButtonShortcut->setShortcut( TDEShortcut(), false ); + + lbShowonlyProtocol->clear(); + lbShowonlyPath->clear(); + lbShowonlyMime->clear(); + lbShowonlyFile->clear(); + + chkSeparateStdError->setChecked( false ); + radioNormal->setChecked( true ); + + radioLocal->setChecked( true ); + + chkConfirmExecution->setChecked( false ); + + ButtonIcon->resetIcon(); + + leDifferentUser->clear(); + chkDifferentUser->setChecked( false ); + + setModified( false ); +} + +void ActionProperty::updateGUI( KrAction *action ) { + if ( action ) + _action = action; + if ( ! _action ) + return; + + // This prevents the changed-signal from being emited during the GUI-update. + _modified = true; // The real state is set at the end of this function. + + leDistinctName->setText( _action->name() ); + cbCategory->setCurrentText( _action->category() ); + leTitle->setText( _action->text() ); + leTooltip->setText( _action->toolTip() ); + textDescription->setText( _action->whatsThis() ); + leCommandline->setText( _action->command() ); + leCommandline->home(false); + leStartpath->setText( _action->startpath() ); + KeyButtonShortcut->setShortcut( _action->shortcut(), false ); + + lbShowonlyProtocol->clear(); + lbShowonlyProtocol->insertStringList( _action->showonlyProtocol() ); + lbShowonlyPath->clear(); + lbShowonlyPath->insertStringList( _action->showonlyPath() ); + lbShowonlyMime->clear(); + lbShowonlyMime->insertStringList( _action->showonlyMime() ); + lbShowonlyFile->clear(); + lbShowonlyFile->insertStringList( _action->showonlyFile() ); + + chkSeparateStdError->setChecked( false ); + switch ( _action->execType() ) { + case KrAction::CollectOutputSeparateStderr: + chkSeparateStdError->setChecked( true ); + radioCollectOutput->setChecked( true ); + break; + case KrAction::CollectOutput: + radioCollectOutput->setChecked( true ); + break; + case KrAction::Terminal: + radioTerminal->setChecked( true ); + break; + default: // case KrAction::Normal: + radioNormal->setChecked( true ); + break; + } + + if ( _action->acceptURLs() ) + radioUrl->setChecked( true ); + else + radioLocal->setChecked( true ); + + chkConfirmExecution->setChecked( _action->confirmExecution() ); + + if ( ! _action->icon().isEmpty() ) + ButtonIcon->setIcon( _action->icon() ); + else + ButtonIcon->resetIcon(); + + leDifferentUser->setText( _action->user() ); + if ( _action->user().isEmpty() ) + chkDifferentUser->setChecked( false ); + else + chkDifferentUser->setChecked( true ); + + setModified( false ); +} + +void ActionProperty::updateAction( KrAction *action ) { + if ( action ) + _action = action; + if ( ! _action ) + return; + + if ( _action->category() != cbCategory->currentText() ) { + _action->setCategory( cbCategory->currentText() ); + // Update the category-list + cbCategory->clear(); + cbCategory->insertStringList( krUserAction->allCategories() ); + cbCategory->setCurrentText( _action->category() ); + } + + _action->setName( leDistinctName->text().latin1() ); + _action->setText( leTitle->text() ); + _action->setToolTip( leTooltip->text() ); + _action->setWhatsThis( textDescription->text() ); + _action->setCommand( leCommandline->text() ); + _action->setStartpath( leStartpath->text() ); + _action->setShortcut( KeyButtonShortcut->shortcut() ); + + TQListBoxItem* lbi = lbShowonlyProtocol->firstItem(); + TQStringList list; + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyProtocol( list ); + + lbi = lbShowonlyPath->firstItem(); + list = TQStringList(); + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyPath( list ); + + lbi = lbShowonlyMime->firstItem(); + list = TQStringList(); + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyMime( list ); + + lbi = lbShowonlyFile->firstItem(); + list = TQStringList(); + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyFile( list ); + + if ( radioCollectOutput->isChecked() && chkSeparateStdError->isChecked() ) + _action->setExecType( KrAction::CollectOutputSeparateStderr ); + else if ( radioCollectOutput->isChecked() && ! chkSeparateStdError->isChecked() ) + _action->setExecType( KrAction::CollectOutput ); + else if ( radioTerminal->isChecked() ) + _action->setExecType( KrAction::Terminal ); + else + _action->setExecType( KrAction::Normal ); + + if ( radioUrl->isChecked() ) + _action->setAcceptURLs( true ); + else + _action->setAcceptURLs( false ); + + _action->setConfirmExecution( chkConfirmExecution->isChecked() ); + + _action->setIcon( ButtonIcon->icon() ); + + _action->setUser( leDifferentUser->text() ); + + setModified( false ); +} + +void ActionProperty::addPlaceholder() { + AddPlaceholderPopup popup( this ); + TQString exp = popup.getPlaceholder( mapToGlobal( + TQPoint( + ButtonAddPlaceholder->pos().x() + ButtonAddPlaceholder->width()+6, // 6 is the default margin + ButtonAddPlaceholder->pos().y() + ) + ) ); + leCommandline->insert( exp ); +} + + +void ActionProperty::addStartpath() { + TQString folder = KFileDialog::getExistingDirectory(TQString(), this); + if (folder != TQString()) { + leStartpath->setText( folder ); + } +} + + +void ActionProperty::newProtocol() { + bool ok; + TQString text = KInputDialog::getText( + i18n( "New protocol" ), + i18n( "Set a protocol:" ), + lbShowonlyProtocol->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyProtocol->insertStringList( TQStringList::split( ";", text ) ); + setModified(); + } +} + +void ActionProperty::editProtocol() { + if (lbShowonlyProtocol->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit protocol" ), + i18n( "Set another protocol:" ), + lbShowonlyProtocol->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyProtocol->changeItem( text, lbShowonlyProtocol->currentItem() ); + setModified(); + } +} + +void ActionProperty::removeProtocol() { + if (lbShowonlyProtocol->currentItem() != -1) { + lbShowonlyProtocol->removeItem( lbShowonlyProtocol->currentItem() ); + setModified(); + } +} + +void ActionProperty::addPath() { + TQString folder = KFileDialog::getExistingDirectory(TQString(), this); + if (folder != TQString()) { + lbShowonlyPath->insertItem( folder ); + setModified(); + } +} + +void ActionProperty::editPath() { + if (lbShowonlyPath->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit path" ), + i18n( "Set another path:" ), + lbShowonlyPath->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyPath->changeItem( text, lbShowonlyPath->currentItem() ); + setModified(); + } +} + +void ActionProperty::removePath() { + if (lbShowonlyPath->currentItem() != -1) { + lbShowonlyPath->removeItem( lbShowonlyPath->currentItem() ); + setModified(); + } +} + +void ActionProperty::addMime() { + bool ok; + TQString text = KInputDialog::getText( + i18n( "New mime-type" ), + i18n( "Set a mime-type:" ), + lbShowonlyMime->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyMime->insertStringList( TQStringList::split( ";", text ) ); + setModified(); + } +} + +void ActionProperty::editMime() { + if (lbShowonlyMime->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit mime-type" ), + i18n( "Set another mime-type:" ), + lbShowonlyMime->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyMime->changeItem( text, lbShowonlyMime->currentItem() ); + setModified(); + } +} + +void ActionProperty::removeMime() { + if (lbShowonlyMime->currentItem() != -1) { + lbShowonlyMime->removeItem( lbShowonlyMime->currentItem() ); + setModified(); + } +} + +void ActionProperty::newFile() { + bool ok; + TQString text = KInputDialog::getText( + i18n( "New filename" ), + i18n( "Set a filename:" ), + lbShowonlyFile->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyFile->insertStringList( TQStringList::split( ";", text ) ); + setModified(); + } +} + +void ActionProperty::editFile() { + if (lbShowonlyFile->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit filename" ), + i18n( "Set another filename:" ), + lbShowonlyFile->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyFile->changeItem( text, lbShowonlyFile->currentItem() ); + setModified(); + } +} + +void ActionProperty::removeFile() { + if (lbShowonlyFile->currentItem() != -1) { + lbShowonlyFile->removeItem( lbShowonlyFile->currentItem() ); + setModified(); + } +} + + +bool ActionProperty::validProperties() { + if ( leDistinctName->text().simplifyWhiteSpace().isEmpty() ) { + KMessageBox::error( this, i18n("Please set a unique name for the useraction") ); + leDistinctName->setFocus(); + return false; + } + if ( leTitle->text().simplifyWhiteSpace().isEmpty() ) { + KMessageBox::error( this, i18n("Please set a title for the menu entry") ); + leTitle->setFocus(); + return false; + } + if ( leCommandline->text().simplifyWhiteSpace().isEmpty() ) { + KMessageBox::error( this, i18n("Command line is empty") ); + leCommandline->setFocus(); + return false; + } + if ( leDistinctName->isEnabled() ) + if ( krApp->actionCollection()->action( leDistinctName->text().latin1() ) ) { + KMessageBox::error( this, + i18n("There already is an action with this name\n" + "If you don't have such an useraction the name is used by Krusader for an internal action") + ); + leDistinctName->setFocus(); + return false; + } + + return true; +} + +void ActionProperty::setModified( bool m ) +{ + if ( m && !_modified ) { // emit only when the state _changes_to_true_, + emit changed(); + } + _modified = m; +} + + +#include "actionproperty.moc" diff --git a/src/app/ActionMan/actionproperty.h b/src/app/ActionMan/actionproperty.h new file mode 100644 index 0000000..dfdc5a1 --- /dev/null +++ b/src/app/ActionMan/actionproperty.h @@ -0,0 +1,147 @@ +// +// C++ Interface: actionproperty +// +// Description: +// +// +// Author: Jonas Bähr (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef ACTIONPROPERTY_H +#define ACTIONPROPERTY_H + +#include "actionpropertybase.h" + +class KrAction; +class TDEShortcut; + +/** + * Use this widget where ever you need to manipulate a UserAction + * @author Jonas Bähr (http://www.jonas-baehr.de) + */ +class ActionProperty : public ActionPropertyBase { + TQ_OBJECT + +public: + ActionProperty( TQWidget *parent=0, const char *name=0, KrAction *action=0 ); + ~ActionProperty(); + + /** + * @return the currently displayed action + */ + KrAction* action() { return _action; }; + + /** + * This inits the widget with the actions properties. + * If no action is provided, the last used will be taken! + * It also resets the changed() state. + * @param action the action which should be displayd + */ + void updateGUI( KrAction *action = 0 ); + + /** + * This writes the displayed properties back into the action. + * If no action is provided, the last used will be taken! + * It also resets the changed() state. + * @param action the action which should be manipulated + */ + void updateAction( KrAction *action = 0 ); + + /** + * clears everything + */ + void clear(); + + /** + * @return true if all properties got valid values + */ + bool validProperties(); + + /** + * @return true if any property got changed + */ + bool isModified() { return _modified; }; + +signals: + /** + * emited when any actionproperty changed. This signal is only emited when + * the _modified attribute changes to true. If there are changes made and + * _modified is already true, no signal is emited! + */ + void changed(); + +protected slots: + void setModified( bool m = true ); + /** + * executes the AddPlaceholderPopup + */ + void addPlaceholder(); + /** + * asks for an existing path + */ + void addStartpath(); + /** + * (availability) asks for a new protocol + */ + void newProtocol(); + /** + * (availability) changes a protocol of the list + */ + void editProtocol(); + /** + * (availability) removes a protocol from the list + */ + void removeProtocol(); + /** + * (availability) asks for a new path + */ + void addPath(); + /** + * (availability) edits a path of the list + */ + void editPath(); + /** + * (availability) removes a path from the list + */ + void removePath(); + /** + * (availability) asks for a new mime-type + */ + void addMime(); + /** + * (availability) changes a mime-type of the list + */ + void editMime(); + /** + * (availability) removes a mime-type from the list + */ + void removeMime(); + /** + * (availability) asks for a new file-filter + */ + void newFile(); + /** + * (availability) edits a file-filter of the list + */ + void editFile(); + /** + * (availability) removes a file-filter from the lsit + */ + void removeFile(); + +private: + KrAction *_action; + bool _modified; + +private slots: + /** + * This updates the ShortcutButton + * @internal + */ + void changedShortcut(const TDEShortcut& shortcut); +}; + +#endif diff --git a/src/app/ActionMan/actionpropertybase.cpp b/src/app/ActionMan/actionpropertybase.cpp new file mode 100644 index 0000000..7facfa5 --- /dev/null +++ b/src/app/ActionMan/actionpropertybase.cpp @@ -0,0 +1,463 @@ +#include <kdialog.h> +#include <tdelocale.h> +/**************************************************************************** +** Form implementation generated from reading ui file './actionpropertybase.ui' +** +** Created: Sat Mar 15 11:41:43 2008 +** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.8 edited Jan 11 14:47 $) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#include "actionpropertybase.h" + +#include <tqvariant.h> +#include <tqpushbutton.h> +#include <tqtabwidget.h> +#include <tqtoolbutton.h> +#include <tqlabel.h> +#include <tqbuttongroup.h> +#include <tqradiobutton.h> +#include <klineedit.h> +#include <kcombobox.h> +#include <kicondialog.h> +#include <ktextedit.h> +#include <kkeybutton.h> +#include <tqcheckbox.h> +#include <tqgroupbox.h> +#include <tdelistbox.h> +#include <tqlayout.h> +#include <tqtooltip.h> +#include <tqwhatsthis.h> +#include "klineedit.h" +#include "kcombobox.h" +#include "kicondialog.h" +#include "ktextedit.h" +#include "kkeybutton.h" +#include "tdelistbox.h" + +/* + * Constructs a ActionPropertyBase as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +ActionPropertyBase::ActionPropertyBase( TQWidget* parent, const char* name, WFlags fl ) + : TQWidget( parent, name, fl ) +{ + if ( !name ) + setName( "ActionPropertyBase" ); + ActionPropertyBaseLayout = new TQGridLayout( this, 1, 1, 0, 0, "ActionPropertyBaseLayout"); + + tabWidget3 = new TQTabWidget( this, "tabWidget3" ); + + tab = new TQWidget( tabWidget3, "tab" ); + tabLayout = new TQGridLayout( tab, 1, 1, 11, 6, "tabLayout"); + + ButtonAddStartpath = new TQToolButton( tab, "ButtonAddStartpath" ); + + tabLayout->addWidget( ButtonAddStartpath, 8, 3 ); + + LabelDescription = new TQLabel( tab, "LabelDescription" ); + LabelDescription->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)1, 0, 0, LabelDescription->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelDescription, 4, 0 ); + + bgAccept = new TQButtonGroup( tab, "bgAccept" ); + bgAccept->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)1, 0, 0, bgAccept->sizePolicy().hasHeightForWidth() ) ); + bgAccept->setColumnLayout(0, TQt::Vertical ); + bgAccept->layout()->setSpacing( 6 ); + bgAccept->layout()->setMargin( 11 ); + bgAcceptLayout = new TQGridLayout( bgAccept->layout() ); + bgAcceptLayout->setAlignment( TQt::AlignTop ); + + radioLocal = new TQRadioButton( bgAccept, "radioLocal" ); + radioLocal->setChecked( true ); + + bgAcceptLayout->addWidget( radioLocal, 0, 0 ); + + radioUrl = new TQRadioButton( bgAccept, "radioUrl" ); + + bgAcceptLayout->addWidget( radioUrl, 1, 0 ); + + tabLayout->addMultiCellWidget( bgAccept, 9, 9, 2, 3 ); + + leTitle = new KLineEdit( tab, "leTitle" ); + + tabLayout->addMultiCellWidget( leTitle, 2, 2, 1, 3 ); + + LabelTitle = new TQLabel( tab, "LabelTitle" ); + LabelTitle->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelTitle->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelTitle, 2, 0 ); + + layout3 = new TQHBoxLayout( 0, 0, 6, "layout3"); + + layout2 = new TQVBoxLayout( 0, 0, 6, "layout2"); + + leDistinctName = new KLineEdit( tab, "leDistinctName" ); + layout2->addWidget( leDistinctName ); + + cbCategory = new KComboBox( false, tab, "cbCategory" ); + cbCategory->setEditable( true ); + layout2->addWidget( cbCategory ); + layout3->addLayout( layout2 ); + + ButtonIcon = new TDEIconButton( tab, "ButtonIcon" ); + ButtonIcon->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, ButtonIcon->sizePolicy().hasHeightForWidth() ) ); + ButtonIcon->setMinimumSize( TQSize( 50, 50 ) ); + ButtonIcon->setMaximumSize( TQSize( 50, 50 ) ); + layout3->addWidget( ButtonIcon ); + + tabLayout->addMultiCellLayout( layout3, 0, 1, 1, 3 ); + + LabelDistinctName = new TQLabel( tab, "LabelDistinctName" ); + LabelDistinctName->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelDistinctName->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelDistinctName, 0, 0 ); + + LabelCommandline = new TQLabel( tab, "LabelCommandline" ); + LabelCommandline->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, LabelCommandline->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelCommandline, 7, 0 ); + + leTooltip = new KLineEdit( tab, "leTooltip" ); + + tabLayout->addMultiCellWidget( leTooltip, 3, 3, 1, 3 ); + + leStartpath = new KLineEdit( tab, "leStartpath" ); + + tabLayout->addMultiCellWidget( leStartpath, 8, 8, 1, 2 ); + + LabelTooltip = new TQLabel( tab, "LabelTooltip" ); + LabelTooltip->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelTooltip->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelTooltip, 3, 0 ); + + leCommandline = new KLineEdit( tab, "leCommandline" ); + + tabLayout->addMultiCellWidget( leCommandline, 7, 7, 1, 2 ); + + LabelCategory = new TQLabel( tab, "LabelCategory" ); + LabelCategory->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelCategory->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelCategory, 1, 0 ); + + ButtonAddPlaceholder = new TQToolButton( tab, "ButtonAddPlaceholder" ); + ButtonAddPlaceholder->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, ButtonAddPlaceholder->sizePolicy().hasHeightForWidth() ) ); + ButtonAddPlaceholder->setMinimumSize( TQSize( 0, 0 ) ); + + tabLayout->addWidget( ButtonAddPlaceholder, 7, 3 ); + + textDescription = new KTextEdit( tab, "textDescription" ); + textDescription->setWordWrap( KTextEdit::WidgetWidth ); + + tabLayout->addMultiCellWidget( textDescription, 4, 6, 1, 3 ); + + LabelStartpath = new TQLabel( tab, "LabelStartpath" ); + LabelStartpath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, LabelStartpath->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelStartpath, 8, 0 ); + spacer = new TQSpacerItem( 80, 19, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout->addItem( spacer, 6, 0 ); + + layout4 = new TQHBoxLayout( 0, 0, 6, "layout4"); + + LabelShortcut = new TQLabel( tab, "LabelShortcut" ); + layout4->addWidget( LabelShortcut ); + spacer6_2 = new TQSpacerItem( 161, 21, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); + layout4->addItem( spacer6_2 ); + + KeyButtonShortcut = new KKeyButton( tab, "KeyButtonShortcut" ); + layout4->addWidget( KeyButtonShortcut ); + + tabLayout->addMultiCellLayout( layout4, 10, 10, 2, 3 ); + + bgExecType = new TQButtonGroup( tab, "bgExecType" ); + bgExecType->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)1, 0, 0, bgExecType->sizePolicy().hasHeightForWidth() ) ); + bgExecType->setColumnLayout(0, TQt::Vertical ); + bgExecType->layout()->setSpacing( 6 ); + bgExecType->layout()->setMargin( 11 ); + bgExecTypeLayout = new TQGridLayout( bgExecType->layout() ); + bgExecTypeLayout->setAlignment( TQt::AlignTop ); + + radioCollectOutput = new TQRadioButton( bgExecType, "radioCollectOutput" ); + + bgExecTypeLayout->addWidget( radioCollectOutput, 2, 0 ); + + chkSeparateStdError = new TQCheckBox( bgExecType, "chkSeparateStdError" ); + chkSeparateStdError->setEnabled( false ); + + bgExecTypeLayout->addWidget( chkSeparateStdError, 3, 0 ); + + radioNormal = new TQRadioButton( bgExecType, "radioNormal" ); + radioNormal->setChecked( true ); + + bgExecTypeLayout->addWidget( radioNormal, 0, 0 ); + + radioTerminal = new TQRadioButton( bgExecType, "radioTerminal" ); + + bgExecTypeLayout->addWidget( radioTerminal, 1, 0 ); + + tabLayout->addMultiCellWidget( bgExecType, 9, 10, 0, 1 ); + tabWidget3->insertTab( tab, TQString::fromLatin1("") ); + + tab_2 = new TQWidget( tabWidget3, "tab_2" ); + tabLayout_2 = new TQGridLayout( tab_2, 1, 1, 11, 6, "tabLayout_2"); + + gbShowonly = new TQGroupBox( tab_2, "gbShowonly" ); + gbShowonly->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)7, (TQSizePolicy::SizeType)7, 0, 0, gbShowonly->sizePolicy().hasHeightForWidth() ) ); + gbShowonly->setColumnLayout(0, TQt::Vertical ); + gbShowonly->layout()->setSpacing( 6 ); + gbShowonly->layout()->setMargin( 11 ); + gbShowonlyLayout = new TQGridLayout( gbShowonly->layout() ); + gbShowonlyLayout->setAlignment( TQt::AlignTop ); + + tabShowonly = new TQTabWidget( gbShowonly, "tabShowonly" ); + tabShowonly->setTabPosition( TQTabWidget::Top ); + tabShowonly->setTabShape( TQTabWidget::Triangular ); + + TabPage = new TQWidget( tabShowonly, "TabPage" ); + TabPageLayout = new TQGridLayout( TabPage, 1, 1, 11, 6, "TabPageLayout"); + + ButtonNewProtocol = new TQToolButton( TabPage, "ButtonNewProtocol" ); + ButtonNewProtocol->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonNewProtocol->sizePolicy().hasHeightForWidth() ) ); + ButtonNewProtocol->setMinimumSize( TQSize( 0, 0 ) ); + ButtonNewProtocol->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout->addWidget( ButtonNewProtocol, 0, 1 ); + + ButtonEditProtocol = new TQToolButton( TabPage, "ButtonEditProtocol" ); + ButtonEditProtocol->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditProtocol->sizePolicy().hasHeightForWidth() ) ); + ButtonEditProtocol->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditProtocol->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout->addWidget( ButtonEditProtocol, 1, 1 ); + spacer6_3 = new TQSpacerItem( 21, 58, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + TabPageLayout->addItem( spacer6_3, 3, 1 ); + + ButtonRemoveProtocol = new TQToolButton( TabPage, "ButtonRemoveProtocol" ); + ButtonRemoveProtocol->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemoveProtocol->sizePolicy().hasHeightForWidth() ) ); + ButtonRemoveProtocol->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemoveProtocol->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout->addWidget( ButtonRemoveProtocol, 2, 1 ); + + lbShowonlyProtocol = new TDEListBox( TabPage, "lbShowonlyProtocol" ); + + TabPageLayout->addMultiCellWidget( lbShowonlyProtocol, 0, 3, 0, 0 ); + tabShowonly->insertTab( TabPage, TQString::fromLatin1("") ); + + tab_3 = new TQWidget( tabShowonly, "tab_3" ); + tabLayout_3 = new TQGridLayout( tab_3, 1, 1, 11, 6, "tabLayout_3"); + + lbShowonlyPath = new TDEListBox( tab_3, "lbShowonlyPath" ); + + tabLayout_3->addMultiCellWidget( lbShowonlyPath, 0, 3, 0, 0 ); + + ButtonAddPath = new TQToolButton( tab_3, "ButtonAddPath" ); + ButtonAddPath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonAddPath->sizePolicy().hasHeightForWidth() ) ); + ButtonAddPath->setMinimumSize( TQSize( 0, 0 ) ); + ButtonAddPath->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_3->addWidget( ButtonAddPath, 0, 1 ); + + ButtonEditPath = new TQToolButton( tab_3, "ButtonEditPath" ); + ButtonEditPath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditPath->sizePolicy().hasHeightForWidth() ) ); + ButtonEditPath->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditPath->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_3->addWidget( ButtonEditPath, 1, 1 ); + + ButtonRemovePath = new TQToolButton( tab_3, "ButtonRemovePath" ); + ButtonRemovePath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemovePath->sizePolicy().hasHeightForWidth() ) ); + ButtonRemovePath->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemovePath->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_3->addWidget( ButtonRemovePath, 2, 1 ); + spacer4 = new TQSpacerItem( 21, 61, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout_3->addItem( spacer4, 3, 1 ); + tabShowonly->insertTab( tab_3, TQString::fromLatin1("") ); + + tab_4 = new TQWidget( tabShowonly, "tab_4" ); + tabLayout_4 = new TQGridLayout( tab_4, 1, 1, 11, 6, "tabLayout_4"); + + lbShowonlyMime = new TDEListBox( tab_4, "lbShowonlyMime" ); + + tabLayout_4->addMultiCellWidget( lbShowonlyMime, 0, 3, 0, 0 ); + + ButtonAddMime = new TQToolButton( tab_4, "ButtonAddMime" ); + ButtonAddMime->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonAddMime->sizePolicy().hasHeightForWidth() ) ); + ButtonAddMime->setMinimumSize( TQSize( 0, 0 ) ); + ButtonAddMime->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_4->addWidget( ButtonAddMime, 0, 1 ); + + ButtonEditMime = new TQToolButton( tab_4, "ButtonEditMime" ); + ButtonEditMime->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditMime->sizePolicy().hasHeightForWidth() ) ); + ButtonEditMime->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditMime->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_4->addWidget( ButtonEditMime, 1, 1 ); + + ButtonRemoveMime = new TQToolButton( tab_4, "ButtonRemoveMime" ); + ButtonRemoveMime->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemoveMime->sizePolicy().hasHeightForWidth() ) ); + ButtonRemoveMime->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemoveMime->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_4->addWidget( ButtonRemoveMime, 2, 1 ); + spacer5 = new TQSpacerItem( 21, 41, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout_4->addItem( spacer5, 3, 1 ); + tabShowonly->insertTab( tab_4, TQString::fromLatin1("") ); + + TabPage_2 = new TQWidget( tabShowonly, "TabPage_2" ); + TabPageLayout_2 = new TQGridLayout( TabPage_2, 1, 1, 11, 6, "TabPageLayout_2"); + + lbShowonlyFile = new TDEListBox( TabPage_2, "lbShowonlyFile" ); + + TabPageLayout_2->addMultiCellWidget( lbShowonlyFile, 0, 3, 0, 0 ); + + ButtonNewFile = new TQToolButton( TabPage_2, "ButtonNewFile" ); + ButtonNewFile->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonNewFile->sizePolicy().hasHeightForWidth() ) ); + ButtonNewFile->setMinimumSize( TQSize( 0, 0 ) ); + ButtonNewFile->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout_2->addWidget( ButtonNewFile, 0, 1 ); + + ButtonEditFile = new TQToolButton( TabPage_2, "ButtonEditFile" ); + ButtonEditFile->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditFile->sizePolicy().hasHeightForWidth() ) ); + ButtonEditFile->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditFile->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout_2->addWidget( ButtonEditFile, 1, 1 ); + + ButtonRemoveFile = new TQToolButton( TabPage_2, "ButtonRemoveFile" ); + ButtonRemoveFile->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemoveFile->sizePolicy().hasHeightForWidth() ) ); + ButtonRemoveFile->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemoveFile->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout_2->addWidget( ButtonRemoveFile, 2, 1 ); + spacer6 = new TQSpacerItem( 21, 41, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + TabPageLayout_2->addItem( spacer6, 3, 1 ); + tabShowonly->insertTab( TabPage_2, TQString::fromLatin1("") ); + + gbShowonlyLayout->addWidget( tabShowonly, 0, 0 ); + + tabLayout_2->addMultiCellWidget( gbShowonly, 0, 0, 0, 1 ); + + chkConfirmExecution = new TQCheckBox( tab_2, "chkConfirmExecution" ); + + tabLayout_2->addMultiCellWidget( chkConfirmExecution, 1, 1, 0, 1 ); + + chkDifferentUser = new TQCheckBox( tab_2, "chkDifferentUser" ); + + tabLayout_2->addWidget( chkDifferentUser, 2, 0 ); + + leDifferentUser = new KLineEdit( tab_2, "leDifferentUser" ); + leDifferentUser->setEnabled( false ); + + tabLayout_2->addWidget( leDifferentUser, 2, 1 ); + spacer3 = new TQSpacerItem( 161, 102, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout_2->addMultiCell( spacer3, 3, 3, 0, 1 ); + tabWidget3->insertTab( tab_2, TQString::fromLatin1("") ); + + ActionPropertyBaseLayout->addWidget( tabWidget3, 0, 0 ); + languageChange(); + resize( TQSize(485, 470).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); + + // signals and slots connections + connect( radioCollectOutput, TQ_SIGNAL( toggled(bool) ), chkSeparateStdError, TQ_SLOT( setEnabled(bool) ) ); + connect( chkDifferentUser, TQ_SIGNAL( toggled(bool) ), leDifferentUser, TQ_SLOT( setEnabled(bool) ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +ActionPropertyBase::~ActionPropertyBase() +{ + // no need to delete child widgets, TQt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void ActionPropertyBase::languageChange() +{ + setCaption( tr2i18n( "Action Property" ) ); + ButtonAddStartpath->setText( tr2i18n( "..." ) ); + LabelDescription->setText( tr2i18n( "Description:" ) ); + TQWhatsThis::add( LabelDescription, tr2i18n( "A detailed description of the <b>Useraction</b>. It is only displayed in the <i>Konfigurator</i> and via <code>Shift-F1</code>." ) ); + bgAccept->setTitle( tr2i18n( "Command accepts" ) ); + radioLocal->setText( tr2i18n( "Local files only (no URL's)" ) ); + TQWhatsThis::add( radioLocal, tr2i18n( "Substitute the <b>Placeholders</b> with local filenames." ) ); + radioUrl->setText( tr2i18n( "URL's (remote and local)" ) ); + TQWhatsThis::add( radioUrl, tr2i18n( "Substitute the <b>Placeholders</b> with valid URL's." ) ); + TQWhatsThis::add( leTitle, tr2i18n( "The title displayed in the <b>Usermenu</b>." ) ); + LabelTitle->setText( tr2i18n( "Title:" ) ); + TQWhatsThis::add( LabelTitle, tr2i18n( "The title displayed in the <b>Usermenu</b>." ) ); + TQWhatsThis::add( leDistinctName, tr2i18n( "Unique name of the <b>Useraction</b>. It is only used in the <i>Konfigurator</i> and doesn't appear in any other menu.<p><b>Note</b>: The <i>Title</i> shown in the <b>Usermenu</b> can be set below." ) ); + TQWhatsThis::add( cbCategory, tr2i18n( "<b>Useractions</b> can be grouped in categories for better distinction. Choose a existing <i>Category</i> or create a new one by entering a name." ) ); + ButtonIcon->setText( tr2i18n( "Icon" ) ); + TQWhatsThis::add( ButtonIcon, tr2i18n( "Each <b>Useraction</b> can have its own icon. It will appear in front of the title in the <b>Usermenu</b>." ) ); + LabelDistinctName->setText( tr2i18n( "Identifier:" ) ); + TQWhatsThis::add( LabelDistinctName, tr2i18n( "<p>Unique name of the <b>Useraction</b>. It is only used in the <i>Konfigurator</i> and doesn't appear in any other menu.</p><p><b>Note</b>: The <i>Title</i> shown in the <b>Usermenu</b> can be set below.</p>" ) ); + LabelCommandline->setText( tr2i18n( "Command:" ) ); + TQWhatsThis::add( LabelCommandline, tr2i18n( "<p>The <i>Command</i> defines the command that will be executed when the <b>Useraction</b> is used. It can be a simple shell command or a complex sequence of multiple commands with <b>Placeholders</b>.</p><p>Examples:<ul><code><li>eject /mnt/cdrom</li><li>amarok --append %aList(\"Selected\")%</li></code></ul>\n" +"Please consult the handbook to learn more about the syntax.</p>" ) ); + TQWhatsThis::add( leTooltip, tr2i18n( "The <i>Tooltip</i> is shown when the mouse cursor is hold over an entry of the <b>Useraction Toolbar</b>." ) ); + TQWhatsThis::add( leStartpath, tr2i18n( "The <i>Workdir</i> defines in which directory the <i>Command</i> will be executed." ) ); + LabelTooltip->setText( tr2i18n( "Tooltip:" ) ); + TQWhatsThis::add( LabelTooltip, tr2i18n( "The <i>Tooltip</i> is shown when the mouse cursor is hold over an entry of the <b>Useraction Toolbar</b>." ) ); + leCommandline->setText( TQString() ); + TQWhatsThis::add( leCommandline, tr2i18n( "The <i>Command</i> defines the command that will be executed when the <b>Useraction</b> is used. It can be a simple shell command or a complex sequence of multiple commands with <b>Placeholders</b>.<p>\n" +"Examples:<ul><code><li>eject /mnt/cdrom</li><li>amarok --append %aList(\"Selected\")%</li></code></ul>\n" +"Please consult the handbook to learn more about the syntax." ) ); + LabelCategory->setText( tr2i18n( "Category:" ) ); + TQWhatsThis::add( LabelCategory, tr2i18n( "<b>Useractions</b> can be grouped in categories for better distinction. Choose a existing <i>Category</i> or create a new one by entering a name." ) ); + ButtonAddPlaceholder->setText( tr2i18n( "&Add" ) ); + TQWhatsThis::add( ButtonAddPlaceholder, tr2i18n( "Add <b>Placeholders</b> for the selected files in the panel." ) ); + TQWhatsThis::add( textDescription, tr2i18n( "A detailed description of the <b>Useraction</b>. It is only displayed in the <i>Konfigurator</i> and via <code>Shift-F1</code>." ) ); + LabelStartpath->setText( tr2i18n( "Workdir:" ) ); + TQWhatsThis::add( LabelStartpath, tr2i18n( "The <i>Workdir</i> defines in which directory the <i>Command</i> will be executed." ) ); + LabelShortcut->setText( tr2i18n( "Default shortcut:" ) ); + KeyButtonShortcut->setText( tr2i18n( "None" ) ); + TQWhatsThis::add( KeyButtonShortcut, tr2i18n( "Set a default keyboard shortcut." ) ); + bgExecType->setTitle( tr2i18n( "Execution mode" ) ); + radioCollectOutput->setText( tr2i18n( "Collect output" ) ); + TQWhatsThis::add( radioCollectOutput, tr2i18n( "Collect the output of the executed program." ) ); + chkSeparateStdError->setText( tr2i18n( "Separate standard error" ) ); + TQWhatsThis::add( chkSeparateStdError, tr2i18n( "Separate standard out and standard error in the output collection." ) ); + radioNormal->setText( tr2i18n( "Normal" ) ); + radioTerminal->setText( tr2i18n( "Run in terminal" ) ); + TQWhatsThis::add( radioTerminal, tr2i18n( "Run the command in a terminal." ) ); + tabWidget3->changeTab( tab, tr2i18n( "Basic Properties" ) ); + gbShowonly->setTitle( tr2i18n( "The Useraction is only available for" ) ); + ButtonNewProtocol->setText( tr2i18n( "&New..." ) ); + ButtonEditProtocol->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemoveProtocol->setText( tr2i18n( "De&lete" ) ); + TQWhatsThis::add( lbShowonlyProtocol, tr2i18n( "Show the <b>Useraction</b> only for the values defined here." ) ); + tabShowonly->changeTab( TabPage, tr2i18n( "Protocol" ) ); + TQWhatsThis::add( lbShowonlyPath, tr2i18n( "Show the <b>Useraction</b> only for the values defined here." ) ); + ButtonAddPath->setText( tr2i18n( "&New..." ) ); + ButtonEditPath->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemovePath->setText( tr2i18n( "De&lete" ) ); + tabShowonly->changeTab( tab_3, tr2i18n( "Path" ) ); + TQWhatsThis::add( lbShowonlyMime, tr2i18n( "Show the <b>Useraction</b> only for the values defined here." ) ); + ButtonAddMime->setText( tr2i18n( "&New..." ) ); + ButtonEditMime->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemoveMime->setText( tr2i18n( "De&lete" ) ); + tabShowonly->changeTab( tab_4, tr2i18n( "Mime-type" ) ); + TQWhatsThis::add( lbShowonlyFile, tr2i18n( "Show the <b>Useraction</b> only for the filenames defined here. The wildcards '<code>?</code>' and '<code>*</code>' can be used." ) ); + ButtonNewFile->setText( tr2i18n( "&New..." ) ); + ButtonEditFile->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemoveFile->setText( tr2i18n( "De&lete" ) ); + tabShowonly->changeTab( TabPage_2, tr2i18n( "Filename" ) ); + chkConfirmExecution->setText( tr2i18n( "Confirm each program call separately" ) ); + TQWhatsThis::add( chkConfirmExecution, tr2i18n( "Allows to tweak the <i>Command</i> before it is executed." ) ); + chkDifferentUser->setText( tr2i18n( "Run as different user:" ) ); + TQWhatsThis::add( chkDifferentUser, tr2i18n( "Execute the <i>Command</i> under a different user-id." ) ); + TQWhatsThis::add( leDifferentUser, tr2i18n( "Execute the <i>Command</i> under a different user-id." ) ); + tabWidget3->changeTab( tab_2, tr2i18n( "Advanced Properties" ) ); +} + +#include "actionpropertybase.moc" diff --git a/src/app/ActionMan/actionpropertybase.ui b/src/app/ActionMan/actionpropertybase.ui new file mode 100644 index 0000000..42cd052 --- /dev/null +++ b/src/app/ActionMan/actionpropertybase.ui @@ -0,0 +1,1116 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>ActionPropertyBase</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>ActionPropertyBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>485</width> + <height>470</height> + </rect> + </property> + <property name="caption"> + <string>Action Property</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabWidget3</cstring> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Basic Properties</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQToolButton" row="8" column="3"> + <property name="name"> + <cstring>ButtonAddStartpath</cstring> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="0"> + <property name="name"> + <cstring>LabelDescription</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Description:</string> + </property> + <property name="whatsThis" stdset="0"> + <string>A detailed description of the <b>Useraction</b>. It is only displayed in the <i>Konfigurator</i> and via <code>Shift-F1</code>.</string> + </property> + </widget> + <widget class="TQButtonGroup" row="9" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>bgAccept</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Command accepts</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton" row="0" column="0"> + <property name="name"> + <cstring>radioLocal</cstring> + </property> + <property name="text"> + <string>Local files only (no URL's)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="whatsThis" stdset="0"> + <string>Substitute the <b>Placeholders</b> with local filenames.</string> + </property> + </widget> + <widget class="TQRadioButton" row="1" column="0"> + <property name="name"> + <cstring>radioUrl</cstring> + </property> + <property name="text"> + <string>URL's (remote and local)</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Substitute the <b>Placeholders</b> with valid URL's.</string> + </property> + </widget> + </grid> + </widget> + <widget class="KLineEdit" row="2" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>leTitle</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>The title displayed in the <b>Usermenu</b>.</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>LabelTitle</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Title:</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The title displayed in the <b>Usermenu</b>.</string> + </property> + </widget> + <widget class="TQLayoutWidget" row="0" column="1" rowspan="2" colspan="3"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KLineEdit"> + <property name="name"> + <cstring>leDistinctName</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Unique name of the <b>Useraction</b>. It is only used in the <i>Konfigurator</i> and doesn't appear in any other menu.<p><b>Note</b>: The <i>Title</i> shown in the <b>Usermenu</b> can be set below.</string> + </property> + </widget> + <widget class="KComboBox"> + <property name="name"> + <cstring>cbCategory</cstring> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="whatsThis" stdset="0"> + <string><b>Useractions</b> can be grouped in categories for better distinction. Choose a existing <i>Category</i> or create a new one by entering a name.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="TDEIconButton"> + <property name="name"> + <cstring>ButtonIcon</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>50</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>50</height> + </size> + </property> + <property name="text"> + <string>Icon</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Each <b>Useraction</b> can have its own icon. It will appear in front of the title in the <b>Usermenu</b>.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>LabelDistinctName</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Identifier:</string> + </property> + <property name="whatsThis" stdset="0"> + <string><p>Unique name of the <b>Useraction</b>. It is only used in the <i>Konfigurator</i> and doesn't appear in any other menu.</p><p><b>Note</b>: The <i>Title</i> shown in the <b>Usermenu</b> can be set below.</p></string> + </property> + </widget> + <widget class="TQLabel" row="7" column="0"> + <property name="name"> + <cstring>LabelCommandline</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Command:</string> + </property> + <property name="whatsThis" stdset="0"> + <string><p>The <i>Command</i> defines the command that will be executed when the <b>Useraction</b> is used. It can be a simple shell command or a complex sequence of multiple commands with <b>Placeholders</b>.</p><p>Examples:<ul><code><li>eject /mnt/cdrom</li><li>amarok --append %aList("Selected")%</li></code></ul> +Please consult the handbook to learn more about the syntax.</p></string> + </property> + </widget> + <widget class="KLineEdit" row="3" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>leTooltip</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>The <i>Tooltip</i> is shown when the mouse cursor is hold over an entry of the <b>Useraction Toolbar</b>.</string> + </property> + </widget> + <widget class="KLineEdit" row="8" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>leStartpath</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>The <i>Workdir</i> defines in which directory the <i>Command</i> will be executed.</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>LabelTooltip</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Tooltip:</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The <i>Tooltip</i> is shown when the mouse cursor is hold over an entry of the <b>Useraction Toolbar</b>.</string> + </property> + </widget> + <widget class="KLineEdit" row="7" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>leCommandline</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="whatsThis" stdset="0"> + <string>The <i>Command</i> defines the command that will be executed when the <b>Useraction</b> is used. It can be a simple shell command or a complex sequence of multiple commands with <b>Placeholders</b>.<p> +Examples:<ul><code><li>eject /mnt/cdrom</li><li>amarok --append %aList("Selected")%</li></code></ul> +Please consult the handbook to learn more about the syntax.</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>LabelCategory</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Category:</string> + </property> + <property name="whatsThis" stdset="0"> + <string><b>Useractions</b> can be grouped in categories for better distinction. Choose a existing <i>Category</i> or create a new one by entering a name.</string> + </property> + </widget> + <widget class="TQToolButton" row="7" column="3"> + <property name="name"> + <cstring>ButtonAddPlaceholder</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>&Add</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Add <b>Placeholders</b> for the selected files in the panel.</string> + </property> + </widget> + <widget class="KTextEdit" row="4" column="1" rowspan="3" colspan="3"> + <property name="name"> + <cstring>textDescription</cstring> + </property> + <property name="wordWrap"> + <enum>WidgetWidth</enum> + </property> + <property name="whatsThis" stdset="0"> + <string>A detailed description of the <b>Useraction</b>. It is only displayed in the <i>Konfigurator</i> and via <code>Shift-F1</code>.</string> + </property> + </widget> + <widget class="TQLabel" row="8" column="0"> + <property name="name"> + <cstring>LabelStartpath</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Workdir:</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The <i>Workdir</i> defines in which directory the <i>Command</i> will be executed.</string> + </property> + </widget> + <spacer row="6" column="0"> + <property name="name"> + <cstring>spacer</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>80</width> + <height>19</height> + </size> + </property> + </spacer> + <widget class="TQLayoutWidget" row="10" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>LabelShortcut</cstring> + </property> + <property name="text"> + <string>Default shortcut:</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>161</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="KKeyButton"> + <property name="name"> + <cstring>KeyButtonShortcut</cstring> + </property> + <property name="text"> + <string>None</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Set a default keyboard shortcut.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="TQButtonGroup" row="9" column="0" rowspan="2" colspan="2"> + <property name="name"> + <cstring>bgExecType</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Execution mode</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton" row="2" column="0"> + <property name="name"> + <cstring>radioCollectOutput</cstring> + </property> + <property name="text"> + <string>Collect output</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Collect the output of the executed program.</string> + </property> + </widget> + <widget class="TQCheckBox" row="3" column="0"> + <property name="name"> + <cstring>chkSeparateStdError</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Separate standard error</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Separate standard out and standard error in the output collection.</string> + </property> + </widget> + <widget class="TQRadioButton" row="0" column="0"> + <property name="name"> + <cstring>radioNormal</cstring> + </property> + <property name="text"> + <string>Normal</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQRadioButton" row="1" column="0"> + <property name="name"> + <cstring>radioTerminal</cstring> + </property> + <property name="text"> + <string>Run in terminal</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Run the command in a terminal.</string> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Advanced Properties</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>gbShowonly</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>The Useraction is only available for</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabShowonly</cstring> + </property> + <property name="tabPosition"> + <enum>Top</enum> + </property> + <property name="tabShape"> + <enum>Triangular</enum> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Protocol</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQToolButton" row="0" column="1"> + <property name="name"> + <cstring>ButtonNewProtocol</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>&New...</string> + </property> + </widget> + <widget class="TQToolButton" row="1" column="1"> + <property name="name"> + <cstring>ButtonEditProtocol</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>Chan&ge...</string> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer6_3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>58</height> + </size> + </property> + </spacer> + <widget class="TQToolButton" row="2" column="1"> + <property name="name"> + <cstring>ButtonRemoveProtocol</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>De&lete</string> + </property> + </widget> + <widget class="TDEListBox" row="0" column="0" rowspan="4" colspan="1"> + <property name="name"> + <cstring>lbShowonlyProtocol</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Show the <b>Useraction</b> only for the values defined here.</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Path</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TDEListBox" row="0" column="0" rowspan="4" colspan="1"> + <property name="name"> + <cstring>lbShowonlyPath</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Show the <b>Useraction</b> only for the values defined here.</string> + </property> + </widget> + <widget class="TQToolButton" row="0" column="1"> + <property name="name"> + <cstring>ButtonAddPath</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>&New...</string> + </property> + </widget> + <widget class="TQToolButton" row="1" column="1"> + <property name="name"> + <cstring>ButtonEditPath</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>Chan&ge...</string> + </property> + </widget> + <widget class="TQToolButton" row="2" column="1"> + <property name="name"> + <cstring>ButtonRemovePath</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>De&lete</string> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>61</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Mime-type</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TDEListBox" row="0" column="0" rowspan="4" colspan="1"> + <property name="name"> + <cstring>lbShowonlyMime</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Show the <b>Useraction</b> only for the values defined here.</string> + </property> + </widget> + <widget class="TQToolButton" row="0" column="1"> + <property name="name"> + <cstring>ButtonAddMime</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>&New...</string> + </property> + </widget> + <widget class="TQToolButton" row="1" column="1"> + <property name="name"> + <cstring>ButtonEditMime</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>Chan&ge...</string> + </property> + </widget> + <widget class="TQToolButton" row="2" column="1"> + <property name="name"> + <cstring>ButtonRemoveMime</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>De&lete</string> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>41</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Filename</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TDEListBox" row="0" column="0" rowspan="4" colspan="1"> + <property name="name"> + <cstring>lbShowonlyFile</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Show the <b>Useraction</b> only for the filenames defined here. The wildcards '<code>?</code>' and '<code>*</code>' can be used.</string> + </property> + </widget> + <widget class="TQToolButton" row="0" column="1"> + <property name="name"> + <cstring>ButtonNewFile</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>&New...</string> + </property> + </widget> + <widget class="TQToolButton" row="1" column="1"> + <property name="name"> + <cstring>ButtonEditFile</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>Chan&ge...</string> + </property> + </widget> + <widget class="TQToolButton" row="2" column="1"> + <property name="name"> + <cstring>ButtonRemoveFile</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>De&lete</string> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>41</height> + </size> + </property> + </spacer> + </grid> + </widget> + </widget> + </grid> + </widget> + <widget class="TQCheckBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkConfirmExecution</cstring> + </property> + <property name="text"> + <string>Confirm each program call separately</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Allows to tweak the <i>Command</i> before it is executed.</string> + </property> + </widget> + <widget class="TQCheckBox" row="2" column="0"> + <property name="name"> + <cstring>chkDifferentUser</cstring> + </property> + <property name="text"> + <string>Run as different user:</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Execute the <i>Command</i> under a different user-id.</string> + </property> + </widget> + <widget class="KLineEdit" row="2" column="1"> + <property name="name"> + <cstring>leDifferentUser</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="whatsThis" stdset="0"> + <string>Execute the <i>Command</i> under a different user-id.</string> + </property> + </widget> + <spacer row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>161</width> + <height>102</height> + </size> + </property> + </spacer> + </grid> + </widget> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>radioCollectOutput</sender> + <signal>toggled(bool)</signal> + <receiver>chkSeparateStdError</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>chkDifferentUser</sender> + <signal>toggled(bool)</signal> + <receiver>leDifferentUser</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includes> + <include location="global" impldecl="in implementation">kcombobox.h</include> + <include location="global" impldecl="in implementation">kicondialog.h</include> + <include location="global" impldecl="in implementation">kkeybutton.h</include> + <include location="global" impldecl="in implementation">klineedit.h</include> + <include location="global" impldecl="in implementation">ktextedit.h</include> + <include location="global" impldecl="in implementation">tdelistbox.h</include> +</includes> +</UI> diff --git a/src/app/ActionMan/addplaceholderpopup.cpp b/src/app/ActionMan/addplaceholderpopup.cpp new file mode 100644 index 0000000..3fe7c29 --- /dev/null +++ b/src/app/ActionMan/addplaceholderpopup.cpp @@ -0,0 +1,582 @@ +// +// C++ Implementation: addplaceholderpopup +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "addplaceholderpopup.h" + +#include "../UserAction/expander.h" + +#include <tdelocale.h> +#include <tdefiledialog.h> +#include <tdemessagebox.h> + +// for ParameterDialog +#include "../krusader.h" // for konfig-access +#include "../BookMan/krbookmarkbutton.h" +#include "../GUI/profilemanager.h" + +#include <tqlayout.h> +#include <tqhbox.h> +#include <tqlabel.h> +#include <tqtoolbutton.h> +#include <klineedit.h> +#include <tqcheckbox.h> +#include <kiconloader.h> +#include <kcombobox.h> +#include <kurlcompletion.h> +#include <knuminput.h> + +#include <kdebug.h> + +#define ACTIVE_MASK 0x0100 +#define OTHER_MASK 0x0200 +#define LEFT_MASK 0x0400 +#define RIGHT_MASK 0x0800 +#define INDEPENDENT_MASK 0x1000 +#define EXECUTABLE_ID 0xFFFF + + +AddPlaceholderPopup::AddPlaceholderPopup( TQWidget *parent ) : TDEPopupMenu( parent ) { + + _activeSub = new TDEPopupMenu( this ); + _otherSub = new TDEPopupMenu( this ); + _leftSub = new TDEPopupMenu( this ); + _rightSub = new TDEPopupMenu( this ); + _independentSub = new TDEPopupMenu( this ); + + insertItem( i18n( "Active panel" ), _activeSub ); + insertItem( i18n( "Other panel" ), _otherSub ); + insertItem( i18n( "Left panel" ), _leftSub ); + insertItem( i18n( "Right panel" ), _rightSub ); + insertItem( i18n( "Panel independent" ), _independentSub ); + _independentSub->insertItem( i18n( "Choose executable..." ), EXECUTABLE_ID ); + _independentSub->insertSeparator(); + + // read the expressions array from the user menu and populate menus + Expander expander; + for ( int i = 0; i < expander.placeholderCount(); ++i ) { + if ( expander.placeholder( i )->expression().isEmpty() ) { + if ( expander.placeholder( i )->needPanel() ) { + _activeSub->insertSeparator(); + _otherSub->insertSeparator(); + _leftSub->insertSeparator(); + _rightSub->insertSeparator(); + } + else + _independentSub->insertSeparator(); + } + else { + if ( expander.placeholder( i )->needPanel() ) { + _activeSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | ACTIVE_MASK ) ); + _otherSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | OTHER_MASK ) ); + _leftSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | LEFT_MASK ) ); + _rightSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | RIGHT_MASK ) ); + } + else + _independentSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | INDEPENDENT_MASK ) ); + } + } + +} + + +TQString AddPlaceholderPopup::getPlaceholder( const TQPoint& pos ) { + int res = exec( pos ); + if ( res == -1 ) + return TQString(); + + // add the selected flag to the command line + if ( res == EXECUTABLE_ID ) { // did the user need an executable ? + // select an executable + TQString filename = KFileDialog::getOpenFileName(TQString(), TQString(), this); + if (filename != TQString()) + return filename + " "; // with extra space + //return filename; // without extra space + } else { // user selected something from the menus + Expander expander; + const exp_placeholder* currentPlaceholder = expander.placeholder( res & ~( ACTIVE_MASK | OTHER_MASK | LEFT_MASK | RIGHT_MASK | INDEPENDENT_MASK ) ); +// if ( ¤tPlaceholder->expFunc == 0 ) { +// KMessageBox::sorry( this, "BOFH Excuse #93:\nFeature not yet implemented" ); +// return TQString(); +// } + ParameterDialog* parameterDialog = new ParameterDialog( currentPlaceholder, this ); + TQString panel, parameter = parameterDialog->getParameter(); + delete parameterDialog; + // indicate the panel with 'a' 'o', 'l', 'r' or '_'. + if ( res & ACTIVE_MASK ) + panel = "a"; + else if ( res & OTHER_MASK ) + panel = "o"; + else if ( res & LEFT_MASK ) + panel = "l"; + else if ( res & RIGHT_MASK ) + panel = "r"; + else if ( res & INDEPENDENT_MASK ) + panel = "_"; + //return "%" + panel + currentPlaceholder->expression() + parameter + "% "; // with extra space + return "%" + panel + currentPlaceholder->expression() + parameter + "%"; // without extra space + } + return TQString(); +} + + +//////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// ParameterDialog //////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +ParameterDialog::ParameterDialog( const exp_placeholder* currentPlaceholder, TQWidget *parent ) : KDialogBase( Plain, i18n("User Action Parameter Dialog"), Default | Ok, Ok, parent ) { + _parameter.clear(); + _parameterCount = currentPlaceholder->parameterCount(); + + TQVBoxLayout* layout = new TQVBoxLayout( plainPage() ); + layout->setAutoAdd( true ); + layout->setSpacing( 11 ); + + new TQLabel( i18n("This placeholder allows some parameter:"), plainPage(), "intro" ); + + for (int i = 0; i < _parameterCount; ++i ) { + if ( currentPlaceholder->parameter( i ).preset() == "__placeholder" ) + _parameter.append( new ParameterPlaceholder( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__yes" ) + _parameter.append( new ParameterYes( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__no" ) + _parameter.append( new ParameterNo( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__file" ) + _parameter.append( new ParameterFile( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset().find( "__choose" ) != -1 ) + _parameter.append( new ParameterChoose( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__select" ) + _parameter.append( new ParameterSelect( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__goto" ) + _parameter.append( new ParameterGoto( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__syncprofile" ) + _parameter.append( new ParameterSyncprofile( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__searchprofile" ) + _parameter.append( new ParameterSearch( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__panelprofile" ) + _parameter.append( new ParameterPanelprofile( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset().find( "__int" ) != -1 ) + _parameter.append( new ParameterInt( currentPlaceholder->parameter( i ), plainPage() ) ); + else + _parameter.append( new ParameterText( currentPlaceholder->parameter( i ), plainPage() ) ); + } + + TQFrame * line = new TQFrame( plainPage() ); + line->setFrameShape( TQFrame::HLine ); + line->setFrameShadow( TQFrame::Sunken ); + + connect( this, TQ_SIGNAL(defaultClicked()), this, TQ_SLOT(reset()) ); +} + +TQString ParameterDialog::getParameter() { + if ( _parameterCount == 0 ) // meaning no parameters + return TQString(); + + if ( exec() == -1 ) + return TQString(); + + int lastParameter = _parameterCount; + while ( --lastParameter > -1 ) { + if ( _parameter[ lastParameter ]->text() != _parameter[ lastParameter ]->preset() || _parameter[ lastParameter ]->nessesary() ) + break; + } + + if ( lastParameter < 0) // all parameters have default-values + return TQString(); + + TQString parameter = "("; + for ( int i = 0; i <= lastParameter; ++i ) { + if ( i > 0 ) + parameter += ", "; + parameter += "\"" + _parameter[ i ]->text().replace( "\"", "\\\"" ) + "\""; + } + parameter += ")"; + return parameter; +} + +void ParameterDialog::reset() { + for ( int i = 0; i < _parameterCount; ++i ) + _parameter[ i ]->reset(); +} + +void ParameterDialog::slotOk() { + bool valid = true; + for (int i = 0; i < _parameterCount; ++i ) { + if ( _parameter[ i ]->nessesary() && ! _parameter[ i ]->valid() ) + valid = false; + } + + if ( valid ) + accept(); +} + +///////////// ParameterText +ParameterText::ParameterText( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _lineEdit = new KLineEdit( parameter.preset(), this ); + _preset = parameter.preset(); +} + +TQString ParameterText::text() { + return _lineEdit->text(); +} +TQString ParameterText::preset() { + return _preset; +} +void ParameterText::reset() { + _lineEdit->setText( _preset ); +} +bool ParameterText::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} + +///////////// ParameterPlaceholder +ParameterPlaceholder::ParameterPlaceholder( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + TQHBox * hbox = new TQHBox( this ); + hbox->setSpacing( 6 ); + _lineEdit = new KLineEdit( hbox ); + _button = new TQToolButton( hbox); + _button->setText( i18n("add") ); + connect( _button, TQ_SIGNAL(clicked()), this, TQ_SLOT(addPlaceholder()) ); +} + +TQString ParameterPlaceholder::text() { + return _lineEdit->text(); +} +TQString ParameterPlaceholder::preset() { + return TQString(); +} +void ParameterPlaceholder::reset() { + _lineEdit->setText( TQString() ); +} +bool ParameterPlaceholder::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} +void ParameterPlaceholder::addPlaceholder() { + AddPlaceholderPopup* popup = new AddPlaceholderPopup( this ); + TQString exp = popup->getPlaceholder( mapToGlobal( TQPoint( _button->pos().x() + _button->width() + 6, _button->pos().y() + _button->height() / 2 ) ) ); + _lineEdit->insert( exp ); + delete popup; +} + +///////////// ParameterYes +ParameterYes::ParameterYes( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + _checkBox = new TQCheckBox( i18n( parameter.description().utf8() ), this ); + _checkBox->setChecked( true ); +} + +TQString ParameterYes::text() { + if ( _checkBox->isChecked() ) + return TQString(); + else + return "No"; +} +TQString ParameterYes::preset() { + return TQString(); +} +void ParameterYes::reset() { + _checkBox->setChecked( true ); +} +bool ParameterYes::valid() { + return true; +} + +///////////// ParameterNo +ParameterNo::ParameterNo( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + _checkBox = new TQCheckBox( i18n( parameter.description().utf8() ), this ); + _checkBox->setChecked( false ); +} + +TQString ParameterNo::text() { + if ( _checkBox->isChecked() ) + return "Yes"; + else + return TQString(); +} +TQString ParameterNo::preset() { + return TQString(); +} +void ParameterNo::reset() { + _checkBox->setChecked( false ); +} +bool ParameterNo::valid() { + return true; +} + +///////////// ParameterFile +ParameterFile::ParameterFile( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + TQHBox * hbox = new TQHBox( this ); + hbox->setSpacing( 6 ); + _lineEdit = new KLineEdit( hbox ); + _button = new TQToolButton( hbox); + TDEIconLoader *iconLoader = new TDEIconLoader(); + _button->setPixmap( iconLoader->loadIcon( "document-open", TDEIcon::Toolbar, 16 ) ); + connect( _button, TQ_SIGNAL(clicked()), this, TQ_SLOT(addFile()) ); +} + +TQString ParameterFile::text() { + return _lineEdit->text(); +} +TQString ParameterFile::preset() { + return TQString(); +} +void ParameterFile::reset() { + _lineEdit->setText( TQString() ); +} +bool ParameterFile::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} +void ParameterFile::addFile() { + TQString filename = KFileDialog::getOpenFileName(TQString(), TQString(), this); + _lineEdit->insert( filename ); +} + +///////////// ParameterChoose +ParameterChoose::ParameterChoose( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + _combobox->insertStringList( TQStringList::split( ";", parameter.preset().section(":", 1) ) ); +} + +TQString ParameterChoose::text() { + return _combobox->currentText(); +} +TQString ParameterChoose::preset() { + return _combobox->text( 0 ); +} +void ParameterChoose::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterChoose::valid() { + return true; +} + +///////////// ParameterSelect +ParameterSelect::ParameterSelect( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + _combobox->setEditable( true ); + + krConfig->setGroup( "Private" ); + TQStrList lst; + int i = krConfig->readListEntry( "Predefined Selections", lst ); + if ( i > 0 ) + _combobox->insertStrList( lst ); + + _combobox->setCurrentText( "*" ); +} + +TQString ParameterSelect::text() { + return _combobox->currentText(); +} +TQString ParameterSelect::preset() { + return "*"; +} +void ParameterSelect::reset() { + _combobox->setCurrentText( "*" ); +} +bool ParameterSelect::valid() { + return true; +} + +///////////// ParameterGoto +ParameterGoto::ParameterGoto( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + TQHBox * hbox = new TQHBox( this ); + hbox->setSpacing( 6 ); + _lineEdit = new KLineEdit( hbox ); + _lineEdit->setCompletionObject( new KURLCompletion( KURLCompletion::DirCompletion ) ); + _dirButton = new TQToolButton( hbox ); + TDEIconLoader *iconLoader = new TDEIconLoader(); + _dirButton->setPixmap( iconLoader->loadIcon( "document-open", TDEIcon::Toolbar, 16 ) ); + connect( _dirButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(setDir()) ); + _placeholderButton = new TQToolButton( hbox); + _placeholderButton->setText( i18n("add") ); + connect( _placeholderButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(addPlaceholder()) ); +} + +TQString ParameterGoto::text() { + return _lineEdit->text(); +} +TQString ParameterGoto::preset() { + return TQString(); +} +void ParameterGoto::reset() { + _lineEdit->setText( TQString() ); +} +bool ParameterGoto::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} +void ParameterGoto::setDir() { + TQString folder = KFileDialog::getExistingDirectory(TQString(), this); + _lineEdit->setText( folder ); +} +void ParameterGoto::addPlaceholder() { + AddPlaceholderPopup* popup = new AddPlaceholderPopup( this ); + TQString exp = popup->getPlaceholder( mapToGlobal( TQPoint( _placeholderButton->pos().x() + _placeholderButton->width() + 6, _placeholderButton->pos().y() + _placeholderButton->height() / 2 ) ) ); + _lineEdit->insert( exp ); + delete popup; +} + +///////////// ParameterSyncprofile +ParameterSyncprofile::ParameterSyncprofile( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + + _combobox->insertStringList( ProfileManager::availableProfiles("SynchronizerProfile") ); +} + +TQString ParameterSyncprofile::text() { + return _combobox->currentText(); +} +TQString ParameterSyncprofile::preset() { + return _combobox->text( 0 ); +} +void ParameterSyncprofile::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterSyncprofile::valid() { + return true; +} + +///////////// ParameterSearch +ParameterSearch::ParameterSearch( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + + _combobox->insertStringList( ProfileManager::availableProfiles("SearcherProfile") ); +} + +TQString ParameterSearch::text() { + return _combobox->currentText(); +} +TQString ParameterSearch::preset() { + return _combobox->text( 0 ); +} +void ParameterSearch::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterSearch::valid() { + return true; +} + +///////////// ParameterPanelprofile +ParameterPanelprofile::ParameterPanelprofile( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + + _combobox->insertStringList( ProfileManager::availableProfiles("Panel") ); +} + +TQString ParameterPanelprofile::text() { + return _combobox->currentText(); +} +TQString ParameterPanelprofile::preset() { + return _combobox->text( 0 ); +} +void ParameterPanelprofile::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterPanelprofile::valid() { + return true; +} + +///////////// ParameterInt +ParameterInt::ParameterInt( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQHBoxLayout* layout = new TQHBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _spinbox = new KIntSpinBox( this ); + TQStringList para = TQStringList::split( ";", parameter.preset().section(":", 1) ); + + _spinbox->setMinValue( para[0].toInt() ); + _spinbox->setMaxValue( para[1].toInt() ); + _spinbox->setLineStep( para[2].toInt() ); + _spinbox->setValue( para[3].toInt() ); + + _default = _spinbox->value(); +} + +TQString ParameterInt::text() { + return _spinbox->text(); +} +TQString ParameterInt::preset() { + return TQString( "%1" ).arg( _default ); +} +void ParameterInt::reset() { + return _spinbox->setValue( _default ); +} +bool ParameterInt::valid() { + return true; +} + + +#include "addplaceholderpopup.moc" diff --git a/src/app/ActionMan/addplaceholderpopup.h b/src/app/ActionMan/addplaceholderpopup.h new file mode 100644 index 0000000..c463dae --- /dev/null +++ b/src/app/ActionMan/addplaceholderpopup.h @@ -0,0 +1,322 @@ +// +// C++ Interface: addplaceholderpopup +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef ADDPLACEHOLDERPOPUP_H +#define ADDPLACEHOLDERPOPUP_H + +#include <tdepopupmenu.h> +#include <kdialogbase.h> +#include "../UserAction/expander.h" + +class TQString; +class KLineEdit; +class TQToolButton; +class TQCheckBox; +class KComboBox; +class KrBookmarkButton; +class KURL; +class KIntSpinBox; + + +/** + * This reads Expander::placeholder[] and fills a popup for easy access to the UserAction Placeholder + * @author Jonas Bähr (http://www.jonas-baehr.de), Shie Erlich + */ +class AddPlaceholderPopup : public TDEPopupMenu { + +public: + AddPlaceholderPopup( TQWidget *parent ); + + /** + * Use this to exec the popup. + * @param pos Position where the popup should appear + * @return the expression which can be placed in the UserAction commandline + */ + TQString getPlaceholder( const TQPoint& pos ); + +protected: + /** + * This is calles when a Placeholder got parameter. + * @param currentPlaceholder A pointer to the Placeholder the user has choosen + * @return a parameter-string + */ + TQString getParameter( exp_placeholder* currentPlaceholder ); + +private: + TDEPopupMenu *_activeSub, *_otherSub, *_leftSub, *_rightSub, *_independentSub; +}; + + +//////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Parameter Widgets /////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +/** + * abstract baseclass for all Parameter widgets + * @author Jonas Bähr (http://www.jonas-baehr.de) + */ +class ParameterBase : public TQWidget { +public: + inline ParameterBase( const exp_parameter& parameter, TQWidget* parent ) : TQWidget( parent ) { _nessesary = parameter.nessesary(); } + /** + * @return the text for the parameter + */ + virtual TQString text() = 0; + /** + * @return the default of the parameter + */ + virtual TQString preset() = 0; + /** + * re-init the parameter with the default + */ + virtual void reset() = 0; + /** + * @return true if the Parameter as a valid value + */ + virtual bool valid() = 0; + /** + * @return true if the Placeholder realy needs this parameter + */ + inline bool nessesary() { return _nessesary; } +private: + bool _nessesary; +}; + +/** + * The simple Parameter widgets: a line-edit with the description above + * used by default + */ +class ParameterText : public ParameterBase { +public: + ParameterText( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQString _preset; +}; + +/** + * A line-edit with the "addPlaceholder"-button + * used with default = "__placeholder" + */ +class ParameterPlaceholder : public ParameterBase { +TQ_OBJECT + +public: + ParameterPlaceholder( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQToolButton* _button; +private slots: + void addPlaceholder(); +}; + +/** + * A Checkbox, default: checked; retuns "No" if unchecked + * used with default = "__yes" + */ +class ParameterYes : public ParameterBase { +public: + ParameterYes( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + TQCheckBox* _checkBox; +}; + +/** + * A Checkbox, default: unchecked; retuns "Yes" if checked + * used with default = "__no" + */ +class ParameterNo : public ParameterBase { +public: + ParameterNo( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + TQCheckBox* _checkBox; +}; + +/** + * A line-edit with the "file open"-button + * used with default = "__file" + */ +class ParameterFile : public ParameterBase { +TQ_OBJECT + +public: + ParameterFile( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQToolButton* _button; +private slots: + void addFile(); +}; + +/** + * A ComboBox with the description above + * used with default = "__choose:item1;item2;..." + */ +class ParameterChoose : public ParameterBase { +public: + ParameterChoose( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * An editable ComboBox with the predifined selections + * used with default = "__select" + */ +class ParameterSelect : public ParameterBase { +public: + ParameterSelect( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A line-edit with a "choose dir"- and a bookmark-button + * used with default = "__goto" + */ +class ParameterGoto : public ParameterBase { +TQ_OBJECT + +public: + ParameterGoto( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQToolButton* _dirButton, *_placeholderButton; +private slots: + void setDir(); + void addPlaceholder(); +}; + +/** + * A ComboBox with all profiles available for the Synchronizer + * used with default = "__syncprofile" + */ +class ParameterSyncprofile : public ParameterBase { +public: + ParameterSyncprofile( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A ComboBox with all profiles available for the panels + * used with default = "__panelprofile" + */ +class ParameterPanelprofile : public ParameterBase { +public: + ParameterPanelprofile( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A ComboBox with all profiles available for the Searchmodule + * used with default = "__searchprofile" + */ +class ParameterSearch : public ParameterBase { +public: + ParameterSearch( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A SpinBox for integer + * used with default = "__int:min;max;step;value" + */ +class ParameterInt : public ParameterBase { +public: + ParameterInt( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KIntSpinBox * _spinbox; + int _default; +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// ParameterDialog //////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Opens a dialog for the parameter. Depending on the default (preset) a differend widget is used. + * See Parameter-Classes for details + */ +class ParameterDialog : public KDialogBase { +TQ_OBJECT + +public: + ParameterDialog( const exp_placeholder* currentPlaceholder, TQWidget *parent ); + + /** + * Use this to execute the dialog. + * @return a TQString with all paremeters; ommiting the optional ones if they have the default-value. + */ + TQString getParameter(); + +private: + typedef TQValueList<ParameterBase*> ParameterList; + ParameterList _parameter; + int _parameterCount; +private slots: + void reset(); + void slotOk(); +}; + + +#endif // ADDPLACEHOLDERPOPUP_H diff --git a/src/app/ActionMan/useractionlistview.cpp b/src/app/ActionMan/useractionlistview.cpp new file mode 100644 index 0000000..fe078e5 --- /dev/null +++ b/src/app/ActionMan/useractionlistview.cpp @@ -0,0 +1,232 @@ +// +// C++ Implementation: useractionlistview +// +// Description: +// +// +// Author: Jonas Bähr, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "useractionlistview.h" + +#include <tdelocale.h> +#include <kiconloader.h> +#include <tqptrlist.h> +#include <tqdom.h> + +#include "../krusader.h" +#include "../UserAction/kraction.h" +#include "../UserAction/useraction.h" + +#define COL_TITLE 0 +#define COL_NAME 1 + + +////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// UserActionListView ///////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////// + +UserActionListView::UserActionListView( TQWidget * parent, const char * name ) + : TDEListView( parent, name ) +{ + addColumn( i18n("Title") ); + //addColumn( i18n("Identifier") ); + setResizeMode( TQListView::AllColumns ); + + setRootIsDecorated( true ); + setSelectionMode( TQListView::Extended ); // normaly select single items but one may use Ctrl or Shift to select multiple + setSorting( COL_TITLE ); + + update(); +} + +UserActionListView::~UserActionListView() +{ +} + +TQSize UserActionListView::sizeHint() const { + return TQSize(200, 400); +} + + +void UserActionListView::update() { + clear(); + UserAction::KrActionList list = krUserAction->actionList(); + for ( KrAction* action = list.first(); action; action = list.next() ) + insertAction( action ); + //sort(); // this is done automaticly +} + +void UserActionListView::update( KrAction* action ) { + UserActionListViewItem* item = findActionItem( action ); + if ( item ) { + // deleting & re-inserting is _much_easyer then tracking all possible cases of category changes! + bool current = ( item == currentItem() ); + bool selected = item->isSelected(); + delete item; + item = insertAction( action ); + if ( current ) + setCurrentItem( item ); + if ( selected ) + setSelected( item, true ); + } +} + +UserActionListViewItem* UserActionListView::insertAction( KrAction* action ) { + if ( ! action ) + return 0; + + UserActionListViewItem* item; + + if ( action->category().isEmpty() ) + item = new UserActionListViewItem( this, action ); + else { + TQListViewItem* categoryItem = findCategoryItem( action->category() ); + if ( ! categoryItem ) { + categoryItem = new TDEListViewItem( this, action->category() ); // create the new category item it not already present + categoryItem->setSelectable( false ); + } + item = new UserActionListViewItem( categoryItem, action ); + } + + item->setAction( action ); + return item; +} + +TQListViewItem* UserActionListView::findCategoryItem( const TQString& category ) { + for ( TQListViewItem* item = firstChild(); item; item = item->nextSibling() ) + if ( item->text( COL_TITLE ) == category && item->text( COL_NAME ).isEmpty() ) // because actions must have a name, items without name haveto be categories + return item; + + return 0; +} + +UserActionListViewItem* UserActionListView::findActionItem( const KrAction* action ) { + for ( TQListViewItemIterator it( this ); it.current(); ++it ) { + if ( UserActionListViewItem* item = dynamic_cast<UserActionListViewItem*>( it.current() ) ) { + if ( item->action() == action ) + return item; + } + } //for + return 0; +} + +KrAction * UserActionListView::currentAction() const { + if ( UserActionListViewItem* item = dynamic_cast<UserActionListViewItem*>( currentItem() ) ) + return item->action(); + else + return 0; +} + +void UserActionListView::setCurrentAction( const KrAction* action) { + UserActionListViewItem* item = findActionItem( action ); + if ( item ) { + setCurrentItem( item ); +// setSelected( item, true ); +// repaintItem( item ); + } +} + +void UserActionListView::setFirstActionCurrent() { + for ( TQListViewItemIterator it( this ); it.current(); ++it ) { + if ( UserActionListViewItem* item = dynamic_cast<UserActionListViewItem*>( it.current() ) ) { + setCurrentItem( item ); + break; + } + } //for +} + +void UserActionListView::setCurrentItem( TQListViewItem* item ) { + if ( ! item ) + return; + ensureItemVisible( item ); + TQListView::setCurrentItem( item ); +} + +TQDomDocument UserActionListView::dumpSelectedActions( TQDomDocument* mergeDoc ) const { + TQPtrList<TQListViewItem> list = selectedItems(); + TQDomDocument doc; + if ( mergeDoc ) + doc = *mergeDoc; + else + doc = UserAction::createEmptyDoc(); + TQDomElement root = doc.documentElement(); + + for ( TQListViewItem* item = list.first(); item; item = list.next() ) + if ( UserActionListViewItem* actionItem = dynamic_cast<UserActionListViewItem*>( item ) ) + root.appendChild( actionItem->action()->xmlDump( doc ) ); + + return doc; +} + +void UserActionListView::removeSelectedActions() { + TQPtrList<TQListViewItem> list = selectedItems(); + + for ( TQListViewItem* item = list.first(); item; item = list.next() ) + if ( UserActionListViewItem* actionItem = dynamic_cast<UserActionListViewItem*>( item ) ) { + delete actionItem->action(); // remove the action itself + delete actionItem; // remove the action from the list + } // if + +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// UserActionListViewItem //////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////// + +UserActionListViewItem::UserActionListViewItem( TQListView* view, KrAction* action ) + : TDEListViewItem( view ) +{ + setAction( action ); +} + +UserActionListViewItem::UserActionListViewItem( TQListViewItem* item, KrAction * action ) + : TDEListViewItem( item ) +{ + setAction( action ); +} + +UserActionListViewItem::~UserActionListViewItem() { +/* // remove category-item if the last member ofthiscategory disappears + if ( TQListViewItem* item = dynamic_cast<TQListViewItem*>( parent() ) ) { + if ( item->childCount() <= 1 ) + item->deleteLater(); // not possible since not inherited from TQObject + }*/ +} + + +void UserActionListViewItem::setAction( KrAction * action ) { + if ( ! action ) + return; + + _action = action; + update(); +} + +KrAction * UserActionListViewItem::action() const { + return _action; +} + +void UserActionListViewItem::update() { + if ( ! _action ) + return; + + if ( ! _action->icon().isEmpty() ) + setPixmap( COL_TITLE, TDEGlobal::iconLoader()->loadIcon( _action->icon(), TDEIcon::Small ) ); + setText( COL_TITLE, _action->text() ); + setText( COL_NAME, _action->name() ); +} + +int UserActionListViewItem::compare( TQListViewItem* i, int col, bool ascending ) const { +// FIXME some how this only produces bullshit :-/ +// if ( i->text( COL_NAME ).isEmpty() ) { // categories only have titles +// //kdDebug() << "this->title: " << text(COL_TITLE) << " |=| i->title: " << i->text(COL_TITLE) << endl; +// return ( ascending ? -1 : 1 ); // <0 means this is smaller then i +// } +// else + return TQListViewItem::compare( i, col, ascending ); +} + + diff --git a/src/app/ActionMan/useractionlistview.h b/src/app/ActionMan/useractionlistview.h new file mode 100644 index 0000000..b423637 --- /dev/null +++ b/src/app/ActionMan/useractionlistview.h @@ -0,0 +1,81 @@ +// +// C++ Interface: useractionlistview +// +// Description: +// +// +// Author: Jonas Bähr, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef USERACTIONLISTVIEW_H +#define USERACTIONLISTVIEW_H + +#include <tdelistview.h> + +class KrAction; +class TQString; +class UserActionListViewItem; +class TQDomDocument; + +/** + * @author Jonas Bähr + */ +class UserActionListView : public TDEListView { +public: + UserActionListView( TQWidget* parent = 0, const char* name = 0 ); + ~UserActionListView(); + virtual TQSize sizeHint() const; + + void update(); + void update( KrAction* action ); + UserActionListViewItem* insertAction( KrAction* action ); + + KrAction* currentAction() const; + void setCurrentAction( const KrAction* ); + + TQDomDocument dumpSelectedActions( TQDomDocument* mergeDoc = 0 ) const; + + void removeSelectedActions(); + + /** + * makes the first action in the list current + */ + void setFirstActionCurrent(); + + /** + * makes @e item current and ensures its visibility + */ + virtual void setCurrentItem( TQListViewItem* item ); + +protected: + TQListViewItem* findCategoryItem( const TQString& category ); + UserActionListViewItem* findActionItem( const KrAction* action ); +}; + + +/** + * @author Jonas Bähr + */ +class UserActionListViewItem : public TDEListViewItem { +public: + UserActionListViewItem( TQListView* view, KrAction* action ); + UserActionListViewItem( TQListViewItem* item, KrAction* action ); + ~UserActionListViewItem(); + + void setAction( KrAction* action ); + KrAction* action() const; + void update(); + + /** + * This reimplements TQt's compare-function in order to have categories on the top of the list + */ + int compare ( TQListViewItem * i, int col, bool ascending ) const; + +private: + KrAction* _action; +}; + + +#endif //USERACTIONLISTVIEW_H diff --git a/src/app/ActionMan/useractionpage.cpp b/src/app/ActionMan/useractionpage.cpp new file mode 100644 index 0000000..065b087 --- /dev/null +++ b/src/app/ActionMan/useractionpage.cpp @@ -0,0 +1,317 @@ +// +// C++ Implementation: useractionpage +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "useractionpage.h" + +#include <tqsplitter.h> +#include <tqlayout.h> +#include <tqtoolbutton.h> +#include <tqtooltip.h> +#include <klineedit.h> +#include <tdemessagebox.h> +#include <tdefiledialog.h> +#include <kiconloader.h> +#include <tdelocale.h> +#include <kclipboard.h> + +#include "actionproperty.h" +#include "useractionlistview.h" +#include "../UserMenu/usermenu.h" //FIXME this should not be needed here! +#include "../UserAction/useraction.h" +#include "../UserAction/kraction.h" +#include "../krusader.h" + +#define ICON(N) TDEGlobal::iconLoader()->loadIcon(N, TDEIcon::Toolbar) +//This is the filter in the KFileDialog of Import/Export: +static const char* FILE_FILTER = I18N_NOOP("*.xml|xml-files\n*|all files"); + + +UserActionPage::UserActionPage( TQWidget* parent ) + : TQWidget( parent, "UserActionPage" ) +{ + TQVBoxLayout* layout = new TQVBoxLayout( this, 0, 6, "UserActionPageLayout" ); // 0px margin, 6px item-spacing + + // ======== pseudo-toolbar start ======== + TQHBoxLayout* toolbarLayout = new TQHBoxLayout( layout, 0, 0 ); // neither margin nor spacing for the toolbar with autoRaise + + newButton = new TQToolButton( this, "newButton" ); + newButton->setPixmap( ICON("document-new") ); + newButton->setAutoRaise(true); + TQToolTip::add( newButton, i18n("Create new useraction") ); + + importButton = new TQToolButton( this, "importButton" ); + importButton->setPixmap( ICON("fileimport") ); + importButton->setAutoRaise(true); + TQToolTip::add( importButton, i18n("Import useractions") ); + + exportButton = new TQToolButton( this, "exportButton" ); + exportButton->setPixmap( ICON("fileexport") ); + exportButton->setAutoRaise(true); + TQToolTip::add( exportButton, i18n("Export useractions") ); + + copyButton = new TQToolButton( this, "copyButton" ); + copyButton->setPixmap( ICON("edit-copy") ); + copyButton->setAutoRaise(true); + TQToolTip::add( copyButton, i18n("Copy useractions to clipboard") ); + + pasteButton = new TQToolButton( this, "pasteButton" ); + pasteButton->setPixmap( ICON("edit-paste") ); + pasteButton->setAutoRaise(true); + TQToolTip::add( pasteButton, i18n("Paste useractions from clipboard") ); + + removeButton = new TQToolButton( this, "removeButton" ); + removeButton->setPixmap( ICON("edit-delete") ); + removeButton->setAutoRaise(true); + TQToolTip::add( removeButton, i18n("Delete selected useractions") ); + + toolbarLayout->addWidget( newButton ); + toolbarLayout->addWidget( importButton ); + toolbarLayout->addWidget( exportButton ); + toolbarLayout->addWidget( copyButton ); + toolbarLayout->addWidget( pasteButton ); + toolbarLayout->addSpacing( 6 ); // 6 pixel nothing + toolbarLayout->addWidget( removeButton ); + toolbarLayout->addStretch( 1000 ); // some very large stretch-factor + // ======== pseudo-toolbar end ======== +/* This seems obsolete now! + // Display some help + KMessageBox::information( this, // parent + i18n( "When you apply changes to an action, the modifications " + "become available in the current session immediately.\n" + "When closing ActionMan, you will be asked to save the changes permanently." + ), + TQString(), // caption + "show UserAction help" //dontShowAgainName for the config + ); +*/ + TQSplitter *split = new TQSplitter( this, "useractionpage splitter"); + layout->addWidget( split, 1000 ); // again a very large stretch-factor to fix the height of the toolbar + + actionTree = new UserActionListView( split, "actionTree" ); + actionProperties = new ActionProperty( split, "actionProperties" ); + actionProperties->setEnabled( false ); // if there are any actions in the list, the first is displayed and this widget is enabled + + connect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), TQ_SLOT( slotChangeCurrent() ) ); + connect( newButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotNewAction() ) ); + connect( removeButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotRemoveAction() ) ); + connect( importButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotImport() ) ); + connect( exportButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotExport() ) ); + connect( copyButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotToClip() ) ); + connect( pasteButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotFromClip() ) ); + + // forwards the changed signal of the properties + connect ( actionProperties, TQ_SIGNAL( changed() ), TQ_SIGNAL( changed() ) ); + + actionTree->setFirstActionCurrent(); + actionTree->setFocus(); +} + +UserActionPage::~UserActionPage() +{ +} + +bool UserActionPage::continueInSpiteOfChanges() { + if ( ! actionProperties->isModified() ) + return true; + + int answer = KMessageBox::questionYesNoCancel( this, + i18n("The current action has been modified. Do you want to apply these changes?") + ); + if ( answer == KMessageBox::Cancel ) { + disconnect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), this, TQ_SLOT( slotChangeCurrent() ) ); + actionTree->setCurrentAction( actionProperties->action() ); + connect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), TQ_SLOT( slotChangeCurrent() ) ); + return false; + } + if ( answer == KMessageBox::Yes ) { + if ( ! actionProperties->validProperties() ) { + disconnect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), this, TQ_SLOT( slotChangeCurrent() ) ); + actionTree->setCurrentAction( actionProperties->action() ); + connect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), TQ_SLOT( slotChangeCurrent() ) ); + return false; + } + slotUpdateAction(); + } // if Yes + return true; +} + +void UserActionPage::slotChangeCurrent() { + if ( ! continueInSpiteOfChanges() ) + return; + + KrAction* action = actionTree->currentAction(); + if ( action ) { + actionProperties->setEnabled( true ); + // the discinct name is used as ID it is not allowd to change it afterwards because it is may referenced anywhere else + actionProperties->leDistinctName->setEnabled( false ); + actionProperties->updateGUI( action ); + } + else { + // If the current item in the tree is no action (i.e. a cathegory), disable the properties + actionProperties->clear(); + actionProperties->setEnabled( false ); + } + emit applied(); // to disable the apply-button +} + + +void UserActionPage::slotUpdateAction() { + // check that we have a command line, title and a name + if ( ! actionProperties->validProperties() ) + return; + + if ( actionProperties->leDistinctName->isEnabled() ) { + // := new entry + KrAction* action = new KrAction( krApp->actionCollection(), actionProperties->leDistinctName->text().latin1() ); + krUserAction->addKrAction( action ); + actionProperties->updateAction( action ); + UserActionListViewItem* item = actionTree->insertAction( action ); + actionTree->setCurrentItem( item ); + krApp->userMenu->update(); + } + else { // := edit an existing + actionProperties->updateAction(); + actionTree->update( actionProperties->action() ); // update the listviewitem as well... + } + apply(); +} + + +void UserActionPage::slotNewAction() { + if ( continueInSpiteOfChanges() ) { + actionTree->clearSelection(); // else the user may think that he is overwriting the selected action + actionProperties->clear(); + actionProperties->setEnabled( true ); // it may be disabled because the tree has the focus on a category + actionProperties->leDistinctName->setEnabled( true ); + actionProperties->leDistinctName->setFocus(); + } +} + +void UserActionPage::slotRemoveAction() { + if ( ! dynamic_cast<UserActionListViewItem*>( actionTree->currentItem() ) ) + return; + + int messageDelete = KMessageBox::warningContinueCancel ( this, //parent + i18n("Are you sure that you want to remove all selected actions?"), //text + i18n("Remove selected actions?"), //caption + i18n("Remove"), //Label for the continue-button + "Confirm Remove UserAction", //dontAskAgainName (for the config-file) + KMessageBox::Dangerous) ; + + if ( messageDelete != KMessageBox::Continue ) + return; + + actionTree->removeSelectedActions(); + + apply(); +} + +void UserActionPage::slotImport() { + TQString filename = KFileDialog::getOpenFileName(TQString(), i18n(FILE_FILTER), this); + if ( filename.isEmpty() ) + return; + + UserAction::KrActionList newActions; + krUserAction->readFromFile( filename, UserAction::renameDoublicated, &newActions ); + for ( KrAction* action = newActions.first(); action; action = newActions.next() ) + actionTree->insertAction( action ); + + if ( newActions.count() > 0 ) { + apply(); + } +} + +void UserActionPage::slotExport() { + if ( ! dynamic_cast<UserActionListViewItem*>( actionTree->currentItem() ) ) + return; + + TQString filename = KFileDialog::getSaveFileName(TQString(), i18n(FILE_FILTER), this); + if ( filename.isEmpty() ) + return; + + TQDomDocument doc = TQDomDocument( ACTION_DOCTYPE ); + TQFile file( filename ); + int answer = 0; + if( file.open( IO_ReadOnly ) ) { // getting here, means the file already exists an can be read + if( doc.setContent( &file ) ) // getting here means the file exists and already contains an UserAction-XML-tree + answer = KMessageBox::warningYesNoCancel( this, //parent + i18n("This file already contains some useractions.\nDo you want to overwrite it or should it be merged with the selected actions?"), //text + i18n("Overwrite or merge?"), //caption + i18n("Overwrite"), //label for Yes-Button + i18n("Merge") //label for No-Button + ); + file.close(); + } + if ( answer == 0 && file.exists() ) + answer = KMessageBox::warningContinueCancel( this, //parent + i18n("This file already exists. Do you want to overwrite it?"), //text + i18n("Overwrite existing file?"), //caption + i18n("Overwrite") //label for Continue-Button + ); + + if ( answer == KMessageBox::Cancel ) + return; + + if ( answer == KMessageBox::No ) // that means the merge-button + doc = actionTree->dumpSelectedActions( &doc ); // merge + else // Yes or Continue means overwrite + doc = actionTree->dumpSelectedActions(); + + bool success = UserAction::writeToFile( doc, filename ); + if ( ! success ) + KMessageBox::error( this, + i18n("Can't open %1 for writing!\nNothing exported.").arg(filename), + i18n("Export failed!") + ); +} + +void UserActionPage::slotToClip() { + if ( ! dynamic_cast<UserActionListViewItem*>( actionTree->currentItem() ) ) + return; + + TQDomDocument doc = actionTree->dumpSelectedActions(); + TDEApplication::clipboard()->setText( doc.toString() ); +} + +void UserActionPage::slotFromClip() { + TQDomDocument doc( ACTION_DOCTYPE ); + if ( doc.setContent( TDEApplication::clipboard()->text() ) ) { + TQDomElement root = doc.documentElement(); + UserAction::KrActionList newActions; + krUserAction->readFromElement( root, UserAction::renameDoublicated, &newActions ); + for ( KrAction* action = newActions.first(); action; action = newActions.next() ) + actionTree->insertAction( action ); + if ( newActions.count() > 0 ) { + apply(); + } + } // if ( doc.setContent ) +} + +bool UserActionPage::readyToQuit() { + // Check if the current UserAction has changed + if ( ! continueInSpiteOfChanges() ) + return false; + + krUserAction->writeActionFile(); + return true; +} + +void UserActionPage::apply() { + krUserAction->writeActionFile(); + emit applied(); +} + +void UserActionPage::applyChanges() { + slotUpdateAction(); +} + + +#include "useractionpage.moc" diff --git a/src/app/ActionMan/useractionpage.h b/src/app/ActionMan/useractionpage.h new file mode 100644 index 0000000..2a117f6 --- /dev/null +++ b/src/app/ActionMan/useractionpage.h @@ -0,0 +1,74 @@ +// +// C++ Interface: useractionpage +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef USERACTIONPAGE_H +#define USERACTIONPAGE_H + +#include <tqwidget.h> + +class UserActionListView; +class ActionProperty; +class TQToolButton; + +/** + * @author Jonas Bähr +*/ +class UserActionPage : public TQWidget { +TQ_OBJECT + +public: + UserActionPage( TQWidget* parent ); + ~UserActionPage(); + + /** + * Be sure to call this function before you delete this page!! + * @return true if this page can be closed + */ + bool readyToQuit(); + + void applyChanges(); + +signals: + void changed(); ///< emited on changes to an action (used to enable the apply-button) + void applied(); ///< emited when changes are applied to an action (used to disable the apply-button) + +private: + /** + * If there are modifications in the property-widget, the user is asked + * what to do. Apply, discard or continue editing. In the first case, + * saving is done in this function. + * @return true if a new action can be loaded in the property-widget. + */ + bool continueInSpiteOfChanges(); + /** + * applyes all changes by writing the actionfile and emits "applied" + */ + void apply(); + + //bool _modified; ///< true if the action-tree was changed (= changes were applied to an action) + UserActionListView *actionTree; + ActionProperty *actionProperties; + TQToolButton *importButton, *exportButton; + TQToolButton *copyButton, *pasteButton; + TQToolButton *removeButton, *newButton; + +private slots: + void slotChangeCurrent(); //loads a new action into the detail-view + void slotUpdateAction(); //updates the action to the xml-file + void slotNewAction(); + void slotRemoveAction(); + void slotImport(); + void slotExport(); + void slotToClip(); + void slotFromClip(); +}; + +#endif //USERACTIONPAGE_H |