diff --git a/RingWinClient.pro b/RingWinClient.pro index 8b71c575b0e6f4adc72ac2e2780488810b4b65bb..bfe17b848a52679ec3666e2d6ef378e462330fbe 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -6,7 +6,7 @@ QT += core gui -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg xml +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg winextras xml VERSION = 0.3.0 GIT_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags) @@ -53,7 +53,8 @@ SOURCES += main.cpp\ videooverlay.cpp \ imdelegate.cpp \ contactpicker.cpp \ - contactmethodpicker.cpp + contactmethodpicker.cpp \ + globalsystemtray.cpp HEADERS += mainwindow.h \ callwidget.h \ @@ -79,7 +80,8 @@ HEADERS += mainwindow.h \ imdelegate.h \ contactpicker.h \ contactmethodpicker.h \ - settingskey.h + settingskey.h \ + globalsystemtray.h FORMS += mainwindow.ui \ callwidget.ui \ @@ -153,7 +155,7 @@ win32 { QTRUNTIME.files = $$RUNTIMEDIR/Qt5Core.dll $$RUNTIMEDIR/Qt5Widgets.dll \ $$RUNTIMEDIR/Qt5Gui.dll $$RUNTIMEDIR/Qt5Svg.dll \ - $$RUNTIMEDIR/Qt5Xml.dll + $$RUNTIMEDIR/Qt5Xml.dll $$RUNTIMEDIR/Qt5WinExtras.dll QTRUNTIME.path = $$OUT_PWD/release QTDEPSRUNTIME.files = $$RUNTIMEDIR/zlib1.dll $$RUNTIMEDIR/iconv.dll \ diff --git a/callwidget.cpp b/callwidget.cpp index 6afd76dd8e766c4682d8699f9a8324d62f72c47c..2310c7adad07d71c1f9d8c99f0fbef10847558dd 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -41,6 +41,7 @@ #include "windowscontactbackend.h" #include "contactpicker.h" #include "contactmethodpicker.h" +#include "globalsystemtray.h" CallWidget::CallWidget(QWidget *parent) : NavWidget(Main ,parent), @@ -256,6 +257,11 @@ CallWidget::findRingAccount() void CallWidget::callIncoming(Call *call) { + if (!QApplication::activeWindow()) { + GlobalSystemTray::instance().showMessage("Ring", "Call incoming from " + call->formattedName()); + QApplication::alert(this, 5000); + } + if (!call->account()->isAutoAnswer()) { ui->callLabel->setText(QString(tr("Call from %1", "%1 is the name of the caller")) .arg(call->formattedName())); diff --git a/globalsystemtray.cpp b/globalsystemtray.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8cf6992988789ad21e78580774fe82bc80bb4848 --- /dev/null +++ b/globalsystemtray.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * Copyright (C) 2015 by Savoir-faire Linux * + * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#include "globalsystemtray.h" + +GlobalSystemTray::GlobalSystemTray() +{ +} + diff --git a/globalsystemtray.h b/globalsystemtray.h new file mode 100644 index 0000000000000000000000000000000000000000..855414a1cfb76a76af3bfbc4963c264a17bdeba3 --- /dev/null +++ b/globalsystemtray.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2015 by Savoir-faire Linux * + * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#ifndef GLOBALSYSTEMTRAY_H +#define GLOBALSYSTEMTRAY_H + +#include <QSystemTrayIcon> + +class GlobalSystemTray : public QSystemTrayIcon +{ + Q_OBJECT + +public: + static GlobalSystemTray& instance() + { + static GlobalSystemTray instance_; + + return instance_; + } + +private: + GlobalSystemTray(); +}; + +#endif // GLOBALSYSTEMTRAY_H diff --git a/instantmessagingwidget.cpp b/instantmessagingwidget.cpp index f64c6623f05090c1245d1aaf12a3046db80b55ed..d186a108babe7a2d0c3f1fc63a3316610cec4ea1 100644 --- a/instantmessagingwidget.cpp +++ b/instantmessagingwidget.cpp @@ -23,10 +23,13 @@ #include <QClipboard> #include <QMenu> +#include "navstack.h" + #include "media/text.h" #include "media/textrecording.h" #include "imdelegate.h" +#include "globalsystemtray.h" InstantMessagingWidget::InstantMessagingWidget(QWidget *parent) : QWidget(parent), @@ -102,6 +105,10 @@ InstantMessagingWidget::mediaAdd(Media::Media *media) connect(ui->messageOutput->model(), SIGNAL(rowsInserted(const QModelIndex&, int, int)), ui->messageOutput, SLOT(scrollToBottom())); + connect(static_cast<Media::Text*>(media), + SIGNAL(messageReceived(QMap<QString,QString>)), + this, + SLOT(onMsgReceived(QMap<QString,QString>))); this->show(); } break; @@ -143,3 +150,12 @@ InstantMessagingWidget::on_sendButton_clicked() { emit ui->messageInput->returnPressed(); } + +void +InstantMessagingWidget::onMsgReceived(const QMap<QString,QString>& message) +{ + if (!QApplication::activeWindow()) { + GlobalSystemTray::instance().showMessage("Ring: Message Received", message["text/plain"]); + QApplication::alert(this, 5000); + } +} diff --git a/instantmessagingwidget.h b/instantmessagingwidget.h index 3aaf04ab89dfc6a771e64c775b37bb107ed2ee99..8220b1c55c2a70eea377e5bf6e4da6029dbe93ce 100644 --- a/instantmessagingwidget.h +++ b/instantmessagingwidget.h @@ -51,6 +51,7 @@ private slots: private slots: void mediaAdd(Media::Media *media); + void onMsgReceived(const QMap<QString, QString>& message); private: Ui::InstantMessagingWidget *ui; diff --git a/main.cpp b/main.cpp index fdf97b3f4de6203eb038a3a3485249ba7fe873fb..ff1360ecffb838bea6b8862b0fce318842f3ef7d 100644 --- a/main.cpp +++ b/main.cpp @@ -103,6 +103,8 @@ main(int argc, char *argv[]) else w.showMinimized(); + w.createThumbBar(); + QObject::connect(&a, &QApplication::aboutToQuit, [&a]() { delete CallModel::instance(); }); diff --git a/mainwindow.cpp b/mainwindow.cpp index 0cd33f09b9f99d8690d13a1551805cf4625df6e0..9cd507c70c2990bc11ae330a51e39d167eff44ae 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -20,6 +20,11 @@ #include "ui_mainwindow.h" #include <QSizeGrip> +#include <QWinThumbnailToolBar> +#include <QWinThumbnailToolButton> + +#include "media/text.h" +#include "media/textrecording.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -34,10 +39,25 @@ MainWindow::MainWindow(QWidget *parent) : this->setWindowIcon(icon); - sysIcon_.setIcon(icon); - sysIcon_.show(); + GlobalSystemTray& sysIcon = GlobalSystemTray::instance(); + sysIcon.setIcon(icon); + + QMenu *menu = new QMenu(); + + auto configAction = new QAction("Configuration", this); + menu->addAction(configAction); + + auto exitAction = new QAction("Exit", this); + connect(exitAction, &QAction::triggered, []() { + QCoreApplication::exit(); + }); - connect(&sysIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), + menu->addAction(exitAction); + + sysIcon.setContextMenu(menu); + sysIcon.show(); + + connect(&sysIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); connect(CallModel::instance(), SIGNAL(incomingCall(Call*)), @@ -46,6 +66,9 @@ MainWindow::MainWindow(QWidget *parent) : navStack_ = new NavStack(ui->bar, ui->stackedWidgetView, this); ui->verticalLayout_2->addWidget( new QSizeGrip(this), 0, Qt::AlignBottom | Qt::AlignRight); + connect(configAction, &QAction::triggered, [this]() { + navStack_->onNavigationRequested(ScreenEnum::ConfScreen); + }); } MainWindow::~MainWindow() @@ -71,13 +94,32 @@ MainWindow::mouseMoveEvent(QMouseEvent *evt) } void -MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) { +MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) +{ if (reason != QSystemTrayIcon::ActivationReason::Context) this->show(); } void -MainWindow::onIncomingCall(Call *call) { +MainWindow::onIncomingCall(Call *call) +{ Q_UNUSED(call); QWidget::showNormal(); } + +void +MainWindow::createThumbBar() +{ + QWinThumbnailToolBar *thumbbar = new QWinThumbnailToolBar(this); + thumbbar->setWindow(this->windowHandle()); + QWinThumbnailToolButton *settings = new QWinThumbnailToolButton(thumbbar); + settings->setToolTip("Settings"); + QIcon icon(":/images/settings.png"); + settings->setIcon(icon); + settings->setDismissOnClick(true); + connect(settings, &QWinThumbnailToolButton::clicked, [this]() { + navStack_->onNavigationRequested(ScreenEnum::ConfScreen); + }); + + thumbbar->addButton(settings); +} diff --git a/mainwindow.h b/mainwindow.h index 6f46d97c70a0406985fd4cb2738e3878f72d902d..50b05d3105947200f87f153b9241b50503affc7e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -19,13 +19,13 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "globalsystemtray.h" + #include <QMainWindow> #include <QMouseEvent> -#include <QSystemTrayIcon> #include "navstack.h" - namespace Ui { class MainWindow; } @@ -37,6 +37,7 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + void createThumbBar(); private slots: void trayActivated(QSystemTrayIcon::ActivationReason reason); @@ -46,8 +47,6 @@ private: Ui::MainWindow *ui; NavStack* navStack_; QPoint oldPos_; - QSystemTrayIcon sysIcon_; - protected: void mousePressEvent(QMouseEvent *evt); void mouseMoveEvent(QMouseEvent *evt); diff --git a/navstack.cpp b/navstack.cpp index f058b4bc953c3e097257ed9207225be02d3718d6..c1c6ddabb49cb7bfc30c108117dfaa19b9f3f2c7 100644 --- a/navstack.cpp +++ b/navstack.cpp @@ -50,6 +50,8 @@ NavStack::~NavStack() void NavStack::onNavigationRequested(ScreenEnum screen) { + if (navList_[screen] == stack_->currentWidget()) + return; if (screen < CallScreen) { bar_->setCurrentWidget(navList_[screen]); } else {