MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow), server(NULL)
{
    ui->setupUi(this);

    setWindowTitle(tr("Sanguosha") + " " + Sanguosha->getVersionNumber());

    scene = NULL;

    connection_dialog = new ConnectionDialog(this);
    connect(ui->actionStart_Game, SIGNAL(triggered()), connection_dialog, SLOT(exec()));
    connect(connection_dialog, SIGNAL(accepted()), this, SLOT(startConnection()));

    config_dialog = new ConfigDialog(this);
    connect(ui->actionConfigure, SIGNAL(triggered()), config_dialog, SLOT(show()));
    connect(config_dialog, SIGNAL(bg_changed()), this, SLOT(changeBackground()));

    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->actionAcknowledgement_2, SIGNAL(triggered()), this, SLOT(on_actionAcknowledgement_triggered()));

    StartScene *start_scene = new StartScene;

    QList<QAction *> actions;
    actions << ui->actionStart_Game
        << ui->actionStart_Server
        << ui->actionReplay
        << ui->actionConfigure
        << ui->actionGeneral_Overview
        << ui->actionCard_Overview
        << ui->actionScenario_Overview
        << ui->actionAbout;

    foreach(QAction *action, actions)
        start_scene->addButton(action);
    view = new FitView(scene);

    setCentralWidget(view);
    restoreFromConfig();

    BackLoader::preload();
    gotoScene(start_scene);

    addAction(ui->actionShow_Hide_Menu);
    addAction(ui->actionFullscreen);

    connect(ui->actionRestart_Game, SIGNAL(triggered()), this, SLOT(startConnection()));
    connect(ui->actionReturn_to_Main_Menu, SIGNAL(triggered()), this, SLOT(gotoStartScene()));

    systray = NULL;
}
Exemple #2
0
MainWindow::MainWindow(QWidget *parent)
    :QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    scene = NULL;

    // initialize random seed for later use
    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));

    connection_dialog = new ConnectionDialog(this);
    connect(ui->actionStart_Game, SIGNAL(triggered()), connection_dialog, SLOT(exec()));
    connect(connection_dialog, SIGNAL(accepted()), this, SLOT(startConnection()));

    config_dialog = new ConfigDialog(this);
    connect(ui->actionConfigure, SIGNAL(triggered()), config_dialog, SLOT(show()));
    connect(config_dialog, SIGNAL(bg_changed()), this, SLOT(changeBackground()));

    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    StartScene *start_scene = new StartScene;

    QList<QAction*> actions;
    actions << ui->actionStart_Game
            << ui->actionStart_Server
            << ui->actionPC_Console_Start
            << ui->actionReplay
            << ui->actionConfigure
            << ui->actionGeneral_Overview
            << ui->actionCard_Overview
            << ui->actionScenario_Overview
            << ui->actionAbout
            << ui->actionAcknowledgement;

    foreach(QAction *action, actions)
        start_scene->addButton(action);

    view = new FitView(scene);

    setCentralWidget(view);
    restoreFromConfig();

    gotoScene(start_scene);

    addAction(ui->actionShow_Hide_Menu);
    addAction(ui->actionFullscreen);
    addAction(ui->actionMinimize_to_system_tray);

    systray = NULL;
}
void MainWindow::gotoStartScene(){
	StartScene *start_scene = new StartScene;

	QList<QAction*> actions;
	actions << ui->actionStart_Game
			<< ui->actionStart_Server
			<< ui->actionPC_Console_Start
			<< ui->actionReplay
			<< ui->actionConfigure
			<< ui->actionGeneral_Overview
			<< ui->actionCard_Overview
			<< ui->actionScenario_Overview
			<< ui->actionAbout
			<< ui->actionAcknowledgement;

	foreach(QAction *action, actions)
		start_scene->addButton(action);

	setCentralWidget(view);
	restoreFromConfig();

	ui->menuCheat->setEnabled(false);
	ui->actionGet_card->disconnect();
	ui->actionDeath_note->disconnect();
	ui->actionDamage_maker->disconnect();
	ui->actionRevive_wand->disconnect();
	ui->actionSend_lowlevel_command->disconnect();
	ui->actionExecute_script_at_server_side->disconnect();
	gotoScene(start_scene);

	addAction(ui->actionShow_Hide_Menu);
	addAction(ui->actionFullscreen);
	addAction(ui->actionMinimize_to_system_tray);

	systray = NULL;
	delete ClientInstance;
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), isLeftPressDown(false),
      scene(NULL), ui(new Ui::MainWindow), server(NULL), about_window(NULL),
      minButton(NULL), maxButton(NULL), normalButton(NULL), closeButton(NULL),
      versionInfomationReply(NULL), changeLogReply(NULL)
{
    ui->setupUi(this);
    setWindowTitle(tr("QSanguosha-Hegemony") + " " + Sanguosha->getVersion());
#ifdef Q_OS_WIN
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
#endif
    setAttribute(Qt::WA_TranslucentBackground);

    setMouseTracking(true);
    setMinimumWidth(800);
    setMinimumHeight(580);

    fetchUpdateInformation();

    connection_dialog = new ConnectionDialog(this);
    connect(ui->actionStart_Game, SIGNAL(triggered()), connection_dialog, SLOT(exec()));
    connect(connection_dialog, SIGNAL(accepted()), this, SLOT(startConnection()));

    config_dialog = new ConfigDialog(this);
    connect(ui->actionConfigure, SIGNAL(triggered()), config_dialog, SLOT(show()));
    connect(config_dialog, SIGNAL(bg_changed()), this, SLOT(changeBackground()));
    connect(config_dialog, SIGNAL(tableBg_changed()), this, SLOT(changeBackground()));

    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->actionAcknowledgement_2, SIGNAL(triggered()), this, SLOT(on_actionAcknowledgement_triggered()));

    StartScene *start_scene = new StartScene(this);

    QList<QAction *> actions;
    actions << ui->actionStart_Game
        << ui->actionStart_Server
        << ui->actionPC_Console_Start
        << ui->actionReplay
        << ui->actionConfigure
        << ui->actionGeneral_Overview
        << ui->actionCard_Overview
        << ui->actionAbout;

    foreach(QAction *action, actions)
        start_scene->addButton(action);

#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
    ui->menuSumMenu->setAttribute(Qt::WA_TranslucentBackground);
    ui->menuGame->setAttribute(Qt::WA_TranslucentBackground);
    ui->menuView->setAttribute(Qt::WA_TranslucentBackground);
    ui->menuOptions->setAttribute(Qt::WA_TranslucentBackground);
    ui->menuDIY->setAttribute(Qt::WA_TranslucentBackground);
    ui->menuCheat->setAttribute(Qt::WA_TranslucentBackground);
    ui->menuHelp->setAttribute(Qt::WA_TranslucentBackground);
#endif

    view = new FitView(scene);

    setCentralWidget(view);
    restoreFromConfig();

    roundCorners();

    BackLoader::preload();
    gotoScene(start_scene);

    addAction(ui->actionFullscreen);

#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
    menu = new QPushButton(this);
    menu->setMenu(ui->menuSumMenu);
    menu->setProperty("control", true);
    StyleHelper::getInstance()->setIcon(menu, QChar(0xf0c9), 15);
    menu->setToolTip(tr("<font color=%1>Config</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
#endif

#if defined(Q_OS_WIN)
    minButton = new QPushButton(this);
    minButton->setProperty("control", true);

    maxButton = new QPushButton(this);
    maxButton->setProperty("bold", true);
    maxButton->setProperty("control", true);

    normalButton = new QPushButton(this);
    normalButton->setProperty("bold", true);
    normalButton->setProperty("control", true);

    closeButton= new QPushButton(this);
    closeButton->setObjectName("closeButton");
    closeButton->setProperty("control", true);

    StyleHelper::getInstance()->setIcon(minButton, QChar(0xf068), 15);
    StyleHelper::getInstance()->setIcon(maxButton, QChar(0xf106), 15);
    StyleHelper::getInstance()->setIcon(normalButton, QChar(0xf107), 15);
    StyleHelper::getInstance()->setIcon(closeButton, QChar(0xf00d), 15);

    minButton->setToolTip(tr("<font color=%1>Minimize</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
    connect(minButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
    maxButton->setToolTip(tr("<font color=%1>Maximize</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
    connect(maxButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
    normalButton->setToolTip(tr("<font color=%1>Restore downward</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
    connect(normalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
    closeButton->setToolTip(tr("<font color=%1>Close</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));

    menuBar()->hide();
#elif defined(Q_OS_ANDROID)
    ui->menuSumMenu->removeAction(ui->menuView->menuAction());
#endif
    repaintButtons();

#ifndef Q_OS_ANDROID
    QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
    animation->setDuration(1000);
    animation->setStartValue(0);
    animation->setEndValue(1);
    animation->setEasingCurve(QEasingCurve::OutCurve);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
#endif

    start_scene->showOrganization();

    systray = NULL;
}