This commit is contained in:
stojce 2013-09-13 20:10:27 +02:00
parent 921e88ea5d
commit 4b993ec931

View file

@ -15,35 +15,29 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#define SETTINGS_VERSION_KEY "info-version" #define SETTINGS_VERSION_KEY "info-version"
#define MAX_DIALOG_HEIGHT_RATIO 0.9
InfoView::InfoView(bool forced) InfoView::InfoView(bool forced) {
{
_forced = forced; _forced = forced;
settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true); settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
#ifdef Q_OS_MAC switchToResourcesParentIfRequired();
QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; QString absPath = QFileInfo("resources/html/interface-welcome-allsvg.html").absoluteFilePath();
#else QUrl url = QUrl::fromLocalFile(absPath);
QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources";
#endif
QUrl url = QUrl::fromLocalFile(resourcesPath + "/html/interface-welcome-allsvg.html");
load(url); load(url);
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loaded(bool))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loaded(bool)));
} }
void InfoView::showFirstTime() void InfoView::showFirstTime() {
{
new InfoView(false); new InfoView(false);
} }
void InfoView::forcedShow() void InfoView::forcedShow() {
{
new InfoView(true); new InfoView(true);
} }
bool InfoView::shouldShow() bool InfoView::shouldShow() {
{
if (_forced) { if (_forced) {
return true; return true;
} }
@ -66,9 +60,8 @@ bool InfoView::shouldShow()
return false; return false;
} }
void InfoView::loaded(bool ok) void InfoView::loaded(bool ok) {
{ if (!ok || !shouldShow()) {
if (!shouldShow()) {
return; return;
} }
@ -76,8 +69,8 @@ void InfoView::loaded(bool ok)
QWebFrame* mainFrame = page()->mainFrame(); QWebFrame* mainFrame = page()->mainFrame();
int height = mainFrame->contentsSize().height() > desktop->height() ? int height = mainFrame->contentsSize().height() > desktop->height() ?
desktop->height() * 0.9 : desktop->height() * MAX_DIALOG_HEIGHT_RATIO :
mainFrame->contentsSize().height(); mainFrame->contentsSize().height();
resize(mainFrame->contentsSize().width(), height); resize(mainFrame->contentsSize().width(), height);
move(desktop->screen()->rect().center() - rect().center()); move(desktop->screen()->rect().center() - rect().center());