void FullEraseConfirmationWindow::updateCountDownText()
{
	if (m_secondsLeft == 1) {
		m_countDown = qFromUtf8Stl(LOCALIZED(kFullEraseCountDownSingular));
	} else {
		m_countDown = qFromUtf8Stl(LOCALIZED(kFullEraseCountDownPlural)).arg(m_secondsLeft);
	}

	m_font.setPixelSize(kCountDownFontHeight);
	QFontMetrics metrics(m_font);
	m_countDownBounds = metrics.boundingRect(m_boundingRect.toRect(), Qt::AlignCenter|Qt::TextWordWrap, m_countDown);
	m_countDownBounds.moveTop(m_boundingRect.y() + (m_boundingRect.height() * countRatio));
}
QPixmap ApplicationDescription::miniIcon() const
{
    QPixmap pix(m_miniIconName.c_str());
    if (!pix.isNull()) {
        return pix;
    }

    // if there is no mini-icon, we will scale and desaturate the regular app icon
    // to get one

#ifndef FIX_FOR_QT
    m_miniIconName = std::string("*default");	//invalid filename so it'll never be confused with a "real" icon file
#endif
    int miniIconSize = Settings::LunaSettings()->positiveSpaceBottomPadding;

    const LaunchPoint* lp = m_launchPoints.front();

    QImage img = QImage(qFromUtf8Stl(lp->iconPath())).scaled(miniIconSize, miniIconSize,
                 Qt::IgnoreAspectRatio,
                 Qt::SmoothTransformation);
    desaturate(img);
    pix = QPixmap::fromImage(img);

    return pix;
}
Пример #3
0
LaunchPoint::LaunchPoint(ApplicationDescription* appDesc,
						 const std::string& id,
						 const std::string& launchPointId,
						 const std::string& title,
						 const std::string& menuName,
						 const std::string& iconPath,
						 const std::string& params,
						 bool removable) :
	m_appDesc(appDesc) ,
	m_id(id) ,
	m_launchPointId(launchPointId) ,
	m_appmenuName(menuName) ,
	m_iconPath(iconPath) ,
	m_params(params) ,
	m_removable(removable)
{
	this->m_bDefault = false;
	if (m_iconPath.compare(0, 7, localFileURI) == 0) {
		m_iconPath.erase(0, 7);
	}
	QImage icon;
    icon.load(qFromUtf8Stl(m_iconPath));
	if (icon.isNull()) {
		// load a default image
		m_iconPath = Settings::LunaSettings()->lunaSystemResourcesPath + "/default-app-icon.png";
//		icon.load(qFromUtf8Stl(m_iconPath));
//		if (m_icon.isNull())
//			g_warning("%s: Failed to load application icon for app %s (original: %s, default: %s)",
//					__PRETTY_FUNCTION__, id.c_str(), iconPath.c_str(), m_iconPath.c_str());
	}

	m_title.set(title);
}
Пример #4
0
QPixmap LaunchPoint::icon() const
{
	//get size of icon from launcher settings!
	return QPixmap::fromImage(QImage(qFromUtf8Stl(m_iconPath)).scaled(DEFAULT_ICON_W,
																	DEFAULT_ICON_H,
																	Qt::IgnoreAspectRatio,
																	Qt::SmoothTransformation));
}
void FullEraseConfirmationWindow::setupLabels()
{
	QRect bounds = m_boundingRect.toRect();

	m_title = qFromUtf8Stl(LOCALIZED(kFullEraseConfirmationTitle));
	m_font.setPixelSize(kTitleFontHeight);
	QFontMetrics metrics(m_font);
	m_titleBounds = metrics.boundingRect(bounds, Qt::AlignCenter|Qt::TextWordWrap, m_title);
	m_titleBounds.moveTop(m_boundingRect.y() + (m_boundingRect.height() * titleRatio));
	
	m_description = qFromUtf8Stl(LOCALIZED(kFullEraseConfirmationDescription));
	m_font.setPixelSize(kDescriptionFontHeight);
	metrics = QFontMetrics(m_font);
	m_descBounds = metrics.boundingRect(bounds, Qt::AlignCenter|Qt::TextWordWrap, m_description);
	m_descBounds.moveTop(m_boundingRect.y() + (m_boundingRect.height() * descRatio));

	updateCountDownText();
}
Пример #6
0
ReticleItem::ReticleItem()
{
	setVisible(false);

	std::string filePath = Settings::LunaSettings()->lunaSystemResourcesPath + "/penindicator-ripple.png";
	m_pixmap = QPixmap::fromImage(QImage(qFromUtf8Stl(filePath)));

	m_width = m_pixmap.width();
	m_height = m_pixmap.height();
}
Пример #7
0
void ClockWindow::loadDigits()
{
	QString digitPath = qFromUtf8Stl(Settings::LunaSettings()->lunaSystemResourcesPath) + "/";
	const ImagePath imagePaths[] = {
		{'0', "screen-lock-clock-0.png"},		{'1', "screen-lock-clock-1.png"},
		{'2', "screen-lock-clock-2.png"},		{'3', "screen-lock-clock-3.png"},
		{'4', "screen-lock-clock-4.png"},		{'5', "screen-lock-clock-5.png"},
		{'6', "screen-lock-clock-6.png"},		{'7', "screen-lock-clock-7.png"},
		{'8', "screen-lock-clock-8.png"},		{'9', "screen-lock-clock-9.png"},
		{':', "screen-lock-clock-colon.png"},	{'.', "screen-lock-clock-decimal.png"},
		{0, 0}
	};

	const ImagePath* cur = imagePaths;
	while (cur->path != 0) {
		m_digits[cur->key] = QPixmap(digitPath + cur->path);
		cur++;
	}
}
Пример #8
0
bool LaunchPoint::updateIconPath(std::string newIconPath)
{
	// strip off local file url
	if (newIconPath.compare(0, 7, localFileURI) == 0) {
		newIconPath.erase(0, 7);
	}

	QImage newIcon(qFromUtf8Stl(newIconPath));
	if (newIcon.isNull()) {
		return false;
	}

	m_iconPath = newIconPath;

	// attempt to persist change
	toFile();

	return true;
}
FullEraseConfirmationWindow::FullEraseConfirmationWindow()
{
	m_boundingRect.setRect(-SystemUiController::instance()->currentUiWidth()/2, -SystemUiController::instance()->currentUiHeight()/2,
			               SystemUiController::instance()->currentUiWidth(), SystemUiController::instance()->currentUiHeight());

	m_secondsLeft = 6;

	m_timer.setInterval(1000);
	m_timer.setSingleShot(false);
	connect(&m_timer, SIGNAL(timeout()), SLOT(slotTimerTicked()));

	std::string iconPath = Settings::LunaSettings()->lunaSystemResourcesPath + "/warning-system.png";
	m_warningPix.load(qFromUtf8Stl(iconPath));
	if (m_warningPix.isNull()) {
		g_warning("FullEraseConfirmationWindow failed to load the icon");
	}
	m_warningOffsetY = m_boundingRect.y() + (m_boundingRect.height() * iconRatio);

	m_font = QFont(QString::fromStdString(Settings::LunaSettings()->fontBanner));

	setupLabels();

	m_timer.start();
}
Пример #10
0
void Localization::loadLocalizedStrings()
{
    m_localizationMap.clear();

    QVector<std::string> translations;

    std::string locale = LocalePreferences::instance()->locale();
    translations << Settings::LunaSettings()->lunaCustomizationLocalePath + "/" + locale + s_localeFile;
    translations << Settings::LunaSettings()->lunaSystemLocalePath + "/" + locale + s_localeFile;

    pbnjson::JSchema localeSchema = pbnjson::JSchemaFile("/etc/palm/schemas/localization.schema");

    pbnjson::JDomParser parser;
    Q_FOREACH(std::string translation, translations) {
        if (!QFile::exists(qFromUtf8Stl(translation))) {
            //qDebug() << "Failed to find localization" << translation.c_str();
            continue;
        }

        if (!parser.parseFile(translation, localeSchema, JFileOptMMap)) {
            //qWarning() << "Failed to load localization from" << translation.c_str();
            continue;
        }

        pbnjson::JValue localized = parser.getDom();
        pbnjson::JValue::ObjectIterator iter;
        for (iter = localized.begin(); iter != localized.end(); iter++) {
            pbnjson::JValue::KeyValue pair = (*iter);
            std::string key = pair.first.asString();
            std::string value = pair.second.asString();

            if (!m_localizationMap.contains(key))
                m_localizationMap.insert(key, value);
        }
    }
}
Пример #11
0
EmulatedCardWindow::EmulatedCardWindow(Window::Type type, HostWindowData* data, IpcClientHost* clientHost)
	: CardWindow(type, data, clientHost)
	, m_fullScreenMode(false)
	, m_appFreeOrientation(false)
	, m_positiveSpaceChanging(false)
        , m_smoothEdgeShaderStage(0)
	, m_keyboardUpManually(false)
{

	m_positiveSpaceAdjustment = 0;
	m_screenMidLine = 0;
	//NOTE: it seems the bounding rect may have a width and height of 0 at this time
	//making brect's use in the calculation below pointless

	QRectF brect = boundingRect();
	int emuWidth = Settings::LunaSettings()->emulatedCardWidth;
	int emuHeight = Settings::LunaSettings()->emulatedCardHeight - Settings::LunaSettings()->positiveSpaceTopPadding;

	//Center emu card in its bounding card
	int x = (brect.x() + (brect.width()/2)) - (emuWidth/2);
	int y = (brect.y() + (brect.height()/2)) - (emuHeight/2);

	QRectF emuRect(x,y,emuWidth,emuHeight);
	m_emulationBoundingRect = emuRect;

	//Start out with a screen mid-line that is half the buffer height.
	m_screenMidLine = (SystemUiController::instance()->currentUiHeight() - Settings::LunaSettings()->positiveSpaceTopPadding)/2;

	//Find the right angle to start bringing in this card at.
	//This will control the rotation angle for rendering the
	//card, how the widgets are laid out, etc.

	refreshAdjustmentAngle();

	//Note that these assets are hidden at initialization.  They will be shown the
	//first time the card is maximized.

	m_gestureStrip = new VirtualCoreNavi(emuWidth, 66);
	m_gestureStrip->setParentItem(this);
	m_gestureStrip->hide();

	//Set the accepted corenavi gestures.  We're currently supporting...only back.
	QList<Qt::Key> acceptedKeys;
	acceptedKeys.append(Qt::Key_CoreNavi_Back);
	m_gestureStrip->setAcceptedKeys(acceptedKeys);
	m_gestureStrip->setTapGesture(Qt::Key_CoreNavi_Back);

	m_statusBar = new StatusBar(StatusBar::TypeEmulatedCard, emuWidth, Settings::LunaSettings()->positiveSpaceTopPadding);
	m_statusBar->setParentItem(this);
	m_statusBar->init();
	m_statusBar->hide();

	m_keyboardButton = new PixmapButton(QPixmap (qFromUtf8Stl(KEYBOARD_UP_BUTTON)),
										QRect(0,0,52,44), QRect(0,44,52,44));
	m_keyboardButton->setParentItem(this);
	m_keyboardButton->setManualMode(true);
	m_keyboardButton->hide();
	m_keyboardButton->createLargerHitTargetRect(10,10);
		connect(m_keyboardButton,SIGNAL(clickComplete()),SLOT(slotKeyboardUpClicked()));
	layoutWidgets();

	//And now to load the rounded corners.  These are drawn in by paintBase()

	m_upperLeftCorner = s_upperLeftCorner.toStrongRef();
	if (m_upperLeftCorner.isNull()) {
		QPixmap corner = QPixmap::fromImage(QImage(qFromUtf8Stl(UPPER_LEFT_CORNER)));
		if (corner.isNull()) {
			corner = QPixmap(10, 10);
			corner.fill(Qt::transparent);
		}
		m_upperLeftCorner = QSharedPointer<QPixmap>(new QPixmap(corner));
		s_upperLeftCorner = m_upperLeftCorner.toWeakRef();
	}

	m_upperRightCorner = s_upperRightCorner.toStrongRef();
	if (m_upperRightCorner.isNull()) {
		QPixmap corner = QPixmap::fromImage(QImage(qFromUtf8Stl(UPPER_RIGHT_CORNER)));
		if (corner.isNull()) {
			corner = QPixmap(10, 10);
			corner.fill(Qt::transparent);
		}
		m_upperRightCorner = QSharedPointer<QPixmap>(new QPixmap(corner));
		s_upperRightCorner = m_upperRightCorner.toWeakRef();
	}

	m_lowerLeftCorner = s_lowerLeftCorner.toStrongRef();
	if (m_lowerLeftCorner.isNull()) {
		QPixmap corner = QPixmap::fromImage(QImage(qFromUtf8Stl(LOWER_LEFT_CORNER)));
		if (corner.isNull()) {
			corner = QPixmap(10, 10);
			corner.fill(Qt::transparent);
		}
		m_lowerLeftCorner = QSharedPointer<QPixmap>(new QPixmap(corner));
		s_lowerLeftCorner = m_lowerLeftCorner.toWeakRef();
	}

	m_lowerRightCorner = s_lowerRightCorner.toStrongRef();
	if (m_lowerRightCorner.isNull()) {
		QPixmap corner = QPixmap::fromImage(QImage(qFromUtf8Stl(LOWER_RIGHT_CORNER)));
		if (corner.isNull()) {
			corner = QPixmap(10, 10);
			corner.fill(Qt::transparent);
		}
		m_lowerRightCorner = QSharedPointer<QPixmap>(new QPixmap(corner));
		s_lowerRightCorner = m_lowerRightCorner.toWeakRef();
	}

	m_deviceFrame = s_deviceFrame.toStrongRef();
	if (m_deviceFrame.isNull()) {
		QPixmap corner = QPixmap::fromImage(QImage(qFromUtf8Stl(DEVICE_FRAME)));
		if (corner.isNull()) {
			corner = QPixmap(10, 10);
			corner.fill(Qt::transparent);
		}
		m_deviceFrame = QSharedPointer<QPixmap>(new QPixmap(corner));
		s_deviceFrame = m_deviceFrame.toWeakRef();
        }

        m_background = s_background.toStrongRef();
        if (m_background.isNull()) {
                QPixmap corner = QPixmap::fromImage(QImage(qFromUtf8Stl(BACKGROUND)));
                if (corner.isNull()) {
                        corner = QPixmap(10, 10);
                        corner.fill(Qt::transparent);
                }
                m_background = QSharedPointer<QPixmap>(new QPixmap(corner));
                s_background = m_background.toWeakRef();
        }

	grabGesture(Qt::TapGesture);
}