mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
- added new status menu to tray menu
- moved internal status functions from MessengerWindow to MainWindow - cleaned some includes git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3300 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d92e1911eb
commit
8f5fe8bae2
6 changed files with 252 additions and 158 deletions
|
@ -19,9 +19,7 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QtGui>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSystemTrayIcon>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
@ -51,10 +49,12 @@
|
||||||
#include "QuickStartWizard.h"
|
#include "QuickStartWizard.h"
|
||||||
|
|
||||||
#include "gui/TurtleRouterDialog.h"
|
#include "gui/TurtleRouterDialog.h"
|
||||||
|
#include "idle/idle.h"
|
||||||
|
|
||||||
#include "statusbar/peerstatus.h"
|
#include "statusbar/peerstatus.h"
|
||||||
#include "statusbar/natstatus.h"
|
#include "statusbar/natstatus.h"
|
||||||
#include "statusbar/ratesstatus.h"
|
#include "statusbar/ratesstatus.h"
|
||||||
|
#include "rsiface/rsstatus.h"
|
||||||
|
|
||||||
#include "rsiface/rsiface.h"
|
#include "rsiface/rsiface.h"
|
||||||
#include "rsiface/rspeers.h"
|
#include "rsiface/rspeers.h"
|
||||||
|
@ -115,19 +115,30 @@
|
||||||
/*static*/ MainWindow *MainWindow::Create ()
|
/*static*/ MainWindow *MainWindow::Create ()
|
||||||
{
|
{
|
||||||
if (_instance == NULL) {
|
if (_instance == NULL) {
|
||||||
_instance = new MainWindow ();
|
/* _instance is set in constructor */
|
||||||
|
new MainWindow ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ MainWindow *MainWindow::getInstance()
|
||||||
|
{
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
: RWindow("MainWindow", parent, flags)
|
: RWindow("MainWindow", parent, flags), maxTimeBeforeIdle(30)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated QObject setup routine */
|
/* Invoke the Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
_instance = this;
|
||||||
|
|
||||||
|
m_bStatusLoadDone = false;
|
||||||
|
isIdle = false;
|
||||||
|
|
||||||
if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool())
|
if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool())
|
||||||
{
|
{
|
||||||
Settings->setValue(QString::fromUtf8("FirstRun"), false);
|
Settings->setValue(QString::fromUtf8("FirstRun"), false);
|
||||||
|
@ -273,8 +284,11 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
/* Creates a tray icon with a context menu and adds it to the system's * notification area. */
|
/* Creates a tray icon with a context menu and adds it to the system's * notification area. */
|
||||||
createTrayIcon();
|
createTrayIcon();
|
||||||
|
|
||||||
|
loadOwnStatus(); // hack; placed in constructor to preempt sendstatus, so status loaded from file
|
||||||
|
|
||||||
idle = new Idle();
|
idle = new Idle();
|
||||||
idle->start();
|
idle->start();
|
||||||
|
connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||||
|
@ -327,6 +341,11 @@ void MainWindow::createTrayIcon()
|
||||||
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||||
toggleVisibilityAction =
|
toggleVisibilityAction =
|
||||||
trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
||||||
|
|
||||||
|
QMenu *pStatusMenu = trayMenu->addMenu(tr("Status"));
|
||||||
|
initializeStatusObject(pStatusMenu);
|
||||||
|
connect(pStatusMenu, SIGNAL(triggered (QAction*)), this, SLOT(statusChanged(QAction*)));
|
||||||
|
|
||||||
trayMenu->addSeparator();
|
trayMenu->addSeparator();
|
||||||
trayMenu->addAction(_messengerwindowAct);
|
trayMenu->addAction(_messengerwindowAct);
|
||||||
trayMenu->addAction(_messagesAct);
|
trayMenu->addAction(_messagesAct);
|
||||||
|
@ -802,4 +821,182 @@ void MainWindow::setStyle()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get own status */
|
||||||
|
static int getOwnStatus()
|
||||||
|
{
|
||||||
|
std::string ownId = rsPeers->getOwnId();
|
||||||
|
|
||||||
|
StatusInfo si;
|
||||||
|
std::list<StatusInfo> statusList;
|
||||||
|
std::list<StatusInfo>::iterator it;
|
||||||
|
|
||||||
|
if (!rsStatus->getStatus(statusList)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (it = statusList.begin(); it != statusList.end(); it++){
|
||||||
|
if (it->id == ownId)
|
||||||
|
return it->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set status object to status value */
|
||||||
|
static void setStatusObject(QObject *pObject, int nStatus)
|
||||||
|
{
|
||||||
|
QMenu *pMenu = dynamic_cast<QMenu*>(pObject);
|
||||||
|
if (pMenu) {
|
||||||
|
/* set action in menu */
|
||||||
|
foreach(QObject *pObject, pMenu->children()) {
|
||||||
|
QAction *pAction = qobject_cast<QAction*> (pObject);
|
||||||
|
if (pAction == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pAction->data().toInt() == nStatus) {
|
||||||
|
pAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
|
||||||
|
if (pComboBox) {
|
||||||
|
/* set index of combobox */
|
||||||
|
int nIndex = pComboBox->findData(nStatus, Qt::UserRole);
|
||||||
|
if (nIndex != -1) {
|
||||||
|
pComboBox->setCurrentIndex(nIndex);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add more objects here */
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load own status Online,Away,Busy **/
|
||||||
|
void MainWindow::loadOwnStatus()
|
||||||
|
{
|
||||||
|
m_bStatusLoadDone = true;
|
||||||
|
|
||||||
|
int nStatus = getOwnStatus();
|
||||||
|
|
||||||
|
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {
|
||||||
|
setStatusObject(*it, nStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::checkAndSetIdle(int idleTime)
|
||||||
|
{
|
||||||
|
if ((idleTime >= (int) maxTimeBeforeIdle) && !isIdle) {
|
||||||
|
setIdle(true);
|
||||||
|
}else
|
||||||
|
if((idleTime < (int) maxTimeBeforeIdle) && isIdle) {
|
||||||
|
setIdle(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setIdle(bool idle)
|
||||||
|
{
|
||||||
|
isIdle = idle;
|
||||||
|
setStatus(NULL, getOwnStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add and initialize status object */
|
||||||
|
void MainWindow::initializeStatusObject(QObject *pObject)
|
||||||
|
{
|
||||||
|
if (m_apStatusObjects.find(pObject) != m_apStatusObjects.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_apStatusObjects.insert(m_apStatusObjects.end(), pObject);
|
||||||
|
|
||||||
|
QMenu *pMenu = dynamic_cast<QMenu*>(pObject);
|
||||||
|
if (pMenu) {
|
||||||
|
/* initialize menu */
|
||||||
|
QActionGroup *pGroup = new QActionGroup(pMenu);
|
||||||
|
|
||||||
|
QAction *pAction = new QAction(QIcon(":/images/im-user.png"), tr("Online"), pMenu);
|
||||||
|
pAction->setData(RS_STATUS_ONLINE);
|
||||||
|
pAction->setCheckable(true);
|
||||||
|
pMenu->addAction(pAction);
|
||||||
|
pGroup->addAction(pAction);
|
||||||
|
|
||||||
|
pAction = new QAction(QIcon(":/images/im-user-busy.png"), tr("Busy"), pMenu);
|
||||||
|
pAction->setData(RS_STATUS_BUSY);
|
||||||
|
pAction->setCheckable(true);
|
||||||
|
pMenu->addAction(pAction);
|
||||||
|
pGroup->addAction(pAction);
|
||||||
|
|
||||||
|
pAction = new QAction(QIcon(":/images/im-user-away.png"), tr("Away"), pMenu);
|
||||||
|
pAction->setData(RS_STATUS_AWAY);
|
||||||
|
pAction->setCheckable(true);
|
||||||
|
pMenu->addAction(pAction);
|
||||||
|
pGroup->addAction(pAction);
|
||||||
|
} else {
|
||||||
|
/* initialize combobox */
|
||||||
|
QComboBox *pComboBox = dynamic_cast<QComboBox*>(pObject);
|
||||||
|
if (pComboBox) {
|
||||||
|
pComboBox->addItem(QIcon(":/images/im-user.png"), tr("Online"), RS_STATUS_ONLINE);
|
||||||
|
pComboBox->addItem(QIcon(":/images/im-user-busy.png"), tr("Busy"), RS_STATUS_BUSY);
|
||||||
|
pComboBox->addItem(QIcon(":/images/im-user-away.png"), tr("Away"), RS_STATUS_AWAY);
|
||||||
|
}
|
||||||
|
/* add more objects here */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bStatusLoadDone) {
|
||||||
|
/* loadOwnStatus done, set own status directly */
|
||||||
|
int nStatus = getOwnStatus();
|
||||||
|
if (nStatus != -1) {
|
||||||
|
setStatusObject(pObject, nStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove status object */
|
||||||
|
void MainWindow::removeStatusObject(QObject *pObject)
|
||||||
|
{
|
||||||
|
m_apStatusObjects.erase(pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save own status Online,Away,Busy **/
|
||||||
|
void MainWindow::setStatus(QObject *pObject, int nStatus)
|
||||||
|
{
|
||||||
|
RsPeerDetails detail;
|
||||||
|
std::string ownId = rsPeers->getOwnId();
|
||||||
|
|
||||||
|
if (!rsPeers->getPeerDetails(ownId, detail)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusInfo si;
|
||||||
|
|
||||||
|
if (isIdle && nStatus == (int) RS_STATUS_ONLINE) {
|
||||||
|
/* set idle state only when I am in online state */
|
||||||
|
nStatus = RS_STATUS_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
si.id = ownId;
|
||||||
|
si.status = nStatus;
|
||||||
|
|
||||||
|
rsStatus->sendStatus(si);
|
||||||
|
|
||||||
|
/* set status in all status objects, but the calling one */
|
||||||
|
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {
|
||||||
|
if (*it != pObject) {
|
||||||
|
setStatusObject(*it, nStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* new status from context menu */
|
||||||
|
void MainWindow::statusChanged(QAction *pAction)
|
||||||
|
{
|
||||||
|
if (pAction == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatus(pAction->parent(), pAction->data().toInt());
|
||||||
|
}
|
||||||
|
|
|
@ -22,10 +22,8 @@
|
||||||
#ifndef _MainWindow_H
|
#ifndef _MainWindow_H
|
||||||
#define _MainWindow_H
|
#define _MainWindow_H
|
||||||
|
|
||||||
#include <QtGui>
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#ifdef UNFINISHED
|
#ifdef UNFINISHED
|
||||||
#include "unfinished/ApplicationWindow.h"
|
#include "unfinished/ApplicationWindow.h"
|
||||||
|
@ -38,8 +36,8 @@
|
||||||
|
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
#include "gui/common/rwindow.h"
|
#include "gui/common/rwindow.h"
|
||||||
#include "idle/idle.h"
|
|
||||||
|
|
||||||
|
class Idle;
|
||||||
class PeerStatus;
|
class PeerStatus;
|
||||||
class NATStatus;
|
class NATStatus;
|
||||||
class RatesStatus;
|
class RatesStatus;
|
||||||
|
@ -88,6 +86,7 @@ public:
|
||||||
|
|
||||||
/** Create main window */
|
/** Create main window */
|
||||||
static MainWindow *Create ();
|
static MainWindow *Create ();
|
||||||
|
static MainWindow *getInstance();
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
@ -133,11 +132,17 @@ public:
|
||||||
|
|
||||||
static void installGroupChatNotifier();
|
static void installGroupChatNotifier();
|
||||||
|
|
||||||
|
/* initialize widget with status informations, status constant stored in data or in Qt::UserRole */
|
||||||
|
void initializeStatusObject(QObject *pObject);
|
||||||
|
void removeStatusObject(QObject *pObject);
|
||||||
|
void setStatus(QObject *pObject, int nStatus);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateHashingInfo(const QString&) ;
|
void updateHashingInfo(const QString&) ;
|
||||||
void displayErrorMessage(int,int,const QString&) ;
|
void displayErrorMessage(int,int,const QString&) ;
|
||||||
void postModDirectories(bool update_local);
|
void postModDirectories(bool update_local);
|
||||||
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
||||||
|
void checkAndSetIdle(int idleTime);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
|
@ -177,6 +182,7 @@ private slots:
|
||||||
void showMess();
|
void showMess();
|
||||||
void showSettings();
|
void showSettings();
|
||||||
void setStyle();
|
void setStyle();
|
||||||
|
void statusChanged(QAction *pAction);
|
||||||
|
|
||||||
/** Called when user attempts to quit via quit button*/
|
/** Called when user attempts to quit via quit button*/
|
||||||
void doQuit();
|
void doQuit();
|
||||||
|
@ -223,8 +229,19 @@ private:
|
||||||
RatesStatus *ratesstatus;
|
RatesStatus *ratesstatus;
|
||||||
|
|
||||||
QLabel *_hashing_info_label ;
|
QLabel *_hashing_info_label ;
|
||||||
|
|
||||||
QAction *messageAction ;
|
QAction *messageAction ;
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
std::set <QObject*> m_apStatusObjects; // added objects for status
|
||||||
|
bool m_bStatusLoadDone;
|
||||||
|
|
||||||
|
void loadOwnStatus();
|
||||||
|
|
||||||
|
// idle function
|
||||||
|
void setIdle(bool Idle);
|
||||||
|
bool isIdle;
|
||||||
|
const unsigned long maxTimeBeforeIdle;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::MainWindow ui;
|
Ui::MainWindow ui;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
#include "MessengerWindow.h"
|
#include "MessengerWindow.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
|
||||||
#include "chat/PopupChatDialog.h"
|
#include "chat/PopupChatDialog.h"
|
||||||
|
@ -131,7 +132,7 @@ void MessengerWindow::releaseInstance()
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
: RWindow("MessengerWindow", parent, flags), maxTimeBeforeIdle(30)
|
: RWindow("MessengerWindow", parent, flags)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -147,6 +148,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||||
|
|
||||||
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
|
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
|
||||||
|
connect(ui.statuscomboBox, SIGNAL(activated(int)), this, SLOT(statusChanged(int)));
|
||||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
|
@ -187,8 +189,10 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
// load settings
|
// load settings
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
|
||||||
isIdle = false;
|
MainWindow *pMainWindow = MainWindow::getInstance();
|
||||||
loadOwnStatus(); // hack; placed in constructor to preempt sendstatus, so status loaded from file
|
if (pMainWindow) {
|
||||||
|
pMainWindow->initializeStatusObject(ui.statuscomboBox);
|
||||||
|
}
|
||||||
insertPeers();
|
insertPeers();
|
||||||
updateAvatar();
|
updateAvatar();
|
||||||
loadmystatusmessage();
|
loadmystatusmessage();
|
||||||
|
@ -206,6 +210,11 @@ MessengerWindow::~MessengerWindow ()
|
||||||
{
|
{
|
||||||
// save settings
|
// save settings
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
||||||
|
MainWindow *pMainWindow = MainWindow::getInstance();
|
||||||
|
if (pMainWindow) {
|
||||||
|
pMainWindow->removeStatusObject(ui.statuscomboBox);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessengerWindow::processSettings(bool bLoad)
|
void MessengerWindow::processSettings(bool bLoad)
|
||||||
|
@ -367,7 +376,6 @@ void MessengerWindow::updateMessengerDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
insertPeers();
|
insertPeers();
|
||||||
savestatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the list of peers from the RsIface. */
|
/* get the list of peers from the RsIface. */
|
||||||
|
@ -973,13 +981,25 @@ void MessengerWindow::loadmystatusmessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Save own status message */
|
/** Save own status message */
|
||||||
void MessengerWindow::savestatusmessage()
|
void MessengerWindow::savestatusmessage()
|
||||||
{
|
{
|
||||||
Settings->setValueToGroup("Profile", "StatusMessage",ui.messagelineEdit->text());
|
Settings->setValueToGroup("Profile", "StatusMessage",ui.messagelineEdit->text());
|
||||||
|
|
||||||
rsMsgs->setCustomStateString(ui.messagelineEdit->text().toStdString());
|
rsMsgs->setCustomStateString(ui.messagelineEdit->text().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessengerWindow::statusChanged(int index)
|
||||||
|
{
|
||||||
|
if (index < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow *pMainWindow = MainWindow::getInstance();
|
||||||
|
if (pMainWindow) {
|
||||||
|
pMainWindow->setStatus(ui.statuscomboBox, ui.statuscomboBox->itemData(index, Qt::UserRole).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessengerWindow::on_actionSort_Peers_Descending_Order_activated()
|
void MessengerWindow::on_actionSort_Peers_Descending_Order_activated()
|
||||||
{
|
{
|
||||||
ui.messengertreeWidget->sortItems ( COLUMN_NAME, Qt::DescendingOrder );
|
ui.messengertreeWidget->sortItems ( COLUMN_NAME, Qt::DescendingOrder );
|
||||||
|
@ -1007,110 +1027,6 @@ void MessengerWindow::displayMenu()
|
||||||
ui.displaypushButton->setMenu(lookmenu);
|
ui.displaypushButton->setMenu(lookmenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load own status Online,Away,Busy **/
|
|
||||||
void MessengerWindow::loadOwnStatus()
|
|
||||||
{
|
|
||||||
|
|
||||||
std::string ownId = rsPeers->getOwnId();
|
|
||||||
|
|
||||||
StatusInfo si;
|
|
||||||
std::list<StatusInfo> statusList;
|
|
||||||
std::list<StatusInfo>::iterator it;
|
|
||||||
|
|
||||||
if (!rsStatus->getStatus(statusList))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(it=statusList.begin(); it != statusList.end(); it++){
|
|
||||||
if(it->id == ownId)
|
|
||||||
si = *it;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* set status mode */
|
|
||||||
int statusIndex = 0;
|
|
||||||
switch(si.status)
|
|
||||||
{
|
|
||||||
case RS_STATUS_AWAY:
|
|
||||||
statusIndex = 2;
|
|
||||||
break;
|
|
||||||
case RS_STATUS_BUSY:
|
|
||||||
statusIndex = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case RS_STATUS_ONLINE:
|
|
||||||
statusIndex = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.statuscomboBox->setCurrentIndex(statusIndex);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Save own status Online,Away,Busy **/
|
|
||||||
void MessengerWindow::savestatus()
|
|
||||||
{
|
|
||||||
|
|
||||||
RsPeerDetails detail;
|
|
||||||
std::string ownId = rsPeers->getOwnId();
|
|
||||||
|
|
||||||
if (!rsPeers->getPeerDetails(ownId, detail))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusInfo si;
|
|
||||||
int statusIndex;
|
|
||||||
|
|
||||||
if(!isIdle)
|
|
||||||
statusIndex = ui.statuscomboBox->currentIndex();
|
|
||||||
else
|
|
||||||
statusIndex = 3;
|
|
||||||
|
|
||||||
/* Check if status has changed */
|
|
||||||
int status = 0;
|
|
||||||
switch(statusIndex)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
status = RS_STATUS_INACTIVE;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
status = RS_STATUS_AWAY;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
status = RS_STATUS_BUSY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case 0:
|
|
||||||
status = RS_STATUS_ONLINE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
si.id = ownId;
|
|
||||||
si.status = status;
|
|
||||||
|
|
||||||
rsStatus->sendStatus(si);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessengerWindow::checkAndSetIdle(int idleTime){
|
|
||||||
|
|
||||||
if((idleTime >= (int) maxTimeBeforeIdle) && !isIdle){
|
|
||||||
setIdle(true);
|
|
||||||
}else
|
|
||||||
if((idleTime < (int) maxTimeBeforeIdle) && isIdle){
|
|
||||||
setIdle(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessengerWindow::setIdle(bool idle){
|
|
||||||
isIdle = idle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clear Filter */
|
/* clear Filter */
|
||||||
void MessengerWindow::clearFilter()
|
void MessengerWindow::clearFilter()
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,8 +47,6 @@ public slots:
|
||||||
void updatePeersAvatar(const QString& peer_id);
|
void updatePeersAvatar(const QString& peer_id);
|
||||||
void updateAvatar();
|
void updateAvatar();
|
||||||
void loadmystatusmessage();
|
void loadmystatusmessage();
|
||||||
void loadOwnStatus();
|
|
||||||
void checkAndSetIdle(int idleTime);
|
|
||||||
|
|
||||||
LogoBar & getLogoBar() const;
|
LogoBar & getLogoBar() const;
|
||||||
|
|
||||||
|
@ -91,6 +89,7 @@ private slots:
|
||||||
|
|
||||||
void changeAvatarClicked();
|
void changeAvatarClicked();
|
||||||
|
|
||||||
|
void statusChanged(int index);
|
||||||
void savestatusmessage();
|
void savestatusmessage();
|
||||||
|
|
||||||
void on_actionSort_Peers_Descending_Order_activated();
|
void on_actionSort_Peers_Descending_Order_activated();
|
||||||
|
@ -115,12 +114,7 @@ private:
|
||||||
|
|
||||||
/* (2) Utility Fns */
|
/* (2) Utility Fns */
|
||||||
QTreeWidgetItem *getCurrentPeer();
|
QTreeWidgetItem *getCurrentPeer();
|
||||||
void savestatus();
|
|
||||||
void insertPeers();
|
void insertPeers();
|
||||||
// idle function
|
|
||||||
void setIdle(bool Idle);
|
|
||||||
bool isIdle;
|
|
||||||
const unsigned long maxTimeBeforeIdle;
|
|
||||||
|
|
||||||
void FilterItems();
|
void FilterItems();
|
||||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
|
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
|
||||||
|
|
|
@ -125,33 +125,6 @@ p, li { white-space: pre-wrap; }
|
||||||
<property name="modelColumn">
|
<property name="modelColumn">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Online</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="images.qrc">
|
|
||||||
<normaloff>:/images/im-user.png</normaloff>:/images/im-user.png</iconset>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Busy</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="images.qrc">
|
|
||||||
<normaloff>:/images/im-user-busy.png</normaloff>:/images/im-user-busy.png</iconset>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Away</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="images.qrc">
|
|
||||||
<normaloff>:/images/im-user-away.png</normaloff>:/images/im-user-away.png</iconset>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QtGui>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <rshare.h>
|
#include <rshare.h>
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
@ -34,6 +33,7 @@
|
||||||
#include "gui/GenCertDialog.h"
|
#include "gui/GenCertDialog.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
#include "gui/connect/ConfCertDialog.h"
|
#include "gui/connect/ConfCertDialog.h"
|
||||||
|
#include "idle/idle.h"
|
||||||
|
|
||||||
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
||||||
#include <gui/qskinobject/qskinobject.h>
|
#include <gui/qskinobject/qskinobject.h>
|
||||||
|
@ -194,12 +194,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
w->installGroupChatNotifier();
|
w->installGroupChatNotifier();
|
||||||
|
|
||||||
QObject::connect(w->idle, SIGNAL(secondsIdle(int)), w->messengerWindow, SLOT(checkAndSetIdle(int)));
|
|
||||||
|
|
||||||
/* only show window, if not startMinimized */
|
/* only show window, if not startMinimized */
|
||||||
if(!Settings->value(QString::fromUtf8("StartMinimized"), false).toBool())
|
if(!Settings->value(QString::fromUtf8("StartMinimized"), false).toBool())
|
||||||
{
|
{
|
||||||
|
|
||||||
w->show();
|
w->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue