From 982cdfa5adaefa4f0d9dbba77a2853ef0a63a9e7 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Wed, 9 Apr 2025 15:51:42 +0300 Subject: KPDF Shell: Fix bugs related to tabbing * Update tab caption when user opens another document * Fix activation event setting window/tab title to full URL * Add tooltip with full path to tabs Resolves #119. Signed-off-by: Mavridis Philippe --- kpdf/shell/shell.cpp | 20 ++++++++++++++++++++ kpdf/shell/shell.h | 1 + 2 files changed, 21 insertions(+) (limited to 'kpdf/shell') diff --git a/kpdf/shell/shell.cpp b/kpdf/shell/shell.cpp index a44e596c..e18d4bba 100644 --- a/kpdf/shell/shell.cpp +++ b/kpdf/shell/shell.cpp @@ -146,6 +146,7 @@ void Shell::openURL( const KURL & url ) if (url.isValid()) { m_tabs->changeTab(part->widget(), url.filename()); + m_tabs->setTabToolTip(part->widget(), url.prettyURL()); bool openOk = part->openURL(url); if (openOk) { @@ -346,6 +347,8 @@ KParts::ReadOnlyPart* Shell::createTab() part, TQ_SLOT(saveDocumentRestoreInfo(TDEConfig*))); connect(part, TQ_SIGNAL(enablePrintAction(bool)), m_printAction, TQ_SLOT(setEnabled(bool))); + connect(part, TQ_SIGNAL(setWindowCaption(const TQString&)), + this, TQ_SLOT(slotSetTabCaption(const TQString&))); part->widget()->show(); m_manager->addPart(part, true); @@ -608,4 +611,21 @@ void Shell::slotRemoveOtherTabs() } } +void Shell::slotSetTabCaption(const TQString &caption) +{ + KParts::ReadOnlyPart *part = const_cast + (static_cast(TQObject::sender())); + if (!part) return; + + m_tabs->changeTab(part->widget(), caption.isEmpty() ? i18n("No file") : caption); + if (caption.isEmpty()) + { + m_tabs->removeTabToolTip(part->widget()); + } + else + { + m_tabs->setTabToolTip(part->widget(), part->url().pathOrURL()); + } +} + #include "shell.moc" diff --git a/kpdf/shell/shell.h b/kpdf/shell/shell.h index 28be65e3..6b4eb48b 100644 --- a/kpdf/shell/shell.h +++ b/kpdf/shell/shell.h @@ -115,6 +115,7 @@ namespace KPDF void slotMoveTabLeft(); void slotMoveTabRight(); void slotRemoveOtherTabs(); + void slotSetTabCaption(const TQString &caption); signals: void restoreDocument(TDEConfig* config); -- cgit v1.2.3