Commit 48f85735 authored by scuq's avatar scuq

some bits for own status

parent f8be9eba
......@@ -10,6 +10,7 @@ set(CPP_SOURCE_FILES
dialogaccountdetail.cpp
dialogfileviewer.cpp
dialogchat.cpp
aictrayicon.cpp
imcontact.cpp
imsession.cpp
manipulator.cpp
......
......@@ -146,7 +146,10 @@ void dialogChat::setChatFont(QFont font)
void dialogChat::closeEvent(QCloseEvent *closeev)
{
this->m_mp->setSaveWindowStatePosition(this->windowTitle().replace(" ","").replace("*",""), saveGeometry(),0);
closeev->accept();
this->hide();
closeev->ignore();
}
void dialogChat::resizeEvent(QResizeEvent *e)
......
......@@ -50,7 +50,8 @@ SOURCES += \
replytimeout.cpp \
dialogfileviewer.cpp \
qclicklabel.cpp \
aictrayicon.cpp
aictrayicon.cpp \
statuslabel.cpp
HEADERS += \
qmmainwindow.h \
......@@ -75,7 +76,8 @@ HEADERS += \
replytimeout.h \
dialogfileviewer.h \
qclicklabel.h \
aictrayicon.h
aictrayicon.h \
statuslabel.h
FORMS += \
qmmainwindow.ui \
......
......@@ -12,6 +12,9 @@ qmMainWindow::qmMainWindow(QWidget *parent) :
m_mp = new manipulator();
m_mp->setInitialized(true);
labelMyStatus = new StatusLabel();
connect( this->m_mp, SIGNAL(siGlobalSettingsChanged(QMap<QString, QVariant>)), labelMyStatus, SLOT(slGlobalSettingsChanged(QMap<QString, QVariant>)) );
this->setupTrayIcon();
this->updateQuestionShown = false;
......@@ -38,10 +41,12 @@ qmMainWindow::qmMainWindow(QWidget *parent) :
this->setupTableViews();
this->printDebugSslLib();
this->printDebugSslLib();
......@@ -204,6 +209,8 @@ void qmMainWindow::setupTableViews()
connect(rostermodel, SIGNAL(siUnreadsPending()), this, SLOT(slUnreadsPending()));
connect(rostermodel, SIGNAL(siUnreadsPending()), this->trayIcon, SLOT(slBeFlashy()));
connect(rostermodel, SIGNAL(siMyStatus(QString)), this, SLOT(slMyStatusReceived(QString)));
this->m_mp->apply();
......@@ -232,7 +239,7 @@ accntviews.value()->setModel(fsModel);
_account = iMSessions.value(accntviews.key())->getAccount();
QPushButton *pushButtonMe = new QPushButton(_account->getNickname());
QPushButton *pushButtonMe = new QPushButton(_account->getUsername());
QSignalMapper * mapper = new QSignalMapper(this);
......@@ -242,19 +249,21 @@ accntviews.value()->setModel(fsModel);
mapper->setMapping(pushButtonMe, accntviews.key());
QComboBox *comboBoxMyStatus = new QComboBox();
// QComboBox *comboBoxMyStatus = new QComboBox();
pushButtonMe->setFixedHeight(25);
comboBoxMyStatus->addItem("online");
comboBoxMyStatus->addItem("away");
comboBoxMyStatus->addItem("offline");
comboBoxMyStatus->setMaximumWidth(60);
comboBoxMyStatus->view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
this->labelMyStatus->setCurrentStatus(ImContact::presenceStatus::online);
selfLayout->addWidget( comboBoxMyStatus );
selfLayout->addWidget( labelMyStatus );
selfLayout->addWidget( pushButtonMe );
selfLayout->setMargin(0);
selfLayout->setSpacing(0);
QWidget *selfContent = new QWidget;
......@@ -618,6 +627,15 @@ void qmMainWindow::slRosterContextMenuRequested(const QPoint &pos)
menu->popup(currentAccountTableView->viewport()->mapToGlobal(pos));
}
void qmMainWindow::slMyStatusReceived(QString presencestatusstr)
{
this->labelMyStatus->setCurrentStatus(ImContact::stringToPresenceStatus(presencestatusstr));
}
void qmMainWindow::slActionAddIgnore()
{
QString _newignorenick = currentAccountTableView->selectionModel()->selectedRows(int(RosterModel::ColumnIndex::nickname)).at(0).data().toString();
......
......@@ -8,6 +8,10 @@
#include <QHeaderView>
#include <QMessageBox>
#include <QDesktopServices>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QComboBox>
#include <QSignalMapper>
......@@ -24,6 +28,7 @@
#include "updatecheck.h"
#include "dialogchat.h"
#include "aictrayicon.h"
#include "statuslabel.h"
namespace Ui {
class qmMainWindow;
......@@ -55,6 +60,7 @@ private:
manipulator *m_mp;
StatusLabel *labelMyStatus;
AicTrayIcon *trayIcon;
QAction *actionAddIgnore;
QAction *actionRemoveIgnore;
......@@ -115,6 +121,9 @@ private slots:
void slRosterContextMenuRequested(const QPoint &pos);
void slMyStatusReceived(QString presencestatusstr);
void slActionAddIgnore();
......
......@@ -286,6 +286,7 @@ void RosterModel::slOnRosterUpdateReceived(QMap<QString, ImContact *> imContacts
_account = this->session->getAccount();
if (cntcts.value()->getId() == _account->getUserid()) {
emit (siMyStatus( cntcts.value()->getPresencestatusString() ) );
continue;
}
......
......@@ -109,6 +109,7 @@ private:
signals:
void siRosterLoaded();
void siUnreadsPending();
void siMyStatus(QString presencestatusstr);
private slots:
......
#include "statuslabel.h"
StatusLabel::StatusLabel()
{
this->setFixedWidth(20);
this->setFixedHeight(20);
}
ImContact::presenceStatus StatusLabel::getCurrentStatus() const
{
return currentStatus;
}
void StatusLabel::setCurrentStatus(const ImContact::presenceStatus &value)
{
currentStatus = value;
qDebug() << "AAAAAAAAAAAAA"<< value;
QImage image(QSize(this->width(),this->height()),QImage::Format_RGB32);
QPainter painter;
//painter.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing);
switch (currentStatus) {
case ImContact::presenceStatus::online:
{
qDebug() << "AAAAAAAAAAAAA"<< value << this->getColorOnline();
painter.begin(&image);
painter.setBrush(QBrush( this->getColorOnline() ));
QRectF rect = QRectF(this->rect().left(), this->rect().top(), this->width(), this->height());
painter.drawRect(rect);
painter.end();
this->setPixmap(QPixmap::fromImage(image));
break;
}
case ImContact::presenceStatus::offline:
{
painter.begin(&image);
painter.setBrush(QBrush( this->getColorOffline() ));
QRectF rect = QRectF(this->rect().left(), this->rect().top(), this->width(), this->height());
painter.drawRect(rect);
painter.end();
this->setPixmap(QPixmap::fromImage(image));
break;
}
case ImContact::presenceStatus::away:
{
painter.begin(&image);
painter.setBrush(QBrush( this->getColorAway() ));
QRectF rect = QRectF(this->rect().left(), this->rect().top(), this->width(), this->height());
painter.drawRect(rect);
painter.end();
this->setPixmap(QPixmap::fromImage(image));
break;
}
default:
{
painter.begin(&image);
painter.setBrush(QBrush( QColor(Qt::blue) ));
QRectF rect = QRectF(this->rect().left(), this->rect().top(), this->width(), this->height());
painter.drawRect(rect);
painter.end();
this->setPixmap(QPixmap::fromImage(image));
}
}
}
QColor StatusLabel::getColorOnline() const
{
return colorOnline;
}
void StatusLabel::setColorOnline(const QColor &value)
{
colorOnline = value;
}
QColor StatusLabel::getColorAway() const
{
return colorAway;
}
void StatusLabel::setColorAway(const QColor &value)
{
colorAway = value;
}
QColor StatusLabel::getColorOffline() const
{
return colorOffline;
}
void StatusLabel::setColorOffline(const QColor &value)
{
colorOffline = value;
}
void StatusLabel::slGlobalSettingsChanged(QMap<QString, QVariant> globalSettings)
{
this->setColorOnline( QColor::fromRgba((unsigned)globalSettings.value("color_online").toInt()) );
this->setColorAway( QColor::fromRgba((unsigned)globalSettings.value("color_away").toInt()) );
this->setColorOffline( QColor::fromRgba((unsigned)globalSettings.value("color_offline").toInt()) );
}
#ifndef STATUSLABEL_H
#define STATUSLABEL_H
#include <QObject>
#include <QLabel>
#include <QPainter>
#include <QDebug>
#include <imcontact.h>
class StatusLabel : public QLabel
{
Q_OBJECT
public:
StatusLabel();
ImContact::presenceStatus getCurrentStatus() const;
void setCurrentStatus(const ImContact::presenceStatus &value);
QColor getColorOnline() const;
void setColorOnline(const QColor &value);
QColor getColorAway() const;
void setColorAway(const QColor &value);
QColor getColorOffline() const;
void setColorOffline(const QColor &value);
private:
ImContact::presenceStatus currentStatus;
QColor colorOnline;
QColor colorAway;
QColor colorOffline;
private slots:
void slGlobalSettingsChanged(QMap<QString, QVariant> globalSettings);
};
#endif // STATUSLABEL_H
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