From d45eb9aa24f34827965c55bad35ea0ea9bc9aee4 Mon Sep 17 00:00:00 2001 From: Espen Sand Date: Sun, 19 Mar 2000 19:35:28 +0000 Subject: [PATCH] RIP dear dialog based on setGeometry() and fixed sizes. New "Add Account" dialog box based on KDialogBase. svn path=/trunk/kdenetwork/kmail/; revision=44055 --- kmacctseldlg.cpp | 103 ++++++++++++++++++++++++----------------------- kmacctseldlg.h | 57 +++++++++++++++++--------- 2 files changed, 90 insertions(+), 70 deletions(-) diff --git a/kmacctseldlg.cpp b/kmacctseldlg.cpp index e92b61e0d..7cf94a6ba 100644 --- a/kmacctseldlg.cpp +++ b/kmacctseldlg.cpp @@ -1,68 +1,71 @@ -// kmacctseldlg.cpp +/* + * kmail: KDE mail client + * This file: Copyright (C) 2000 Espen Sand, + * Contains code segments and ideas from earlier kmail dialog code + * by Stefan Taferner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ -#include #include -#include -#include #include +#include -#include "kmacctseldlg.h" -#include "kmglobal.h" #include -//----------------------------------------------------------------------------- -KMAcctSelDlg::KMAcctSelDlg(QWidget* parent, const char* name): - KMAcctSelDlgInherited(parent, name, TRUE) -{ - QPushButton *cancel; - QRadioButton *rbtn; - - initMetaObject(); - - setFixedSize(230,180); - setCaption(name); - mSelBtn = 0; +#include "kmacctseldlg.h" +#include "kmacctseldlg.moc" - grp = new QButtonGroup(i18n("Account Type"), this); - grp->resize(230, 140); - connect(grp, SIGNAL(clicked(int)), SLOT(buttonClicked(int))); +KMAcctSelDlg::KMAcctSelDlg( QWidget *parent, const char *name, bool modal ) + : KDialogBase( parent, name, modal, i18n("Add Account"), Ok|Cancel, Ok ) +{ + QFrame *page = makeMainWidget(); + QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); + + QButtonGroup *group = new QButtonGroup( i18n("Account Type"), page ); + connect(group, SIGNAL(clicked(int)), SLOT(buttonClicked(int)) ); - ok = new QPushButton(i18n("OK"), this); - ok->adjustSize(); - ok->setMinimumSize(ok->sizeHint()); - ok->resize(100, ok->size().height()); - ok->move(10, 175-ok->size().height()); - ok->setEnabled(FALSE); - connect(ok, SIGNAL(clicked()), SLOT(accept())); + topLayout->addWidget( group, 10 ); + QVBoxLayout *vlay = new QVBoxLayout( group, spacingHint()*2, spacingHint() ); + vlay->addSpacing( fontMetrics().lineSpacing() ); + + QRadioButton *radioButton1 = new QRadioButton(i18n("Local Mailbox"), group ); + vlay->addWidget( radioButton1 ); + QRadioButton *radioButton2 = new QRadioButton(i18n("Pop3"), group ); + vlay->addWidget( radioButton2 ); + QRadioButton *radioButton3 = + new QRadioButton(i18n("Experimental Pop3"), group ); + vlay->addWidget( radioButton3 ); - cancel = new QPushButton(i18n("Cancel"), this); - cancel->adjustSize(); - cancel->setMinimumSize(cancel->sizeHint()); - cancel->resize(100, cancel->size().height()); - cancel->move(120, 175-cancel->size().height()); - connect(cancel, SIGNAL(clicked()), SLOT(reject())); + vlay->addStretch( 10 ); - rbtn = new QRadioButton(i18n("Local Mailbox"), grp); - rbtn->adjustSize(); - rbtn->move(30,30); + radioButton2->setChecked(true); // Pop is most common ? + buttonClicked(1); +} - rbtn = new QRadioButton(i18n("Pop3"), grp); - rbtn->adjustSize(); - rbtn->move(30,60); - rbtn = new QRadioButton(i18n("Experimental Pop3"), grp); - rbtn->adjustSize(); - rbtn->move(30,90); +void KMAcctSelDlg::buttonClicked( int id ) +{ + mSelectedButton = id; } -//----------------------------------------------------------------------------- -void KMAcctSelDlg::buttonClicked(int id) -{ - mSelBtn = id; - ok->setEnabled(TRUE); +int KMAcctSelDlg::selected( void ) const +{ + return mSelectedButton; } -//----------------------------------------------------------------------------- -#include "kmacctseldlg.moc" diff --git a/kmacctseldlg.h b/kmacctseldlg.h index b53022115..8be7e36c8 100644 --- a/kmacctseldlg.h +++ b/kmacctseldlg.h @@ -1,34 +1,51 @@ -/* Select account from given list of account types - * Author: Stefan Taferner +/* + * kmail: KDE mail client + * This file: Copyright (C) 2000 Espen Sand, + * Contains code segments and ideas from earlier kmail dialog code + * by Stefan Taferner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * */ -#ifndef kmacctseldlg_h -#define kmacctseldlg_h -#include +// Select account from given list of account types -class QButtonGroup; -class QPushButton; +#ifndef kmacctseldlg_h +#define kmacctseldlg_h -#define KMAcctSelDlgInherited QDialog +#include -class KMAcctSelDlg: public QDialog +class KMAcctSelDlg: public KDialogBase { Q_OBJECT -public: - KMAcctSelDlg(QWidget* parent=0, const char* name=0); + public: + KMAcctSelDlg( QWidget *parent=0, const char *name=0, bool modal=true ); - /** Returns selected button from the account selection group: - 0=local mail, 1=pop3, 2=experimental pop3. */ - int selected(void) const { return mSelBtn; } + /** + * Returns selected button from the account selection group: + * 0=local mail, 1=pop3, 2=experimental pop3. + */ + int selected(void) const; -protected slots: - void buttonClicked(int); + private slots: + void buttonClicked(int); -protected: - QButtonGroup* grp; - QPushButton* ok; - int mSelBtn; + private: + int mSelectedButton; }; + #endif /*kmacctseldlg_h*/