Theme download link fixed in web page.
[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 "mainwindowstack.h"
20
21 MainWindowStack::MainWindowStack(QWidget* parent): WidgetScreen(parent),
22 currentScreen_(-1)
23 {
24 }
25
26 void MainWindowStack::addScreen(WidgetScreen* screen)
27 {
28     screens_.push_back(screen);
29     connect(screen, SIGNAL(minimizePressed()), this, SIGNAL(minimizePressed()));
30     connect(screen, SIGNAL(settingsPressed()), this, SIGNAL(settingsPressed()));
31     connect(screen, SIGNAL(closePressed()), this, SIGNAL(closePressed()));
32     connect(screen, SIGNAL(clicked()), this, SLOT(toggleScreen()));
33     addWidget(screen);
34
35     if(currentScreen_ == -1)
36     {
37         toggleScreen();
38     }
39 }
40
41 void MainWindowStack::reArrange()
42 {
43     for(int i = 0; i < screens_.size(); i++)
44     {
45         screens_.at(i)->reArrange();
46     }
47 }
48
49 void MainWindowStack::flip()
50 {
51     for(int i = 0; i < screens_.size(); i++)
52     {
53         screens_.at(i)->flip();
54     }
55 }
56
57 void MainWindowStack::toggleScreen()
58 {
59     if(currentScreen_ < 0)
60     {
61         currentScreen_ = 0;
62     }
63     else
64     {
65         currentScreen_++;
66
67         if(currentScreen_ >= screens_.size())
68         {
69             currentScreen_ = 0;
70         }
71     }
72
73     setCurrentIndex(currentScreen_);
74 }