[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[651] | 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the examples of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "menus.h"
|
---|
| 43 | #include <QAction>
|
---|
| 44 | #include <QAxFactory>
|
---|
| 45 | #include <QMenuBar>
|
---|
| 46 | #include <QMessageBox>
|
---|
| 47 | #include <QTextEdit>
|
---|
| 48 | #include <QPixmap>
|
---|
| 49 |
|
---|
| 50 | #include "fileopen.xpm"
|
---|
| 51 | #include "filesave.xpm"
|
---|
| 52 |
|
---|
| 53 | QMenus::QMenus(QWidget *parent)
|
---|
| 54 | : QMainWindow(parent, 0) // QMainWindow's default flag is WType_TopLevel
|
---|
| 55 | {
|
---|
| 56 | QAction *action;
|
---|
| 57 |
|
---|
| 58 | QMenu *file = new QMenu(this);
|
---|
| 59 |
|
---|
| 60 | action = new QAction(QPixmap((const char**)fileopen), "&Open", this);
|
---|
| 61 | action->setShortcut(tr("CTRL+O"));
|
---|
| 62 | connect(action, SIGNAL(triggered()), this, SLOT(fileOpen()));
|
---|
| 63 | file->addAction(action);
|
---|
| 64 |
|
---|
| 65 | action = new QAction(QPixmap((const char**)filesave),"&Save", this);
|
---|
| 66 | action->setShortcut(tr("CTRL+S"));
|
---|
| 67 | connect(action, SIGNAL(triggered()), this, SLOT(fileSave()));
|
---|
| 68 | file->addAction(action);
|
---|
| 69 |
|
---|
| 70 | QMenu *edit = new QMenu(this);
|
---|
| 71 |
|
---|
| 72 | action = new QAction("&Normal", this);
|
---|
| 73 | action->setShortcut(tr("CTRL+N"));
|
---|
| 74 | action->setToolTip("Normal");
|
---|
| 75 | action->setStatusTip("Toggles Normal");
|
---|
| 76 | action->setCheckable(true);
|
---|
| 77 | connect(action, SIGNAL(triggered()), this, SLOT(editNormal()));
|
---|
| 78 | edit->addAction(action);
|
---|
| 79 |
|
---|
| 80 | action = new QAction("&Bold", this);
|
---|
| 81 | action->setShortcut(tr("CTRL+B"));
|
---|
| 82 | action->setCheckable(true);
|
---|
| 83 | connect(action, SIGNAL(triggered()), this, SLOT(editBold()));
|
---|
| 84 | edit->addAction(action);
|
---|
| 85 |
|
---|
| 86 | action = new QAction("&Underline", this);
|
---|
| 87 | action->setShortcut(tr("CTRL+U"));
|
---|
| 88 | action->setCheckable(true);
|
---|
| 89 | connect(action, SIGNAL(triggered()), this, SLOT(editUnderline()));
|
---|
| 90 | edit->addAction(action);
|
---|
| 91 |
|
---|
| 92 | QMenu *advanced = new QMenu(this);
|
---|
| 93 | action = new QAction("&Font...", this);
|
---|
| 94 | connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedFont()));
|
---|
| 95 | advanced->addAction(action);
|
---|
| 96 |
|
---|
| 97 | action = new QAction("&Style...", this);
|
---|
| 98 | connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedStyle()));
|
---|
| 99 | advanced->addAction(action);
|
---|
| 100 |
|
---|
| 101 | edit->addMenu(advanced)->setText("&Advanced");
|
---|
| 102 |
|
---|
| 103 | edit->addSeparator();
|
---|
| 104 |
|
---|
| 105 | action = new QAction("Una&vailable", this);
|
---|
| 106 | action->setShortcut(tr("CTRL+V"));
|
---|
| 107 | action->setCheckable(true);
|
---|
| 108 | action->setEnabled(false);
|
---|
| 109 | connect(action, SIGNAL(triggered()), this, SLOT(editUnderline()));
|
---|
| 110 | edit->addAction(action);
|
---|
| 111 |
|
---|
| 112 | QMenu *help = new QMenu(this);
|
---|
| 113 |
|
---|
| 114 | action = new QAction("&About...", this);
|
---|
| 115 | action->setShortcut(tr("F1"));
|
---|
| 116 | connect(action, SIGNAL(triggered()), this, SLOT(helpAbout()));
|
---|
| 117 | help->addAction(action);
|
---|
| 118 |
|
---|
| 119 | action = new QAction("&About Qt...", this);
|
---|
| 120 | connect(action, SIGNAL(triggered()), this, SLOT(helpAboutQt()));
|
---|
| 121 | help->addAction(action);
|
---|
| 122 |
|
---|
| 123 | if (!QAxFactory::isServer())
|
---|
| 124 | menuBar()->addMenu(file)->setText("&File");
|
---|
| 125 | menuBar()->addMenu(edit)->setText("&Edit");
|
---|
| 126 | menuBar()->addMenu(help)->setText("&Help");
|
---|
| 127 |
|
---|
| 128 | editor = new QTextEdit(this);
|
---|
| 129 | setCentralWidget(editor);
|
---|
| 130 |
|
---|
| 131 | statusBar();
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | void QMenus::fileOpen()
|
---|
| 135 | {
|
---|
| 136 | editor->append("File Open selected.");
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | void QMenus::fileSave()
|
---|
| 140 | {
|
---|
| 141 | editor->append("File Save selected.");
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | void QMenus::editNormal()
|
---|
| 145 | {
|
---|
| 146 | editor->append("Edit Normal selected.");
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | void QMenus::editBold()
|
---|
| 150 | {
|
---|
| 151 | editor->append("Edit Bold selected.");
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | void QMenus::editUnderline()
|
---|
| 155 | {
|
---|
| 156 | editor->append("Edit Underline selected.");
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | void QMenus::editAdvancedFont()
|
---|
| 160 | {
|
---|
| 161 | editor->append("Edit Advanced Font selected.");
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | void QMenus::editAdvancedStyle()
|
---|
| 165 | {
|
---|
| 166 | editor->append("Edit Advanced Style selected.");
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | void QMenus::helpAbout()
|
---|
| 170 | {
|
---|
| 171 | QMessageBox::about(this, "About QMenus",
|
---|
| 172 | "This example implements an in-place ActiveX control with menus and status messages.");
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | void QMenus::helpAboutQt()
|
---|
| 176 | {
|
---|
| 177 | QMessageBox::aboutQt(this);
|
---|
| 178 | }
|
---|