Initial commit
[tietoopcom] / src / TocUi / TocAccountIntermediateWidget.cpp
1 /** \file TocAccountIntermediateWidget.cpp
2  * \brief Implementation of TocAccountIntermediateWidget class
3  * 
4  * Tieto Open Communicator - Client for the Telepathy communications framework.
5  * Copyright (c) 2010, Tieto Corporation
6  *
7  * All rights reserved.
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
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.
19  *
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.
29  * 
30  */
31  
32 #include "TocAccountIntermediateWidget"
33 #include <QPushButton>
34 #include <QGridLayout>
35 #include <QHBoxLayout>
36 #include <QVBoxLayout>
37 #include <QFrame>
38 #include "macros.h"
39
40 TocAccountIntermediateWidget::TocAccountIntermediateWidget(QWidget * parent, Qt::WindowFlags flags)
41         : QWidget(parent, flags) { 
42
43         setContentsMargins( -10, -10, -10, -10 );
44         setObjectName("intermediateWidget");
45
46     QGridLayout* gridLayout = new QGridLayout(this);
47     _pIntermediateFrame = new QFrame( this );
48     _pIntermediateFrame->setObjectName("intermediateFrame");
49     gridLayout->addWidget( _pIntermediateFrame );
50     
51     QHBoxLayout* mainHorizontalLayout = new QHBoxLayout( _pIntermediateFrame );
52
53     //1st layout - vertical - back button + strech
54     QVBoxLayout* vLayout1 = new QVBoxLayout();
55
56     vLayout1->addStretch(1);
57     
58     _pBackButton = new QPushButton(tr("Back"), this);
59     _pBackButton->setObjectName("backButton");
60     vLayout1->addWidget(_pBackButton);
61     
62     mainHorizontalLayout->addLayout(vLayout1);
63     
64     //2nd layout - vertical - for Create and Edit buttons
65     QVBoxLayout* vLayout2 = new QVBoxLayout();
66
67     vLayout2->addStretch(1);
68     
69     QHBoxLayout* hLayout1 = new QHBoxLayout();
70
71     hLayout1->addStretch(1);
72     
73     _pCreateButton = new QPushButton(tr("Create\nnew"), this);
74     _pCreateButton->setObjectName("createButton");
75     hLayout1->addWidget(_pCreateButton);
76     
77     hLayout1->addStretch(1);    
78
79     _pEditButton = new QPushButton(tr("Edit"), this);
80     _pEditButton->setObjectName("editButton");
81     hLayout1->addWidget(_pEditButton);
82     
83     hLayout1->addStretch(1);
84
85     vLayout2->addLayout( hLayout1 );
86     vLayout2->addStretch(2);
87         
88     mainHorizontalLayout->addLayout(vLayout2);
89  
90
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);
95     
96     mainHorizontalLayout->addLayout(hLayout3);
97         
98     
99     setupStyles();
100
101     CONNECT(_pBackButton, SIGNAL(clicked()), this, SIGNAL(backClicked()));
102     CONNECT(_pEditButton, SIGNAL(clicked()), this, SIGNAL(editClicked()));
103     CONNECT(_pCreateButton, SIGNAL(clicked()), this, SIGNAL(createClicked()));
104 }
105
106 TocAccountIntermediateWidget::~TocAccountIntermediateWidget() {
107
108 }
109
110 void TocAccountIntermediateWidget::setupStyles() {
111         setStyleSheet("QPushButton {  }");
112         _pCreateButton->setStyleSheet(
113                 "QPushButton {"
114                         "font: bold 16px;"
115                 "border-radius: 5px;"
116                         "min-height: 120px;"
117                         "min-width: 140px;"
118                         "max-height: 120px;"
119                         "max-width: 140px;"
120                 "}"
121         );
122
123         _pEditButton->setStyleSheet(
124                 "QPushButton {"
125                         "font: bold 16px;"
126                 "border-radius: 5px;"
127                         "min-height: 120px;"
128                         "min-width: 140px;"
129                         "max-height: 120px;"
130                         "max-width: 140px;"
131                 "}"
132         );
133
134         _pBackButton->setStyleSheet(
135                 "QPushButton {"
136                         "font: bold 16px;"
137                 "border-radius: 5px;"
138                         "min-height: 80px;"
139                         "min-width: 80px;"
140                         "max-height: 80px;"
141                         "max-width: 80px;"
142                 "}"
143         );
144 }
145
146 void TocAccountIntermediateWidget::enableFTUMode( bool ftu ) {
147         _pBackButton->setHidden(ftu);
148
149         if(ftu) {
150                 _pEditButton->setText(tr("Use\nexisting"));
151         } else {
152                 _pEditButton->setText(tr("Edit"));
153         }
154 }