File indexing completed on 2024-10-06 07:58:40

0001 /*
0002  *   SPDX-FileCopyrightText: 2000 Matthias Elter <elter@kde.org>
0003  *   SPDX-FileCopyrightText: 2008 Laurent Montel <montel@kde.org>
0004  *
0005  *   SPDX-License-Identifier: GPL-2.0-or-later
0006  *
0007  */
0008 
0009 #include "basictab.h"
0010 
0011 #include <QCheckBox>
0012 #include <QGridLayout>
0013 #include <QGroupBox>
0014 #include <QLabel>
0015 #include <QVBoxLayout>
0016 
0017 #include <KConfigGroup>
0018 #include <KDesktopFile>
0019 #include <KIconButton>
0020 #include <KKeySequenceWidget>
0021 #include <KLocalizedString>
0022 #include <KShell>
0023 #include <KUrlRequester>
0024 #include <QLineEdit>
0025 
0026 #include "globalaccel.h"
0027 
0028 #include "klinespellchecking.h"
0029 #include "menuinfo.h"
0030 
0031 BasicTab::BasicTab(QWidget *parent)
0032     : QTabWidget(parent)
0033 {
0034     initGeneralTab();
0035     initAdvancedTab();
0036     initConnections();
0037 
0038     setDocumentMode(true);
0039 
0040     slotDisableAction();
0041 }
0042 
0043 void BasicTab::initGeneralTab()
0044 {
0045     // general tab
0046     QWidget *generalTab = new QWidget();
0047     QGridLayout *generalTabLayout = new QGridLayout(generalTab);
0048     generalTab->setAcceptDrops(false);
0049 
0050     // name
0051     _nameLabel = new QLabel(i18n("&Name:"));
0052     generalTabLayout->addWidget(_nameLabel, 0, 0);
0053     _nameEdit = new QLineEdit();
0054     _nameEdit->setAcceptDrops(false);
0055     _nameEdit->setClearButtonEnabled(true);
0056     _nameLabel->setBuddy(_nameEdit);
0057     generalTabLayout->addWidget(_nameEdit, 0, 1, 1, 1);
0058 
0059     // description
0060     _descriptionLabel = new QLabel(i18n("&Description:"));
0061     generalTabLayout->addWidget(_descriptionLabel, 1, 0);
0062     _descriptionEdit = new KLineSpellChecking();
0063     _descriptionEdit->setAcceptDrops(false);
0064     _descriptionLabel->setBuddy(_descriptionEdit);
0065     generalTabLayout->addWidget(_descriptionEdit, 1, 1, 1, 1);
0066 
0067     // comment
0068     _commentLabel = new QLabel(i18n("&Comment:"));
0069     generalTabLayout->addWidget(_commentLabel, 2, 0);
0070     _commentEdit = new KLineSpellChecking();
0071     _commentEdit->setAcceptDrops(false);
0072     _commentLabel->setBuddy(_commentEdit);
0073     generalTabLayout->addWidget(_commentEdit, 2, 1, 1, 2);
0074 
0075     // environment variables
0076     _envarsLabel = new QLabel(i18nc("@label:textfield", "Environment Variables:"));
0077     generalTabLayout->addWidget(_envarsLabel, 3, 0);
0078     _envarsEdit = new QLineEdit();
0079     _envarsLabel->setBuddy(_envarsEdit);
0080     generalTabLayout->addWidget(_envarsEdit, 3, 1, 1, 2);
0081 
0082     // command
0083     _programLabel = new QLabel(i18nc("@label:textbox the name or path to a command-line program", "Program:"));
0084     generalTabLayout->addWidget(_programLabel, 4, 0);
0085     _programEdit = new KUrlRequester();
0086     _programEdit->lineEdit()->setAcceptDrops(false);
0087     _programLabel->setBuddy(_programEdit);
0088     generalTabLayout->addWidget(_programEdit, 4, 1, 1, 2);
0089 
0090     _argsLabel = new QLabel(i18nc("@label:textfield", "Command-Line Arguments:"));
0091     generalTabLayout->addWidget(_argsLabel, 5, 0);
0092     _argsEdit = new QLineEdit();
0093     _argsEdit->setWhatsThis(
0094         i18n("Following the command, you can have several place holders which will be replaced "
0095              "with the actual values when the actual program is run:\n"
0096              "%f - a single file name\n"
0097              "%F - a list of files; use for applications that can open several local files at once\n"
0098              "%u - a single URL\n"
0099              "%U - a list of URLs\n"
0100              "%d - the folder of the file to open\n"
0101              "%D - a list of folders\n"
0102              "%i - the icon\n"
0103              "%m - the mini-icon\n"
0104              "%c - the caption"));
0105     _argsLabel->setBuddy(_argsEdit);
0106     generalTabLayout->addWidget(_argsEdit, 5, 1, 1, 2);
0107 
0108     // launch feedback
0109     _launchCB = new QCheckBox(i18n("Enable &launch feedback"));
0110     generalTabLayout->addWidget(_launchCB, 6, 0, 1, 3);
0111 
0112     // KDE visibility
0113     _onlyShowInKdeCB = new QCheckBox(i18n("Only show when logged into a Plasma session"));
0114     generalTabLayout->addWidget(_onlyShowInKdeCB, 7, 0, 1, 3);
0115 
0116     // hidden entry
0117     _hiddenEntryCB = new QCheckBox(i18n("Hidden entry"));
0118     _hiddenEntryCB->hide();
0119     generalTabLayout->addWidget(_hiddenEntryCB, 8, 0, 1, 3);
0120 
0121     // icon
0122     _iconButton = new KIconButton();
0123     _iconButton->setFixedSize(56, 56);
0124     _iconButton->setIconSize(32);
0125     generalTabLayout->addWidget(_iconButton, 0, 2, 2, 1);
0126     generalTabLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 8, 0, 1, 3);
0127 
0128     // add the general group
0129     addTab(generalTab, i18n("General"));
0130 }
0131 
0132 void BasicTab::initAdvancedTab()
0133 {
0134     // advanced tab
0135     QWidget *advancedTab = new QWidget();
0136     QVBoxLayout *advancedTabLayout = new QVBoxLayout(advancedTab);
0137 
0138     // work path
0139     _workPathGroup = new QGroupBox();
0140     QHBoxLayout *workPathGroupLayout = new QHBoxLayout(_workPathGroup);
0141     _pathLabel = new QLabel(i18n("&Work path:"));
0142     workPathGroupLayout->addWidget(_pathLabel);
0143     _pathEdit = new KUrlRequester();
0144     _pathEdit->setMode(KFile::Directory | KFile::LocalOnly);
0145     _pathEdit->lineEdit()->setAcceptDrops(false);
0146     _pathLabel->setBuddy(_pathEdit);
0147     workPathGroupLayout->addWidget(_pathEdit);
0148     advancedTabLayout->addWidget(_workPathGroup);
0149 
0150     // terminal CB
0151     _terminalGroup = new QGroupBox();
0152     QVBoxLayout *terminalGroupLayout = new QVBoxLayout(_terminalGroup);
0153     _terminalCB = new QCheckBox(i18n("Run in term&inal"));
0154     terminalGroupLayout->addWidget(_terminalCB);
0155     // terminal options
0156     QWidget *terminalOptionsGroup = new QWidget();
0157     QHBoxLayout *terminalOptionsGroupLayout = new QHBoxLayout(terminalOptionsGroup);
0158     _terminalOptionsLabel = new QLabel(i18n("Terminal &options:"));
0159     terminalOptionsGroupLayout->addWidget(_terminalOptionsLabel);
0160     _terminalOptionsEdit = new QLineEdit();
0161     _terminalOptionsEdit->setClearButtonEnabled(true);
0162     _terminalOptionsEdit->setAcceptDrops(false);
0163     _terminalOptionsEdit->setEnabled(false);
0164     _terminalOptionsLabel->setBuddy(_terminalOptionsEdit);
0165     terminalOptionsGroupLayout->addWidget(_terminalOptionsEdit);
0166     terminalGroupLayout->addWidget(terminalOptionsGroup);
0167     advancedTabLayout->addWidget(_terminalGroup);
0168 
0169     // user name CB
0170     _userGroup = new QGroupBox();
0171     QVBoxLayout *userGroupLayout = new QVBoxLayout(_userGroup);
0172     _userCB = new QCheckBox(i18n("&Run as a different user"));
0173     userGroupLayout->addWidget(_userCB);
0174     // user name
0175     QWidget *userNameGroup = new QWidget();
0176     QHBoxLayout *userNameGroupLayout = new QHBoxLayout(userNameGroup);
0177     _userNameLabel = new QLabel(i18n("&Username:"));
0178     userNameGroupLayout->addWidget(_userNameLabel);
0179     _userNameEdit = new QLineEdit();
0180     _userNameEdit->setClearButtonEnabled(true);
0181     _userNameEdit->setAcceptDrops(false);
0182     _userNameEdit->setEnabled(false);
0183     _userNameLabel->setBuddy(_userNameEdit);
0184     userNameGroupLayout->addWidget(_userNameEdit);
0185     userGroupLayout->addWidget(userNameGroup);
0186     advancedTabLayout->addWidget(_userGroup);
0187 
0188     // key binding
0189     _keyBindingGroup = new QGroupBox();
0190     QHBoxLayout *keyBindingGroupLayout = new QHBoxLayout(_keyBindingGroup);
0191     _keyBindingLabel = new QLabel(i18n("Current shortcut &key:"));
0192     keyBindingGroupLayout->addWidget(_keyBindingLabel);
0193     _keyBindingEdit = new KKeySequenceWidget();
0194     _keyBindingEdit->setMultiKeyShortcutsAllowed(false);
0195     _keyBindingLabel->setBuddy(_keyBindingEdit);
0196     keyBindingGroupLayout->addWidget(_keyBindingEdit);
0197     advancedTabLayout->addWidget(_keyBindingGroup);
0198 
0199     // push components to the top
0200     advancedTabLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
0201     // add the general group
0202     addTab(advancedTab, i18n("Advanced"));
0203 }
0204 
0205 void BasicTab::initConnections()
0206 {
0207     // general tab's components
0208     connect(_nameEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
0209     connect(_descriptionEdit, &KLineSpellChecking::textChanged, this, &BasicTab::slotChanged);
0210     connect(_commentEdit, &KLineSpellChecking::textChanged, this, &BasicTab::slotChanged);
0211     connect(_programEdit, &KUrlRequester::textChanged, this, &BasicTab::slotChanged);
0212     connect(_envarsEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
0213     connect(_argsEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
0214     connect(_programEdit, &KUrlRequester::urlSelected, this, &BasicTab::slotExecSelected);
0215     connect(_launchCB, &QCheckBox::clicked, this, &BasicTab::launchcb_clicked);
0216     connect(_onlyShowInKdeCB, &QCheckBox::clicked, this, &BasicTab::onlyshowcb_clicked);
0217     connect(_hiddenEntryCB, &QCheckBox::clicked, this, &BasicTab::hiddenentrycb_clicked);
0218     connect(_iconButton, &KIconButton::iconChanged, this, &BasicTab::slotChanged);
0219 
0220     // advanced tab's components
0221     connect(_pathEdit, &KUrlRequester::textChanged, this, &BasicTab::slotChanged);
0222     connect(_terminalCB, &QCheckBox::clicked, this, &BasicTab::termcb_clicked);
0223     connect(_terminalOptionsEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
0224     connect(_userCB, &QCheckBox::clicked, this, &BasicTab::uidcb_clicked);
0225     connect(_userNameEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
0226     connect(_keyBindingEdit, &KKeySequenceWidget::keySequenceChanged, this, &BasicTab::slotCapturedKeySequence);
0227 }
0228 
0229 void BasicTab::slotDisableAction()
0230 {
0231     // disable all group at the beginning.
0232     // because there is not file selected.
0233     _nameEdit->setEnabled(false);
0234     _descriptionEdit->setEnabled(false);
0235     _commentEdit->setEnabled(false);
0236     _programEdit->setEnabled(false);
0237     _envarsEdit->setEnabled(false);
0238     _argsEdit->setEnabled(false);
0239     _launchCB->setEnabled(false);
0240     _onlyShowInKdeCB->setEnabled(false);
0241     _hiddenEntryCB->setEnabled(false);
0242     _nameLabel->setEnabled(false);
0243     _descriptionLabel->setEnabled(false);
0244     _commentLabel->setEnabled(false);
0245     _programLabel->setEnabled(false);
0246     _envarsLabel->setEnabled(false);
0247     _argsLabel->setEnabled(false);
0248     _workPathGroup->setEnabled(false);
0249     _terminalGroup->setEnabled(false);
0250     _userGroup->setEnabled(false);
0251     _iconButton->setEnabled(false);
0252     // key binding part
0253     _keyBindingGroup->setEnabled(false);
0254 }
0255 
0256 void BasicTab::enableWidgets(bool isDF, bool isDeleted)
0257 {
0258     // set only basic attributes if it is not a .desktop file
0259     _nameEdit->setEnabled(!isDeleted);
0260     _descriptionEdit->setEnabled(!isDeleted);
0261     _commentEdit->setEnabled(!isDeleted);
0262     _iconButton->setEnabled(!isDeleted);
0263     _programEdit->setEnabled(isDF && !isDeleted);
0264     _envarsEdit->setEnabled(isDF && !isDeleted);
0265     _argsEdit->setEnabled(isDF && !isDeleted);
0266     _launchCB->setEnabled(isDF && !isDeleted);
0267     _onlyShowInKdeCB->setEnabled(isDF && !isDeleted);
0268     _hiddenEntryCB->setEnabled(isDF && !isDeleted);
0269     _nameLabel->setEnabled(!isDeleted);
0270     _descriptionLabel->setEnabled(!isDeleted);
0271     _commentLabel->setEnabled(!isDeleted);
0272     _programLabel->setEnabled(isDF && !isDeleted);
0273     _envarsLabel->setEnabled(isDF && !isDeleted);
0274     _argsLabel->setEnabled(isDF && !isDeleted);
0275 
0276     _workPathGroup->setEnabled(isDF && !isDeleted);
0277     _terminalGroup->setEnabled(isDF && !isDeleted);
0278     _userGroup->setEnabled(isDF && !isDeleted);
0279     _keyBindingGroup->setEnabled(isDF && !isDeleted);
0280 
0281     _terminalOptionsEdit->setEnabled(isDF && !isDeleted && _terminalCB->isChecked());
0282     _terminalOptionsLabel->setEnabled(isDF && !isDeleted && _terminalCB->isChecked());
0283 
0284     _userNameEdit->setEnabled(isDF && !isDeleted && _userCB->isChecked());
0285     _userNameLabel->setEnabled(isDF && !isDeleted && _userCB->isChecked());
0286 }
0287 
0288 void BasicTab::setFolderInfo(MenuFolderInfo *folderInfo)
0289 {
0290     blockSignals(true);
0291     _menuFolderInfo = folderInfo;
0292     _menuEntryInfo = 0;
0293 
0294     _nameEdit->setText(folderInfo->caption);
0295     _descriptionEdit->setText(folderInfo->genericname);
0296     _descriptionEdit->setCursorPosition(0);
0297     _commentEdit->setText(folderInfo->comment);
0298     _commentEdit->setCursorPosition(0);
0299     _iconButton->setIcon(folderInfo->icon);
0300 
0301     // clean all disabled fields and return
0302     _programEdit->lineEdit()->clear();
0303     _envarsEdit->clear();
0304     _argsEdit->clear();
0305     _pathEdit->lineEdit()->clear();
0306     _terminalOptionsEdit->clear();
0307     _userNameEdit->clear();
0308     _launchCB->setChecked(false);
0309     _terminalCB->setChecked(false);
0310     _onlyShowInKdeCB->setChecked(false);
0311     _hiddenEntryCB->setChecked(false);
0312     _userCB->setChecked(false);
0313     _keyBindingEdit->clearKeySequence();
0314 
0315     enableWidgets(false, folderInfo->hidden);
0316     blockSignals(false);
0317 }
0318 
0319 void BasicTab::setEntryInfo(MenuEntryInfo *entryInfo)
0320 {
0321     blockSignals(true);
0322     _menuFolderInfo = 0;
0323     _menuEntryInfo = entryInfo;
0324 
0325     if (!entryInfo) {
0326         _nameEdit->clear();
0327         _descriptionEdit->clear();
0328         _commentEdit->clear();
0329         _iconButton->setIcon(QString());
0330 
0331         // key binding part
0332         _keyBindingEdit->clearKeySequence();
0333 
0334         _programEdit->lineEdit()->clear();
0335         _envarsEdit->clear();
0336         _argsEdit->clear();
0337         _onlyShowInKdeCB->setChecked(false);
0338         _hiddenEntryCB->setChecked(false);
0339 
0340         _pathEdit->lineEdit()->clear();
0341         _terminalOptionsEdit->clear();
0342         _userNameEdit->clear();
0343 
0344         _launchCB->setChecked(false);
0345         _terminalCB->setChecked(false);
0346         _userCB->setChecked(false);
0347         enableWidgets(true, true);
0348         blockSignals(false);
0349         return;
0350     }
0351 
0352     KDesktopFile *df = entryInfo->desktopFile();
0353 
0354     _nameEdit->setText(df->readName());
0355     _descriptionEdit->setText(df->readGenericName());
0356     _descriptionEdit->setCursorPosition(0);
0357     _commentEdit->setText(df->readComment());
0358     _commentEdit->setCursorPosition(0);
0359     _iconButton->setIcon(df->readIcon());
0360 
0361     // key binding part
0362     if (!entryInfo->shortcut().isEmpty()) {
0363         _keyBindingEdit->setKeySequence(entryInfo->shortcut());
0364     } else {
0365         _keyBindingEdit->clearKeySequence();
0366     }
0367 
0368     QStringList execLine = KShell::splitArgs(df->desktopGroup().readEntry("Exec"));
0369     QStringList enVars = {};
0370     if (!execLine.isEmpty()) {
0371         // check for apps that use the env executable
0372         // to set the environment
0373         if (execLine[0] == QLatin1String("env")) {
0374             execLine.pop_front();
0375         }
0376         for (auto env : execLine) {
0377             if (!env.contains(QLatin1String("="))) {
0378                 break;
0379             }
0380             enVars += env;
0381             execLine.pop_front();
0382         }
0383 
0384         _programEdit->lineEdit()->setText(execLine.takeFirst());
0385     } else {
0386         _programEdit->lineEdit()->clear();
0387     }
0388     _argsEdit->setText(KShell::joinArgs(execLine));
0389     _envarsEdit->setText(KShell::joinArgs(enVars));
0390 
0391     _pathEdit->lineEdit()->setText(df->readPath());
0392     _terminalOptionsEdit->setText(df->desktopGroup().readEntry("TerminalOptions"));
0393     _userNameEdit->setText(df->desktopGroup().readEntry("X-KDE-Username"));
0394 
0395     if (df->desktopGroup().hasKey("StartupNotify")) {
0396         _launchCB->setChecked(df->desktopGroup().readEntry("StartupNotify", true));
0397     } else { // backwards comp.
0398         _launchCB->setChecked(df->desktopGroup().readEntry("X-KDE-StartupNotify", true));
0399     }
0400 
0401     // or maybe enable only if it contains nothing but KDE?
0402     _onlyShowInKdeCB->setChecked(df->desktopGroup().readXdgListEntry("OnlyShowIn").contains(QLatin1String("KDE")));
0403 
0404     if (df->desktopGroup().hasKey("NoDisplay")) {
0405         _hiddenEntryCB->setChecked(df->desktopGroup().readEntry("NoDisplay", true));
0406     } else {
0407         _hiddenEntryCB->setChecked(false);
0408     }
0409 
0410     _terminalCB->setChecked(df->desktopGroup().readEntry("Terminal", false));
0411 
0412     _userCB->setChecked(df->desktopGroup().readEntry("X-KDE-SubstituteUID", false));
0413 
0414     enableWidgets(true, entryInfo->hidden);
0415     blockSignals(false);
0416 }
0417 
0418 void BasicTab::apply()
0419 {
0420     if (_menuEntryInfo) {
0421         _menuEntryInfo->setDirty();
0422         _menuEntryInfo->setCaption(_nameEdit->text());
0423         _menuEntryInfo->setDescription(_descriptionEdit->text());
0424         _menuEntryInfo->setIcon(_iconButton->icon());
0425 
0426         KDesktopFile *df = _menuEntryInfo->desktopFile();
0427         KConfigGroup dg = df->desktopGroup();
0428         dg.writeEntry("Comment", _commentEdit->text());
0429         
0430         QStringList command;
0431         QStringList envars = KShell::splitArgs(_envarsEdit->text());
0432         if (!envars.isEmpty()) {
0433             envars.push_front(QLatin1String("env"));
0434             command << KShell::joinArgs(envars);
0435         }
0436         command << _programEdit->lineEdit()->text();
0437         const QStringList args = KShell::splitArgs(_argsEdit->text());
0438         if (!args.isEmpty()) {
0439             command << KShell::joinArgs(args);
0440         }
0441         dg.writeEntry("Exec", command.join(QLatin1Char(' ')));
0442 
0443         // NOT writePathEntry, it writes the entry with non-XDG-compliant flag: Path[$e]
0444         dg.writeEntry("Path", _pathEdit->lineEdit()->text());
0445 
0446         dg.writeEntry("Terminal", _terminalCB->isChecked());
0447         dg.writeEntry("TerminalOptions", _terminalOptionsEdit->text());
0448         dg.writeEntry("X-KDE-SubstituteUID", _userCB->isChecked());
0449         dg.writeEntry("X-KDE-Username", _userNameEdit->text());
0450         dg.writeEntry("StartupNotify", _launchCB->isChecked());
0451         dg.writeEntry("NoDisplay", _hiddenEntryCB->isChecked());
0452 
0453         QStringList onlyShowIn = df->desktopGroup().readXdgListEntry("OnlyShowIn");
0454         /* the exact semantics of this checkbox are unclear if there is more than just KDE in the list...
0455          * For example: - The list is "Gnome;", the user enables "Only show when logged into a Plasma session" - should we remove Gnome?
0456          *              - The list is "Gnome;KDE;", the user unchecks the box - should we keep Gnome?
0457          */
0458         if (_onlyShowInKdeCB->isChecked() && !onlyShowIn.contains(QLatin1String("KDE"))) {
0459             onlyShowIn << QStringLiteral("KDE");
0460         } else if (!_onlyShowInKdeCB->isChecked() && onlyShowIn.contains(QLatin1String("KDE"))) {
0461             onlyShowIn.removeAll(QStringLiteral("KDE"));
0462         }
0463         if (onlyShowIn.isEmpty()) {
0464             dg.deleteEntry("OnlyShowIn");
0465         } else {
0466             dg.writeXdgListEntry("OnlyShowIn", onlyShowIn);
0467         }
0468     } else {
0469         _menuFolderInfo->setCaption(_nameEdit->text());
0470         _menuFolderInfo->setGenericName(_descriptionEdit->text());
0471         _menuFolderInfo->setComment(_commentEdit->text());
0472         _menuFolderInfo->setIcon(_iconButton->icon());
0473     }
0474 }
0475 
0476 void BasicTab::slotChanged()
0477 {
0478     if (signalsBlocked()) {
0479         return;
0480     }
0481     apply();
0482     if (_menuEntryInfo) {
0483         emit changed(_menuEntryInfo);
0484     } else {
0485         emit changed(_menuFolderInfo);
0486     }
0487 }
0488 
0489 void BasicTab::launchcb_clicked()
0490 {
0491     slotChanged();
0492 }
0493 
0494 void BasicTab::onlyshowcb_clicked()
0495 {
0496     slotChanged();
0497 }
0498 
0499 void BasicTab::hiddenentrycb_clicked()
0500 {
0501     slotChanged();
0502 }
0503 
0504 void BasicTab::termcb_clicked()
0505 {
0506     _terminalOptionsEdit->setEnabled(_terminalCB->isChecked());
0507     _terminalOptionsLabel->setEnabled(_terminalCB->isChecked());
0508     slotChanged();
0509 }
0510 
0511 void BasicTab::uidcb_clicked()
0512 {
0513     _userNameEdit->setEnabled(_userCB->isChecked());
0514     _userNameLabel->setEnabled(_userCB->isChecked());
0515     slotChanged();
0516 }
0517 
0518 void BasicTab::slotExecSelected()
0519 {
0520     QString path = _programEdit->lineEdit()->text();
0521     if (!path.startsWith(QLatin1Char('\''))) {
0522         _programEdit->lineEdit()->setText(KShell::quoteArg(path));
0523     }
0524 }
0525 
0526 void BasicTab::slotCapturedKeySequence(const QKeySequence &seq)
0527 {
0528     if (signalsBlocked()) {
0529         return;
0530     }
0531     QKeySequence cut(seq);
0532     if (_menuEntryInfo->isShortcutAvailable(cut)) {
0533         _menuEntryInfo->setShortcut(cut);
0534     } else {
0535         // We will not assign the shortcut so reset the visible key sequence
0536         _keyBindingEdit->setKeySequence(QKeySequence());
0537     }
0538     if (_menuEntryInfo) {
0539         emit changed(_menuEntryInfo);
0540     }
0541 }
0542 
0543 void BasicTab::updateHiddenEntry(bool show)
0544 {
0545     if (show) {
0546         _hiddenEntryCB->show();
0547     } else {
0548         _hiddenEntryCB->hide();
0549     }
0550 }