mirror of
https://github.com/YACReader/yacreader
synced 2025-07-19 05:24:57 -04:00
Format code using clang-format
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#include "actions_groups_model.h"
|
||||
|
||||
ActionsGroupsModel::ActionsGroupsModel(QObject *parent) :
|
||||
QAbstractItemModel(parent)
|
||||
ActionsGroupsModel::ActionsGroupsModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -50,14 +50,14 @@ QModelIndex ActionsGroupsModel::parent(const QModelIndex &index) const
|
||||
|
||||
void ActionsGroupsModel::addActionsGroup(const ActionsGroup &group)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),groups.length(),groups.length());
|
||||
beginInsertRows(QModelIndex(), groups.length(), groups.length());
|
||||
groups.push_back(group);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
QList<QAction *> ActionsGroupsModel::getActions(const QModelIndex &mi)
|
||||
{
|
||||
if(mi.isValid())
|
||||
if (mi.isValid())
|
||||
return groups[mi.row()].getActions();
|
||||
return QList<QAction *>();
|
||||
}
|
||||
@ -65,9 +65,8 @@ QList<QAction *> ActionsGroupsModel::getActions(const QModelIndex &mi)
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
ActionsGroup::ActionsGroup(const QString &name, const QIcon &icon, QList<QAction *> &actions)
|
||||
:name(name), icon(icon), actions(actions)
|
||||
: name(name), icon(icon), actions(actions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString ActionsGroup::getName() const
|
||||
|
@ -9,10 +9,11 @@ class QAction;
|
||||
class ActionsGroup
|
||||
{
|
||||
public:
|
||||
ActionsGroup(const QString & name, const QIcon & icon, QList<QAction *> & actions);
|
||||
ActionsGroup(const QString &name, const QIcon &icon, QList<QAction *> &actions);
|
||||
QString getName() const;
|
||||
QIcon getIcon() const;
|
||||
QList<QAction *> getActions() const;
|
||||
|
||||
protected:
|
||||
QString name;
|
||||
QIcon icon;
|
||||
@ -31,8 +32,8 @@ public:
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
|
||||
void addActionsGroup(const ActionsGroup & group);
|
||||
QList<QAction *> getActions(const QModelIndex & mi);
|
||||
void addActionsGroup(const ActionsGroup &group);
|
||||
QList<QAction *> getActions(const QModelIndex &mi);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
@ -3,10 +3,9 @@
|
||||
|
||||
#include <QAction>
|
||||
|
||||
ActionsShortcutsModel::ActionsShortcutsModel(QObject *parent) :
|
||||
QAbstractItemModel(parent)
|
||||
ActionsShortcutsModel::ActionsShortcutsModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ActionsShortcutsModel::rowCount(const QModelIndex &parent) const
|
||||
@ -35,7 +34,7 @@ Qt::ItemFlags ActionsShortcutsModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
if(index.column() == KEYS)
|
||||
if (index.column() == KEYS)
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
@ -48,10 +47,8 @@ QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const
|
||||
if (role == Qt::DecorationRole && index.column() == ICON)
|
||||
return QVariant(actions[index.row()]->icon());
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
if (role == Qt::TextAlignmentRole) {
|
||||
switch (index.column()) {
|
||||
case ICON:
|
||||
return QVariant(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
case NAME:
|
||||
@ -61,7 +58,7 @@ QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
if(role == Qt::ForegroundRole && index.column() == KEYS && actions[index.row()]->shortcut().isEmpty())
|
||||
if (role == Qt::ForegroundRole && index.column() == KEYS && actions[index.row()]->shortcut().isEmpty())
|
||||
return QBrush(QColor("#AAAAAA"));
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
@ -69,10 +66,9 @@ QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (index.column() == NAME)
|
||||
return QVariant(actions[index.row()]->toolTip());
|
||||
if (index.column() == KEYS)
|
||||
{
|
||||
if (index.column() == KEYS) {
|
||||
QKeySequence ks = actions[index.row()]->shortcut();
|
||||
if(ks.isEmpty())
|
||||
if (ks.isEmpty())
|
||||
return tr("None");
|
||||
return QVariant(ks.toString(QKeySequence::NativeText));
|
||||
}
|
||||
@ -84,13 +80,11 @@ bool ActionsShortcutsModel::setData(const QModelIndex &index, const QVariant &va
|
||||
{
|
||||
Q_UNUSED(role);
|
||||
|
||||
if(index.column() == KEYS)
|
||||
{
|
||||
if (index.column() == KEYS) {
|
||||
ShortcutsManager sm = ShortcutsManager::getShortcutsManager();
|
||||
if(sm.checkConflicts(value.toString(), actions[index.row()]))
|
||||
if (sm.checkConflicts(value.toString(), actions[index.row()]))
|
||||
emit conflict(value.toString());
|
||||
else
|
||||
{
|
||||
else {
|
||||
actions[index.row()]->setShortcut(value.toString());
|
||||
ShortcutsManager::getShortcutsManager().saveShortcut(actions[index.row()]);
|
||||
return true;
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
void addActions(const QList<QAction *> actions);
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
|
||||
enum Columns {
|
||||
ICON = 0,
|
||||
NAME,
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include <QAction>
|
||||
|
||||
EditShortcutItemDelegate::EditShortcutItemDelegate(QObject *parent) :
|
||||
QItemDelegate(parent)
|
||||
EditShortcutItemDelegate::EditShortcutItemDelegate(QObject *parent)
|
||||
: QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ QWidget *EditShortcutItemDelegate::createEditor(QWidget *parent, const QStyleOpt
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(index);
|
||||
|
||||
KeySequenceLineEdit * editor = new KeySequenceLineEdit(parent);
|
||||
connect(editor,SIGNAL(editingFinished()),this,SLOT(closeShortcutEditor()));
|
||||
KeySequenceLineEdit *editor = new KeySequenceLineEdit(parent);
|
||||
connect(editor, SIGNAL(editingFinished()), this, SLOT(closeShortcutEditor()));
|
||||
return editor;
|
||||
}
|
||||
|
||||
@ -21,13 +21,13 @@ void EditShortcutItemDelegate::setEditorData(QWidget *editor, const QModelIndex
|
||||
{
|
||||
QString value = index.model()->data(index, Qt::DisplayRole).toString();
|
||||
|
||||
KeySequenceLineEdit * lineEdit = static_cast<KeySequenceLineEdit*>(editor);
|
||||
KeySequenceLineEdit *lineEdit = static_cast<KeySequenceLineEdit *>(editor);
|
||||
lineEdit->setText(value);
|
||||
}
|
||||
|
||||
void EditShortcutItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
KeySequenceLineEdit *lineEdit = static_cast<KeySequenceLineEdit*>(editor);
|
||||
KeySequenceLineEdit *lineEdit = static_cast<KeySequenceLineEdit *>(editor);
|
||||
|
||||
model->setData(index, lineEdit->text(), Qt::EditRole);
|
||||
}
|
||||
@ -36,25 +36,25 @@ void EditShortcutItemDelegate::updateEditorGeometry(QWidget *editor, const QStyl
|
||||
{
|
||||
Q_UNUSED(mi);
|
||||
|
||||
editor->setGeometry(option.rect);
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
bool EditShortcutItemDelegate::eventFilter(QObject* editor, QEvent* event)
|
||||
bool EditShortcutItemDelegate::eventFilter(QObject *editor, QEvent *event)
|
||||
{
|
||||
if(event->type()==QEvent::KeyPress)
|
||||
return false;
|
||||
return QItemDelegate::eventFilter(editor, event);
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
return false;
|
||||
return QItemDelegate::eventFilter(editor, event);
|
||||
}
|
||||
|
||||
void EditShortcutItemDelegate::closeShortcutEditor()
|
||||
{
|
||||
emit commitData(static_cast<QWidget *>(sender()));
|
||||
emit closeEditor(static_cast<QWidget *>(sender()),QAbstractItemDelegate::NoHint);
|
||||
emit closeEditor(static_cast<QWidget *>(sender()), QAbstractItemDelegate::NoHint);
|
||||
}
|
||||
|
||||
//TODO uncoment commented code for enabling concatenated shortcuts
|
||||
KeySequenceLineEdit::KeySequenceLineEdit(QWidget *parent)
|
||||
:QLineEdit(parent)//,numKeys(0)
|
||||
: QLineEdit(parent) //,numKeys(0)
|
||||
{
|
||||
//keys[0] = keys[1] = keys[2] = keys[3] = 0;
|
||||
setAlignment(Qt::AlignRight);
|
||||
@ -80,29 +80,27 @@ KeySequenceLineEdit::KeySequenceLineEdit(QWidget *parent)
|
||||
connect(acceptButton, SIGNAL(clicked()), this, SIGNAL(editingFinished()));
|
||||
}
|
||||
|
||||
void KeySequenceLineEdit::resizeEvent(QResizeEvent * e)
|
||||
void KeySequenceLineEdit::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QSize szClear = clearButton->sizeHint();
|
||||
//int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
int leftMargin = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
|
||||
//int topMargin = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
|
||||
clearButton->move(0 + leftMargin,(e->size().height()-19)/2); //16 is the icon height+1blank pixel
|
||||
|
||||
acceptButton->move( leftMargin + szClear.width(),(e->size().height()-19)/2);
|
||||
clearButton->move(0 + leftMargin, (e->size().height() - 19) / 2); //16 is the icon height+1blank pixel
|
||||
|
||||
acceptButton->move(leftMargin + szClear.width(), (e->size().height() - 19) / 2);
|
||||
}
|
||||
|
||||
void KeySequenceLineEdit::keyPressEvent(QKeyEvent * e)
|
||||
void KeySequenceLineEdit::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
int key = e->key();
|
||||
|
||||
|
||||
//if ( numKeys > 3 ||
|
||||
if ( key == Qt::Key_Control ||
|
||||
key == Qt::Key_Shift ||
|
||||
key == Qt::Key_Meta ||
|
||||
key == Qt::Key_Alt )
|
||||
return;
|
||||
if (key == Qt::Key_Control ||
|
||||
key == Qt::Key_Shift ||
|
||||
key == Qt::Key_Meta ||
|
||||
key == Qt::Key_Alt)
|
||||
return;
|
||||
|
||||
key |= translateModifiers(e->modifiers(), e->text());
|
||||
|
||||
@ -129,15 +127,12 @@ void KeySequenceLineEdit::keyPressEvent(QKeyEvent * e)
|
||||
}
|
||||
|
||||
int KeySequenceLineEdit::translateModifiers(Qt::KeyboardModifiers state,
|
||||
const QString &text)
|
||||
const QString &text)
|
||||
{
|
||||
int result = 0;
|
||||
// The shift modifier only counts when it is not used to type a symbol
|
||||
// that is only reachable using the shift key anyway
|
||||
if ((state & Qt::ShiftModifier) && (text.size() == 0
|
||||
|| !text.at(0).isPrint()
|
||||
|| text.at(0).isLetterOrNumber()
|
||||
|| text.at(0).isSpace()))
|
||||
if ((state & Qt::ShiftModifier) && (text.size() == 0 || !text.at(0).isPrint() || text.at(0).isLetterOrNumber() || text.at(0).isSpace()))
|
||||
result |= Qt::SHIFT;
|
||||
if (state & Qt::ControlModifier)
|
||||
result |= Qt::CTRL;
|
||||
@ -147,4 +142,3 @@ int KeySequenceLineEdit::translateModifiers(Qt::KeyboardModifiers state,
|
||||
result |= Qt::ALT;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,12 @@ public:
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const;
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & mi) const;
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &mi) const;
|
||||
bool eventFilter(QObject *editor, QEvent *event);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void closeShortcutEditor();
|
||||
|
||||
};
|
||||
|
||||
#endif // EDIT_SHORTCUT_ITEM_DELEGATE_H
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
EditShortcutsDialog::EditShortcutsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QPushButton * resetButton = new QPushButton(tr("Restore defaults"),this);
|
||||
QLabel * infoLabel = new QLabel(tr("To change a shortcut, double click in the key combination and type the new keys."));
|
||||
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||
QSplitter * splitter = new QSplitter(this);
|
||||
QPushButton *resetButton = new QPushButton(tr("Restore defaults"), this);
|
||||
QLabel *infoLabel = new QLabel(tr("To change a shortcut, double click in the key combination and type the new keys."));
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
QSplitter *splitter = new QSplitter(this);
|
||||
actionsGroupsListView = new QListView(this);
|
||||
|
||||
actionsTableView = new QTableView(this);
|
||||
@ -29,12 +29,12 @@ EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
actionsTableView->horizontalHeader()->setHidden(true);
|
||||
splitter->addWidget(actionsGroupsListView);
|
||||
splitter->addWidget(actionsTableView);
|
||||
splitter->setStretchFactor(1,1);
|
||||
splitter->setStretchFactor(1, 1);
|
||||
splitter->setSizes(QList<int>() << 200 << 400);
|
||||
|
||||
layout->addWidget(infoLabel,0);
|
||||
layout->addWidget(splitter,1);
|
||||
layout->addWidget(resetButton,0,Qt::AlignRight);
|
||||
layout->addWidget(infoLabel, 0);
|
||||
layout->addWidget(splitter, 1);
|
||||
layout->addWidget(resetButton, 0, Qt::AlignRight);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
@ -43,13 +43,13 @@ EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
actionsGroupsListView->setModel(groupsModel);
|
||||
actionsGroupsListView->setFocus();
|
||||
actionsTableView->setModel(actionsModel);
|
||||
actionsTableView->setColumnWidth(0,30);
|
||||
actionsTableView->setColumnWidth(1,360);
|
||||
actionsTableView->setColumnWidth(0, 30);
|
||||
actionsTableView->setColumnWidth(1, 360);
|
||||
//actionsTableView->horizontalHeader()->sectionResizeMode(QHeaderView::Custom);
|
||||
actionsTableView->horizontalHeader()->setStretchLastSection(true);
|
||||
actionsTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
actionsTableView->setShowGrid(false);
|
||||
actionsTableView->setItemDelegateForColumn(ActionsShortcutsModel::KEYS,new EditShortcutItemDelegate(this));
|
||||
actionsTableView->setItemDelegateForColumn(ActionsShortcutsModel::KEYS, new EditShortcutItemDelegate(this));
|
||||
actionsTableView->installEventFilter(this);
|
||||
/*actionsTableView->setStyleSheet("QTableView {outline: 0px;}"
|
||||
"QTableView::item {outline: 0px;}");
|
||||
@ -57,15 +57,14 @@ EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
"QTableView::item:selected {outline: 0px; border: 0px;}"
|
||||
"");*/
|
||||
|
||||
|
||||
connect(resetButton,SIGNAL(clicked()),this,SLOT(resetToDefaults()));
|
||||
connect(actionsGroupsListView->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(loadShortcuts(QModelIndex,QModelIndex))); //clicked(QModelIndex) doesn't work :S
|
||||
connect(actionsModel,SIGNAL(conflict(QString)),this,SLOT(processConflict(QString)));
|
||||
connect(resetButton, SIGNAL(clicked()), this, SLOT(resetToDefaults()));
|
||||
connect(actionsGroupsListView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(loadShortcuts(QModelIndex, QModelIndex))); //clicked(QModelIndex) doesn't work :S
|
||||
connect(actionsModel, SIGNAL(conflict(QString)), this, SLOT(processConflict(QString)));
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
setFixedSize(760,500);
|
||||
setFixedSize(760, 500);
|
||||
#else
|
||||
setFixedSize(804,500); //extra width for modifiers
|
||||
setFixedSize(804, 500); //extra width for modifiers
|
||||
#endif
|
||||
setWindowTitle(tr("Shortcuts settings"));
|
||||
|
||||
@ -74,17 +73,16 @@ EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||
|
||||
void EditShortcutsDialog::addActionsGroup(const QString &name, const QIcon &ico, QList<QAction *> &group)
|
||||
{
|
||||
groupsModel->addActionsGroup(ActionsGroup(name,ico,group));
|
||||
if(actionsTableView->model()->rowCount()==0)//first group added
|
||||
actionsGroupsListView->selectionModel()->select(groupsModel->index(0,0),QItemSelectionModel::Select);
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EditShortcutsDialog::loadShortcuts(const QModelIndex &mi,const QModelIndex &mi2)
|
||||
void EditShortcutsDialog::loadShortcuts(const QModelIndex &mi, const QModelIndex &mi2)
|
||||
{
|
||||
Q_UNUSED(mi2);
|
||||
|
||||
@ -93,5 +91,5 @@ void EditShortcutsDialog::loadShortcuts(const QModelIndex &mi,const QModelIndex
|
||||
|
||||
void EditShortcutsDialog::processConflict(const QString &shortcutInConflict)
|
||||
{
|
||||
QMessageBox::warning(this,tr("Shortcut in use"), QString(tr("The shortcut \"%1\" is already assigned to other function")).arg(shortcutInConflict));
|
||||
QMessageBox::warning(this, tr("Shortcut in use"), QString(tr("The shortcut \"%1\" is already assigned to other function")).arg(shortcutInConflict));
|
||||
}
|
||||
|
@ -14,20 +14,20 @@ class EditShortcutsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditShortcutsDialog(QWidget * parent = 0);
|
||||
void addActionsGroup(const QString & name, const QIcon & ico, QList<QAction *> & group);
|
||||
explicit EditShortcutsDialog(QWidget *parent = 0);
|
||||
void addActionsGroup(const QString &name, const QIcon &ico, QList<QAction *> &group);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void resetToDefaults();
|
||||
void loadShortcuts(const QModelIndex & mi,const QModelIndex &mi2);
|
||||
void processConflict(const QString & shortcutInConflict);
|
||||
void loadShortcuts(const QModelIndex &mi, const QModelIndex &mi2);
|
||||
void processConflict(const QString &shortcutInConflict);
|
||||
|
||||
protected:
|
||||
QListView * actionsGroupsListView;
|
||||
QTableView * actionsTableView;
|
||||
ActionsGroupsModel * groupsModel;
|
||||
ActionsShortcutsModel * actionsModel;
|
||||
QListView *actionsGroupsListView;
|
||||
QTableView *actionsTableView;
|
||||
ActionsGroupsModel *groupsModel;
|
||||
ActionsShortcutsModel *actionsModel;
|
||||
};
|
||||
|
||||
#endif // EDIT_SHORTCUTS_DIALOG_H
|
||||
|
@ -13,20 +13,20 @@ void ShortcutsManager::initDefaultShorcuts()
|
||||
{
|
||||
#ifdef YACREADER_LIBRARY
|
||||
//ACTIONS
|
||||
defaultShorcuts.insert(CREATE_LIBRARY_ACTION_YL,Qt::Key_A);
|
||||
defaultShorcuts.insert(OPEN_LIBRARY_ACTION_YL,Qt::Key_O);
|
||||
defaultShorcuts.insert(UPDATE_LIBRARY_ACTION_YL,Qt::Key_U);
|
||||
defaultShorcuts.insert(RENAME_LIBRARY_ACTION_YL,Qt::Key_R);
|
||||
defaultShorcuts.insert(OPEN_COMIC_ACTION_YL,Qt::Key_Return);
|
||||
defaultShorcuts.insert(SHOW_HIDE_MARKS_ACTION_YL,Qt::Key_M);
|
||||
defaultShorcuts.insert(TOGGLE_FULL_SCREEN_ACTION_YL,Qt::Key_F);
|
||||
defaultShorcuts.insert(HELP_ABOUT_ACTION_YL,Qt::Key_F1);
|
||||
defaultShorcuts.insert(SET_ROOT_INDEX_ACTION_YL,Qt::Key_0);
|
||||
defaultShorcuts.insert(EXPAND_ALL_NODES_ACTION_YL,Qt::Key_Plus);
|
||||
defaultShorcuts.insert(COLAPSE_ALL_NODES_ACTION_YL,Qt::Key_Minus);
|
||||
defaultShorcuts.insert(OPTIONS_ACTION_YL,Qt::Key_C);
|
||||
defaultShorcuts.insert(SERVER_CONFIG_ACTION_YL,Qt::Key_S);
|
||||
defaultShorcuts.insert(TOGGLE_COMICS_VIEW_ACTION_YL,Qt::Key_V);
|
||||
defaultShorcuts.insert(CREATE_LIBRARY_ACTION_YL, Qt::Key_A);
|
||||
defaultShorcuts.insert(OPEN_LIBRARY_ACTION_YL, Qt::Key_O);
|
||||
defaultShorcuts.insert(UPDATE_LIBRARY_ACTION_YL, Qt::Key_U);
|
||||
defaultShorcuts.insert(RENAME_LIBRARY_ACTION_YL, Qt::Key_R);
|
||||
defaultShorcuts.insert(OPEN_COMIC_ACTION_YL, Qt::Key_Return);
|
||||
defaultShorcuts.insert(SHOW_HIDE_MARKS_ACTION_YL, Qt::Key_M);
|
||||
defaultShorcuts.insert(TOGGLE_FULL_SCREEN_ACTION_YL, Qt::Key_F);
|
||||
defaultShorcuts.insert(HELP_ABOUT_ACTION_YL, Qt::Key_F1);
|
||||
defaultShorcuts.insert(SET_ROOT_INDEX_ACTION_YL, Qt::Key_0);
|
||||
defaultShorcuts.insert(EXPAND_ALL_NODES_ACTION_YL, Qt::Key_Plus);
|
||||
defaultShorcuts.insert(COLAPSE_ALL_NODES_ACTION_YL, Qt::Key_Minus);
|
||||
defaultShorcuts.insert(OPTIONS_ACTION_YL, Qt::Key_C);
|
||||
defaultShorcuts.insert(SERVER_CONFIG_ACTION_YL, Qt::Key_S);
|
||||
defaultShorcuts.insert(TOGGLE_COMICS_VIEW_ACTION_YL, Qt::Key_V);
|
||||
|
||||
//COMMANDS (used in keypressevent)
|
||||
#else
|
||||
@ -75,7 +75,6 @@ void ShortcutsManager::initDefaultShorcuts()
|
||||
defaultShorcuts.insert(ZOOM_OUT_MGLASS_ACTION_Y, Qt::Key_Underscore);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void ShortcutsManager::resetToDefaults()
|
||||
@ -90,10 +89,10 @@ QString ShortcutsManager::getShortcut(const QString &name)
|
||||
#else
|
||||
QString filePath = "/YACReaderLibrary.ini";
|
||||
#endif
|
||||
QSettings s(YACReader::getSettingsPath()+filePath,QSettings::IniFormat);
|
||||
QSettings s(YACReader::getSettingsPath() + filePath, QSettings::IniFormat);
|
||||
s.beginGroup("shortcuts");
|
||||
|
||||
return s.value(name,defaultShorcuts.value(name)).toString();
|
||||
return s.value(name, defaultShorcuts.value(name)).toString();
|
||||
}
|
||||
|
||||
void ShortcutsManager::saveShortcut(QAction *action)
|
||||
@ -103,10 +102,10 @@ void ShortcutsManager::saveShortcut(QAction *action)
|
||||
#else
|
||||
QString filePath = "/YACReaderLibrary.ini";
|
||||
#endif
|
||||
QSettings s(YACReader::getSettingsPath()+filePath,QSettings::IniFormat);
|
||||
QSettings s(YACReader::getSettingsPath() + filePath, QSettings::IniFormat);
|
||||
s.beginGroup("shortcuts");
|
||||
|
||||
return s.setValue(action->data().toString() , action->shortcut().toString());
|
||||
return s.setValue(action->data().toString(), action->shortcut().toString());
|
||||
}
|
||||
|
||||
void ShortcutsManager::registerActions(const QList<QAction *> &a)
|
||||
@ -114,15 +113,14 @@ void ShortcutsManager::registerActions(const QList<QAction *> &a)
|
||||
actions = a;
|
||||
}
|
||||
|
||||
bool ShortcutsManager::checkConflicts(const QKeySequence & shortcut, const QAction *dest)
|
||||
bool ShortcutsManager::checkConflicts(const QKeySequence &shortcut, const QAction *dest)
|
||||
{
|
||||
if(shortcut.isEmpty())
|
||||
if (shortcut.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach(QAction * action, actions)
|
||||
{
|
||||
if(action != dest) //if the same shortcut is setted there is no conflict
|
||||
if(action->shortcut() == shortcut)
|
||||
foreach (QAction *action, actions) {
|
||||
if (action != dest) //if the same shortcut is setted there is no conflict
|
||||
if (action->shortcut() == shortcut)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
class QAction;
|
||||
|
||||
//QAction: used setData() and data() for storing (userData) an identifier for each QAction. This value is ussed in QSettings
|
||||
@ -15,21 +14,22 @@ class ShortcutsManager
|
||||
{
|
||||
private:
|
||||
ShortcutsManager();
|
||||
QMap<QString,QKeySequence> defaultShorcuts;
|
||||
QMap<QString, QKeySequence> defaultShorcuts;
|
||||
QList<QAction *> actions; //all actions registered, used for checking conflicts
|
||||
|
||||
void initDefaultShorcuts();
|
||||
|
||||
public:
|
||||
static ShortcutsManager & getShortcutsManager()
|
||||
static ShortcutsManager &getShortcutsManager()
|
||||
{
|
||||
static ShortcutsManager manager;
|
||||
return manager;
|
||||
}
|
||||
|
||||
void resetToDefaults();
|
||||
QString getShortcut(const QString & name);
|
||||
void saveShortcut(QAction * action);
|
||||
void registerActions(const QList<QAction *> & actions);
|
||||
QString getShortcut(const QString &name);
|
||||
void saveShortcut(QAction *action);
|
||||
void registerActions(const QList<QAction *> &actions);
|
||||
bool checkConflicts(const QKeySequence &shortcut, const QAction *dest);
|
||||
};
|
||||
|
||||
@ -83,7 +83,6 @@ public:
|
||||
#define SAVE_COVERS_TO_ACTION_YL "SAVE_COVERS_TO_ACTION_YL"
|
||||
//COMMANDS YACReaderLibrary
|
||||
|
||||
|
||||
//ACTION NAMES YACReader
|
||||
#define OPEN_ACTION_Y "OPEN_ACTION_Y"
|
||||
#define OPEN_FOLDER_ACTION_Y "OPEN_FOLDER_ACTION_Y"
|
||||
|
Reference in New Issue
Block a user