Initial commit
[tietoopcom] / src / TocUi / TocSettingsWidget.cpp
1 /** \file TocSettingsWidget.cpp
2  * \brief Implementation of TocSettingsWidget 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 "TocSettingsWidget"
33 #include <QSignalMapper>
34 #include <QGridLayout>
35 #include <QPushButton>
36 #include <QSpacerItem>
37 #include <QFrame>
38 #include "uidefs.h"
39 #include "macros.h"
40
41 TocSettingsWidget::TocSettingsWidget(QWidget * parent, Qt::WindowFlags flags) :
42         QWidget(parent, flags) {
43
44         setContentsMargins(-10, -10, -10, -10);
45         setObjectName("settingsWidget");
46
47         QGridLayout* gridLayout = new QGridLayout(this);
48         settingsFrame = new QFrame(this);
49         settingsFrame->setObjectName("settingsFrame");
50         gridLayout->addWidget(settingsFrame);
51         QVBoxLayout* vLayout = new QVBoxLayout(settingsFrame);
52
53         vLayout->addStretch(1);
54
55         QHBoxLayout* hLayout = new QHBoxLayout();
56
57         generalButton = new QPushButton(tr("General"), this);
58         generalButton->setObjectName("generalButton");
59         hLayout->addWidget(generalButton);
60
61         accountButton = new QPushButton(tr("Account"), this);
62         accountButton->setObjectName("accountButton");
63         hLayout->addWidget(accountButton);
64
65         themesButton = new QPushButton(tr("Themes"), this);
66         themesButton->setObjectName("themesButton");
67         hLayout->addWidget(themesButton);
68
69         vLayout->addLayout(hLayout);
70         vLayout->addStretch(2);
71
72         signalMapper = new QSignalMapper(this);
73         signalMapper->setMapping(generalButton, static_cast<int>(General));
74         signalMapper->setMapping(accountButton, static_cast<int>(AccountIntermediate));
75         signalMapper->setMapping(themesButton, static_cast<int>(Themes));
76
77         CONNECT(generalButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
78         CONNECT(accountButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
79         CONNECT(themesButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
80
81         CONNECT(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(triggered(int)));
82
83         setupStyles();
84 }
85
86 TocSettingsWidget::~TocSettingsWidget() {
87 }
88
89 void TocSettingsWidget::setupStyles() {
90
91         generalButton->setStyleSheet("QPushButton {"
92                 "font: bold 16px;"
93                 "text-align: bottom;"
94                 "border-radius: 5px;"
95                 "background-image: url(:/general.png);"
96                 "background-repeat:no-repeat;"
97                 "background-position:center center;"
98                 "min-height: 120px;"
99                 "min-width: 140px;"
100                 "max-height: 120px;"
101                 "max-width: 140px;"
102                 "}");
103
104         accountButton->setStyleSheet("QPushButton {"
105                 "font: bold 16px;"
106                 "text-align: bottom;"
107                 "border-radius: 5px;"
108                 "background-image: url(:/account.png);"
109                 "background-repeat:no-repeat;"
110                 "background-position:center center;"
111                 "min-height: 120px;"
112                 "min-width: 140px;"
113                 "max-height: 120px;"
114                 "max-width: 140px;"
115                 "}");
116
117         themesButton->setStyleSheet("QPushButton {"
118                 "font: bold 16px;"
119                 "text-align: bottom;"
120                 "border-radius: 5px;"
121                 "background-image: url(:/themes.png);"
122                 "background-repeat:no-repeat;"
123                 "background-position:center center;"
124                 "min-height: 120px;"
125                 "min-width: 140px;"
126                 "max-height: 120px;"
127                 "max-width: 140px;"
128                 "}");
129 }