diff --git a/Commands.cpp b/Commands.cpp index 514c0b7..b1e0146 100644 --- a/Commands.cpp +++ b/Commands.cpp @@ -1,3 +1,26 @@ +/* + * Commands.cpp + * + * (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net + * (c) 2014 Dame Diongue -- baydamd(@)gmail(.)com + * + * 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 "MainWindow.h" +#include "MapperGLCanvas.h" #include "Commands.h" diff --git a/Commands.h b/Commands.h index ee5a7d3..4d53faf 100644 --- a/Commands.h +++ b/Commands.h @@ -23,8 +23,6 @@ #define COMMANDS_H_ #include -#include "MainWindow.h" -#include "MapperGLCanvas.h" enum CommandId { CMD_KEY_MOVE_VERTEX, @@ -33,6 +31,9 @@ enum CommandId { CMD_MOUSE_TRANSLATE_SHAPE, }; +class MainWindow; +class MapperGLCanvas; + class AddShapesCommand : public QUndoCommand { public: diff --git a/MainWindow.cpp b/MainWindow.cpp index d110865..2d35171 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1398,7 +1398,7 @@ void MainWindow::createLayout() sourceCanvasToolbar = new MapperGLCanvasToolbar(sourceCanvas, this); QVBoxLayout* sourceLayout = new QVBoxLayout; - QWidget* sourcePanel = new QWidget(this); + sourcePanel = new QWidget(this); sourceLayout->setContentsMargins(0, 0, 0, 0); sourceLayout->addWidget(sourceCanvas); @@ -1412,7 +1412,7 @@ void MainWindow::createLayout() destinationCanvasToolbar = new MapperGLCanvasToolbar(destinationCanvas, this); QVBoxLayout* destinationLayout = new QVBoxLayout; - QWidget* destinationPanel = new QWidget(this); + destinationPanel = new QWidget(this); destinationLayout->setContentsMargins(0, 0, 0, 0); destinationLayout->addWidget(destinationCanvas); diff --git a/MainWindow.h b/MainWindow.h index 3a51dfb..fec4b4d 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -370,8 +370,10 @@ private: MapperGLCanvas* sourceCanvas; MapperGLCanvasToolbar* sourceCanvasToolbar; + QWidget* sourcePanel; MapperGLCanvas* destinationCanvas; MapperGLCanvasToolbar* destinationCanvasToolbar; + QWidget* destinationPanel; OutputGLWindow* outputWindow; ConsoleWindow* consoleWindow; diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index af798c9..db57a40 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#include "ShapeGraphicsItem.h" #include "MapperGLCanvas.h" #include "MainWindow.h" diff --git a/MappingGui.h b/MappingGui.h index 63d434a..116cade 100644 --- a/MappingGui.h +++ b/MappingGui.h @@ -39,11 +39,10 @@ #include "MapperGLCanvas.h" -#ifndef WIN32 #include "ShapeGraphicsItem.h" #include "ShapeControlPainter.h" + #include "Util.h" -#endif #include "qtpropertymanager.h" #include "qtvariantproperty.h" @@ -54,10 +53,6 @@ #include "variantmanager.h" #include "variantfactory.h" -class MapperGLCanvas; -class ShapeGraphicsItem; -class ShapeControlPainter; - /** * This is the "view" side of the Mapping class (model). It contains the graphic items for * both input and output as well as the properties editor. diff --git a/Maths.h b/Maths.h index d14ba3e..0d28f6e 100644 --- a/Maths.h +++ b/Maths.h @@ -25,10 +25,6 @@ #include #include -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - /// Converts from degrees to radians. inline qreal degreesToRadians(qreal degrees) { return degrees / 180.0f * M_PI; } diff --git a/Paint.cpp b/Paint.cpp index 5da1cfe..4611b57 100644 --- a/Paint.cpp +++ b/Paint.cpp @@ -235,7 +235,6 @@ bool Video::_generateThumbnail() // Copy bits into thumbnail QImage. QImage thumbnail(getWidth(), getHeight(), QImage::Format_ARGB32); - int i=0; for (int y=0; y -#include #include diff --git a/ShapeGraphicsItem.cpp b/ShapeGraphicsItem.cpp index c3d656f..678ffd0 100644 --- a/ShapeGraphicsItem.cpp +++ b/ShapeGraphicsItem.cpp @@ -22,10 +22,6 @@ #include "MainWindow.h" -#ifdef WIN32 -#include "Util.h" -#endif - ShapeGraphicsItem::ShapeGraphicsItem(Mapping::ptr mapping, bool output) : _mapping(mapping), _output(output) { diff --git a/VideoImpl.cpp b/VideoImpl.cpp index 39fe02c..d70095b 100644 --- a/VideoImpl.cpp +++ b/VideoImpl.cpp @@ -296,7 +296,7 @@ void VideoImpl::resetMovie() if (_seekEnabled) { if (_rate > 0) - seekTo(0UL); + seekTo((guint64)0); else { // NOTE: Untested. diff --git a/build.sh b/build.sh index 1e01805..f48894e 100755 --- a/build.sh +++ b/build.sh @@ -70,10 +70,6 @@ if [[ $unamestr == "Darwin" ]]; then qmake -config release make -j4 - # Release language files - echo "Integrating language resources ..." - lrelease resources/texts/mapmap_*.ts - # Bundle Qt frameworks in app using macdeployqt echo "Bundling Qt ..." macdeployqt $app @@ -89,7 +85,6 @@ if [[ $unamestr == "Darwin" ]]; then do_create_dmg elif [[ $unamestr == "Linux" ]]; then qmake - make - lrelease resources/texts/mapmap_*.ts + make -j4 fi diff --git a/main.cpp b/main.cpp index 9dd2ea0..9a58424 100644 --- a/main.cpp +++ b/main.cpp @@ -111,6 +111,10 @@ int main(int argc, char *argv[]) QCommandLineOption oscPortOption(QStringList() << "p" << "osc-port", "Use OSC port number .", "osc-port", ""); parser.addOption(oscPortOption); + // --lang option + QCommandLineOption localeOption(QStringList() << "l" << "lang", "Use language .", "lang", "en"); + parser.addOption(localeOption); + // Positional argument: file parser.addPositionalArgument("file", "Load project from that file."); @@ -124,6 +128,20 @@ int main(int argc, char *argv[]) Util::eraseSettings(); } + // IMPORTANT: Translator must be set *before* the MainWindow is created for it to work. + QString langValue = parser.value("lang"); + QTranslator translator; + if (translator.load(QString(":/translation-%1").arg(langValue))) + { + qDebug() << "Setting language to " << langValue << "." << endl; + app.installTranslator(&translator); + QLocale::setDefault(QLocale(langValue)); + } + else if (langValue != "en") + { + qWarning() << "Unrecognized/unsupported language: " << langValue << "." << endl; + } + #endif // USING_QT_5 if (! QGLFormat::hasOpenGL()) @@ -157,8 +175,6 @@ int main(int argc, char *argv[]) stylesheet.open(QFile::ReadOnly); app.setStyleSheet(QLatin1String(stylesheet.readAll())); - //win.setLocale(QLocale("fr")); - #if USING_QT_5 // read positional argument: const QStringList args = parser.positionalArguments(); @@ -186,8 +202,10 @@ int main(int argc, char *argv[]) { win->setOscPort(oscPortNumberValue); } + #endif + // Terminate splash. splash.showMessage(" " + QObject::tr("Done."), Qt::AlignLeft | Qt::AlignTop, MM::WHITE); diff --git a/mapmap.pro b/mapmap.pro index 1e1625d..f3d1646 100644 --- a/mapmap.pro +++ b/mapmap.pro @@ -84,11 +84,26 @@ SOURCES = \ Util.cpp \ main.cpp -RESOURCES = mapmap.qrc -TRANSLATIONS = resources/texts/mapmap_*.ts + include(contrib/qtpropertybrowser/src/qtpropertybrowser.pri) include(contrib/qtpropertybrowser-extension/qtpropertybrowser-extension.pri) +TRANSLATIONS = resources/texts/mapmap_fr.ts +RESOURCES = mapmap.qrc + +# Manage lrelease (for translations) +isEmpty(QMAKE_LRELEASE) { + win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe + else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease +} +updateqm.input = TRANSLATIONS +updateqm.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm +updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm +updateqm.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += updateqm +PRE_TARGETDEPS += compiler_updateqm_make_all +system(lrelease mapmap.pro) # Run lrelease + # Add the docs target: docs.depends = $(HEADERS) $(SOURCES) docs.commands = (cat Doxyfile; echo "INPUT = $?") | doxygen - @@ -163,25 +178,23 @@ mac { # Windows-specific: win32 { DEFINES += WIN32 - INCLUDEPATH += \ - C:/gstreamer/include \ - C:/gstreamer/include/libxml2 \ - C:/gstreamer/include/glib-2.0 \ - C:/gstreamer/lib/glib-2.0/include \ - C:/gstreamer/include/gstreamer-0.10 - LIBS += -L"C:/gstreamer/lib" \ - -L"C:/gstreamer/bin" \ - -lgstreamer-0.10 \ - -lglib-2.0 \ - -lgmodule-2.0 \ + INCLUDEPATH += C:/gstreamer/1.0/x86/lib/gstreamer-1.0/include \ + C:/gstreamer/1.0/x86/include/glib-2.0 \ + C:/gstreamer/1.0/x86/lib/glib-2.0/include \ + C:/gstreamer/1.0/x86/include/gstreamer-1.0 + LIBS += -LC:/gstreamer/1.0/x86/lib \ + -lgstapp-1.0 \ + -lgstbase-1.0 \ + -lgstpbutils-1.0 \ + -lgstreamer-1.0 \ -lgobject-2.0 \ - -lgthread-2.0 \ - -lgstinterfaces-0.10 \ - -lopengl32 \ - -lglu32 + -lglib-2.0 \ + -lopengl32 + # Add console to the CONFIG to see debug messages printed in # the console on Windows CONFIG += console + QMAKE_CXXFLAGS += -D_USE_MATH_DEFINES } # Adds the tarball target diff --git a/mapmap.qrc b/mapmap.qrc index 871ee18..45ffc66 100644 --- a/mapmap.qrc +++ b/mapmap.qrc @@ -26,16 +26,20 @@ resources/fonts/DroidSans.otf resources/fonts/DroidSans.otf resources/images/test-signal/test-signal.svg - resources/qss/mapmap.qss resources/images/icons/zoom_reset_w.png resources/images/icons/zoom_in_w.png resources/images/icons/zoom_out_w.png resources/images/icons/zoom_fit_w.png - resources/fonts/Hack-Regular.otf resources/images/icons/small/delete_w.png resources/images/icons/small/lock_w.png resources/images/icons/small/visible_w.png resources/images/icons/small/duplicate_w.png resources/images/icons/small/solo_w.png + + resources/qss/mapmap.qss + resources/fonts/Hack-Regular.otf + + resources/texts/mapmap_fr.qm +