1 /** \file TocAccountIntermediateWidget.cpp
2 * \brief Implementation of TocAccountIntermediateWidget class
4 * Tieto Open Communicator - Client for the Telepathy communications framework.
5 * Copyright (c) 2010, Tieto Corporation
8 * Redistribution and use in source and binary forms, with or without modification,
9 * are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * Neither the name of the Tieto Corporation nor the names of its contributors
17 * may be used to endorse or promote products derived from this software without
18 * specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "TocAccountIntermediateWidget"
33 #include <QPushButton>
34 #include <QGridLayout>
35 #include <QHBoxLayout>
36 #include <QVBoxLayout>
40 TocAccountIntermediateWidget::TocAccountIntermediateWidget(QWidget * parent, Qt::WindowFlags flags)
41 : QWidget(parent, flags) {
43 setContentsMargins( -10, -10, -10, -10 );
44 setObjectName("intermediateWidget");
46 QGridLayout* gridLayout = new QGridLayout(this);
47 _pIntermediateFrame = new QFrame( this );
48 _pIntermediateFrame->setObjectName("intermediateFrame");
49 gridLayout->addWidget( _pIntermediateFrame );
51 QHBoxLayout* mainHorizontalLayout = new QHBoxLayout( _pIntermediateFrame );
53 //1st layout - vertical - back button + strech
54 QVBoxLayout* vLayout1 = new QVBoxLayout();
56 vLayout1->addStretch(1);
58 _pBackButton = new QPushButton(tr("Back"), this);
59 _pBackButton->setObjectName("backButton");
60 vLayout1->addWidget(_pBackButton);
62 mainHorizontalLayout->addLayout(vLayout1);
64 //2nd layout - vertical - for Create and Edit buttons
65 QVBoxLayout* vLayout2 = new QVBoxLayout();
67 vLayout2->addStretch(1);
69 QHBoxLayout* hLayout1 = new QHBoxLayout();
71 hLayout1->addStretch(1);
73 _pCreateButton = new QPushButton(tr("Create\nnew"), this);
74 _pCreateButton->setObjectName("createButton");
75 hLayout1->addWidget(_pCreateButton);
77 hLayout1->addStretch(1);
79 _pEditButton = new QPushButton(tr("Edit"), this);
80 _pEditButton->setObjectName("editButton");
81 hLayout1->addWidget(_pEditButton);
83 hLayout1->addStretch(1);
85 vLayout2->addLayout( hLayout1 );
86 vLayout2->addStretch(2);
88 mainHorizontalLayout->addLayout(vLayout2);
91 //3rd layout - horizontal - just to add stretch
92 QHBoxLayout* hLayout3 = new QHBoxLayout();
93 QSpacerItem* spacer = new QSpacerItem(_pBackButton->width(), 0);
94 hLayout3->addItem(spacer);
96 mainHorizontalLayout->addLayout(hLayout3);
101 CONNECT(_pBackButton, SIGNAL(clicked()), this, SIGNAL(backClicked()));
102 CONNECT(_pEditButton, SIGNAL(clicked()), this, SIGNAL(editClicked()));
103 CONNECT(_pCreateButton, SIGNAL(clicked()), this, SIGNAL(createClicked()));
106 TocAccountIntermediateWidget::~TocAccountIntermediateWidget() {
110 void TocAccountIntermediateWidget::setupStyles() {
111 setStyleSheet("QPushButton { }");
112 _pCreateButton->setStyleSheet(
115 "border-radius: 5px;"
123 _pEditButton->setStyleSheet(
126 "border-radius: 5px;"
134 _pBackButton->setStyleSheet(
137 "border-radius: 5px;"
146 void TocAccountIntermediateWidget::enableFTUMode( bool ftu ) {
147 _pBackButton->setHidden(ftu);
150 _pEditButton->setText(tr("Use\nexisting"));
152 _pEditButton->setText(tr("Edit"));