File indexing completed on 2024-04-21 16:33:40

0001 /*
0002  * Copyright 2010, 2011 Bart Kroon <bart@tarmack.eu>
0003  * 
0004  * Redistribution and use in source and binary forms, with or without
0005  * modification, are permitted provided that the following conditions
0006  * are met:
0007  * 
0008  * 1. Redistributions of source code must retain the above copyright
0009  *   notice, this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright
0011  *   notice, this list of conditions and the following disclaimer in the
0012  *   documentation and/or other materials provided with the distribution.
0013  * 
0014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0015  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0016  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0017  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0018  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0019  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0020  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0021  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0023  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0024  */
0025 
0026 #include "Config.h"
0027 
0028 #include <QDialogButtonBox>
0029 #include <QKeySequenceEdit>
0030 #include <KAutostart>
0031 #include <QSettings>
0032 #include <QLabel>
0033 #include <klocalizedstring.h>
0034 #include <QCheckBox>
0035 #include <QGridLayout>
0036 
0037 ConfigDialog::ConfigDialog(QWidget* parent) : QDialog(parent, Qt::Dialog)
0038 {
0039     this->setAttribute(Qt::WA_DeleteOnClose);
0040     setWindowTitle(i18n("Mangonel Configuration"));
0041 
0042     delete layout();
0043     QGridLayout *layout = new QGridLayout;
0044     setLayout(layout);
0045     layout->setAlignment(Qt::AlignHCenter);
0046 
0047     // Shortcut
0048     // TODO: use normal global shortcut stuff
0049     QLabel* hotkeyLabel = new QLabel(i18n("Shortcut to show Mangonel:"), this);
0050     layout->addWidget(hotkeyLabel, 0, 0);
0051     m_hotkeySelect = new QKeySequenceEdit(this);
0052     this->connect(m_hotkeySelect, SIGNAL(keySequenceChanged(const QKeySequence&)), SIGNAL(hotkeyChanged(const QKeySequence&)));
0053     layout->addWidget(m_hotkeySelect, 0, 1);
0054 
0055     QLabel* autostartLabel = new QLabel(i18n("Automatically launch Mangonel on login:"), this);
0056     layout->addWidget(autostartLabel, 1, 0);
0057     QCheckBox *autostartCheck = new QCheckBox(this);
0058     KAutostart as;
0059     autostartCheck->setChecked(as.autostarts());
0060     this->connect(autostartCheck, SIGNAL(toggled(bool)), SLOT(setAutostart(bool)));
0061     layout->addWidget(autostartCheck, 1, 1);
0062 
0063     // Add close button.
0064     QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
0065     this->connect(buttons, SIGNAL(rejected()), this, SLOT(close()));
0066     layout->addWidget(buttons);
0067 }
0068 
0069 ConfigDialog::~ConfigDialog()
0070 {
0071 }
0072 
0073 void ConfigDialog::setHotkey(QKeySequence hotkey)
0074 {
0075     m_hotkeySelect->setKeySequence(hotkey);
0076 }
0077 
0078 void ConfigDialog::setAutostart(bool autostart)
0079 {
0080     KAutostart as;
0081     as.setAutostarts(autostart);
0082 }
0083 
0084 // kate: indent-mode cstyle; space-indent on; indent-width 4;