gui: Don't use friends to limit access to Action
This commit is contained in:
parent
0579101272
commit
68cfb4e585
|
@ -51,7 +51,7 @@ QString Action::text() const
|
||||||
* in the end but now argument inside. If you need a function with no
|
* in the end but now argument inside. If you need a function with no
|
||||||
* argument, it can not have () in the end.
|
* argument, it can not have () in the end.
|
||||||
*/
|
*/
|
||||||
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ?
|
QString text = QString(m_ActionTypeNames[m_KeySequence.isMouseButton() ?
|
||||||
type() + int(mouseDown) : type()]);
|
type() + int(mouseDown) : type()]);
|
||||||
|
|
||||||
switch (type())
|
switch (type())
|
||||||
|
@ -61,9 +61,9 @@ QString Action::text() const
|
||||||
case keystroke:
|
case keystroke:
|
||||||
{
|
{
|
||||||
text += "(";
|
text += "(";
|
||||||
text += keySequence().toString();
|
text += m_KeySequence.toString();
|
||||||
|
|
||||||
if (!keySequence().isMouseButton())
|
if (!m_KeySequence.isMouseButton())
|
||||||
{
|
{
|
||||||
const QStringList& screens = typeScreenNames();
|
const QStringList& screens = typeScreenNames();
|
||||||
if (haveScreens() && !screens.isEmpty())
|
if (haveScreens() && !screens.isEmpty())
|
||||||
|
@ -116,15 +116,15 @@ QString Action::text() const
|
||||||
|
|
||||||
void Action::loadSettings(QSettings& settings)
|
void Action::loadSettings(QSettings& settings)
|
||||||
{
|
{
|
||||||
keySequence().loadSettings(settings);
|
m_KeySequence.loadSettings(settings);
|
||||||
setType(settings.value("type", keyDown).toInt());
|
setType(settings.value("type", keyDown).toInt());
|
||||||
|
|
||||||
typeScreenNames().clear();
|
m_TypeScreenNames.clear();
|
||||||
int numTypeScreens = settings.beginReadArray("typeScreenNames");
|
int numTypeScreens = settings.beginReadArray("typeScreenNames");
|
||||||
for (int i = 0; i < numTypeScreens; i++)
|
for (int i = 0; i < numTypeScreens; i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
typeScreenNames().append(settings.value("typeScreenName").toString());
|
m_TypeScreenNames.append(settings.value("typeScreenName").toString());
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ void Action::loadSettings(QSettings& settings)
|
||||||
|
|
||||||
void Action::saveSettings(QSettings& settings) const
|
void Action::saveSettings(QSettings& settings) const
|
||||||
{
|
{
|
||||||
keySequence().saveSettings(settings);
|
m_KeySequence.saveSettings(settings);
|
||||||
settings.setValue("type", type());
|
settings.setValue("type", type());
|
||||||
|
|
||||||
settings.beginWriteArray("typeScreenNames");
|
settings.beginWriteArray("typeScreenNames");
|
||||||
|
|
|
@ -32,9 +32,6 @@ class QTextStream;
|
||||||
|
|
||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
friend class ActionDialog;
|
|
||||||
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ActionType { keyDown, keyUp, keystroke,
|
enum ActionType { keyDown, keyUp, keystroke,
|
||||||
switchToScreen, toggleScreen, switchInDirection,
|
switchToScreen, toggleScreen, switchInDirection,
|
||||||
|
@ -48,25 +45,31 @@ class Action
|
||||||
public:
|
public:
|
||||||
QString text() const;
|
QString text() const;
|
||||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||||
|
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||||
|
|
||||||
void loadSettings(QSettings& settings);
|
void loadSettings(QSettings& settings);
|
||||||
void saveSettings(QSettings& settings) const;
|
void saveSettings(QSettings& settings) const;
|
||||||
int type() const { return m_Type; }
|
|
||||||
const QStringList& typeScreenNames() const { return m_TypeScreenNames; }
|
|
||||||
const QString& switchScreenName() const { return m_SwitchScreenName; }
|
|
||||||
int switchDirection() const { return m_SwitchDirection; }
|
|
||||||
int lockCursorMode() const { return m_LockCursorMode; }
|
|
||||||
bool activeOnRelease() const { return m_ActiveOnRelease; }
|
|
||||||
bool haveScreens() const { return m_HasScreens; }
|
|
||||||
|
|
||||||
protected:
|
int type() const { return m_Type; }
|
||||||
KeySequence& keySequence() { return m_KeySequence; }
|
|
||||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
|
||||||
void setType(int t) { m_Type = t; }
|
void setType(int t) { m_Type = t; }
|
||||||
QStringList& typeScreenNames() { return m_TypeScreenNames; }
|
|
||||||
|
const QStringList& typeScreenNames() const { return m_TypeScreenNames; }
|
||||||
|
void appendTypeScreenName(QString name) { m_TypeScreenNames.append(name); }
|
||||||
|
void clearTypeScreenNames() { m_TypeScreenNames.clear(); }
|
||||||
|
|
||||||
|
const QString& switchScreenName() const { return m_SwitchScreenName; }
|
||||||
void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; }
|
void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; }
|
||||||
|
|
||||||
|
int switchDirection() const { return m_SwitchDirection; }
|
||||||
void setSwitchDirection(int d) { m_SwitchDirection = d; }
|
void setSwitchDirection(int d) { m_SwitchDirection = d; }
|
||||||
|
|
||||||
|
int lockCursorMode() const { return m_LockCursorMode; }
|
||||||
void setLockCursorMode(int m) { m_LockCursorMode = m; }
|
void setLockCursorMode(int m) { m_LockCursorMode = m; }
|
||||||
|
|
||||||
|
bool activeOnRelease() const { return m_ActiveOnRelease; }
|
||||||
void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; }
|
void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; }
|
||||||
|
|
||||||
|
bool haveScreens() const { return m_HasScreens; }
|
||||||
void setHaveScreens(bool b) { m_HasScreens = b; }
|
void setHaveScreens(bool b) { m_HasScreens = b; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -83,9 +83,9 @@ void ActionDialog::accept()
|
||||||
m_Action.setType(m_pButtonGroupType->checkedId());
|
m_Action.setType(m_pButtonGroupType->checkedId());
|
||||||
m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked());
|
m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked());
|
||||||
|
|
||||||
m_Action.typeScreenNames().clear();
|
m_Action.clearTypeScreenNames();
|
||||||
foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems())
|
foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems())
|
||||||
m_Action.typeScreenNames().append(pItem->text());
|
m_Action.appendTypeScreenName(pItem->text());
|
||||||
|
|
||||||
m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText());
|
m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText());
|
||||||
m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex());
|
m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex());
|
||||||
|
|
Loading…
Reference in New Issue