diff --git a/application/AboutWindow.cpp b/application/AboutWindow.cpp new file mode 100644 index 0000000..edae162 --- /dev/null +++ b/application/AboutWindow.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2010, Pier Luigi Fiorini. All rights reserved. + * Copyright 2007-2009, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com + * Ryan Leavengood, leavengood@gmail.com + */ + +#include +#include +#include +#include +#include + + +AboutWindow::AboutWindow(const char* appName, const char** holders, + const char** authors, const char* extraInfo) +{ + fAppName = new BString(appName); + + // Build the text to display + int32 i; + BString text(appName); + text << "\n\n"; + for (i = 0; holders[i]; i++) + text << "Copyright " B_UTF8_COPYRIGHT " " << holders[i] << "\n"; + text << "\nWritten by:\n"; + for (int32 i = 0; authors[i]; i++) + text << " " << authors[i] << "\n"; + + // The extra information is optional + if (extraInfo != NULL) + text << "\n" << extraInfo << "\n"; + + fText = new BString(text); +} + + +AboutWindow::~AboutWindow() +{ + delete fText; + delete fAppName; +} + + +void +AboutWindow::Show() +{ + BAlert* alert = new BAlert("About" B_UTF8_ELLIPSIS, fText->String(), "Close"); + BTextView* view = alert->TextView(); + BFont font; + view->SetStylable(true); + view->GetFont(&font); + font.SetFace(B_BOLD_FACE); + font.SetSize(font.Size() * 1.7f); + view->SetFontAndColor(0, fAppName->Length(), &font); + alert->Go(); +} diff --git a/application/AboutWindow.h b/application/AboutWindow.h new file mode 100644 index 0000000..2d57b24 --- /dev/null +++ b/application/AboutWindow.h @@ -0,0 +1,24 @@ +/* + * Copyright 2010, Pier Luigi Fiorini. All rights reserved. + * Copyright 2007-2009, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _ABOUT_WINDOW_H +#define _ABOUT_WINDOW_H + +#include + +class AboutWindow { +public: + AboutWindow(const char* appName, const char** holders, + const char** authors, const char* extraInfo = NULL); + virtual ~AboutWindow(); + + void Show(); + +private: + BString* fAppName; + BString* fText; +}; + +#endif // _ABOUT_WINDOW_H diff --git a/application/Jamfile b/application/Jamfile index 9156cad..cf38d99 100644 --- a/application/Jamfile +++ b/application/Jamfile @@ -10,7 +10,13 @@ SubDirSysHdrs [ FDirName $(OPENSSL_INCLUDE_DIR) ] ; SEARCH_SOURCE += [ FDirName $(TOP) application preferences ] ; SEARCH_SOURCE += [ FDirName $(TOP) application views ] ; +# SVN revision +local svnRevisionFile = [ FGristFiles svn_revision ] ; +MakeLocate $(svnRevisionFile) : $(LOCATE_TARGET) ; +CreateSVNRevisionFile $(svnRevisionFile) ; + Application caya : + AboutWindow.cpp Account.cpp AccountManager.cpp CayaUtils.cpp @@ -27,6 +33,7 @@ Application caya : Server.cpp TheApp.cpp WindowsManager.cpp + svn_revision.cpp # preferences AccountDialog.cpp diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index cd83b8f..9a289e8 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -85,10 +85,10 @@ MainWindow::MainWindow() : // Wrench menu BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench"); - (void)wrenchMenu->AddItem(new BMenuItem("About Caya...", + (void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); (void)wrenchMenu->AddItem(new BSeparatorItem()); - (void)wrenchMenu->AddItem(new BMenuItem("Preferences...", + (void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(kPreferences))); (void)wrenchMenu->AddItem(new BSeparatorItem()); (void)wrenchMenu->AddItem(new BMenuItem("Quit", @@ -201,9 +201,11 @@ MainWindow::MessageReceived(BMessage* message) case IM_ERROR: ImError(message); break; + case B_ABOUT_REQUESTED: + be_app->PostMessage(message); + break; default: BWindow::MessageReceived(message); - break; } } diff --git a/application/TheApp.cpp b/application/TheApp.cpp index bcdc216..b809bc2 100644 --- a/application/TheApp.cpp +++ b/application/TheApp.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2009, Andrea Anzani. All rights reserved. + * Copyright 2009-2010, Andrea Anzani. All rights reserved. + * Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -13,6 +14,7 @@ #include #include +#include "AboutWindow.h" #include "Caya.h" #include "TheApp.h" #include "FilePanel.h" @@ -20,6 +22,8 @@ #include "Emoticor.h" #include "ProtocolManager.h" +#include "svn_revision.h" + TheApp::TheApp() : BApplication(CAYA_SIGNATURE), @@ -71,6 +75,32 @@ TheApp::ReadyToRun() } +void +TheApp::AboutRequested() +{ + const char* holders[] = { + "2009-2010 Andrea Anzani", + "2009-2010 Pier Luigi Fiorini", + NULL + }; + + const char* authors[] = { + "Andrea Anzani", + "Pier Luigi Fiorini", + NULL + }; + + BString extraInfo; + extraInfo << "SVN Revision: " << kSVNRevision << "\n"; + extraInfo << "Built: " << BUILD_DATE; + + AboutWindow* about = new AboutWindow("Caya", holders, + authors, extraInfo.String()); + about->Show(); + delete about; +} + + MainWindow* TheApp::GetMainWindow() const { diff --git a/application/svn_revision.cpp b/application/svn_revision.cpp new file mode 100644 index 0000000..dedefb3 --- /dev/null +++ b/application/svn_revision.cpp @@ -0,0 +1,10 @@ +/* + * Copyright 2010, Pier Luigi Fiorini. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include "svn_revision.h" + +const int32 kSVNRevision = + #include "svn_revision" +; diff --git a/application/svn_revision.h b/application/svn_revision.h new file mode 100644 index 0000000..65282d3 --- /dev/null +++ b/application/svn_revision.h @@ -0,0 +1,13 @@ +/* + * Copyright 2010, Pier Luigi Fiorini. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef _SVN_REVISION_H +#define _SVN_REVISION_H + +#include + +extern const int32 kSVNRevision; + +#endif // _SVN_REVISION_H