Commit 600208bd authored by Andreas Traczyk's avatar Andreas Traczyk

code cleanup

- Removes dead code and old-lrc references.

- Removes winsparkle from submodules.

Change-Id: Ia7d00f9f770e1697edf66192252d9d54e035a7b7
parent 0280dca7
[submodule "winsparkle"]
path = winsparkle
url = git://github.com/vslavik/winsparkle.git
ignore = dirty
[submodule "libqrencode"]
path = libqrencode
url = https://github.com/fukuchi/libqrencode.git
......
/**************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@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 "bannedcontactswidget.h"
#include "ui_bannedcontactswidget.h"
#include <QAbstractItemModel>
#include <QPainter>
#include "ringthemeutils.h"
// LRC
#include "account.h"
#include "bannedcontactmodel.h"
#include <ciso646>
/* Widget */
BannedContactsWidget::BannedContactsWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::BannedContactsWidget)
{
ui->setupUi(this);
bannedItemDelegate_ = new BannedContactItemDelegate();
ui->bannedList->setItemDelegate(bannedItemDelegate_);
connect(ui->bannedList, &QAbstractItemView::clicked, this, &BannedContactsWidget::setCurrentContact);
connect(ui->bannedList, &QAbstractItemView::clicked, this, [this](){ui->debanStack->setCurrentWidget(ui->debanPage);});
connect(ui->debanButton, &QPushButton::clicked, this, &BannedContactsWidget::debanContact);
}
BannedContactsWidget::~BannedContactsWidget()
{
delete ui;
}
void BannedContactsWidget::setAccount(Account *ac)
{
account_ = ac;
// Configure banned list to display banned contacts
ui->bannedList->setModel(account_->bannedContactModel());
// deban page hidden when model changes
ui->debanStack->setCurrentWidget(ui->cleanPage);
}
void BannedContactsWidget::setCurrentContact(const QModelIndex index)
{
ui->bannedIdLabel->setText(index.data().toString());
bannedContact_ = index.data(static_cast<int>(ContactMethod::Role::Object)).value<ContactMethod*>();
qDebug() << "banned contact method = " << bannedContact_;
}
void BannedContactsWidget::debanContact()
{
if (bannedContact_){
account_->bannedContactModel()->remove(bannedContact_);
ui->debanStack->setCurrentWidget(ui->cleanPage);
} else {
qDebug() << "banned contact: contactMethod not set!";
}
}
/* List Item Delegate */
BannedContactItemDelegate::BannedContactItemDelegate(QObject *parent):
QItemDelegate(parent)
{
}
void BannedContactItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
painter->setRenderHint(QPainter::Antialiasing);
QStyleOptionViewItem opt(option);
// Not having focus removes dotted lines around the item
if (opt.state & QStyle::State_HasFocus)
opt.state ^= QStyle::State_HasFocus;
// First, we draw the control itself
QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
// Then, we print the text
QFont font(painter->font());
font.setPointSize(10);
font.setBold(true);
painter->setFont(font);
QFontMetrics fontMetrics(font);
QRect rectText(opt.rect);
rectText.setLeft(opt.rect.left() + dxText_);
rectText.setBottom(rectText.top() + dyText_ + fontMetrics.height()/2);
rectText.setTop(rectText.bottom() - fontMetrics.height());
QString text(index.data().toString());
text = fontMetrics.elidedText(text, Qt::ElideRight, rectText.width());
QPen pen(painter->pen());
pen.setColor(RingTheme::lightBlack_);
painter->setPen(pen);
painter->drawText(rectText,text);
// Draw separator when item is not selected
if (not (opt.state & QStyle::State_Selected)) {
QRect rect(opt.rect);
pen.setColor(RingTheme::lightGrey_);
painter->setPen(pen);
painter->drawLine(rect.left() + separatorYPadding_, rect.bottom(),
rect.right() - separatorYPadding_,
rect.bottom());
}
}
QSize BannedContactItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize size = QItemDelegate::sizeHint(option, index);
size.setHeight(cellHeight_);
return size;
}
/**************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@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 BANNEDCONTACTSWIDGET_H
#define BANNEDCONTACTSWIDGET_H
#include <QWidget>
#include <QAbstractItemModel>
#include <QObject>
#include <QItemDelegate>
// LRC
#include "account.h"
#include "contactmethod.h"
/* item delegate */
class BannedContactItemDelegate : public QItemDelegate
{
public:
BannedContactItemDelegate(QObject* parent = 0);
protected:
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
private:
constexpr static int cellHeight_ = 60;
constexpr static int sizeImage_ = 48;
constexpr static int dxImage_ = 16;
constexpr static int dyImage_ = 6;
constexpr static int dxText_ = dxImage_;
constexpr static int dyText_ = cellHeight_/2;
constexpr static int separatorYPadding_ = 20;
};
/* widget */
namespace Ui {
class BannedContactsWidget;
}
class BannedContactsWidget : public QWidget
{
Q_OBJECT
public:
explicit BannedContactsWidget(QWidget *parent = 0);
~BannedContactsWidget();
void setAccount(Account *ac);
private slots:
void setCurrentContact(const QModelIndex index);
void debanContact();
private:
Account* account_ {};
BannedContactItemDelegate* bannedItemDelegate_;
ContactMethod* bannedContact_;
Ui::BannedContactsWidget *ui;
};
#endif // BANNEDCONTACTSWIDGET_H
......@@ -41,8 +41,6 @@
// lrc
#include "globalinstances.h"
#include "profilemodel.h"
#include "localprofilecollection.h"
// client
#include "windowscontactbackend.h"
......@@ -74,9 +72,6 @@ CallWidget::CallWidget(QWidget* parent) :
videoRenderer_ = nullptr;
// this line is not welcome here, and must be removed
ProfileModel::instance().addCollection<LocalProfileCollection>(LoadOptions::FORCE_ENABLED);
QSettings settings;
// select last used account if stored in registry
......
......@@ -36,7 +36,6 @@
#include "video/renderer.h"
#include "video/previewmanager.h"
#include "accountmodel.h"
#include "categorizedhistorymodel.h"
#include "media/textrecording.h"
// new LRC
......
......@@ -139,7 +139,7 @@ main(int argc, char *argv[])
gnutls_global_init();
#endif
GlobalInstances::setPixmapManipulator(std::unique_ptr<PixbufManipulator>(new PixbufManipulator()));
GlobalInstances::setPixmapManipulator(std::make_unique<PixbufManipulator>());
LRCInstance::init();
QFile debugFile("debug.log");
......
......@@ -69,7 +69,7 @@
<TargetExt>.lib</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
<PreBuildEventUseInBuild>false</PreBuildEventUseInBuild>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
......@@ -230,7 +230,6 @@
<ClCompile Include="aboutdialog.cpp" />
<ClCompile Include="accountitemdelegate.cpp" />
<ClCompile Include="accountlistmodel.cpp" />
<ClCompile Include="bannedcontactswidget.cpp" />
<ClCompile Include="callwidget.cpp">
<OutputFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\%(Filename).moc</OutputFile>
<OutputFile Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName)\%(Filename).moc</OutputFile>
......@@ -298,8 +297,6 @@
<ItemGroup>
<QtMoc Include="aboutdialog.h">
</QtMoc>
<QtMoc Include="bannedcontactswidget.h">
</QtMoc>
<QtMoc Include="callwidget.h">
<SubType>Designer</SubType>
</QtMoc>
......
......@@ -63,9 +63,6 @@
<ClCompile Include="aboutdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="bannedcontactswidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="deleteaccountdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -203,9 +200,6 @@
<QtMoc Include="aboutdialog.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="bannedcontactswidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="callwidget.h">
<Filter>Header Files</Filter>
</QtMoc>
......
......@@ -22,7 +22,6 @@
#include <QPainter>
#include "personmodel.h"
#include "categorizedcontactmodel.h"
#include "utils.h"
......@@ -390,4 +389,3 @@ FlagPack<CollectionInterface::SupportedFeatures> WindowsContactBackend::supporte
CollectionInterface::SupportedFeatures::REMOVE |
CollectionInterface::SupportedFeatures::ADD);
}
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