Set version to v1.1
[mverbiste] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <QtGui/QMainWindow>
5 #include <QtGui/QTextEdit>
6 #include <QtGui/QPushButton>
7 #include <QtGui/QCheckBox>
8 #include <QtGui/QVBoxLayout>
9 #include <QtGui/QLineEdit>
10 #include <QtGui/QScrollArea>
11 #include <QtGui/QLabel>
12 #include <QtGui/QTableWidget>
13 #include <QtGui/QMessageBox>
14 #include <QtGui/QActionGroup>
15
16 /* Verbiste */
17 #include <iostream>
18 #include <vector>
19 #include <string.h>
20 #include <verbiste/FrenchVerbDictionary.h>
21 #include "gui/conjugation.h"
22 #include "about.h"
23
24 #ifndef QT_NO_DEBUG
25 #include <QtCore/QDebug>
26 #include <QtCore/QElapsedTimer>
27 #endif
28
29 using namespace verbiste;
30
31 namespace Ui {
32     class MainWindow;
33     class ResultPage;
34 }
35
36 class ResultPage
37 {
38 public:
39     QScrollArea *page;
40     QGridLayout *grid;
41
42     ResultPage();
43     // No destructor because this object does not own the two widgets.
44     void packContent();
45
46 private:
47     QWidget *immediate;
48 };
49
50 class MainWindow : public QMainWindow
51 {
52     Q_OBJECT
53 public:
54     enum ScreenOrientation {
55         ScreenOrientationLockPortrait,
56         ScreenOrientationLockLandscape,
57         ScreenOrientationAuto
58     };
59
60     explicit MainWindow(QWidget *parent = 0);
61     virtual ~MainWindow();
62
63     // Setup UI by coding, not by QtDesigner
64     void setupcodedUI();
65
66     // Note that this will only have an effect on Symbian and Fremantle.
67     void setOrientation(ScreenOrientation orientation);
68
69     void showExpanded();
70     void initverbiste();
71     QVBoxLayout* makeResultCell(const VVS &tenseIterator,
72                                 const std::string &tenseName,
73                                 const std::string &inputWord,
74                                 FrenchVerbDictionary *verbDict);
75
76 public slots:
77     void startLookup();
78     void switchLang();
79
80 private:
81     Ui::MainWindow *ui;
82     QWidget     *cent;               // Central widget
83     QVBoxLayout *mlayout;            // Main layout
84     QTabWidget  *resultPages;
85     QHBoxLayout *btlayout;           // Layout to pack the functional buttons
86     QPushButton *btnClear;           // Clear button
87     QCheckBox   *btnPron;
88     QLineEdit   *wordinput;          //  Word input
89     QPushButton *btnLookup;          // Lookup button
90     QAction     *filFrench;
91     QAction     *filItalian;
92     QMessageBox *msgbox;
93     std::string langCode;
94     FrenchVerbDictionary *freVerbDic;
95     AboutDialog *aboutDialog;
96
97     ResultPage* addResultPage(const std::string &labelText);
98 #ifndef QT_NO_DEBUG
99     QElapsedTimer timer;
100 #endif
101
102 private slots:
103     void clearResults();
104     void startAgain();
105 };
106
107
108 #endif // MAINWINDOW_H