Explorer: add Up button to go up to parent directory

This commit is contained in:
Le Tan 2018-07-18 20:05:45 +08:00
parent 2ae742cc07
commit 1c7e91d26d
5 changed files with 35 additions and 1 deletions

View File

@ -4,7 +4,7 @@
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
<g>
<path d="M177.3,76.95v111c0,6.8,5.5,12.3,12.3,12.3h43.2v33.4h-165c-6.8,0-12.3,5.5-12.3,12.3v43.9H12.3
<path style="fill:#000000" d="M177.3,76.95v111c0,6.8,5.5,12.3,12.3,12.3h43.2v33.4h-165c-6.8,0-12.3,5.5-12.3,12.3v43.9H12.3
c-6.8,0-12.3,5.5-12.3,12.3v111c0,6.8,5.5,12.3,12.3,12.3h111c6.8,0,12.3-5.5,12.3-12.3v-111c0-6.8-5.5-12.3-12.3-12.3H80v-31.7
h152.7v31.7h-43.2c-6.8,0-12.3,5.5-12.3,12.3v111c0,6.8,5.5,12.3,12.3,12.3h111c6.8,0,12.3-5.5,12.3-12.3v-111
c0-6.8-5.5-12.3-12.3-12.3h-43.2v-31.7H410v31.7h-43.2c-6.8,0-12.3,5.5-12.3,12.3v111c0,6.8,5.5,12.3,12.3,12.3h111

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<g id="Icon_8_">
<g>
<path style="fill:#000000" d="M277.375,427V167.296l119.702,119.702L427,256L256,85L85,256l29.924,29.922l119.701-118.626V427H277.375z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 647 B

View File

@ -62,6 +62,25 @@ void VExplorer::setupUI()
}
});
m_upBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/up.svg"),
"",
this);
m_upBtn->setToolTip(tr("Up"));
m_upBtn->setProperty("FlatBtn", true);
connect(m_upBtn, &QPushButton::clicked,
this, [this]() {
if (checkIndex()) {
QDir dir(m_entries[m_index].m_directory);
if (dir.cdUp()) {
int idx = addEntry(dir.absolutePath());
updateDirectoryComboBox();
if (idx != -1) {
setCurrentEntry(idx);
}
}
}
});
m_openLocationBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/open_location.svg"),
"",
this);
@ -97,6 +116,7 @@ void VExplorer::setupUI()
dirLayout->addWidget(dirLabel);
dirLayout->addStretch();
dirLayout->addWidget(m_openBtn);
dirLayout->addWidget(m_upBtn);
dirLayout->addWidget(m_openLocationBtn);
dirLayout->addWidget(m_starBtn);
dirLayout->setContentsMargins(0, 0, 0, 0);
@ -345,6 +365,7 @@ void VExplorer::handleEntryActivated(int p_idx)
m_imgFolderEdit->setEnabled(valid);
m_openLocationBtn->setEnabled(valid);
m_upBtn->setEnabled(valid);
m_newFileBtn->setEnabled(valid);
m_newDirBtn->setEnabled(valid);

View File

@ -82,6 +82,7 @@ private:
int m_index;
QPushButton *m_openBtn;
QPushButton *m_upBtn;
QPushButton *m_openLocationBtn;
QPushButton *m_starBtn;
QComboBox *m_dirCB;

View File

@ -266,5 +266,6 @@
<file>resources/icons/decrease_outline_level.svg</file>
<file>resources/icons/increase_outline_level.svg</file>
<file>utils/markdown-it/markdown-it-texmath.js</file>
<file>resources/icons/up.svg</file>
</qresource>
</RCC>