Mercurial > hg > forks > UniversalIndentGUI
changeset 652:d7b4ce40ceb9
From now on using an extra file and functions for gathering the version, build date and revision. This uncouples the connection between the MainWindow and AboutDialog and UpdateCheckDialog a bit by reducing the number of needed constructor parameters.
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@911 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Wed, 04 Feb 2009 16:46:26 +0000 |
parents | f358d0da57cf |
children | edf5f567ba17 |
files | resources/programicon.rc src/AboutDialog.cpp src/AboutDialog.h src/MainWindow.cpp src/MainWindow.h src/UiGuiVersion.cpp src/UiGuiVersion.h src/UniversalIndentGUI.vcproj src/UniversalIndentGUI_NPP/NPPCommon/Notepad_plus_msgs.h src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj src/UpdateCheckDialog.cpp src/UpdateCheckDialog.h |
diffstat | 12 files changed, 118 insertions(+), 120 deletions(-) [+] |
line wrap: on
line diff
--- a/resources/programicon.rc Tue Feb 03 22:12:22 2009 +0000 +++ b/resources/programicon.rc Wed Feb 04 16:46:26 2009 +0000 @@ -39,6 +39,17 @@ #endif //_WIN32 +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + #define PROGRAM_TITLE "UniversalIndentGUI Notepad++ Plugin" + #define INTERNALNAME "UiGUI NPP Plugin" + #define ORIGINALFILENAME "UniversalIndentGUI_NPP.dll" +#else + #define PROGRAM_TITLE "UniversalIndentGUI" + #define INTERNALNAME "UiGUI" + #define ORIGINALFILENAME "UniversalIndentGUI.exe" +#endif + + #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // @@ -66,10 +77,10 @@ VALUE "CompanyName", "Thomas Schweitzer\0" VALUE "FileDescription", PROGRAM_TITLE "\0" VALUE "FileVersion", RESOURCE_VERSION_STRING - VALUE "InternalName", "UiGUI\0" + VALUE "InternalName", INTERNALNAME "\0" VALUE "LegalCopyright", "Copyright © Thomas Schweitzer 2009\0" VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "UniversalIndentGUI.exe\0" + VALUE "OriginalFilename", ORIGINALFILENAME "\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", PROGRAM_TITLE "\0" VALUE "ProductVersion", RESOURCE_VERSION_STRING
--- a/src/AboutDialog.cpp Tue Feb 03 22:12:22 2009 +0000 +++ b/src/AboutDialog.cpp Wed Feb 04 16:46:26 2009 +0000 @@ -19,6 +19,8 @@ #include "AboutDialog.h" +#include "UiGuiVersion.h" + /*! \class AboutDialog \brief Displays a dialog window with information about UniversalIndentGUI @@ -28,7 +30,7 @@ \brief The constructor calls the setup function for the ui created by uic and adds the GPL text to the text edit. */ -AboutDialog::AboutDialog(QWidget *parent, Qt::WindowFlags flags, QString version, QString revision, QString buildDate) : QDialog(parent, flags) { +AboutDialog::AboutDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags) { this->parent = parent; qApp->setStyleSheet("QTextBrowser{background-color:transparent}"); setupUi(this); @@ -37,9 +39,10 @@ authorTextBrowser->setOpenExternalLinks( true ); creditsTextBrowser->setOpenExternalLinks( true ); - this->version = version; - this->revision = revision; - this->buildDate = buildDate; + this->version = PROGRAM_VERSION_STRING; + this->revision = UiGuiVersion::getBuildRevision(); + this->buildDate = UiGuiVersion::getBuildDate(); + QString versionString = versionTextBrowser->toHtml(); versionString = versionString.arg(version).arg(revision).arg(buildDate); versionTextBrowser->setHtml(versionString);
--- a/src/AboutDialog.h Tue Feb 03 22:12:22 2009 +0000 +++ b/src/AboutDialog.h Wed Feb 04 16:46:26 2009 +0000 @@ -35,7 +35,7 @@ Q_OBJECT public: - AboutDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0, QString version = "", QString revision = "", QString buildDate = ""); + AboutDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); public slots: int exec();
--- a/src/MainWindow.cpp Tue Feb 03 22:12:22 2009 +0000 +++ b/src/MainWindow.cpp Wed Feb 04 16:46:26 2009 +0000 @@ -19,6 +19,8 @@ #include "MainWindow.h" +#include "UiGuiVersion.h" + //! \defgroup grp_MainWindow All concerning main window functionality. /*! @@ -35,12 +37,6 @@ \brief Constructs the main window. */ MainWindow::MainWindow(QString file2OpenOnStart, QWidget *parent) : QMainWindow(parent) { - // set the program version, revision and date, which is shown in the main window title and in the about dialog. - version = "1.0.2"; - revision = "907"; - QDate buildDate(2009, 1, 4); - buildDateStr = buildDate.toString("d. MMMM yyyy"); - // Init of some variables. sourceCodeChanged = false; scrollPositionChanged = false; @@ -71,13 +67,13 @@ createHighlighterMenu(); - // generate about dialog box - aboutDialog = new AboutDialog(this, Qt::SplashScreen, version, revision, buildDateStr); + // Generate about dialog box + aboutDialog = new AboutDialog(this, Qt::SplashScreen); aboutDialogGraphicsView = new AboutDialogGraphicsView(aboutDialog, this); connect( toolBarWidget->pbAbout, SIGNAL(clicked()), this, SLOT(showAboutDialog()) ); connect( actionAbout_UniversalIndentGUI, SIGNAL(triggered()), this, SLOT(showAboutDialog()) ); - // generate settings dialog box + // Generate settings dialog box settingsDialog = new UiGuiSettingsDialog(this, settings); connect( actionShowSettings, SIGNAL(triggered()), settingsDialog, SLOT(showDialog()) ); @@ -127,7 +123,7 @@ // ----------------------------------- QString readVersion = settings->getValueByName("VersionInSettingsFile").toString(); // If version strings are not equal set first run true. - if ( readVersion != version ) { + if ( readVersion != PROGRAM_VERSION_STRING ) { isFirstRunOfThisVersion = true; } else { @@ -138,7 +134,7 @@ // ------------------------------- currentEncoding = settings->getValueByName("FileEncoding").toString(); - updateCheckDialog = new UpdateCheckDialog(version, settings, this); + updateCheckDialog = new UpdateCheckDialog(settings, this); // Register the syntax highlightning setting in the menu to the settings object. connect( enableSyntaxHighlightningAction, SIGNAL(toggled(bool)), settings, SLOT(handleValueChangeFromExtern(bool)) ); @@ -813,7 +809,7 @@ source code filename. */ void MainWindow::updateWindowTitle() { - this->setWindowTitle( "UniversalIndentGUI " + version +" [*]"+ currentSourceFile); + this->setWindowTitle( "UniversalIndentGUI " + QString(PROGRAM_VERSION_STRING) + " [*]" + currentSourceFile ); } @@ -925,7 +921,7 @@ */ void MainWindow::saveSettings() { settings->setValueByName( "FileEncoding", currentEncoding ); - settings->setValueByName( "VersionInSettingsFile", version ); + settings->setValueByName( "VersionInSettingsFile", PROGRAM_VERSION_STRING ); settings->setValueByName( "WindowIsMaximized", isMaximized() ); if ( !isMaximized() ) { settings->setValueByName( "WindowPosition", pos() );
--- a/src/MainWindow.h Tue Feb 03 22:12:22 2009 +0000 +++ b/src/MainWindow.h Wed Feb 04 16:46:26 2009 +0000 @@ -79,10 +79,6 @@ QsciScintilla *qSciSourceCodeEditor; UiGuiSettings *settings; - QString version; - QString revision; - QString buildDateStr; - QString currentEncoding; QString sourceFileContent; QString sourceFormattedContent;
--- a/src/UiGuiVersion.cpp Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UiGuiVersion.cpp Wed Feb 04 16:46:26 2009 +0000 @@ -19,51 +19,45 @@ #include "UiGuiVersion.h" -#include "stdlib.h" -#include "string.h" +#include <QString> +#include <QStringList> +#include <QDate> -const int programVersionDate() -{ - static int version = 0; +namespace UiGuiVersion { - if (0 == version) { - union timeUnion { - struct { - char Mmm[3]; - char space1; - char dd[2]; - char space2; - char yyyy[4]; - char terminator; - }; - char timeString[12]; - }; - timeUnion timeVar; - //get date from system - const char * dateString = __DATE__; - //copy to internal - strncpy((char *)&timeVar.timeString, dateString, 11); - //terminate string - timeVar.timeString[11] = 0; - //swap characters - char convertString[9]; - strncpy((char *)&convertString, (char *)&timeVar.yyyy, 4); - strncpy((char *)&convertString[6], (char *)&timeVar.dd, 2); - //convert month - const char * month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez", NULL}; - const char * monthNumbers[] = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "00"}; - //find string in table - for (int i = 0; month[i] != NULL; i++) { - if (strncmp(month[i], (char *)&timeVar.Mmm, 2) == 0) { - strncpy((char *)&convertString[4], monthNumbers[i], 2); - break; - } - } - //terminate string - convertString[8] = 0; - version = atoi((char *)&convertString); +/*! + \brief Returns the build date as a localized string, e.g. "9. Februar 2009". If + there was some kind of error, the returned string is empty. + */ +QString getBuildDate() { + QStringList monthNames; + QString buildDateString = ""; + + monthNames << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dez"; + QStringList buildDateStringList = QString(__DATE__).simplified().split(' '); // __DATE__ returns eg "Feb 4 2009" + + if ( buildDateStringList.count() == 3 ) { + QDate buildDate(buildDateStringList.last().toInt(), monthNames.indexOf( buildDateStringList.first() )+1, buildDateStringList.at(1).toInt()); + buildDateString = buildDate.toString("d. MMMM yyyy"); } - return version; - //return PROGRAM_DATE; //ORIGINAL 24.11.2008!!! + return buildDateString; } + + +/*! + \brief Returns the revision number, that the current build is based on, as string. If + there was some kind of error, the returned string is empty. + */ +QString getBuildRevision() { + QString buildRevision = ""; + QStringList buildRevisionStringList = QString(PROGRAM_REVISION).simplified().split(' '); + + if ( buildRevisionStringList.count() == 3 ) { + buildRevision = buildRevisionStringList.at(1); // PROGRAM_REVISION is eg "$Revision: 907 $" + } + + return buildRevision; +} + +} // namespace UiGuiVersion
--- a/src/UiGuiVersion.h Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UiGuiVersion.h Wed Feb 04 16:46:26 2009 +0000 @@ -20,13 +20,20 @@ #ifndef UIGUIVERSION_H #define UIGUIVERSION_H -#define PROGRAM_VERSION 1.0.2 -#define PROGRAM_VERSION_STRING "1.0.2" -#define RESOURCE_VERSION 1,0,2,0 -#define RESOURCE_VERSION_STRING "1,0,2,0\0" -#define PROGRAM_REVISION "$Revision: 2831 $" -#define PROGRAM_TITLE "UniversalIndentGUI" +class QString; -const int programVersionDate(); +// Define the version number here. Update this as the last file before a release. +#define PROGRAM_VERSION 1.0.1 +#define PROGRAM_VERSION_STRING "1.0.1" +#define RESOURCE_VERSION 1,0,1,0 +#define RESOURCE_VERSION_STRING "1,0,1,0\0" +#define PROGRAM_REVISION "$Revision$" + +namespace UiGuiVersion { + + QString getBuildDate(); + QString getBuildRevision(); + +} #endif // UIGUIVERSION_H
--- a/src/UniversalIndentGUI.vcproj Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UniversalIndentGUI.vcproj Wed Feb 04 16:46:26 2009 +0000 @@ -215,17 +215,6 @@ <File RelativePath=".\AboutDialogGraphicsView.cpp" > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\UiGuiHighlighter.cpp" - > </File> <File RelativePath=".\IndentHandler.cpp" @@ -243,7 +232,7 @@ RelativePath=".\SettingsPaths.cpp" > </File> - <File + <File RelativePath=".\TemplateBatchScript.cpp" > </File> @@ -252,6 +241,10 @@ > </File> <File + RelativePath=".\UiGuiHighlighter.cpp" + > + </File> + <File RelativePath=".\UiGuiIndentServer.cpp" > </File> @@ -268,6 +261,10 @@ > </File> <File + RelativePath=".\UiGuiVersion.cpp" + > + </File> + <File RelativePath=".\UpdateCheckDialog.cpp" > </File> @@ -284,17 +281,6 @@ <File RelativePath=".\AboutDialogGraphicsView.h" > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="MOC" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\UiGuiHighlighter.h" - > </File> <File RelativePath=".\IndentHandler.h" @@ -317,6 +303,10 @@ > </File> <File + RelativePath=".\UiGuiHighlighter.h" + > + </File> + <File RelativePath=".\UiGuiIndentServer.h" > </File> @@ -333,6 +323,10 @@ > </File> <File + RelativePath=".\UiGuiVersion.h" + > + </File> + <File RelativePath=".\UpdateCheckDialog.h" > </File> @@ -385,17 +379,6 @@ <File RelativePath="$(OutDir)\tmp\moc\moc_AboutDialogGraphicsView.cpp" > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - </File> - <File - RelativePath="$(OutDir)\tmp\moc\moc_UiGuiHighlighter.cpp" - > </File> <File RelativePath="$(OutDir)\tmp\moc\moc_IndentHandler.cpp" @@ -410,6 +393,10 @@ > </File> <File + RelativePath="$(OutDir)\tmp\moc\moc_UiGuiHighlighter.cpp" + > + </File> + <File RelativePath="$(OutDir)\tmp\moc\moc_UiGuiIndentServer.cpp" > </File>
--- a/src/UniversalIndentGUI_NPP/NPPCommon/Notepad_plus_msgs.h Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UniversalIndentGUI_NPP/NPPCommon/Notepad_plus_msgs.h Wed Feb 04 16:46:26 2009 +0000 @@ -431,4 +431,4 @@ // UCHAR _key; //}; -#endif //NOTEPAD_PLUS_MSGS_H \ No newline at end of file +#endif //NOTEPAD_PLUS_MSGS_H
--- a/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj Wed Feb 04 16:46:26 2009 +0000 @@ -52,10 +52,9 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalOptions="/D _CRT_SECURE_NO_DEPRECATE" Optimization="0" AdditionalIncludeDirectories=""$(QTDIR)\include\QtScript";.;NPPCommon;.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UNIVERSALINDENTGUI_NPP_EXPORTS;__STDC_WANT_SECURE_LIB__=0;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UNIVERSALINDENTGUI_NPP_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -71,6 +70,7 @@ /> <Tool Name="VCResourceCompilerTool" + PreprocessorDefinitions="_VC80_UPGRADE=0x0700;UNIVERSALINDENTGUI_NPP_EXPORTS" /> <Tool Name="VCPreLinkEventTool" @@ -78,7 +78,7 @@ <Tool Name="VCLinkerTool" AdditionalDependencies="shlwapi.lib comctl32.lib qtmaind.lib QtGuid4.lib QtCored4.lib QtScriptd4.lib " - OutputFile="D:\Programme\Tools\Notepad++\plugins\$(ProjectName).dll" + OutputFile="C:\temp\smallwebserve\WebdevelopmentIDE\devtools\npp\plugins\$(ProjectName).dll" LinkIncremental="2" GenerateDebugInformation="true" ProgramDatabaseFile="$(OutDir)\$(TargetName).pdb" @@ -146,7 +146,7 @@ <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories=""$(QTDIR)\include\QtScript";.;NPPCommon;.." - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UNIVERSALINDENTGUI_NPP_EXPORTS;__STDC_WANT_SECURE_LIB__=0;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UNIVERSALINDENTGUI_NPP_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" @@ -158,6 +158,7 @@ /> <Tool Name="VCResourceCompilerTool" + PreprocessorDefinitions="_VC80_UPGRADE=0x0700;UNIVERSALINDENTGUI_NPP_EXPORTS" /> <Tool Name="VCPreLinkEventTool" @@ -165,7 +166,7 @@ <Tool Name="VCLinkerTool" AdditionalDependencies="shlwapi.lib comctl32.lib qtmain.lib QtGui4.lib QtCore4.lib QtScript4.lib" - OutputFile="D:\Programme\Tools\Notepad++\plugins\$(ProjectName).dll" + OutputFile="C:\temp\smallwebserve\WebdevelopmentIDE\devtools\npp\plugins\$(ProjectName).dll" LinkIncremental="1" GenerateDebugInformation="false" SubSystem="2" @@ -274,6 +275,10 @@ > </File> <File + RelativePath="..\UiGuiVersion.h" + > + </File> + <File RelativePath=".\UniversalIndentGUI_NPP.h" > <FileConfiguration
--- a/src/UpdateCheckDialog.cpp Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UpdateCheckDialog.cpp Wed Feb 04 16:46:26 2009 +0000 @@ -19,6 +19,7 @@ #include "UpdateCheckDialog.h" +#include "UiGuiVersion.h" #include <QRegExpValidator> /*! @@ -31,7 +32,7 @@ /*! \brief Initializes member variables and stores the version of UiGui and a pointer to the settings object. */ -UpdateCheckDialog::UpdateCheckDialog(QString currentVersion, UiGuiSettings *settings, QWidget *parent) : QDialog(parent) { +UpdateCheckDialog::UpdateCheckDialog(UiGuiSettings *settings, QWidget *parent) : QDialog(parent) { setupUi(this); manualUpdateRequested = false; @@ -50,7 +51,6 @@ // Connect the dialogs buttonbox with a button click handler. connect( buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(handleUpdateCheckDialogButtonClicked(QAbstractButton*)) ); - this->currentVersion = currentVersion; this->settings = settings; // This dialog is always modal. @@ -117,7 +117,7 @@ // Create integer values from the version strings. int versionOnServerInt = convertVersionStringToNumber( returnedString ); - int currentVersionInt = convertVersionStringToNumber( currentVersion ); + int currentVersionInt = convertVersionStringToNumber( PROGRAM_VERSION_STRING ); // Only show update dialog, if the current version number is lower than the one received from the server. if ( versionOnServerInt > currentVersionInt && currentVersionInt >= 0 && versionOnServerInt >= 0 ) { @@ -176,7 +176,7 @@ void UpdateCheckDialog::showNewVersionAvailableDialog(QString newVersion) { progressBar->hide(); setWindowTitle( tr("Update available") ); - label->setText( tr("A newer version of UniversalIndentGUI is available.\nYour version is %1. New version is %2.\nDo you want to go to the download website?").arg(currentVersion).arg(newVersion) ); + label->setText( tr("A newer version of UniversalIndentGUI is available.\nYour version is %1. New version is %2.\nDo you want to go to the download website?").arg(PROGRAM_VERSION_STRING).arg(newVersion) ); buttonBox->setStandardButtons(QDialogButtonBox::No|QDialogButtonBox::NoButton|QDialogButtonBox::Yes); exec(); }
--- a/src/UpdateCheckDialog.h Tue Feb 03 22:12:22 2009 +0000 +++ b/src/UpdateCheckDialog.h Wed Feb 04 16:46:26 2009 +0000 @@ -38,7 +38,7 @@ Q_OBJECT public: - UpdateCheckDialog(QString currentVersion, UiGuiSettings *settings, QWidget *parent=0); + UpdateCheckDialog(UiGuiSettings *settings, QWidget *parent=0); public slots: void checkForUpdateAndShowDialog(); @@ -53,7 +53,6 @@ UiGuiSettings *settings; bool manualUpdateRequested; QHttp *http; - QString currentVersion; QDialogButtonBox::ButtonRole roleOfClickedButton; QTimer *updateCheckProgressTimer; int updateCheckProgressCounter;