Commit ed0b2805 authored by Edric Milaret's avatar Edric Milaret

smartlist: implement smart list view

- remove mainbar
- reconnect search/call bar
- add welcome screen
- add smartlist delegate
- use PeopleProxy
- clean and guard (WIN32) code
- remove state label

Issue: #81177
Change-Id: I0cbeb1bf754124ca6bb83acab50f1e7fd0f19e0a
parent 24c15d76
......@@ -6,7 +6,9 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg winextras xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg xml
win32: QT += winextras
VERSION = 0.3.0
GIT_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
......@@ -35,7 +37,6 @@ SOURCES += main.cpp\
configurationwidget.cpp \
navstack.cpp \
navbar.cpp \
mainbar.cpp \
navwidget.cpp \
accountdetails.cpp \
aboutdialog.cpp \
......@@ -55,14 +56,14 @@ SOURCES += main.cpp\
contactpicker.cpp \
contactmethodpicker.cpp \
globalsystemtray.cpp \
transferdialog.cpp
transferdialog.cpp \
smartlistdelegate.cpp
HEADERS += mainwindow.h \
callwidget.h \
configurationwidget.h \
navstack.h \
navbar.h \
mainbar.h \
navwidget.h \
accountdetails.h \
aboutdialog.h \
......@@ -83,13 +84,13 @@ HEADERS += mainwindow.h \
contactmethodpicker.h \
settingskey.h \
globalsystemtray.h \
transferdialog.h
transferdialog.h \
smartlistdelegate.h
FORMS += mainwindow.ui \
callwidget.ui \
configurationwidget.ui \
navbar.ui \
mainbar.ui \
accountdetails.ui \
aboutdialog.ui \
wizarddialog.ui \
......
......@@ -25,9 +25,6 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setFixedSize(this->width(),this->height());
ui->creditsWidget->hide();
ui->clientVersionLabel->setText(
......@@ -77,9 +74,3 @@ AboutDialog::on_creditsButton_clicked(bool checked)
ui->creditsWidget->setVisible(checked);
ui->aboutWidget->setVisible(!checked);
}
void
AboutDialog::on_toolButton_clicked()
{
this->close();
}
......@@ -36,7 +36,6 @@ public:
private slots:
void on_aboutButton_toggled(bool checked);
void on_creditsButton_clicked(bool checked);
void on_toolButton_clicked();
private:
Ui::AboutDialog *ui;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>674</width>
<height>565</height>
<height>555</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -439,7 +439,7 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0">
<property name="topMargin">
<number>0</number>
</property>
......@@ -492,23 +492,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>X</string>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/close.png</normaloff>:/images/close.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter">
......@@ -537,7 +520,10 @@
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="clientVersionLabel">
......@@ -684,7 +670,10 @@ Ring is a secured and distributed communication software.</string>
<widget class="QWidget" name="creditsWidget" native="true">
<layout class="QVBoxLayout" name="creditsLayout">
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="creditsBrowser">
......
......@@ -157,6 +157,8 @@ AccountDetails::setAccount(Account* currentAccount) {
currentAccount_ = currentAccount;
ui->lrcfg_username->setReadOnly(currentAccount_->protocol() == Account::Protocol::RING);
codecModel_ = currentAccount->codecModel();
ui->typeValueLabel->setText(currentAccount_->protocolModel()->
......
......@@ -56,7 +56,7 @@
<x>0</x>
<y>0</y>
<width>746</width>
<height>645</height>
<height>646</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
......@@ -360,12 +360,18 @@
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lrcfg_username">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
......@@ -626,7 +632,7 @@
<x>0</x>
<y>0</y>
<width>733</width>
<height>685</height>
<height>665</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
......@@ -1192,7 +1198,7 @@
<x>0</x>
<y>0</y>
<width>746</width>
<height>645</height>
<height>646</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
......
......@@ -32,7 +32,7 @@ AccountStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
initStyleOption(&opt, index);
if (index.column() == 0) {
auto name = index.model()->data(index, Qt::DisplayRole).toString();
opt.text = "";
opt.text = QString();
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
auto rect = opt.rect;
......
This diff is collapsed.
......@@ -27,8 +27,6 @@
#include "navwidget.h"
#include "instantmessagingwidget.h"
#include "historydelegate.h"
#include "contactdelegate.h"
#include "callmodel.h"
#include "video/renderer.h"
......@@ -36,6 +34,10 @@
#include "accountmodel.h"
#include "categorizedhistorymodel.h"
class ContactDelegate;
class HistoryDelegate;
class SmartListDelegate;
namespace Ui {
class CallWidget;
}
......@@ -54,18 +56,20 @@ private slots:
void on_acceptButton_clicked();
void on_refuseButton_clicked();
void on_contactView_doubleClicked(const QModelIndex &index);
void on_cancelButton_clicked();
void on_smartList_doubleClicked(const QModelIndex &index);
void on_searchEdit_returnPressed();
void on_settingsButton_clicked();
void on_historyList_doubleClicked(const QModelIndex &index);
void on_sortComboBox_currentIndexChanged(int index);
void on_callList_activated(const QModelIndex &index);
void on_contactButton_clicked(bool checked);
void on_historicButton_clicked(bool checked);
private slots:
void callIncoming(Call *call);
void addedCall(Call *call, Call *parent);
void callStateChanged(Call *call, Call::State previousState);
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void checkRegistrationState(Account* account,Account::RegistrationState state);
void on_cancelButton_clicked();
void smartListSelectionChanged(const QItemSelection &newSel, const QItemSelection &oldSel);
private:
Ui::CallWidget *ui;
......@@ -76,12 +80,14 @@ private:
int inputVolume_;
QMenu *menu_;
QMovie *spinner_;
HistoryDelegate *historyDelegate_;
ContactDelegate *contactDelegate_;
HistoryDelegate *historyDelegate_;
SmartListDelegate* smartListDelegate_;
private:
void findRingAccount();
void setActualCall(Call *value);
void displaySpinner(bool display);
void placeCall();
};
This diff is collapsed.
......@@ -73,7 +73,7 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
CategorizedHistoryModel::instance()->historyLimit());
ui->closeOrMinCheckBox->setChecked(settings_.value(
SettingsKey::closeOrMinimized).toBool());
connect(ui->tabWidget, QTabWidget::currentChanged, [](int index) {
connect(ui->tabWidget, &QTabWidget::currentChanged, [](int index) {
if (index == 1
&& CallModel::instance()->getActiveCalls().size() == 0) {
Video::PreviewManager::instance()->startPreview();
......
......@@ -31,11 +31,11 @@ void
ContactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
if (index.column() == 0) {
opt.text = "";
opt.text.clear();
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
QRect rect = opt.rect;
......@@ -53,8 +53,6 @@ ContactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
rect.width(), rect.height()/2),
opt.displayAlignment, c->formattedName());
QVariant var_p = c->photo();
painter->drawRect(QRect(rect.left(), rect.top(),
sizeImage_+1, sizeImage_+1));
if (var_p.isValid()) {
painter->drawImage(QRect(rect.left()+1, rect.top()+1,
sizeImage_, sizeImage_),
......
......@@ -18,8 +18,6 @@
#include "historydelegate.h"
#include <QDebug>
HistoryDelegate::HistoryDelegate(QObject *parent) :
QStyledItemDelegate(parent)
{
......@@ -30,7 +28,7 @@ void
HistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
if (index.column() == 0) {
......@@ -38,7 +36,7 @@ HistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
auto number = index.model()->data(index, static_cast<int>(Call::Role::Number)).toString();
Call::Direction direction = index.model()->data(index, static_cast<int>(Call::Role::Direction)).value<Call::Direction>();
opt.text = "";
opt.text.clear();
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
auto rect = opt.rect;
......
......@@ -37,13 +37,13 @@ ImDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
if (index.isValid()) {
auto msg = index.model()->data(index, Qt::DisplayRole).toString();
opt.text = "";
opt.text.clear();
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
auto rect = opt.rect;
......
/***************************************************************************
* 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 "mainbar.h"
#include "ui_mainbar.h"
#include <QSettings>
#include <QMessageBox>
#include "settingskey.h"
#include "callmodel.h"
#include "aboutdialog.h"
MainBar::MainBar(QWidget *parent) :
NavWidget(END, parent),
ui(new Ui::MainBar),
menu_(new QMenu())
{
ui->setupUi(this);
auto aboutAction = new QAction(tr("About"), this);
menu_->addAction(aboutAction);
connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
auto exitAction = new QAction(tr("Exit"), this);
menu_->addAction(exitAction);
connect(exitAction, SIGNAL(triggered()), this, SLOT(on_exitButton_clicked()));
ui->logoToolButton->setMenu(menu_);
ui->logoToolButton->setPopupMode(QToolButton::InstantPopup);
}
MainBar::~MainBar()
{
delete ui;
}
void
MainBar::on_confButton_clicked()
{
emit NavigationRequested(ScreenEnum::ConfScreen);
}
void
MainBar::on_callLineEdit_returnPressed()
{
callAction();
}
void
MainBar::on_callButton_clicked()
{
callAction();
}
void
MainBar::callAction() {
if (ui->callLineEdit->text().isEmpty())
return;
auto outCall = CallModel::instance()->dialingCall(ui->callLineEdit->text());
outCall->setDialNumber(ui->callLineEdit->text());
outCall->performAction(Call::Action::ACCEPT);
}
void
MainBar::showAboutDialog() {
AboutDialog *aboutDialog = new AboutDialog();
aboutDialog->exec();
delete aboutDialog;
}
void
MainBar::on_exitButton_clicked()
{
QSettings settings;
if (not settings.value(SettingsKey::closeOrMinimized).isValid()) {
QMessageBox confirmationDialog;
confirmationDialog.setText("Do you want to keep Ring minimized ?");
confirmationDialog.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
auto ret = confirmationDialog.exec();
if (ret == QMessageBox::Ok)
settings.setValue(SettingsKey::closeOrMinimized, true);
else
settings.setValue(SettingsKey::closeOrMinimized, false);
}
if (settings.value(SettingsKey::closeOrMinimized).toBool() == true)
emit minimize();
else
QCoreApplication::exit();
}
void
MainBar::on_minimizeButton_clicked()
{
emit minimize();
}
void
MainBar::atExit() {
}
This diff is collapsed.
......@@ -20,21 +20,23 @@
#include "ui_mainwindow.h"
#include <QSizeGrip>
#include <QWinThumbnailToolBar>
#include <QWinThumbnailToolButton>
#include "aboutdialog.h"
#include "media/text.h"
#include "media/textrecording.h"
#ifdef Q_OS_WIN32
#include <windows.h>
#include <QWinThumbnailToolBar>
#include <QWinThumbnailToolButton>
#endif
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
QIcon icon(":images/ring.png");
this->setWindowIcon(icon);
......@@ -64,11 +66,18 @@ MainWindow::MainWindow(QWidget *parent) :
this, SLOT(onIncomingCall(Call*)));
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);
});
#ifdef Q_OS_WIN32
HMENU sysMenu = ::GetSystemMenu((HWND) winId(), FALSE);
if (sysMenu != NULL) {
::AppendMenuA(sysMenu, MF_SEPARATOR, 0, 0);
QString aboutTitle = tr("About");
::AppendMenuA(sysMenu, MF_STRING, IDM_ABOUTBOX, aboutTitle.toStdString().c_str());
}
#endif
}
MainWindow::~MainWindow()
......@@ -77,20 +86,26 @@ MainWindow::~MainWindow()
delete navStack_;
}
void
MainWindow::mousePressEvent(QMouseEvent *evt)
bool
MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
oldPos_ = evt->globalPos();
}
Q_UNUSED(eventType)
void
MainWindow::mouseMoveEvent(QMouseEvent *evt)
{
if(evt->buttons() & Qt::LeftButton) {
const auto delta = evt->globalPos() - oldPos_;
move(x() + delta.x(), y() + delta.y());
oldPos_ = evt->globalPos();
#ifdef Q_OS_WIN32
MSG *msg = (MSG*) message;
if (msg->message == WM_SYSCOMMAND) {
if ((msg->wParam & 0xfff0) == IDM_ABOUTBOX) {
*result = 0;
AboutDialog aboutDialog;
aboutDialog.exec();
return true;
}
}
#endif
return false;
}
void
......@@ -110,6 +125,7 @@ MainWindow::onIncomingCall(Call *call)
void
MainWindow::createThumbBar()
{
#ifdef Q_OS_WIN32
QWinThumbnailToolBar *thumbbar = new QWinThumbnailToolBar(this);
thumbbar->setWindow(this->windowHandle());
QWinThumbnailToolButton *settings = new QWinThumbnailToolButton(thumbbar);
......@@ -122,4 +138,5 @@ MainWindow::createThumbBar()
});
thumbbar->addButton(settings);
#endif
}
......@@ -25,6 +25,8 @@
#include "navstack.h"
static constexpr char IDM_ABOUTBOX = 0x0010;
namespace Ui {
class MainWindow;
}
......@@ -38,6 +40,8 @@ public:
~MainWindow();
void createThumbBar();
protected:
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
private slots:
void trayActivated(QSystemTrayIcon::ActivationReason reason);
void onIncomingCall(Call *call);
......@@ -45,9 +49,5 @@ private slots:
private:
Ui::MainWindow *ui;
NavStack* navStack_;
QPoint oldPos_;
protected:
void mousePressEvent(QMouseEvent *evt);
void mouseMoveEvent(QMouseEvent *evt);
};
This diff is collapsed.
......@@ -22,13 +22,13 @@ NavStack::NavStack(QStackedWidget* bar, QStackedWidget* stack, QWidget *parent)
: bar_(bar)
, stack_(stack)
{
navList_.append(new MainBar());
Q_UNUSED(parent)
navList_.append(new NavBar());
navList_.append(new CallWidget());
navList_.append(new ConfigurationWidget());
connect(navList_[Main], SIGNAL(minimize()), parent, SLOT(showMinimized()));
for (int i = 0; i < END; i++) {
if (i < CallScreen)
bar_->addWidget(navList_[i]);
......@@ -39,6 +39,7 @@ NavStack::NavStack(QStackedWidget* bar, QStackedWidget* stack, QWidget *parent)
connect(navList_[i], SIGNAL(BackRequested()),
this, SLOT(onBackRequested()));
}
bar_->hide();
}
NavStack::~NavStack()
......@@ -53,7 +54,11 @@ NavStack::onNavigationRequested(ScreenEnum screen) {
if (navList_[screen] == stack_->currentWidget())
return;
if (screen < CallScreen) {
bar_->setCurrentWidget(navList_[screen]);
bar_->show();
if (auto barItem = navList_[screen])
bar_->setCurrentWidget(barItem);
else
bar_->hide();
} else {
stack_->setCurrentWidget(navList_[screen]);
setNavBar(navList_[screen]);
......@@ -78,6 +83,10 @@ NavStack::onBackRequested() {
void
NavStack::setNavBar(NavWidget* navW) {
if (navW->barDesired != END)
if (navW->barDesired != END) {
bar_->setCurrentWidget(navList_[navW->barDesired]);
bar_->show();
} else {
bar_->hide();
}
}
......@@ -23,7 +23,6 @@
#include "navwidget.h"
#include "configurationwidget.h"
#include "mainbar.h"
#include "navbar.h"
#include "callwidget.h"
......
......@@ -21,7 +21,6 @@
#include <QWidget>
enum ScreenEnum {
Main,
Nav,
//DO not add main widget screen before callScreen
CallScreen,
......
......@@ -25,5 +25,6 @@
<file>images/folder-download.png</file>
<file>images/arrow-right.png</file>
<file>images/message-text-outline.png</file>
<file>images/history.png</file>
</qresource>
</RCC>
/***************************************************************************
* 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 "smartlistdelegate.h"
#include <QApplication>
#include <QSortFilterProxyModel>
#include <QPainter>
#include "itemdataroles.h"
#include "person.h"
#include "recentmodel.h"
#include "call.h"
SmartListDelegate::SmartListDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{
}
void
SmartListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
if (index.column() == 0) {
opt.text.clear();
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
QRect rect = opt.rect;
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ?
QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
cg = QPalette::Inactive;
painter->setPen(opt.palette.color(cg, QPalette::Text));
painter->setOpacity(1.0);
QVariant name = index.data(static_cast<int>(Ring::Role::Name));
if (name.isValid()) {
painter->drawText(QRect(rect.left()+sizeImage_+5, rect.top(),
rect.width(), rect.height()/2),
opt.displayAlignment, name.toString());
}
QVariant state = index.data(static_cast<int>(Ring::Role::FormattedState));
if (state.isValid() && RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(index))) {
painter->drawText(QRect(rect.left()+sizeImage_+5,
rect.top() + rect.height()/2,
rect.width(), rect.height()/2),
opt.displayAlignment, state.toString());