Revise HowtoTranslate, add gen-tr.sh
[nomnom.git] / src / i / Reminder.cpp
blob85e47ad5bab135e828fddf88f68ab42790e26b2a
1 /*
2 * Copyright (C) 2010 Toni Gundogdu.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include <QSettings>
19 #include <QShowEvent>
20 #include <QDebug>
22 #include "util.h"
23 #include "tips.h"
24 #include "Reminder.h"
26 #define QSETTINGS_GROUP "Reminder"
28 #define QSETTINGS_REMINDER_SHOWREMINDER "showReminder"
29 #define QSETTINGS_REMINDER_FIRSTRUN "firstRun"
31 // Ctor.
33 Reminder::Reminder (QWidget *parent, const QString& group)
34 : QDialog (parent), showReminder (true), currTip (0), firstRun (true)
36 setupUi (this);
38 QSettings s;
39 NomNom::restore_size (s, this, QSETTINGS_GROUP, QSize (400,200));
41 firstRunKey = QString ("%1/%2")
42 .arg (group)
43 .arg (QSETTINGS_REMINDER_FIRSTRUN);
45 showReminderKey = QString ("%1/%2")
46 .arg (group)
47 .arg (QSETTINGS_REMINDER_SHOWREMINDER);
49 if (s.contains (firstRunKey))
50 firstRun = s.value (firstRunKey).toBool ();
52 if (s.contains (showReminderKey))
53 showReminder = s.value (showReminderKey).toBool ();
55 textBrowser->setHtml (NomNom::get_tip (currTip, firstRun));
58 // Slot: on Next.
60 void
61 Reminder::onNext ()
63 textBrowser->setHtml (NomNom::next_tip (currTip));
66 // Conditional exec, or "until a more elegant way is found".
68 bool
69 Reminder::conditionalExec ()
71 if (showReminder) exec ();
72 return showReminder;
75 // Done. QDialog and closeEvent design glitch workaround.
77 void
78 Reminder::done (int r)
80 QSettings s;
81 NomNom::save_size (s, this, QSETTINGS_GROUP);
83 showReminder = showagainBox->isChecked(); // Update.
85 s.setValue (firstRunKey, false);
86 s.setValue (showReminderKey, showReminder);
88 QDialog::done (r);
89 close ();
92 // Close.
94 void
95 Reminder::closeEvent (QCloseEvent *e)
97 QDialog::closeEvent(e);
100 // vim: set ts=2 sw=2 tw=72 expandtab: