Пример #1
0
	void Menu::keyEvent(const KeyPressEvent& event)
	{
		gui.keyEvent(event);

		if (event.getCode() == SDLK_RETURN)
		{
			addPerson();
		}

		if (event.getCode() == SDLK_F1)
		{
			play();
		}

		if (event.getCode() == SDLK_F3)
		{
			if (deleteQuestion())
			{
				cleanPersonData();
			}
		}

		if (event.getCode() == SDLK_ESCAPE)
		{
			close();
		}
	}
Пример #2
0
	void Menu::deletePerson()
	{
		Int32 index = listbox[ALL_PLAYER_LIST]->selectedIndex();
		if (index != -1)
		{
			if (!deleteQuestion())
				return;

			const std::string& playerName = listbox[ALL_PLAYER_LIST]->selectedItem();
			persons.remove(playerName);
			listbox[ALL_PLAYER_LIST]->removeItem(playerName);
		}
	}
Пример #3
0
MainWindow::MainWindow()
{
    // User interface ----------------------------------------------------------
    if (tr("LTR") == "RTL") {
        qApp->setLayoutDirection(Qt::RightToLeft);
    }
    setupUi(this);
    network_access_manager = new QNetworkAccessManager(this);
    default_printer = NULL;
#ifdef Q_OS_MAC
    this->setUnifiedTitleAndToolBarOnMac(true);
#endif
    progressBar = new QProgressBar(this);
    progressBar->setTextVisible(false);
    progressBar->resize(QSize(30, 10));
    statusBar()->addPermanentWidget(progressBar, 0);
    statusBar()->setFixedHeight(20);
    progressBar->setFixedWidth(150);
    progressBar->setFixedHeight(15);
    progressBar->setVisible(false);
    LQCategoryComboBox->setVisible(false);
    SQStatisticsLabel->setVisible(false);
    currentSvgChanged();
    btnApply = SQButtonBox->button(QDialogButtonBox::Apply);
    btnApply->setText(tr("Apply"));
    btnApply->setStatusTip(tr("Apply any changes you have made to the question"));
    btnApply->setIcon(QIcon(QString::fromUtf8(":/images/images/button_ok.png")));
    btnDiscard = SQButtonBox->button(QDialogButtonBox::Discard);
    btnDiscard->setText(tr("Discard"));
    btnDiscard->setStatusTip(tr("Discard any changes you have made to the question"));
    btnDiscard->setIcon(QIcon(QString::fromUtf8(":/images/images/button_cancel.png")));
    SQQuestionTextEdit->setTitle(tr("Question:"));
    SQQuestionTextEdit->textEdit()->setStatusTip(tr("Text of the selected question"));
    ECTextEdit->setTitle(tr("Comments:"));
    ECTextEdit->textEdit()->setStatusTip(tr("Use this field for your comments, notes, reminders..."));
    EFTreeWidget->setMouseTracking(true);
    EFTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Fixed);
    EFTreeWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
    EFTreeWidget->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    EFButtonBox->button(QDialogButtonBox::Apply)->setText(tr("Apply"));
    EFButtonBox->button(QDialogButtonBox::Apply)->setStatusTip(tr("Apply any changes you have made to the categories"));
    EFButtonBox->button(QDialogButtonBox::Apply)->setIcon(QIcon(QString::fromUtf8(":/images/images/button_ok.png")));
    EFButtonBox->button(QDialogButtonBox::Discard)->setText(tr("Discard"));
    EFButtonBox->button(QDialogButtonBox::Discard)->setStatusTip(tr("Discard any changes you have made to the categories"));
    EFButtonBox->button(QDialogButtonBox::Discard)->setIcon(QIcon(QString::fromUtf8(":/images/images/button_cancel.png")));
    // Initialize variables ----------------------------------------------------
    // URLs
    docs_url = tr("http://itest.sourceforge.net/documentation/%1/en/").arg("1.4");
    // i18n
    QTranslator translator; translator.load(":/i18n/iTest-i18n.qm");
    itest_i18n.insert("English", "en");
    itest_i18n.insert(translator.translate("LanguageNames", "Slovak"), "sk");
    itest_i18n.insert(translator.translate("LanguageNames", "Russian"), "ru");
    itest_i18n.insert(translator.translate("LanguageNames", "Turkish"), "tr");
    itest_i18n.insert(translator.translate("LanguageNames", "Portuguese"), "pt");
    itest_i18n.insert(translator.translate("LanguageNames", "Spanish"), "es");
    itest_i18n.insert(translator.translate("LanguageNames", "Italian"), "it");
    itest_i18n.insert(translator.translate("LanguageNames", "Latvian"), "lv");
    itest_i18n.insert(translator.translate("LanguageNames", "Ukrainian"), "uk");
    itest_i18n.insert(translator.translate("LanguageNames", "Czech"), "cs");
    itest_i18n.insert(translator.translate("LanguageNames", "Hungarian"), "hu");
    itest_i18n.insert(translator.translate("LanguageNames", "German"), "de");
    // CURRENT_DB
    current_db_open = false;
    current_db_session = NULL;
    current_db_class = NULL;
    current_db_categories.resize(20);
    current_db_categories_enabled.resize(20);
    // Connect slots -----------------------------------------------------------
    tbtnAddQuestion->setDefaultAction(actionAdd);
    tbtnDuplicateQuestion->setDefaultAction(actionDuplicate);
    tbtnDeleteQuestion->setDefaultAction(actionDelete);
    QObject::connect(actionAdd, SIGNAL(triggered()), this, SLOT(addQuestion()));
    QObject::connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteQuestion()));
    QObject::connect(actionDuplicate, SIGNAL(triggered()), this, SLOT(duplicateQuestion()));
    QObject::connect(btnApply, SIGNAL(released()), this, SLOT(applyQuestionChanges()));
    QObject::connect(actionApply, SIGNAL(triggered()), this, SLOT(applyQuestionChanges()));
    QObject::connect(btnDiscard, SIGNAL(released()), this, SLOT(discardQuestionChanges()));
    QObject::connect(actionDiscard, SIGNAL(triggered()), this, SLOT(discardQuestionChanges()));

    QObject::connect(actionNew, SIGNAL(triggered()), this, SLOT(newDB()));
    QObject::connect(btnNew, SIGNAL(released()), this, SLOT(newDB()));
    QObject::connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    QObject::connect(btnOpenOther, SIGNAL(released()), this, SLOT(open()));
    QObject::connect(btnOpenSelected, SIGNAL(released()), this, SLOT(openRecent()));
    QObject::connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
    QObject::connect(actionSave_as, SIGNAL(triggered()), this, SLOT(saveAs()));
    QObject::connect(actionSave_a_copy, SIGNAL(triggered()), this, SLOT(saveCopy()));
    QObject::connect(actionExport_CSV, SIGNAL(triggered()), this, SLOT(exportCSV()));
    QObject::connect(actionClose, SIGNAL(triggered()), this, SLOT(closeDB()));
    QObject::connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    QObject::connect(actionAbout, SIGNAL(triggered()), this, SLOT(about()));

    QObject::connect(recentDBsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openRecent(QListWidgetItem *)));
    QObject::connect(LQListWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(setCurrentQuestion()));

    QObject::connect(actionFrom_A_to_Z, SIGNAL(triggered()), this, SLOT(sortQuestionsAscending()));
    QObject::connect(actionFrom_Z_to_A, SIGNAL(triggered()), this, SLOT(sortQuestionsDescending()));
    QObject::connect(actionBy_category, SIGNAL(triggered()), this, SLOT(sortQuestionsByCategory()));

    tbtnAddSVG->setDefaultAction(actionAdd_SVG);
    tbtnRemoveSVG->setDefaultAction(actionRemove_SVG);
    tbtnEditSVG->setDefaultAction(actionEdit_SVG);
    tbtnExportSVG->setDefaultAction(actionExport_SVG);
    QObject::connect(actionAdd_SVG, SIGNAL(triggered()), this, SLOT(addSvg()));
    QObject::connect(actionRemove_SVG, SIGNAL(triggered()), this, SLOT(removeSvg()));
    QObject::connect(actionEdit_SVG, SIGNAL(triggered()), this, SLOT(editSvg()));
    QObject::connect(actionExport_SVG, SIGNAL(triggered()), this, SLOT(exportSvg()));
    QObject::connect(SQSVGListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(previewSvg(QListWidgetItem *)));
    QObject::connect(SQSVGListWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(currentSvgChanged()));

    tbtnMoveUp->setDefaultAction(actionMove_up);
    tbtnMoveDown->setDefaultAction(actionMove_down);
    QObject::connect(actionMove_up, SIGNAL(triggered()), this, SLOT(moveUp()));
    QObject::connect(actionMove_down, SIGNAL(triggered()), this, SLOT(moveDown()));
    QObject::connect(actionMove_to_top, SIGNAL(triggered()), this, SLOT(moveToTop()));
    QObject::connect(actionMove_to_bottom, SIGNAL(triggered()), this, SLOT(moveToBottom()));
    QObject::connect(actionHide, SIGNAL(triggered()), this, SLOT(hideQuestion()));
    QObject::connect(actionShow_hidden, SIGNAL(triggered()), this, SLOT(filterLQSearch()));

    rbtngrpFilterLQ = new QButtonGroup(this);
    rbtngrpFilterLQ->addButton(LQAllRadioButton);
    rbtngrpFilterLQ->addButton(LQEasyRadioButton);
    rbtngrpFilterLQ->addButton(LQMediumRadioButton);
    rbtngrpFilterLQ->addButton(LQDifficultRadioButton);
    rbtngrpFilterLQ->addButton(LQCategoryRadioButton);

    actgrpFilterLQ = new QActionGroup(this);
    actgrpFilterLQ->addAction(actionShow_all);
    actgrpFilterLQ->addAction(actionShow_easy);
    actgrpFilterLQ->addAction(actionShow_medium);
    actgrpFilterLQ->addAction(actionShow_difficult);
    actgrpFilterLQ->addAction(actionShow_category);

    QObject::connect(rbtngrpFilterLQ, SIGNAL(buttonReleased(QAbstractButton *)), this, SLOT(filterLQ(QAbstractButton *)));
    QObject::connect(actgrpFilterLQ, SIGNAL(triggered(QAction *)), this, SLOT(filterLQAction(QAction *)));
    QObject::connect(LQCategoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterLQCategoryChanged()));
    QObject::connect(LQSearchLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterLQSearch()));
    QObject::connect(tbtnSearchByGroup, SIGNAL(released()), this, SLOT(searchByGroup()));

    actgrpPage = new QActionGroup(this);
    actgrpPage->addAction(actionEdit_questions);
    actgrpPage->addAction(actionEdit_comments);
    actgrpPage->addAction(actionEdit_categories);
    actgrpPage->addAction(actionEdit_test);
    actgrpPage->addAction(actionSaved_sessions);
    actgrpPage->addAction(actionEdit_classes);

    QObject::connect(actgrpPage, SIGNAL(triggered(QAction *)), this, SLOT(setPage(QAction *)));

    //QObject::connect(btnApply, SIGNAL(released()), this, SLOT(setDatabaseModified()));
    //QObject::connect(actionApply, SIGNAL(triggered()), this, SLOT(setDatabaseModified()));
    QObject::connect(ECTextEdit, SIGNAL(textChanged()), this, SLOT(setDatabaseModified()));

    QObject::connect(actionCheck_for_updates, SIGNAL(triggered()), this, SLOT(checkForUpdates()));
    QObject::connect(network_access_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(httpRequestFinished(QNetworkReply *)));
    QObject::connect(actionDocumentation, SIGNAL(triggered()), this, SLOT(openDocumentation()));
    QObject::connect(SQStatisticsLabel, SIGNAL(linkActivated(QString)), this, SLOT(adjustQuestionDifficulty()));
    QObject::connect(actionPrint_questions, SIGNAL(triggered()), this, SLOT(showPrintQuestionsDialogue()));
    QObject::connect(actionOverall_statistics, SIGNAL(triggered()), this, SLOT(overallStatistics()));
    QObject::connect(actionChange_language, SIGNAL(triggered()), this, SLOT(changeLanguage()));

    QObject::connect(mainStackedWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int)));
    // Disable all -------------------------------------------------------------
    setAllEnabled(false);
    // Categories -------------------------------------------------------------------
    setupCategoriesPage();
    // Server ------------------------------------------------------------------
    setupServer();
    // Session viewer ----------------------------------------------------------
    setupSessionViewer();
    // Class viewer ------------------------------------------------------------
    setupClassViewer();
    // -------------------------------------------------------------------------
#ifdef Q_OS_MAC
    show();
#endif
    // Load settings -----------------------------------------------------------
    loadSettings();
    // Ready -------------------------------------------------------------------
    statusBar()->showMessage(tr("Ready"), 10000);
    // Check app args ----------------------------------------------------------
    if (qApp->arguments().count() > 1) {
        openFile(qApp->arguments().at(1));
    }
    // -------------------------------------------------------------------------
#ifndef Q_OS_MAC
    show();
#endif
}
Пример #4
0
	void Menu::initialize()
	{
		appService.getConsole().printLine("\n===Menu initialization===");
		menuBannerTexture = appService.getTextureManager().load(D6_TEXTURE_MENU_PATH, TextureFilter::LINEAR, true);
		appService.getConsole().printLine("...Starting GUI library");
		gui.screenSize(video.getScreen().getClientWidth(), video.getScreen().getClientHeight(),
			(video.getScreen().getClientWidth() - 800) / 2, (video.getScreen().getClientHeight() - 600) / 2);

		listbox[0] = new Gui::ListBox(gui, true);
		listbox[0]->setPosition(10, 199, 94, 12, 16);

		listbox[ALL_PLAYER_LIST] = new Gui::ListBox(gui, true);
		listbox[ALL_PLAYER_LIST]->setPosition(10, 470, 20, 13, 18);
		listbox[ALL_PLAYER_LIST]->onDoubleClick([this](Gui::ListBox& listBox, Int32 index, const std::string& item) {
			addPlayer(index);
		});

		listbox[CUR_PLAYERS_LIST] = new Gui::ListBox(gui, false);
		listbox[CUR_PLAYERS_LIST]->setPosition(200, 470, 20, D6_MAX_PLAYERS, 18);
		listbox[CUR_PLAYERS_LIST]->onDoubleClick([this](Gui::ListBox& listBox, Int32 index, const std::string& item) {
			removePlayer(index);
		});

		listbox[3] = new Gui::ListBox(gui, true);
		listbox[3]->setPosition(654, 410, 13, 6, 16);

		listbox[4] = new Gui::ListBox(gui, true);
		listbox[4]->setPosition(520, 363, 13, 3, 16);

		listbox[5] = new Gui::ListBox(gui, false);
		listbox[5]->setPosition(654, 470, 15, 2, 16);
		listbox[5]->addItem("Fullscreen");
		listbox[5]->addItem("Split screen");

		listbox[6] = new Gui::ListBox(gui, true);
		listbox[6]->setPosition(520, 470, 13, 5, 16);

		loadPersonProfiles(D6_FILE_PROFILES);
		loadPersonData(D6_FILE_PHIST);

		button[0] = new Gui::Button(gui);
		button[0]->setPosition(200, 282, 80, 25);
		button[0]->setCaption(">>");
		button[0]->onClick([this](Gui::Button&) {
			addPlayer(listbox[ALL_PLAYER_LIST]->selectedIndex());
		});

		button[1] = new Gui::Button(gui);
		button[1]->setPosition(200, 253, 80, 25);
		button[1]->setCaption("<<");
		button[1]->onClick([this](Gui::Button&) {
			removePlayer(listbox[CUR_PLAYERS_LIST]->selectedIndex());
		});

		button[2] = new Gui::Button(gui);
		button[2]->setPosition(284, 282, 80, 25);
		button[2]->setCaption("Remove");
		button[2]->onClick([this](Gui::Button&) {
			deletePerson();
			rebuildTable();
		});

		button[3] = new Gui::Button(gui);
		button[3]->setPosition(284, 253, 80, 25);
		button[3]->setCaption("Add");
		button[3]->onClick([this](Gui::Button&) {
			addPerson();
		});

		button[6] = new Gui::Button(gui);
		button[6]->setPosition(370, 282, 125, 25);
		button[6]->setCaption("Clear (F3)");
		button[6]->onClick([this](Gui::Button&) {
			if (deleteQuestion())
			{
				cleanPersonData();
			}
		});

		button[4] = new Gui::Button(gui);
		button[4]->setPosition(520, 299, 125, 73);
		button[4]->setCaption("Play (F1)");
		button[4]->onClick([this](Gui::Button&) {
			play();
		});

		button[5] = new Gui::Button(gui);
		button[5]->setPosition(654, 299, 125, 73);
		button[5]->setCaption("Quit (ESC)");
		button[5]->onClick([this](Gui::Button&) {
			close();
		});

		label[0] = new Gui::Label(gui);
		label[0]->setPosition(10, 219, 772, 18);
		label[0]->setCaption("    Name   | Games | Wins | Shots | Accuracy | Kills | Penalties | Points | Alive | Time");

		label[1] = new Gui::Label(gui);
		label[1]->setPosition(520, 383, 125, 18);
		label[1]->setCaption("Background");

		label[2] = new Gui::Label(gui);
		label[2]->setPosition(654, 429, 125, 18);
		label[2]->setCaption("Level");

		label[3] = new Gui::Label(gui);
		label[3]->setPosition(654, 489, 125, 18);
		label[3]->setCaption("Screen mode");

		label[4] = new Gui::Label(gui);
		label[4]->setPosition(520, 489, 125, 18);
		label[4]->setCaption("Zoom");

		label[5] = new Gui::Label(gui);
		label[5]->setPosition(10, 489, 181, 18);
		label[5]->setCaption("Persons");

		label[6] = new Gui::Label(gui);
		label[6]->setPosition(200, 489, 165, 18);
		label[6]->setCaption("Players");

		label[7] = new Gui::Label(gui);
		label[7]->setPosition(370, 489, 120, 18);
		label[7]->setCaption("Controller");

		textbox = new Gui::Textbox(gui);
		textbox->setPosition(370, 252, 14, 10, D6_ALL_CHR);

		// Switchbox - volba ovladani
		for (Size i = 0; i < D6_MAX_PLAYERS; i++)
		{
			controlSwitch[i] = new Gui::Spinner(gui);
			controlSwitch[i]->setPosition(370, 468 - i * 18, 120, 0);

			// TODO: Might be deleted in future if the use case is fully covered with detect-all functionality
			Gui::Button* button = new Gui::Button(gui);
			button->setCaption("D");
			button->setPosition(494, 466 - i * 18, 17, 17);
			button->onClick([this,i](Gui::Button&) {
				detectControls(i);
			});
		}

		// Button to detect all user's controllers in a batch
		Gui::Button* button = new Gui::Button(gui);
		button->setCaption("D");
		button->setPosition(490, 487, 24, 17);
		button->onClick([this](Gui::Button&){
			Size curPlayersCount = listbox[CUR_PLAYERS_LIST]->size();
			for (Size j = 0; j < curPlayersCount; j++)
			{
				detectControls(j);
			}
		});

		initializeGameModes();
		gameModeSwitch = new Gui::Spinner(gui);
		for(auto& gameMode : gameModes)
		{
			gameModeSwitch->addItem(gameMode->getName());
		}
		gameModeSwitch->setPosition(10, 0, 330, 20);

		joyRescan();

		backgroundCount = File::countFiles(D6_TEXTURE_BCG_PATH, D6_TEXTURE_EXTENSION);
		levelList.initialize(D6_FILE_LEVEL, D6_LEVEL_EXTENSION);

		listbox[3]->addItem("Random");
		for (Size i = 0; i < levelList.getLength(); i++)
		{
			listbox[3]->addItem(levelList.getFileName(i).substr(0, levelList.getFileName(i).rfind(".")));
		}

		listbox[4]->addItem("Random");
		for (Size i = 0; i < backgroundCount; i++)
		{
			listbox[4]->addItem(std::to_string(i + 1));
		}

		for (Int32 i = 5; i < 21; i++)
		{
			listbox[6]->addItem(std::to_string(i));
		}
		listbox[6]->selectItem(8).scrollToView(8);

		menuTrack = sound.loadModule("sound/undead.xm");
	}