1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/***************************************************************************
* Copyright (C) 2007 by Tobias Koenig <tokoe@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., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "configdialog.h"
#include <KLocale>
#include <KStandardDirs>
#include "picture.h"
ConfigDialog::ConfigDialog(QWidget *parent)
: QObject(parent)
{
m_picture = new Picture(this);
connect(m_picture, SIGNAL(pictureLoaded(QPixmap)), this, SLOT(pictureLoaded(QPixmap)));
appearanceSettings = new QWidget();
appearanceUi.setupUi(appearanceSettings);
imageSettings = new QWidget();
imageUi.setupUi(imageSettings);
imageUi.addDirButton->setIcon(KIcon("list-add"));
imageUi.removeDirButton->setIcon(KIcon("list-remove"));
imageUi.slideShowDelay->setMinimumTime(QTime(0, 0, 1)); // minimum to 1 second
QString monitorPath = KStandardDirs::locate("data", "kcontrol/pics/monitor.png");
// Size of monitor image: 200x186
// Geometry of "display" part of monitor image: (23,14)-[151x115]
imageUi.monitorLabel->setPixmap(QPixmap(monitorPath));
imageUi.monitorLabel->setWhatsThis(i18n(
"This picture of a monitor contains a preview of "
"the picture you currently have in your frame."));
m_preview = new QLabel(imageUi.monitorLabel);
m_preview->setScaledContents(true);
m_preview->setGeometry(23, 14, 151, 115);
m_preview->show();
connect(imageUi.picRequester, SIGNAL(urlSelected(const KUrl &)), this, SLOT(changePreview(const KUrl &)));
connect(imageUi.picRequester->comboBox(), SIGNAL(activated(const QString &)), this, SLOT(changePreview(const QString &)));
}
ConfigDialog::~ConfigDialog()
{
}
void ConfigDialog::setRoundCorners(bool round)
{
appearanceUi.roundCheckBox->setChecked(round);
}
bool ConfigDialog::roundCorners() const
{
return appearanceUi.roundCheckBox->isChecked();
}
void ConfigDialog::setRandom(bool random)
{
imageUi.randomCheckBox->setChecked(random);
}
bool ConfigDialog::random() const
{
return imageUi.randomCheckBox->isChecked();
}
void ConfigDialog::setShadow(bool shadow)
{
appearanceUi.shadowCheckBox->setChecked(shadow);
}
bool ConfigDialog::shadow() const
{
return appearanceUi.shadowCheckBox->isChecked();
}
void ConfigDialog::setShowFrame(bool show)
{
appearanceUi.frameCheckBox->setChecked(show);
}
bool ConfigDialog::showFrame() const
{
return appearanceUi.frameCheckBox->isChecked();
}
void ConfigDialog::setFrameColor(const QColor& frameColor)
{
appearanceUi.changeFrameColor->setColor(frameColor);
}
QColor ConfigDialog::frameColor() const
{
return appearanceUi.changeFrameColor->color();
}
void ConfigDialog::setCurrentUrl(const KUrl& currentUrl)
{
imageUi.picRequester->setUrl(currentUrl);
}
KUrl ConfigDialog::currentUrl() const
{
return imageUi.picRequester->url();
}
void ConfigDialog::previewPicture(const QPixmap &image)
{
QPixmap scaledImage = image.scaled(QRect(23, 14, 151, 115).size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
m_preview->setPixmap(scaledImage);
}
void ConfigDialog::changePreview(const KUrl &path)
{
m_picture->setPicture(path);
}
void ConfigDialog::pictureLoaded(QPixmap image)
{
previewPicture(image);
}
void ConfigDialog::changePreview(const QString &path)
{
m_picture->setPicture(KUrl(path));
}
void ConfigDialog::setSmoothScaling(bool smooth)
{
appearanceUi.smoothScaling->setChecked(smooth);
}
bool ConfigDialog::smoothScaling() const
{
return appearanceUi.smoothScaling->isChecked();
}
|