mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 17:01:22 +00:00
This commit was manufactured by cvs2svn to accommodate
a server-side copy/move. svn path=/trunk/kdebase/libkonq/; revision=46538
This commit is contained in:
parent
8b3c0ff6cf
commit
cd6902c50b
86
lib/konq/konq_bgnddlg.h
Normal file
86
lib/konq/konq_bgnddlg.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
|
||||
Copyright (c) 1999 David Faure <fauren@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __konq_bgnd_h
|
||||
#define __konq_bgnd_h
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qpixmap.h>
|
||||
|
||||
#include <kurl.h>
|
||||
#include <kdialogbase.h>
|
||||
|
||||
class KonqFileItem;
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
|
||||
class DirPropsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DirPropsPage( QWidget * parent, const KURL & dirURL, KInstance *instance );
|
||||
virtual ~DirPropsPage();
|
||||
|
||||
QPixmap pixmap() { return m_wallPixmap; }
|
||||
|
||||
public slots:
|
||||
void slotWallPaperChanged( int );
|
||||
void slotBrowse();
|
||||
void slotApply();
|
||||
void slotApplyGlobal();
|
||||
|
||||
protected:
|
||||
void showSettings( QString filename );
|
||||
void loadWallPaper();
|
||||
virtual void resizeEvent ( QResizeEvent * );
|
||||
|
||||
const KURL & m_url;
|
||||
QPushButton * m_browseButton;
|
||||
KonqFileItem * m_fileitem;
|
||||
QComboBox * m_wallBox;
|
||||
QWidget * m_wallWidget;
|
||||
QPixmap m_wallPixmap;
|
||||
QString m_wallFile;
|
||||
int imageX, imageW, imageH, imageY;
|
||||
KInstance *m_instance;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Dialog for configuring the background image for a directory
|
||||
*/
|
||||
class KonqBgndDialog : public KDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
KonqBgndDialog( const KURL & dirURL, KInstance *instance );
|
||||
~KonqBgndDialog();
|
||||
|
||||
QPixmap pixmap() { return m_propsPage->pixmap(); }
|
||||
|
||||
private:
|
||||
DirPropsPage * m_propsPage;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
6
lib/konq/konq_events.cc
Normal file
6
lib/konq/konq_events.cc
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
#include "konq_events.h"
|
||||
|
||||
const char *KonqURLEnterEvent::s_urlEnterEventName = "Konqueror/URLEntered";
|
||||
|
||||
const char *KonqFileSelectionEvent::s_fileItemSelectionEventName = "Konqueror/FileSelection";
|
47
lib/konq/konq_events.h
Normal file
47
lib/konq/konq_events.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef __konq_events_h__
|
||||
#define __konq_events_h__ $Id$
|
||||
|
||||
#include <kparts/event.h>
|
||||
#include <qlist.h>
|
||||
|
||||
namespace KParts
|
||||
{
|
||||
class ReadOnlyPart;
|
||||
};
|
||||
|
||||
class KFileItem;
|
||||
typedef QList<KFileItem> KFileItemList;
|
||||
|
||||
class KonqURLEnterEvent : public KParts::Event
|
||||
{
|
||||
public:
|
||||
KonqURLEnterEvent( const QString &url ) : KParts::Event( s_urlEnterEventName ), m_url( url ) {}
|
||||
|
||||
QString url() const { return m_url; }
|
||||
|
||||
static bool test( const QEvent *event ) { return KParts::Event::test( event, s_urlEnterEventName ); }
|
||||
|
||||
private:
|
||||
static const char *s_urlEnterEventName;
|
||||
|
||||
QString m_url;
|
||||
};
|
||||
|
||||
class KonqFileSelectionEvent : public KParts::Event
|
||||
{
|
||||
public:
|
||||
KonqFileSelectionEvent( const KFileItemList &selection, KParts::ReadOnlyPart *part ) : KParts::Event( s_fileItemSelectionEventName ), m_selection( selection ), m_part( part ) {}
|
||||
|
||||
KFileItemList selection() const { return m_selection; }
|
||||
KParts::ReadOnlyPart *part() const { return m_part; }
|
||||
|
||||
static bool test( const QEvent *event ) { return KParts::Event::test( event, s_fileItemSelectionEventName ); }
|
||||
|
||||
private:
|
||||
static const char *s_fileItemSelectionEventName;
|
||||
|
||||
KFileItemList m_selection;
|
||||
KParts::ReadOnlyPart *m_part;
|
||||
};
|
||||
|
||||
#endif
|
189
lib/konq/konq_propsview.cc
Normal file
189
lib/konq/konq_propsview.cc
Normal file
|
@ -0,0 +1,189 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 1998, 1999 Faure David <faure@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 "konq_propsview.h"
|
||||
#include <konqdefaults.h>
|
||||
#include <konqsettings.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kstddirs.h>
|
||||
#include <klocale.h>
|
||||
#include <kpixmap.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <qpixmapcache.h>
|
||||
#include <unistd.h>
|
||||
#include <qfile.h>
|
||||
#include <iostream>
|
||||
#include <kinstance.h>
|
||||
|
||||
#include <ksimpleconfig.h>
|
||||
|
||||
QPixmap wallpaperPixmap( const char *_wallpaper )
|
||||
{
|
||||
QString key = "wallpapers/";
|
||||
key += _wallpaper;
|
||||
KPixmap pix;
|
||||
|
||||
if ( QPixmapCache::find( key, pix ) )
|
||||
return pix;
|
||||
|
||||
QString path = locate("wallpaper", _wallpaper);
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
pix.load( path, 0, KPixmap::LowColor ); // ?
|
||||
if ( pix.isNull() )
|
||||
debug("Wallpaper %s couldn't be loaded",path.ascii());
|
||||
else
|
||||
QPixmapCache::insert( key, pix );
|
||||
return pix;
|
||||
} else debug("Wallpaper %s not found",_wallpaper);
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
//KonqPropsView * KonqPropsView::m_pDefaultProps = 0L;
|
||||
|
||||
// static
|
||||
KonqPropsView * KonqPropsView::defaultProps( KInstance *instance )
|
||||
{
|
||||
// if (!m_pDefaultProps)
|
||||
// {
|
||||
kdDebug(1202) << "Reading global config for konq_propsview" << endl;
|
||||
KConfig *config = instance->config();
|
||||
KConfigGroupSaver cgs(config, "Settings");
|
||||
return new KonqPropsView( config );
|
||||
// m_pDefaultProps = new KonqPropsView(config);
|
||||
// }
|
||||
// return m_pDefaultProps;
|
||||
}
|
||||
|
||||
KonqPropsView::KonqPropsView( KConfig * config )
|
||||
{
|
||||
QString entry = "LargeIcons"; // default
|
||||
/* m_viewMode = KfmView::HOR_ICONS;
|
||||
entry = config->readEntry("ViewMode", entry);
|
||||
if (entry == "SmallIcons")
|
||||
m_viewMode = KfmView::VERT_ICONS;
|
||||
if (entry == "TreeView")
|
||||
m_viewMode = KfmView::FINDER;
|
||||
if (entry == "HTMLView")
|
||||
m_viewMode = KfmView::HTML;
|
||||
*/
|
||||
m_bShowDot = config->readBoolEntry( "ShowDotFiles", false );
|
||||
m_bImagePreview = config->readBoolEntry( "ImagePreview", false );
|
||||
m_bHTMLAllowed = config->readBoolEntry( "HTMLAllowed", false );
|
||||
// m_bCache = false; // What is it ???
|
||||
|
||||
// Default background color is the one from the settings, i.e. configured in kcmkonq
|
||||
m_bgColor = KonqFMSettings::settings()->bgColor();
|
||||
|
||||
m_bgPixmap.resize(0,0);
|
||||
QString pix = config->readEntry( "BackgroundPixmap", "" );
|
||||
if ( pix.isEmpty() )
|
||||
{
|
||||
KConfig builtinviewConfig( "konqbuiltinviewrc", true, false );
|
||||
QString pix = builtinviewConfig.readEntry( "BackgroundPixmap", "" );
|
||||
}
|
||||
if ( !pix.isEmpty() )
|
||||
{
|
||||
QPixmap p = wallpaperPixmap( pix );
|
||||
if ( !p.isNull() )
|
||||
{
|
||||
kdDebug(1202) << "Got background" << endl;
|
||||
m_bgPixmap = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KonqPropsView::~KonqPropsView()
|
||||
{
|
||||
}
|
||||
|
||||
bool KonqPropsView::enterDir( const KURL & dir, KonqPropsView *defaultProps )
|
||||
{
|
||||
// Revert to default setting first
|
||||
// m_bgPixmap = m_pDefaultProps->m_bgPixmap;
|
||||
m_bgPixmap = defaultProps->m_bgPixmap;
|
||||
m_bgColor = KonqFMSettings::settings()->bgColor();
|
||||
// Check for .directory
|
||||
KURL u ( dir );
|
||||
u.addPath(".directory");
|
||||
if (u.isLocalFile() && QFile::exists( u.path() ))
|
||||
{
|
||||
//kdDebug(1202) << "Found .directory file" << endl;
|
||||
KSimpleConfig config( u.path(), true);
|
||||
config.setGroup("URL properties");
|
||||
m_bgColor = config.readColorEntry( "BgColor", &m_bgColor );
|
||||
QString pix = config.readEntry( "BgImage", "" );
|
||||
if ( !pix.isEmpty() )
|
||||
{
|
||||
debug("BgImage is %s", debugString(pix));
|
||||
QPixmap p = wallpaperPixmap( pix );
|
||||
if ( !p.isNull() )
|
||||
m_bgPixmap = p;
|
||||
else debug("Wallpaper not found");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void KonqPropsView::saveAsDefault( KInstance *instance )
|
||||
{
|
||||
KConfig *config = instance->config();
|
||||
KConfigGroupSaver cgs(config, "Settings");
|
||||
saveProps( config );
|
||||
}
|
||||
|
||||
void KonqPropsView::saveLocal( const KURL & dir )
|
||||
{
|
||||
KURL u ( dir );
|
||||
u.addPath(".directory");
|
||||
if (!u.isLocalFile() || access (dir.path(), W_OK) != 0)
|
||||
{
|
||||
KMessageBox::sorry( 0L, i18n( QString("Can't write to %1").arg(dir.path()) ) );
|
||||
// Well in theory we could write even to some FTP dir, but not with KSimpleConfig :)
|
||||
return;
|
||||
}
|
||||
|
||||
//kdDebug(1202) << "Found .directory file" << endl;
|
||||
KSimpleConfig config( u.path());
|
||||
config.setGroup("URL properties");
|
||||
saveProps( & config );
|
||||
}
|
||||
|
||||
void KonqPropsView::saveProps( KConfig * config )
|
||||
{
|
||||
QString entry;
|
||||
/* switch ( m_viewMode )
|
||||
{
|
||||
case KfmView::HOR_ICONS: entry = "LargeIcons"; break;
|
||||
case KfmView::FINDER: entry = "TreeView"; break;
|
||||
case KfmView::VERT_ICONS: entry = "SmallIcons"; break;
|
||||
case KfmView::HTML: entry = "HTMLView"; break;
|
||||
default: assert( 0 ); break;
|
||||
}
|
||||
config->writeEntry( "ViewMode", entry);
|
||||
*/
|
||||
config->writeEntry( "ShowDotFiles", m_bShowDot );
|
||||
config->writeEntry( "ImagePreview", m_bImagePreview );
|
||||
config->writeEntry( "HTMLAllowed", m_bHTMLAllowed );
|
||||
config->writeEntry( "BgColor", m_bgColor );
|
||||
// TODO save FILENAME for the BgImage...
|
||||
config->sync();
|
||||
}
|
||||
|
127
lib/konq/konq_propsview.h
Normal file
127
lib/konq/konq_propsview.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 1997 David Faure <faure@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; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __kfm_viewprops_h__
|
||||
#define __kfm_viewprops_h__
|
||||
|
||||
#include <qpixmap.h>
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kurl.h>
|
||||
|
||||
class KInstance;
|
||||
class KonqKfmIconView;
|
||||
class KonqTreeViewWidget;
|
||||
|
||||
/**
|
||||
* The class KonqPropsView holds the properties for a Konqueror View
|
||||
*
|
||||
* Separating them from the view class allows to store the default
|
||||
* values (the one read from konquerorrc) in a static instance of this class
|
||||
* and to have another instance of this class in each view, storing the
|
||||
* current values of the view.
|
||||
*
|
||||
* The local values can be read from a desktop entry, if any (.directory, bookmark, ...).
|
||||
*/
|
||||
class KonqPropsView
|
||||
{
|
||||
// A View can read/write the values directly.
|
||||
//friend KonqKfmIconView;
|
||||
//friend KonqTreeViewWidget;
|
||||
|
||||
// This is not a QObject because we need a copy constructor.
|
||||
public:
|
||||
/**
|
||||
* The static instance of KonqPropsView, holding the default values
|
||||
* from the config file
|
||||
*/
|
||||
static KonqPropsView * defaultProps( KInstance *instance );
|
||||
|
||||
/**
|
||||
* To construct a new KonqPropsView instance with values taken
|
||||
* from defaultProps, use the copy constructor.
|
||||
|
||||
* Constructs a KonqPropsView instance from a config file.
|
||||
* Set the group before calling.
|
||||
* ("Settings" for global props, "ViewNNN" for local props)
|
||||
*/
|
||||
KonqPropsView( KConfig * config );
|
||||
|
||||
/** Destructor */
|
||||
virtual ~KonqPropsView();
|
||||
|
||||
/**
|
||||
* Called when entering a directory
|
||||
* Checks for a .directory, read it, and
|
||||
* @return true if found it
|
||||
*/
|
||||
bool enterDir( const KURL & dir, KonqPropsView *defaultProps );
|
||||
|
||||
/**
|
||||
* Save in local .directory if possible
|
||||
*/
|
||||
void saveLocal( const KURL & dir );
|
||||
|
||||
/**
|
||||
* Save those properties as default
|
||||
* ("Options"/"Save settings") ["as default" missing ?]
|
||||
*/
|
||||
void saveAsDefault( KInstance *instance );
|
||||
|
||||
/**
|
||||
* Save to config file
|
||||
* Set the group before calling.
|
||||
* ("Settings" for global props, "ViewNNN" for SM (TODO),
|
||||
* "URL properties" for .directory files)
|
||||
*/
|
||||
void saveProps( KConfig * config );
|
||||
|
||||
//////// The read-only access methods. Order is to be kept. /////
|
||||
|
||||
bool isShowingDotFiles() { return m_bShowDot; }
|
||||
bool isShowingImagePreview() { return m_bImagePreview; }
|
||||
bool isHTMLAllowed() { return m_bHTMLAllowed; }
|
||||
// Cache ?
|
||||
// TODO : window size
|
||||
|
||||
const QColor& bgColor() { return m_bgColor; }
|
||||
const QPixmap& bgPixmap() { return m_bgPixmap; }
|
||||
|
||||
//without the protected user made views can access this directly
|
||||
//without modifying konqy's sources
|
||||
//protected:
|
||||
|
||||
/** The static instance. */
|
||||
// static KonqPropsView * m_pDefaultProps;
|
||||
|
||||
bool m_bShowDot;
|
||||
bool m_bImagePreview;
|
||||
bool m_bHTMLAllowed;
|
||||
// bool m_bCache; ?
|
||||
QColor m_bgColor;
|
||||
QPixmap m_bgPixmap; // one per view or one per GUI ?
|
||||
|
||||
private:
|
||||
|
||||
/** There is no default constructor. Use the provided one or copy constructor */
|
||||
KonqPropsView();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue