File indexing completed on 2024-04-28 16:44:25

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2000, 2007 David Faure <faure@kde.org>
0003    SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
0004 
0005    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
0006 */
0007 #include "filegroupdetails.h"
0008 #include "mimetypedata.h"
0009 
0010 #include <QButtonGroup>
0011 #include <QGroupBox>
0012 #include <QRadioButton>
0013 #include <QVBoxLayout>
0014 
0015 #include <klocalizedstring.h>
0016 
0017 FileGroupDetails::FileGroupDetails(QWidget *parent)
0018     : QWidget(parent)
0019 {
0020     QVBoxLayout *secondLayout = new QVBoxLayout(this);
0021 
0022     QGroupBox *autoEmbedBox = new QGroupBox(i18n("Left Click Action (only for Konqueror file manager)"));
0023     m_autoEmbed = new QButtonGroup(autoEmbedBox);
0024     secondLayout->addWidget(autoEmbedBox);
0025     // The order of those two items is very important. If you change it, fix typeslistitem.cpp !
0026     QRadioButton *r1 = new QRadioButton(i18n("Show file in embedded viewer"));
0027     QRadioButton *r2 = new QRadioButton(i18n("Show file in separate viewer"));
0028     QVBoxLayout *autoEmbedBoxLayout = new QVBoxLayout(autoEmbedBox);
0029     autoEmbedBoxLayout->addWidget(r1);
0030     autoEmbedBoxLayout->addWidget(r2);
0031     m_autoEmbed->addButton(r1, 0);
0032     m_autoEmbed->addButton(r2, 1);
0033     connect(m_autoEmbed, SIGNAL(buttonClicked(int)), SLOT(slotAutoEmbedClicked(int)));
0034 
0035     autoEmbedBox->setWhatsThis(
0036         i18n("Here you can configure what the Konqueror file manager"
0037              " will do when you click on a file belonging to this group. Konqueror can display the file in"
0038              " an embedded viewer or start up a separate application. You can change this setting for a"
0039              " specific file type in the 'Embedding' tab of the file type configuration. Dolphin "
0040              " shows files always in a separate viewer"));
0041 
0042     secondLayout->addStretch();
0043 }
0044 
0045 void FileGroupDetails::setMimeTypeData(MimeTypeData *mimeTypeData)
0046 {
0047     Q_ASSERT(mimeTypeData->isMeta());
0048     m_mimeTypeData = mimeTypeData;
0049     m_autoEmbed->button(m_mimeTypeData->autoEmbed())->setChecked(true);
0050 }
0051 
0052 void FileGroupDetails::slotAutoEmbedClicked(int button)
0053 {
0054     if (!m_mimeTypeData) {
0055         return;
0056     }
0057     m_mimeTypeData->setAutoEmbed((MimeTypeData::AutoEmbed)button);
0058     Q_EMIT changed(true);
0059 }