/* Klat - A LaTeX editor for KDE Copyright (C) 2002-2004 Jori Liesenborgs (jori@lumumba.luc.ac.be) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "klateditcommanddlgimpl.h" #include "klateditcommanddlgimpl.moc" #include #include #include #include #include #include #include #define NOSHORTCUTTEXT "[none]" KlatEditCommandDlgImpl::KlatEditCommandDlgImpl(QWidget *parent,char *name) : KlatEditCommandDlg(parent,name,true) { changeShortcutButton->setText( trUtf8( "Change" ) ); savefirst = false; connect(okButton,SIGNAL(clicked()),this,SLOT(slotOkButtonPressed())); connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject())); connect(changeShortcutButton,SIGNAL(capturedShortcut(const KShortcut &)),this,SLOT(slotChangeShortcut(const KShortcut &))); connect(clearShortcutButton,SIGNAL(clicked()),this,SLOT(slotClearShortcut())); } KlatEditCommandDlgImpl::~KlatEditCommandDlgImpl() { } int KlatEditCommandDlgImpl::exec() { menuNameEdit->setText(menuname); commandLineEdit->setText(cmdLine); saveFirstCheckbox->setChecked(savefirst); if (cut.count() > 0) shortcutText->setText(cut.toString()); else shortcutText->setText(NOSHORTCUTTEXT); return KlatEditCommandDlg::exec(); } void KlatEditCommandDlgImpl::slotOkButtonPressed() { menuname = menuNameEdit->text(); cmdLine = commandLineEdit->text(); savefirst = saveFirstCheckbox->isChecked(); // the shortcut has already been saved bool valid; if (menuname.length() == 0) valid = false; else { int i,len; bool found; len = menuname.length(); for (i = 0,found = false ; !found && i < len ; i++) { if (!(menuname[i] == ' ' || menuname[i] == '\t')) found = true; } if (found) valid = true; else valid = false; } if (!valid) { KMessageBox::messageBox(this,KMessageBox::Information,"You must specify a name to appear in the menu","No menu name"); return; } accept(); } void KlatEditCommandDlgImpl::slotChangeShortcut(const KShortcut &newshortcut) { cut = newshortcut; shortcutText->setText(cut.toString()); } void KlatEditCommandDlgImpl::slotClearShortcut() { cut.clear(); shortcutText->setText(NOSHORTCUTTEXT); }