bool Window::initialise()
{
	Inform("Initialising window");

	ui.setupUi(this);

	connect(ui.ButtonAdd, SIGNAL(pressed()), this, SLOT(buttonAddEvent()));
	connect(ui.ButtonRemove, SIGNAL(pressed()), this, SLOT(buttonRemoveEvent()));
	connect(ui.ButtonUp, SIGNAL(pressed()), this, SLOT(buttonUpEvent()));
	connect(ui.ButtonDown, SIGNAL(pressed()), this, SLOT(buttonDownEvent()));

	connect(ui.BoxIso, SIGNAL(currentIndexChanged(int)), this, SLOT(changeIsoEvent(int)));
	connect(ui.BoxAperture, SIGNAL(currentIndexChanged(int)), this, SLOT(changeApertureEvent(int)));
	connect(ui.BoxShutter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeShutterEvent(int)));
	connect(ui.BoxWhiteBalance, SIGNAL(currentIndexChanged(int)), this, SLOT(changeWhiteBalanceEvent(int)));

	connect(ui.ButtonChoosePath, SIGNAL(pressed()), this, SLOT(buttonChangeDirEvent()));

	connect(ui.ButtonGo, SIGNAL(pressed()), this, SLOT(shootEvent()));


	ui.BoxProcessedformat->addItems({ "tiff", "png" });

	mColourModel = std::unique_ptr<QStringListModel>(new QStringListModel(this));
	ui.ListColours->setModel(mColourModel.get());
	ui.ListColours->setEditTriggers(QAbstractItemView::NoEditTriggers);

	if (!(mActionClass = std::unique_ptr<ActionClass>(ActionClass::create())).get())
		return false;

	//Set selectable values
	std::vector<int> apList = mActionClass->ennumeratePossibleValues(Camera::EnnumerableProperties::Aperture);
	std::vector<int> isList = mActionClass->ennumeratePossibleValues(Camera::EnnumerableProperties::ISO);
	std::vector<int> shList = mActionClass->ennumeratePossibleValues(Camera::EnnumerableProperties::ShutterSpeed);

	int currentAp = mActionClass->aperture();
	int currentIs = mActionClass->iso();
	int currentSh = mActionClass->shutter();
	int currentWb = mActionClass->whiteBalance();

	//Populate combo boxes
	for (size_t i = 0; i < apList.size(); ++i)
	{
		ui.BoxAperture->addItem(Camera::apertureMappings[apList[i]].c_str());
		if (apList[i] == currentAp)
			ui.BoxAperture->setCurrentIndex(i);
	}

	for (size_t i = 0; i < isList.size(); ++i)
	{
		ui.BoxIso->addItem(Camera::isoMappings[isList[i]].c_str());
		if (isList[i] == currentIs)
			ui.BoxIso->setCurrentIndex(i);
	}

	bool foundShutter = false;
	for (size_t i = 0; i < shList.size(); ++i)
	{
		ui.BoxShutter->addItem(Camera::shutterSpeedMappings[shList[i]].c_str());
		if (shList[i] == currentSh)
		{
			ui.BoxShutter->setCurrentIndex(i);
			foundShutter = true;
		}
	}

	//If shutter is not a valid value (such as bulb mode), change it to a default.
	if (!foundShutter && shList.size() > 0)
	{
		mActionClass->shutter(Camera::shutterSpeedMappings[shList.front()]);
		ui.BoxShutter->setCurrentIndex(0);
	}

	std::vector<int> availableWhiteBalances = { 1, 2, 3, 4, 5, 8, 9 };
	bool foundWhiteBalance = false;
	for (size_t i = 0; i < availableWhiteBalances.size(); ++i)
	{
		ui.BoxWhiteBalance->addItem(Camera::whiteBalanceMappings[availableWhiteBalances[i]].c_str());
		if (availableWhiteBalances[i] == currentWb)
		{
			ui.BoxWhiteBalance->setCurrentIndex(i);
			foundWhiteBalance = true;
		}
	}

	//If no valid white balance set, set default
	if (!foundWhiteBalance)
	{
		mActionClass->whiteBalance("Daylight");
		ui.BoxWhiteBalance->setCurrentIndex(0);
	}

	//Read in colours file
	std::fstream colourFile("colours.txt", std::ios::in);
	if (colourFile.fail())
	{
		Warning("Could not open colours.txt - Colours will not be reloaded.");
	}
	else
	{
		//Read file
		std::string tmp;
		while (getline(colourFile, tmp))
		{
			QString qs(tmp.c_str());
			qs = qs.trimmed();

			if (qs.size() == 0)
				continue;

			QColor colour(qs);

			if (colour.isValid() == false)
			{
				Warning("Invalid colour found in colours.txt");
				continue;
			}
			else
				mColourModel->setStringList(mColourModel->stringList() << colour.name());
		}
	}

	Inform("Window ready");
	initialised = true;
	return true;
}
Beispiel #2
0
void InputDevice::dpadButtonUpEvent(int setindex, int dpadindex, int buttonindex)
{
    Q_UNUSED(dpadindex);

    buttonUpEvent(setindex, buttonindex);
}
Beispiel #3
0
void InputDevice::stickButtonUpEvent(int setindex, int stickindex, int buttonindex)
{
    Q_UNUSED(stickindex);

    buttonUpEvent(setindex, buttonindex);
}
Beispiel #4
0
void InputDevice::axisButtonUpEvent(int setindex, int axisindex, int buttonindex)
{
    Q_UNUSED(axisindex);

    buttonUpEvent(setindex, buttonindex);
}