Commit eff5fa3f authored by Boudewijn Rempt's avatar Boudewijn 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 @@
*/
#include "kis_splash_screen.h"
KisSplashScreen::KisSplashScreen(QWidget *parent) :
QWidget(parent)
#include <QApplication>
#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);
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 @@
#include <QWidget>
#include "ui_wdgsplash.h"
class QPixmap;
class KisSplashScreen : public QWidget, public Ui::WdgSplash
{
Q_OBJECT
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
......@@ -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
// location of our datadir before we've started our components,
// so use an xpm.
QWidget *splash = new KisSplashScreen();
QWidget *splash = new KisSplashScreen(aboutData->version(), QPixmap(splash_screen_xpm));
app.setSplashScreen(splash);
if (!app.start()) {
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>440</width>
<height>525</height>
<height>571</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -16,43 +16,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</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">
<string>Form</string>
</property>
......@@ -69,7 +32,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -77,7 +40,7 @@
<property name="minimumSize">
<size>
<width>440</width>
<height>0</height>
<height>286</height>
</size>
</property>
<property name="text">
......@@ -94,7 +57,13 @@
<item>
<widget class="QLabel" name="lblVersion">
<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>
</widget>
</item>
......@@ -107,7 +76,7 @@
<number>10</number>
</property>
<property name="bottomMargin">
<number>20</number>
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lblLinks">
......@@ -115,7 +84,7 @@
<string notr="true"/>
</property>
<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 name="textFormat">
<enum>Qt::RichText</enum>
......@@ -131,7 +100,7 @@
<item>
<widget class="QLabel" name="lblRecent">
<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 name="textFormat">
<enum>Qt::RichText</enum>
......@@ -146,6 +115,42 @@
</item>
</layout>
</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>
</widget>
<resources/>
......
......@@ -46,6 +46,9 @@
#include <kiconloader.h>
#include <kdebug.h>
#include <kmimetype.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kconfiggroup.h>
#if KDE_IS_VERSION(4,6,0)
#include <krecentdirs.h>
......@@ -66,6 +69,9 @@
#include <tchar.h>
#endif
#include <QDesktopWidget>
KoApplication* KoApplication::KoApp = 0;
namespace {
......@@ -93,9 +99,27 @@ public:
~ResetStarting() {
if (m_splash) {
m_splash->hide();
delete m_splash;
m_splash = 0;
KConfigGroup cfg(KGlobal::config(), "SplashScreen");
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()
if (d->splashScreen) {
d->splashScreen->show();
//d->splashScreen->showMessage(".");
d->splashScreen->repaint();
}
ResetStarting resetStarting(d->splashScreen); // remove the splash when done
......@@ -581,6 +605,13 @@ QList<KoPart*> KoApplication::partList() const
return d->partList;
}
void KoApplication::removeSplash()
{
d->splashScreen->hide();
delete d->splashScreen;
d->splashScreen = 0;
}
QStringList KoApplication::mimeFilter(KoFilterManager::Direction direction) const
{
KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(d->nativeMimeType);
......
......@@ -87,6 +87,11 @@ public:
QList<KoPart*> partList() const;
/**
* Remove the splash dialog
*/
void removeSplash();
/**
* 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