File indexing completed on 2024-05-05 16:39:00
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998-2002 Carsten Pfeiffer <pfeiffer@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "generalwidget.h" 0020 #include <ui_generalwidget.h> 0021 0022 #include <KIconLoader> 0023 #include <KLocalizedString> 0024 0025 #include <QDesktopServices> 0026 #include <QPixmap> 0027 #include <QUrl> 0028 0029 #include "kuickdata.h" 0030 0031 0032 GeneralWidget::GeneralWidget( QWidget *parent ) 0033 : QWidget( parent ) 0034 { 0035 // setup the widget based on its .ui file 0036 ui = new Ui::GeneralWidget; 0037 ui->setupUi(this); 0038 0039 0040 // now the properties that couldn't be set in the .ui file 0041 0042 // the KuickShow logo 0043 QPixmap pixmap = KIconLoader::global()->loadIcon("logo", KIconLoader::User); 0044 ui->logo->setUrl(HOMEPAGE_URL); 0045 ui->logo->setPixmap( pixmap ); 0046 ui->logo->setFixedSize( pixmap.size() ); 0047 0048 // actions 0049 connect( ui->logo, SIGNAL( leftClickedUrl( const QString & ) ), 0050 SLOT( slotURLClicked( const QString & ) ) ); 0051 0052 connect( ui->cbOwnPalette, SIGNAL( clicked() ), this, SLOT( useOwnPalette() ) ); 0053 0054 0055 // load and show the saved settings 0056 loadSettings( *kdata ); 0057 ui->cbFullscreen->setFocus(); 0058 } 0059 0060 GeneralWidget::~GeneralWidget() 0061 { 0062 delete ui; 0063 } 0064 0065 void GeneralWidget::slotURLClicked( const QString & url ) 0066 { 0067 QDesktopServices::openUrl(QUrl::fromUserInput(url)); 0068 } 0069 0070 void GeneralWidget::loadSettings( const KuickData& data ) 0071 { 0072 ImData *idata = data.idata; 0073 0074 ui->colorButton->setColor( data.backgroundColor ); 0075 ui->editFilter->setText( data.fileFilter ); 0076 ui->cbFullscreen->setChecked( data.fullScreen ); 0077 ui->cbPreload->setChecked( data.preloadImage ); 0078 ui->cbLastdir->setChecked( data.startInLastDir ); 0079 ui->cbFastRemap->setChecked( idata->fastRemap ); 0080 ui->cbOwnPalette->setChecked( idata->ownPalette ); 0081 ui->cbSmoothScale->setChecked( idata->smoothScale ); 0082 ui->cbFastRender->setChecked( idata->fastRender ); 0083 ui->cbDither16bit->setChecked( idata->dither16bit ); 0084 ui->cbDither8bit->setChecked( idata->dither8bit ); 0085 ui->maxCacheSpinBox->setValue( idata->maxCache / 1024 ); 0086 0087 useOwnPalette(); // enable/disable remap-checkbox 0088 } 0089 0090 void GeneralWidget::applySettings( KuickData& data) 0091 { 0092 ImData *idata = data.idata; 0093 0094 data.backgroundColor = ui->colorButton->color(); 0095 data.fileFilter = ui->editFilter->text(); 0096 data.fullScreen = ui->cbFullscreen->isChecked(); 0097 data.preloadImage = ui->cbPreload->isChecked(); 0098 data.startInLastDir = ui->cbLastdir->isChecked(); 0099 0100 idata->smoothScale = ui->cbSmoothScale->isChecked(); 0101 idata->fastRemap = ui->cbFastRemap->isChecked(); 0102 idata->ownPalette = ui->cbOwnPalette->isChecked(); 0103 idata->fastRender = ui->cbFastRender->isChecked(); 0104 idata->dither16bit = ui->cbDither16bit->isChecked(); 0105 idata->dither8bit = ui->cbDither8bit->isChecked(); 0106 0107 idata->maxCache = (uint) ui->maxCacheSpinBox->value() * 1024; 0108 } 0109 0110 void GeneralWidget::useOwnPalette() 0111 { 0112 ui->cbFastRemap->setEnabled( ui->cbOwnPalette->isChecked() ); 0113 }