00001 #include <iostream>
00002 using namespace std;
00003
00004 #include <qlayout.h>
00005 #include <qpushbutton.h>
00006 #include <qbuttongroup.h>
00007 #include <qlabel.h>
00008 #include <qcursor.h>
00009 #include <qapplication.h>
00010
00011 #include "dialogbox.h"
00012 #include "mythcontext.h"
00013 #include "mythwidgets.h"
00014
00015 #ifdef USING_MINGW
00016 #undef DialogBox
00017 #endif
00018
00019 DialogBox::DialogBox(MythMainWindow *parent, const QString &text,
00020 const char *checkboxtext,
00021 const char *name)
00022 : MythDialog(parent, name)
00023 {
00024 QLabel *maintext = new QLabel(text, this);
00025 maintext->setBackgroundOrigin(WindowOrigin);
00026 maintext->setAlignment(Qt::WordBreak | Qt::AlignLeft | Qt::AlignTop);
00027
00028 box = new QVBoxLayout(this, (int)(60 * wmult), (int)(0 * hmult));
00029
00030 box->addWidget(maintext, 1);
00031
00032 checkbox = NULL;
00033 if (checkboxtext)
00034 {
00035 checkbox = new MythCheckBox(this);
00036 checkbox->setText(checkboxtext);
00037 checkbox->setBackgroundOrigin(WindowOrigin);
00038 box->addWidget(checkbox, 0);
00039 }
00040
00041 buttongroup = new QButtonGroup(0);
00042
00043 if (checkbox)
00044 buttongroup->insert(checkbox);
00045 connect(buttongroup, SIGNAL(clicked(int)), this, SLOT(buttonPressed(int)));
00046 }
00047
00048 void DialogBox::AddButton(const QString &title)
00049 {
00050 MythPushButton *button = new MythPushButton(title, this);
00051
00052 if (buttongroup->count() == 0 ||
00053 (checkbox && buttongroup->count() == 1))
00054 {
00055 button->setFocus();
00056 }
00057
00058 buttongroup->insert(button);
00059
00060 box->addWidget(button, 0);
00061 }
00062
00063 void DialogBox::buttonPressed(int which)
00064 {
00065 if (buttongroup->find(which) != checkbox)
00066 AcceptItem(which);
00067 }