Commit 627500d9 authored by Edric Milaret's avatar Edric Milaret Committed by Guillaume Roguez

first Qt-based client version

Refs #68886

Change-Id: I69b44506dc52a18c47f102466472c68fbf08600b
parents
#-------------------------------------------------
#
# Project created by QtCreator 2015-03-23T14:30:35
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg
VERSION = 0.0.1
DEFINES += VERSION=\\\"$$VERSION\\\"
TARGET = RingClientWindows
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
CONFIG += console
SOURCES += main.cpp\
mainwindow.cpp \
callwidget.cpp \
configurationwidget.cpp \
navstack.cpp \
navbar.cpp \
mainbar.cpp \
navwidget.cpp \
accountdetails.cpp \
minimalhistorybackend.cpp \
aboutdialog.cpp \
pivotviewwidget.cpp \
pivotcontrol.cpp \
videowidget.cpp
HEADERS += mainwindow.h \
callwidget.h \
configurationwidget.h \
navstack.h \
navbar.h \
mainbar.h \
navwidget.h \
accountdetails.h \
minimalhistorybackend.h \
aboutdialog.h \
pivotviewwidget.h \
pivotcontrol.h \
videowidget.h
FORMS += mainwindow.ui \
callwidget.ui \
configurationwidget.ui \
navbar.ui \
mainbar.ui \
accountdetails.ui \
aboutdialog.ui \
pivotviewwidget.ui
INCLUDEPATH += /home/edric/Documents/CrossWorkspace/ring/binArch/include/libringclient
win32: LIBS += -L/home/edric/Documents/CrossWorkspace/ring/binArch/lib/ -lringclient
linux: LIBS += -L/usr/local/lib/ -lringclient
RESOURCES += \
ressources.qrc
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2011-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 "aboutdialog.h"
#include "ui_aboutdialog.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setFixedSize(this->width(),this->height());
ui->creditsWidget->hide();
ui->clientVersionLabel->setText(
QString("<html><head/><body><p><span style=\" font-weight:600;\">Windows Ring v")
+ VERSION
+ "</span></p></body></html>");
}
AboutDialog::~AboutDialog()
{
delete ui;
}
void
AboutDialog::on_aboutButton_toggled(bool checked)
{
ui->creditsButton->setChecked(!checked);
ui->aboutWidget->setVisible(checked);
ui->creditsWidget->setVisible(!checked);
}
void
AboutDialog::on_creditsButton_clicked(bool checked)
{
ui->aboutButton->setChecked(!checked);
ui->creditsWidget->setVisible(checked);
ui->aboutWidget->setVisible(!checked);
}
void
AboutDialog::on_toolButton_clicked()
{
this->close();
}
/***************************************************************************
* Copyright (C) 2011-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 ABOUTDIALOG_H
#define ABOUTDIALOG_H
#include <QDialog>
namespace Ui {
class AboutDialog;
}
class AboutDialog : public QDialog
{
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();
//UI SLOTS
private slots:
void on_aboutButton_toggled(bool checked);
void on_creditsButton_clicked(bool checked);
void on_toolButton_clicked();
private:
Ui::AboutDialog *ui;
};
#endif // ABOUTDIALOG_H
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2011-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 "accountdetails.h"
#include "ui_accountdetails.h"
#include <QSortFilterProxyModel>
#include "accountmodel.h"
#include "account.h"
#include "accountdetails.h"
#include "audio/codecmodel.h"
AccountDetails::AccountDetails(QWidget *parent) :
QWidget(parent),
ui(new Ui::AccountDetails),
codecModel_(nullptr),
codecModelModified(false)
{
ui->setupUi(this);
ui->audioCodecView->setColumnCount(4);
QStringList audioHeader {"Enabled", "Name", "Bitrate", "Samplerate"};
ui->audioCodecView->setHorizontalHeaderLabels(audioHeader);
ui->audioCodecView->verticalHeader()->hide();
ui->audioCodecView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->audioCodecView->setShowGrid(false);
ui->videoCodecView->setColumnCount(3);
QStringList videoHeader {"Enabled", "Name", "Bitrate"};
ui->videoCodecView->setHorizontalHeaderLabels(videoHeader);
ui->videoCodecView->verticalHeader()->hide();
ui->videoCodecView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->videoCodecView->setShowGrid(false);
ui->hashValue->setAlignment(Qt::AlignCenter);
connect(ui->audioCodecView, SIGNAL(cellChanged(int,int)),
this, SLOT(audio_codec_checked(int, int)));
connect(ui->videoCodecView, SIGNAL(cellChanged(int,int)),
this, SLOT(video_codec_checked(int,int)));
connect(ui->videoEnabledCheckBox, SIGNAL(toggled(bool)),
this, SLOT(setVideoEnabled(bool)));
connect(ui->autoAnswerCheckBox, SIGNAL(toggled(bool)),
this, SLOT(setAutoAnswer(bool)));
connect(ui->aliasValue, SIGNAL(editingFinished()),
this, SLOT(aliasChanged()));
connect(ui->bootstrapLineEdit, SIGNAL(editingFinished()),
this, SLOT(bootstrapChanged()));
}
AccountDetails::~AccountDetails()
{
delete ui;
}
void
AccountDetails::reloadCodec(CodecType type)
{
auto selectedIdx = codecModel_->selectionModel()->currentIndex();
if (type != CodecType::VIDEO) {
ui->audioCodecView->clearContents();
ui->audioCodecView->setRowCount(codecModel_->audioCodecs()->rowCount());
for (int i = 0; i < codecModel_->audioCodecs()->rowCount(); i++) {
auto idx = codecModel_->audioCodecs()->index(i, 0);
auto checkBoxItem = new QTableWidgetItem();
checkBoxItem->setCheckState(
codecModel_->audioCodecs()->data(idx ,
Qt::CheckStateRole).toBool()
? Qt::Checked : Qt::Unchecked);
ui->audioCodecView->setItem(i, 0, checkBoxItem);
auto item = new QTableWidgetItem(
codecModel_->audioCodecs()->data(idx).toString());
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->audioCodecView->setItem(i, 1, item);
item = new QTableWidgetItem(
codecModel_->audioCodecs()->
data(idx,CodecModel::Role::BITRATE).toString());
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->audioCodecView->setItem(i, 2, item);
item = new QTableWidgetItem(
codecModel_->audioCodecs()->
data(idx, CodecModel::Role::SAMPLERATE).toString());
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->audioCodecView->setItem(i, 3, item);
if (codecModel_->audioCodecs()->mapToSource(idx) == selectedIdx) {
ui->audioCodecView->setCurrentCell(i, 0);
}
}
}
if (type != CodecType::AUDIO) {
ui->videoCodecView->clearContents();
ui->videoCodecView->setRowCount(codecModel_->videoCodecs()->rowCount());
for (int i = 0; i < codecModel_->videoCodecs()->rowCount(); i++) {
auto idx = codecModel_->videoCodecs()->index(i, 0);
auto checkBoxItem = new QTableWidgetItem();
checkBoxItem->setCheckState(codecModel_->videoCodecs()->
data(idx , Qt::CheckStateRole).toBool()
? Qt::Checked : Qt::Unchecked);
ui->videoCodecView->setItem(i, 0, checkBoxItem);
auto item = new QTableWidgetItem(
codecModel_->videoCodecs()->data(idx).toString());
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->videoCodecView->setItem(i, 1, item);
item = new QTableWidgetItem(codecModel_->videoCodecs()->
data(idx,CodecModel::Role::BITRATE).toString());
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->videoCodecView->setItem(i, 2, item);
if (codecModel_->videoCodecs()->mapToSource(idx) == selectedIdx) {
ui->videoCodecView->setCurrentCell(i, 0);
}
}
}
}
void
AccountDetails::setAccount(Account* currentAccount) {
currentAccount_ = currentAccount;
if (codecModel_ && codecModelModified)
codecModel_->save();
codecModel_ = currentAccount->codecModel();
//FIX ME : Reorganize this in group
ui->hashValue->hide();
ui->hashLabel->hide();
ui->aliasValue->hide();
ui->aliasLabel->hide();
ui->bootstrapLabel->hide();
ui->bootstrapLineEdit->hide();
ui->hostnameLabel->hide();
ui->hostnameEdit->hide();
ui->usernameEdit->hide();
ui->usernameLabel->hide();
ui->passwordEdit->hide();
ui->passwordLabel->hide();
ui->proxyEdit->hide();
ui->proxyLabel->hide();
ui->voicemailLabel->hide();
ui->voicemailEdit->hide();
switch (currentAccount_->protocol()) {
case Account::Protocol::SIP:
if (currentAccount_ != AccountModel::instance()->ip2ip()) {
ui->typeValueLabel->setText("SIP");
ui->aliasValue->setText(currentAccount_->alias());
ui->hostnameEdit->setText(currentAccount_->hostname());
ui->usernameEdit->setText(currentAccount_->username());
ui->passwordEdit->setText(currentAccount_->password());
ui->proxyEdit->setText(currentAccount_->proxy());
ui->voicemailEdit->setText(currentAccount_->mailbox());
ui->aliasLabel->show();
ui->aliasValue->show();
ui->hostnameLabel->show();
ui->hostnameEdit->show();
ui->usernameEdit->show();
ui->usernameLabel->show();
ui->passwordEdit->show();
ui->passwordLabel->show();
ui->proxyEdit->show();
ui->proxyLabel->show();
ui->voicemailLabel->show();
ui->voicemailEdit->show();
} else {
ui->typeValueLabel->setText("IP2IP");
}
break;
case Account::Protocol::IAX:
ui->typeValueLabel->setText("IAX");
break;
case Account::Protocol::RING:
ui->typeValueLabel->setText("RING");
ui->aliasValue->setText(currentAccount_->alias());
ui->hashValue->setText(currentAccount_->username());
ui->bootstrapLineEdit->setText(currentAccount_->hostname());
ui->hashValue->show();
ui->hashLabel->show();
ui->aliasLabel->show();
ui->aliasValue->show();
ui->bootstrapLabel->show();
ui->bootstrapLineEdit->show();
break;
default:
break;
}
reloadCodec();
ui->videoEnabledCheckBox->setChecked(currentAccount_->isVideoEnabled());
ui->autoAnswerCheckBox->setChecked(currentAccount_->isAutoAnswer());
}
void
AccountDetails::audio_codec_checked(int row, int column) {
if (column != 0)
return;
auto item = ui->audioCodecView->item(row, 0);
auto idx = codecModel_->audioCodecs()->index(row, 0);
codecModel_->audioCodecs()->setData(idx, item->checkState(),
Qt::CheckStateRole);
codecModelModified = true;
}
void
AccountDetails::video_codec_checked(int row, int column) {
if (column != 0)
return;
auto item = ui->videoCodecView->item(row, 0);
auto idx = codecModel_->videoCodecs()->index(row, 0);
codecModel_->videoCodecs()->setData(idx, item->checkState(),
Qt::CheckStateRole);
codecModelModified = true;
}
void
AccountDetails::setVideoEnabled(bool enabled) {
currentAccount_->setVideoEnabled(enabled);
}
void
AccountDetails::setAutoAnswer(bool enabled) {
currentAccount_->setAutoAnswer(enabled);
}
void
AccountDetails::aliasChanged() {
currentAccount_->setAlias(ui->aliasValue->text());
}
void
AccountDetails::bootstrapChanged() {
currentAccount_->setHostname(ui->bootstrapLineEdit->text());
}
void
AccountDetails::on_upAudioButton_clicked()
{
codecModel_->moveUp();
reloadCodec(CodecType::AUDIO);
codecModelModified = true;
}
void
AccountDetails::on_downAudioButton_clicked()
{
codecModel_->moveDown();
reloadCodec(CodecType::AUDIO);
codecModelModified = true;
}
void
AccountDetails::on_upVideoButton_clicked()
{
codecModel_->moveUp();
reloadCodec(CodecType::VIDEO);
codecModelModified = true;
}
void
AccountDetails::on_downVideoButton_clicked()
{
codecModel_->moveDown();
reloadCodec(CodecType::VIDEO);
codecModelModified = true;
}
void
AccountDetails::on_audioCodecView_itemSelectionChanged()
{
int row = ui->audioCodecView->currentRow();
auto idx = codecModel_->audioCodecs()->index(row, 0);
auto srcIdx = codecModel_->audioCodecs()->mapToSource(idx);
codecModel_->selectionModel()->setCurrentIndex(srcIdx,
QItemSelectionModel::Select);
}
void
AccountDetails::on_videoCodecView_itemSelectionChanged()
{
int row = ui->videoCodecView->currentRow();
auto idx = codecModel_->videoCodecs()->index(row, 0);
auto srcIdx = codecModel_->videoCodecs()->mapToSource(idx);
codecModel_->selectionModel()->setCurrentIndex(srcIdx,
QItemSelectionModel::Select);
}
void
AccountDetails::save() {
if (codecModelModified)
codecModel_->save();
}
void
AccountDetails::on_hostnameEdit_editingFinished()
{
currentAccount_->setHostname(ui->hostnameEdit->text());
}
void
AccountDetails::on_usernameEdit_editingFinished()
{
currentAccount_->setUsername(ui->usernameEdit->text());
}
void
AccountDetails::on_passwordEdit_editingFinished()
{
currentAccount_->setPassword(ui->passwordEdit->text());
}
void
AccountDetails::on_proxyEdit_editingFinished()
{
currentAccount_->setProxy(ui->proxyEdit->text());
}
void
AccountDetails::on_voicemailEdit_editingFinished()
{
currentAccount_->setMailbox(ui->voicemailEdit->text());
}
void
AccountDetails::on_tabWidget_currentChanged(int index)
{
if (index == 1) {
ui->audioCodecView->setCurrentItem(ui->audioCodecView->item(0, 0));
} else if (index == 2) {
ui->videoCodecView->setCurrentItem(ui->videoCodecView->item(0, 0));
}
}
/***************************************************************************
* Copyright (C) 2011-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 ACCOUNTDETAILS_H
#define ACCOUNTDETAILS_H
#include <QWidget>
#include <QTableWidgetItem>
#include "accountmodel.h"
#include "audio/codecmodel.h"
namespace Ui {
class AccountDetails;
}
class AccountDetails : public QWidget
{
Q_OBJECT
private:
enum CodecType { AUDIO, VIDEO, ALL };
public:
explicit AccountDetails(QWidget *parent = 0);
~AccountDetails();
void setAccount(Account *currentAccount);
void reloadCodec(CodecType type = CodecType::ALL);
void save();
//UI SLOTS
private slots:
void on_upAudioButton_clicked();
void on_downAudioButton_clicked();
void on_upVideoButton_clicked();
void on_downVideoButton_clicked();
void on_audioCodecView_itemSelectionChanged();
void on_videoCodecView_itemSelectionChanged();
void on_hostnameEdit_editingFinished();
void on_usernameEdit_editingFinished();
void on_passwordEdit_editingFinished();
void on_proxyEdit_editingFinished();
void on_voicemailEdit_editingFinished();
void on_tabWidget_currentChanged(int index);
private slots:
void audio_codec_checked(int row, int column);
void setVideoEnabled(bool enabled);
void video_codec_checked(int row, int column);
void setAutoAnswer(bool enabled);
void aliasChanged();
void bootstrapChanged();
private:
Ui::AccountDetails *ui;
CodecModel* codecModel_;
Account* currentAccount_;
bool codecModelModified;
};
#endif // ACCOUNTDETAILS_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AccountDetails</class>
<widget class="QWidget" name="AccountDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>