Add background images to intro wizard
This commit is contained in:
committed by
craig.p.drummond
parent
d68ca06522
commit
8195c421bf
@@ -148,6 +148,7 @@ SET( CANTATA_SRCS
|
||||
widgets/genrecombo.cpp
|
||||
widgets/toolbar.cpp
|
||||
widgets/menubutton.cpp
|
||||
widgets/wizardpage.cpp
|
||||
lyrics/lyricspage.cpp
|
||||
lyrics/lyricsettings.cpp
|
||||
lyrics/ultimatelyricsprovider.cpp
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
#include "settings.h"
|
||||
#include "utils.h"
|
||||
#include "icon.h"
|
||||
#include "icons.h"
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
static const int constIconSize=48;
|
||||
|
||||
@@ -65,6 +67,14 @@ InitialSettingsWizard::InitialSettingsWizard(QWidget *p)
|
||||
storeCoversInMpdDir->setChecked(Settings::self()->storeCoversInMpdDir());
|
||||
storeLyricsInMpdDir->setChecked(Settings::self()->storeLyricsInMpdDir());
|
||||
storeStreamsInMpdDir->setChecked(Settings::self()->storeStreamsInMpdDir());
|
||||
#ifdef ENABLE_KDE_SUPPORT
|
||||
introPage->setBackground(Icon("cantata"));
|
||||
#else
|
||||
introPage->setBackground(Icons::appIcon);
|
||||
#endif
|
||||
connectionPage->setBackground(Icons::libraryIcon);
|
||||
filesPage->setBackground(Icons::filesIcon);
|
||||
finishedPage->setBackground(Icon("dialog-ok"));
|
||||
}
|
||||
|
||||
InitialSettingsWizard::~InitialSettingsWizard()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Cantata First Run</string>
|
||||
</property>
|
||||
<widget class="QWizardPage" name="wizardPage1">
|
||||
<widget class="WizardPage" name="introPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
@@ -69,7 +69,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="wizardPage2">
|
||||
<widget class="WizardPage" name="connectionPage">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
@@ -297,7 +297,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="filesPage">
|
||||
<widget class="WizardPage" name="filesPage">
|
||||
<layout class="QGridLayout" name="gridLayoutf">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6f">
|
||||
@@ -446,7 +446,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="wizardPage">
|
||||
<widget class="WizardPage" name="finishedPage">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
@@ -559,6 +559,11 @@
|
||||
<extends>QcheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>WizardPage</class>
|
||||
<extends>QWizardPage</extends>
|
||||
<header>wizardpage.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PathRequester</class>
|
||||
<extends>QLineEdit</extends>
|
||||
|
||||
54
widgets/wizardpage.cpp
Normal file
54
widgets/wizardpage.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Cantata
|
||||
*
|
||||
* Copyright (c) 2011-2013 Craig Drummond <craig.p.drummond@gmail.com>
|
||||
*
|
||||
* ----
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "wizardpage.h"
|
||||
#include "icon.h"
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
|
||||
void WizardPage::setBackground(const Icon &i)
|
||||
{
|
||||
int size=fontMetrics().height()*10;
|
||||
size=((int)(size/4))*4;
|
||||
pix=i.pixmap(size, QIcon::Disabled);
|
||||
if (pix.width()<size && pix.height()<size) {
|
||||
pix=pix.scaled(QSize(size, size), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPage::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
spacing*=2;
|
||||
|
||||
QWizardPage::paintEvent(e);
|
||||
QRect r(rect());
|
||||
QPainter painter(this);
|
||||
|
||||
painter.setOpacity(0.2);
|
||||
painter.drawPixmap(Qt::RightToLeft == layoutDirection() ? r.left() + spacing : r.right() - (pix.width() + spacing),
|
||||
r.bottom() - (pix.height() + spacing), pix);
|
||||
}
|
||||
45
widgets/wizardpage.h
Normal file
45
widgets/wizardpage.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Cantata
|
||||
*
|
||||
* Copyright (c) 2011-2013 Craig Drummond <craig.p.drummond@gmail.com>
|
||||
*
|
||||
* ----
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef WIZARDPAGE_H
|
||||
#define WIZARDPAGE_H
|
||||
|
||||
#include <QWizardPage>
|
||||
#include <QPixmap>
|
||||
|
||||
class Icon;
|
||||
|
||||
class WizardPage : public QWizardPage
|
||||
{
|
||||
public:
|
||||
WizardPage(QWidget *parent = 0) : QWizardPage(parent) { }
|
||||
virtual ~WizardPage() { }
|
||||
|
||||
void setBackground(const Icon &i);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
private:
|
||||
QPixmap pix;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user