📄 friendpropertylistener.java
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.events;
import org.eclipse.swt.SWT;
import edu.tsinghua.lumaqq.models.FriendModel;
import edu.tsinghua.lumaqq.shells.*;
import edu.tsinghua.lumaqq.utils.OptionUtils;
import edu.tsinghua.swt.events.PropertyEvent;
import edu.tsinghua.swt.events.PropertyListener;
import edu.tsinghua.swt.widgets.ShutterLabel;
/**
* 监视好友的属性,比如好友的状态改变了等等,做出相应的处理
*
* @author 马若劼
*/
public class FriendPropertyListener implements PropertyListener {
private MainShell main;
/**
* 构造函数
* @param main
*/
public FriendPropertyListener(MainShell main) {
this.main = main;
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.PropertyListener#propertyAdded(edu.tsinghua.swt.events.PropertyEvent)
*/
public void propertyAdded(PropertyEvent e) {
// 没有什么要做的
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.PropertyListener#propertyRemoved(edu.tsinghua.swt.events.PropertyEvent)
*/
public void propertyRemoved(PropertyEvent e) {
// 没有什么要做的
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.PropertyListener#propertyModified(edu.tsinghua.swt.events.PropertyEvent)
*/
public void propertyModified(PropertyEvent e) {
/*
* 如果一个属性改变了,那么我们就要判断是不是上线状态改变了,如果是,需要设置不同的头像
* 注意这里的属性也可能是tab的属性,所有control可能为null,对于这种情况我们直接返回
*/
// 如果不是status属性变了,那我们不关心
if(e.key.equals("status")) {
// 首先我们得到相关的ShutterLabel对象
FriendModel f = (FriendModel)e.getSource();
ShutterLabel control = main.shutter.getItemControl(f);
if(control == null) return;
// 判断是否会员
boolean member = f.isMember();
// 设置头像
control.setImage(main.getFaceByStatus(f));
// 开始判断状态
if(e.newValue.equals("online")) {
if(member)
control.setForeground(main.display.getSystemColor(SWT.COLOR_RED));
else
control.setForeground(main.display.getSystemColor(SWT.COLOR_BLACK));
// 如果当前处于只显示在线好友模式,则显示这个好友的view part
if(OptionUtils.getInstance().isShowOnlineOnly()) {
int[] temp = main.getFriendCoordinate(f.getQQ());
if(temp != null && temp.length > 0) {
main.shutter.showItem(temp[0], temp[1], true);
}
}
} else if(e.newValue.equals("away")) {
control.setForeground(main.display.getSystemColor(SWT.COLOR_BLUE));
// 如果当前处于只显示在线好友模式,则显示这个好友的view part
if(OptionUtils.getInstance().isShowOnlineOnly()) {
int[] temp = main.getFriendCoordinate(f.getQQ());
if(temp != null && temp.length > 0) {
main.shutter.showItem(temp[0], temp[1], true);
}
}
} else {
control.setForeground(main.display.getSystemColor(SWT.COLOR_BLACK));
// 如果当前处于只显示在线好友模式,则要隐藏这个好友的view part
if(OptionUtils.getInstance().isShowOnlineOnly()) {
int[] temp = main.getFriendCoordinate(f.getQQ());
if(temp != null && temp.length > 0)
main.shutter.hideItem(temp[0], temp[1], true);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -