| 1 | /* |
| 2 | * chewing-editor: Chewing userphrase editor |
| 3 | * Copyright (C) 2014 Chewing Development Team |
| 4 | |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | |
| 20 | #include "Notification.h" |
| 21 | |
| 22 | #include <QDebug> |
| 23 | |
| 24 | Notification::Notification(QWidget* parent) |
| 25 | :QLabel(parent) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | void Notification::notifyImportCompleted( |
| 30 | bool result, |
| 31 | const QString& path, |
| 32 | size_t imported, |
| 33 | size_t total) |
| 34 | { |
| 35 | qDebug() << result << path << imported << total; |
| 36 | |
| 37 | if (result) { |
| 38 | setText( |
| 39 | tr("%1 %2 %3") |
| 40 | .arg(tr("Import \"%1\" successful.").arg(path)) |
| 41 | .arg(tr("%n phrase(s) are imported.", 0, imported)) |
| 42 | .arg(tr("Total %n user phrase(s).", 0, total))); |
| 43 | } else { |
| 44 | setText(tr("Import \"%1\" failed.").arg(path)); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void Notification::notifyExportCompleted( |
| 49 | bool result, |
| 50 | const QString& path, |
| 51 | size_t exported) |
| 52 | { |
| 53 | qDebug() << result << path << exported; |
| 54 | |
| 55 | if (result) { |
| 56 | setText( |
| 57 | tr("%1 %2") |
| 58 | .arg(tr("Export \"%1\" successful.").arg(path)) |
| 59 | .arg(tr("%n phrase(s) are exported.", 0, exported))); |
| 60 | } else { |
| 61 | setText(tr("Export \"%1\" failed.").arg(path)); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void Notification::notifyAddNewPhraseCompleted(const Userphrase& userphrase) |
| 66 | { |
| 67 | qDebug() << userphrase.display_; |
| 68 | |
| 69 | setText(tr("Add new phrase %1 successful.").arg(userphrase.display_)); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | void Notification::notifyRemovePhraseCompleted(size_t count) |
| 74 | { |
| 75 | qDebug() << count; |
| 76 | |
| 77 | setText(tr("Remove %n phrase(s) successful.", 0, count)); |
| 78 | } |
| 79 | |
| 80 | void Notification::notifyRefreshCompleted(size_t count) |
| 81 | { |
| 82 | qDebug() << count; |
| 83 | |
| 84 | setText(tr("Refresh completed. Total %n user phrase(s).", 0, count)); |
| 85 | } |
| 86 | |
| 87 | void Notification::notifyAddNewPhraseFailed() |
| 88 | { |
| 89 | setText(tr("Add new phrase failed. Please enter the bopomofo for each word and try again.")); |
| 90 | } |
| 91 | |
| 92 | void Notification::notifyUndoCompleted(const QString &phrase) |
| 93 | { |
| 94 | setText(tr("Undo completed. Revert %1.").arg(phrase)); |
| 95 | } |