mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
add notebooknodeexplorer shortcut properties (#2094)
* impl properties * repeat logic merge to function * code format * properties only 1 node * change function name
This commit is contained in:
parent
0cadea231a
commit
09789590a2
@ -71,6 +71,7 @@ namespace vnotex
|
|||||||
UnitedEntry,
|
UnitedEntry,
|
||||||
Copy,
|
Copy,
|
||||||
Paste,
|
Paste,
|
||||||
|
Properties,
|
||||||
MaxShortcut
|
MaxShortcut
|
||||||
};
|
};
|
||||||
Q_ENUM(Shortcut)
|
Q_ENUM(Shortcut)
|
||||||
|
@ -62,7 +62,8 @@
|
|||||||
"OpenLastClosedFile" : "Ctrl+Shift+T",
|
"OpenLastClosedFile" : "Ctrl+Shift+T",
|
||||||
"UnitedEntry" : "Ctrl+G, G",
|
"UnitedEntry" : "Ctrl+G, G",
|
||||||
"Copy" : "Ctrl+C",
|
"Copy" : "Ctrl+C",
|
||||||
"Paste" : "Ctrl+V"
|
"Paste" : "Ctrl+V",
|
||||||
|
"Properties" : "F2"
|
||||||
},
|
},
|
||||||
"file_type_suffixes" : [
|
"file_type_suffixes" : [
|
||||||
{
|
{
|
||||||
|
@ -1088,23 +1088,7 @@ QAction *NotebookNodeExplorer::createAction(Action p_act, QObject *p_parent, boo
|
|||||||
p_parent);
|
p_parent);
|
||||||
connect(act, &QAction::triggered,
|
connect(act, &QAction::triggered,
|
||||||
this, [this, p_master]() {
|
this, [this, p_master]() {
|
||||||
auto node = p_master ? getCurrentMasterNode() : getCurrentSlaveNode();
|
openCurrentNodeProperties(p_master);
|
||||||
if (checkInvalidNode(node)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = QDialog::Rejected;
|
|
||||||
if (node->hasContent()) {
|
|
||||||
NotePropertiesDialog dialog(node, VNoteX::getInst().getMainWindow());
|
|
||||||
ret = dialog.exec();
|
|
||||||
} else {
|
|
||||||
FolderPropertiesDialog dialog(node, VNoteX::getInst().getMainWindow());
|
|
||||||
ret = dialog.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == QDialog::Accepted) {
|
|
||||||
setCurrentNode(node);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2207,6 +2191,17 @@ void NotebookNodeExplorer::setupShortcuts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::Properties), this);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
openCurrentNodeProperties(isActionFromMaster());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
const auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
for (const auto &pro : sessionConfig.getExternalPrograms()) {
|
for (const auto &pro : sessionConfig.getExternalPrograms()) {
|
||||||
auto shortcut = WidgetUtils::createShortcut(pro.m_shortcut, this);
|
auto shortcut = WidgetUtils::createShortcut(pro.m_shortcut, this);
|
||||||
@ -2251,6 +2246,29 @@ void NotebookNodeExplorer::openSelectedNodesWithProgram(const QString &p_name, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotebookNodeExplorer::openCurrentNodeProperties(bool p_master)
|
||||||
|
{
|
||||||
|
const int selectedSize = p_master ? m_masterExplorer->selectedItems().size() : m_slaveExplorer->selectedItems().size();
|
||||||
|
if (selectedSize != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto node = p_master ? getCurrentMasterNode() : getCurrentSlaveNode();
|
||||||
|
if (checkInvalidNode(node)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int ret = QDialog::Rejected;
|
||||||
|
if (node->hasContent()) {
|
||||||
|
NotePropertiesDialog dialog(node, VNoteX::getInst().getMainWindow());
|
||||||
|
ret = dialog.exec();
|
||||||
|
} else {
|
||||||
|
FolderPropertiesDialog dialog(node, VNoteX::getInst().getMainWindow());
|
||||||
|
ret = dialog.exec();
|
||||||
|
}
|
||||||
|
if (ret == QDialog::Accepted) {
|
||||||
|
setCurrentNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotebookNodeExplorer::loadMasterItemChildren(QTreeWidgetItem *p_item) const
|
void NotebookNodeExplorer::loadMasterItemChildren(QTreeWidgetItem *p_item) const
|
||||||
{
|
{
|
||||||
auto cnt = p_item->childCount();
|
auto cnt = p_item->childCount();
|
||||||
|
@ -301,6 +301,8 @@ namespace vnotex
|
|||||||
|
|
||||||
void openSelectedNodesWithProgram(const QString &p_name, bool p_master);
|
void openSelectedNodesWithProgram(const QString &p_name, bool p_master);
|
||||||
|
|
||||||
|
void openCurrentNodeProperties(bool p_master);
|
||||||
|
|
||||||
bool belongsToMasterExplorer(const Node *p_node) const;
|
bool belongsToMasterExplorer(const Node *p_node) const;
|
||||||
|
|
||||||
bool belongsToMasterExplorer(const ExternalNode *p_node) const;
|
bool belongsToMasterExplorer(const ExternalNode *p_node) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user