#include "iconutils.h"

#include "qmath.h"

#include <math.h>

namespace IconUtils {

QIcon createSettingsIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::black, 2));
    painter.drawEllipse(8, 8, 8, 8);
    for (int i = 0; i < 8; ++i) {
        painter.drawLine(12 + 6 * qCos(i * M_PI / 4), 12 + 6 * qSin(i * M_PI / 4),
                        12 + 8 * qCos(i * M_PI / 4), 12 + 8 * qSin(i * M_PI / 4));
    }
    return QIcon(pixmap);
}

QIcon createSearchIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::black, 2));
    painter.drawEllipse(6, 6, 10, 10);
    painter.drawLine(14, 14, 18, 18);
    return QIcon(pixmap);
}

QIcon createUserIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::black, 2));
    painter.drawEllipse(8, 4, 8, 8);
    painter.drawArc(4, 12, 16, 12, 0, 180 * 16);
    return QIcon(pixmap);
}

QIcon createAudioDeviceIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::black, 2));
    painter.drawRect(8, 6, 8, 12);
    painter.drawLine(6, 10, 8, 10);
    painter.drawLine(6, 14, 8, 14);
    painter.drawLine(16, 10, 18, 10);
    painter.drawLine(16, 14, 18, 14);
    return QIcon(pixmap);
}

QIcon createStreamIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::black, 2));
    QPolygon triangle;
    triangle << QPoint(6, 6) << QPoint(18, 12) << QPoint(6, 18);
    painter.drawPolygon(triangle);
    return QIcon(pixmap);
}

QIcon createChatIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::black, 2));
    painter.drawRoundedRect(4, 4, 16, 12, 2, 2);
    QPolygon tail;
    tail << QPoint(8, 16) << QPoint(12, 20) << QPoint(12, 16);
    painter.drawPolygon(tail);
    return QIcon(pixmap);
}

QIcon createRecordIcon()
{
    QPixmap pixmap(24, 24);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(Qt::red, 2));
    painter.setBrush(QBrush(Qt::red));
    painter.drawEllipse(6, 6, 12, 12);
    return QIcon(pixmap);
}

} // namespace IconUtils
