QTfrontend/AbstractPage.cpp
changeset 6042 8b5345758f62
parent 6038 58d9badf3e7f
equal deleted inserted replaced
6040:a740069c21e3 6042:8b5345758f62
    23     Q_UNUSED(parent);
    23     Q_UNUSED(parent);
    24 
    24 
    25     font14 = new QFont("MS Shell Dlg", 14);
    25     font14 = new QFont("MS Shell Dlg", 14);
    26 }
    26 }
    27 
    27 
       
    28 void AbstractPage::initPage()
       
    29 {
       
    30     QGridLayout * pageLayout = new QGridLayout(this);
       
    31 
       
    32     // stretch grid space for body and footer
       
    33     pageLayout->setColumnStretch(0,0);
       
    34     pageLayout->setColumnStretch(1,1);
       
    35     pageLayout->setRowStretch(0,1);
       
    36     pageLayout->setRowStretch(1,0);
       
    37 
       
    38     // add back/exit button
       
    39     btnBack = formattedButton(":/res/Exit.png", true);
       
    40     pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom);
       
    41 
       
    42     // add body layout as defined by the subclass
       
    43     pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 2);
       
    44 
       
    45     // add footer layout
       
    46     QLayout * fld = footerLayoutDefinition();
       
    47     if (fld != NULL)
       
    48         pageLayout->addLayout(fld, 1, 1);
       
    49 
       
    50     // connect signals
       
    51     connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
       
    52     connectSignals();
       
    53 }
       
    54 
    28 QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
    55 QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
    29 {
    56 {
    30     QPushButton* btn = new QPushButton(this);
    57     QPushButton * btn = new QPushButton(this);
    31 
    58 
    32     if (hasIcon)
    59     if (hasIcon)
    33     {
    60     {
    34         const QIcon& lp=QIcon(btname);
    61         const QIcon& lp=QIcon(btname);
    35         QSize sz = lp.actualSize(QSize(65535, 65535));
    62         QSize sz = lp.actualSize(QSize(65535, 65535));
    47     return btn;
    74     return btn;
    48 }
    75 }
    49 
    76 
    50 QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
    77 QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
    51 {
    78 {
    52     QPushButton* btn = formattedButton(btname, hasIcon);
    79     QPushButton * btn = formattedButton(btname, hasIcon);
    53     grid->addWidget(btn, wy, wx);
    80     grid->addWidget(btn, wy, wx);
    54     return btn;
    81     return btn;
    55 }
    82 }
    56 
    83 
    57 QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
    84 QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
    58 {
    85 {
    59     QPushButton* btn = formattedButton(btname, hasIcon);
    86     QPushButton * btn = formattedButton(btname, hasIcon);
    60     grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
    87     grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
    61     return btn;
    88     return btn;
    62 }
    89 }
    63 
    90 
    64 QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
    91 QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
    65 {
    92 {
    66     QPushButton* btn = formattedButton(btname, hasIcon);
    93     QPushButton * btn = formattedButton(btname, hasIcon);
    67     box->addWidget(btn, where);
    94     box->addWidget(btn, where);
    68     return btn;
    95     return btn;
    69 }
    96 }
    70 
    97 
       
    98 void AbstractPage::setBackButtonVisible(bool visible)
       
    99 {
       
   100     btnBack->setVisible(visible);
       
   101 }