Commit b6342c5c authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Removed the whole old sidepane code

svn path=/trunk/kdepim/; revision=385353
parent ccc35818
......@@ -15,7 +15,7 @@ kontact_LDADD = $(top_builddir)/libkdepim/libkdepim.la \
$(top_builddir)/kontact/interfaces/libkpinterfaces.la libkontact.la \
$(LIB_KPARTS) $(LIB_KUTILS) $(LIB_KHTML)
kontact_SOURCES = main.cpp mainwindow.cpp sidepanebase.cpp \
sidepane.cpp iconsidepane.cpp aboutdialog.cpp
iconsidepane.cpp aboutdialog.cpp
kontact_COMPILE_FIRST = prefs.h
kde_module_LTLIBRARIES = kcm_kontact.la
......
......@@ -20,19 +20,6 @@
<entry type="IntList" name="SidePaneSplitter">
</entry>
<entry type="Enum" name="SidePaneType">
<label>Side Pane Type</label>
<choices>
<choice name="SidePaneBars">
<label>Button view with sidebar extension</label>
</choice>
<choice name="SidePaneIcons">
<label>Icon view</label>
</choice>
</choices>
<default>SidePaneIcons</default>
</entry>
<entry type="Int" name="SidePaneIconSize">
<default>32</default>
</entry>
......
......@@ -63,14 +63,11 @@
#include <krun.h>
#include <kaboutdata.h>
#include <infoextension.h>
#include "aboutdialog.h"
#include "iconsidepane.h"
#include "mainwindow.h"
#include "plugin.h"
#include "prefs.h"
#include "sidepane.h"
#include "progressdialog.h"
#include "statusbarprogresswidget.h"
#include "broadcaststatus.h"
......@@ -78,8 +75,8 @@
using namespace Kontact;
MainWindow::MainWindow()
: Kontact::Core(), mTopWidget( 0 ), mHeaderText( 0 ), mHeaderPixmap( 0 ), mSplitter( 0 ),
mCurrentPlugin( 0 ), mLastInfoExtension( 0 ), mAboutDialog( 0 ), mReallyClose( false ),
: Kontact::Core(), mTopWidget( 0 ), mSplitter( 0 ),
mCurrentPlugin( 0 ), mAboutDialog( 0 ), mReallyClose( false ),
mStartupCompleted( false )
{
// Set this to be the group leader for all subdialogs - this means
......@@ -205,27 +202,12 @@ void MainWindow::initWidgets()
mTopWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken );
setCentralWidget( mTopWidget );
// init appropriate sidebar (disabled for now)
mSidePaneType = Prefs::self()->mSidePaneType;
QHBox *mBox = 0;
#if 0
if ( mSidePaneType == Prefs::SidePaneBars ) {
mSplitter = new QSplitter( mTopWidget );
mSidePane = new SidePane( this, mSplitter );
mSidePane->setSizePolicy( QSizePolicy( QSizePolicy::Maximum,
QSizePolicy::Preferred ) );
mSplitter->setResizeMode( mSidePane, QSplitter::KeepSize );
}
else
#endif
{
mSplitter = 0;
mBox = new QHBox( mTopWidget );
mSidePane = new IconSidePane( this, mBox );
mSidePane->setSizePolicy( QSizePolicy( QSizePolicy::Maximum,
QSizePolicy::Preferred ) );
}
mSplitter = 0;
mBox = new QHBox( mTopWidget );
mSidePane = new IconSidePane( this, mBox );
mSidePane->setSizePolicy( QSizePolicy( QSizePolicy::Maximum,
QSizePolicy::Preferred ) );
mSidePane->setActionCollection( actionCollection() );
......@@ -239,10 +221,6 @@ void MainWindow::initWidgets()
vBox = new QVBox( mBox );
}
initHeaderWidget( vBox );
if ( mSidePaneType != Prefs::SidePaneBars )
mHeaderFrame->hide();
vBox->setSpacing( 0 );
mPartsStack = new QWidgetStack( vBox );
......@@ -331,38 +309,6 @@ void MainWindow::setupActions()
actionCollection(), "help_requestfeature" );
}
void MainWindow::initHeaderWidget( QVBox *vBox )
{
// Initiate the headerWidget
mHeaderFrame = new QHBox( vBox );
mHeaderFrame->setSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::Maximum );
mHeaderFrame->setSpacing( 0 );
mHeaderFrame->setFixedHeight( 22 );
mHeaderText = new QLabel( mHeaderFrame );
mHeaderText->setSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::Preferred );
mHeaderText->setPaletteForegroundColor( colorGroup().light() );
mHeaderText->setPaletteBackgroundColor( colorGroup().dark() );
mHeaderPixmap = new QLabel( mHeaderFrame );
mHeaderPixmap->setSizePolicy( QSizePolicy::Maximum,
QSizePolicy::Preferred );
mHeaderPixmap->setAlignment( AlignRight|AlignVCenter );
mHeaderPixmap->setPaletteBackgroundColor( colorGroup().dark() );
connect( this, SIGNAL( textChanged( const QString& ) ),
this, SLOT( setHeaderText( const QString& ) ) );
connect( this, SIGNAL( iconChanged( const QPixmap& ) ),
this, SLOT( setHeaderPixmap( const QPixmap& ) ) );
QFont fnt( mSidePane->font() );
fnt.setBold( true );
fnt.setPointSize( mSidePane->font().pointSize() + 3 );
mHeaderText->setFont( fnt );
}
bool MainWindow::isPluginLoaded( const KPluginInfo *info )
{
return (pluginFromInfo( info ) != 0);
......@@ -442,8 +388,6 @@ void MainWindow::loadPlugins()
addPlugin( plugin );
}
mLastInfoExtension = 0;
mNewActions->setEnabled( mPlugins.size() != 0 );
}
......@@ -516,33 +460,8 @@ void MainWindow::slotActivePartChanged( KParts::Part *part )
return;
}
if ( mLastInfoExtension ) {
disconnect( mLastInfoExtension, SIGNAL( textChanged( const QString& ) ),
this, SLOT( setHeaderText( const QString& ) ) );
disconnect( mLastInfoExtension, SIGNAL( iconChanged( const QPixmap& ) ),
this, SLOT( setHeaderPixmap( const QPixmap& ) ) );
}
kdDebug(5600) << "Part activated: " << part << " with stack id. "
<< mPartsStack->id( part->widget() )<< endl;
QObjectList *l = part->queryList( "KParts::InfoExtension" );
KParts::InfoExtension *ie = 0;
if ( l )
ie = static_cast<KParts::InfoExtension*>( l->first() );
delete l;
if ( ie ) {
connect( ie, SIGNAL( textChanged( const QString& ) ),
SLOT( setHeaderText( const QString& ) ) );
connect( ie, SIGNAL( iconChanged( const QPixmap& ) ),
SLOT( setHeaderPixmap( const QPixmap& ) ) );
}
mLastInfoExtension = ie;
InfoExtData data = mInfoExtCache[ ie ];
setHeaderPixmap( data.pixmap );
setHeaderText( data.text );
createGUI( part );
......@@ -767,26 +686,6 @@ int MainWindow::startServiceFor( const QString& serviceType,
preferences, error, dcopService, flags );
}
void MainWindow::setHeaderText( const QString &text )
{
mInfoExtCache[ mLastInfoExtension ].text = text;
mHeaderText->setText( text );
}
void MainWindow::setHeaderPixmap( const QPixmap &pixmap )
{
QPixmap pm( pixmap );
if ( pm.height() > 22 || pm.width() > 22 ) {
QImage img;
img = pixmap;
pm = img.smoothScale( 22, 22, QImage::ScaleMin );
}
mInfoExtCache[ mLastInfoExtension ].pixmap = pm;
mHeaderPixmap->setPixmap( pm );
}
void MainWindow::pluginsChanged()
{
unloadPlugins();
......@@ -799,45 +698,6 @@ void MainWindow::updateConfig()
kdDebug( 5600 ) << k_funcinfo << endl;
saveSettings();
#if 0
bool sidePaneChanged = ( Prefs::self()->mSidePaneType != mSidePaneType );
if ( sidePaneChanged ) {
mSidePaneType = Prefs::self()->mSidePaneType;
delete mSidePane;
switch ( mSidePaneType ) {
case Prefs::SidePaneIcons:
mSidePane = new IconSidePane( this, mSplitter );
mHeaderFrame->hide();
break;
default:
kdError() << "Invalid SidePaneType: " << mSidePaneType << endl;
case Prefs::SidePaneBars:
mSidePane = new SidePane( this, mSplitter );
mHeaderFrame->show();
break;
}
mSplitter->setResizeMode( mSidePane, QSplitter::KeepSize );
mSidePane->setSizePolicy( QSizePolicy( QSizePolicy::Maximum,
QSizePolicy::Preferred ) );
connect( mSidePane, SIGNAL( pluginSelected( Kontact::Plugin * ) ),
SLOT( selectPlugin( Kontact::Plugin * ) ) );
mSplitter->moveToFirst( mSidePane );
mSidePane->show();
}
if ( sidePaneChanged )
mSidePane->updatePlugins();
#endif
loadSettings();
}
......
......@@ -47,20 +47,9 @@ namespace KPIM
class StatusbarProgressWidget;
}
namespace KParts
{
class InfoExtension;
}
namespace Kontact
{
struct InfoExtData
{
QString text;
QPixmap pixmap;
};
class Plugin;
class SidePaneBase;
class AboutDialog;
......@@ -84,16 +73,13 @@ class MainWindow : public Kontact::Core, public KDCOPServiceStarter
virtual PluginList pluginList() const { return mPlugins; }
void setActivePluginModule( const QString & );
public slots:
virtual void selectPlugin( Kontact::Plugin *plugin );
virtual void selectPlugin( const QString &pluginName );
void updateConfig();
signals:
void textChanged( const QString& );
void iconChanged( const QPixmap& );
protected slots:
void initObject();
void initGUI();
......@@ -125,14 +111,11 @@ class MainWindow : public Kontact::Core, public KDCOPServiceStarter
void addPlugin( Kontact::Plugin *plugin );
void partLoaded( Kontact::Plugin *plugin, KParts::ReadOnlyPart *part );
void setupActions();
void initHeaderWidget( QVBox *vBox );
void showTip( bool );
virtual bool queryClose ();
virtual bool queryClose();
private slots:
void pluginsChanged();
void setHeaderText( const QString& );
void setHeaderPixmap( const QPixmap& );
void configureShortcuts();
void configureToolbars();
......@@ -140,9 +123,6 @@ class MainWindow : public Kontact::Core, public KDCOPServiceStarter
private:
QFrame *mTopWidget;
QHBox *mHeaderFrame;
QLabel *mHeaderText;
QLabel *mHeaderPixmap;
QSplitter *mSplitter;
KToolBarPopupAction *mNewActions;
......@@ -153,9 +133,6 @@ class MainWindow : public Kontact::Core, public KDCOPServiceStarter
PluginList mPlugins;
PluginList mDelayedPreload;
QValueList<KPluginInfo*> mPluginInfos;
KParts::InfoExtension *mLastInfoExtension;
QMap<KParts::InfoExtension*, InfoExtData> mInfoExtCache;
int mSidePaneType;
......
/* This file is part of the KDE project
Copyright (C) 2003 Daniel Molkentin <molkentin@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qptrlist.h>
#include <qwidgetstack.h>
#include <qsignal.h>
#include <qobjectlist.h>
#include <qlabel.h>
#include <qpainter.h>
#include <qbitmap.h>
#include <qfontmetrics.h>
#include <qstyle.h>
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <kiconloader.h>
#include <sidebarextension.h>
#include <kdebug.h>
#include "mainwindow.h"
#include "plugin.h"
#include "sidepane.h"
using namespace Kontact;
///////////////////////////////////////////////////////////////////////
// Helper classes
///////////////////////////////////////////////////////////////////////
PanelButton::PanelButton( Kontact::Plugin *plugin, int id, QWidget *parent, const char* name)
: QPushButton(parent, name)
{
setPixmap( BarIcon( plugin->icon() ) );
setText( plugin->title() );
mActive = false;
mId = id;
mPlugin = plugin;
QFont fnt(font());
fnt.setBold(true);
setFont(fnt);
if (style().inherits("KStyle"))
setFlat(true);
connect(this, SIGNAL(clicked()), SLOT(slotClicked()));
}
void PanelButton::slotClicked()
{
emit clicked( this );
emit showPart( mPlugin );
setActive();
}
void PanelButton::setActive()
{
QColorGroup cga(palette().active());
cga.setColor(QColorGroup::Button, cga.highlight());
cga.setColor(QColorGroup::ButtonText, cga.highlightedText());
QColorGroup cgi(palette().inactive());
cgi.setColor(QColorGroup::Button, cgi.highlight());
cgi.setColor(QColorGroup::ButtonText, cgi.highlightedText());
QPalette pal = palette();
pal.setActive(cga);
pal.setInactive(cgi);
setPalette(pal);
mActive = true;
kdDebug(5600) << "PanelButton::setActive()" << endl;
}
void PanelButton::setInactive()
{
// reset using parents palette
setPalette(parentWidget()->palette());
mActive = false;
}
void PanelButton::setPixmap(const QPixmap& pix)
{
mPix = pix;
QPushButton::setPixmap(pix);
}
void PanelButton::setText(const QString& text)
{
mText = text;
QPushButton::setText(text);
}
void PanelButton::composeLabel(QPainter *p)
{
QRect rect = style().subRect(QStyle::SR_PushButtonContents, this);
QRect pixRect = mPix.rect();
pixRect.moveCenter(rect.center());
if (kapp->reverseLayout())
pixRect.setLeft(rect.right()-pixRect.width());
else
pixRect.setLeft(rect.left());
pixRect.setWidth(mPix.width());
p->drawPixmap(pixRect, mPix);
QPen tmp = p->pen();
p->setPen(colorGroup().buttonText());
if (kapp->reverseLayout())
{
rect.setRight(rect.right()-(mPix.width()+2));
p->drawText(rect, AlignVCenter|AlignRight, mText);
}
else
{
rect.setLeft(mPix.width()+2);
p->drawText(rect, AlignVCenter, mText);
}
p->setPen(tmp);
}
void PanelButton::drawButtonLabel(QPainter *p)
{
composeLabel(p);
}
///////////////////////////////////////////////////////////////////////
SidePane::SidePane( Core* core, QWidget *parent, const char* name )
: SidePaneBase( core, parent, name ),
mContentStack( 0 ),
mHeaderWidget( 0 )
{
setSpacing(0);
mHeaderWidget = new QLabel(this, "header");
mHeaderWidget->setAlignment( AlignVCenter );
mHeaderWidget->setPaletteBackgroundColor( colorGroup().dark() );
mHeaderWidget->setPaletteForegroundColor( colorGroup().light() );
mHeaderWidget->setFixedHeight(22);
QFont fnt(font());
fnt.setBold(true);
fnt.setPointSize(font().pointSize()+3);
mHeaderWidget->setFont(fnt);
mContentStack = new QWidgetStack(this);
mContentStack->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
mContentStack->addWidget(new QWidget(mContentStack));
}
SidePane::~SidePane()
{
QValueList<QGuardedPtr<QWidget> >::Iterator it;
for ( it = mContentList.begin(); it != mContentList.end(); ++it ) {
if ( (*it) )
(*it)->reparent( 0, 0, QPoint( 0, 0 ) );
}
}
void SidePane::switchSidePaneWidget( Kontact::Plugin *plugin )
{
KParts::Part *part = plugin->part();
Q_ASSERT(part);
QObjectList *l = part->queryList( "KParts::SideBarExtension" );
KParts::SideBarExtension *sbe = 0;
if ( l )
sbe = static_cast<KParts::SideBarExtension*>(l->first());
delete l;
if (!sbe) {
mContentStack->raiseWidget(0);
return;
}
if (mContentStack->id(sbe->widget()) == -1) {
mContentStack->addWidget(sbe->widget());
QGuardedPtr<QWidget> ptr = sbe->widget();
mContentList.append( ptr );
}
mContentStack->raiseWidget(sbe->widget());
}
void SidePane::switchItems(PanelButton* pb)
{
QPtrListIterator<PanelButton> it( mButtonList );
for (; it.current(); ++it)
{
if (it.current()->isActive())
it.current()->setInactive();
}
mContentStack->raiseWidget( pb->id() );
mHeaderWidget->setText( pb->text() );
}
void SidePane::updatePlugins()
{
// delete all existing buttons
mButtonList.setAutoDelete( true );
mButtonList.clear();
mButtonList.setAutoDelete( false );
QValueList<Plugin*> plugins = core()->pluginList();
QValueList<Plugin*>::ConstIterator end = plugins.end();
QValueList<Plugin*>::ConstIterator it = plugins.begin();
for ( ; it != end; ++it ) {
Plugin *plugin = *it;
if ( !plugin->showInSideBar() )
continue;
PanelButton* pb = new PanelButton( plugin, 0, this, "PanelButton" );
mButtonList.append( pb );
connect( pb, SIGNAL( clicked( PanelButton* ) ),
SLOT( switchItems( PanelButton* ) ) );
connect( pb, SIGNAL( showPart( Kontact::Plugin* ) ),
SIGNAL( pluginSelected( Kontact::Plugin* ) ) );
connect( pb, SIGNAL( showPart( Kontact::Plugin* ) ),
SLOT( switchSidePaneWidget( Kontact::Plugin* ) ) );
pb->show();
}
}
void SidePane::selectPlugin( Kontact::Plugin *plugin )
{
bool blocked = signalsBlocked();
blockSignals( true );
QPtrListIterator<PanelButton> it( mButtonList );
PanelButton *btn;
while ( ( btn = it.current() ) != 0 ) {
++it;
if ( btn->plugin() == plugin ) {
btn->slotClicked();
blockSignals( blocked );
return;
}
}
btn = mButtonList.first();
// no plugins loaded. Something is really broken..
Q_ASSERT( btn );
if ( btn )
btn->slotClicked();
blockSignals( blocked );
}
void SidePane::selectPlugin( const QString &pluginName )
{
bool blocked = signalsBlocked();
blockSignals( true );
QPtrListIterator<PanelButton> it( mButtonList );
PanelButton *btn;
while ( ( btn = it.current() ) != 0 ) {
++it;
Kontact::Plugin *plugin = btn->plugin();
if ( plugin->identifier() == pluginName ) {
btn->slotClicked();
blockSignals( blocked );
return;
}
}
btn = mButtonList.first();
// no plugins loaded. Something is really broken..
Q_ASSERT( btn );
if ( btn )
btn->slotClicked();