From 52b06bd89d91e2f5e0c1ae439cd1e5c3e4b9bf2e Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sat, 29 Aug 2009 10:07:01 +0100 Subject: Basic About dialog diff --git a/Swift/QtUI/QtAboutWidget.cpp b/Swift/QtUI/QtAboutWidget.cpp new file mode 100644 index 0000000..bc3fb4b --- /dev/null +++ b/Swift/QtUI/QtAboutWidget.cpp @@ -0,0 +1,45 @@ +#include "Swift/QtUI/QtAboutWidget.h" + +#include +#include +#include +#include +#include + + +#include "Swiften/Application/Application.h" + +namespace Swift { +QtAboutWidget* QtAboutWidget::instance() { + if (!instance_) { + instance_ = new QtAboutWidget(); + } + return instance_; +} + +QtAboutWidget::QtAboutWidget() : QWidget() { + resize(180, 240); + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->setAlignment(Qt::AlignHCenter); + setLayout(mainLayout); + + QLabel* iconLabel = new QLabel(this); + iconLabel->setPixmap(QIcon(":/logo-shaded-text.256.png").pixmap(90, 90)); + mainLayout->addWidget(iconLabel); + + QLabel* appNameLabel = new QLabel("" + QCoreApplication::applicationName() + "", this); + //appNameLabel->setTextFormat + mainLayout->addWidget(appNameLabel); + + QLabel* versionLabel = new QLabel(QString("Version ") + QCoreApplication::applicationVersion() + "", this); + mainLayout->addWidget(versionLabel); + QString buildString = QString("Built with: Qt version ") + QT_VERSION_STR; + buildString += QString("
Running with Qt version ") + qVersion(); + buildString += "
"; + QLabel* buildLabel = new QLabel(buildString, this); + mainLayout->addWidget(buildLabel); + +} + +QtAboutWidget* QtAboutWidget::instance_ = NULL; +} \ No newline at end of file diff --git a/Swift/QtUI/QtAboutWidget.h b/Swift/QtUI/QtAboutWidget.h new file mode 100644 index 0000000..8e6f027 --- /dev/null +++ b/Swift/QtUI/QtAboutWidget.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace Swift { + class QtAboutWidget : public QWidget { + Q_OBJECT + public: + static QtAboutWidget* instance(); + + private: + QtAboutWidget(); + static QtAboutWidget* instance_; + }; +} \ No newline at end of file diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 210d927..2a25420 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -1,4 +1,6 @@ #include "QtLoginWindow.h" + +#include "QtAboutWidget.h" #include "QtSwiftUtil.h" #include "QtMainWindow.h" @@ -91,10 +93,17 @@ QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPass QApplication::setQuitOnLastWindowClosed(false); swiftMenu_ = new QMenu(tr("Swift"), this); + + QAction* aboutAction = new QAction("About Swift", this); + connect(aboutAction, SIGNAL(activated()), SLOT(handleAbout())); + swiftMenu_->addAction(aboutAction); + QAction* quitAction = new QAction("Quit", this); connect(quitAction, SIGNAL(activated()), SLOT(handleQuit())); swiftMenu_->addAction(quitAction); + + setInitialMenus(); this->show(); } @@ -126,6 +135,10 @@ void QtLoginWindow::handleCertficateChecked(bool checked) { } } +void QtLoginWindow::handleAbout() { + QtAboutWidget::instance()->show(); +} + void QtLoginWindow::handleQuit() { QApplication::quit(); } diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index e880ace..1c156db 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -28,6 +28,7 @@ namespace Swift { void loginClicked(); void handleCertficateChecked(bool); void handleQuit(); + void handleAbout(); private: void setInitialMenus(); diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 90742a5..a949b7d 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -17,6 +17,7 @@ #include "Swiften/Client/Client.h" #include "Swift/Controllers/ChatController.h" #include "Swift/Controllers/MainController.h" +#include "Swift/QtUI/BuildVersion.h" namespace Swift{ @@ -35,6 +36,7 @@ QtSwift::QtSwift(bool netbookMode) { QCoreApplication::setApplicationName("Swift"); QCoreApplication::setOrganizationName("Swift"); QCoreApplication::setOrganizationDomain("swift.im"); + QCoreApplication::setApplicationVersion(buildVersion); settings_ = new QtSettingsProvider(); application_ = new PlatformApplication("Swift"); if (splitter_) { diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 43211a9..679b3c0 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -47,6 +47,7 @@ myenv.Command("DefaultTheme.qrc", "../resources/themes/Default", Action(generate sources = [ "main.cpp", + "QtAboutWidget.cpp", "QtAddContactDialog.cpp", "QtChatWindow.cpp", "QtChatWindowFactory.cpp", -- cgit v0.10.2-6-g49f6