Skip to content

Commit

Permalink
implemented about box as temporary gui placeholder
Browse files Browse the repository at this point in the history
modified CommandLine to start GUI if no command lines options specified
changed local CommandLine instance to member pointer variable
implemented MainWindow about() to display about box
temporarily redefined MainWindow::show() to display about box and quit
  • Loading branch information
thunder422 committed Dec 9, 2012
1 parent 3b93360 commit 6eab343
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
8 changes: 7 additions & 1 deletion commandline.cpp
Expand Up @@ -50,7 +50,13 @@ CommandLine::CommandLine(const QStringList &args)
QStringList options = Tester::options();
// append any other options here
options.prepend("-h|-?|-v");
m_usage = tr("usage: %1 %2").arg(m_programName).arg(options.join("|"));
m_usage = tr("usage: %1 [%2]").arg(m_programName).arg(options.join("|"));

if (args.count() == 1)
{
// no options, start GUI
return;
}

// parse command line arguments
if (isVersionOption(args))
Expand Down
37 changes: 34 additions & 3 deletions mainwindow.cpp
Expand Up @@ -23,6 +23,8 @@
// 2012-11-28 initial version

#include <QApplication>
#include <QMessageBox>
#include <QTimer>

#include "mainwindow.h"
#include "ui_mainwindow.h"
Expand All @@ -32,12 +34,12 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
CommandLine commandLine(qApp->arguments());
if (commandLine.processed())
m_commandLine = new CommandLine(qApp->arguments());
if (m_commandLine->processed())
{
// don't start GUI and retrieve the return code
m_guiActive = false;
m_returnCode = commandLine.returnCode();
m_returnCode = m_commandLine->returnCode();
return;
}

Expand All @@ -47,9 +49,38 @@ MainWindow::MainWindow(QWidget *parent) :
}


void MainWindow::show(void)
{
about();
QTimer::singleShot(0, qApp, SLOT(quit()));
}


void MainWindow::about(void)
{
// build up about box string
QString aboutString(tr("<h2>Interactive BASIC Compiler Project</h2>"));

const char **gpl = m_commandLine->gplStatement();
// add version and copyright year to first string
aboutString.append(tr(gpl[0]).arg(tr("Version %1")
.arg(m_commandLine->version())).arg(m_commandLine->copyrightYear())
.append("<br>"));
for (int i = 1; gpl[i]; i++)
{
aboutString.append("<br>").append(tr(gpl[i]));
}
aboutString.append(tr("<p><i>Temporary GUI Placeholder</i>"));
aboutString.append(tr("<p>Command line %1").arg(m_commandLine->usage()));

QMessageBox::about(this, tr("About IBCP"), aboutString);
}


MainWindow::~MainWindow()
{
delete ui;
delete m_commandLine;
}


Expand Down
8 changes: 8 additions & 0 deletions mainwindow.h
Expand Up @@ -31,6 +31,8 @@ namespace Ui {
class MainWindow;
}

class CommandLine;

class MainWindow : public QMainWindow
{
Q_OBJECT
Expand All @@ -47,10 +49,16 @@ class MainWindow : public QMainWindow
return m_returnCode;
}

public slots:
void show(void);

private:
void about(void);

Ui::MainWindow *ui;
bool m_guiActive;
int m_returnCode;
CommandLine *m_commandLine;
};

#endif // MAINWINDOW_H

0 comments on commit 6eab343

Please sign in to comment.