Esempio n. 1
0
void MainMenu::createActions()
{
	//创建菜单项
	action_setting = new QAction(this);
	action_new_character = new QAction(this);
	action_check_update = new QAction(this);
	action_change_company = new QAction(this);
	action_help_online = new QAction(this);
	action_platform_help = new QAction(this);
	action_login_home = new QAction(this);
	action_protect = new QAction(this);
	action_about_us = new QAction(this);

	action_about_us->setIcon(QIcon(":/mainMenu/about"));
	action_help_online->setIcon(QIcon(":/mainMenu/help"));
	action_check_update->setIcon(QIcon(":/mainMenu/update"));
	action_setting->setIcon(QIcon(":/mainMenu/setting"));

	//添加菜单项
	this->addAction(action_setting);
	this->addAction(action_new_character);
	this->addAction(action_check_update);
	this->addAction(action_change_company);
	this->addSeparator();
	this->addAction(action_help_online);
	this->addAction(action_platform_help);
	this->addAction(action_login_home);
	this->addAction(action_protect);
	this->addAction(action_about_us);

	//设置信号连接
	QObject::connect(action_setting, SIGNAL(triggered()), this, SIGNAL(showSettingDialog()));
	QObject::connect(action_new_character, SIGNAL(triggered()), this, SIGNAL(showNewCharacter()));
	QObject::connect(action_about_us, SIGNAL(triggered()), this, SIGNAL(showAboutUs()));
}
Esempio n. 2
0
MainWidget::MainWidget(QWidget *parent)
    : DropShadowWidget(parent)
{
	initLocalConnection();
    setMinimumSize(900, 600);
	setWindowIcon(QIcon(":/img/safe"));

	statked_widget = new QStackedWidget();
    title_widget = new TitleWidget();
    content_widget = new ContentWidget();
	kill_mummy_widget = new KillMummyWidget();
	main_menu = new MainMenu();
	character_widget = new CharacterWidget();
	about_us_dialog = new AboutUsDialog(this);
	setting_dialog = new SettingDialog(this);
	login_dialog = new LoginDialog(this);
	register_widget = new RegisterWidget(this); 
	skin_widget = new SkinWidget(this);
	system_tray = new SystemTray(this);

	QPalette palette;
	palette.setBrush(QPalette::Window, QBrush(Qt::white));
    statked_widget->setPalette(palette);
    statked_widget->setAutoFillBackground(true);

	statked_widget->addWidget(content_widget);
	statked_widget->addWidget(kill_mummy_widget);

	QVBoxLayout *center_layout = new QVBoxLayout();
	center_layout->addWidget(statked_widget);
	center_layout->setSpacing(0);
	center_layout->setContentsMargins(0, 0, 0, 0);

    QVBoxLayout *main_layout = new QVBoxLayout();
    main_layout->addWidget(title_widget);
    main_layout->addLayout(center_layout);
	main_layout->setSpacing(0);
	main_layout->setContentsMargins(SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH);

    setLayout(main_layout);

	connect(title_widget, SIGNAL(showSkin()), this, SLOT(showSkinWidget()));
	connect(title_widget, SIGNAL(showMainMenu()), this, SLOT(showMainMenu()));
	connect(title_widget, SIGNAL(showMin()), this, SLOT(showMinimized()));
	connect(title_widget, SIGNAL(closeWidget()), this, SLOT(hide()));
	connect(title_widget, SIGNAL(turnPage(int)), this, SLOT(turnPage(int)));

	connect(main_menu, SIGNAL(showSettingDialog()), this, SLOT(showSettingDialog()));
	connect(main_menu, SIGNAL(showNewCharacter()), this, SLOT(showNewCharacter()));
	connect(main_menu, SIGNAL(showAboutUs()), this, SLOT(showAboutUs()));

	connect(content_widget, SIGNAL(showLoginDialog()), this, SLOT(showLoginDialog()));
	connect(content_widget, SIGNAL(showRegisterDialog()), this, SLOT(showRegisterDialog()));

	connect(setting_dialog, SIGNAL(changeLanguage(LANGUAGE)), this, SLOT(changeLanguage(LANGUAGE)));

	connect(skin_widget, SIGNAL(changeSkin(QString)), this, SLOT(changeSkin(QString)));

	connect(system_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconIsActived(QSystemTrayIcon::ActivationReason)));
	connect(system_tray, SIGNAL(showWidget()), this, SLOT(showWidget()));
	
	system_tray->show();

	title_widget->turnPage("0");

	skin_name = Util::getSkinName();
	if( QString::compare(skin_name, QString("")) == 0)
	{
		this->changeSkin(DEFAULT_SKIN);
	}
}