File indexing completed on 2024-06-23 05:20:46
0001 /* 0002 Copyright (C) 2012, 2013 by Glad Deschrijver <glad.deschrijver@gmail.com> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public License as 0006 published by the Free Software Foundation; either version 2 of 0007 the License or (at your option) version 3 or any later version 0008 accepted by the membership of KDE e.V. (or its successor approved 0009 by the membership of KDE e.V.), which shall act as a proxy 0010 defined in Section 14 of version 3 of the license. 0011 0012 This program is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 GNU General Public License for more details. 0016 0017 You should have received a copy of the GNU General Public License 0018 along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #include "ShortcutConfigDialog.h" 0022 0023 #ifndef QT_NO_SHORTCUT 0024 0025 #include <QDialogButtonBox> 0026 0027 #include "ShortcutConfigWidget.h" 0028 #include "ShortcutHandler.h" 0029 0030 namespace Gui 0031 { 0032 0033 ShortcutConfigDialog::ShortcutConfigDialog(QWidget *parent) 0034 : QDialog(parent) 0035 { 0036 setModal(true); 0037 setWindowTitle(tr("Configure Shortcuts") + QLatin1String(" - ") + tr("Trojitá")); 0038 0039 m_shortcutConfigWidget = new ShortcutConfigWidget(this); 0040 connect(m_shortcutConfigWidget, &ShortcutConfigWidget::shortcutsChanged, this, &ShortcutConfigDialog::shortcutsChanged); 0041 0042 QDialogButtonBox *buttonBox = new QDialogButtonBox(this); 0043 buttonBox->addButton(QDialogButtonBox::Ok); 0044 buttonBox->addButton(QDialogButtonBox::Cancel); 0045 connect(buttonBox, &QDialogButtonBox::accepted, this, &ShortcutConfigDialog::accept); 0046 connect(buttonBox, &QDialogButtonBox::rejected, this, &ShortcutConfigDialog::reject); 0047 0048 QWidget *buttonWidget = new QWidget(this); 0049 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonWidget); 0050 buttonLayout->addWidget(m_shortcutConfigWidget->clearButton()); 0051 buttonLayout->addWidget(m_shortcutConfigWidget->useDefaultButton()); 0052 buttonLayout->addStretch(); 0053 buttonLayout->addWidget(buttonBox); 0054 buttonLayout->setContentsMargins(0, 0, 0, 0); 0055 0056 QVBoxLayout *mainLayout = new QVBoxLayout; 0057 mainLayout->addWidget(m_shortcutConfigWidget); 0058 mainLayout->addWidget(buttonWidget); 0059 setLayout(mainLayout); 0060 } 0061 0062 ShortcutConfigDialog::~ShortcutConfigDialog() 0063 { 0064 } 0065 0066 /***************************************************************************/ 0067 0068 void ShortcutConfigDialog::setExclusivityGroups(const QList<QStringList> &groups) 0069 { 0070 m_shortcutConfigWidget->setExclusivityGroups(groups); 0071 } 0072 0073 void ShortcutConfigDialog::setActionDescriptions(const QHash<QString, ActionDescription> &actionDescriptions) 0074 { 0075 m_shortcutConfigWidget->setActionDescriptions(actionDescriptions); 0076 } 0077 0078 /***************************************************************************/ 0079 0080 void ShortcutConfigDialog::accept() 0081 { 0082 m_shortcutConfigWidget->accept(); 0083 QDialog::accept(); 0084 } 0085 0086 void ShortcutConfigDialog::reject() 0087 { 0088 m_shortcutConfigWidget->reject(); 0089 QDialog::reject(); 0090 } 0091 0092 } // namespace Gui 0093 0094 #endif // QT_NO_SHORTCUT