1 #include "BootSplash.h"
2 #include "ui_BootSplash.h"
3
4 #include <LuminaXDG.h>
5 #include <LUtils.h>
6 #include <LDesktopUtils.h>
7
BootSplash()8 BootSplash::BootSplash() : QWidget(0, Qt::SplashScreen | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus), ui(new Ui::BootSplash){
9 ui->setupUi(this);
10 this->setObjectName("LuminaBootSplash"); //for theme styling
11 //Center the window on the primary screen
12 this->show();
13 QPoint ctr = QApplication::desktop()->screenGeometry().center();
14 this->move( ctr.x()-(this->width()/2), ctr.y()-(this->height()/2) );
15 generateTipOfTheDay();
16 ui->label_version->setText( QString(tr("Version %1")).arg(LDesktopUtils::LuminaDesktopVersion()) );
17 }
18
generateTipOfTheDay()19 void BootSplash::generateTipOfTheDay(){
20 //Try to find a system-defined message of the day for lumina
21 QStringList dirs; dirs << LOS::AppPrefix()+"/etc/" << LOS::SysPrefix()+"/etc/" << L_ETCDIR+"/";
22 QString sysMOTD = "lumina-motd";
23 for(int i=0; i<dirs.length(); i++){
24 if(QFile::exists(dirs[i]+sysMOTD)){ sysMOTD.prepend(dirs[i]); break; }
25 }
26
27 QString tip;
28 if(sysMOTD.contains("/") && LUtils::isValidBinary(sysMOTD)){
29 //is binary - run it to generate text
30 tip = LUtils::getCmdOutput(sysMOTD).join("\n");
31
32 }else if(QFile::exists(sysMOTD)){
33 //text file - read it to generate text
34 tip = LUtils::readFile(sysMOTD).join("\n");
35
36 }else{
37 int index = qrand()%46; //Make sure this number matches the length of the case below (max value +1)
38 switch(index){
39 case 0:
40 tip = tr("This desktop is powered by coffee, coffee, and more coffee."); break;
41 case 1:
42 tip = tr("Keep up with desktop news!")+"\n\nwww.lumina-desktop.org"; break;
43 case 2:
44 tip = tr("There is a full handbook of information about the desktop available online.")+"\n\nwww.lumina-desktop.org/handbook"; break;
45 case 3:
46 tip = tr("Want to change the interface? Everything is customizable in the desktop configuration!"); break;
47 case 4:
48 tip = tr("Lumina can easily reproduce the interface from most other desktop environments."); break;
49 case 5:
50 tip = tr("This desktop is generously sponsored by iXsystems")+"\n\nwww.ixsystems.com"; break;
51 case 6:
52 tip = "\""+tr("I have never been hurt by what I have not said")+"\"\n\n- Calvin Coolidge -"; break;
53 case 7:
54 tip = "\""+tr("Gotta have more cowbell!")+"\"\n\n- Christopher Walken (SNL) -"; break;
55 case 8:
56 tip = "\""+tr("Everything has its beauty but not everyone sees it.")+"\"\n\n- Confucius -"; break;
57 case 9:
58 tip = "\""+tr("Before God we are all equally wise - and equally foolish.")+"\"\n\n- Albert Einstein -"; break;
59 case 10:
60 tip = "\""+tr("We cannot do everything at once, but we can do something at once.")+"\"\n\n- Calvin Coolidge -"; break;
61 case 11:
62 tip = "\""+tr("One with the law is a majority.")+"\"\n\n- Calvin Coolidge -"; break;
63 case 12:
64 tip = "\""+tr("Don't expect to build up the weak by pulling down the strong.")+"\"\n\n- Calvin Coolidge -"; break;
65 case 13:
66 tip = "\""+tr("You can't know too much, but you can say too much.")+"\"\n\n- Calvin Coolidge -"; break;
67 case 14:
68 tip = "\""+tr("Duty is not collective; it is personal.")+"\"\n\n- Calvin Coolidge -"; break;
69 case 15:
70 tip = "\""+tr("Any society that would give up a little liberty to gain a little security will deserve neither and lose both.")+"\"\n\n- Benjamin Franklin -"; break;
71 case 16:
72 tip = "\""+tr("Never trust a computer you can’t throw out a window.")+"\"\n\n- Steve Wozniak -"; break;
73 case 17:
74 tip = "\""+tr("Study the past if you would define the future.")+"\"\n\n- Confucius -"; break;
75 case 18:
76 tip = "\""+tr("The way to get started is to quit talking and begin doing.")+"\"\n\n- Walt Disney -"; break;
77 case 19:
78 tip = "\""+tr("Ask and it will be given to you; search, and you will find; knock and the door will be opened for you.")+"\"\n\n- Jesus Christ -"; break;
79 case 20:
80 tip = "\""+tr("Start where you are. Use what you have. Do what you can.")+"\"\n\n- Arthur Ashe -"; break;
81 case 21:
82 tip = "\""+tr("A person who never made a mistake never tried anything new.")+"\"\n\n- Albert Einstein -"; break;
83 case 22:
84 tip = "\""+tr("It does not matter how slowly you go as long as you do not stop.")+"\"\n\n- Confucius -"; break;
85 case 23:
86 tip = "\""+tr("Do what you can, where you are, with what you have.")+"\"\n\n- Theodore Roosevelt -"; break;
87 case 24:
88 tip = "\""+tr("Remember no one can make you feel inferior without your consent.")+"\"\n\n- Eleanor Roosevelt -"; break;
89 case 25:
90 tip = "\""+tr("It’s not the years in your life that count. It’s the life in your years.")+"\"\n\n- Abraham Lincoln -"; break;
91 case 26:
92 tip = "\""+tr("Either write something worth reading or do something worth writing.")+"\"\n\n- Benjamin Franklin -"; break;
93 case 27:
94 tip = "\""+tr("The only way to do great work is to love what you do.")+"\"\n\n- Steve Jobs -"; break;
95 case 28:
96 tip = "\""+tr("Political correctness is tyranny with manners.")+"\"\n\n- Charlton Heston -"; break;
97 case 29:
98 tip = "\""+tr("Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.")+"\"\n\n- Albert Einstein -"; break;
99 case 30:
100 tip = "\""+tr("I find that the harder I work, the more luck I seem to have.")+"\"\n\n- Thomas Jefferson -"; break;
101 case 31:
102 tip = "\""+tr("Do, or do not. There is no 'try'.")+"\"\n\n- Yoda -"; break;
103 case 32:
104 tip = "\""+tr("A mathematician is a device for turning coffee into theorems.")+"\"\n\n- Paul Erdos -"; break;
105 case 33:
106 tip = "\""+tr("Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws.")+"\"\n\n- Plato -"; break;
107 case 34:
108 tip = "\""+tr("Black holes are where God divided by zero.")+"\"\n\n- Steven Wright -"; break;
109 case 35:
110 tip = "\""+tr("It's kind of fun to do the impossible.")+"\"\n\n- Walt Disney -"; break;
111 case 36:
112 tip = "\""+tr("Knowledge speaks, but wisdom listens.")+"\"\n\n- Jimi Hendrix -"; break;
113 case 37:
114 tip = "\""+tr("A witty saying proves nothing.")+"\"\n\n- Voltaire -"; break;
115 case 38:
116 tip = "\""+tr("Success usually comes to those who are too busy to be looking for it.")+"\"\n\n- Henry David Thoreau -"; break;
117 case 39:
118 tip = "\""+tr("Well-timed silence hath more eloquence than speech.")+"\"\n\n- Martin Fraquhar Tupper -"; break;
119 case 40:
120 tip = "\""+tr("I have never let my schooling interfere with my education.")+"\"\n\n- Mark Twain -"; break;
121 case 41:
122 tip = "\""+tr("The best way to predict the future is to invent it.")+"\"\n\n- Alan Kay -"; break;
123 case 42:
124 tip = "\""+tr("Well done is better than well said.")+"\"\n\n- Benjamin Franklin -"; break;
125 case 43:
126 tip = "\""+tr("Sometimes it is not enough that we do our best; we must do what is required.")+"\"\n\n- Sir Winston Churchill -"; break;
127 case 44:
128 tip = "\""+tr("The truth is more important than the facts.")+"\"\n\n- Frank Lloyd Wright -"; break;
129 case 45:
130 tip = "\""+tr("Better to remain silent and be thought a fool than to speak out and remove all doubt.")+"\"\n\n- Abraham Lincoln -"; break;
131 } //end of switch for tips
132
133 } //end of fallback tip generation
134 ui->label_welcome->setText( tip);
135 }
136
showScreen(QString loading)137 void BootSplash::showScreen(QString loading){ //update icon, text, and progress
138 QString txt, icon;
139 int per = 0;
140 if(loading=="init"){
141 txt = tr("Initializing Session …"); per = 10;
142 icon = "preferences-system-login";
143 }else if(loading=="settings"){
144 txt = tr("Loading System Settings …"); per = 20;
145 icon = "user-home";
146 }else if(loading=="user"){
147 txt = tr("Loading User Preferences …"); per = 30;
148 icon = "preferences-desktop-user";
149 }else if(loading=="systray"){
150 txt = tr("Preparing System Tray …"); per = 40;
151 icon = "preferences-plugin";
152 }else if(loading=="wm"){
153 txt = tr("Starting Window Manager …"); per = 50;
154 icon = "preferences-system-windows-actions";
155 }else if(loading=="apps"){
156 txt = tr("Detecting Applications …"); per = 60;
157 icon = "preferences-desktop-icons";
158 }else if(loading=="menus"){
159 txt = tr("Preparing Menus …"); per = 70;
160 icon = "preferences-system-windows";
161 }else if(loading=="desktop"){
162 txt = tr("Preparing Workspace …"); per = 80;
163 icon = "preferences-desktop-wallpaper";
164 }else if(loading=="final"){
165 txt = tr("Finalizing …"); per = 90;
166 icon = "start-here-lumina";
167 }else if(loading.startsWith("app::")){
168 txt = QString(tr("Starting App: %1")).arg(loading.section("::",1,50)); per = -1;
169 }
170 if(per>0){ ui->progressBar->setValue(per); }
171 else{ ui->progressBar->setRange(0,0); } //loading indicator
172 ui->label_text->setText(txt);
173 if(!icon.isEmpty()){ui->label_icon->setPixmap( LXDG::findIcon(icon, "Lumina-DE").pixmap(64,64) ); }
174 this->raise();
175 this->show();
176 this->update();
177 QApplication::processEvents();
178 }
179
showText(QString txt)180 void BootSplash::showText(QString txt){ //will only update the text, not the icon/progress
181 ui->label_text->setText(txt);
182 this->show();
183 this->update();
184 QApplication::processEvents();
185 }
186