File indexing completed on 2024-04-28 04:02:31
0001 /*************************************************************************** 0002 dlgquickconnect.cpp - QuickConnect dialog 0003 This file is a part of KMuddy distribution. 0004 ------------------- 0005 begin : Út Jul 23 2002 0006 copyright : (C) 2002 by Tomas Mecir 0007 email : kmuddy@kmuddy.com 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 #include "dlgquickconnect.h" 0020 0021 #include <QDialogButtonBox> 0022 #include <QGridLayout> 0023 #include <QLabel> 0024 #include <QLineEdit> 0025 #include <QPushButton> 0026 #include <QSpinBox> 0027 0028 #include <KLocalizedString> 0029 0030 dlgQuickConnect::dlgQuickConnect(QWidget *parent) : QDialog (parent) 0031 { 0032 //initial dialog size 0033 setWindowTitle (i18n ("Quick Connect")); 0034 0035 QGridLayout *layout = new QGridLayout (this); 0036 0037 //put some edit boxes there 0038 QLabel *l1 = new QLabel (i18n ("&Host:"), this); 0039 ed1 = new QLineEdit (this); 0040 QLabel *l2 = new QLabel (i18n ("&Port:"), this); 0041 ed2 = new QSpinBox (this); 0042 ed2->setRange(1, 65535); 0043 ed2->setValue(23); 0044 int w = std::max (l1->width(), l2->width()); 0045 l1->setFixedWidth (w); 0046 l2->setFixedWidth (w); 0047 ed1->setGeometry (ed1->x(), ed1->y(), 200, ed1->height()); 0048 ed2->setFixedWidth (80); 0049 0050 l1->setBuddy (ed1); 0051 l2->setBuddy (ed2); 0052 0053 QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0054 QPushButton *button = buttons->button (QDialogButtonBox::Ok); 0055 button->setText (i18n ("&Connect")); 0056 button->setToolTip (i18n ("Establishes connection with specified parameters.")); 0057 connect (buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); 0058 connect (buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); 0059 0060 layout->addWidget (l1, 0, 0); 0061 layout->addWidget (l2, 1, 0); 0062 layout->addWidget (ed1, 0, 1); 0063 layout->addWidget (ed2, 1, 1); 0064 layout->addWidget (buttons, 2, 0, 1, 2); 0065 0066 //humm, this one seems to be causing some X Error 42 BadMatch... 0067 //I have no idea why does it happen; however, everything seems 0068 //to be working perfectly... 0069 ed1->setFocus (); 0070 } 0071 0072 dlgQuickConnect::~dlgQuickConnect() 0073 { 0074 //all widgets are destroyed in Qt's destructors, so we needn't care about it 0075 0076 } 0077 0078 QSize dlgQuickConnect::sizeHint() const 0079 { 0080 return QSize (300, 120); 0081 } 0082 0083 QString dlgQuickConnect::host () 0084 { 0085 return ed1->text(); 0086 } 0087 0088 int dlgQuickConnect::port () 0089 { 0090 return ed2->value(); 0091 } 0092 0093 #include "moc_dlgquickconnect.cpp"