+ fixes #0001719: Show current shortcuts (S) in menus and hover text.
This commit is contained in:
parent
80e80fef83
commit
ce528d1c4a
|
@ -772,14 +772,8 @@ UndoAction::~UndoAction()
|
|||
void UndoAction::addTo (QWidget * w)
|
||||
{
|
||||
if (w->inherits("QToolBar")) {
|
||||
// Do NOT set the shortcut again for _toolAction since this is already
|
||||
// reserved for _action. Otherwise we get an ambiguity of it with the
|
||||
// result that it doesn't work anymore.
|
||||
_toolAction->setText(_action->text());
|
||||
_toolAction->setToolTip(_action->toolTip());
|
||||
_toolAction->setStatusTip(_action->statusTip());
|
||||
_toolAction->setWhatsThis(_action->whatsThis());
|
||||
_toolAction->setIcon(_action->icon());
|
||||
actionChanged();
|
||||
connect(_action, SIGNAL(changed()), this, SLOT(actionChanged()));
|
||||
w->addAction(_toolAction);
|
||||
}
|
||||
else {
|
||||
|
@ -787,6 +781,18 @@ void UndoAction::addTo (QWidget * w)
|
|||
}
|
||||
}
|
||||
|
||||
void UndoAction::actionChanged()
|
||||
{
|
||||
// Do NOT set the shortcut again for _toolAction since this is already
|
||||
// reserved for _action. Otherwise we get an ambiguity of it with the
|
||||
// result that it doesn't work anymore.
|
||||
_toolAction->setText(_action->text());
|
||||
_toolAction->setToolTip(_action->toolTip());
|
||||
_toolAction->setStatusTip(_action->statusTip());
|
||||
_toolAction->setWhatsThis(_action->whatsThis());
|
||||
_toolAction->setIcon(_action->icon());
|
||||
}
|
||||
|
||||
void UndoAction::setEnabled(bool b)
|
||||
{
|
||||
Action::setEnabled(b);
|
||||
|
@ -819,14 +825,8 @@ RedoAction::~RedoAction()
|
|||
void RedoAction::addTo ( QWidget * w )
|
||||
{
|
||||
if (w->inherits("QToolBar")) {
|
||||
// Do NOT set the shortcut again for _toolAction since this is already
|
||||
// reserved for _action. Otherwise we get an ambiguity of it with the
|
||||
// result that it doesn't work anymore.
|
||||
_toolAction->setText(_action->text());
|
||||
_toolAction->setToolTip(_action->toolTip());
|
||||
_toolAction->setStatusTip(_action->statusTip());
|
||||
_toolAction->setWhatsThis(_action->whatsThis());
|
||||
_toolAction->setIcon(_action->icon());
|
||||
actionChanged();
|
||||
connect(_action, SIGNAL(changed()), this, SLOT(actionChanged()));
|
||||
w->addAction(_toolAction);
|
||||
}
|
||||
else {
|
||||
|
@ -834,6 +834,18 @@ void RedoAction::addTo ( QWidget * w )
|
|||
}
|
||||
}
|
||||
|
||||
void RedoAction::actionChanged()
|
||||
{
|
||||
// Do NOT set the shortcut again for _toolAction since this is already
|
||||
// reserved for _action. Otherwise we get an ambiguity of it with the
|
||||
// result that it doesn't work anymore.
|
||||
_toolAction->setText(_action->text());
|
||||
_toolAction->setToolTip(_action->toolTip());
|
||||
_toolAction->setStatusTip(_action->statusTip());
|
||||
_toolAction->setWhatsThis(_action->whatsThis());
|
||||
_toolAction->setIcon(_action->icon());
|
||||
}
|
||||
|
||||
void RedoAction::setEnabled ( bool b )
|
||||
{
|
||||
Action::setEnabled(b);
|
||||
|
|
|
@ -219,6 +219,9 @@ public:
|
|||
void setEnabled(bool);
|
||||
void setVisible(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
void actionChanged();
|
||||
|
||||
private:
|
||||
QAction* _toolAction;
|
||||
};
|
||||
|
@ -241,6 +244,9 @@ public:
|
|||
void setEnabled(bool);
|
||||
void setVisible(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
void actionChanged();
|
||||
|
||||
private:
|
||||
QAction* _toolAction;
|
||||
};
|
||||
|
|
|
@ -557,35 +557,41 @@ const char * Command::endCmdHelp(void)
|
|||
return "</body></html>\n\n";
|
||||
}
|
||||
|
||||
void Command::applyCommandData(Action* action)
|
||||
void Command::applyCommandData(const char* context, Action* action)
|
||||
{
|
||||
action->setText(QCoreApplication::translate(
|
||||
this->className(), sMenuText, 0,
|
||||
context, getMenuText(), 0,
|
||||
QCoreApplication::UnicodeUTF8));
|
||||
action->setToolTip(QCoreApplication::translate(
|
||||
this->className(), sToolTipText, 0,
|
||||
context, getToolTipText(), 0,
|
||||
QCoreApplication::UnicodeUTF8));
|
||||
if (sStatusTip)
|
||||
action->setStatusTip(QCoreApplication::translate(
|
||||
this->className(), sStatusTip, 0,
|
||||
context, getStatusTip(), 0,
|
||||
QCoreApplication::UnicodeUTF8));
|
||||
else
|
||||
action->setStatusTip(QCoreApplication::translate(
|
||||
this->className(), sToolTipText, 0,
|
||||
context, getToolTipText(), 0,
|
||||
QCoreApplication::UnicodeUTF8));
|
||||
if (sWhatsThis)
|
||||
action->setWhatsThis(QCoreApplication::translate(
|
||||
this->className(), sWhatsThis, 0,
|
||||
context, getWhatsThis(), 0,
|
||||
QCoreApplication::UnicodeUTF8));
|
||||
else
|
||||
action->setWhatsThis(QCoreApplication::translate(
|
||||
this->className(), sToolTipText, 0,
|
||||
context, getToolTipText(), 0,
|
||||
QCoreApplication::UnicodeUTF8));
|
||||
QString accel = action->shortcut().toString();
|
||||
QString accel = action->shortcut().toString(QKeySequence::NativeText);
|
||||
if (!accel.isEmpty()) {
|
||||
QString tip = QString::fromAscii("(%1)\t%2")
|
||||
// show shortcut inside tooltip
|
||||
QString ttip = QString::fromLatin1("%1 (%2)")
|
||||
.arg(action->toolTip()).arg(accel);
|
||||
action->setToolTip(ttip);
|
||||
|
||||
// show shortcut inside status tip
|
||||
QString stip = QString::fromLatin1("(%1)\t%2")
|
||||
.arg(accel).arg(action->statusTip());
|
||||
action->setStatusTip(tip);
|
||||
action->setStatusTip(stip);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,10 +653,10 @@ Action * Command::createAction(void)
|
|||
Action *pcAction;
|
||||
|
||||
pcAction = new Action(this,getMainWindow());
|
||||
applyCommandData(pcAction);
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
applyCommandData(this->className(), pcAction);
|
||||
if (sPixmap)
|
||||
pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap));
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
@ -658,7 +664,7 @@ Action * Command::createAction(void)
|
|||
void Command::languageChange()
|
||||
{
|
||||
if (_pcAction) {
|
||||
applyCommandData(_pcAction);
|
||||
applyCommandData(this->className(), _pcAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -700,10 +706,26 @@ Action * MacroCommand::createAction(void)
|
|||
pcAction->setText(QString::fromUtf8(sMenuText));
|
||||
pcAction->setToolTip(QString::fromUtf8(sToolTipText));
|
||||
pcAction->setStatusTip(QString::fromUtf8(sStatusTip));
|
||||
if (pcAction->statusTip().isEmpty())
|
||||
pcAction->setStatusTip(pcAction->toolTip());
|
||||
pcAction->setWhatsThis(QString::fromUtf8(sWhatsThis));
|
||||
if ( sPixmap )
|
||||
if (sPixmap)
|
||||
pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap));
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
|
||||
QString accel = pcAction->shortcut().toString(QKeySequence::NativeText);
|
||||
if (!accel.isEmpty()) {
|
||||
// show shortcut inside tooltip
|
||||
QString ttip = QString::fromLatin1("%1 (%2)")
|
||||
.arg(pcAction->toolTip()).arg(accel);
|
||||
pcAction->setToolTip(ttip);
|
||||
|
||||
// show shortcut inside status tip
|
||||
QString stip = QString::fromLatin1("(%1)\t%2")
|
||||
.arg(accel).arg(pcAction->statusTip());
|
||||
pcAction->setStatusTip(stip);
|
||||
}
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
|
@ -854,12 +876,7 @@ bool PythonCommand::isActive(void)
|
|||
void PythonCommand::languageChange()
|
||||
{
|
||||
if (_pcAction) {
|
||||
_pcAction->setText (qApp->translate(getName(), getMenuText ()));
|
||||
_pcAction->setToolTip (qApp->translate(getName(), getToolTipText()));
|
||||
_pcAction->setStatusTip (qApp->translate(getName(), getStatusTip ()));
|
||||
_pcAction->setWhatsThis (qApp->translate(getName(), getWhatsThis ()));
|
||||
if (_pcAction->statusTip().isEmpty())
|
||||
_pcAction->setStatusTip(qApp->translate(getName(), getToolTipText()));
|
||||
applyCommandData(getName(), _pcAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -879,16 +896,10 @@ Action * PythonCommand::createAction(void)
|
|||
Action *pcAction;
|
||||
|
||||
pcAction = new Action(this,getMainWindow());
|
||||
|
||||
pcAction->setText (qApp->translate(getName(), getMenuText ()));
|
||||
pcAction->setToolTip (qApp->translate(getName(), getToolTipText()));
|
||||
pcAction->setStatusTip (qApp->translate(getName(), getStatusTip ()));
|
||||
pcAction->setWhatsThis (qApp->translate(getName(), getWhatsThis ()));
|
||||
if (pcAction->statusTip().isEmpty())
|
||||
pcAction->setStatusTip(qApp->translate(getName(), getToolTipText()));
|
||||
pcAction->setShortcut(QString::fromAscii(getAccel()));
|
||||
applyCommandData(this->getName(), pcAction);
|
||||
if (strcmp(getResource("Pixmap"),"") != 0)
|
||||
pcAction->setIcon(Gui::BitmapFactory().pixmap(getResource("Pixmap")));
|
||||
pcAction->setShortcut (QString::fromAscii(getAccel()));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ protected:
|
|||
/// Creates the used Action
|
||||
virtual Action * createAction(void);
|
||||
/// Applies the menu text, tool and status tip to the passed action object
|
||||
void applyCommandData(Action* );
|
||||
void applyCommandData(const char* context, Action* );
|
||||
const char* keySequenceToAccel(int) const;
|
||||
void adjustCameraPosition();
|
||||
//@}
|
||||
|
|
|
@ -724,10 +724,10 @@ Action * StdCmdUndo::createAction(void)
|
|||
Action *pcAction;
|
||||
|
||||
pcAction = new UndoAction(this,getMainWindow());
|
||||
applyCommandData(pcAction);
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
applyCommandData(this->className(), pcAction);
|
||||
if (sPixmap)
|
||||
pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap));
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
@ -767,10 +767,10 @@ Action * StdCmdRedo::createAction(void)
|
|||
Action *pcAction;
|
||||
|
||||
pcAction = new RedoAction(this,getMainWindow());
|
||||
applyCommandData(pcAction);
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
applyCommandData(this->className(), pcAction);
|
||||
if (sPixmap)
|
||||
pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap));
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
|
|
@ -125,10 +125,10 @@ Action * StdCmdWorkbench::createAction(void)
|
|||
Action *pcAction;
|
||||
|
||||
pcAction = new WorkbenchGroup(this,getMainWindow());
|
||||
applyCommandData(pcAction);
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
applyCommandData(this->className(), pcAction);
|
||||
if (sPixmap)
|
||||
pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap));
|
||||
pcAction->setShortcut(QString::fromAscii(sAccel));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ Action * StdCmdRecentFiles::createAction(void)
|
|||
RecentFilesAction* pcAction = new RecentFilesAction(this, getMainWindow());
|
||||
pcAction->setObjectName(QLatin1String("recentFiles"));
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ Action * StdCmdFreezeViews::createAction(void)
|
|||
{
|
||||
ActionGroup* pcAction = new ActionGroup(this, getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
// add the action items
|
||||
saveView = pcAction->addAction(QObject::tr("Save views..."));
|
||||
|
@ -559,7 +559,7 @@ Gui::Action * StdCmdDrawStyle::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* a0 = pcAction->addAction(QString());
|
||||
a0->setCheckable(true);
|
||||
|
|
|
@ -316,7 +316,7 @@ Action * StdCmdDockViewMenu::createAction(void)
|
|||
{
|
||||
Action *pcAction;
|
||||
pcAction = new DockWidgetAction(this, getMainWindow());
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ Action * StdCmdToolBarMenu::createAction(void)
|
|||
{
|
||||
Action *pcAction;
|
||||
pcAction = new ToolBarAction(this, getMainWindow());
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# include <QFileInfo>
|
||||
# include <QHeaderView>
|
||||
# include <QImageReader>
|
||||
# include <QKeySequence>
|
||||
# include <QMessageBox>
|
||||
# include <QTextStream>
|
||||
#endif
|
||||
|
@ -261,7 +262,7 @@ void DlgCustomActionsImp::on_buttonAddAction_clicked()
|
|||
m_sPixmap = QString::null;
|
||||
|
||||
if (!actionAccel->text().isEmpty()) {
|
||||
macro->setAccel(actionAccel->text().toAscii());
|
||||
macro->setAccel(actionAccel->text().toAscii());
|
||||
}
|
||||
actionAccel->clear();
|
||||
|
||||
|
@ -329,9 +330,22 @@ void DlgCustomActionsImp::on_buttonReplaceAction_clicked()
|
|||
action->setToolTip(QString::fromUtf8(macro->getToolTipText()));
|
||||
action->setWhatsThis(QString::fromUtf8(macro->getWhatsThis()));
|
||||
action->setStatusTip(QString::fromUtf8(macro->getStatusTip()));
|
||||
if( macro->getPixmap() )
|
||||
if (macro->getPixmap())
|
||||
action->setIcon(Gui::BitmapFactory().pixmap(macro->getPixmap()));
|
||||
action->setShortcut(QString::fromAscii(macro->getAccel()));
|
||||
|
||||
QString accel = action->shortcut().toString(QKeySequence::NativeText);
|
||||
if (!accel.isEmpty()) {
|
||||
// show shortcut inside tooltip
|
||||
QString ttip = QString::fromLatin1("%1 (%2)")
|
||||
.arg(action->toolTip()).arg(accel);
|
||||
action->setToolTip(ttip);
|
||||
|
||||
// show shortcut inside status tip
|
||||
QString stip = QString::fromLatin1("(%1)\t%2")
|
||||
.arg(accel).arg(action->statusTip());
|
||||
action->setStatusTip(stip);
|
||||
}
|
||||
}
|
||||
|
||||
// emit signal to notify the container widget
|
||||
|
|
|
@ -198,11 +198,43 @@ void DlgCustomKeyboardImp::on_buttonAssign_clicked()
|
|||
CommandManager & cCmdMgr = Application::Instance->commandManager();
|
||||
Command* cmd = cCmdMgr.getCommandByName(name.constData());
|
||||
if (cmd && cmd->getAction()) {
|
||||
Action* action = cmd->getAction();
|
||||
QKeySequence shortcut = editShortcut->text();
|
||||
cmd->getAction()->setShortcut(shortcut);
|
||||
action->setShortcut(shortcut);
|
||||
accelLineEditShortcut->setText(editShortcut->text());
|
||||
editShortcut->clear();
|
||||
|
||||
// update the tool tip
|
||||
QString accel = shortcut.toString(QKeySequence::NativeText);
|
||||
QString toolTip = QCoreApplication::translate(cmd->className(),
|
||||
cmd->getToolTipText(), 0, QCoreApplication::UnicodeUTF8);
|
||||
if (!accel.isEmpty()) {
|
||||
if (!toolTip.isEmpty()) {
|
||||
QString tip = QString::fromLatin1("%1 (%2)")
|
||||
.arg(toolTip).arg(accel);
|
||||
action->setToolTip(tip);
|
||||
}
|
||||
}
|
||||
else {
|
||||
action->setToolTip(toolTip);
|
||||
}
|
||||
|
||||
// update the status tip
|
||||
QString statusTip = QCoreApplication::translate(cmd->className(),
|
||||
cmd->getStatusTip(), 0, QCoreApplication::UnicodeUTF8);
|
||||
if (statusTip.isEmpty())
|
||||
statusTip = toolTip;
|
||||
if (!accel.isEmpty()) {
|
||||
if (!statusTip.isEmpty()) {
|
||||
QString tip = QString::fromLatin1("(%1)\t%2")
|
||||
.arg(accel).arg(statusTip);
|
||||
action->setStatusTip(tip);
|
||||
}
|
||||
}
|
||||
else {
|
||||
action->setStatusTip(statusTip);
|
||||
}
|
||||
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Shortcut");
|
||||
hGrp->SetASCII(name.constData(), accelLineEditShortcut->text().toUtf8());
|
||||
buttonAssign->setEnabled(false);
|
||||
|
|
|
@ -118,7 +118,7 @@ Gui::Action * CmdDrawingNewPage::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* defaultAction = 0;
|
||||
int defaultId = 0;
|
||||
|
|
|
@ -355,7 +355,7 @@ Gui::Action * CmdRaytracingNewPovrayProject::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* defaultAction = 0;
|
||||
int defaultId = 0;
|
||||
|
@ -744,7 +744,7 @@ Gui::Action * CmdRaytracingNewLuxProject::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* defaultAction = 0;
|
||||
int defaultId = 0;
|
||||
|
|
|
@ -1560,7 +1560,7 @@ Gui::Action * CmdSketcherCompCreateArc::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* arc1 = pcAction->addAction(QString());
|
||||
arc1->setIcon(Gui::BitmapFactory().pixmapFromSvg("Sketcher_CreateArc", QSize(24,24)));
|
||||
|
@ -2036,7 +2036,7 @@ Gui::Action * CmdSketcherCompCreateCircle::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* arc1 = pcAction->addAction(QString());
|
||||
arc1->setIcon(Gui::BitmapFactory().pixmapFromSvg("Sketcher_CreateCircle", QSize(24,24)));
|
||||
|
@ -3466,7 +3466,7 @@ Gui::Action * CmdSketcherCompCreateRegularPolygon::createAction(void)
|
|||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* triangle = pcAction->addAction(QString());
|
||||
triangle->setIcon(Gui::BitmapFactory().pixmapFromSvg("Sketcher_CreateTriangle", QSize(24,24)));
|
||||
|
|
Loading…
Reference in New Issue
Block a user