File indexing completed on 2024-05-19 13:31:10
0001 /*************************************************************************** 0002 * Copyright (C) 2016 Christian Ehrlicher <ch.ehrlicher@gmx.de> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0018 ***************************************************************************/ 0019 0020 #include "ksvndialog.h" 0021 0022 #include "helpers/windowgeometryhelper.h" 0023 #include <KHelpClient> 0024 #include <QApplication> 0025 #include <QDialogButtonBox> 0026 #include <QPushButton> 0027 #include <QVBoxLayout> 0028 0029 KSvnDialog::KSvnDialog(const QString &configGroupName, QWidget *parent) 0030 : QDialog(parent ? parent : QApplication::activeModalWidget()) 0031 , m_configGroupName(configGroupName) 0032 { 0033 } 0034 0035 KSvnDialog::~KSvnDialog() 0036 { 0037 WindowGeometryHelper::save(this, m_configGroupName); 0038 } 0039 0040 void KSvnDialog::setDefaultButton(QPushButton *defaultButton) 0041 { 0042 if (defaultButton) { 0043 defaultButton->setDefault(true); 0044 defaultButton->setShortcut(Qt::CTRL | Qt::Key_Return); 0045 } 0046 } 0047 0048 void KSvnDialog::showEvent(QShowEvent *e) 0049 { 0050 QDialog::showEvent(e); 0051 WindowGeometryHelper::restore(this, m_configGroupName); 0052 } 0053 0054 // ---------------------------------------------------------------- 0055 KSvnSimpleOkDialog::KSvnSimpleOkDialog(const QString &configGroupName, QWidget *parent) 0056 : KSvnDialog(configGroupName, parent) 0057 , m_layout(new QVBoxLayout(this)) 0058 , m_bBox(new QDialogButtonBox(QDialogButtonBox::Ok, this)) 0059 , m_bBoxAdded(false) 0060 { 0061 connect(m_bBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0062 connect(m_bBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0063 connect(m_bBox, &QDialogButtonBox::helpRequested, this, &KSvnSimpleOkDialog::onHelpRequested); 0064 setDefaultButton(m_bBox->button(QDialogButtonBox::Ok)); 0065 } 0066 0067 void KSvnSimpleOkDialog::setWithCancelButton() 0068 { 0069 m_bBox->setStandardButtons(m_bBox->standardButtons() | QDialogButtonBox::Cancel); 0070 } 0071 0072 void KSvnSimpleOkDialog::addWidget(QWidget *widget) 0073 { 0074 m_layout->addWidget(widget); 0075 } 0076 0077 void KSvnSimpleOkDialog::addButtonBox() 0078 { 0079 if (!m_bBoxAdded) { 0080 m_bBoxAdded = true; 0081 m_layout->addWidget(m_bBox); 0082 } 0083 } 0084 0085 void KSvnSimpleOkDialog::setHelp(const QString &context) 0086 { 0087 m_helpContext = context; 0088 m_bBox->setStandardButtons(m_bBox->standardButtons() | QDialogButtonBox::Help); 0089 } 0090 0091 int KSvnSimpleOkDialog::exec() 0092 { 0093 addButtonBox(); 0094 return KSvnDialog::exec(); 0095 } 0096 0097 void KSvnSimpleOkDialog::onHelpRequested() 0098 { 0099 KHelpClient::invokeHelp(m_helpContext, QLatin1String("kdesvn")); 0100 } 0101 0102 #include "moc_ksvndialog.cpp"