Example #1
0
void StageManager::createSectionData() {
    apNum = 0;
    if (rank <= 0)
        return;
    field->aimSpeed = 0.1 + section * 0.02;
    if (section == 4) {
        // Set the middle boss.
        Vector pos;
        pos.x = 0; pos.y = field->size.y / 4 * 3;
        gameManager->addBoss(pos, M_PI, middleBossType);
        bossSection = true;
        sectionIntervalCnt = sectionCnt = 2 * 60;
        field->aimZ = 11;
        return;
    } else if (section == 9) {
        // Set the large boss.
        Vector pos;
        pos.x = 0; pos.y = field->size.y / 4 * 3;
        gameManager->addBoss(pos, M_PI, largeBossType);
        bossSection = true;
        sectionIntervalCnt = sectionCnt = 3 * 60;
        field->aimZ = 12;
        return;
    } else if (section == middleRushSectionNum) {
        // In this section, no small enemy.
        middleRushSection = true;
        field->aimZ = 9;
    } else {
        middleRushSection = false;
        field->aimZ = 10 + rand.nextSignedFloat(0.3);
    }
    bossSection = false;
    if (section == 3)
        sectionIntervalCnt = 2 * 60;
    else if (section == 3)
        sectionIntervalCnt = 4 * 60;
    else
        sectionIntervalCnt = 1 * 60;
    sectionCnt = sectionIntervalCnt + 10 * 60;
    int sp = section * 3 / 7 + 1;
    int ep = 3 + section * 3 / 10;
    int ap = sp + rand.nextInt(ep - sp + 1);
    if (section == 0)
        ap = 0;
    else if (middleRushSection)
        ap = MIDDLE_RUSH_SECTION_PATTERN;
    for (int i = 0; i < apparancePattern[gameManager->mode][ap][0]; ++i, ++apNum) {
        EnemyAppearance* ap = &appearance[apNum];
        setAppearance(ap, SMALL);
    }
    for (int i = 0; i < apparancePattern[gameManager->mode][ap][1]; ++i, ++apNum) {
        EnemyAppearance* ap = &appearance[apNum];
        setAppearance(ap, MIDDLE);
    }
    for (int i = 0; i < apparancePattern[gameManager->mode][ap][2]; ++i, ++apNum) {
        EnemyAppearance* ap = &appearance[apNum];
        setAppearance(ap, LARGE);
    }
}
Example #2
0
    void Counter::setup(const StringMap & settings)
    {
        std::vector<std::string> coordinates;
        
        // Set incoming coordinates
        helper::tokenize(settings.at("heuristics.Counter.markers"), coordinates, "|");
        for(int i = 0; i < 2; i++)
        {
            std::vector<std::string> fromAndTo;
            helper::tokenize(coordinates[i], fromAndTo, ",");
            int from = std::atoi(fromAndTo[0].c_str());
            int to = std::atoi(fromAndTo[1].c_str());
            cv::Point p(from ,to);
            m_in.push_back(p);
        }
        
        // Set outgoing coordinates

        for(int i = 2; i < 4; i++)
        {
            std::vector<std::string> fromAndTo;
            helper::tokenize(coordinates[i], fromAndTo, ",");
            int from = std::atoi(fromAndTo[0].c_str());
            int to = std::atoi(fromAndTo[1].c_str());
            cv::Point p(from ,to);
            m_out.push_back(p);
        }

        setMinimumChanges(std::atoi(settings.at("heuristics.Counter.minimumChanges").c_str()));
        setNoMotionDelayTime(std::atoi(settings.at("heuristics.Counter.noMotionDelayTime").c_str()));
        setAppearance(std::atoi(settings.at("heuristics.Counter.appearance").c_str()));
        setMaxDistance(std::atoi(settings.at("heuristics.Counter.maxDistance").c_str()));
        setMinArea(std::atoi(settings.at("heuristics.Counter.minArea").c_str()));
        setOnlyTrueWhenCounted((settings.at("heuristics.Counter.onlyTrueWhenCounted") == "true"));
    }
//*************************************************************************
ImageBody::ImageBody(QPixmap *pixmap, const QString &altText,
                 int appearance,
                 QWidget *parent)
  : StringBody(altText, appearance, NULL, parent) {

  QPushButton::setPixmap(pixmap == NULL ? 0 : *pixmap);
  setAppearance(appearance);
}
Example #4
0
// Draw all Objects
void Scene::drawObjectsOfScene(int timer) {
    for (size_t i = 0; i < drawnObjects.size(); ++i) {
        if(drawnObjects[i].objectId !=-1){
            const ObjectInstance &instance = drawnObjects[i];
            setAppearance(instance,timer);
            storedObjects[instance.objectId]->drawObject();
        }
    }
}
//*************************************************************************
StringBody::StringBody(const QString &textStr, int appearance,
                       QFont *f,
                       QWidget *parent)
  : QPushButton(parent) {

  if (f != NULL) {
    setFont(*f);
  }

  textLineHeight = QFontMetrics(font()).height();

  setAppearance(appearance);
  setContent(textStr, appearance);
}
Example #6
0
// Draw all Objects
void Scene::drawObjectsOfScene()
{
    
    GLuint indexStoredObjects=0;
    for (GLuint iDrawnObjects=0 ; iDrawnObjects<this->nbDrawnObjects; iDrawnObjects++)
    {
        indexStoredObjects=this->drawnObjects[iDrawnObjects];
	    if ((indexStoredObjects<this->maxStoredObjects) && (this->storedObjects[indexStoredObjects]!=NULL))
	    {
	        setAppearance(iDrawnObjects);
    	    this->storedObjects[indexStoredObjects]->drawObject();
        }
    }
}
/**
 * @brief Parse the advertising pay load.
 *
 * The pay load is a buffer of bytes that is either 31 bytes long or terminated by
 * a 0 length value.  Each entry in the buffer has the format:
 * [length][type][data...]
 *
 * The length does not include itself but does include everything after it until the next record.  A record
 * with a length value of 0 indicates a terminator.
 *
 * https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
 */
void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len) {
	uint8_t length;
	uint8_t ad_type;
	uint8_t sizeConsumed = 0;
	bool finished = false;
	m_payload = payload;
	m_payloadLength = total_len;

	while(!finished) {
		length = *payload;          // Retrieve the length of the record.
		payload++;                  // Skip to type
		sizeConsumed += 1 + length; // increase the size consumed.

		if (length != 0) { // A length of 0 indicates that we have reached the end.
			ad_type = *payload;
			payload++;
			length--;

			char* pHex = BLEUtils::buildHexData(nullptr, payload, length);
			ESP_LOGD(LOG_TAG, "Type: 0x%.2x (%s), length: %d, data: %s",
					ad_type, BLEUtils::advTypeToString(ad_type), length, pHex);
			free(pHex);

			switch(ad_type) {
				case ESP_BLE_AD_TYPE_NAME_CMPL: {   // Adv Data Type: 0x09
					setName(std::string(reinterpret_cast<char*>(payload), length));
					break;
				} // ESP_BLE_AD_TYPE_NAME_CMPL

				case ESP_BLE_AD_TYPE_TX_PWR: {      // Adv Data Type: 0x0A
					setTXPower(*payload);
					break;
				} // ESP_BLE_AD_TYPE_TX_PWR

				case ESP_BLE_AD_TYPE_APPEARANCE: { // Adv Data Type: 0x19
					setAppearance(*reinterpret_cast<uint16_t*>(payload));
					break;
				} // ESP_BLE_AD_TYPE_APPEARANCE

				case ESP_BLE_AD_TYPE_FLAG: {        // Adv Data Type: 0x01
					setAdFlag(*payload);
					break;
				} // ESP_BLE_AD_TYPE_FLAG

				case ESP_BLE_AD_TYPE_16SRV_CMPL:
				case ESP_BLE_AD_TYPE_16SRV_PART: {   // Adv Data Type: 0x02
					for (int var = 0; var < length/2; ++var) {
						setServiceUUID(BLEUUID(*reinterpret_cast<uint16_t*>(payload + var * 2)));
					}
					break;
				} // ESP_BLE_AD_TYPE_16SRV_PART

				case ESP_BLE_AD_TYPE_32SRV_CMPL:
				case ESP_BLE_AD_TYPE_32SRV_PART: {   // Adv Data Type: 0x04
					for (int var = 0; var < length/4; ++var) {
						setServiceUUID(BLEUUID(*reinterpret_cast<uint32_t*>(payload + var * 4)));
					}
					break;
				} // ESP_BLE_AD_TYPE_32SRV_PART

				case ESP_BLE_AD_TYPE_128SRV_CMPL: { // Adv Data Type: 0x07
					setServiceUUID(BLEUUID(payload, 16, false));
					break;
				} // ESP_BLE_AD_TYPE_128SRV_CMPL

				case ESP_BLE_AD_TYPE_128SRV_PART: { // Adv Data Type: 0x06
					setServiceUUID(BLEUUID(payload, 16, false));
					break;
				} // ESP_BLE_AD_TYPE_128SRV_PART

				// See CSS Part A 1.4 Manufacturer Specific Data
				case ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE: {
					setManufacturerData(std::string(reinterpret_cast<char*>(payload), length));
					break;
				} // ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE

				case ESP_BLE_AD_TYPE_SERVICE_DATA: {  // Adv Data Type: 0x16 (Service Data) - 2 byte UUID
					if (length < 2) {
						ESP_LOGE(LOG_TAG, "Length too small for ESP_BLE_AD_TYPE_SERVICE_DATA");
						break;
					}
					uint16_t uuid = *(uint16_t*)payload;
					setServiceDataUUID(BLEUUID(uuid));
					if (length > 2) {
						setServiceData(std::string(reinterpret_cast<char*>(payload + 2), length - 2));
					}
					break;
				} //ESP_BLE_AD_TYPE_SERVICE_DATA

				case ESP_BLE_AD_TYPE_32SERVICE_DATA: {  // Adv Data Type: 0x20 (Service Data) - 4 byte UUID
					if (length < 4) {
						ESP_LOGE(LOG_TAG, "Length too small for ESP_BLE_AD_TYPE_32SERVICE_DATA");
						break;
					}
					uint32_t uuid = *(uint32_t*) payload;
					setServiceDataUUID(BLEUUID(uuid));
					if (length > 4) {
						setServiceData(std::string(reinterpret_cast<char*>(payload + 4), length - 4));
					}
					break;
				} //ESP_BLE_AD_TYPE_32SERVICE_DATA

				case ESP_BLE_AD_TYPE_128SERVICE_DATA: {  // Adv Data Type: 0x21 (Service Data) - 16 byte UUID
					if (length < 16) {
						ESP_LOGE(LOG_TAG, "Length too small for ESP_BLE_AD_TYPE_128SERVICE_DATA");
						break;
					}

					setServiceDataUUID(BLEUUID(payload, (size_t)16, false));
					if (length > 16) {
						setServiceData(std::string(reinterpret_cast<char*>(payload + 16), length - 16));
					}
					break;
				} //ESP_BLE_AD_TYPE_32SERVICE_DATA

				default: {
					ESP_LOGD(LOG_TAG, "Unhandled type: adType: %d - 0x%.2x", ad_type, ad_type);
					break;
				}
			} // switch
			payload += length;
		} // Length <> 0


		if (sizeConsumed >= total_len)
			finished = true;

	} // !finished
} // parseAdvertisement
Example #8
0
SettingsWidget::SettingsWidget(int page, const QString &moduleName, QWidget *videoEq) :
	videoEq(videoEq), videoEqOriginalParent(videoEq->parentWidget()),
	wasShow(false),
	moduleIndex(0)
{
	setWindowFlags(Qt::Window);
	setWindowTitle(tr("Settings"));
	setAttribute(Qt::WA_DeleteOnClose);

	Settings &QMPSettings = QMPlay2Core.getSettings();

	tabW = new QTabWidget;

	QPushButton *applyB = new QPushButton;
	applyB->setText(tr("Apply"));
	connect(applyB, SIGNAL(clicked()), this, SLOT(apply()));

	QPushButton *closeB = new QPushButton;
	closeB->setText(tr("Close"));
	closeB->setShortcut(QKeySequence("Escape"));
	connect(closeB, SIGNAL(clicked()), this, SLOT(close()));

	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(tabW, 0, 0, 1, 3);
	layout->addWidget(applyB, 1, 1, 1, 1);
	layout->addWidget(closeB, 1, 2, 1, 1);
	layout->setMargin(2);

	/* Page 1 */
	{
		QWidget *page1Widget = new QWidget;
		page1 = new Ui::GeneralSettings;
		page1->setupUi(page1Widget);

		appendColon(page1->langL);
		appendColon(page1->styleL);
		appendColon(page1->encodingL);
		appendColon(page1->audioLangL);
		appendColon(page1->subsLangL);
		appendColon(page1->screenshotL);
		appendColon(page1->profileL);

		tabW->addTab(page1Widget, tr("General settings"));

		int idx;

		page1->langBox->addItem("English", "en");
		page1->langBox->setCurrentIndex(0);
		const QStringList langs = QMPlay2Core.getLanguages();
		for (int i = 0; i < langs.count(); i++)
		{
			page1->langBox->addItem(QMPlay2Core.getLongFromShortLanguage(langs[i]), langs[i]);
			if (QMPlay2Core.getLanguage() == langs[i])
				page1->langBox->setCurrentIndex(i + 1);
		}

		page1->styleBox->addItems(QStyleFactory::keys());
		idx = page1->styleBox->findText(QApplication::style()->objectName(), Qt::MatchFixedString);
		if (idx > -1 && idx < page1->styleBox->count())
			page1->styleBox->setCurrentIndex(idx);
		connect(page1->styleBox, SIGNAL(currentIndexChanged(int)), this, SLOT(chStyle()));

		QStringList encodings;
		for (const QByteArray &item : QTextCodec::availableCodecs())
			encodings += QTextCodec::codecForName(item)->name();
		encodings.removeDuplicates();
		page1->encodingB->addItems(encodings);
		idx = page1->encodingB->findText(QMPSettings.getByteArray("FallbackSubtitlesEncoding"));
		if (idx > -1)
			page1->encodingB->setCurrentIndex(idx);

		const QString audioLang = QMPSettings.getString("AudioLanguage");
		const QString subsLang = QMPSettings.getString("SubtitlesLanguage");
		page1->audioLangB->addItem(tr("Default or first stream"));
		page1->subsLangB->addItem(tr("Default or first stream"));
		for (const QString &lang : QMPlay2Core.getLanguagesMap())
		{
			page1->audioLangB->addItem(lang);
			page1->subsLangB->addItem(lang);
			if (lang == audioLang)
				page1->audioLangB->setCurrentIndex(page1->audioLangB->count() - 1);
			if (lang == subsLang)
				page1->subsLangB->setCurrentIndex(page1->subsLangB->count() - 1);
		}
		{
			const QString currentProfile = QSettings(QMPlay2Core.getSettingsDir() + "Profile.ini", QSettings::IniFormat).value("Profile").toString();
			page1->profileB->addItem(tr("Default"));
			for (const QString &profile : QDir(QMPlay2Core.getSettingsDir() + "Profiles/").entryList(QDir::Dirs | QDir::NoDotAndDotDot))
			{
				page1->profileB->addItem(profile);
				if (profile == currentProfile)
					page1->profileB->setCurrentIndex(page1->profileB->count() - 1);
			}
			connect(page1->profileB, SIGNAL(currentIndexChanged(int)), this, SLOT(profileListIndexChanged(int)));

			page1->profileRemoveB->setIcon(QMPlay2Core.getIconFromTheme("list-remove"));
			page1->profileRemoveB->setEnabled(page1->profileB->currentIndex() != 0);
			connect(page1->profileRemoveB, SIGNAL(clicked()), this, SLOT(removeProfile()));
		}

		page1->screenshotE->setText(QMPSettings.getString("screenshotPth"));
		page1->screenshotFormatB->setCurrentIndex(page1->screenshotFormatB->findText(QMPSettings.getString("screenshotFormat")));
		page1->screenshotB->setIcon(QMPlay2Core.getIconFromTheme("folder-open"));
		connect(page1->screenshotB, SIGNAL(clicked()), this, SLOT(chooseScreenshotDir()));

		connect(page1->setAppearanceB, SIGNAL(clicked()), this, SLOT(setAppearance()));
		connect(page1->setKeyBindingsB, SIGNAL(clicked()), this, SLOT(setKeyBindings()));

#ifdef ICONS_FROM_THEME
		page1->iconsFromTheme->setChecked(QMPSettings.getBool("IconsFromTheme"));
#else
		delete page1->iconsFromTheme;
		page1->iconsFromTheme = nullptr;
#endif

		page1->showCoversGB->setChecked(QMPSettings.getBool("ShowCovers"));
		page1->blurCoversB->setChecked(QMPSettings.getBool("BlurCovers"));
		page1->showDirCoversB->setChecked(QMPSettings.getBool("ShowDirCovers"));

		page1->autoOpenVideoWindowB->setChecked(QMPSettings.getBool("AutoOpenVideoWindow"));
		page1->autoRestoreMainWindowOnVideoB->setChecked(QMPSettings.getBool("AutoRestoreMainWindowOnVideo"));

		page1->autoUpdatesB->setChecked(QMPSettings.getBool("AutoUpdates"));
#ifndef UPDATER
		page1->autoUpdatesB->setText(tr("Automatically check for updates"));
#endif

		if (Notifies::hasBoth())
			page1->trayNotifiesDefault->setChecked(QMPSettings.getBool("TrayNotifiesDefault"));
		else
		{
			delete page1->trayNotifiesDefault;
			page1->trayNotifiesDefault = nullptr;
		}

		page1->autoDelNonGroupEntries->setChecked(QMPSettings.getBool("AutoDelNonGroupEntries"));

		page1->tabsNorths->setChecked(QMPSettings.getBool("MainWidget/TabPositionNorth"));

#ifdef QMPLAY2_ALLOW_ONLY_ONE_INSTANCE
		page1->allowOnlyOneInstance->setChecked(QMPSettings.getBool("AllowOnlyOneInstance"));
#else
		delete page1->allowOnlyOneInstance;
		page1->allowOnlyOneInstance = nullptr;
#endif

		page1->hideArtistMetadata->setChecked(QMPSettings.getBool("HideArtistMetadata"));
		page1->displayOnlyFileName->setChecked(QMPSettings.getBool("DisplayOnlyFileName"));
		page1->restoreRepeatMode->setChecked(QMPSettings.getBool("RestoreRepeatMode"));
		page1->stillImages->setChecked(QMPSettings.getBool("StillImages"));

		page1->proxyB->setChecked(QMPSettings.getBool("Proxy/Use"));
		page1->proxyHostE->setText(QMPSettings.getString("Proxy/Host"));
		page1->proxyPortB->setValue(QMPSettings.getInt("Proxy/Port"));
		page1->proxyLoginB->setChecked(QMPSettings.getBool("Proxy/Login"));
		page1->proxyUserE->setText(QMPSettings.getString("Proxy/User"));
		page1->proxyPasswordE->setText(QByteArray::fromBase64(QMPSettings.getByteArray("Proxy/Password")));

		const QIcon viewRefresh = QMPlay2Core.getIconFromTheme("view-refresh");
		page1->clearCoversCache->setIcon(viewRefresh);
		connect(page1->clearCoversCache, SIGNAL(clicked()), this, SLOT(clearCoversCache()));
		page1->removeYtDlB->setIcon(QMPlay2Core.getIconFromTheme("list-remove"));
		connect(page1->removeYtDlB, SIGNAL(clicked()), this, SLOT(removeYouTubeDl()));
		page1->resetSettingsB->setIcon(viewRefresh);
		connect(page1->resetSettingsB, SIGNAL(clicked()), this, SLOT(resetSettings()));
	}

	/* Page 2 */
	{
		QWidget *page2Widget = new QWidget;
		page2 = new Ui::PlaybackSettings;
		page2->setupUi(page2Widget);

		appendColon(page2->shortSeekL);
		appendColon(page2->longSeekL);
		appendColon(page2->bufferLocalL);
		appendColon(page2->bufferNetworkL);
		appendColon(page2->backwardBufferNetworkL);
		appendColon(page2->playIfBufferedL);
		appendColon(page2->maxVolL);
		appendColon(page2->forceSamplerate);
		appendColon(page2->forceChannels);

		page2->shortSeekB->setSuffix(" " + page2->shortSeekB->suffix());
		page2->longSeekB->setSuffix(" " + page2->longSeekB->suffix());
		page2->playIfBufferedB->setSuffix(" " + page2->playIfBufferedB->suffix());
		page2->replayGainPreamp->setPrefix(page2->replayGainPreamp->prefix() + ": ");

		tabW->addTab(page2Widget, tr("Playback settings"));

		page2->shortSeekB->setValue(QMPSettings.getInt("ShortSeek"));
		page2->longSeekB->setValue(QMPSettings.getInt("LongSeek"));
		page2->bufferLocalB->setValue(QMPSettings.getInt("AVBufferLocal"));
		page2->bufferNetworkB->setValue(QMPSettings.getInt("AVBufferNetwork"));
		page2->backwardBufferNetworkB->setCurrentIndex(QMPSettings.getUInt("BackwardBuffer"));
		page2->playIfBufferedB->setValue(QMPSettings.getDouble("PlayIfBuffered"));
		page2->maxVolB->setValue(QMPSettings.getInt("MaxVol"));

		page2->forceSamplerate->setChecked(QMPSettings.getBool("ForceSamplerate"));
		page2->samplerateB->setValue(QMPSettings.getInt("Samplerate"));
		connect(page2->forceSamplerate, SIGNAL(toggled(bool)), page2->samplerateB, SLOT(setEnabled(bool)));
		page2->samplerateB->setEnabled(page2->forceSamplerate->isChecked());

		page2->forceChannels->setChecked(QMPSettings.getBool("ForceChannels"));
		page2->channelsB->setValue(QMPSettings.getInt("Channels"));
		connect(page2->forceChannels, SIGNAL(toggled(bool)), page2->channelsB, SLOT(setEnabled(bool)));
		page2->channelsB->setEnabled(page2->forceChannels->isChecked());

		page2->replayGain->setChecked(QMPSettings.getBool("ReplayGain/Enabled"));
		page2->replayGainAlbum->setChecked(QMPSettings.getBool("ReplayGain/Album"));
		page2->replayGainPreventClipping->setChecked(QMPSettings.getBool("ReplayGain/PreventClipping"));
		page2->replayGainPreamp->setValue(QMPSettings.getDouble("ReplayGain/Preamp"));

		page2->wheelActionB->setChecked(QMPSettings.getBool("WheelAction"));
		page2->wheelSeekB->setChecked(QMPSettings.getBool("WheelSeek"));
		page2->wheelVolumeB->setChecked(QMPSettings.getBool("WheelVolume"));

		page2->storeARatioAndZoomB->setChecked(QMPSettings.getBool("StoreARatioAndZoom"));
		connect(page2->storeARatioAndZoomB, &QCheckBox::toggled, this, [this](bool checked) {
			if (checked)
			{
				page2->keepZoom->setChecked(true);
				page2->keepARatio->setChecked(true);
			}
		});

		page2->keepZoom->setChecked(QMPSettings.getBool("KeepZoom"));
		connect(page2->keepZoom, &QCheckBox::toggled, this, [this](bool checked) {
			if (!checked && !page2->keepARatio->isChecked())
			{
				page2->storeARatioAndZoomB->setChecked(false);
			}
		});

		page2->keepARatio->setChecked(QMPSettings.getBool("KeepARatio"));
		connect(page2->keepARatio, &QCheckBox::toggled, this, [this](bool checked) {
			if (!checked && !page2->keepZoom->isChecked())
			{
				page2->storeARatioAndZoomB->setChecked(false);
			}
		});

		page2->showBufferedTimeOnSlider->setChecked(QMPSettings.getBool("ShowBufferedTimeOnSlider"));
		page2->savePos->setChecked(QMPSettings.getBool("SavePos"));
		page2->keepSubtitlesDelay->setChecked(QMPSettings.getBool("KeepSubtitlesDelay"));
		page2->keepSubtitlesScale->setChecked(QMPSettings.getBool("KeepSubtitlesScale"));
		page2->keepVideoDelay->setChecked(QMPSettings.getBool("KeepVideoDelay"));
		page2->keepSpeed->setChecked(QMPSettings.getBool("KeepSpeed"));
		page2->syncVtoA->setChecked(QMPSettings.getBool("SyncVtoA"));
		page2->silence->setChecked(QMPSettings.getBool("Silence"));
		page2->restoreVideoEq->setChecked(QMPSettings.getBool("RestoreVideoEqualizer"));
		page2->ignorePlaybackError->setChecked(QMPSettings.getBool("IgnorePlaybackError"));
		page2->leftMouseTogglePlay->setCheckState((Qt::CheckState)qBound(0, QMPSettings.getInt("LeftMouseTogglePlay"), 2));

		page2->accurateSeekB->setCheckState((Qt::CheckState)QMPSettings.getInt("AccurateSeek"));
		page2->accurateSeekB->setToolTip(tr("Slower, but more accurate seeking.\nPartially checked doesn't affect seeking on slider."));

		page2->unpauseWhenSeekingB->setChecked(QMPSettings.getBool("UnpauseWhenSeeking"));

		const QString modulesListTitle[3] = {
			tr("Video output priority"),
			tr("Audio output priority"),
			tr("Decoders priority")
		};
		for (int m = 0; m < 3; ++m)
		{
			QGroupBox *groupB = new QGroupBox(modulesListTitle[m]);
			Ui::ModulesList *ml = new Ui::ModulesList;
			ml->setupUi(groupB);
			connect(ml->list, SIGNAL(itemDoubleClicked (QListWidgetItem *)), this, SLOT(openModuleSettings(QListWidgetItem *)));
			connect(ml->moveUp, SIGNAL(clicked()), this, SLOT(moveModule()));
			connect(ml->moveDown, SIGNAL(clicked()), this, SLOT(moveModule()));
			ml->moveUp->setProperty("idx", m);
			ml->moveDown->setProperty("idx", m);
			page2->modulesListLayout->addWidget(groupB);
			page2ModulesList[m] = ml;
		}
	}

	/* Page 3 */
	{
		page3 = new Page3;
		tabW->addTab(page3, tr("Modules"));

		page3->listW = new QListWidget;
		page3->listW->setIconSize({32, 32});
		page3->listW->setMinimumSize(200, 0);
		page3->listW->setMaximumSize(200, 16777215);
		for (Module *module : QMPlay2Core.getPluginsInstance())
		{
			QListWidgetItem *tWI = new QListWidgetItem(module->name());
			tWI->setData(Qt::UserRole, qVariantFromValue((void *)module));
			QString toolTip = "<html>" + tr("Contains") + ":";
			for (const Module::Info &mod : module->getModulesInfo(true))
			{
				const QPixmap moduleIcon = Functions::getPixmapFromIcon(mod.icon, QSize(22, 22), this);
				toolTip += "<p>&nbsp;&nbsp;&nbsp;&nbsp;";
				bool hasIcon = false;
				if (!moduleIcon.isNull())
				{
					QBuffer buffer;
					if (buffer.open(QBuffer::WriteOnly) && moduleIcon.save(&buffer, "PNG"))
					{
						toolTip += "<img width='22' height='22' src='data:image/png;base64, " + buffer.data().toBase64() + "'/> ";
						hasIcon = true;
					}
				}
				if (!hasIcon)
					toolTip += "- ";
				toolTip += mod.name + "</p>";
			}
			toolTip += "</html>";
			tWI->setToolTip(toolTip);
			tWI->setIcon(QMPlay2GUI.getIcon(module->icon()));
			page3->listW->addItem(tWI);
			if (page == 2 && !moduleName.isEmpty() && module->name() == moduleName)
				moduleIndex = page3->listW->count() - 1;
		}

		page3->scrollA = new QScrollArea;
		page3->scrollA->setWidgetResizable(true);
		page3->scrollA->setFrameShape(QFrame::NoFrame);

		QHBoxLayout *layout = new QHBoxLayout(page3);
		layout->setMargin(0);
		layout->setSpacing(1);
		layout->addWidget(page3->listW);
		layout->addWidget(page3->scrollA);
		connect(page3->listW, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(chModule(QListWidgetItem *)));
	}

	/* Page 4 */
	{
		page4 = new Page4;
		tabW->addTab(page4, tr("Subtitles"));

		page4->colorsAndBordersB = new QCheckBox(tr("Colors and borders"));
		page4->colorsAndBordersB->setChecked(QMPSettings.getBool("ApplyToASS/ColorsAndBorders"));

		page4->marginsAndAlignmentB = new QCheckBox(tr("Margins and alignment"));
		page4->marginsAndAlignmentB->setChecked(QMPSettings.getBool("ApplyToASS/MarginsAndAlignment"));

		page4->fontsB = new QCheckBox(tr("Fonts and spacing"));
		page4->fontsB->setChecked(QMPSettings.getBool("ApplyToASS/FontsAndSpacing"));

		page4->overridePlayResB = new QCheckBox(tr("Use the same size"));
		page4->overridePlayResB->setChecked(QMPSettings.getBool("ApplyToASS/OverridePlayRes"));

		page4->toAssGB = new QGroupBox(tr("Apply for ASS/SSA subtitles"));
		page4->toAssGB->setCheckable(true);
		page4->toAssGB->setChecked(QMPSettings.getBool("ApplyToASS/ApplyToASS"));

		QGridLayout *page4ToAssLayout = new QGridLayout(page4->toAssGB);
		page4ToAssLayout->addWidget(page4->colorsAndBordersB, 0, 0, 1, 1);
		page4ToAssLayout->addWidget(page4->marginsAndAlignmentB, 1, 0, 1, 1);
		page4ToAssLayout->addWidget(page4->fontsB, 0, 1, 1, 1);
		page4ToAssLayout->addWidget(page4->overridePlayResB, 1, 1, 1, 1);

		page4->addWidget(page4->toAssGB);
	}

	/* Page 5 */
	{
		page5 = new Page5;
		tabW->addTab(page5, tr("OSD"));

		page5->enabledB = new QCheckBox(tr("OSD enabled"));
		page5->enabledB->setChecked(QMPSettings.getBool("OSD/Enabled"));
		page5->addWidget(page5->enabledB);
	}

	/* Page 6 */
	{
		page6 = new Page6;
		tabW->addTab(page6, tr("Video filters"));

		QWidget *widget = new QWidget;

		QGridLayout *layout = new QGridLayout(widget);
		layout->setMargin(0);

		page6->deintSettingsW = new DeintSettingsW;
		layout->addWidget(page6->deintSettingsW, 0, 0, 1, 2);

		page6->videoEqContainer = new QGroupBox(videoEq->objectName());
		layout->addWidget(page6->videoEqContainer, 1, 0, 2, 1);

		page6->otherVFiltersW = new OtherVFiltersW(false);
		if (!page6->otherVFiltersW->count())
		{
			delete page6->otherVFiltersW;
			page6->otherVFiltersW = nullptr;
		}
		else
		{
			QGroupBox *otherVFiltersContainer = new QGroupBox(tr("Software video filters"));
			QGridLayout *otherVFiltersLayout = new QGridLayout(otherVFiltersContainer);
			otherVFiltersLayout->addWidget(page6->otherVFiltersW);
			connect(page6->otherVFiltersW, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openModuleSettings(QListWidgetItem *)));
			layout->addWidget(otherVFiltersContainer, 1, 1, 1, 1);
		}

		OtherVFiltersW *otherHWVFiltersW = new OtherVFiltersW(true);
		if (!otherHWVFiltersW->count())
			delete otherHWVFiltersW;
		else
		{
			QGroupBox *otherHWVFiltersContainer = new QGroupBox(tr("Hardware accelerated video outputs"));
			QGridLayout *otherHWVFiltersLayout = new QGridLayout(otherHWVFiltersContainer);
			otherHWVFiltersLayout->addWidget(otherHWVFiltersW);
			connect(otherHWVFiltersW, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openModuleSettings(QListWidgetItem *)));
			layout->addWidget(otherHWVFiltersContainer, 2, 1, 1, 1);
		}

		page6->setWidget(widget);
	}

	connect(tabW, SIGNAL(currentChanged(int)), this, SLOT(tabCh(int)));
	tabW->setCurrentIndex(page);

	show();
}