summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp8
-rw-r--r--src/main_window.cpp66
-rw-r--r--src/main_window.hpp42
3 files changed, 116 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..bb08972
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,8 @@
+#include "main_window.hpp"
+
+int main(int argc, char* argv[]) {
+ QApplication app{argc, argv};
+ getsuyobi::GetsuyobiApp getsuyobi{};
+
+ return app.exec();
+}
diff --git a/src/main_window.cpp b/src/main_window.cpp
new file mode 100644
index 0000000..796b4fc
--- /dev/null
+++ b/src/main_window.cpp
@@ -0,0 +1,66 @@
+#include "main_window.hpp"
+
+#include <QString>
+
+namespace getsuyobi {
+
+GetsuyobiApp::GetsuyobiApp() : m_getsuyobi{new Getsuyobi()}
+{
+ setCentralWidget(m_getsuyobi);
+ setup();
+}
+
+void GetsuyobiApp::setup()
+{
+ createActions();
+ createMenus();
+
+ QCoreApplication::setApplicationName(AppName);
+ QCoreApplication::setApplicationVersion(AppVersionString);
+ setWindowTitle(AppName);
+
+ show();
+}
+
+void GetsuyobiApp::createActions()
+{
+ m_openAction = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen), tr("&Open"), this);
+ m_openAction->setShortcuts(QKeySequence::Open);
+ m_openAction->setStatusTip(tr("Open a file"));
+ connect(m_openAction, &QAction::triggered, this, &GetsuyobiApp::openFile);
+
+ m_quitAction = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::ApplicationExit), tr("&Quit"), this);
+ m_quitAction->setShortcuts(QKeySequence::Quit);
+ m_quitAction->setStatusTip(tr("Quit"));
+ connect(m_quitAction, &QAction::triggered, this, &GetsuyobiApp::quit);
+}
+
+void GetsuyobiApp::createMenus()
+{
+ m_fileMenu = menuBar()->addMenu(tr("&File"));
+ m_fileMenu->addAction(m_openAction);
+ m_fileMenu->addAction(m_quitAction);
+}
+
+void GetsuyobiApp::openFile()
+{
+ printf("Open file!\n");
+}
+
+void GetsuyobiApp::quit()
+{
+ printf("Quit!\n");
+ QCoreApplication::quit();
+}
+
+Getsuyobi::Getsuyobi()
+{
+ m_layout = new QVBoxLayout();
+
+ auto* label = new QLabel(AppName);
+ m_layout->addWidget(label);
+
+ setLayout(m_layout);
+}
+
+} // namespace getsuyobi
diff --git a/src/main_window.hpp b/src/main_window.hpp
new file mode 100644
index 0000000..0bd074a
--- /dev/null
+++ b/src/main_window.hpp
@@ -0,0 +1,42 @@
+#include <QtWidgets>
+
+namespace getsuyobi {
+
+constexpr const char* AppName = "GetsuYobi";
+constexpr const char* AppVersionString = "1.0.0";
+
+class Getsuyobi;
+
+class GetsuyobiApp : public QMainWindow {
+ Q_OBJECT
+
+ public:
+ GetsuyobiApp();
+
+ private:
+ void setup();
+ void createActions();
+ void createMenus();
+
+ Getsuyobi* m_getsuyobi;
+
+ QAction* m_openAction;
+ QAction* m_quitAction;
+
+ QMenu* m_fileMenu;
+
+ private slots:
+ void openFile();
+ void quit();
+};
+
+class Getsuyobi : public QWidget {
+ Q_OBJECT
+ public:
+ Getsuyobi();
+
+ private:
+ QLayout* m_layout{nullptr};
+};
+
+} // namespace getsuyobi