On some platforms (such as N900), Qt doesn't support a tray icon.
This adds tons of #defines to allow compilation in that case.
#ifndef HAVE_KDE
QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
+# ifndef QT_NO_SYSTEMTRAYICON
QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
+# endif
# ifdef HAVE_PHONON
QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
# endif
move(_normalPos);
#endif
- if(s.value("MainWinHidden").toBool())
+#ifndef QT_NO_SYSTEMTRAYICON
+ if(s.value("MainWinHidden").toBool()) {
hideToTray();
- else if(s.value("MainWinMinimized").toBool())
+ return;
+ }
+#endif
+ if(s.value("MainWinMinimized").toBool())
showMinimized();
else if(maximized)
showMaximized();
}
void MainWin::setupSystray() {
+#ifndef QT_NO_SYSTEMTRAYICON
_systemTray = new SystemTray(this);
+#endif
}
void MainWin::setupToolBars() {
_coreConnectionStatusWidget->setVisible(!Client::internalCore());
updateIcon();
+#ifndef QT_NO_SYSTEMTRAYICON
systemTray()->setState(SystemTray::Active);
+#endif
if(Client::networkIds().isEmpty()) {
IrcConnectionWizard *wizard = new IrcConnectionWizard(this, Qt::Sheet);
if(_msgProcessorStatusWidget)
_msgProcessorStatusWidget->setProgress(0, 0);
updateIcon();
+#ifndef QT_NO_SYSTEMTRAYICON
systemTray()->setState(SystemTray::Inactive);
+#endif
}
void MainWin::userAuthenticationRequired(CoreAccount *account, bool *valid, const QString &errorMessage) {
}
void MainWin::closeEvent(QCloseEvent *event) {
+#ifndef QT_NO_SYSTEMTRAYICON
QtUiSettings s;
QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
Q_ASSERT(app);
event->accept();
quit();
}
+#else
+ event->accept();
+ quit();
+#endif
}
void MainWin::changeEvent(QEvent *event) {
QMainWindow::changeEvent(event);
}
+#ifndef QT_NO_SYSTEMTRAYICON
+
void MainWin::hideToTray() {
if(!systemTray()->isSystemTrayAvailable()) {
qWarning() << Q_FUNC_INFO << "was called with no SystemTray available!";
#endif
}
+#endif /* QT_NO_SYSTEMTRAYICON */
+
void MainWin::forceActivated() {
#ifdef HAVE_KDE
show();
# include <windows.h>
#endif
-#include <QSystemTrayIcon>
-
#include "qtui.h"
#include "titlesetter.h"
#include "uisettings.h"
void addBufferView(ClientBufferViewConfig *config);
BufferView *allBuffersView() const;
- BufferWidget *bufferWidget() const { return _bufferWidget; }
+ inline BufferWidget *bufferWidget() const { return _bufferWidget; }
- inline SystemTray *systemTray() const;
+#ifndef QT_NO_SYSTEMTRAYICON
+ inline SystemTray *systemTray() const { return _systemTray; }
+#endif
bool event(QEvent *event);
public slots:
void showStatusBarMessage(const QString &message);
+#ifndef QT_NO_SYSTEMTRAYICON
void toggleMinimizedToTray();
+#endif
//! Bring window to front and focus it
void forceActivated();
void updateIcon();
void enableMenus();
+#ifndef QT_NO_SYSTEMTRAYICON
void hideToTray();
-
SystemTray *_systemTray;
+#endif
QList<BufferViewDock *> _bufferViews;
BufferWidget *_bufferWidget;
friend class QtUi;
};
-SystemTray *MainWin::systemTray() const {
- return _systemTray;
-}
-
#endif
#include "qtuimessageprocessor.h"
#include "qtuisettings.h"
#include "qtuistyle.h"
+#include "systemtray.h"
#include "toolbaractionprovider.h"
#include "types.h"
#include "util.h"
_mainWin->disconnectedFromCore();
}
+bool QtUi::haveSystemTray() {
+#ifdef QT_NO_SYSTEMTRAYICON
+ return false;
+#else
+ return mainWindow()->systemTray()->isSystemTrayAvailable();
+#endif
+}
+
void QtUi::registerNotificationBackend(AbstractNotificationBackend *backend) {
if(!_notificationBackends.contains(backend)) {
_notificationBackends.append(backend);
inline static QtUiStyle *style();
inline static MainWin *mainWindow();
+ static bool haveSystemTray();
+
/* Notifications */
static void registerNotificationBackend(AbstractNotificationBackend *);
#ifdef Q_WS_MAC
ui.minimizeOnClose->hide();
#endif
+#ifdef QT_NO_SYSTEMTRAYICON
+ ui.useSystemTrayIcon->hide();
+#endif
initAutoWidgets();
initStyleComboBox();
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#ifndef QT_NO_SYSTEMTRAYICON
+
#include <QMenu>
#include "systemtray.h"
}
}
+
+#endif /* QT_NO_SYSTEMTRAYICON */
#ifndef SYSTEMTRAY_H_
#define SYSTEMTRAY_H_
+#ifndef QT_NO_SYSTEMTRAYICON
+
#ifdef HAVE_KDE
# include <KSystemTrayIcon>
#else
bool SystemTray::isAlerted() const { return _alert; }
void SystemTray::setInhibitActivation() { _inhibitActivation = true; }
+#endif /* QT_NO_SYSTEMTRAYICON */
+
#endif
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#ifndef QT_NO_SYSTEMTRAYICON
+
#include "systraynotificationbackend.h"
#include <QtGui>
s.setValue("Systray/ShowBubble", _showBubbleBox->isChecked());
load();
}
+
+#endif /* QT_NO_SYSTEMTRAYICON */
#ifndef SYSTRAYNOTIFICATIONBACKEND_H_
#define SYSTRAYNOTIFICATIONBACKEND_H_
+#ifndef QT_NO_SYSTEMTRAYICON
+
#include <QSystemTrayIcon>
#include "abstractnotificationbackend.h"
bool _showBubble, _animate;
};
+#endif /* QT_NO_SYSTEMTRAYICON */
+
#endif