⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syncpage.java

📁 java写的qq代码实现qq的部分功能
💻 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.sys;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;

import edu.tsinghua.lumaqq.Colors;
import edu.tsinghua.lumaqq.IconHolder;
import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.ui.config.AbstractPage;
import edu.tsinghua.lumaqq.ui.tool.UITool;
import edu.tsinghua.lumaqq.utils.OptionUtil;

/**
 * 同步配置页
 * 
 * @author luma
 */
public class SyncPage extends AbstractPage {
    private Button chkAutoDownloadGroup;
    private Button chkAutoDownloadFriendRemark;
    private Button rdoPromptUpload;
    private Button rdoAlwaysUpload;
    private Button rdoNeverUpload;
    
    private static final int AUTO_DOWNLOAD = 0;
    private static final int AUTO_UPLOAD = 1;
    private static final int AUTO_DOWNLOAD_FRIEND_REMARK = 2;
    
    /**
     * @param parent
     */
    public SyncPage(Composite parent) {
        super(parent);
    }

    /* (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 = 15;
        layout.verticalSpacing = 15;
        container.setLayout(layout);        

        // 设置使用缺省背景色
        UITool.setDefaultBackground(null);
        
        // 下载设置组
        layout = new GridLayout();
        layout.marginHeight = layout.marginWidth = 8;
        Group downGroup = UITool.createGroup(container, LumaQQ.getString("sys.opt.group.download.group"), layout);
        
        // 是否自动同步分组
        chkAutoDownloadGroup = UITool.createCheckbox(downGroup, LumaQQ.getString("sys.opt.sync.auto.download.group"));
        chkAutoDownloadGroup.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                makeDirty(AUTO_DOWNLOAD);
            }
        });
        
        // 是否自动下载好友备注
        chkAutoDownloadFriendRemark = UITool.createCheckbox(downGroup, LumaQQ.getString("sys.opt.sync.auto.download.friend.remark"));
        chkAutoDownloadFriendRemark.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                makeDirty(AUTO_DOWNLOAD_FRIEND_REMARK);
            }
        });
        
        // 上传设置组
        layout = new GridLayout();
        layout.marginHeight = layout.marginWidth = 8;
        Group upGroup = UITool.createGroup(container, LumaQQ.getString("sys.opt.group.upload.group"), layout);

        SelectionListener sl = new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                makeDirty(AUTO_UPLOAD);
            }
        };
        
        // prompt
        rdoPromptUpload = UITool.createRadio(upGroup, LumaQQ.getString("sys.opt.sync.prompt.upload.group"));
        rdoPromptUpload.addSelectionListener(sl);
        // always
        rdoAlwaysUpload = UITool.createRadio(upGroup, LumaQQ.getString("sys.opt.sync.always.upload.group"));
        rdoAlwaysUpload.addSelectionListener(sl);
        // never
        rdoNeverUpload = UITool.createRadio(upGroup, LumaQQ.getString("sys.opt.sync.never.upload.group"));        
        rdoNeverUpload.addSelectionListener(sl);
        
        return container;
    }

    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.ui.config.AbstractPage#saveDirtyProperty(int)
     */
    protected void saveDirtyProperty(int propertyId) {
        OptionUtil options = OptionUtil.getInstance();
        
        switch(propertyId) {
            case AUTO_DOWNLOAD:
				options.setAutoDownloadGroup(chkAutoDownloadGroup.getSelection());
				break;
			case AUTO_UPLOAD:
			    if(rdoAlwaysUpload.getSelection())
			        options.setAutoUploadGroup(OptionUtil.ALWAYS);
			    else if(rdoNeverUpload.getSelection())
			        options.setAutoUploadGroup(OptionUtil.NEVER);
			    else
			        options.setAutoUploadGroup(OptionUtil.PROMPT);
			    break;
			case AUTO_DOWNLOAD_FRIEND_REMARK:
			    options.setAutoDownloadFriendRemark(chkAutoDownloadFriendRemark.getSelection());
			    break;
        }
    }

    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.ui.config.AbstractPage#initializeValues()
     */
    protected void initializeValues() {
		OptionUtil options = OptionUtil.getInstance();
		chkAutoDownloadGroup.setSelection(options.isAutoDownloadGroup());
		String s = options.getAutoUploadGroup();
		if(s == OptionUtil.ALWAYS)
		    rdoAlwaysUpload.setSelection(true);
		else if(s == OptionUtil.NEVER)
		    rdoNeverUpload.setSelection(true);
		else
		    rdoPromptUpload.setSelection(true);
    }

    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.ui.config.AbstractPage#getImage()
     */
    protected Image getImage() {
        return IconHolder.getInstance().getImage(IconHolder.icoSysOpt24);
    }

    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.ui.config.AbstractPage#getTitle()
     */
    protected String getTitle(int page) {
        return LumaQQ.getString("sys.opt.button.sync");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -