Skip to content

Commit

Permalink
add Confirmation Window while deleting user-phrase
Browse files Browse the repository at this point in the history
Close #155
  • Loading branch information
YWJamesLin committed Apr 9, 2016
1 parent 5514dfa commit e93a51f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/view/ChewingEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,24 @@ void ChewingEditor::showAbout()
aboutBox.exec();
}

void ChewingEditor::showDeleteConfirmWindow()
{
QString text = tr("Do you want to delete this phrase?");

QMessageBox deleteBox(this);
deleteBox.setWindowTitle(tr("Delete phrase"));
deleteBox.setText(text);
deleteBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
deleteBox.setDefaultButton(QMessageBox::No);

connect(
deleteBox.button(QMessageBox::Yes), SIGNAL(clicked()),
ui_.get()->userphraseView, SLOT(remove())
);

deleteBox.exec();
}

void ChewingEditor::setupFileSelection()
{
fileDialog_->setNameFilter("*.json");
Expand Down Expand Up @@ -250,12 +268,12 @@ void ChewingEditor::setupRemove()
shortcut_remove_ = new QShortcut(QKeySequence::Delete, this);
connect(
shortcut_remove_, SIGNAL(activated()),
ui_.get()->userphraseView, SLOT(remove())
this, SLOT(showDeleteConfirmWindow())
);

connect(
ui_.get()->removeButton, SIGNAL(pressed()),
ui_.get()->userphraseView, SLOT(remove())
this, SLOT(showDeleteConfirmWindow())
);

connect(
Expand Down
1 change: 1 addition & 0 deletions src/view/ChewingEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public slots:
void selectExportFile();
void finishFileSelection(const QString& file);
void showAbout();
void showDeleteConfirmWindow();

private:
enum DialogType {
Expand Down

0 comments on commit e93a51f

Please sign in to comment.