*
*/
-#include <QtWidgets>
-
#include "contextmenu.h"
#include "emulator_common.h"
#include "mainwindow.h"
qDebug("SDB shell");
if (is_sdbd_initialized == 0) {
- QString msg = "SDB is not ready.\nPlease wait until the emulator is completely boot up.";
- qDebug() << msg;
-
- QMessageBox *msgBox = new QMessageBox(QMessageBox::Information,
- "Emulator", msg, QMessageBox::Ok, (QWidget*)parent);
- msgBox->setAttribute(Qt::WA_DeleteOnClose);
- msgBox->setModal(false);
- msgBox->show();
-
+ showMsgBox(QMessageBox::Warning,
+ "SDB is not ready.\nPlease wait until the emulator is completely boot up.");
return;
}
QFileInfo sdbFileInfo(sdbPath);
if (sdbFileInfo.exists() == false) {
- QString msg = "SDB file does not exist in the following path.\n"
- + sdbFileInfo.absoluteFilePath();
- qWarning() << msg;
-
- QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
- "Emulator", msg, QMessageBox::Ok, (QWidget*)parent);
- msgBox->setAttribute(Qt::WA_DeleteOnClose);
- msgBox->setModal(false);
- msgBox->show();
-
+ showMsgBox(QMessageBox::Warning,
+ "SDB file does not exist in the following path.\n"
+ + sdbFileInfo.absoluteFilePath());
return;
}
try {
QProcess::startDetached(command, arguments);
} catch (QString &error) {
- QString msg = "Failed to open Shell : " + error;
- qDebug() << msg;
-
- QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
- "Emulator", msg, QMessageBox::Ok ,(QWidget*)parent);
- msgBox->setAttribute(Qt::WA_DeleteOnClose);
- msgBox->setModal(false);
- msgBox->show();
-
+ showMsgBox(QMessageBox::Warning,
+ "Failed to open Shell : " + error);
return;
}
}
}
#endif
-void ContextMenu::showPopup(QString msg)
-{
- qDebug() << msg;
-
- QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
- "Emulator", msg, QMessageBox::Ok, (QWidget*)parent);
- msgBox->setAttribute(Qt::WA_DeleteOnClose);
- msgBox->setModal(false);
- msgBox->show();
-}
-
void ContextMenu::slotControlPanel()
{
qDebug("Control Panel");
QFileInfo ecpFileInfo(ecpPath);
if (!ecpFileInfo.exists()) {
- showPopup("Control Panel file does not exist in the following path.\n"
+ showMsgBox(QMessageBox::Warning,
+ "Control Panel file does not exist in the following path.\n"
+ ecpFileInfo.absoluteFilePath());
return;
}
if (menu_get_java_path(&path)) {
command = QString::fromLocal8Bit(path);
} else {
- showPopup("Failed to get java path.");
+ showMsgBox(QMessageBox::Warning, "Failed to get java path.");
free(path);
return;
}
try {
QProcess::startDetached(command, arguments);
} catch (QString &error) {
- showPopup("Failed to open Control Panel : " + error);
+ showMsgBox(QMessageBox::Warning, "Failed to open Control Panel : " + error);
return;
}
}
{
qDebug("force close");
- QMessageBox *msg = new QMessageBox((QWidget*)parent);
- msg->setAttribute(Qt::WA_DeleteOnClose);
- msg->setWindowTitle("Emulator");
- msg->setText("If you force stop an emulator, it may cause some problems.\n"
- "Are you sure you want to continue?");
- msg->setStandardButtons(QMessageBox::Yes|QMessageBox::No);
- msg->setDefaultButton(QMessageBox::Yes);
- msg->setIcon(QMessageBox::Question);
- msg->setModal(false);
- msg->show();
- connect(msg, SIGNAL(buttonClicked(QAbstractButton *)),
- this, SLOT(slotForceCloseSelected(QAbstractButton *)));
-}
-
-void ContextMenu::slotForceCloseSelected(QAbstractButton *btn)
-{
- if (btn->text().compare("&Yes") == 0) {
- qDebug() << "exit!";
- /* force close */
- shutdown_qemu_gracefully(1);
- } else {
- qDebug() << "cancel";
+ QMessageBox *msgBox = showMsgBox(QMessageBox::Question,
+ "If you force stop an emulator, it may cause some problems.\n"
+ "Are you sure you want to continue?", QMessageBox::Yes | QMessageBox::No);
+
+ connect(msgBox, SIGNAL(buttonClicked(QAbstractButton *)),
+ this, SLOT(slotForceCloseSelected(QAbstractButton *)));
+}
+
+void ContextMenu::slotForceCloseSelected(QAbstractButton *button)
+{
+ QMessageBox *msgBox = (QMessageBox *)button->parent()->parent();
+ if (msgBox == NULL) {
+ qWarning() << "invalid slot call";
+ return;
+ }
+
+ switch(msgBox->standardButton(button)) {
+ case QMessageBox::Yes:
+ qDebug() << "exit!";
+ shutdown_qemu_gracefully(3);
+
+ break;
+ case QMessageBox::No:
+ qDebug() << "cancel";
+
+ break;
+ default:
+ /* do nothing */
+ break;
}
}
void ContextMenu::slotClose()
{
qDebug("close");
+
do_hw_key_event(KEY_PRESSED, HARD_KEY_POWER);
longPressTimer->setInterval(CLOSE_POWER_KEY_INTERVAL);
return actionTopMost;
}
+QMessageBox *ContextMenu::showMsgBox(
+ int iconType, const QString &text, int buttons)
+{
+ qDebug() << text;
+
+ QMessageBox *msgBox = new QMessageBox((QMessageBox::Icon)iconType,
+ "Emulator", text, (QMessageBox::StandardButton)buttons, parent);
+ msgBox->setAttribute(Qt::WA_DeleteOnClose);
+ msgBox->show(); /* non-blocking */
+
+#ifdef CONFIG_LINUX
+ slotTopMost(parent->getUIState()->isOnTop());
+#endif
+
+ return msgBox;
+}
+
ContextMenu::~ContextMenu()
{
qDebug("destroy menu");