From bd9e6617827818fd043452c08c606f07b78014a0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kbugbuster/gui/messageeditor.cpp | 117 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 kbugbuster/gui/messageeditor.cpp (limited to 'kbugbuster/gui/messageeditor.cpp') diff --git a/kbugbuster/gui/messageeditor.cpp b/kbugbuster/gui/messageeditor.cpp new file mode 100644 index 00000000..517ef80b --- /dev/null +++ b/kbugbuster/gui/messageeditor.cpp @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "kbbprefs.h" + +#include "messageeditor.h" +#include +#include "messageeditor.moc" + +MessageEditor::MessageEditor( QWidget *parent ) + : KDialogBase(Plain,i18n("Edit Message Buttons"),Ok|Cancel,Ok,parent,0, + true,true) +{ + QFrame *topFrame = plainPage(); + QBoxLayout *topLayout = new QVBoxLayout(topFrame,0,spacingHint()); + + QBoxLayout *selectionLayout = new QHBoxLayout; + topLayout->addLayout(selectionLayout); + + QLabel *selectionLabel = new QLabel(i18n("Button:"),topFrame); + selectionLayout->addWidget(selectionLabel); + + mSelectionCombo = new QComboBox(topFrame); + selectionLayout->addWidget(mSelectionCombo); + connect(mSelectionCombo,SIGNAL(activated(int)),SLOT(changeMessage())); + + QPushButton *addButton = new QPushButton(i18n("Add Button..."),topFrame); + selectionLayout->addWidget(addButton); + connect(addButton,SIGNAL(clicked()),SLOT(addButton())); + + QPushButton *removeButton = new QPushButton(i18n("Remove Button"),topFrame); + selectionLayout->addWidget(removeButton); + connect(removeButton,SIGNAL(clicked()),SLOT(removeButton())); + + mMessageEdit = new KTextEdit(topFrame); + topLayout->addWidget(mMessageEdit,1); + + updateConfig(); +} + +void MessageEditor::updateConfig() +{ + mMessageButtons = KBBPrefs::instance()->mMessageButtons; + + mSelectionCombo->clear(); + + QMap::ConstIterator it; + for(it = mMessageButtons.begin();it != mMessageButtons.end();++it) { + mSelectionCombo->insertItem(it.key()); + } + + updateMessage(); +} + +void MessageEditor::addButton() +{ + QString txt; + txt = KInputDialog::getText(i18n("Add Message Button"), + i18n("Enter button name:"), QString::null, + NULL, this ); + + if ( !txt.isNull() ) { + saveMessage(); + mSelectionCombo->insertItem(txt); + mMessageButtons.insert(txt,""); + mSelectionCombo->setCurrentItem(mSelectionCombo->count()-1); + updateMessage(); + } + +} + +void MessageEditor::removeButton() +{ + int result = KMessageBox::warningContinueCancel(this, + i18n("Remove the button %1?").arg(mSelectionCombo->currentText()), + i18n("Remove"), KGuiItem( i18n("Delete"), "editdelete") ); + + if (result == KMessageBox::Continue) { + mMessageButtons.remove(mSelectionCombo->currentText()); + mSelectionCombo->removeItem(mSelectionCombo->currentItem()); + mSelectionCombo->setCurrentItem(0); + updateMessage(); + } +} + +void MessageEditor::changeMessage() +{ + saveMessage(); + updateMessage(); +} + +void MessageEditor::updateMessage() +{ + mCurrentButton = mSelectionCombo->currentText(); + + mMessageEdit->setText(mMessageButtons[mCurrentButton]); +} + +void MessageEditor::saveMessage() +{ + mMessageButtons.replace(mCurrentButton,mMessageEdit->text()); +} + +void MessageEditor::slotOk() +{ + saveMessage(); + + KBBPrefs::instance()->mMessageButtons = mMessageButtons; + accept(); +} -- cgit v1.2.1