Changeset View
Changeset View
Standalone View
Standalone View
krusader/UserAction/kraction.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 94 | } else { | |||
---|---|---|---|---|---|
95 | // create stdout | 95 | // create stdout | ||
96 | mainLayout->addWidget(new QLabel(i18n("Output"))); | 96 | mainLayout->addWidget(new QLabel(i18n("Output"))); | ||
97 | _stdout = new KTextEdit; | 97 | _stdout = new KTextEdit; | ||
98 | _stdout->setReadOnly(true); | 98 | _stdout->setReadOnly(true); | ||
99 | mainLayout->addWidget(_stdout); | 99 | mainLayout->addWidget(_stdout); | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | _currentTextEdit = _stdout; | 102 | _currentTextEdit = _stdout; | ||
103 | connect(_stdout, SIGNAL(textChanged()), SLOT(currentTextEditChanged())); | 103 | connect(_stdout, &KTextEdit::textChanged, this, &KrActionProcDlg::currentTextEditChanged); | ||
104 | if (_stderr) | 104 | if (_stderr) | ||
105 | connect(_stderr, SIGNAL(textChanged()), SLOT(currentTextEditChanged())); | 105 | connect(_stderr, &KTextEdit::textChanged, this, &KrActionProcDlg::currentTextEditChanged); | ||
106 | 106 | | |||
107 | KConfigGroup group(krConfig, "UserActions"); | 107 | KConfigGroup group(krConfig, "UserActions"); | ||
108 | normalFont = group.readEntry("Normal Font", _UserActions_NormalFont); | 108 | normalFont = group.readEntry("Normal Font", _UserActions_NormalFont); | ||
109 | fixedFont = group.readEntry("Fixed Font", _UserActions_FixedFont); | 109 | fixedFont = group.readEntry("Fixed Font", _UserActions_FixedFont); | ||
110 | bool startupState = group.readEntry("Use Fixed Font", _UserActions_UseFixedFont); | 110 | bool startupState = group.readEntry("Use Fixed Font", _UserActions_UseFixedFont); | ||
111 | toggleFixedFont(startupState); | 111 | toggleFixedFont(startupState); | ||
112 | 112 | | |||
113 | QHBoxLayout *hbox = new QHBoxLayout; | 113 | QHBoxLayout *hbox = new QHBoxLayout; | ||
Show All 13 Lines | |||||
127 | KGuiItem::assign(saveAsButton, KStandardGuiItem::saveAs()); | 127 | KGuiItem::assign(saveAsButton, KStandardGuiItem::saveAs()); | ||
128 | buttonBox->addButton(saveAsButton, QDialogButtonBox::ActionRole); | 128 | buttonBox->addButton(saveAsButton, QDialogButtonBox::ActionRole); | ||
129 | 129 | | |||
130 | killButton = new QPushButton(i18n("Kill")); | 130 | killButton = new QPushButton(i18n("Kill")); | ||
131 | killButton->setToolTip(i18n("Kill the running process")); | 131 | killButton->setToolTip(i18n("Kill the running process")); | ||
132 | killButton->setDefault(true); | 132 | killButton->setDefault(true); | ||
133 | buttonBox->addButton(killButton, QDialogButtonBox::ActionRole); | 133 | buttonBox->addButton(killButton, QDialogButtonBox::ActionRole); | ||
134 | 134 | | |||
135 | connect(killButton, SIGNAL(clicked()), this, SIGNAL(killClicked())); | 135 | connect(killButton, &QPushButton::clicked, this, &KrActionProcDlg::killClicked); | ||
136 | connect(saveAsButton, SIGNAL(clicked()), this, SLOT(slotSaveAs())); | 136 | connect(saveAsButton, &QPushButton::clicked, this, &KrActionProcDlg::slotSaveAs); | ||
137 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | 137 | connect(buttonBox, &QDialogButtonBox::rejected, this, &KrActionProcDlg::reject); | ||
138 | connect(useFixedFont, SIGNAL(toggled(bool)), SLOT(toggleFixedFont(bool))); | 138 | connect(useFixedFont, &QCheckBox::toggled, this, &KrActionProcDlg::toggleFixedFont); | ||
139 | 139 | | |||
140 | resize(sizeHint() * 2); | 140 | resize(sizeHint() * 2); | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | void KrActionProcDlg::addStderr(const QString& str) | 143 | void KrActionProcDlg::addStderr(const QString& str) | ||
144 | { | 144 | { | ||
145 | if (_stderr) | 145 | if (_stderr) | ||
146 | _stderr->append(str); | 146 | _stderr->append(str); | ||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | 274 | && MAIN_VIEW->terminalDock()->isInitialised()) { //send the commandline contents to the terminal emulator | |||
279 | } | 279 | } | ||
280 | MAIN_VIEW->terminalDock()->sendInput(cmd + '\n'); | 280 | MAIN_VIEW->terminalDock()->sendInput(cmd + '\n'); | ||
281 | deleteLater(); | 281 | deleteLater(); | ||
282 | } | 282 | } | ||
283 | else { // will start a new process | 283 | else { // will start a new process | ||
284 | _proc = new KProcess(this); | 284 | _proc = new KProcess(this); | ||
285 | _proc->clearProgram(); // this clears the arglist too | 285 | _proc->clearProgram(); // this clears the arglist too | ||
286 | _proc->setWorkingDirectory(workingDir); | 286 | _proc->setWorkingDirectory(workingDir); | ||
287 | connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), | 287 | connect(_proc, QOverload<int, QProcess::ExitStatus>::of(&KProcess::finished), this, &KrActionProc::processExited); | ||
288 | this, SLOT(processExited(int,QProcess::ExitStatus))); | | |||
289 | 288 | | |||
290 | if (_action->execType() == KrAction::Normal || _action->execType() == KrAction::Terminal) { // not collect output | 289 | if (_action->execType() == KrAction::Normal || _action->execType() == KrAction::Terminal) { // not collect output | ||
291 | if (_action->execType() == KrAction::Terminal) { // run in terminal | 290 | if (_action->execType() == KrAction::Terminal) { // run in terminal | ||
292 | KConfigGroup group(krConfig, "UserActions"); | 291 | KConfigGroup group(krConfig, "UserActions"); | ||
293 | QString term = group.readEntry("Terminal", _UserActions_Terminal); | 292 | QString term = group.readEntry("Terminal", _UserActions_Terminal); | ||
294 | QStringList termArgs = KShell::splitArgs(term, KShell::TildeExpand); | 293 | QStringList termArgs = KShell::splitArgs(term, KShell::TildeExpand); | ||
295 | if (termArgs.isEmpty()) { | 294 | if (termArgs.isEmpty()) { | ||
296 | KMessageBox::error(0, i18nc("Arg is a string containing the bad quoting.", | 295 | KMessageBox::error(0, i18nc("Arg is a string containing the bad quoting.", | ||
Show All 17 Lines | |||||
314 | } | 313 | } | ||
315 | else { // collect output | 314 | else { // collect output | ||
316 | bool separateStderr = false; | 315 | bool separateStderr = false; | ||
317 | if (_action->execType() == KrAction::CollectOutputSeparateStderr) | 316 | if (_action->execType() == KrAction::CollectOutputSeparateStderr) | ||
318 | separateStderr = true; | 317 | separateStderr = true; | ||
319 | _output = new KrActionProcDlg(_action->text(), separateStderr); | 318 | _output = new KrActionProcDlg(_action->text(), separateStderr); | ||
320 | // connect the output to the dialog | 319 | // connect the output to the dialog | ||
321 | _proc->setOutputChannelMode(KProcess::SeparateChannels); | 320 | _proc->setOutputChannelMode(KProcess::SeparateChannels); | ||
322 | connect(_proc, SIGNAL(readyReadStandardError()), SLOT(addStderr())); | 321 | connect(_proc, &KProcess::readyReadStandardError, this, &KrActionProc::addStderr); | ||
323 | connect(_proc, SIGNAL(readyReadStandardOutput()), SLOT(addStdout())); | 322 | connect(_proc, &KProcess::readyReadStandardOutput, this, &KrActionProc::addStdout); | ||
324 | connect(_output, SIGNAL(killClicked()), this, SLOT(kill())); | 323 | connect(_output, &KrActionProcDlg::killClicked, this, &KrActionProc::kill); | ||
325 | _output->show(); | 324 | _output->show(); | ||
326 | 325 | | |||
327 | if (!_action->user().isEmpty()) { | 326 | if (!_action->user().isEmpty()) { | ||
328 | // "-t" is necessary that kdesu displays the terminal-output of the command | 327 | // "-t" is necessary that kdesu displays the terminal-output of the command | ||
329 | cmd = KrServices::quote(KDESU_PATH) + | 328 | cmd = KrServices::quote(KDESU_PATH) + | ||
330 | " -t -u " + _action->user() + | 329 | " -t -u " + _action->user() + | ||
331 | " -c " + KrServices::quote(cmd); | 330 | " -c " + KrServices::quote(cmd); | ||
332 | } | 331 | } | ||
Show All 31 Lines | |||||
364 | 363 | | |||
365 | // KrAction | 364 | // KrAction | ||
366 | KrAction::KrAction(KActionCollection *parent, QString name) : QAction((QObject *)parent) | 365 | KrAction::KrAction(KActionCollection *parent, QString name) : QAction((QObject *)parent) | ||
367 | { | 366 | { | ||
368 | _actionCollection = parent; | 367 | _actionCollection = parent; | ||
369 | setObjectName(name); | 368 | setObjectName(name); | ||
370 | parent->addAction(name, this); | 369 | parent->addAction(name, this); | ||
371 | 370 | | |||
372 | connect(this, SIGNAL(triggered()), this, SLOT(exec())); | 371 | connect(this, &KrAction::triggered, this, &KrAction::exec); | ||
373 | } | 372 | } | ||
374 | 373 | | |||
375 | KrAction::~KrAction() | 374 | KrAction::~KrAction() | ||
376 | { | 375 | { | ||
377 | foreach(QWidget *w, associatedWidgets()) | 376 | foreach(QWidget *w, associatedWidgets()) | ||
378 | w->removeAction(this); | 377 | w->removeAction(this); | ||
379 | krUserAction->removeKrAction(this); // Importent! Else Krusader will crash when writing the actions to file | 378 | krUserAction->removeKrAction(this); // Importent! Else Krusader will crash when writing the actions to file | ||
380 | } | 379 | } | ||
▲ Show 20 Lines • Show All 320 Lines • Show Last 20 Lines |