mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-27 09:58:08 +01:00
Disable impossible actions in the popup menu instead of hiding them
This commit is contained in:
parent
893219b164
commit
f9ca096dda
6 changed files with 40 additions and 37 deletions
|
@ -598,37 +598,38 @@ void ArbitrationWidget::populateResultsMenu(QMenu &iMenu, const QPoint &iPoint)
|
|||
return;
|
||||
|
||||
const Move &move = getSelectedMove();
|
||||
if (move.getType() == Move::VALID_ROUND)
|
||||
{
|
||||
// Action to display the word definition
|
||||
const QModelIndex &wordIndex = m_resultsModel->index(index.row(), 0);
|
||||
QString selectedWord = m_resultsModel->data(wordIndex).toString();
|
||||
m_resultsPopup->addShowDefinitionEntry(iMenu, selectedWord);
|
||||
|
||||
// Action to select as master move
|
||||
QAction *setAsMasterAction =
|
||||
new QAction(_q("Use as master move"), this);
|
||||
setAsMasterAction->setStatusTip(_q("Use the selected move (%1) as master move")
|
||||
.arg(formatMove(move)));
|
||||
setAsMasterAction->setShortcut(Qt::Key_M);
|
||||
QObject::connect(setAsMasterAction, SIGNAL(triggered()),
|
||||
this, SLOT(assignMasterMove()));
|
||||
iMenu.addAction(setAsMasterAction);
|
||||
}
|
||||
// Action to display the word definition
|
||||
const QModelIndex &wordIndex = m_resultsModel->index(index.row(), 0);
|
||||
QString selectedWord = m_resultsModel->data(wordIndex).toString();
|
||||
QAction *showDefAction = m_resultsPopup->getShowDefinitionEntry(selectedWord);
|
||||
iMenu.addAction(showDefAction);
|
||||
if (move.getType() != Move::VALID_ROUND)
|
||||
showDefAction->setEnabled(false);
|
||||
|
||||
// Action to select as master move
|
||||
QAction *setAsMasterAction =
|
||||
new QAction(_q("Use as master move"), this);
|
||||
setAsMasterAction->setStatusTip(_q("Use the selected move (%1) as master move")
|
||||
.arg(formatMove(move)));
|
||||
setAsMasterAction->setShortcut(Qt::Key_M);
|
||||
QObject::connect(setAsMasterAction, SIGNAL(triggered()),
|
||||
this, SLOT(assignMasterMove()));
|
||||
iMenu.addAction(setAsMasterAction);
|
||||
if (move.getType() != Move::VALID_ROUND)
|
||||
setAsMasterAction->setEnabled(false);
|
||||
|
||||
// Action to assign the selected move
|
||||
if (treeViewPlayers->selectionModel()->hasSelection())
|
||||
{
|
||||
const Move &move = getSelectedMove();
|
||||
QAction *assignSelMoveAction =
|
||||
new QAction(_q("Assign selected move (%1)").arg(formatMove(move)), this);
|
||||
assignSelMoveAction->setStatusTip(_q("Assign move (%1) to the selected player(s)")
|
||||
.arg(formatMove(move)));
|
||||
assignSelMoveAction->setShortcut(Qt::Key_Enter);
|
||||
QObject::connect(assignSelMoveAction, SIGNAL(triggered()),
|
||||
this, SLOT(assignSelectedMove()));
|
||||
iMenu.addAction(assignSelMoveAction);
|
||||
}
|
||||
QAction *assignSelMoveAction =
|
||||
new QAction(_q("Assign selected move (%1)").arg(formatMove(move)), this);
|
||||
assignSelMoveAction->setStatusTip(_q("Assign move (%1) to the selected player(s)")
|
||||
.arg(formatMove(move)));
|
||||
assignSelMoveAction->setShortcut(Qt::Key_Enter);
|
||||
QObject::connect(assignSelMoveAction, SIGNAL(triggered()),
|
||||
this, SLOT(assignSelectedMove()));
|
||||
iMenu.addAction(assignSelMoveAction);
|
||||
if (!treeViewPlayers->selectionModel()->hasSelection())
|
||||
assignSelMoveAction->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -652,7 +653,6 @@ void ArbitrationWidget::populatePlayersMenu(QMenu &iMenu, const QPoint &iPoint)
|
|||
iMenu.addAction(assignSelMoveAction);
|
||||
}
|
||||
|
||||
#if 1
|
||||
// Action to assign the top move
|
||||
QAction *assignTopMoveAction =
|
||||
new QAction(_q("Assign top move"), this);
|
||||
|
@ -661,7 +661,6 @@ void ArbitrationWidget::populatePlayersMenu(QMenu &iMenu, const QPoint &iPoint)
|
|||
QObject::connect(assignTopMoveAction, SIGNAL(triggered()),
|
||||
this, SLOT(assignTopMove()));
|
||||
iMenu.addAction(assignTopMoveAction);
|
||||
#endif
|
||||
|
||||
// TODO: add other actions
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ void CustomPopup::showPopup(const QPoint &iPoint)
|
|||
}
|
||||
|
||||
|
||||
void CustomPopup::addShowDefinitionEntry(QMenu &iPopup, QString iWord)
|
||||
QAction * CustomPopup::getShowDefinitionEntry(QString iWord)
|
||||
{
|
||||
m_word = iWord;
|
||||
|
||||
|
@ -53,7 +53,7 @@ void CustomPopup::addShowDefinitionEntry(QMenu &iPopup, QString iWord)
|
|||
QObject::connect(definitionAction, SIGNAL(triggered()),
|
||||
this, SLOT(definitionRequested()));
|
||||
|
||||
iPopup.addAction(definitionAction);
|
||||
return definitionAction;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "logging.h"
|
||||
|
||||
class QWidget;
|
||||
class QAction;
|
||||
class QPoint;
|
||||
class QMenu;
|
||||
|
||||
|
@ -38,7 +39,7 @@ class CustomPopup: public QObject
|
|||
|
||||
public:
|
||||
CustomPopup(QWidget *iWidget);
|
||||
void addShowDefinitionEntry(QMenu &iPopup, QString iWord);
|
||||
QAction * getShowDefinitionEntry(QString iWord);
|
||||
|
||||
signals:
|
||||
void requestDefinition(QString iWord);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtCore/QString>
|
||||
|
||||
#include "dic_tools_widget.h"
|
||||
|
@ -440,7 +441,7 @@ void DicToolsWidget::populateMenuPlus1(QMenu &iMenu, const QPoint &iPoint)
|
|||
const QModelIndex &wordIndex = m_plus1Model->index(index.row(), 0, index.parent());
|
||||
QString selectedWord = m_plus1Model->data(wordIndex).toString();
|
||||
|
||||
m_customPopupPlus1->addShowDefinitionEntry(iMenu, selectedWord);
|
||||
iMenu.addAction(m_customPopupPlus1->getShowDefinitionEntry(selectedWord));
|
||||
}
|
||||
|
||||
|
||||
|
@ -454,6 +455,6 @@ void DicToolsWidget::populateMenuRegexp(QMenu &iMenu, const QPoint &iPoint)
|
|||
const QModelIndex &wordIndex = m_regexpModel->index(index.row(), 0);
|
||||
QString selectedWord = m_regexpModel->data(wordIndex).toString();
|
||||
|
||||
m_customPopupRegexp->addShowDefinitionEntry(iMenu, selectedWord);
|
||||
iMenu.addAction(m_customPopupRegexp->getShowDefinitionEntry(selectedWord));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include "history_widget.h"
|
||||
|
@ -99,7 +100,7 @@ void HistoryWidget::populateMenu(QMenu &iMenu, const QPoint &iPoint)
|
|||
QString selectedWord = m_model->data(wordIndex).toString();
|
||||
|
||||
if (selectedWord != "")
|
||||
m_customPopup->addShowDefinitionEntry(iMenu, selectedWord);
|
||||
iMenu.addAction(m_customPopup->getShowDefinitionEntry(selectedWord));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QMenu>
|
||||
|
||||
#include "training_widget.h"
|
||||
#include "qtcommon.h"
|
||||
|
@ -260,7 +261,7 @@ void TrainingWidget::populateMenu(QMenu &iMenu, const QPoint &iPoint)
|
|||
const QModelIndex &wordIndex = m_model->index(index.row(), 0);
|
||||
QString selectedWord = m_model->data(wordIndex).toString();
|
||||
|
||||
m_customPopup->addShowDefinitionEntry(iMenu, selectedWord);
|
||||
iMenu.addAction(m_customPopup->getShowDefinitionEntry(selectedWord));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue