mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 07:24:58 -04:00
added default value for empty shortcuts "None"
autoload the actions in the first actions groups added to edit shortcuts dialog
This commit is contained in:
@ -57,13 +57,21 @@ QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
if(role == Qt::ForegroundRole && index.column() == KEYS && actions[index.row()]->shortcut().isEmpty())
|
||||
return QBrush(QColor("#AAAAAA"));
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (index.column() == NAME)
|
||||
return QVariant(actions[index.row()]->toolTip());
|
||||
if (index.column() == KEYS)
|
||||
return QVariant(actions[index.row()]->shortcut().toString(QKeySequence::NativeText));
|
||||
{
|
||||
QKeySequence ks = actions[index.row()]->shortcut();
|
||||
if(ks.isEmpty())
|
||||
return tr("None");
|
||||
return QVariant(ks.toString(QKeySequence::NativeText));
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
groupsModel = new ActionsGroupsModel();
|
||||
actionsModel = new ActionsShortcutsModel();
|
||||
actionsGroupsListView->setModel(groupsModel);
|
||||
actionsGroupsListView->setFocus();
|
||||
actionsTableView->setModel(actionsModel);
|
||||
actionsTableView->setColumnWidth(0,30);
|
||||
actionsTableView->setColumnWidth(1,360);
|
||||
@ -71,9 +72,9 @@ EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
|
||||
void EditShortcutsDialog::addActionsGroup(const QString &name, const QIcon &ico, QList<QAction *> &group)
|
||||
{
|
||||
//TODO
|
||||
//groups model add
|
||||
groupsModel->addActionsGroup(ActionsGroup(name,ico,group));
|
||||
if(actionsTableView->model()->rowCount()==0)//first group added
|
||||
actionsGroupsListView->selectionModel()->select(groupsModel->index(0,0),QItemSelectionModel::Select);
|
||||
}
|
||||
|
||||
void EditShortcutsDialog::resetToDefaults()
|
||||
@ -84,5 +85,4 @@ void EditShortcutsDialog::resetToDefaults()
|
||||
void EditShortcutsDialog::loadShortcuts(const QModelIndex &mi,const QModelIndex &mi2)
|
||||
{
|
||||
actionsModel->addActions(groupsModel->getActions(mi));
|
||||
//actionsTableView->resizeColumnsToContents();
|
||||
}
|
||||
|
Reference in New Issue
Block a user