Fix typo
[yandex-traffic] / menudialog.cpp
1 #include <QtGui>
2
3 #include "menudialog.hpp"
4
5
6 // --------------------------------------------------
7 // MenuDialog
8 // --------------------------------------------------
9 MenuDialog::MenuDialog (const QString &title)
10     : QDialog ()
11 {
12     setWindowTitle (title);
13     _layout = new QVBoxLayout (this);
14 }
15
16
17 MenuDialog& MenuDialog::addEntry (const QString &text)
18 {
19     QPushButton* btn = new QPushButton (text, this);
20
21     connect (btn, SIGNAL (clicked ()), SLOT (buttonClicked ()));
22     _layout->addWidget (btn);
23     _buttons.append (btn);
24
25     return *this;
26 }
27
28
29 void MenuDialog::buttonClicked ()
30 {
31     QPushButton *btn = static_cast<QPushButton*> (sender ());
32
33     if (!btn)
34         return;
35
36     index = _buttons.indexOf (btn);
37
38     accept ();
39 }
40
41
42 int MenuDialog::run ()
43 {
44     index = -1;
45
46     if (exec () == QDialog::Accepted)
47         return index;
48     else
49         return -1;
50 }
51
52