Commit 2cf34296 authored by Edric Milaret's avatar Edric Milaret Committed by gerrit2

UI: add notification and settings buttons

- Settings on tray and taskbar icon

This patch has repercussions on build system as
it relies on a new dependency win-extras

This patch also breaks the possibility to compile on Linux
as win-extras doesn't exists on other systems;

Issue: #76151
Issue: #76152
Change-Id: Iadc5eb0949b1f66cf8de297b81a3ea286d77aca4
parent b6efc9c1
......@@ -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 \
......
......@@ -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()));
......
/***************************************************************************
* 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()
{
}
/***************************************************************************
* 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
......@@ -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);
}
}
......@@ -51,6 +51,7 @@ private slots:
private slots:
void mediaAdd(Media::Media *media);
void onMsgReceived(const QMap<QString, QString>& message);
private:
Ui::InstantMessagingWidget *ui;
......
......@@ -103,6 +103,8 @@ main(int argc, char *argv[])
else
w.showMinimized();
w.createThumbBar();
QObject::connect(&a, &QApplication::aboutToQuit, [&a]() {
delete CallModel::instance();
});
......
......@@ -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);
}
......@@ -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);
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment