1 #include "pirmacropack.h"
9 PIRMacroPack::PIRMacroPack(
16 bool PIRMacroPack::hasButton(
17 unsigned int buttonID)
19 ButtonCollection::const_iterator i = buttons.find(buttonID);
21 if (i != buttons.end())
32 void PIRMacroPack::registerButton(
33 unsigned int buttonID,
36 buttons[buttonID] = macro;
40 void PIRMacroPack::eraseButton(
41 unsigned int buttonID,
44 ButtonCollection::iterator i = buttons.find(buttonID);
46 if (i != buttons.end() && (*i).second == macro)
53 QString PIRMacroPack::buttonText(
54 unsigned int buttonID)
56 ButtonCollection::const_iterator i = buttons.find(buttonID);
58 if (i != buttons.end())
60 return i->second->getName();
64 return "Error: Macro not found";
69 void PIRMacroPack::executeButton(
70 unsigned int buttonID)
72 ButtonCollection::const_iterator i = buttons.find(buttonID);
74 if (i != buttons.end())
76 i->second->executeMacro();
81 bool PIRMacroPack::hasKey(
84 KeyboardCollection::const_iterator i = keymaps.find(key);
86 if (i != keymaps.end())
97 void PIRMacroPack::registerKey(
101 keymaps[key] = macro;
105 void PIRMacroPack::eraseKey(
109 KeyboardCollection::iterator i = keymaps.find(key);
111 if (i != keymaps.end() && (*i).second == macro)
118 void PIRMacroPack::executeKey(
121 KeyboardCollection::const_iterator i = keymaps.find(key);
123 if (i != keymaps.end())
125 i->second->executeMacro();
130 void PIRMacroPack::storeSettings()
132 QSettings settings("pietrzak.org", "Pierogi");
134 // Erase any existing macros:
135 settings.remove("userMacros");
137 // First, do we even have any macros? If not, quit.
138 int macroCount = childCount();
139 if (macroCount == 0) return;
141 // (Re-) Construct the macros array:
146 settings.beginWriteArray("userMacros");
148 while (index < macroCount)
150 settings.setArrayIndex(index);
151 macro = dynamic_cast<PIRMacro *> (child(index));
153 macro->storeSettings(settings);