Commit eff5fa3f authored by Halla Rempt's avatar Halla Rempt

Extended splash screen: morph into a dialog when the app is done starting

Conflicts:
	libs/main/KoApplication.cpp
parent f97c4e14
...@@ -17,8 +17,73 @@ ...@@ -17,8 +17,73 @@
*/ */
#include "kis_splash_screen.h" #include "kis_splash_screen.h"
KisSplashScreen::KisSplashScreen(QWidget *parent) : #include <QApplication>
QWidget(parent) #include <QDesktopWidget>
#include <QPixmap>
#include <QCheckBox>
#include <QDebug>
#include <klocale.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kconfiggroup.h>
KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap, QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, Qt::SplashScreen | Qt::FramelessWindowHint | f)
, version(version)
, pixmap(pixmap)
{ {
setupUi(this); setupUi(this);
lblSplash->setPixmap(pixmap);
bnClose->hide();
connect(bnClose, SIGNAL(clicked()), this, SLOT(close()));
chkShowAtStartup->hide();
connect(chkShowAtStartup, SIGNAL(toggled(bool)), this, SLOT(toggleShowAtStartup(bool)));
KConfigGroup cfg(KGlobal::config(), "SplashScreen");
bool hideSplash = cfg.readEntry("HideSplashAfterStartup", false);
chkShowAtStartup->setChecked(hideSplash);
lblLinks->setTextFormat(Qt::RichText);
lblLinks->setText("<html>"
"<head/>"
"<body>"
"<p align=\"center\"><b>Links</b></p>"
"<p><a href=\"http://krita.org/support-krita#general\"><span style=\" text-decoration: underline; \">Donations</span></a></p>"
"<p><a href=\"http://www.zazzle.com/kritashop\"><span style=\" text-decoration: underline; \">Shop</span></a></p>"
"<p><a href=\"http://krita.org/resources\"><span style=\" text-decoration: underline; \">Getting Started</span></a></p>"
"<p><a href=\"http://krita.org\"><span style=\" text-decoration: underline; \">Website</span></a></p>"
"<p><a href=\"http://kritastudio.com\"><span style=\" text-decoration: underline; \">Commercial Support</span></a></p>"
"<p><a href=\"http://forum.kde.org/viewforum.php?f=136\"><span style=\" text-decoration: underline; \">User Community</span></a></p>"
"<p><a href=\"https://projects.kde.org/projects/calligra\"><span style=\" text-decoration: underline; \">Source Code</span></a></p>"
"<p><a href=\"http://store.steampowered.com/app/280680/\"><span style=\" text-decoration: underline; \">Get Krita on Steam</span></a></p>"
"</body>"
"</html>");
lblVersion->setText(i18n("Version: %1", version));
}
void KisSplashScreen::repaint()
{
QWidget::repaint();
QApplication::flush();
}
void KisSplashScreen::show()
{
QRect r(QPoint(), sizeHint());
resize(r.size());
move(QApplication::desktop()->screenGeometry().center() - r.center());
if (isVisible()) {
repaint();
}
}
void KisSplashScreen::toggleShowAtStartup(bool toggle)
{
KConfigGroup cfg(KGlobal::config(), "SplashScreen");
cfg.writeEntry("HideSplashAfterStartup", toggle);
} }
...@@ -21,16 +21,25 @@ ...@@ -21,16 +21,25 @@
#include <QWidget> #include <QWidget>
#include "ui_wdgsplash.h" #include "ui_wdgsplash.h"
class QPixmap;
class KisSplashScreen : public QWidget, public Ui::WdgSplash class KisSplashScreen : public QWidget, public Ui::WdgSplash
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit KisSplashScreen(QWidget *parent = 0); explicit KisSplashScreen(const QString &version, const QPixmap &pixmap, QWidget *parent = 0, Qt::WindowFlags f = 0);
void repaint();
void show();
signals: private slots:
public slots: void toggleShowAtStartup(bool toggle);
private:
QString version;
QPixmap pixmap;
}; };
#endif // KIS_SPLASH_SCREEN_H #endif // KIS_SPLASH_SCREEN_H
...@@ -97,7 +97,7 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv) ...@@ -97,7 +97,7 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
// then create the pixmap from an xpm: we cannot get the // then create the pixmap from an xpm: we cannot get the
// location of our datadir before we've started our components, // location of our datadir before we've started our components,
// so use an xpm. // so use an xpm.
QWidget *splash = new KisSplashScreen(); QWidget *splash = new KisSplashScreen(aboutData->version(), QPixmap(splash_screen_xpm));
app.setSplashScreen(splash); app.setSplashScreen(splash);
if (!app.start()) { if (!app.start()) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>440</width> <width>440</width>
<height>525</height> <height>571</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -16,43 +16,6 @@ ...@@ -16,43 +16,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>40</red>
<green>40</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>40</red>
<green>40</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>250</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
...@@ -69,7 +32,7 @@ ...@@ -69,7 +32,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
...@@ -77,7 +40,7 @@ ...@@ -77,7 +40,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>440</width> <width>440</width>
<height>0</height> <height>286</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
...@@ -94,7 +57,13 @@ ...@@ -94,7 +57,13 @@
<item> <item>
<widget class="QLabel" name="lblVersion"> <widget class="QLabel" name="lblVersion">
<property name="text"> <property name="text">
<string>Version 2.8.1 (d73aa83)</string> <string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>4</number>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -107,7 +76,7 @@ ...@@ -107,7 +76,7 @@
<number>10</number> <number>10</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>20</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="lblLinks"> <widget class="QLabel" name="lblLinks">
...@@ -115,7 +84,7 @@ ...@@ -115,7 +84,7 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Links&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://krita.org/support-krita#general&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Donations&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.zazzle.com/kritashop&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Shop&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://krita.org/resources&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Getting Started&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://krita.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Website&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kritastudio.com&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Commercial Support&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://forum.kde.org/viewforum.php?f=136&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;User Community&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://projects.kde.org/projects/calligra&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Source Code&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Links&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://krita.org/support-krita#general&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Donations&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.zazzle.com/kritashop&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Shop&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://krita.org/resources&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Getting Started&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://krita.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Website&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kritastudio.com&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Commercial Support&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://forum.kde.org/viewforum.php?f=136&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;User Community&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://projects.kde.org/projects/calligra&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Source Code&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://store.steampowered.com/app/280680/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#006e28;&quot;&gt;Get Krita on Steam&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::RichText</enum> <enum>Qt::RichText</enum>
...@@ -131,7 +100,7 @@ ...@@ -131,7 +100,7 @@
<item> <item>
<widget class="QLabel" name="lblRecent"> <widget class="QLabel" name="lblRecent">
<property name="text"> <property name="text">
<string>Recent files</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Recent files&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::RichText</enum> <enum>Qt::RichText</enum>
...@@ -146,6 +115,42 @@ ...@@ -146,6 +115,42 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QCheckBox" name="chkShowAtStartup">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Hide after startup.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnClose">
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
#include <kiconloader.h> #include <kiconloader.h>
#include <kdebug.h> #include <kdebug.h>
#include <kmimetype.h> #include <kmimetype.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kconfiggroup.h>
#if KDE_IS_VERSION(4,6,0) #if KDE_IS_VERSION(4,6,0)
#include <krecentdirs.h> #include <krecentdirs.h>
...@@ -66,6 +69,9 @@ ...@@ -66,6 +69,9 @@
#include <tchar.h> #include <tchar.h>
#endif #endif
#include <QDesktopWidget>
KoApplication* KoApplication::KoApp = 0; KoApplication* KoApplication::KoApp = 0;
namespace { namespace {
...@@ -93,9 +99,27 @@ public: ...@@ -93,9 +99,27 @@ public:
~ResetStarting() { ~ResetStarting() {
if (m_splash) { if (m_splash) {
m_splash->hide();
delete m_splash; KConfigGroup cfg(KGlobal::config(), "SplashScreen");
m_splash = 0; bool hideSplash = cfg.readEntry("HideSplashAfterStartup", false);
if (hideSplash) {
m_splash->hide();
}
else {
m_splash->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
m_splash->setWindowModality(Qt::ApplicationModal);
m_splash->setParent(qApp->activeWindow());
QRect r(QPoint(), m_splash->size());
m_splash->move(QApplication::desktop()->screenGeometry().center() - r.center());
m_splash->show();
foreach(QObject *o, m_splash->children()) {
QWidget *w = qobject_cast<QWidget*>(o);
if (w && w->isHidden()) {
w->setVisible(true);
}
}
}
} }
} }
...@@ -223,7 +247,7 @@ bool KoApplication::start() ...@@ -223,7 +247,7 @@ bool KoApplication::start()
if (d->splashScreen) { if (d->splashScreen) {
d->splashScreen->show(); d->splashScreen->show();
//d->splashScreen->showMessage("."); d->splashScreen->repaint();
} }
ResetStarting resetStarting(d->splashScreen); // remove the splash when done ResetStarting resetStarting(d->splashScreen); // remove the splash when done
...@@ -581,6 +605,13 @@ QList<KoPart*> KoApplication::partList() const ...@@ -581,6 +605,13 @@ QList<KoPart*> KoApplication::partList() const
return d->partList; return d->partList;
} }
void KoApplication::removeSplash()
{
d->splashScreen->hide();
delete d->splashScreen;
d->splashScreen = 0;
}
QStringList KoApplication::mimeFilter(KoFilterManager::Direction direction) const QStringList KoApplication::mimeFilter(KoFilterManager::Direction direction) const
{ {
KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(d->nativeMimeType); KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(d->nativeMimeType);
......
...@@ -87,6 +87,11 @@ public: ...@@ -87,6 +87,11 @@ public:
QList<KoPart*> partList() const; QList<KoPart*> partList() const;
/**
* Remove the splash dialog
*/
void removeSplash();
/** /**
* return a list of mimetypes this application supports. * return a list of mimetypes this application supports.
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment