add notebooknodeexplorer shortcut copy paste (#2088)

* add notebooknodeexplorer shortcut copy paste

* simplify code and add isActionFromMaster function

* add const

* adj ann

* adj return
This commit is contained in:
chendapao 2022-04-06 12:45:16 +08:00 committed by GitHub
parent bbab5cc223
commit 0cadea231a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 6 deletions

View File

@ -69,6 +69,8 @@ namespace vnotex
MoveOneSplitRight,
OpenLastClosedFile,
UnitedEntry,
Copy,
Paste,
MaxShortcut
};
Q_ENUM(Shortcut)

View File

@ -60,7 +60,9 @@
"MoveOneSplitUp" : "Ctrl+G, Shift+K",
"MoveOneSplitRight" : "Ctrl+G, Shift+L",
"OpenLastClosedFile" : "Ctrl+Shift+T",
"UnitedEntry" : "Ctrl+G, G"
"UnitedEntry" : "Ctrl+G, G",
"Copy" : "Ctrl+C",
"Paste" : "Ctrl+V"
},
"file_type_suffixes" : [
{

View File

@ -2163,6 +2163,15 @@ void NotebookNodeExplorer::addOpenWithMenu(QMenu *p_menu, bool p_master)
});
}
// Shortcut auxiliary, it can also be used to determine the browser.
bool NotebookNodeExplorer::isActionFromMaster() const
{
if (!isCombinedExploreMode()) {
return m_masterExplorer->hasFocus();
}
return true;
}
void NotebookNodeExplorer::setupShortcuts()
{
const auto &coreConfig = ConfigMgr::getInst().getCoreConfig();
@ -2173,15 +2182,31 @@ void NotebookNodeExplorer::setupShortcuts()
if (shortcut) {
connect(shortcut, &QShortcut::activated,
this, [this]() {
bool isMaster = true;
if (!isCombinedExploreMode()) {
isMaster = m_masterExplorer->hasFocus();
}
openSelectedNodesWithProgram(QString(), isMaster);
openSelectedNodesWithProgram(QString(), isActionFromMaster());
});
}
}
// Copy
{
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::Copy), this);
if (shortcut) {
connect(shortcut, &QShortcut::activated,
this, [this]() {
copySelectedNodes(false, isActionFromMaster());
});
}
}
// Paste
{
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::Paste), this);
if (shortcut) {
connect(shortcut, &QShortcut::activated,
this, &NotebookNodeExplorer::pasteNodesFromClipboard);
}
}
const auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
for (const auto &pro : sessionConfig.getExternalPrograms()) {
auto shortcut = WidgetUtils::createShortcut(pro.m_shortcut, this);

View File

@ -176,6 +176,8 @@ namespace vnotex
void setupUI();
bool isActionFromMaster() const;
void setupShortcuts();
void setupMasterExplorer(QWidget *p_parent = nullptr);