1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
/***************************************************************************
* *
* This file is part of the Fotowall project, *
* http://www.enricoros.com/opensource/fotowall *
* *
* Copyright (C) 2009 by Enrico Ros <enrico.ros@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. *
* *
***************************************************************************/
#include "HelpAppliance.h"
#include "Shared/AbstractScene.h"
#include "Shared/RenderOpts.h"
#include "App.h"
#include "HelpItem.h"
#include "OnlineServices.h"
#include "Workflow.h"
#include <QDesktopServices>
#include <QMessageBox>
#include <QPainter>
#include <QLinearGradient>
/** Help Scene **/
class HelpScene : public AbstractScene {
public:
HelpItem * helpItem;
HelpScene()
: helpItem(0)
{
// create and place the help item
helpItem = new HelpItem;
helpItem->setZValue(10001);
addItem(helpItem);
}
bool sceneSelectable() const
{
return false;
}
void resizeEvent()
{
helpItem->setPos(QPointF(sceneCenter().toPoint()));
}
void drawBackground(QPainter *painter, const QRectF &rect)
{
// draw a gray shade as background
painter->setCompositionMode(QPainter::CompositionMode_Source);
QLinearGradient lg(0, 0, 0, sceneHeight());
lg.setColorAt(0.0, QColor(192, 192, 192, RenderOpts::ARGBWindow ? 200 : 255));
lg.setColorAt(1.0, QColor(128, 128, 128, RenderOpts::ARGBWindow ? 200 : 255));
painter->fillRect(rect, lg);
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
}
};
/** Help Appliance **/
HelpAppliance::HelpAppliance(QObject *parent)
: QObject(parent)
, m_helpScene(new HelpScene)
, m_dummyWidget(new QWidget)
{
// create the gui components over a dummy widget
ui.setupUi(m_dummyWidget);
ui.tutorialButton->setVisible(App::onlineServices->checkForTutorial());
connect(App::onlineServices, SIGNAL(tutorialFound(bool)), ui.tutorialButton, SLOT(setVisible(bool)));
connect(ui.webButton, SIGNAL(clicked()), App::onlineServices, SLOT(openWebpage()));
connect(ui.blogButton, SIGNAL(clicked()), App::onlineServices, SLOT(openBlog()));
connect(ui.tutorialButton, SIGNAL(clicked()), App::onlineServices, SLOT(openTutorial()));
connect(ui.updateButton, SIGNAL(clicked()), App::onlineServices, SLOT(checkForUpdates()));
// listen to scene events
connect(m_helpScene->helpItem, SIGNAL(closeMe()), this, SLOT(slotClose()));
// customize appliance
sceneSet(m_helpScene);
topbarAddWidget(ui.helpBox);
setFocusToScene();
}
HelpAppliance::~HelpAppliance()
{
delete ui.helpBox;
delete m_helpScene;
delete m_dummyWidget;
}
void HelpAppliance::slotClose()
{
App::workflow->popCurrentAppliance();
}
|