Skip to content

Commit

Permalink
Add show the currently opened .tex document in file explorer (texstud…
Browse files Browse the repository at this point in the history
  • Loading branch information
frostybee authored Aug 19, 2024
1 parent 544bac3 commit efb565a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/editors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,16 @@ void Editors::tabBarContextMenu(const QPoint &point)

act = menu.addAction((splitter->orientation() == Qt::Horizontal) ? tr("Split Vertically") : tr("Split Horizontally"));
connect(act, SIGNAL(triggered()), SLOT(changeSplitOrientation()));
menu.addSeparator();

if (editorUnderCursor) {
act = menu.addAction(tr("Copy file path"));
act->setData(QVariant::fromValue<LatexDocument *>(editorUnderCursor->getDocument()));
connect(act, SIGNAL(triggered()), SLOT(copyFilePath()));
// Open the containing folder of the currently opened document.
act = menu.addAction(msgGraphicalShellAction());
act->setData(QVariant::fromValue<LatexDocument *>(editorUnderCursor->getDocument()));
connect(act, SIGNAL(triggered()), SLOT(showInGraphicalShell_()));
menu.addSeparator();
QString text = tr("Set Read-Only");
if (editorUnderCursor->editor->isReadOnly())
Expand All @@ -432,6 +440,37 @@ void Editors::onEditorChangeByTabClick(LatexEditorView *from, LatexEditorView *t
emit editorAboutToChangeByTabClick(currentEditor(), to);
}


/*!
* \brief copy file path of document to clipboard
*
* Called from the tab's context menu of the currently opened document
*/
void Editors::copyFilePath()
{
QAction *action = qobject_cast<QAction *>(sender());
if (!action) return;
LatexDocument *document = qvariant_cast<LatexDocument *>(action->data());
if (!document) return;
QClipboard* clipboard = QGuiApplication::clipboard();
if (!clipboard) return;
clipboard->setText(document->getFileInfo().absoluteFilePath());
}
/*!
* \brief open directory in external explorer
*
* Called from the tab's context menu of the currently opened document
*/

void Editors::showInGraphicalShell_()
{
QAction *action = qobject_cast<QAction *>(sender());
if (!action) return;
LatexDocument *document = qvariant_cast<LatexDocument *>(action->data());
if (!document) return;
showInGraphicalShell(this, document->getFileName());
}

/*!
* Called from and action with data() set to an editor. Moves the editor to the other tabGroup.
* This currently assumes a restriction to two tab groups.
Expand Down
2 changes: 2 additions & 0 deletions src/editors.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ protected slots:
void moveAllToOtherTabGroup();
void moveAllOthersToOtherTabGroup();
void moveToTabGroup(LatexEditorView *edView, TxsTabWidget *target, int targetIndex);
void showInGraphicalShell_();
void copyFilePath();

protected:
TxsTabWidget *tabWidgetFromEditor(LatexEditorView *edView) const;
Expand Down

0 comments on commit efb565a

Please sign in to comment.