Improved special field handling in text element.
[jspeed] / src / mainwindowstack.cpp
1 /*
2  * This file is part of jSpeed.
3  *
4  * jSpeed is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * jSpeed is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with jSpeed.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18
19 #include "widgetscreen.h"
20 #include "mainwindowstack.h"
21
22 MainWindowStack::MainWindowStack(QWidget* parent): WidgetScreen(parent),
23 currentScreen_(-1)
24 {
25 }
26
27 void MainWindowStack::addScreen(WidgetScreen* screen)
28 {
29     screens_.push_back(screen);
30     connect(screen, SIGNAL(minimizePressed()), this, SIGNAL(minimizePressed()));
31     connect(screen, SIGNAL(settingsPressed()), this, SIGNAL(settingsPressed()));
32     connect(screen, SIGNAL(closePressed()), this, SIGNAL(closePressed()));
33     connect(screen, SIGNAL(clicked()), this, SLOT(toggleScreen()));
34     addWidget(screen);
35
36     if(currentScreen_ == -1)
37     {
38         toggleScreen();
39     }
40 }
41
42 void MainWindowStack::reArrange()
43 {
44     for(int i = 0; i < screens_.size(); i++)
45     {
46         screens_.at(i)->reArrange();
47     }
48 }
49
50 void MainWindowStack::flip()
51 {
52     for(int i = 0; i < screens_.size(); i++)
53     {
54         screens_.at(i)->flip();
55     }
56 }
57
58 void MainWindowStack::toggleScreen()
59 {
60     if(currentScreen_ < 0)
61     {
62         currentScreen_ = 0;
63     }
64     else
65     {
66         currentScreen_++;
67
68         if(currentScreen_ >= screens_.size())
69         {
70             currentScreen_ = 0;
71         }
72     }
73
74     setCurrentIndex(currentScreen_);
75 }