From be0053764d346e55ee14ef769b9fdf6ced9cb75d Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Mon, 27 Oct 2014 14:05:36 -0400 Subject: [PATCH] add PreferencesDialog - not yet effective --- MainApplication.h | 1 + MainWindow.cpp | 17 +++++++++ MainWindow.h | 5 +++ OutputGLWindow.cpp | 1 + PreferencesDialog.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++ PreferencesDialog.h | 54 +++++++++++++++++++++++++++++ mapmap.pro | 2 ++ 7 files changed, 160 insertions(+) create mode 100644 PreferencesDialog.cpp create mode 100644 PreferencesDialog.h diff --git a/MainApplication.h b/MainApplication.h index 6ceaa8f..0b42138 100644 --- a/MainApplication.h +++ b/MainApplication.h @@ -25,6 +25,7 @@ #include #include #include "MM.h" +#include "PreferencesDialog.h" class MainApplication : public QApplication { diff --git a/MainWindow.cpp b/MainWindow.cpp index fd3e58a..1df269f 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -26,6 +26,7 @@ MainWindow::MainWindow() { + // Create model. if (Media::hasVideoSupport()) std::cout << "Video support: yes" << std::endl; @@ -73,6 +74,8 @@ MainWindow::MainWindow() // Start playing by default. play(); + + _preferences_dialog = new PreferencesDialog(this, this); } MainWindow::~MainWindow() @@ -306,6 +309,11 @@ void MainWindow::open() videoTimer->start(); } +void MainWindow::preferences() +{ + this->_preferences_dialog->show(); +} + bool MainWindow::save() { // Popup save-as dialog if file has never been saved. @@ -1160,6 +1168,14 @@ void MainWindow::createActions() deleteAction->setIconVisibleInMenu(false); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem())); + // Preferences... + preferencesAction = new QAction(tr("&Preferences..."), this); + //preferencesAction->setIcon(QIcon(":/preferences")); + preferencesAction->setShortcut(QKeySequence::Preferences); + preferencesAction->setStatusTip(tr("Configure preferences...")); + //preferencesAction->setIconVisibleInMenu(false); + connect(preferencesAction, SIGNAL(triggered()), this, SLOT(preferences())); + // Add quad/mesh. addMeshAction = new QAction(tr("Add Quad/&Mesh"), this); addMeshAction->setShortcut(tr("CTRL+M")); @@ -1344,6 +1360,7 @@ void MainWindow::createMenus() // editMenu->addAction(copyAction); // editMenu->addAction(pasteAction); editMenu->addAction(deleteAction); + editMenu->addAction(preferencesAction); // View. viewMenu = menuBar->addMenu(tr("&View")); diff --git a/MainWindow.h b/MainWindow.h index f4d6cdb..dc59b03 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -35,6 +35,7 @@ #include "DestinationGLCanvas.h" #include "OutputGLWindow.h" +#include "PreferencesDialog.h" #include "MappingManager.h" @@ -76,6 +77,7 @@ private slots: // File menu. void newFile(); void open(); + void preferences(); bool save(); bool saveAs(); void importVideo(); @@ -263,6 +265,7 @@ private: // QAction *copyAction; // QAction *pasteAction; QAction *deleteAction; + QAction *preferencesAction; QAction *aboutAction; QAction *clearRecentFileActions; @@ -346,6 +349,8 @@ private: QListWidgetItem* currentSelectedItem; QTimer *videoTimer; + PreferencesDialog* _preferences_dialog; + public: // Accessor/mutators for the view. /////////////////////////////////////////////////////////////////// MappingManager& getMappingManager() { return *mappingManager; } diff --git a/OutputGLWindow.cpp b/OutputGLWindow.cpp index d289c93..db4707d 100644 --- a/OutputGLWindow.cpp +++ b/OutputGLWindow.cpp @@ -2,6 +2,7 @@ * OutputGLWindow.cpp * * (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net * * 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 diff --git a/PreferencesDialog.cpp b/PreferencesDialog.cpp new file mode 100644 index 0000000..1bd71bd --- /dev/null +++ b/PreferencesDialog.cpp @@ -0,0 +1,80 @@ +/* + * OutputGLWindow.cpp + * + * (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net + * + * 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 3 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, see . + */ + +#include "PreferencesDialog.h" +#include "MainWindow.h" +#include + +PreferencesDialog::PreferencesDialog(MainWindow* mainWindow, QWidget* parent) : + QDialog(parent) +{ + (void) mainWindow; + // static const int width = 600; + // static const int height = 400; + // resize(MainWindow::OUTPUT_WINDOW_MINIMUM_WIDTH, MainWindow::OUTPUT_WINDOW_MINIMUM_HEIGHT); + + // OSC port number + QLabel* osc_port_label = new QLabel(tr("OSC port number")); + + _osc_port_numbox = new QSpinBox; + _osc_port_numbox->setRange(1024, 65534); + _osc_port_numbox->setValue(12345); // FIXME read settings + + QLayout* hbox_osc_port = new QHBoxLayout; + hbox_osc_port->addWidget(osc_port_label); + hbox_osc_port->addWidget(_osc_port_numbox); + + // cancel / ok + _button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(_button_box, SIGNAL(accepted()), this, SLOT(accept_cb())); + connect(_button_box, SIGNAL(rejected()), this, SLOT(reject_cb())); + + //QLayout* hbox_confirm = new QHBoxLayout; + //hbox_confirm->addWidget(_button_box); + hbox_osc_port->addWidget(_button_box); + + // pack all rows + //QLayout* vbox = new QVBoxLayout; + //vbox->addWidget(hbox_osc_port); + setLayout(hbox_osc_port); +} + +void PreferencesDialog::closeEvent(QCloseEvent *event) +{ + emit closed(); + event->accept(); +} + +void PreferencesDialog::reject_cb() +{ + // nothing to do + this->setResult(QMessageBox::Cancel); + this->close(); +} + +void PreferencesDialog::accept_cb() +{ + std::cout << "Values:" << + " osc port=" << _osc_port_numbox->value() << + std::endl; + this->setResult(QMessageBox::Ok); + this->close(); +} + diff --git a/PreferencesDialog.h b/PreferencesDialog.h new file mode 100644 index 0000000..d57a633 --- /dev/null +++ b/PreferencesDialog.h @@ -0,0 +1,54 @@ +/* + * OutputGLWindow.h + * + * (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net + * + * 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 3 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, see . + */ + +#ifndef PREFERENCESDIALOG_H_ +#define PREFERENCESDIALOG_H_ + +#include +#include +#include +#include +#include + +class MainWindow; + +class PreferencesDialog : public QDialog +{ + Q_OBJECT + +public: + PreferencesDialog(MainWindow* mainWindow, QWidget* parent = 0); + +protected: + void closeEvent(QCloseEvent* event); + +signals: + void closed(); + +private slots: + void accept_cb(); + void reject_cb(); + +private: + QSpinBox* _osc_port_numbox; + QDialogButtonBox* _button_box; +}; + +#endif /* PREFERENCESDIALOG_H_ */ diff --git a/mapmap.pro b/mapmap.pro index 1531161..87ff03a 100644 --- a/mapmap.pro +++ b/mapmap.pro @@ -21,6 +21,7 @@ HEADERS = \ OutputGLWindow.h \ Paint.h \ PaintGui.h \ + PreferencesDialog.h \ ProjectReader.h \ ProjectWriter.h \ Shape.h \ @@ -43,6 +44,7 @@ SOURCES = \ OutputGLWindow.cpp \ Paint.cpp \ PaintGui.cpp \ + PreferencesDialog.cpp \ ProjectReader.cpp \ ProjectWriter.cpp \ Shape.cpp \