📄 aboutdialog.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.shells;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import edu.tsinghua.lumaqq.IconHolder;
import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.swt.widgets.MySWT;
import edu.tsinghua.swt.widgets.ShutterLabel;
/**
* 关于对话框
*
* @author 马若劼
*/
public class AboutDialog extends Dialog {
private IconHolder icons = IconHolder.getInstance();
private ShutterLabel btnPhoto;
/**
* @param parent
*/
public AboutDialog(Shell parent) {
super(parent);
}
/**
* @param parent
* @param style
*/
public AboutDialog(Shell parent, int style) {
super(parent, style);
}
/**
* 打开对话框
*/
public void open() {
// create dialog
Shell parent = getParent();
Display display = parent.getDisplay();
Shell dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.MIN);
// init child controls
initLayout(dialog);
// set title and image
dialog.setImage(icons.getResource(IconHolder.icoQQ));
dialog.setText(LumaQQ.getResourceString("about.title"));
// set dialog to center of screen
Rectangle dialogRect = dialog.getBounds();
Rectangle displayRect = display.getBounds();
dialog.setLocation((displayRect.width-dialogRect.width)/2, (displayRect.height-dialogRect.height)/2);
// event loop
dialog.pack();
dialog.open();
while(!dialog.isDisposed())
if(!display.readAndDispatch())
display.sleep();
}
/**
* @param dialog
*/
private void initLayout(final Shell dialog) {
dialog.setLayout(new GridLayout());
// photo
btnPhoto = new ShutterLabel(dialog, MySWT.FLAT | MySWT.NO_ZOOM | MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("about.text"), icons.getResource(IconHolder.icoQQ));
btnPhoto.setTextOrientation(SWT.BOTTOM);
btnPhoto.setMouseTrackColor(dialog.getDisplay().getSystemColor(SWT.COLOR_BLUE));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
btnPhoto.setLayoutData(gd);
btnPhoto.addMouseListener(
new MouseAdapter() {
public void mouseUp(MouseEvent e) {
if((e.stateMask & SWT.CTRL) != 0) {
btnPhoto.setImage(icons.getResource(IconHolder.icoMe));
dialog.layout();
dialog.pack();
}
}
}
);
// close button
Button btnClose = new Button(dialog, SWT.PUSH);
btnClose.setText(LumaQQ.getResourceString("about.button.close"));
gd = new GridData();
gd.horizontalAlignment = GridData.CENTER;
btnClose.setLayoutData(gd);
btnClose.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
dialog.close();
}
}
);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -