Skip to content

Commit

Permalink
About window
Browse files Browse the repository at this point in the history
  • Loading branch information
Harinlen committed Jun 2, 2015
1 parent 30769bd commit 8af6a9b
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Robot.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ CONFIG += c++11
win32
{
RC_FILE += win.rc
DISTFILES += \
win.rc
}

SOURCES += \
Expand All @@ -26,7 +28,8 @@ SOURCES += \
groundrealtimepreviewer.cpp \
groundglobal.cpp \
polygoneditor.cpp \
robotmanagewidget.cpp
robotmanagewidget.cpp \
about.cpp

HEADERS += \
mainwindow.h \
Expand All @@ -49,6 +52,3 @@ HEADERS += \

RESOURCES += \
res.qrc

DISTFILES += \
win.rc
56 changes: 56 additions & 0 deletions about.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) Kreogist Dev Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QScopedPointer>
#include <QBoxLayout>
#include <QApplication>
#include <QLabel>

#include "about.h"

void About::showAbout(QWidget *parent)
{
QScopedPointer<About> aboutWindow(new About(parent));
aboutWindow->exec();
}

About::About(QWidget *parent) :
QDialog(parent)
{
QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::TopToBottom,
this);
setLayout(mainLayout);

QLabel *icon=new QLabel(this);
icon->setPixmap(QPixmap(""));
mainLayout->addWidget(icon, 1, Qt::AlignHCenter);
mainLayout->addWidget(new QLabel(tr("Robot Emulator"), this),
0,
Qt::AlignHCenter);
mainLayout->addWidget(new QLabel(QApplication::applicationVersion(), this),
0,
Qt::AlignHCenter);
QLabel *author=new QLabel(this);
author->setAlignment(Qt::AlignHCenter);
author->setText(tr("Author:\n"
"Haolei Ye, 1120132191, Class: 08111302\n"
"Han Wang, 1120132065, Class: 08211301\n"
"Quanquan Li, 1120132192, Class: 08211302\n"));
mainLayout->addWidget(author,
0,
Qt::AlignHCenter);
}
52 changes: 52 additions & 0 deletions about.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) Kreogist Dev Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef ABOUT_H
#define ABOUT_H

#include <QDialog>

class MenuBar;
/*!
* \brief The About class is a window to display the basic information of this
* emulator.
*/
class About : public QDialog
{
Q_OBJECT
public:
/*!
* \brief Show the about window.
* \param parent The parent widget.
*/
static void showAbout(QWidget *parent=0);

signals:

public slots:

private:
/*!
* \brief Construct About class.
* \param parent The parent widget.
*/
explicit About(QWidget *parent = 0);

};

#endif // ABOUT_H
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ int main(int argc, char *argv[])
//Set application information.
QApplication::setApplicationName("Robot Emulator");
QApplication::setApplicationDisplayName("Robot Emulator");
QApplication::setApplicationVersion("1.0");
//Conrtruct main window.
MainWindow mainWindow;
mainWindow.show();
Expand Down
19 changes: 18 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
*/
#include <QBoxLayout>
#include <QScrollArea>
#include <QAction>

#include "about.h"
#include "ground.h"
#include "paneldock.h"
#include "menubar.h"
Expand All @@ -32,7 +34,8 @@ MainWindow::MainWindow(QWidget *parent) :
m_panel(new PanelDock(this)),
m_menuBar(new MenuBar(this)),
m_robotManagement(new RobotManagement(this)),
m_groundGenerator(new GenerateGround(this))
m_groundGenerator(new GenerateGround(this)),
m_about(new QAction(this))
{
//Set properties.
setWindowIcon(QIcon("://res/icon.png"));
Expand All @@ -50,6 +53,8 @@ MainWindow::MainWindow(QWidget *parent) :
m_panel->setGround(m_ground);
m_robotManagement->setGround(m_ground);

//Add action to menubar.
m_menuBar->addCategoryAction(MenuBar::Help, m_about);
//Give the menu bar to elements.
m_ground->setMenuBar(m_menuBar);
m_panel->setMenuBar(m_menuBar);
Expand All @@ -59,9 +64,21 @@ MainWindow::MainWindow(QWidget *parent) :
addDockWidget(Qt::RightDockWidgetArea, m_panel);
m_panel->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea);

//Configure the about action.
connect(m_about,
static_cast<void (QAction::*)(bool)>(&QAction::triggered),
[=]{About::showAbout(this);});
#ifdef Q_OS_MACX
setWindowTitle("Robot Emulator");
#else
setMenuBar(m_menuBar);
#endif

retranslate();
}

void MainWindow::retranslate()
{
m_about->setText(tr("About"));
}
5 changes: 5 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ class MainWindow : public QMainWindow

public slots:

private slots:
void retranslate();

private:
Ground *m_ground;
PanelDock *m_panel;
MenuBar *m_menuBar;
RobotManagement *m_robotManagement;
GenerateGround *m_groundGenerator;

QAction *m_about;
};

#endif // MAINWINDOW_H

0 comments on commit 8af6a9b

Please sign in to comment.