#include "pirselectkeysetform.h"
#include "pirselectdeviceform.h"
#include "pirpanelselectionform.h"
+#include "pirpreferencesform.h"
#include "pirdocumentationform.h"
#include "piraboutform.h"
#include "pirkeysetmanager.h"
#include "pirpanelmanager.h"
//#define DEBUGGING
+//#include <iostream>
// Some ugly globals used for thread communications:
selectKeysetForm(0),
selectDeviceForm(0),
panelSelectionForm(0),
+ preferencesForm(0),
documentationForm(0),
aboutForm(0),
- currentKeyset(0)
+ currentKeyset(1) // Zero is not a valid keyset any more
{
ui->setupUi(this);
myKeysets = new PIRKeysetManager();
myPanels = new PIRPanelManager(this);
- // Set up the keyset selection window:
+ // Construct the forms:
+ panelSelectionForm = new PIRPanelSelectionForm(this);
+ myPanels->setupPanels(panelSelectionForm);
+
selectKeysetForm = new PIRSelectKeysetForm(this);
myKeysets->populateSelectionWidget(selectKeysetForm);
- // Set up the device selection window:
selectDeviceForm = new PIRSelectDeviceForm(this);
PIRKeysetMetaData::populateDevices(selectDeviceForm);
- // Set up the panel selection window:
- panelSelectionForm = new PIRPanelSelectionForm(this);
-
-// myPanels->setupPanels(panelSelectionForm);
+ preferencesForm = new PIRPreferencesForm(this, myKeysets);
// Remember any favorites the user has already set:
populateFavorites();
- // Retrieve the user's most recent keyset (if any):
+ // Retrieve the user's preferences:
QSettings settings("pietrzak.org", "Pierogi");
if (settings.contains("currentKeysetName"))
{
settings.value("currentKeysetMake").toString(),
settings.value("currentKeysetName").toString(),
currentKeyset);
-// currentKeyset = settings.value("currentKeyset").toInt();
}
enableButtons();
// Just to be sure, check to see if the keyset has been populated:
myKeysets->populateKeyset(this, currentKeyset);
- myPanels->enableButtons(myKeysets, currentKeyset);
+ if (preferencesForm)
+ {
+ unsigned int dk = preferencesForm->getDefaultKeyset();
+ if (preferencesForm->defaultControlsVolume() && dk)
+ {
+ myKeysets->populateKeyset(this, dk);
+ myPanels->enableButtons(myKeysets, currentKeyset, dk);
+ }
+ else
+ {
+ myPanels->enableButtons(myKeysets, currentKeyset);
+ }
+ }
+ else
+ {
+ myPanels->enableButtons(myKeysets, currentKeyset);
+ }
+}
+
+
+void MainWindow::useMainPanel()
+{
+ myPanels->useMainPanel();
+}
+
+
+void MainWindow::useAltMainPanel()
+{
+ myPanels->useAltMainPanel();
+}
+
+
+QString MainWindow::getCurrentMake()
+{
+ return makeManager.getMakeString(myKeysets->getMake(currentKeyset));
+}
+
+
+QString MainWindow::getCurrentName()
+{
+ return myKeysets->getDisplayName(currentKeyset);
}
panelSelectionForm->show();
}
+void MainWindow::on_actionPreferences_triggered()
+{
+ preferencesForm->show();
+}
+
void MainWindow::on_actionAbout_triggered()
{
if (!aboutForm)
}
+void MainWindow::startRepeating(
+ PIRKeyName name,
+ unsigned int keysetID)
+{
+ QMutexLocker locker(&commandIFMutex);
+ if (!commandInFlight)
+ {
+ commandInFlight = true;
+ emit buttonPressed(keysetID, name);
+ }
+}
+
+
void MainWindow::stopRepeating()
{
QMutexLocker locker(&stopRepeatingMutex);
}
+void MainWindow::selectPanel(
+ int index)
+{
+ ui->selectPanelComboBox->setCurrentIndex(index);
+}
+
+
void MainWindow::managePanel(
PIRPanelName name,
int state)
QWidget *panel,
const QString &displayName)
{
- ui->stackedButtonsWidget->insertWidget(index, panel);
ui->selectPanelComboBox->insertItem(index, displayName);
+ ui->stackedButtonsWidget->insertWidget(index, panel);
}