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