Skip to content

Commit

Permalink
refactor: [shortcut] Refactor the shortcut settings view
Browse files Browse the repository at this point in the history
as title

Log: code refactor
  • Loading branch information
Kakueeen committed Aug 22, 2024
1 parent fd5597f commit 5d2e381
Show file tree
Hide file tree
Showing 23 changed files with 1,105 additions and 411 deletions.
4 changes: 2 additions & 2 deletions src/common/actionmanager/actionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void ActionManagerPrivate::saveSettings(Command *cmd)
settings.setValue(settingsKey, keys.first().toString());
} else {
QStringList shortcutList;
std::transform(keys.begin(), keys.end(), shortcutList.begin(),
std::transform(keys.begin(), keys.end(), std::back_inserter(shortcutList),
[](const QKeySequence &k) {
return k.toString();
});
Expand All @@ -142,7 +142,7 @@ void ActionManagerPrivate::readUserSettings(const QString &id, Command *cmd)
if (QMetaType::Type(v.type()) == QMetaType::QStringList) {
auto list = v.toStringList();
QList<QKeySequence> keySequenceList;
std::transform(list.begin(), list.end(), keySequenceList.begin(),
std::transform(list.begin(), list.end(), std::back_inserter(keySequenceList),
[](const QString &s) {
return QKeySequence::fromString(s);
});
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/binarytools/configure/binarytoolsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ void BinaryToolsManager::updateToolMenu(const BinaryTools &tools)

for (const auto &tool : iter.value()) {
auto act = new QAction(QIcon::fromTheme(tool.icon), tool.name, mGroup);
auto cmd = ActionManager::instance()->registerAction(act, tool.id);
auto actId = QString("BinaryTools.Tool.%1").arg(tool.id);
auto cmd = ActionManager::instance()->registerAction(act, actId);
mGroup->addAction(cmd);

connect(act, &QAction::triggered, this, std::bind(&BinaryToolsManager::executeTool, this, tool.id));
Expand Down Expand Up @@ -578,7 +579,8 @@ void BinaryToolsManager::addToToolBar(const ToolInfo &tool)
act->setIcon(QIcon::fromTheme(tool.icon));
connect(act, &QAction::triggered, this, std::bind(&BinaryToolsManager::executeTool, this, tool.id));

auto cmd = ActionManager::instance()->registerAction(act, tool.id);
auto actId = QString("BinaryTools.Tool.%1").arg(tool.id);
auto cmd = ActionManager::instance()->registerAction(act, actId);
return cmd;
};

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/codeeditor/gui/workspacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void WorkspaceWidgetPrivate::initActions()

// show opened files
QAction *showOpenedAction = new QAction(tr("Show opened files"), q);
cmd = ActionManager::instance()->registerAction(commentAction, "Editor.ShowOpenedFiles");
cmd = ActionManager::instance()->registerAction(showOpenedAction, "Editor.ShowOpenedFiles");
cmd->setDefaultKeySequence(Qt::CTRL | Qt::Key_Tab);
connect(showOpenedAction, &QAction::triggered, this, &WorkspaceWidgetPrivate::handleShowOpenedFiles);
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/debugger/interface/menumanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ void MenuManager::initialize(WindowService *windowService)
QKeySequence key, const QString &iconName = {}) -> Command * {
action->setIcon(QIcon::fromTheme(iconName));
auto cmd = ActionManager::instance()->registerAction(action, id);
cmd->setDefaultKeySequence(key);
cmd->setDescription(description);
if (!key.isEmpty())
cmd->setDefaultKeySequence(key);
return cmd;
};

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/git/utils/gitmenumanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ void GitMenuManager::createFileSubMenu()
{
auto mCurFile = ActionManager::instance()->actionContainer(M_GIT_FILE);
auto fileLogAct = new QAction(this);
auto cmd = registerShortcut(fileLogAct, A_GIT_LOG_FILE, tr("Git Log"), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_L));
auto cmd = registerShortcut(fileLogAct, A_GIT_LOG_FILE, tr("Git Log"), QKeySequence("Alt+G,Alt+L"));
mCurFile->addAction(cmd);
connect(fileLogAct, &QAction::triggered, this, std::bind(&GitMenuManager::actionHandler, this, cmd, GitLog));

auto fileBlameAct = new QAction(this);
cmd = registerShortcut(fileBlameAct, A_GIT_BLAME_FILE, tr("Git Blame"), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_B));
cmd = registerShortcut(fileBlameAct, A_GIT_BLAME_FILE, tr("Git Blame"), QKeySequence("Alt+G,Alt+B"));
mCurFile->addAction(cmd);
connect(fileBlameAct, &QAction::triggered, this, std::bind(&GitMenuManager::actionHandler, this, cmd, GitBlame));

auto fileDiffAct = new QAction(this);
cmd = registerShortcut(fileDiffAct, A_GIT_DIFF_FILE, tr("Git Diff"), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_D));
cmd = registerShortcut(fileDiffAct, A_GIT_DIFF_FILE, tr("Git Diff"), QKeySequence("Alt+G,Alt+D"));
mCurFile->addAction(cmd);
connect(fileDiffAct, &QAction::triggered, this, std::bind(&GitMenuManager::actionHandler, this, cmd, GitDiff));
}
Expand Down
44 changes: 10 additions & 34 deletions src/plugins/option/optioncore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,19 @@ project(optioncore)

find_package(Qt5 COMPONENTS Xml REQUIRED)

set(CXX_CPP

mainframe/shortcutsettingwidget.cpp
mainframe/persistentsettings.cpp
mainframe/optionsdialog.cpp
mainframe/optiondefaultkeeper.cpp
mainframe/profilesettingwidget.cpp

mainframe/optionprofilesettinggenerator.cpp
mainframe/optionshortcutsettinggenerator.cpp
mainframe/navigationdelegate.cpp
mainframe/shortcutedit.cpp
optioncore.cpp
optioncore.json
)

set(CXX_H

mainframe/shortcutsettingwidget.h
mainframe/persistentsettings.h
mainframe/optionsdialog.h
mainframe/optiondefaultkeeper.h
mainframe/profilesettingwidget.h

mainframe/optionprofilesettinggenerator.h
mainframe/optionshortcutsettinggenerator.h
mainframe/navigationdelegate.h
mainframe/shortcutedit.h
optioncore.h
)
FILE(GLOB_RECURSE PROJECT_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*.json"
)

add_library(${PROJECT_NAME}
SHARED
${CXX_CPP}
${CXX_H}
${PROJECT_SOURCES}
optioncore.qrc
)
)

target_link_libraries(${PROJECT_NAME}
framework
Expand All @@ -50,6 +26,6 @@ target_link_libraries(${PROJECT_NAME}
${QtUseModules}
${PkgUserModules}
Qt5::Xml
)
)

install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
151 changes: 151 additions & 0 deletions src/plugins/option/optioncore/icons/shortcut_group_128px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5d2e381

Please sign in to comment.