File indexing completed on 2024-04-28 04:58:20
0001 /* 0002 SPDX-FileCopyrightText: 2001 David Faure <david@mandrakesoft.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 // Behaviour options for konqueror 0008 0009 // Own 0010 #include "behaviour.h" 0011 0012 // Qt 0013 #include <QDBusConnection> 0014 #include <QDBusMessage> 0015 #include <QCheckBox> 0016 #include <QGroupBox> 0017 #include <QLabel> 0018 #include <QVBoxLayout> 0019 0020 // KDE 0021 #include <KLocalizedString> 0022 0023 #include <KPluginFactory> 0024 #include <kurlrequester.h> 0025 #include <kconfiggroup.h> 0026 #include <QStandardPaths> 0027 #include <KSharedConfig> 0028 0029 K_PLUGIN_CLASS_WITH_JSON(KBehaviourOptions, "filebehavior.json") 0030 0031 KBehaviourOptions::KBehaviourOptions(QObject *parent, const KPluginMetaData &md, const QVariantList &) 0032 : KCModule(parent, md) 0033 , g_pConfig(KSharedConfig::openConfig(QStringLiteral("konquerorrc"), KConfig::IncludeGlobals)) 0034 , groupname(QStringLiteral("FMSettings")) 0035 { 0036 QVBoxLayout *mainLayout = new QVBoxLayout(widget()); 0037 0038 QGroupBox *miscGb = new QGroupBox(i18n("Misc Options"), widget()); 0039 QHBoxLayout *miscHLayout = new QHBoxLayout; 0040 QVBoxLayout *miscLayout = new QVBoxLayout; 0041 0042 winPixmap = new QLabel(widget()); 0043 winPixmap->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 0044 winPixmap->setPixmap(QPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kcontrol/pics/onlyone.png")))); 0045 winPixmap->setFixedSize(winPixmap->sizeHint()); 0046 0047 cbNewWin = new QCheckBox(i18n("Open folders in separate &windows"), widget()); 0048 cbNewWin->setToolTip(i18n("If this option is checked, Konqueror will open a new window when " 0049 "you open a folder, rather than showing that folder's contents in the current window.")); 0050 connect(cbNewWin, &QAbstractButton::toggled, this, &KBehaviourOptions::markAsChanged); 0051 connect(cbNewWin, &QAbstractButton::toggled, this, &KBehaviourOptions::updateWinPixmap); 0052 0053 miscLayout->addWidget(cbNewWin); 0054 0055 QHBoxLayout *previewLayout = new QHBoxLayout; 0056 QWidget *spacer = new QWidget(widget()); 0057 spacer->setMinimumSize(20, 0); 0058 spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); 0059 0060 previewLayout->addWidget(spacer); 0061 0062 miscLayout->addLayout(previewLayout); 0063 0064 miscHLayout->addLayout(miscLayout); 0065 miscHLayout->addWidget(winPixmap); 0066 0067 miscGb->setLayout(miscHLayout); 0068 0069 mainLayout->addWidget(miscGb); 0070 0071 cbShowDeleteCommand = new QCheckBox(i18n("Show 'Delete' me&nu entries which bypass the trashcan"), widget()); 0072 mainLayout->addWidget(cbShowDeleteCommand); 0073 connect(cbShowDeleteCommand, &QAbstractButton::toggled, this, &KBehaviourOptions::markAsChanged); 0074 0075 cbShowDeleteCommand->setToolTip(i18n("Check this if you want 'Delete' menu commands to be displayed " 0076 "on the desktop and in the file manager's menus and context menus. " 0077 "You can always delete files by holding the Shift key " 0078 "while calling 'Move to Trash'.")); 0079 0080 mainLayout->addStretch(); 0081 } 0082 0083 KBehaviourOptions::~KBehaviourOptions() 0084 { 0085 } 0086 0087 void KBehaviourOptions::load() 0088 { 0089 KConfigGroup cg(g_pConfig, groupname); 0090 cbNewWin->setChecked(cg.readEntry("AlwaysNewWin", false)); 0091 updateWinPixmap(cbNewWin->isChecked()); 0092 0093 KSharedConfig::Ptr globalconfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); 0094 KConfigGroup cg2(globalconfig, "KDE"); 0095 cbShowDeleteCommand->setChecked(cg2.readEntry("ShowDeleteCommand", false)); 0096 } 0097 0098 void KBehaviourOptions::defaults() 0099 { 0100 cbNewWin->setChecked(false); 0101 0102 cbShowDeleteCommand->setChecked(false); 0103 } 0104 0105 void KBehaviourOptions::save() 0106 { 0107 KConfigGroup cg(g_pConfig, groupname); 0108 0109 cg.writeEntry("AlwaysNewWin", cbNewWin->isChecked()); 0110 0111 KSharedConfig::Ptr globalconfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); 0112 KConfigGroup cg2(globalconfig, "KDE"); 0113 cg2.writeEntry("ShowDeleteCommand", cbShowDeleteCommand->isChecked()); 0114 cg2.sync(); 0115 0116 // Send signal to all konqueror instances 0117 QDBusMessage message = 0118 QDBusMessage::createSignal(QStringLiteral("/KonqMain"), QStringLiteral("org.kde.Konqueror.Main"), QStringLiteral("reparseConfiguration")); 0119 QDBusConnection::sessionBus().send(message); 0120 } 0121 0122 void KBehaviourOptions::updateWinPixmap(bool b) 0123 { 0124 if (b) { 0125 winPixmap->setPixmap(QPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kcontrol/pics/overlapping.png")))); 0126 } else { 0127 winPixmap->setPixmap(QPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kcontrol/pics/onlyone.png")))); 0128 } 0129 } 0130 0131 #include "behaviour.moc"