You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
7.2 KiB
212 lines
7.2 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
|
||
|
Copyright (c) 1999 David Faure <faure@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., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqbuttongroup.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqradiobutton.h>
|
||
15 years ago
|
|
||
|
#include <kcolorbutton.h>
|
||
|
#include <kcombobox.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kimagefilepreview.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
12 years ago
|
//#include <tderecentdocument.h>
|
||
15 years ago
|
#include <kstandarddirs.h>
|
||
|
#include <kurlrequester.h>
|
||
|
|
||
|
#include "konq_bgnddlg.h"
|
||
|
|
||
|
|
||
15 years ago
|
KonqBgndDialog::KonqBgndDialog( TQWidget* parent,
|
||
|
const TQString& pixmapFile,
|
||
|
const TQColor& theColor,
|
||
|
const TQColor& defaultColor )
|
||
15 years ago
|
: KDialogBase( parent, "KonqBgndDialog", false,
|
||
|
i18n("Background Settings"), Ok|Cancel, Ok, true )
|
||
|
{
|
||
15 years ago
|
TQWidget* page = new TQWidget( this );
|
||
15 years ago
|
setMainWidget( page );
|
||
15 years ago
|
TQVBoxLayout* mainLayout = new TQVBoxLayout( page, 0, KDialog::spacingHint() );
|
||
15 years ago
|
|
||
15 years ago
|
m_buttonGroup = new TQButtonGroup( i18n("Background"), page );
|
||
15 years ago
|
m_buttonGroup->setColumnLayout( 0, Qt::Vertical );
|
||
13 years ago
|
m_buttonGroup->layout()->setMargin( KDialog::marginHint() );
|
||
|
m_buttonGroup->layout()->setSpacing( KDialog::spacingHint() );
|
||
|
TQGridLayout* groupLayout = new TQGridLayout( m_buttonGroup->layout() );
|
||
13 years ago
|
groupLayout->setAlignment( Qt::AlignTop );
|
||
15 years ago
|
mainLayout->addWidget( m_buttonGroup );
|
||
|
|
||
15 years ago
|
connect( m_buttonGroup, TQT_SIGNAL( clicked(int) ),
|
||
|
this, TQT_SLOT( slotBackgroundModeChanged() ) );
|
||
15 years ago
|
|
||
|
// color
|
||
15 years ago
|
m_radioColor = new TQRadioButton( i18n("Co&lor:"), m_buttonGroup );
|
||
15 years ago
|
groupLayout->addWidget( m_radioColor, 0, 0 );
|
||
|
m_buttonColor = new KColorButton( theColor, defaultColor, m_buttonGroup );
|
||
13 years ago
|
m_buttonColor->setSizePolicy( TQSizePolicy::Preferred,
|
||
15 years ago
|
TQSizePolicy::Minimum );
|
||
15 years ago
|
groupLayout->addWidget( m_buttonColor, 0, 1 );
|
||
|
|
||
15 years ago
|
connect( m_buttonColor, TQT_SIGNAL( changed( const TQColor& ) ),
|
||
|
this, TQT_SLOT( slotColorChanged() ) );
|
||
15 years ago
|
|
||
|
// picture
|
||
15 years ago
|
m_radioPicture = new TQRadioButton( i18n("&Picture:"), m_buttonGroup );
|
||
15 years ago
|
groupLayout->addWidget( m_radioPicture, 1, 0 );
|
||
|
m_comboPicture = new KURLComboRequester( m_buttonGroup );
|
||
|
groupLayout->addMultiCellWidget( m_comboPicture, 1, 1, 1, 2 );
|
||
|
initPictures();
|
||
|
|
||
15 years ago
|
connect( m_comboPicture->comboBox(), TQT_SIGNAL( activated( int ) ),
|
||
|
this, TQT_SLOT( slotPictureChanged() ) );
|
||
|
connect( m_comboPicture, TQT_SIGNAL( urlSelected(const TQString &) ),
|
||
|
this, TQT_SLOT( slotPictureChanged() ) );
|
||
15 years ago
|
|
||
15 years ago
|
TQSpacerItem* spacer1 = new TQSpacerItem( 0, 0, TQSizePolicy::Expanding,
|
||
|
TQSizePolicy::Minimum );
|
||
15 years ago
|
groupLayout->addItem( spacer1, 0, 2 );
|
||
|
|
||
|
// preview title
|
||
15 years ago
|
TQHBoxLayout* hlay = new TQHBoxLayout( mainLayout, KDialog::spacingHint() );
|
||
15 years ago
|
//mainLayout->addLayout( hlay );
|
||
15 years ago
|
TQLabel* lbl = new TQLabel( i18n("Preview"), page );
|
||
15 years ago
|
hlay->addWidget( lbl );
|
||
15 years ago
|
TQFrame* frame = new TQFrame( page );
|
||
13 years ago
|
frame->setSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Minimum );
|
||
15 years ago
|
frame->setFrameShape( TQFrame::HLine );
|
||
|
frame->setFrameShadow( TQFrame::Sunken );
|
||
15 years ago
|
hlay->addWidget( frame );
|
||
|
|
||
|
// preview frame
|
||
15 years ago
|
m_preview = new TQFrame( page );
|
||
13 years ago
|
m_preview->setSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding );
|
||
15 years ago
|
m_preview->setMinimumSize( 370, 180 );
|
||
15 years ago
|
m_preview->setFrameShape( TQFrame::Panel );
|
||
|
m_preview->setFrameShadow( TQFrame::Raised );
|
||
15 years ago
|
mainLayout->addWidget( m_preview );
|
||
|
|
||
|
if ( !pixmapFile.isEmpty() ) {
|
||
|
loadPicture( pixmapFile );
|
||
|
m_buttonColor->setColor( defaultColor );
|
||
|
m_radioPicture->setChecked( true );
|
||
|
}
|
||
|
else {
|
||
|
m_buttonColor->setColor( theColor );
|
||
|
m_comboPicture->comboBox()->setCurrentItem( 0 );
|
||
|
m_radioColor->setChecked( true );
|
||
|
}
|
||
|
slotBackgroundModeChanged();
|
||
|
}
|
||
|
|
||
|
KonqBgndDialog::~KonqBgndDialog()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
TQColor KonqBgndDialog::color() const
|
||
15 years ago
|
{
|
||
|
if ( m_radioColor->isChecked() )
|
||
|
return m_buttonColor->color();
|
||
|
|
||
15 years ago
|
return TQColor();
|
||
15 years ago
|
}
|
||
|
|
||
|
void KonqBgndDialog::initPictures()
|
||
|
{
|
||
12 years ago
|
TDEGlobal::dirs()->addResourceType( "tiles",
|
||
|
TDEGlobal::dirs()->kde_default("data") + "konqueror/tiles/");
|
||
|
kdDebug(1203) << TDEGlobal::dirs()->kde_default("data") + "konqueror/tiles/" << endl;
|
||
15 years ago
|
|
||
12 years ago
|
TQStringList list = TDEGlobal::dirs()->findAllResources("tiles");
|
||
15 years ago
|
|
||
|
if ( list.isEmpty() )
|
||
|
m_comboPicture->comboBox()->insertItem( i18n("None") );
|
||
|
else {
|
||
15 years ago
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
for ( it = list.begin(); it != list.end(); it++ )
|
||
|
m_comboPicture->comboBox()->insertItem(
|
||
13 years ago
|
( (*it).at(0) == '/' ) ? // if absolute path
|
||
15 years ago
|
KURL( *it ).fileName() : // then only fileName
|
||
|
*it );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void KonqBgndDialog::loadPicture( const TQString& fileName )
|
||
15 years ago
|
{
|
||
|
int i ;
|
||
|
for ( i = 0; i < m_comboPicture->comboBox()->count(); i++ ) {
|
||
|
if ( fileName == m_comboPicture->comboBox()->text( i ) ) {
|
||
|
m_comboPicture->comboBox()->setCurrentItem( i );
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( !fileName.isEmpty() ) {
|
||
|
m_comboPicture->comboBox()->insertItem( fileName );
|
||
|
m_comboPicture->comboBox()->setCurrentItem( i );
|
||
|
}
|
||
|
else
|
||
|
m_comboPicture->comboBox()->setCurrentItem( 0 );
|
||
|
}
|
||
|
|
||
|
void KonqBgndDialog::slotPictureChanged()
|
||
|
{
|
||
|
m_pixmapFile = m_comboPicture->comboBox()->currentText();
|
||
15 years ago
|
TQString file = locate( "tiles", m_pixmapFile );
|
||
15 years ago
|
if ( file.isEmpty() )
|
||
|
file = locate("wallpaper", m_pixmapFile); // add fallback for compatibility
|
||
|
if ( file.isEmpty() ) {
|
||
|
kdWarning(1203) << "Couldn't locate wallpaper " << m_pixmapFile << endl;
|
||
|
m_preview->unsetPalette();
|
||
15 years ago
|
m_pixmap = TQPixmap();
|
||
15 years ago
|
m_pixmapFile = "";
|
||
|
}
|
||
|
else {
|
||
|
m_pixmap.load( file );
|
||
|
|
||
|
if ( m_pixmap.isNull() )
|
||
|
kdWarning(1203) << "Could not load wallpaper " << file << endl;
|
||
|
}
|
||
|
m_preview->setPaletteBackgroundPixmap( m_pixmap );
|
||
|
}
|
||
|
|
||
|
void KonqBgndDialog::slotColorChanged()
|
||
|
{
|
||
|
m_preview->setPaletteBackgroundColor( m_buttonColor->color() );
|
||
|
}
|
||
|
|
||
|
void KonqBgndDialog::slotBackgroundModeChanged()
|
||
|
{
|
||
|
if ( m_radioColor->isChecked() ) {
|
||
|
m_buttonColor->setEnabled( true );
|
||
|
m_comboPicture->setEnabled( false );
|
||
|
m_pixmapFile = "";
|
||
|
slotColorChanged();
|
||
|
}
|
||
|
else { // m_comboPicture->isChecked() == true
|
||
|
m_comboPicture->setEnabled( true );
|
||
|
m_buttonColor->setEnabled( false );
|
||
|
slotPictureChanged();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
#include "konq_bgnddlg.moc"
|