📄 qqshowpage.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.ui.config.user;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import edu.tsinghua.lumaqq.Colors;
import edu.tsinghua.lumaqq.IconHolder;
import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.models.FriendModel;
import edu.tsinghua.lumaqq.ui.MainShell;
import edu.tsinghua.lumaqq.ui.config.AbstractPage;
import edu.tsinghua.lumaqq.ui.tool.AroundBorderPaintListener;
import edu.tsinghua.lumaqq.ui.tool.UITool;
/**
* QQ秀页
*
* @author luma
*/
public class QQShowPage extends AbstractPage {
private Label lblQQShow;
private MainShell main;
private Cursor handCursor;
private FriendModel model;
/**
* @param parent
*/
public QQShowPage(Composite parent, MainShell main, FriendModel model, int style) {
super(parent, style);
this.main = main;
this.model = model;
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.shells.AbstractPage#setModel(java.lang.Object)
*/
public void setModel(Object model) {
if(model instanceof FriendModel)
this.model = (FriendModel)model;
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.shells.AbstractPage#initialVariable()
*/
protected void initialVariable() {
handCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.ui.config.AbstractPage#createContent(org.eclipse.swt.widgets.Composite)
*/
protected Control createContent(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setBackground(Colors.PAGE_BACKGROUND);
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = 10;
container.setLayout(layout);
// 设置使用缺省背景色
UITool.setDefaultBackground(null);
// QQ秀组
layout = new GridLayout(2, false);
layout.marginHeight = layout.marginWidth = layout.horizontalSpacing = 15;
Group qqshowGroup = UITool.createGroup(container, LumaQQ.getString("user.info.group.qqshow"), layout);
qqshowGroup.addPaintListener(new AroundBorderPaintListener(new Class[] { Label.class }));
MouseListener ml = new MouseAdapter() {
public void mouseDown(MouseEvent e) {
main.getShellLauncher().goQQShowMall();
}
};
// QQ秀,QQ秀大小是140x226
GridData gd = new GridData();
gd.widthHint = 142;
gd.heightHint = 228;
lblQQShow = UITool.createLabel(qqshowGroup, "", gd, SWT.CENTER);
lblQQShow.setCursor(handCursor);
lblQQShow.addMouseListener(ml);
layout = new GridLayout();
layout.verticalSpacing = 15;
Composite c = UITool.createContainer(qqshowGroup, new GridData(GridData.VERTICAL_ALIGN_BEGINNING), layout);
// 刷新QQ秀
gd = new GridData(GridData.VERTICAL_ALIGN_END);
CLabel lblRefreshQQShow = UITool.createLink(c, LumaQQ.getString("user.info.label.refresh.qqshow"), IconHolder.getInstance().getImage(IconHolder.icoRefresh), gd);
lblRefreshQQShow.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
// 这里暂时去掉QQ Show的检查,目前的检查代码感觉并不正确,不启用
// if(hasQQShow()) {
setQQShow(IconHolder.getInstance().getImage(IconHolder.bmpDownloading));
main.getQQShowManager().downloadQQShowImage(model.getQQ());
/* } else
MessageDialog.openInformation(parentShell, LumaQQ.getString("message.box.common.info.title"), LumaQQ.getString("message.box.no.qqshow"));*/
}
});
if(style == UserInfoWindow.EDITABLE) {
// 去QQ秀商城
CLabel lblQQShowMall = UITool.createLink(c, LumaQQ.getString("user.info.label.go.qqshow.mall"), IconHolder.getInstance().getImage(IconHolder.icoQQShowMall));
lblQQShowMall.addMouseListener(ml);
// 更换QQ秀
CLabel lblChangeQQShow = UITool.createLink(c, LumaQQ.getString("user.info.label.change.qqshow"), IconHolder.getInstance().getImage(IconHolder.icoChangeQQShow));
lblChangeQQShow.addMouseListener(ml);
// QQ家园
CLabel lblQQHome = UITool.createLink(c, LumaQQ.getString("user.info.label.qqshow.home"), IconHolder.getInstance().getImage(IconHolder.icoQQHome));
lblQQHome.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
main.getShellLauncher().goQQHome();
}
});
}
return container;
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.shells.AbstractPage#saveDirtyProperty(int)
*/
protected void saveDirtyProperty(int propertyId) {
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.shells.AbstractPage#initializeValues()
*/
protected void initializeValues() {
// QQ秀
if(main.getQQShowManager().isCached(model.getQQ()))
lblQQShow.setImage(main.getQQShowManager().getQQShowImage(model.getQQ()));
else
lblQQShow.setImage(IconHolder.getInstance().getImage(IconHolder.bmpDefaultQQShow));
lblQQShow.redraw();
}
/**
* 设置QQ秀
*
* @param image
*/
protected void setQQShow(Image image) {
lblQQShow.setImage(image);
lblQQShow.redraw();
}
/**
* @return true如果好友有QQ秀,false如果没有QQ秀
*/
/*private boolean hasQQShow() {
ContactInfo info = (ContactInfo)model.getProperty(IQQNode.CONTACT);
if(info == null)
return false;
if(info.infos[info.qqShow].equals("0") || info.infos[info.qqShow].equals(""))
return false;
else
return true;
}*/
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.shells.AbstractPage#getImage()
*/
protected Image getImage() {
if(style == UserInfoWindow.EDITABLE)
return IconHolder.getInstance().getImage(IconHolder.icoModifyPersonInfo24);
else
return IconHolder.getInstance().getImage(IconHolder.icoViewPersonInfo24);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.shells.AbstractPage#getTitle()
*/
protected String getTitle(int page) {
return LumaQQ.getString("user.info.page.qqshow");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -