summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2025-04-09 15:51:42 +0300
committerMavridis Philippe <mavridisf@gmail.com>2025-04-14 19:07:27 +0300
commit982cdfa5adaefa4f0d9dbba77a2853ef0a63a9e7 (patch)
tree00a67bf5ccad2c431b3485bb3c7f824d310d75ab
parentc7c1795c817c1f7b89046c6d9f24379143f0bf6b (diff)
downloadtdegraphics-982cdfa5adaefa4f0d9dbba77a2853ef0a63a9e7.tar.gz
tdegraphics-982cdfa5adaefa4f0d9dbba77a2853ef0a63a9e7.zip
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 <mavridisf@gmail.com>
-rw-r--r--kpdf/part.cpp8
-rw-r--r--kpdf/part.h6
-rw-r--r--kpdf/shell/shell.cpp20
-rw-r--r--kpdf/shell/shell.h1
4 files changed, 33 insertions, 2 deletions
diff --git a/kpdf/part.cpp b/kpdf/part.cpp
index 0dbe5ca9..853fbdb4 100644
--- a/kpdf/part.cpp
+++ b/kpdf/part.cpp
@@ -536,6 +536,14 @@ void Part::readMimeType(TDEIO::Job *, const TQString &mime)
m_jobMime = mime;
}
+void Part::guiActivateEvent(KParts::GUIActivateEvent *e)
+{
+ if (e->activated())
+ {
+ emitWindowCaption();
+ }
+}
+
void Part::emitWindowCaption()
{
// these setWindowCaption call only works for remote files
diff --git a/kpdf/part.h b/kpdf/part.h
index aa3b6659..7a5b2739 100644
--- a/kpdf/part.h
+++ b/kpdf/part.h
@@ -17,6 +17,7 @@
#define _KPDF_PART_H_
#include <tdeparts/browserextension.h>
+#include <tdeparts/event.h>
#include <tdeparts/part.h>
#include <tqguardedptr.h>
#include "core/document.h"
@@ -89,8 +90,9 @@ protected:
bool openFile();
bool openURL(const KURL &url);
bool closeURL();
- // filter that watches for splitter size changes
- bool eventFilter( TQObject * watched, TQEvent * e );
+ void guiActivateEvent(KParts::GUIActivateEvent *e);
+ // filter that watches for splitter size changes
+ bool eventFilter( TQObject * watched, TQEvent * e );
protected slots:
void openURLFromDocument(const KURL &url);
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<KParts::ReadOnlyPart*>
+ (static_cast<const KParts::ReadOnlyPart*>(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);