[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    konq header patch, round 2.
From:       Mark Deneen <deneen () bucknell ! edu>
Date:       2001-05-10 13:56:52
[Download RAW message or body]

It now gets the title from the .desktop file (from the Name part) and is on 
all vertical parts.

It works on my end really well.  If you could review, test and apply, that 
would be great.  :-)

Best Regards,
Mark Deneen

(Feel free to make it more visibly pretty! -- I considered making the title 
bold..)


["konq.diff" (text/x-c)]

? konq.diff
Index: konq_frame.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_frame.cc,v
retrieving revision 1.122
diff -u -3 -p -r1.122 konq_frame.cc
--- konq_frame.cc	2001/04/12 11:11:31	1.122
+++ konq_frame.cc	2001/05/10 13:50:22
@@ -25,6 +25,7 @@
 #include <qsplitter.h>
 #include <qwhatsthis.h>
 #include <qtimer.h>
+#include <qpushbutton.h>
 
 #include <kapp.h>
 #include <kdebug.h>
@@ -34,6 +35,7 @@
 #include <kprogress.h>
 #include <klocale.h>
 #include <kseparator.h>
+#include <kaction.h>
 
 #include <kparts/browserextension.h>
 #include <kparts/event.h>
@@ -281,6 +283,61 @@ void KonqFrameStatusBar::paintEvent(QPai
 #endif
 }
 
+
+KonqFrameHeader::KonqFrameHeader( KonqFrame *_parent, const char *_name )
+:QWidget( _parent, _name )
+,m_pParentKonqFrame( _parent )
+{
+
+   m_pAction = 0L;
+   m_pLayout = new QHBoxLayout( this, 0, -1, "KonqFrame's QVBoxLayout" );
+   m_pHeaderLabel = new QLabel( this, "KonqFrameHeader label" );
+   m_pHeaderLabel->setAlignment(AlignCenter);
+   m_pHeaderLabel->setFrameStyle( QFrame::StyledPanel );
+
+   m_pCloseButton = new QPushButton( this );
+
+   m_pLayout->addWidget( m_pHeaderLabel );
+   m_pLayout->addWidget( m_pCloseButton );
+
+   m_pLayout->setStretchFactor( m_pHeaderLabel, 1 );
+   m_pLayout->setStretchFactor( m_pCloseButton, 0 );
+   m_pCloseButton->setText("X");
+
+   m_pCloseButton->setFocusPolicy(NoFocus);
+}
+
+KonqFrameHeader::~KonqFrameHeader()
+{
+    if(m_pLayout) delete m_pLayout;
+}
+
+void KonqFrameHeader::slotConnectToNewView(KonqView *, KParts::ReadOnlyPart \
*,KParts::ReadOnlyPart *newOne) +{
+   if (newOne!=0)
+   {
+      connect(m_pCloseButton, SIGNAL(clicked()), this, SLOT(slotDoAction()));
+   }
+}
+
+void KonqFrameHeader::slotDoAction()
+{
+    if( m_pAction )
+        m_pAction->activate();
+}
+void KonqFrameHeader::slotSetHeaderText(const QString &text)
+{
+    if( !isVisible() ) show();
+    m_pHeaderLabel->setText(text);
+}
+
+void KonqFrameHeader::setAction( KAction *inAction )
+{
+    m_pAction = inAction;
+}
+
+
+
 //###################################################################
 
 KonqFrame::KonqFrame( KonqFrameContainer *_parentContainer, const char *_name )
@@ -291,6 +348,7 @@ KonqFrame::KonqFrame( KonqFrameContainer
 
    // the frame statusbar
    m_pStatusBar = new KonqFrameStatusBar( this, "KonquerorFrameStatusBar");
+   m_pHeader = new KonqFrameHeader(this, "KonquerorFrameHeader");
    connect(m_pStatusBar, SIGNAL(clicked()), this, SLOT(slotStatusBarClicked()));
    connect( m_pStatusBar, SIGNAL( linkedViewClicked( bool ) ), this, SLOT( \
slotLinkedViewClicked( bool ) ) );  m_separator = 0;
@@ -347,6 +405,8 @@ KParts::ReadOnlyPart *KonqFrame::attach(
    attachInternal();
 
    m_pStatusBar->slotConnectToNewView(0, 0,m_pPart);
+   m_pHeader->slotConnectToNewView(0, 0,m_pPart);
+
    return m_pPart;
 }
 
@@ -357,11 +417,15 @@ void KonqFrame::attachInternal()
 
    m_pLayout = new QVBoxLayout( this, 0, -1, "KonqFrame's QVBoxLayout" );
 
+   m_pLayout->addWidget( m_pHeader );
+
    m_pLayout->addWidget( m_pPart->widget() );
 
    m_pLayout->addWidget( m_pStatusBar );
    m_pPart->widget()->show();
    m_pStatusBar->show();
+   m_pHeader->hide();
+
    m_pLayout->activate();
 
    m_pPart->widget()->installEventFilter(this);
@@ -396,10 +460,15 @@ void KonqFrame::setView( KonqView* child
    {
      connect(m_pView,SIGNAL(sigPartChanged(KonqView *, KParts::ReadOnlyPart \
                *,KParts::ReadOnlyPart *)),
              m_pStatusBar,SLOT(slotConnectToNewView(KonqView *, KParts::ReadOnlyPart \
                *,KParts::ReadOnlyPart *)));
-     //connect(m_pView->view(),SIGNAL(setStatusBarText(const QString &)),
-     //m_pHeader,SLOT(slotDisplayStatusText(const QString&)));
+     connect(m_pView,SIGNAL(sigPartChanged(KonqView *, KParts::ReadOnlyPart \
*,KParts::ReadOnlyPart *)), +             \
m_pHeader,SLOT(slotConnectToNewView(KonqView *, KParts::ReadOnlyPart \
*,KParts::ReadOnlyPart *)));  }
 };
+
+void KonqFrame::showHeader(const QString &name)
+{
+    m_pHeader->slotSetHeaderText( name );
+}
 
 KonqFrameContainer* KonqFrame::parentContainer()
 {
Index: konq_frame.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_frame.h,v
retrieving revision 1.62
diff -u -3 -p -r1.62 konq_frame.h
--- konq_frame.h	2001/03/06 22:40:19	1.62
+++ konq_frame.h	2001/05/10 13:50:22
@@ -33,7 +33,10 @@
 
 class QPixmap;
 class QVBoxLayout;
+class QHBoxLayout;
 class QTimer;
+class QPushButton;
+
 class KonqView;
 class KonqFrameBase;
 class KonqFrame;
@@ -41,6 +44,7 @@ class KonqFrameContainer;
 class KConfig;
 class KSeparator;
 class KProgress;
+class KAction;
 
 namespace KParts
 {
@@ -124,6 +128,34 @@ class KonqFrameStatusBar : public QWidge
       QString m_savedMessage;
 };
 
+
+/**
+ * The KonqFrameHeader provides a title and button to remove the view.
+ */
+
+class KonqFrameHeader : public QWidget
+{
+  Q_OBJECT
+
+   public:
+      KonqFrameHeader( KonqFrame *_parent = 0L, const char *_name = 0L );
+      virtual ~KonqFrameHeader();
+      virtual void setAction( KAction *inAction );
+
+   public slots:
+      void slotConnectToNewView(KonqView *, KParts::ReadOnlyPart \
*oldOne,KParts::ReadOnlyPart *newOne); +      void slotSetHeaderText(const QString& \
text); +      void slotDoAction();
+
+   protected:
+
+      KonqFrame* m_pParentKonqFrame;
+      QLabel *m_pHeaderLabel;
+      QPushButton *m_pCloseButton;
+      QHBoxLayout *m_pLayout;
+      KAction *m_pAction;
+};
+
 typedef QList<KonqView> ChildViewList;
 
 class KonqFrameBase
@@ -178,7 +210,7 @@ public:
    make KonqMainWindow switch to the next view
    */
   virtual bool eventFilter(QObject*obj,QEvent *ev);
- 
+
   /**
    * Inserts the part's widget and the statusbar into the layout
    */
@@ -210,6 +242,7 @@ public:
   virtual void reparentFrame(QWidget * parent,
                      const QPoint & p, bool showIt=FALSE );
 
+  virtual void showHeader(const QString &name);
   virtual KonqFrameContainer* parentContainer();
   virtual QWidget* widget() { return this; }
   virtual QCString frameType() { return QCString("View"); }
@@ -217,6 +250,7 @@ public:
   QVBoxLayout *layout() { return m_pLayout; }
 
   KonqFrameStatusBar *statusbar() const { return m_pStatusBar; }
+  KonqFrameHeader    *header() const { return m_pHeader; }
 
 public slots:
 
@@ -242,6 +276,7 @@ protected:
 
   KSeparator *m_separator;
   KonqFrameStatusBar* m_pStatusBar;
+  KonqFrameHeader *m_pHeader;
 };
 
 /**
Index: konq_guiclients.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_guiclients.cc,v
retrieving revision 1.35
diff -u -3 -p -r1.35 konq_guiclients.cc
--- konq_guiclients.cc	2000/12/15 23:20:28	1.35
+++ konq_guiclients.cc	2001/05/10 13:50:22
@@ -246,7 +246,14 @@ void ToggleViewGUIClient::slotToggleView
 
     kdDebug() << "ToggleViewGUIClient::slotToggleView setToggleView(true) on " << \
childView << endl;  childView->setToggleView( true );
+
     m_mainWindow->viewCountChanged();
+
+    // turn on frame header if it is vertical.  it looked quite ugly for horizontal,
+    // but this could be fixed by having a fixed height.  (the layout stretched)
+    if( !horizontal)
+        childView->frame()->showHeader(childView->service()->name());
+
   }
   else
   {
@@ -291,6 +298,7 @@ void ToggleViewGUIClient::slotViewAdded(
   {
     static_cast<KToggleAction *>( action )->setChecked( true );
     saveConfig( true, name );
+    view->frame()->header()->setAction(action);
   }
 }



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic