Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
KDE Base Apps
Commits
173282d2
Commit
173282d2
authored
Sep 13, 2012
by
Dawit Alemayehu
Browse files
Fixed the shell command plugin to show the selected items when launched.
BUG: 271126 FIXED-IN: 4.9.2 REVIEW: 106440
parent
1e45cb90
Changes
2
Hide whitespace changes
Inline
Side-by-side
konq-plugins/shellcmdplugin/kshellcmddialog.cpp
View file @
173282d2
...
...
@@ -58,7 +58,7 @@ KShellCommandDialog::KShellCommandDialog(const QString& title, const QString& co
box
->
addWidget
(
m_shell
,
1
);
QHBoxLayout
*
hlayout
=
new
QHBoxLayout
();
box
->
add
Item
(
hlayout
);
box
->
add
Layout
(
hlayout
);
hlayout
->
addWidget
(
cancelButton
);
hlayout
->
addWidget
(
closeButton
);
...
...
konq-plugins/shellcmdplugin/kshellcmdplugin.cpp
View file @
173282d2
...
...
@@ -29,6 +29,7 @@
#include <kpluginfactory.h>
#include <kauthorized.h>
#include <kio/netaccess.h>
#include <kparts/fileinfoextension.h>
KShellCmdPlugin
::
KShellCmdPlugin
(
QObject
*
parent
,
const
QVariantList
&
)
:
KParts
::
Plugin
(
parent
)
...
...
@@ -45,50 +46,50 @@ KShellCmdPlugin::KShellCmdPlugin( QObject* parent, const QVariantList & )
void
KShellCmdPlugin
::
slotExecuteShellCommand
()
{
KParts
::
ReadOnlyPart
*
part
=
dynamic_cast
<
KParts
::
ReadOnlyPart
*>
(
parent
());
if
(
!
part
)
{
KParts
::
ReadOnlyPart
*
part
=
qobject_cast
<
KParts
::
ReadOnlyPart
*>
(
parent
());
if
(
!
part
)
{
KMessageBox
::
sorry
(
0L
,
i18n
(
"KShellCmdPlugin::slotExecuteShellCommand: Program error, please report a bug."
));
return
;
}
KUrl
url
=
KIO
::
NetAccess
::
mostLocalUrl
(
part
->
url
(),
NULL
);
if
(
!
url
.
isLocalFile
()
)
{
if
(
!
url
.
isLocalFile
())
{
KMessageBox
::
sorry
(
part
->
widget
(),
i18n
(
"Executing shell commands works only on local directories."
));
return
;
}
QString
path
;
#if 0 // to be ported if still needed
if ( part->currentItem() )
{
// Putting the complete path to the selected file isn't really necessary,
// since we'll cd to the directory first. But we do need to get the
// complete relative path.
path = KUrl::relativePath( url.path(),
part->currentItem()->url().path() );
KParts
::
FileInfoExtension
*
ext
=
KParts
::
FileInfoExtension
::
childObject
(
part
);
if
(
ext
&&
ext
->
hasSelection
()
&&
(
ext
->
supportedQueryModes
()
&
KParts
::
FileInfoExtension
::
SelectedItems
))
{
KFileItemList
list
=
ext
->
queryFor
(
KParts
::
FileInfoExtension
::
SelectedItems
);
QStringList
fileNames
;
Q_FOREACH
(
const
KFileItem
&
item
,
list
)
{
fileNames
<<
item
.
name
();
}
path
=
KShell
::
joinArgs
(
fileNames
);
}
else
#endif
{
path
=
url
.
toLocalFile
();
if
(
path
.
isEmpty
())
{
path
=
KShell
::
quoteArg
(
url
.
toLocalFile
());
}
bool
ok
;
QString
cmd
=
KInputDialog
::
getText
(
i18nc
(
"@title:window"
,
"Execute Shell Command"
),
i18n
(
"Execute shell command in current directory:"
),
path
,
&
ok
,
part
->
widget
());
if
(
ok
)
{
QString
exeCmd
;
exeCmd
=
QLatin1String
(
"cd "
);
exeCmd
+=
KShell
::
quoteArg
(
part
->
url
().
path
());
exeCmd
+=
QLatin1String
(
"; "
);
exeCmd
+=
cmd
;
KShellCommandDialog
*
dlg
=
new
KShellCommandDialog
(
i18n
(
"Output from command:
\"
%1
\"
"
,
cmd
),
exeCmd
,
part
->
widget
(),
true
);
dlg
->
resize
(
500
,
300
);
dlg
->
executeCommand
();
delete
dlg
;
}
bool
ok
;
QString
cmd
=
KInputDialog
::
getText
(
i18nc
(
"@title:window"
,
"Execute Shell Command"
),
i18n
(
"Execute shell command in current directory:"
),
KShell
::
quoteArg
(
path
),
&
ok
,
part
->
widget
()
);
if
(
ok
)
{
QString
chDir
;
chDir
=
"cd "
;
chDir
+=
KShell
::
quoteArg
(
part
->
url
().
path
());
chDir
+=
"; "
;
chDir
+=
cmd
;
KShellCommandDialog
*
shellCmdDialog
=
new
KShellCommandDialog
(
i18n
(
"Output from command:
\"
%1
\"
"
,
cmd
),
chDir
,
part
->
widget
(),
true
);
shellCmdDialog
->
resize
(
500
,
300
);
shellCmdDialog
->
executeCommand
();
delete
shellCmdDialog
;
}
}
K_PLUGIN_FACTORY
(
KonqShellCmdPluginFactory
,
registerPlugin
<
KShellCmdPlugin
>
();)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment