From 79d610f3c038acb65dfb2f5ccf59cd0b3ffeacf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Thu, 15 Apr 2010 20:53:13 +0200 Subject: Set a special X11 window resource name on the main dialog. This allows users to tweak windowmanagers like FVWM based on the type of dialog of Swift. diff --git a/Swift/Controllers/ApplicationInfo.h b/Swift/Controllers/ApplicationInfo.h new file mode 100644 index 0000000..8e6db31 --- /dev/null +++ b/Swift/Controllers/ApplicationInfo.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#define SWIFT_APPLICATION_NAME "Swift" + +#define SWIFT_ORGANIZATION_NAME "Swift" +#define SWIFT_ORGANIZATION_DOMAIN "swift.im" diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 4637322..794f993 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -7,17 +7,8 @@ #include "QtLoginWindow.h" #include - -#include "Swift/Controllers/UIEvents/UIEventStream.h" -#include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h" -#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" -#include "Swiften/Base/Platform.h" - -#include "QtAboutWidget.h" -#include "QtSwiftUtil.h" -#include "QtMainWindow.h" - #include +#include #include #include @@ -29,13 +20,24 @@ #include #include -#include +#include "Swift/Controllers/UIEvents/UIEventStream.h" +#include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h" +#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" +#include "Swiften/Base/Platform.h" + +#include "QtAboutWidget.h" +#include "QtSwiftUtil.h" +#include "QtMainWindow.h" +#include "QtUtilities.h" namespace Swift{ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { uiEventStream_ = uiEventStream; + setWindowTitle("Swift"); + QtUtilities::setX11Resource(this, "Main"); + resize(200, 500); setContentsMargins(0,0,0,0); QWidget *centralWidget = new QWidget(this); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index f8c9673..116f52e 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -6,15 +6,6 @@ #include "QtMainWindow.h" -#include "QtAddContactDialog.h" -#include "QtJoinMUCDialog.h" -#include "QtSwiftUtil.h" -#include "QtTabWidget.h" -#include "Roster/QtTreeWidgetFactory.h" -#include "Roster/QtTreeWidget.h" -#include "Swift/Controllers/UIEvents/AddContactUIEvent.h" - - #include #include #include @@ -26,6 +17,14 @@ #include #include +#include "QtAddContactDialog.h" +#include "QtJoinMUCDialog.h" +#include "QtSwiftUtil.h" +#include "QtTabWidget.h" +#include "Roster/QtTreeWidgetFactory.h" +#include "Roster/QtTreeWidget.h" +#include "Swift/Controllers/UIEvents/AddContactUIEvent.h" + namespace Swift { QtMainWindow::QtMainWindow(UIEventStream* uiEventStream, QtTreeWidgetFactory *treeWidgetFactory) : QWidget() { diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index efe872f..258a7b6 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -27,6 +27,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/Client/Client.h" #include "Swift/Controllers/MainController.h" +#include "Swift/Controllers/ApplicationInfo.h" #include "Swift/QtUI/BuildVersion.h" #include "SwifTools/AutoUpdater/AutoUpdater.h" #include "SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h" @@ -46,14 +47,14 @@ QtSwift::QtSwift(bool netbookMode) : autoUpdater_(NULL) { } else { splitter_ = NULL; } - QCoreApplication::setApplicationName("Swift"); - QCoreApplication::setOrganizationName("Swift"); - QCoreApplication::setOrganizationDomain("swift.im"); + QCoreApplication::setApplicationName(SWIFT_APPLICATION_NAME); + QCoreApplication::setOrganizationName(SWIFT_ORGANIZATION_NAME); + QCoreApplication::setOrganizationDomain(SWIFT_ORGANIZATION_DOMAIN); QCoreApplication::setApplicationVersion(buildVersion); tabs_ = new QtChatTabs(); settings_ = new QtSettingsProvider(); - application_ = new PlatformApplication("Swift"); + application_ = new PlatformApplication(SWIFT_APPLICATION_NAME); treeWidgetFactory_ = new QtTreeWidgetFactory(); systemTray_ = new QtSystemTray(); loginWindowFactory_ = new QtLoginWindowFactory(splitter_, systemTray_, settings_); diff --git a/Swift/QtUI/QtUtilities.cpp b/Swift/QtUI/QtUtilities.cpp new file mode 100644 index 0000000..11a3768 --- /dev/null +++ b/Swift/QtUI/QtUtilities.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include "QtUtilities.h" + +#include +#ifdef Q_WS_X11 +#include +#include +#include +#endif + +#include "Swift/Controllers/ApplicationInfo.h" + +namespace QtUtilities { + +void setX11Resource(QWidget* widget, const QString& c) { +#ifdef Q_WS_X11 + char res_class[] = SWIFT_APPLICATION_NAME; + XClassHint hint; + hint.res_name = (QString(SWIFT_APPLICATION_NAME) + "-" + c).toUtf8().data(); + hint.res_class = res_class; + XSetClassHint(widget->x11Info().display(), widget->winId(), &hint); +#endif +} + +} diff --git a/Swift/QtUI/QtUtilities.h b/Swift/QtUI/QtUtilities.h new file mode 100644 index 0000000..6e64d6e --- /dev/null +++ b/Swift/QtUI/QtUtilities.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +class QWidget; +class QString; + +namespace QtUtilities { + void setX11Resource(QWidget* widget, const QString& c); +}; diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index b82cb7b..345e7c3 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -72,6 +72,7 @@ sources = [ "QtTextEdit.cpp", "QtXMLConsoleWidgetFactory.cpp", "QtXMLConsoleWidget.cpp", + "QtUtilities.cpp", "ChatSnippet.cpp", "MessageSnippet.cpp", "SystemMessageSnippet.cpp", -- cgit v0.10.2-6-g49f6