diff options
author | Saturneric <[email protected]> | 2021-06-27 20:00:05 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-06-27 20:00:05 +0000 |
commit | 5143c2d56255dec8ca618bc9acaf054781dd8746 (patch) | |
tree | c2861c182fc59bbf5d505bc87929cdd118a5297e /src/ui/widgets/TextEdit.cpp | |
parent | Develop File Opera Functions (diff) | |
download | GpgFrontend-5143c2d56255dec8ca618bc9acaf054781dd8746.tar.gz GpgFrontend-5143c2d56255dec8ca618bc9acaf054781dd8746.zip |
Add and improve file operation functions.
Diffstat (limited to 'src/ui/widgets/TextEdit.cpp')
-rw-r--r-- | src/ui/widgets/TextEdit.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index 2394b694..9ca1b578 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -67,9 +67,9 @@ void TextEdit::slotNewHelpTab(const QString &title, const QString &path) const { void TextEdit::slotNewFileTab() const { auto *page = new FilePage(qobject_cast<QWidget *>(parent())); - tabWidget->addTab(page, "File"); + tabWidget->addTab(page, "[File Browser]"); tabWidget->setCurrentIndex(tabWidget->count() - 1); - connect(page, SIGNAL(pathChanged(QString)), this, SLOT(slotFilePagePathChanged(QString))); + connect(page, SIGNAL(pathChanged(const QString &)), this, SLOT(slotFilePagePathChanged(const QString &))); } @@ -357,10 +357,10 @@ QTextEdit *TextEdit::curTextPage() const { } } -QTextBrowser *TextEdit::curHelpPage() const { - auto *curHelpPage = qobject_cast<HelpPage *>(tabWidget->currentWidget()); - if (curHelpPage != nullptr) { - return curHelpPage->getBrowser(); +FilePage * TextEdit::curFilePage() const { + auto *curFilePage = qobject_cast<FilePage *>(tabWidget->currentWidget()); + if (curFilePage != nullptr) { + return curFilePage; } else { return nullptr; } @@ -439,9 +439,7 @@ void TextEdit::slotPrint() { #ifndef QT_NO_PRINTER QTextDocument *document; - if (curTextPage() == nullptr) { - document = curHelpPage()->document(); - } else { + if (curTextPage() != nullptr) { document = curTextPage()->document(); } QPrinter printer; @@ -515,8 +513,6 @@ void TextEdit::slotCopy() const { if (curTextPage() != nullptr) { curTextPage()->copy(); - } else { - curHelpPage()->copy(); } @@ -553,8 +549,6 @@ void TextEdit::slotZoomIn() const { if (curTextPage() != nullptr) { curTextPage()->zoomIn(); - } else { - curHelpPage()->zoomIn(); } } @@ -566,8 +560,6 @@ void TextEdit::slotZoomOut() const { if (curTextPage() != nullptr) { curTextPage()->zoomOut(); - } else { - curHelpPage()->zoomOut(); } } @@ -578,13 +570,17 @@ void TextEdit::slotSelectAll() const { curTextPage()->selectAll(); } -void TextEdit::slotFilePagePathChanged(const QString& path) { +void TextEdit::slotFilePagePathChanged(const QString &path) { int index = tabWidget->currentIndex(); QString mPath; - if(path.size() > 8) { - mPath = path.mid(path.size()-8,8).prepend("..."); + QFileInfo fileInfo(path); + QString tPath = fileInfo.path(); + if (path.size() > 16) { + mPath = tPath.mid(tPath.size() - 16, 16).prepend("..."); } else { - mPath = path; + mPath = tPath; } + mPath.prepend("[File Browser]: "); + mPath.append("/"); tabWidget->setTabText(index, mPath); }
\ No newline at end of file |