Skip to content

Commit

Permalink
GUI: Add stub for Phaethon's main window
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpm54 authored and DrMcCoy committed May 22, 2018
1 parent ceffc9d commit 6e5f245
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 1 deletion.
45 changes: 45 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Phaethon - A FLOSS resource explorer for BioWare's Aurora engine games
*
* Phaethon is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* Phaethon 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 3
* of the License, or (at your option) any later version.
*
* Phaethon 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 Phaethon. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Phaethon's main window.
*/

#include <QAction>
#include <QCoreApplication>

#include "verdigris/wobjectimpl.h"

#include "src/gui/mainwindow.h"

#include "src/common/util.h"

namespace GUI {

W_OBJECT_IMPL(MainWindow)

MainWindow::MainWindow(QWidget *parent, const char *title, const QSize &size, const char *UNUSED(path)) : QMainWindow(parent) {
_centralWidget = new QWidget(this);
setCentralWidget(_centralWidget);
setWindowTitle(title);
resize(size);
}

} // End of namespace GUI
46 changes: 46 additions & 0 deletions src/gui/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* Phaethon - A FLOSS resource explorer for BioWare's Aurora engine games
*
* Phaethon is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* Phaethon 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 3
* of the License, or (at your option) any later version.
*
* Phaethon 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 Phaethon. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Phaethon's main window.
*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "verdigris/wobjectdefs.h"

namespace GUI {

class MainWindow : public QMainWindow {
W_OBJECT(MainWindow)

public:
MainWindow(QWidget *parent, const char *title, const QSize &size, const char *path);

private:
QWidget *_centralWidget;
};

} // End of namespace GUI

#endif // MAINWINDOW_H
32 changes: 32 additions & 0 deletions src/gui/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Phaethon - A FLOSS resource explorer for BioWare's Aurora engine games
#
# Phaethon is the legal property of its developers, whose names
# can be found in the AUTHORS file distributed with this source
# distribution.
#
# Phaethon 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 3
# of the License, or (at your option) any later version.
#
# Phaethon 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 Phaethon. If not, see <http://www.gnu.org/licenses/>.

# GUI code using Qt5.

noinst_LTLIBRARIES += src/gui/libgui.la

src_gui_libgui_la_SOURCES =

src_gui_libgui_la_SOURCES += \
src/gui/mainwindow.h \
$(EMPTY)

src_gui_libgui_la_SOURCES += \
src/gui/mainwindow.cpp \
$(EMPTY)
20 changes: 19 additions & 1 deletion src/phaethon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@

#include <cstdio>

#include <QApplication>

#include "src/version/version.h"

#include "src/common/util.h"
#include "src/common/error.h"
#include "src/common/ustring.h"
#include "src/common/platform.h"

#include "src/gui/mainwindow.h"

#include "src/sound/sound.h"

#include "src/cline.h"
Expand Down Expand Up @@ -106,9 +110,22 @@ class Phaethon {
};

Phaethon::Phaethon(const Common::UString &path) : _path(path) {
initSubsystems();

int argc = 1; // QApplication requires argc to be at least 1
char empty[] = ""; // Silence -Wwrite-string warning
char *argv[] = {empty}; // QApplication requires argv to be at least 1

QApplication app(argc, argv);

GUI::MainWindow mainWindow(0, Version::getProjectNameVersion(), QSize(800, 600), path.c_str());
mainWindow.show();

app.exec();
}

Phaethon::~Phaethon() {
deinitSubsystems();
}

void Phaethon::initSubsystems() {
Expand All @@ -134,5 +151,6 @@ void Phaethon::deinitSubsystems() {
}
}

void openGamePath(const Common::UString &UNUSED(path)) {
void openGamePath(const Common::UString &path) {
Phaethon phaethon(path);
}
2 changes: 2 additions & 0 deletions src/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ src_phaethon_SOURCES += \
$(EMPTY)

src_phaethon_LDADD = \
src/gui/libgui.la \
src/sound/libsound.la \
src/images/libimages.la \
src/aurora/libaurora.la \
Expand All @@ -47,3 +48,4 @@ include src/common/rules.mk
include src/aurora/rules.mk
include src/images/rules.mk
include src/sound/rules.mk
include src/gui/rules.mk

0 comments on commit 6e5f245

Please sign in to comment.