Commit 12353822 authored by Edric Milaret's avatar Edric Milaret

UI: style and code improvement

- removed unused code
- sort button is now a list
- switched to LRC sort new API
- removed some tab ugly tab border
- add history call dir arrow
- enforce the destruction of LRC on exit
- add placeholder for dial text box
- style tab header to look like pivot control

Refs #73039
Refs #73040

Change-Id: I57d6fcd3c26860596a11f554555d8a43267ea6c2
parent 7d40a4a4
......@@ -36,8 +36,6 @@ SOURCES += main.cpp\
accountdetails.cpp \
minimalhistorybackend.cpp \
aboutdialog.cpp \
pivotviewwidget.cpp \
pivotcontrol.cpp \
videowidget.cpp \
utils.cpp \
wizarddialog.cpp \
......@@ -55,8 +53,6 @@ HEADERS += mainwindow.h \
accountdetails.h \
minimalhistorybackend.h \
aboutdialog.h \
pivotviewwidget.h \
pivotcontrol.h \
videowidget.h \
utils.h \
wizarddialog.h \
......
......@@ -75,81 +75,15 @@ CallWidget::CallWidget(QWidget *parent) :
PersonModel::instance()->
addCollection<WindowsContactBackend>(LoadOptions::FORCE_ENABLED);
auto historyModel = std::unique_ptr<QSortFilterProxyModel>(new QSortFilterProxyModel());
historyModel->setSourceModel(CategorizedHistoryModel::instance());
historyModel->setSortRole(static_cast<int>(Call::Role::Date));
historyModel->sort(0,Qt::DescendingOrder);
ui->historyList->setModel(historyModel.get());
ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance()->model());
CategorizedHistoryModel::SortedProxy::instance()->model()->sort(0, Qt::DescendingOrder);
ui->historyList->setHeaderHidden(true);
ui->historyList->setItemDelegate(new HistoryDelegate());
historyModel.release();
auto sortActionGroup = new QActionGroup(this);
auto alphabetAction = new QAction("Alphetical Order Ascending", this);
alphabetAction->setCheckable(true);
sortActionGroup->addAction(alphabetAction);
menu_->addAction(alphabetAction);
connect(alphabetAction, &QAction::triggered, this, [=]() {
CategorizedHistoryModel::instance()->setCategoryRole(static_cast<int>(Call::Role::Name));
historyModel->setSortRole(static_cast<int>(Call::Role::Name));
historyModel->sort(0,Qt::AscendingOrder);
});
auto alphabetDownAction = new QAction("Alphetical Order Descending", this);
alphabetDownAction->setCheckable(true);
sortActionGroup->addAction(alphabetDownAction);
menu_->addAction(alphabetDownAction);
connect(alphabetDownAction, &QAction::triggered, this, [=]() {
CategorizedHistoryModel::instance()->setCategoryRole(static_cast<int>(Call::Role::Name));
historyModel->setSortRole(static_cast<int>(Call::Role::Name));
historyModel->sort(0,Qt::DescendingOrder);
});
auto dateAction = new QAction("Date Order Ascending", this);
dateAction->setCheckable(true);
sortActionGroup->addAction(dateAction);
menu_->addAction(dateAction);
connect(dateAction, &QAction::triggered, this, [=]() {
CategorizedHistoryModel::instance()->setCategoryRole(static_cast<int>(Call::Role::FuzzyDate));
historyModel->setSortRole(static_cast<int>(Call::Role::Date));
historyModel->sort(0,Qt::AscendingOrder);
});
auto dateDownAction = new QAction("Date Order Descending", this);
dateDownAction->setCheckable(true);
sortActionGroup->addAction(dateDownAction);
menu_->addAction(dateDownAction);
connect(dateDownAction, &QAction::triggered, this, [=]() {
CategorizedHistoryModel::instance()->setCategoryRole(static_cast<int>(Call::Role::FuzzyDate));
historyModel->setSortRole(static_cast<int>(Call::Role::Date));
historyModel->sort(0,Qt::DescendingOrder);
});
dateDownAction->setChecked(true);
dateDownAction->trigger();
auto callsNumberAction = new QAction("Number of calls ascending", this);
callsNumberAction->setCheckable(true);
sortActionGroup->addAction(callsNumberAction);
menu_->addAction(callsNumberAction);
connect(callsNumberAction, &QAction::triggered, this, [=]() {
CategorizedHistoryModel::instance()->setCategoryRole(static_cast<int>(Call::Role::CallCount));
historyModel->setSortRole(static_cast<int>(Call::Role::CallCount));
historyModel->sort(0,Qt::AscendingOrder);
});
auto callsDownNumberAction = new QAction("Number of calls descending", this);
callsDownNumberAction->setCheckable(true);
sortActionGroup->addAction(callsDownNumberAction);
menu_->addAction(callsDownNumberAction);
connect(callsDownNumberAction, &QAction::triggered, this, [=]() {
CategorizedHistoryModel::instance()->setCategoryRole(static_cast<int>(Call::Role::CallCount));
historyModel->setSortRole(static_cast<int>(Call::Role::CallCount));
historyModel->sort(0,Qt::DescendingOrder);
});
ui->sortToolButton->setMenu(menu_);
ui->sortToolButton->setPopupMode(QToolButton::InstantPopup);
auto idx = CategorizedHistoryModel::SortedProxy::instance()->model()->index(0,0);
if (idx.isValid())
ui->historyList->setExpanded(idx, true);
ui->sortComboBox->setModel(CategorizedHistoryModel::SortedProxy::instance()->categoryModel());
CategorizedContactModel::instance()->setSortAlphabetical(false);
ui->contactView->setModel(CategorizedContactModel::instance());
......@@ -369,6 +303,9 @@ CallWidget::on_contactView_doubleClicked(const QModelIndex &index)
void
CallWidget::on_historyList_doubleClicked(const QModelIndex &index)
{
if (not index.isValid())
return;
QString number = index.model()->data(index, static_cast<int>(Call::Role::Number)).toString();
if (not number.isEmpty()) {
auto outCall = CallModel::instance()->dialingCall(number);
......@@ -383,4 +320,14 @@ CallWidget::setActualCall(Call* value)
actualCall_ = value;
ui->holdButton->setEnabled(actualCall_ != nullptr);
ui->hangupButton->setEnabled(actualCall_ != nullptr);
}
void
CallWidget::on_sortComboBox_currentIndexChanged(int index)
{
auto idx = CategorizedHistoryModel::SortedProxy::instance()->
categoryModel()->index(index, 0);
CategorizedHistoryModel::SortedProxy::instance()->categorySelectionModel()->
setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance()->model());
}
......@@ -74,6 +74,8 @@ private slots:
void callStateChanged(Call *call, Call::State previousState);
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void on_sortComboBox_currentIndexChanged(int index);
private:
Ui::CallWidget *ui;
Call* actualCall_;
......
......@@ -91,7 +91,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>4</number>
<number>0</number>
</property>
<property name="topMargin">
<number>4</number>
......@@ -100,7 +100,7 @@
<number>0</number>
</property>
<property name="bottomMargin">
<number>4</number>
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -109,6 +109,9 @@
</property>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>Search</string>
</property>
......@@ -118,13 +121,16 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="sortToolButton">
<widget class="QLabel" name="label">
<property name="text">
<string/>
<string>Sort:</string>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/sort-variant.png</normaloff>:/images/sort-variant.png</iconset>
</widget>
</item>
<item>
<widget class="QComboBox" name="sortComboBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
</widget>
</item>
......@@ -133,7 +139,7 @@
<item>
<widget class="QTreeView" name="historyList">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -146,7 +152,7 @@
</property>
<property name="maximumSize">
<size>
<width>200</width>
<width>220</width>
<height>16777215</height>
</size>
</property>
......@@ -163,16 +169,16 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>4</number>
<number>0</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>4</number>
<number>0</number>
</property>
<item>
<widget class="QListView" name="contactView">
......@@ -314,7 +320,7 @@
</layout>
</widget>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="callStateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>538</height>
<height>544</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -47,39 +47,59 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="deviceSelecLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Device Selection</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
<property name="horizontalSpacing">
<number>15</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="deviceSelecLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Device Selection</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="deviceLabel">
<property name="text">
......@@ -217,7 +237,11 @@
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="accountDetailLayout"/>
<layout class="QVBoxLayout" name="accountDetailLayout">
<property name="bottomMargin">
<number>13</number>
</property>
</layout>
</item>
</layout>
</widget>
......
......@@ -36,6 +36,8 @@ HistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
if (index.column() == 0) {
auto name = index.model()->data(index, Qt::DisplayRole).toString();
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 = "";
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
......@@ -51,6 +53,17 @@ HistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->setOpacity(0.7);
painter->drawText(QRect(rect.left(), rect.top() + rect.height()/2, rect.width(), rect.height()/2),
opt.displayAlignment, number);
painter->setOpacity(1.0);
QImage arrow;
switch (direction) {
case Call::Direction::INCOMING:
arrow.load("://images/arrow-down.png");
break;
case Call::Direction::OUTGOING:
arrow.load("://images/arrow-up.png");
break;
}
painter->drawImage(QRect(rect.left() -imgSize_, rect.top() + (rect.height()-imgSize_)/2, imgSize_, imgSize_), arrow);
} else {
painter->drawText(QRect(rect.left(), rect.top(), rect.width(), rect.height()),
opt.displayAlignment, name);
......
......@@ -36,9 +36,9 @@ public:
protected:
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
public slots:
private:
constexpr static int imgSize_ = 25;
};
#endif // HISTORYDELEGATE_H
......@@ -20,6 +20,13 @@
#include <QApplication>
#include <QFile>
#include "callmodel.h"
#include <iostream>
#include <QThread>
#include <windows.h>
int
main(int argc, char *argv[])
{
......@@ -39,5 +46,9 @@ main(int argc, char *argv[])
MainWindow w;
w.show();
QObject::connect(&a, &QApplication::aboutToQuit, [&a]() {
delete CallModel::instance();
});
return a.exec();
}
......@@ -532,6 +532,9 @@
<height>50</height>
</size>
</property>
<property name="placeholderText">
<string>Dial Number</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
......
......@@ -27,7 +27,6 @@
#include "mainbar.h"
#include "navbar.h"
#include "callwidget.h"
#include "pivotviewwidget.h"
class NavStack : public QWidget
{
......
......@@ -26,7 +26,6 @@ enum ScreenEnum {
Nav,
//DO not add main widget screen before callScreen
CallScreen,
//PivotScreen,
ConfScreen,
END
};
......
/***************************************************************************
* 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 "pivotcontrol.h"
PivotControl::PivotControl(QWidget *parent) : QGraphicsView(parent)
{
const int itemCount = 6;
QGraphicsTextItem *tmp;
QString text;
qreal xPos = 0;
//QParallelAnimationGroup *mGroupAnimHeaderTmp = new QParallelAnimationGroup;
this->setScene(new QGraphicsScene());
for(int i = 0; i < itemCount; ++i) {
tmp = new QGraphicsTextItem();
text = "loremIpsum";
text = text.append(QString("%1").arg(i+1));
tmp->setPlainText(text);
tmp->setFont(headerFont);
tmp->adjustSize();
tmp->setDefaultTextColor(uiTextColor);
tmp->setPos(xPos,(componentMargin * 2 + bodyTextSize));
xPos = xPos + tmp->textWidth() + componentMargin;
// QPropertyAnimation *anim;
// anim = new QPropertyAnimation(tmp, "pos");
// anim->setDuration(animationTime);
// anim->setPropertyName("pos");
// anim->setEasingCurve(QEasingCurve::OutCirc);
// mGroupAnimHeaderTmp->addAnimation(anim);
//mHeaderAnimations.append(anim);
mHeaderItems.append(tmp);
scene()->addItem(tmp);
}
//mGroupAnimHeader = mGroupAnimHeaderTmp;
}
#include <QDebug>
void PivotControl::mousePressEvent(QMouseEvent *event)
{
qDebug() << "MOUSE PRESS EVENT";
//mGroupAnimHeader = new QParallelAnimationGroup;
// int xDif = event->pos().x() - mMouseXPosition;
// ...
// if(xDif < 0) {
// ...
// startContentAnimation(ESweepLeft);
// startHeaderAnimation(ESweepLeft);
// } else if(xDif > 0) {
// ...
// startContentAnimation(ESweepRight);
// startHeaderAnimation(ESweepRight);
// }
// mMouseXPosition = event->pos().x();
}
void PivotControl::startContentAnimation(int direction)
{
// QPropertyAnimation *anim;
// QGraphicsTextItem *text;
// // init animation items
// for(int i = 0; i < itemCount; ++i) {
// text = mContentItems.at(i);
// anim = mContentAnimations.at(i);
// QPointF start = text->pos();
// QPointF end = start;
// if(direction == ESweepLeft)
// end.setX( end.x() - text->textWidth() - componentMargin);
// else
// end.setX( end.x() + text->textWidth() + componentMargin);
// anim->setStartValue(start);
// anim->setEndValue(end);
// }
// mGroupAnimContent->start();
}
PivotControl::~PivotControl()
{
}
/***************************************************************************
* 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 PIVOTCONTROL_H
#define PIVOTCONTROL_H
#include <QObject>
#include <QWidget>
#include <QGraphicsView>
#include <QGraphicsTextItem>
#include <QList>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
class PivotControl : public QGraphicsView
{
const int componentMargin = 24;
const int bodyTextSize = 24;
const int headerTextSize = 16;
const QFont headerFont = QFont("Segoe UI", headerTextSize);
const QFont bodyFont = QFont("Segoe UI", bodyTextSize);
const QColor uiTextColor = Qt::black;
const QString backgroundStyle = "background-color: rgba(26,26,26)";
const int animationTime = 400;
public:
PivotControl(QWidget* parent = 0);
~PivotControl();
protected:
void startContentAnimation(int direction);
void mousePressEvent(QMouseEvent *event);
private:
QList<QGraphicsTextItem*> mHeaderItems;
QParallelAnimationGroup *mGroupAnimHeader;
};
#endif // PIVOTCONTROL_H
/***************************************************************************
* 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 "pivotviewwidget.h"
#include "ui_pivotviewwidget.h"
#include <QDebug>
PivotViewWidget::PivotViewWidget(QWidget *parent) :
NavWidget(CallScreen/*PivotScreen*/ , parent),
ui(new Ui::PivotViewWidget)
{
ui->setupUi(this);
}
PivotViewWidget::~PivotViewWidget()
{
delete ui;
}
void PivotViewWidget::atExit()
{
}
/***************************************************************************
* 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 PIVOTVIEWWIDGET_H
#define PIVOTVIEWWIDGET_H
#include <QWidget>
#include "navwidget.h"
#include "pivotcontrol.h"
namespace Ui {
class PivotViewWidget;
}
class PivotViewWidget : public NavWidget
{
Q_OBJECT
public:
explicit PivotViewWidget(QWidget *parent = 0);
~PivotViewWidget();
void atExit();
private:
Ui::PivotViewWidget *ui;
};
#endif // PIVOTVIEWWIDGET_H
......@@ -19,5 +19,7 @@
<file>images/speaker-off.png</file>
<file>images/account.png</file>
<file>images/sort-variant.png</file>
<file>images/arrow-down.png</file>
<file>images/arrow-up.png</file>
</qresource>
</RCC>
......@@ -162,6 +162,13 @@ QListView::indicator:unchecked {
image: url(://images/checkbox-blank-outline.png);
}
QHeaderView::section {
background-color: white;
padding-left: 4px;
border: none;
border-right: 1px solid grey;
}
QCheckBox::indicator {
width: 18px;
height: 18px;
......@@ -174,3 +181,24 @@ QCheckBox::indicator:checked {
QCheckBox::indicator:unchecked {
image: url(://images/checkbox-blank-outline.png);
}
QTabWidget {
border:none;
}
QTabWidget::pane {
border:none;
}
QTabBar::tab {
min-width: 80px;
min-height: 30px;
font-size: 20px;
color: black;
border-bottom-color: #C2C7CB;
padding: 0px;
}
QTabBar::tab:selected {
font-weight: bold;
border-bottom-style: none;
}
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