mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
keep focus in VFileList once click an item
This commit is contained in:
parent
06cac36412
commit
d630ff7bf2
@ -611,21 +611,28 @@ QListWidgetItem* VFileList::findItem(const VNoteFile *p_file)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::handleItemClicked(QListWidgetItem *currentItem)
|
void VFileList::handleItemClicked(QListWidgetItem *p_item)
|
||||||
|
{
|
||||||
|
activateItem(p_item);
|
||||||
|
|
||||||
|
fileList->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VFileList::activateItem(QListWidgetItem *p_item)
|
||||||
{
|
{
|
||||||
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
||||||
if (modifiers != Qt::NoModifier) {
|
if (modifiers != Qt::NoModifier) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentItem) {
|
if (!p_item) {
|
||||||
emit fileClicked(NULL);
|
emit fileClicked(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qt seems not to update the QListWidget correctly. Manually force it to repaint.
|
// Qt seems not to update the QListWidget correctly. Manually force it to repaint.
|
||||||
fileList->update();
|
fileList->update();
|
||||||
emit fileClicked(getVFile(currentItem), g_config->getNoteOpenMode());
|
emit fileClicked(getVFile(p_item), g_config->getNoteOpenMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VFileList::importFiles(const QStringList &p_files, QString *p_errMsg)
|
bool VFileList::importFiles(const QStringList &p_files, QString *p_errMsg)
|
||||||
@ -852,7 +859,7 @@ void VFileList::keyPressEvent(QKeyEvent *p_event)
|
|||||||
if (p_event->key() == Qt::Key_Return) {
|
if (p_event->key() == Qt::Key_Return) {
|
||||||
QListWidgetItem *item = fileList->currentItem();
|
QListWidgetItem *item = fileList->currentItem();
|
||||||
if (item) {
|
if (item) {
|
||||||
handleItemClicked(item);
|
activateItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,8 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void contextMenuRequested(QPoint pos);
|
void contextMenuRequested(QPoint pos);
|
||||||
void handleItemClicked(QListWidgetItem *currentItem);
|
|
||||||
|
void handleItemClicked(QListWidgetItem *p_item);
|
||||||
|
|
||||||
// View and edit information of selected file.
|
// View and edit information of selected file.
|
||||||
// Valid only when there is only one selected file.
|
// Valid only when there is only one selected file.
|
||||||
@ -161,6 +162,8 @@ private:
|
|||||||
// Init Open With menu.
|
// Init Open With menu.
|
||||||
void initOpenWithMenu();
|
void initOpenWithMenu();
|
||||||
|
|
||||||
|
void activateItem(QListWidgetItem *p_item);
|
||||||
|
|
||||||
VEditArea *editArea;
|
VEditArea *editArea;
|
||||||
QListWidget *fileList;
|
QListWidget *fileList;
|
||||||
QPointer<VDirectory> m_directory;
|
QPointer<VDirectory> m_directory;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user