1/* This file is part of the KDE project
2 Copyright (C) 2000, 2007 David Faure <faure@kde.org>
3 Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 or at your option version 3 as published by
8 the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20#include "filegroupdetails.h"
21#include "mimetypedata.h"
22
23#include <QLayout>
24#include <QRadioButton>
25#include <QButtonGroup>
26#include <QGroupBox>
27
28#include <klocale.h>
29
30FileGroupDetails::FileGroupDetails(QWidget *parent)
31 : QWidget( parent )
32{
33 QVBoxLayout *secondLayout = new QVBoxLayout(this);
34
35 QGroupBox *autoEmbedBox = new QGroupBox( i18n("Left Click Action (only for Konqueror file manager)") );
36 m_autoEmbed = new QButtonGroup( autoEmbedBox );
37 secondLayout->addWidget( autoEmbedBox );
38 // The order of those two items is very important. If you change it, fix typeslistitem.cpp !
39 QRadioButton *r1 = new QRadioButton( i18n("Show file in embedded viewer"));
40 QRadioButton *r2 = new QRadioButton( i18n("Show file in separate viewer"));
41 QVBoxLayout *autoEmbedBoxLayout = new QVBoxLayout(autoEmbedBox);
42 autoEmbedBoxLayout->addWidget(r1);
43 autoEmbedBoxLayout->addWidget(r2);
44 m_autoEmbed->addButton(r1, 0);
45 m_autoEmbed->addButton(r2, 1);
46 connect(m_autoEmbed, SIGNAL( buttonClicked( int ) ), SLOT( slotAutoEmbedClicked( int ) ));
47
48 autoEmbedBox->setWhatsThis( i18n("Here you can configure what the Konqueror file manager"
49 " will do when you click on a file belonging to this group. Konqueror can display the file in"
50 " an embedded viewer or start up a separate application. You can change this setting for a"
51 " specific file type in the 'Embedding' tab of the file type configuration. Dolphin "
52 " shows files always in a separate viewer") );
53
54 secondLayout->addStretch();
55}
56
57void FileGroupDetails::setMimeTypeData( MimeTypeData * mimeTypeData )
58{
59 Q_ASSERT( mimeTypeData->isMeta() );
60 m_mimeTypeData = mimeTypeData;
61 m_autoEmbed->button( m_mimeTypeData->autoEmbed() )->setChecked( true );
62}
63
64void FileGroupDetails::slotAutoEmbedClicked(int button)
65{
66 if ( !m_mimeTypeData )
67 return;
68 m_mimeTypeData->setAutoEmbed( (MimeTypeData::AutoEmbed)button );
69 emit changed(true);
70}
71
72#include "filegroupdetails.moc"
73