3 #include "mainbase.h"
\r
5 #include "platform.h"
\r
7 MainBase::MainBase(QWidget *parent): QMainWindow(parent), toolBar(0)
\r
11 #if defined(Q_WS_MAEMO_5)
\r
12 setAttribute(Qt::WA_Maemo5StackedWindow, true);
\r
15 QFrame *frame = new QFrame(this);
\r
16 QVBoxLayout *layout = new QVBoxLayout(frame);
\r
17 layout->setMargin(0);
\r
18 frame->setLayout(layout);
\r
19 setCentralWidget(frame);
\r
21 #if defined(Q_OS_SYMBIAN)
\r
22 QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);
\r
23 closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
\r
24 connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
\r
25 QMainWindow::addAction(closeAction);
\r
26 #endif // Q_OS_SYMBIAN
\r
29 void MainBase::addToolBar()
\r
37 #if defined(Q_OS_SYMBIAN)
\r
38 toolBar = new QToolBar("", this);
\r
39 toolBar->setFixedHeight(Platform::softKeyHeight());
\r
41 QMainWindow::addToolBar(Qt::BottomToolBarArea, toolBar);
\r
43 toolBar = QMainWindow::addToolBar("");
\r
46 setUnifiedTitleAndToolBarOnMac(true);
\r
47 toolBar->setMovable(false);
\r
48 toolBar->setFloatable(false);
\r
49 toolBar->toggleViewAction()->setVisible(false);
\r
51 #if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)
\r
52 toolBar->setIconSize(QSize(Platform::toolBarIconHeight(),
\r
53 Platform::toolBarIconHeight()));
\r
57 QAction *MainBase::addToolBarAction(QObject *receiver,
\r
59 const QString &iconName,
\r
60 const QString &text,
\r
64 qDebug() << "icon" << iconName << "text" << text;
\r
68 // Add tool bar action
\r
70 QPushButton *button = new QPushButton(this);
\r
71 button->setIconSize(QSize(60, 60));
\r
72 button->setFixedHeight(60);
\r
73 button->setIcon(QIcon(Platform::instance()->icon(iconName)));
\r
74 button->setSizePolicy(QSizePolicy::MinimumExpanding,
\r
75 QSizePolicy::Maximum);
\r
76 connect(button, SIGNAL(clicked()), receiver, member);
\r
77 toolBar->addWidget(button);
\r
79 // Add menu action, too
\r
80 action = menuBar()->addAction(text);
\r
81 connect(action, SIGNAL(triggered()), receiver, member);
\r
83 Q_UNUSED(important);
\r
85 action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
\r
86 text, receiver, member);
\r
89 action->setToolTip("");
\r
93 void MainBase::addToolBarSpace()
\r
96 QFrame *frame = new QFrame(toolBar);
\r
97 frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
\r
98 toolBar->addWidget(frame);
\r
101 int MainBase::toolBarHeight()
\r
103 return toolBar? toolBar->height(): 0;
\r
106 void MainBase::show()
\r
108 Trace t("MainBase::show");
\r
109 #ifdef Q_OS_SYMBIAN
\r
110 foreach (QWidget *w, QApplication::allWidgets()) {
\r
111 w->setContextMenuPolicy(Qt::NoContextMenu);
\r
115 QMainWindow::show();
\r
119 #if 0 // ifdef Q_OS_SYMBIAN
\r
121 void MainBase::resizeEvent(QResizeEvent *e)
\r
123 Trace t("MainBase::resizeEvent");
\r
125 QMainWindow::resizeEvent(e);
\r
129 QSize available = Platform::availableSize();
\r
130 toolBar->setGeometry(0, available.height() - Platform::softKeyHeight(),
\r
131 available.width(), Platform::softKeyHeight());
\r
134 #endif // Q_OS_SYMBIAN
\r