Skip to content

Commit

Permalink
Calculate the copyright year dynamically
Browse files Browse the repository at this point in the history
The command line options for help and version info both print the
copyright as "2004-2014". Until now the value for the second year had to
be adjusted manually. With this patch they are computed dynamically so
that the current year will always be used.
  • Loading branch information
michaelgregorius committed Jul 27, 2015
1 parent d0b5046 commit d8bcc28
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <QFileInfo>
#include <QLocale>
#include <QDate>
#include <QTimer>
#include <QTranslator>
#include <QApplication>
Expand Down Expand Up @@ -75,6 +76,16 @@ static inline QString baseName( const QString & _file )
}




static std::string getCurrentYear()
{
return QString::number( QDate::currentDate().year() ).toStdString();
}




inline void loadTranslation( const QString & _tname,
const QString & _dir = ConfigManager::inst()->localeDir() )
{
Expand All @@ -92,14 +103,14 @@ inline void loadTranslation( const QString & _tname,
void printVersion(char *executableName)
{
printf( "LMMS %s\n(%s %s, Qt %s, %s)\n\n"
"Copyright (c) 2004-2014 LMMS developers.\n\n"
"Copyright (c) 2004-%s LMMS developers.\n\n"
"This program is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU General Public\n"
"License as published by the Free Software Foundation; either\n"
"version 2 of the License, or (at your option) any later version.\n\n"
"Try \"%s --help\" for more information.\n\n", LMMS_VERSION,
PLATFORM, MACHINE, QT_VERSION_STR, GCC_VERSION,
executableName );
getCurrentYear().c_str(), executableName );
}


Expand All @@ -108,7 +119,7 @@ void printVersion(char *executableName)
void printHelp()
{
printf( "LMMS %s\n"
"Copyright (c) 2004-2014 LMMS developers.\n\n"
"Copyright (c) 2004-%s LMMS developers.\n\n"
"usage: lmms [ -r <project file> ] [ options ]\n"
" [ -u <in> <out> ]\n"
" [ -d <in> ]\n"
Expand Down Expand Up @@ -137,9 +148,9 @@ void printHelp()
" standard out is used if no output file is specifed\n"
"-d, --dump <in> dump XML of compressed file <in>\n"
"-v, --version show version information and exit.\n"
" --allowroot bypass root user startup check (use with caution).\n"
" --allowroot bypass root user startup check (use with caution).\n"
"-h, --help show this usage information and exit.\n\n",
LMMS_VERSION );
LMMS_VERSION, getCurrentYear().c_str() );
}


Expand Down

0 comments on commit d8bcc28

Please sign in to comment.