summaryrefslogtreecommitdiffstats
path: root/testapp/main.cpp
blob: 732f67c2a6ba928d4df445919164b03f74eecb0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <QtGui>
#include "qscrollareakineticscroller.h"

#include "settingswidget.h"
#include "plotwidget.h"

int main(int argc, char **argv)
{
    QApplication a(argc, argv);

    QListWidget *list = new QListWidget();

    for (int i = 0; i < 1000; ++i)
        new QListWidgetItem(QString("Oa dsjfhdk jhdsjk hfdskj k %1").arg(i), list);

    QScrollAreaKineticScroller *s = new QScrollAreaKineticScroller();
    s->setWidget(list);

#if defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) || defined(Q_WS_WINCE)
    bool smallScreen = true;
#else
    bool smallScreen = false;
#endif

    QWidget *settings = new SettingsWidget(s, smallScreen);
    QWidget *plot = new PlotWidget(s);

    if (smallScreen) {
        QMainWindow *top = new QMainWindow();
        QStackedWidget *stack = new QStackedWidget();
        stack->addWidget(list);
        stack->addWidget(settings);
        stack->addWidget(plot);
        top->setCentralWidget(stack);

        QActionGroup *pages = new QActionGroup(top);
        pages->setExclusive(true);
        QSignalMapper *mapper = new QSignalMapper(top);
        QObject::connect(mapper, SIGNAL(mapped(int)), stack, SLOT(setCurrentIndex(int)));

        QAction *a = new QAction(QLatin1String("List"), pages);
        a->setCheckable(true);
        a->setChecked(true);
        mapper->setMapping(a, 0);
        QObject::connect(a, SIGNAL(toggled(bool)), mapper, SLOT(map()));

        a = new QAction(QLatin1String("Config"), pages);
        a->setCheckable(true);
        a->setChecked(false);
        a->setMenuRole(QAction::NoRole);
        mapper->setMapping(a, 1);
        QObject::connect(a, SIGNAL(toggled(bool)), mapper, SLOT(map()));

        a = new QAction(QLatin1String("Plot"), pages);
        a->setCheckable(true);
        a->setChecked(false);
        mapper->setMapping(a, 2);
        QObject::connect(a, SIGNAL(toggled(bool)), mapper, SLOT(map()));

        top->menuBar()->addMenu("Pages")->addActions(pages->actions());
        top->showMaximized();
    } else {
        QSplitter *split = new QSplitter();
        split->addWidget(list);
        split->addWidget(settings);
        split->addWidget(plot);
        split->show();
#if defined(Q_WS_MAC)
        split->raise();
#endif
    }

    return a.exec();
}