/**
 * @fn CActionManager()
 *
 * @brief Class constructor
 */
CActionManager::CActionManager()
{
    m_pTypes.Clear();
    // Register all BC types here
    ADD_ACTION(CFlux2DBCSineWaveGenVerticalLeft);
    ADD_ACTION(CFlux2DBCWaterRiseVerticalLeft);
    ADD_ACTION(CFlux2DBCWaterWallVerticalRight);
    ADD_ACTION(CFlux2DBCCopy);
    ADD_ACTION(CFlux2DBCReflectLine);
};
Example #2
0
bool _AutoPilot::init(void* pKiss)
{
    CHECK_F(!this->_ThreadBase::init(pKiss));
    Kiss* pK = (Kiss*)pKiss;
    pK->m_pInst = this;

    //create action instance
    Kiss* pCC = pK->o("action");
    CHECK_T(pCC->empty());
    Kiss** pItr = pCC->getChildItr();

    int i = 0;
    while (pItr[i])
    {
        Kiss* pAction = pItr[i];
        i++;

        bool bInst = false;
        F_INFO(pAction->v("bInst", &bInst));
        if (!bInst)continue;
        if (m_nAction >= N_ACTION)LOG(FATAL);

        ActionBase** pA = &m_pAction[m_nAction];
        m_nAction++;

        //Add action modules below

        ADD_ACTION(RC_visualFollow);
        ADD_ACTION(APMcopter_landing);
        ADD_ACTION(APMcopter_guided);
        ADD_ACTION(HM_base);
        ADD_ACTION(HM_follow);
        ADD_ACTION(APMrover_base);
        ADD_ACTION(APMrover_follow);

        //Add action modules above

        LOG_E("Unknown action class: "+pAction->m_class);
    }

    return true;
}
Example #3
0
void Patcher::initMenu()
{
    //Fichier
    QMenu* menuFichier  = menuBar()->addMenu("&Fichier");
    ///Quitter

    ADD_ACTION(menuFichier,actionRun,("Lancer" + Config::softname).c_str());
    connect(actionRun, SIGNAL(triggered()),this, SLOT(runSoft()));
    actionRun->setShortcut(QKeySequence("Ctrl+Enter"));

    ADD_ACTION(menuFichier,actionQuitter,"&Quitter");
    connect(actionQuitter, SIGNAL(triggered()),this, SLOT(quit()));
    actionQuitter->setShortcut(QKeySequence("Ctrl+Q"));
    //actionQuitter->setIcon(QIcon("quitter.png"));

    //Edition
    QMenu* menuEdition  = menuBar()->addMenu("&Edition");
    //actionGras->setCheckable(true);

    ADD_MENU(menuEdition,menuConfiguration,"&Configuration");

    ADD_ACTION(menuConfiguration,actionConfigurationUrl,"Definir l'url du site");
    connect(actionConfigurationUrl,SIGNAL(triggered()),this,SLOT(configSetUrl()));

    ADD_ACTION(menuConfiguration,actionConfigurationMaj,"Lancer une Maj");
    connect(actionConfigurationMaj,SIGNAL(triggered()),this,SLOT(configMaj()));
    actionConfigurationMaj->setShortcut(QKeySequence("F5"));

    ADD_ACTION(menuConfiguration,actionConfigurationReset,"Reset");
    connect(actionConfigurationReset,SIGNAL(triggered()),this,SLOT(configReset()));
    actionConfigurationReset->setShortcut(QKeySequence("Ctrl+L"));

    //Aide
    QMenu* menuAide     = menuBar()->addMenu("&Aide");
    ///Version
    ADD_ACTION(menuAide,actionVersion,"&Version")
    connect(actionVersion, SIGNAL(triggered()),this, SLOT(showVersion()));
}
Example #4
0
GUIAction::GUIAction(xml_node<>* node)
    : GUIObject(node)
{
    xml_node<>* child;
    xml_node<>* actions;
    xml_attribute<>* attr;

    if (!node) {
        return;
    }

    if (mf.empty()) {
#define ADD_ACTION(n) mf[#n] = &GUIAction::n
#define ADD_ACTION_EX(name, func) mf[name] = &GUIAction::func
        // These actions will be run in the caller's thread
        ADD_ACTION(reboot);
        ADD_ACTION(home);
        ADD_ACTION(key);
        ADD_ACTION(page);
        ADD_ACTION(reload);
        ADD_ACTION(set);
        ADD_ACTION(clear);
        ADD_ACTION(restoredefaultsettings);
        ADD_ACTION(compute);
        ADD_ACTION_EX("addsubtract", compute);
        ADD_ACTION(setguitimezone);
        ADD_ACTION(overlay);
        ADD_ACTION(sleep);
        ADD_ACTION(screenshot);
        ADD_ACTION(setbrightness);
        ADD_ACTION(setlanguage);
        ADD_ACTION(autoboot_cancel);

        // remember actions that run in the caller thread
        for (auto it = mf.cbegin(); it != mf.cend(); ++it) {
            setActionsRunningInCallerThread.insert(it->first);
        }

        // These actions will run in a separate thread
        ADD_ACTION(autoboot);
        ADD_ACTION(switch_rom);
    }

    // First, get the action
    actions = FindNode(node, "actions");
    if (actions) {
        child = FindNode(actions, "action");
    } else {
        child = FindNode(node, "action");
    }

    if (!child) {
        return;
    }

    while (child) {
        Action action;

        attr = child->first_attribute("function");
        if (!attr) {
            return;
        }

        action.mFunction = attr->value();
        action.mArg = child->value();
        mActions.push_back(action);

        child = child->next_sibling("action");
    }

    // Now, let's get either the key or region
    child = FindNode(node, "touch");
    if (child) {
        attr = child->first_attribute("key");
        if (attr) {
            std::vector<std::string> keys = mb::util::split(attr->value(), "+");
            for (size_t i = 0; i < keys.size(); ++i) {
                const int key = getKeyByName(keys[i]);
                mKeys[key] = false;
            }
        } else {
            attr = child->first_attribute("x");
            if (!attr) {
                return;
            }
            mActionX = atol(attr->value());
            attr = child->first_attribute("y");
            if (!attr) {
                return;
            }
            mActionY = atol(attr->value());
            attr = child->first_attribute("w");
            if (!attr) {
                return;
            }
            mActionW = atol(attr->value());
            attr = child->first_attribute("h");
            if (!attr) {
                return;
            }
            mActionH = atol(attr->value());
        }
    }
}
Example #5
0
QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initializeActions()
{
    QMap<QString,QMap<QString, WebApplication::Action> > actions;

    ADD_ACTION(public, webui);
    ADD_ACTION(public, index);
    ADD_ACTION(public, login);
    ADD_ACTION(public, logout);
    ADD_ACTION(public, theme);
    ADD_ACTION(public, images);
    ADD_ACTION(query, torrents);
    ADD_ACTION(query, preferences);
    ADD_ACTION(query, transferInfo);
    ADD_ACTION(query, propertiesGeneral);
    ADD_ACTION(query, propertiesTrackers);
    ADD_ACTION(query, propertiesWebSeeds);
    ADD_ACTION(query, propertiesFiles);
    ADD_ACTION(sync, maindata);
    ADD_ACTION(sync, torrent_peers);
    ADD_ACTION(command, shutdown);
    ADD_ACTION(command, download);
    ADD_ACTION(command, upload);
    ADD_ACTION(command, addTrackers);
    ADD_ACTION(command, resumeAll);
    ADD_ACTION(command, pauseAll);
    ADD_ACTION(command, resume);
    ADD_ACTION(command, pause);
    ADD_ACTION(command, setPreferences);
    ADD_ACTION(command, setFilePrio);
    ADD_ACTION(command, getGlobalUpLimit);
    ADD_ACTION(command, getGlobalDlLimit);
    ADD_ACTION(command, setGlobalUpLimit);
    ADD_ACTION(command, setGlobalDlLimit);
    ADD_ACTION(command, getTorrentsUpLimit);
    ADD_ACTION(command, getTorrentsDlLimit);
    ADD_ACTION(command, setTorrentsUpLimit);
    ADD_ACTION(command, setTorrentsDlLimit);
    ADD_ACTION(command, alternativeSpeedLimitsEnabled);
    ADD_ACTION(command, toggleAlternativeSpeedLimits);
    ADD_ACTION(command, toggleSequentialDownload);
    ADD_ACTION(command, toggleFirstLastPiecePrio);
    ADD_ACTION(command, setSuperSeeding);
    ADD_ACTION(command, setForceStart);
    ADD_ACTION(command, delete);
    ADD_ACTION(command, deletePerm);
    ADD_ACTION(command, increasePrio);
    ADD_ACTION(command, decreasePrio);
    ADD_ACTION(command, topPrio);
    ADD_ACTION(command, bottomPrio);
    ADD_ACTION(command, recheck);
    ADD_ACTION(command, setCategory);
    ADD_ACTION(command, getSavePath);
    ADD_ACTION(version, api);
    ADD_ACTION(version, api_min);
    ADD_ACTION(version, qbittorrent);

    return actions;
}
GUIAction::GUIAction(xml_node<>* node)
	: GUIObject(node)
{
	xml_node<>* child;
	xml_node<>* actions;
	xml_attribute<>* attr;

	if (!node)  return;

	if (mf.empty()) {
#define ADD_ACTION(n) mf[#n] = &GUIAction::n
#define ADD_ACTION_EX(name, func) mf[name] = &GUIAction::func
		// These actions will be run in the caller's thread
		ADD_ACTION(reboot);
		ADD_ACTION(home);
		ADD_ACTION(key);
		ADD_ACTION(page);
		ADD_ACTION(reload);
		ADD_ACTION(readBackup);
		ADD_ACTION(set);
		ADD_ACTION(clear);
		ADD_ACTION(mount);
		ADD_ACTION(unmount);
		ADD_ACTION_EX("umount", unmount);
		ADD_ACTION(restoredefaultsettings);
		ADD_ACTION(copylog);
		ADD_ACTION(compute);
		ADD_ACTION_EX("addsubtract", compute);
		ADD_ACTION(setguitimezone);
		ADD_ACTION(overlay);
		ADD_ACTION(queuezip);
		ADD_ACTION(cancelzip);
		ADD_ACTION(queueclear);
		ADD_ACTION(sleep);
		ADD_ACTION(appenddatetobackupname);
		ADD_ACTION(generatebackupname);
		ADD_ACTION(checkpartitionlist);
		ADD_ACTION(getpartitiondetails);
		ADD_ACTION(screenshot);
		ADD_ACTION(setbrightness);
		ADD_ACTION(fileexists);
		ADD_ACTION(killterminal);
		ADD_ACTION(checkbackupname);
		ADD_ACTION(adbsideloadcancel);
		ADD_ACTION(fixsu);
		ADD_ACTION(startmtp);
		ADD_ACTION(stopmtp);
		ADD_ACTION(cancelbackup);
		ADD_ACTION(checkpartitionlifetimewrites);
		ADD_ACTION(mountsystemtoggle);

		// remember actions that run in the caller thread
		for (mapFunc::const_iterator it = mf.begin(); it != mf.end(); ++it)
			setActionsRunningInCallerThread.insert(it->first);

		// These actions will run in a separate thread
		ADD_ACTION(flash);
		ADD_ACTION(wipe);
		ADD_ACTION(refreshsizes);
		ADD_ACTION(nandroid);
		ADD_ACTION(fixpermissions);
		ADD_ACTION(dd);
		ADD_ACTION(partitionsd);
		ADD_ACTION(installhtcdumlock);
		ADD_ACTION(htcdumlockrestoreboot);
		ADD_ACTION(htcdumlockreflashrecovery);
		ADD_ACTION(cmd);
		ADD_ACTION(terminalcommand);
		ADD_ACTION(reinjecttwrp);
		ADD_ACTION(decrypt);
		ADD_ACTION(adbsideload);
		ADD_ACTION(openrecoveryscript);
		ADD_ACTION(installsu);
		ADD_ACTION(decrypt_backup);
		ADD_ACTION(repair);
		ADD_ACTION(resize);
		ADD_ACTION(changefilesystem);
		ADD_ACTION(flashimage);
	}

	// First, get the action
	actions = FindNode(node, "actions");
	if (actions)	child = FindNode(actions, "action");
	else			child = FindNode(node, "action");

	if (!child) return;

	while (child)
	{
		Action action;

		attr = child->first_attribute("function");
		if (!attr)  return;

		action.mFunction = attr->value();
		action.mArg = child->value();
		mActions.push_back(action);

		child = child->next_sibling("action");
	}

	// Now, let's get either the key or region
	child = FindNode(node, "touch");
	if (child)
	{
		attr = child->first_attribute("key");
		if (attr)
		{
			std::vector<std::string> keys = TWFunc::Split_String(attr->value(), "+");
			for(size_t i = 0; i < keys.size(); ++i)
			{
				const int key = getKeyByName(keys[i]);
				mKeys[key] = false;
			}
		}
		else
		{
			attr = child->first_attribute("x");
			if (!attr)  return;
			mActionX = atol(attr->value());
			attr = child->first_attribute("y");
			if (!attr)  return;
			mActionY = atol(attr->value());
			attr = child->first_attribute("w");
			if (!attr)  return;
			mActionW = atol(attr->value());
			attr = child->first_attribute("h");
			if (!attr)  return;
			mActionH = atol(attr->value());
		}
	}
}
Example #7
0
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0)
{
	fill_profile_color();
	setBackgroundBrush(profile_color[BACKGROUND].at(0));
	setMouseTracking(true);
	setScene(new QGraphicsScene());
	scene()->setSceneRect(0,0,1920,1080);

	verticalLine = new QGraphicsLineItem(
		fromPercent(0, Qt::Horizontal),
		fromPercent(0, Qt::Vertical),
		fromPercent(0, Qt::Horizontal),
		fromPercent(100, Qt::Vertical)
	);

	verticalLine->setPen(QPen(Qt::DotLine));
	scene()->addItem(verticalLine);

	horizontalLine = new QGraphicsLineItem(
		fromPercent(0, Qt::Horizontal),
		fromPercent(0, Qt::Vertical),
		fromPercent(100, Qt::Horizontal),
		fromPercent(0, Qt::Vertical)
	);

	horizontalLine->setPen(QPen(Qt::DotLine));
	scene()->addItem(horizontalLine);

	timeLine = new Ruler();
	timeLine->setMinimum(0);
	timeLine->setMaximum(TIME_INITIAL_MAX);
	timeLine->setTickInterval(10);
	timeLine->setColor(getColor(TIME_GRID));
	timeLine->setLine(
		fromPercent(10, Qt::Horizontal),
		fromPercent(85, Qt::Vertical),
		fromPercent(90, Qt::Horizontal),
		fromPercent(85, Qt::Vertical)
	);
	timeLine->setOrientation(Qt::Horizontal);
	timeLine->setTickSize(fromPercent(1, Qt::Vertical));
	timeLine->setTextColor(getColor(TIME_TEXT));
	timeLine->updateTicks();
	scene()->addItem(timeLine);

	depthLine = new Ruler();
	depthLine->setMinimum(0);
	depthLine->setMaximum(M_OR_FT(40,120));
	depthLine->setTickInterval(M_OR_FT(10,30));
	depthLine->setLine(
		fromPercent(10, Qt::Horizontal),
		fromPercent(10, Qt::Vertical),
		fromPercent(10, Qt::Horizontal),
		fromPercent(85, Qt::Vertical)
	);
	depthLine->setOrientation(Qt::Vertical);
	depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
	depthLine->setColor(getColor(DEPTH_GRID));
	depthLine->setTextColor(getColor(SAMPLE_DEEP));
	depthLine->updateTicks();
	scene()->addItem(depthLine);

	timeString = new QGraphicsSimpleTextItem();
	timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations);
	timeString->setBrush(profile_color[TIME_TEXT].at(0));
	scene()->addItem(timeString);

	depthString = new QGraphicsSimpleTextItem();
	depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations);
	depthString->setBrush(profile_color[SAMPLE_DEEP].at(0));
	scene()->addItem(depthString);

	diveBg = new QGraphicsPolygonItem();
	diveBg->setPen(QPen(QBrush(),0));
	scene()->addItem(diveBg);

	QString incrText;
	if (prefs.units.length == units::METERS)
		incrText = tr("10m");
	else
		incrText = tr("30ft");

	timeHandler = new ExpanderGraphics();
	timeHandler->increaseBtn->setPixmap(QString(":plan_plus"));
	timeHandler->decreaseBtn->setPixmap(QString(":plan_minus"));
	timeHandler->icon->setPixmap(QString(":icon_time"));
	connect(timeHandler->increaseBtn, SIGNAL(clicked()), this, SLOT(increaseTime()));
	connect(timeHandler->decreaseBtn, SIGNAL(clicked()), this, SLOT(decreaseTime()));
	timeHandler->setPos(fromPercent(83, Qt::Horizontal), fromPercent(100, Qt::Vertical));
	timeHandler->setZValue(-2);
	scene()->addItem(timeHandler);

	depthHandler = new ExpanderGraphics();
	depthHandler->increaseBtn->setPixmap(QString(":arrow_up"));
	depthHandler->decreaseBtn->setPixmap(QString(":arrow_down"));
	depthHandler->icon->setPixmap(QString(":icon_depth"));
	// Inverted here in the slots because the 'up' graphi should increase the depness,
	// and the down should decrease.
	connect(depthHandler->increaseBtn, SIGNAL(clicked()), this, SLOT(decreaseDepth()));
	connect(depthHandler->decreaseBtn, SIGNAL(clicked()), this, SLOT(increaseDepth()));
	depthHandler->setPos(fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical));
	depthHandler->setZValue(-2);
	scene()->addItem(depthHandler);

	minMinutes = TIME_INITIAL_MAX;
	QAction *action = NULL;

#define ADD_ACTION( SHORTCUT, Slot ) \
	action = new QAction(this); \
	action->setShortcut( SHORTCUT ); \
	action->setShortcutContext(Qt::WindowShortcut); \
	addAction(action); \
	connect(action, SIGNAL(triggered(bool)), this, SLOT( Slot ))

	ADD_ACTION(Qt::Key_Escape, keyEscAction());
	ADD_ACTION(Qt::Key_Delete, keyDeleteAction());
	ADD_ACTION(Qt::Key_Up, keyUpAction());
	ADD_ACTION(Qt::Key_Down, keyDownAction());
	ADD_ACTION(Qt::Key_Left, keyLeftAction());
	ADD_ACTION(Qt::Key_Right, keyRightAction());
#undef ADD_ACTION

	connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(drawProfile()));

	connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
			this, SLOT(pointInserted(const QModelIndex&, int, int)));
	connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
			this, SLOT(pointsRemoved(const QModelIndex&, int, int)));
	setRenderHint(QPainter::Antialiasing);
}
Example #8
0
// Constructor for window
ImodvWindow::ImodvWindow(ImodvApp *a,
                         QWidget * parent, const char * name, Qt::WindowFlags f)
  : QMainWindow(parent, f)
{
  int numWidg = 0;
  const char *helpStr = "&Help";
  const char *useHelp = helpStr;
  double posValues[3];
  int numVals = 0;

  mRotationTool = NULL;
  mResizeTool = NULL;
  mDBw = mSBw = mDBstw = mSBstw = mDBalw = mDBstAlw = NULL;
  mMinimized = false;
  setAttribute(Qt::WA_DeleteOnClose);
  setAttribute(Qt::WA_AlwaysShowToolTips);

  QSignalMapper *fileMapper = new QSignalMapper(this);
  QSignalMapper *editMapper = new QSignalMapper(this);
  QSignalMapper *viewMapper = new QSignalMapper(this);
  QSignalMapper *helpMapper = new QSignalMapper(this);

  // construct file menu
  QMenu *fileMenu = menuBar()->addMenu("&File");
  ADD_ACTION_KEY(file, "&Open Model", VFILE_MENU_LOAD, Qt::CTRL + Qt::Key_O);
  mActions[VFILE_MENU_LOAD]->setEnabled(a->standalone);

  ADD_ACTION(file, "&Save Model", VFILE_MENU_SAVE);
  mActions[VFILE_MENU_SAVE]->setEnabled(a->standalone);

  ADD_ACTION(file, "Save Model &As...", VFILE_MENU_SAVEAS);
  mActions[VFILE_MENU_SAVEAS]->setEnabled(a->standalone);
  fileMenu->addSeparator();

  ADD_ACTION(file, "Snap &Tiff As...", VFILE_MENU_SNAPTIFF);
  ADD_ACTION(file, "Snap &NonT As...", VFILE_MENU_SNAPRGB);
  ADD_ACTION(file, "&Zero Snap File #", VFILE_MENU_ZEROSNAP);
  ADD_ACTION(file, "S&et Snap Dir...", VFILE_MENU_SNAPDIR);
  ADD_ACTION_KEY(file, "&Movie/Montage...", VFILE_MENU_MOVIE, Qt::Key_M);
  ADD_ACTION_KEY(file, "Movie Seque&nce...", VFILE_MENU_SEQUENCE, Qt::Key_N);

  ADD_ACTION_KEY(file, a->standalone ? "&Quit" : "&Close", VFILE_MENU_QUIT,
                 Qt::CTRL + Qt::Key_Q);

  connect(fileMapper, SIGNAL(mapped(int)), this, SLOT(fileMenuSlot(int)));

  // Construct Edit menu
  QMenu *editMenu = menuBar()->addMenu("&Edit");
  ADD_ACTION_KEY(edit, "&Objects...", VEDIT_MENU_OBJECTS, Qt::SHIFT + Qt::Key_O);
  ADD_ACTION_KEY(edit, "&Controls...", VEDIT_MENU_CONTROLS, Qt::SHIFT + Qt::Key_C);
  ADD_ACTION_KEY(edit, "&Rotation...", VEDIT_MENU_ROTATION, Qt::SHIFT + Qt::Key_R);
  ADD_ACTION_KEY(edit, "Object &List...", VEDIT_MENU_OBJLIST, Qt::SHIFT + Qt::Key_L);
  ADD_ACTION_KEY(edit, "&Background...", VEDIT_MENU_BKG, Qt::SHIFT + Qt::Key_B);
  ADD_ACTION_KEY(edit, "&Models...", VEDIT_MENU_MODELS, Qt::SHIFT + Qt::Key_M);
  ADD_ACTION_KEY(edit, "&Views...", VEDIT_MENU_VIEWS, Qt::SHIFT + Qt::Key_V);
  ADD_ACTION_KEY(edit, "&Image...", VEDIT_MENU_IMAGE, Qt::SHIFT + Qt::Key_I);
  ADD_ACTION_KEY(edit, "Isos&urface...", VEDIT_MENU_ISOSURFACE, Qt::SHIFT + Qt::Key_U);
  mActions[VEDIT_MENU_IMAGE]->setEnabled(imodvByteImagesExist() != 0);
  mActions[VEDIT_MENU_ISOSURFACE]->setEnabled(imodvByteImagesExist() != 0);
  connect(editMapper, SIGNAL(mapped(int)), this, SLOT(editMenuSlot(int)));

  // View menu
  QMenu *viewMenu = menuBar()->addMenu("&View");
  ADD_ACTION_KEY(view, "Low &Resolution", VVIEW_MENU_LOWRES, Qt::CTRL + Qt::Key_R);
  mActions[VVIEW_MENU_LOWRES]->setCheckable(true);
  mActions[VVIEW_MENU_LOWRES]->setChecked(a->lowres);
  if (!a->standalone) {
    ADD_ACTION_KEY(view, "&Current Point", VVIEW_MENU_CURPNT, Qt::Key_P);
    mActions[VVIEW_MENU_CURPNT]->setCheckable(true);
  }
  ADD_ACTION(view, "Bounding Bo&x", VVIEW_MENU_BOUNDBOX);
  mActions[VVIEW_MENU_BOUNDBOX]->setCheckable(true);

  ADD_ACTION(view, "&Stereo...", VVIEW_MENU_STEREO);
  ADD_ACTION(view, "&Depth Cue...", VVIEW_MENU_DEPTH);
  ADD_ACTION(view, "Scale &Bar...", VVIEW_MENU_SCALEBAR);
  ADD_ACTION(view, "Window Si&ze...", VVIEW_MENU_RESIZE);

  ADD_ACTION(view, "&Invert Z", VVIEW_MENU_INVERTZ);
  mActions[VVIEW_MENU_INVERTZ]->setCheckable(true);
  mActions[VVIEW_MENU_INVERTZ]->setChecked(a->invertZ);

  ADD_ACTION(view, "&Lighting", VVIEW_MENU_LIGHTING);
  mActions[VVIEW_MENU_LIGHTING]->setCheckable(true);
  mActions[VVIEW_MENU_LIGHTING]->setChecked(a->lighting);

  ADD_ACTION(view, "&Wireframe", VVIEW_MENU_WIREFRAME);
  mActions[VVIEW_MENU_WIREFRAME]->setCheckable(true);
  connect(viewMapper, SIGNAL(mapped(int)), this, SLOT(viewMenuSlot(int)));

  ADD_ACTION(view, "&Transparent Bkgd", VVIEW_MENU_TRANSBKGD);
  mActions[VVIEW_MENU_TRANSBKGD]->setCheckable(true);
  ADD_ACTION(view, "Do&uble Buffer", VVIEW_MENU_DB);

  // This made it act on a shifted D only and steal it from imodv_input
  //mViewMenu->setAccel(Qt::Key_D, VVIEW_MENU_DB);
  mActions[VVIEW_MENU_DB]->setCheckable(true);

  QMenu *keyMenu = menuBar()->addMenu("Hot&Keys");
  QSignalMapper *keyMapper = new QSignalMapper(this);
  connect(keyMapper, SIGNAL(mapped(int)), this, SLOT(keyMenuSlot(int)));
  utilBuildPopupMenu(sPopupTable, false, keyMapper, keyMenu, mNumKeyEntries, mActions);

  // Help menu
  // To stabilize the 3dmod menu with model view open, it had to have a 
  // modified menu name PLUS omit the code for the about entry - making it
  // conditional on standalone did not work!  Qt 4.5+ Cocoa Mac. 3/1/10
  // Even this is not perfect, if there is a 3dmodv already up.
#if defined(Q_OS_MACX) && QT_VERSION >= 0x040500
  const char *altHelp = ".&Help.";
  if (!a->standalone)
    useHelp = altHelp;
#endif
  QMenu *helpMenu = menuBar()->addMenu(useHelp);
  ADD_ACTION(help, "&Menus", VHELP_MENU_MENUS);
  ADD_ACTION(help, "&Keyboard", VHELP_MENU_KEYBOARD);
  ADD_ACTION(help, "M&ouse", VHELP_MENU_MOUSE);
#if !(defined(Q_OS_MACX) && QT_VERSION >= 0x040500)
  helpMenu->addSeparator();
  ADD_ACTION(help, "&About", VHELP_MENU_ABOUT);
#endif
  connect(helpMapper, SIGNAL(mapped(int)), this, SLOT(helpMenuSlot(int)));
  
  // Get the widget stack and the GL widgets
  mStack = new QStackedWidget(this);
  setCentralWidget(mStack);
  QGLFormat glFormat;

  if (a->enableDepthDB >= 0) { 
    mDBw = addGLWidgetToStack(&glFormat, true, a->enableDepthDB, false, false);
    mCurGLw = mDBw;
    numWidg++;
  }

  if (a->enableDepthDBal >= 0) { 
    mDBalw = addGLWidgetToStack(&glFormat, true, a->enableDepthDB, false, true);
    if (!numWidg) {
      mCurGLw = mDBalw;
      a->alphaVisual = 1;
    }
    numWidg++;
  }

  if (!numWidg && a->enableDepthDBst >= 0) { 
    mDBstw = addGLWidgetToStack(&glFormat, true, a->enableDepthDBst, true, false);
    if (!numWidg)
      mCurGLw = mDBstw;
    numWidg++;
  }

  if (!numWidg && a->enableDepthDBstAl >= 0) { 
    mDBstAlw = addGLWidgetToStack(&glFormat, true, a->enableDepthDBstAl, true, true);
    if (!numWidg) {
      mCurGLw = mDBstAlw;
      a->alphaVisual = 1;
    }
    numWidg++;
  }

  if (a->enableDepthSB >= 0) { 
    mSBw = addGLWidgetToStack(&glFormat, false, a->enableDepthSB, false, false);
    if (!numWidg) {
      mCurGLw = mSBw;
      a->dblBuf = 0;
    }
    numWidg++;
  }

  if (!numWidg && a->enableDepthSBst >= 0) { 
    mSBstw = addGLWidgetToStack(&glFormat, true, a->enableDepthSBst, true, false);
    if (!numWidg) {
      mCurGLw = mSBstw;
      a->dblBuf = 0;
    }
    numWidg++;
  }
  a->dbPossible = a->dblBuf;

  if (a->transBkgd) {
    if (a->dblBuf && a->enableDepthDBal >= 0) {
      mCurGLw = mDBalw;
      a->alphaVisual = 1;
    } else {
      a->transBkgd = 0;
    }
  }

  // Set the topmost widget of the stack
  mStack->setCurrentWidget(mCurGLw);
  mActions[VVIEW_MENU_DB]->setChecked(a->dblBuf > 0);
  mActions[VVIEW_MENU_DB]->setEnabled(a->dblBuf > 0 && a->enableDepthSB >= 0 && 
                                      !a->transBkgd);
  mActions[VVIEW_MENU_TRANSBKGD]->setChecked(a->transBkgd > 0);
  mActions[VVIEW_MENU_TRANSBKGD]->setEnabled(a->dblBuf > 0 && (a->enableDepthDBal >= 0 || 
                                                           a->enableDepthDBstAl >= 0));

  mTimer = new QTimer(this);
  connect(mTimer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));

  // First time, get the preferences for rotation tool and store in statics
  if (sRToolWithImodv < 0) {
    numVals = ImodPrefs->getGenericSettings("ModvRotationTool", posValues, 3);
    if (numVals > 1) {
      sRToolLeftPos = (int)posValues[0];
      sRToolTopPos = (int)posValues[1];
    }
    if (numVals > 2) 
      sRToolWithImodv = (int)posValues[2];
    else
      sRToolWithImodv = 0;
  }

  // Open tool if it closed with window before
  if (sRToolWithImodv > 0)
    openRotationTool(a);
}
Example #9
0
ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
	currentState(INVALID),
	dataModel(new DivePlotDataModel(this)),
	zoomLevel(0),
	zoomFactor(1.15),
	background(new DivePixmapItem()),
	backgroundFile(":poster"),
	toolTipItem(new ToolTipItem()),
	isPlotZoomed(prefs.zoomed_plot),
	forceReplot(false),
	profileYAxis(new DepthAxis()),
	gasYAxis(new PartialGasPressureAxis()),
	temperatureAxis(new TemperatureAxis()),
	timeAxis(new TimeAxis()),
	diveProfileItem(new DiveProfileItem()),
	temperatureItem(new DiveTemperatureItem()),
	cylinderPressureAxis(new DiveCartesianAxis()),
	gasPressureItem(new DiveGasPressureItem()),
	meanDepth(new MeanDepthLine()),
	diveComputerText(new DiveTextItem()),
	diveCeiling(new DiveCalculatedCeiling()),
	reportedCeiling(new DiveReportedCeiling()),
	pn2GasItem(new PartialPressureGasItem()),
	pheGasItem(new PartialPressureGasItem()),
	po2GasItem(new PartialPressureGasItem()),
	heartBeatAxis(new DiveCartesianAxis()),
	heartBeatItem(new DiveHeartrateItem()),
	rulerItem(new RulerItem2()),
	isGrayscale(false),
	printMode(false),
	shouldCalculateMaxTime(true)
{
	memset(&plotInfo, 0, sizeof(plotInfo));

	setupSceneAndFlags();
	setupItemSizes();
	setupItemOnScene();
	addItemsToScene();
	scene()->installEventFilter(this);
	setEmptyState();
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));

	QAction *action = NULL;
#define ADD_ACTION(SHORTCUT, Slot)                                  \
	action = new QAction(this);                                 \
	action->setShortcut(SHORTCUT);                              \
	action->setShortcutContext(Qt::WindowShortcut);             \
	addAction(action);                                          \
	connect(action, SIGNAL(triggered(bool)), this, SLOT(Slot)); \
	actionsForKeys[SHORTCUT] = action;

	ADD_ACTION(Qt::Key_Escape, keyEscAction());
	ADD_ACTION(Qt::Key_Delete, keyDeleteAction());
	ADD_ACTION(Qt::Key_Up, keyUpAction());
	ADD_ACTION(Qt::Key_Down, keyDownAction());
	ADD_ACTION(Qt::Key_Left, keyLeftAction());
	ADD_ACTION(Qt::Key_Right, keyRightAction());
#undef ADD_ACTION

#ifndef QT_NO_DEBUG
	QTableView *diveDepthTableView = new QTableView();
	diveDepthTableView->setModel(dataModel);
	diveDepthTableView->show();
#endif
}
Example #10
0
void MainMenu::init()
{
#define ADD_ACTION(name, menu, icon, trName, slot, shortcut) \
    action = menu->addAction(icon, trName); \
    action->setShortcut(QKeySequence(QSL(shortcut))); \
    connect(action, SIGNAL(triggered()), this, slot); \
    m_actions[QSL(name)] = action

#define ADD_CHECKABLE_ACTION(name, menu, icon, trName, slot, shortcut) \
    action = menu->addAction(icon, trName); \
    action->setShortcut(QKeySequence(QSL(shortcut))); \
    action->setCheckable(true); \
    connect(action, SIGNAL(triggered(bool)), this, slot); \
    m_actions[QSL(name)] = action

    // Standard actions - needed on Mac to be placed correctly in "application" menu
    QAction* action = new QAction(QIcon::fromTheme(QSL("help-about")), tr("&About QupZilla"), this);
    action->setMenuRole(QAction::AboutRole);
    connect(action, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
    m_actions[QSL("Standard/About")] = action;

    action = new QAction(IconProvider::settingsIcon(), tr("Pr&eferences"), this);
    action->setMenuRole(QAction::PreferencesRole);
    action->setShortcut(QKeySequence(QKeySequence::Preferences));
    connect(action, SIGNAL(triggered()), this, SLOT(showPreferences()));
    m_actions[QSL("Standard/Preferences")] = action;

    action = new QAction(QIcon::fromTheme(QSL("application-exit")), tr("Quit"), this);
    action->setMenuRole(QAction::QuitRole);
    // shortcut set from browserwindow
    connect(action, SIGNAL(triggered()), this, SLOT(quitApplication()));
    m_actions[QSL("Standard/Quit")] = action;

    // File menu
    m_menuFile = new QMenu(tr("&File"));
    connect(m_menuFile, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFileMenu()));
    connect(m_menuFile, SIGNAL(aboutToHide()), this, SLOT(aboutToHideFileMenu()));

    ADD_ACTION("File/NewTab", m_menuFile, IconProvider::newTabIcon(), tr("New Tab"), SLOT(newTab()), "Ctrl+T");
    ADD_ACTION("File/NewWindow", m_menuFile, IconProvider::newWindowIcon(), tr("&New Window"), SLOT(newWindow()), "Ctrl+N");
    ADD_ACTION("File/NewPrivateWindow", m_menuFile, IconProvider::privateBrowsingIcon(), tr("New &Private Window"), SLOT(newPrivateWindow()), "Ctrl+Shift+P");
    ADD_ACTION("File/OpenLocation", m_menuFile, QIcon::fromTheme(QSL("document-open-remote")), tr("Open Location"), SLOT(openLocation()), "Ctrl+L");
    ADD_ACTION("File/OpenFile", m_menuFile, QIcon::fromTheme(QSL("document-open")), tr("Open &File..."), SLOT(openFile()), "Ctrl+O");
    ADD_ACTION("File/CloseWindow", m_menuFile, QIcon::fromTheme(QSL("window-close")), tr("Close Window"), SLOT(closeWindow()), "Ctrl+Shift+W");
    m_menuFile->addSeparator();
    ADD_ACTION("File/SavePageAs", m_menuFile, QIcon::fromTheme(QSL("document-save")), tr("&Save Page As..."), SLOT(savePageAs()), "Ctrl+S");
    ADD_ACTION("File/SavePageScreen", m_menuFile, QIcon::fromTheme(QSL("image-loading")), tr("Save Page Screen"), SLOT(savePageScreen()), "Ctrl+Shift+S");
    ADD_ACTION("File/SendLink", m_menuFile, QIcon::fromTheme(QSL("mail-message-new")), tr("Send Link..."), SLOT(sendLink()), "");
    ADD_ACTION("File/Print", m_menuFile, QIcon::fromTheme(QSL("document-print")), tr("&Print..."), SLOT(printPage()), "Ctrl+P");
    m_menuFile->addSeparator();
    ADD_CHECKABLE_ACTION("File/WorkOffline", m_menuFile, QIcon(), tr("Work &Offline"), SLOT(toggleOfflineMode()), "");
    m_menuFile->addSeparator();
    m_menuFile->addAction(m_actions[QSL("Standard/Quit")]);

    // Edit menu
    m_menuEdit = new QMenu(tr("&Edit"));
    connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu()));
    connect(m_menuEdit, SIGNAL(aboutToHide()), this, SLOT(aboutToHideEditMenu()));

    ADD_ACTION("Edit/Undo", m_menuEdit, QIcon::fromTheme(QSL("edit-undo")), tr("&Undo"), SLOT(editUndo()), "Ctrl+Z");
    ADD_ACTION("Edit/Redo", m_menuEdit, QIcon::fromTheme(QSL("edit-redo")), tr("&Redo"), SLOT(editRedo()), "Ctrl+Shift+Z");
    m_menuEdit->addSeparator();
    ADD_ACTION("Edit/Cut", m_menuEdit, QIcon::fromTheme(QSL("edit-cut")), tr("&Cut"), SLOT(editCut()), "Ctrl+X");
    ADD_ACTION("Edit/Copy", m_menuEdit, QIcon::fromTheme(QSL("edit-copy")), tr("C&opy"), SLOT(editCopy()), "Ctrl+C");
    ADD_ACTION("Edit/Paste", m_menuEdit, QIcon::fromTheme(QSL("edit-paste")), tr("&Paste"), SLOT(editPaste()), "Ctrl+V");
    m_menuEdit->addSeparator();
    ADD_ACTION("Edit/SelectAll", m_menuEdit, QIcon::fromTheme(QSL("edit-select-all")), tr("Select &All"), SLOT(editSelectAll()), "Ctrl+A");
    ADD_ACTION("Edit/Find", m_menuEdit, QIcon::fromTheme(QSL("edit-find")), tr("&Find"), SLOT(editFind()), "Ctrl+F");
    m_menuEdit->addSeparator();

    // View menu
    m_menuView = new QMenu(tr("&View"));
    connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu()));
    connect(m_menuView, SIGNAL(aboutToHide()), this, SLOT(aboutToHideViewMenu()));

    QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
    connect(toolbarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolbarsMenu()));
    QMenu* sidebarMenu = new QMenu(tr("Sidebar"));
    connect(sidebarMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowSidebarsMenu()));
    QMenu* encodingMenu = new QMenu(tr("Character &Encoding"));
    connect(encodingMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu()));

    // Create menus to make shortcuts available even before first showing the menu
    m_window->createToolbarsMenu(toolbarsMenu);
    m_window->createSidebarsMenu(sidebarMenu);

    m_menuView->addMenu(toolbarsMenu);
    m_menuView->addMenu(sidebarMenu);
    ADD_CHECKABLE_ACTION("View/ShowStatusBar", m_menuView, QIcon(), tr("Sta&tus Bar"), SLOT(showStatusBar()), "");
    m_menuView->addSeparator();
    ADD_ACTION("View/Stop", m_menuView, QIcon::fromTheme(QSL("process-stop")), tr("&Stop"), SLOT(stop()), "Esc");
    ADD_ACTION("View/Reload", m_menuView, QIcon::fromTheme(QSL("view-refresh")), tr("&Reload"), SLOT(reload()), "F5");
    m_menuView->addSeparator();
    ADD_ACTION("View/ZoomIn", m_menuView, QIcon::fromTheme(QSL("zoom-in")), tr("Zoom &In"), SLOT(zoomIn()), "Ctrl++");
    ADD_ACTION("View/ZoomOut", m_menuView, QIcon::fromTheme(QSL("zoom-out")), tr("Zoom &Out"), SLOT(zoomOut()), "Ctrl+-");
    ADD_ACTION("View/ZoomReset", m_menuView, QIcon::fromTheme(QSL("zoom-original")), tr("Reset"), SLOT(zoomReset()), "Ctrl+0");
    m_menuView->addSeparator();
    ADD_CHECKABLE_ACTION("View/CaretBrowsing", m_menuView, QIcon(), tr("&Caret Browsing"), SLOT(toggleCaretBrowsing()), "F7");
    m_menuView->addMenu(encodingMenu);
    m_menuView->addSeparator();
    ADD_ACTION("View/PageSource", m_menuView, QIcon::fromTheme(QSL("text-html")), tr("&Page Source"), SLOT(showPageSource()), "Ctrl+U");
    ADD_CHECKABLE_ACTION("View/FullScreen", m_menuView, QIcon(), tr("&FullScreen"), SLOT(showFullScreen()), "F11");

    // Tools menu
    m_menuTools = new QMenu(tr("&Tools"));
    connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
    connect(m_menuTools, SIGNAL(aboutToHide()), this, SLOT(aboutToHideToolsMenu()));

    ADD_ACTION("Tools/WebSearch", m_menuTools, QIcon(), tr("&Web Search"), SLOT(webSearch()), "Ctrl+K");
    ADD_ACTION("Tools/SiteInfo", m_menuTools, QIcon::fromTheme(QSL("dialog-information")), tr("Site &Info"), SLOT(showSiteInfo()), "Ctrl+I");
    m_menuTools->addSeparator();
    ADD_ACTION("Tools/DownloadManager", m_menuTools, QIcon(), tr("&Download Manager"), SLOT(showDownloadManager()), "Ctrl+Y");
    ADD_ACTION("Tools/CookiesManager", m_menuTools, QIcon(), tr("&Cookies Manager"), SLOT(showCookieManager()), "");
    ADD_ACTION("Tools/AdBlock", m_menuTools, QIcon(), tr("&AdBlock"), SLOT(showAdBlockDialog()), "");
    ADD_ACTION("Tools/RssReader", m_menuTools, QIcon(), tr("RSS &Reader"), SLOT(showRssManager()), "");
    ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(showWebInspector()), "Ctrl+Shift+I");
    ADD_ACTION("Tools/ClearRecentHistory", m_menuTools, QIcon::fromTheme(QSL("edit-clear")), tr("Clear Recent &History"), SLOT(showClearRecentHistoryDialog()), "Ctrl+Shift+Del");
    m_menuTools->addSeparator();

    // Help menu
    m_menuHelp = new QMenu(tr("&Help"));

#ifndef Q_OS_MAC
    ADD_ACTION("Help/AboutQt", m_menuHelp, QIcon(QSL(":/icons/menu/qt.png")), tr("About &Qt"), SLOT(aboutQt()), "");
    m_menuHelp->addAction(m_actions[QSL("Standard/About")]);
    m_menuHelp->addSeparator();
#endif

    ADD_ACTION("Help/InfoAboutApp", m_menuHelp, QIcon::fromTheme(QSL("help-contents")), tr("Information about application"), SLOT(showInfoAboutApp()), "");
    ADD_ACTION("Help/ConfigInfo", m_menuHelp, QIcon(), tr("Configuration Information"), SLOT(showConfigInfo()), "");
    ADD_ACTION("Help/ReportIssue", m_menuHelp, QIcon(), tr("Report &Issue"), SLOT(reportIssue()), "");

    m_actions[QSL("Help/InfoAboutApp")]->setShortcut(QKeySequence(QKeySequence::HelpContents));

    // History menu
    m_menuHistory = new HistoryMenu();
    m_menuHistory->setMainWindow(m_window);

    // Bookmarks menu
    m_menuBookmarks = new BookmarksMenu();
    m_menuBookmarks->setMainWindow(m_window);

    // Other actions
    action = new QAction(QIcon::fromTheme(QSL("user-trash")), tr("Restore &Closed Tab"), this);
    action->setShortcut(QKeySequence(QSL("Ctrl+Shift+T")));
    connect(action, SIGNAL(triggered()), this, SLOT(restoreClosedTab()));
    m_actions[QSL("Other/RestoreClosedTab")] = action;

#ifdef Q_OS_MAC
    m_actions[QSL("View/FullScreen")]->setShortcut(QKeySequence(QSL("F11")));

    // Add standard actions to File Menu (as it won't be ever cleared) and Mac menubar should move them to "Application" menu
    m_menuFile->addAction(m_actions[QSL("Standard/About")]);
    m_menuFile->addAction(m_actions[QSL("Standard/Preferences")]);
#endif

#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
    m_menuEdit->addAction(m_actions[QSL("Standard/Preferences")]);
#elif !defined(Q_OS_MAC)
    m_menuTools->addAction(m_actions[QSL("Standard/Preferences")]);
#endif

#ifndef QTWEBKIT_FROM_2_3
    m_actions[QSL("View/CaretBrowsing")]->setVisible(false);
#endif

    // Menus are hidden by default
    aboutToHideFileMenu();
    aboutToHideViewMenu();
    aboutToHideEditMenu();
    aboutToHideToolsMenu();

    addActionsToWindow();
}
Example #11
0
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0)
{
	fill_profile_color();
	setBackgroundBrush(profile_color[BACKGROUND].at(0));
	setMouseTracking(true);
	setScene(new QGraphicsScene());
	scene()->setSceneRect(0,0,1920,1080);

	verticalLine = new QGraphicsLineItem(
		fromPercent(0, Qt::Horizontal),
		fromPercent(0, Qt::Vertical),
		fromPercent(0, Qt::Horizontal),
		fromPercent(100, Qt::Vertical)
	);

	verticalLine->setPen(QPen(Qt::DotLine));
	scene()->addItem(verticalLine);

	horizontalLine = new QGraphicsLineItem(
		fromPercent(0, Qt::Horizontal),
		fromPercent(0, Qt::Vertical),
		fromPercent(100, Qt::Horizontal),
		fromPercent(0, Qt::Vertical)
	);

	horizontalLine->setPen(QPen(Qt::DotLine));
	scene()->addItem(horizontalLine);

	timeLine = new Ruler();
	timeLine->setMinimum(0);
	timeLine->setMaximum(TIME_INITIAL_MAX);
	timeLine->setTickInterval(10);
	timeLine->setColor(getColor(TIME_GRID));
	timeLine->setLine(
		fromPercent(10, Qt::Horizontal),
		fromPercent(90, Qt::Vertical),
		fromPercent(90, Qt::Horizontal),
		fromPercent(90, Qt::Vertical)
	);
	timeLine->setOrientation(Qt::Horizontal);
	timeLine->setTickSize(fromPercent(1, Qt::Vertical));
	timeLine->setTextColor(getColor(TIME_TEXT));
	timeLine->updateTicks();
	scene()->addItem(timeLine);

	depthLine = new Ruler();
	depthLine->setMinimum(0);
	depthLine->setMaximum(M_OR_FT(40,120));
	depthLine->setTickInterval(M_OR_FT(10,30));
	depthLine->setLine(
		fromPercent(10, Qt::Horizontal),
		fromPercent(10, Qt::Vertical),
		fromPercent(10, Qt::Horizontal),
		fromPercent(90, Qt::Vertical)
	);
	depthLine->setOrientation(Qt::Vertical);
	depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
	depthLine->setColor(getColor(DEPTH_GRID));
	depthLine->setTextColor(getColor(SAMPLE_DEEP));
	depthLine->updateTicks();
	scene()->addItem(depthLine);

	timeString = new QGraphicsSimpleTextItem();
	timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations);
	timeString->setBrush(profile_color[TIME_TEXT].at(0));
	scene()->addItem(timeString);

	depthString = new QGraphicsSimpleTextItem();
	depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations);
	depthString->setBrush(profile_color[SAMPLE_DEEP].at(0));
	scene()->addItem(depthString);

	diveBg = new QGraphicsPolygonItem();
	diveBg->setPen(QPen(QBrush(),0));
	scene()->addItem(diveBg);

#define ADDBTN(obj, icon, text, horizontal, vertical, tooltip, value, slot) \
	obj = new Button(); \
	obj->setPixmap(QPixmap(icon)); \
	obj->setPos(fromPercent(horizontal, Qt::Horizontal), fromPercent(vertical, Qt::Vertical)); \
	obj->setToolTip(QString(tooltip.arg(value))); \
	scene()->addItem(obj); \
	connect(obj, SIGNAL(clicked()), this, SLOT(slot));

	QString incrText;
	if (prefs.units.length == units::METERS)
		incrText = tr("10m");
	else
		incrText = tr("30ft");
	ADDBTN(plusDepth, ":plus",   ""  , 5,  5, tr("Increase maximum depth by %1"), incrText, increaseDepth());
	ADDBTN(lessDepth, ":minimum",""  , 2,  5, tr("Decreases maximum depth by %1"), incrText, decreaseDepth());
	ADDBTN(plusTime,  ":plus",   ""  , 95, 95, tr("Increase minimum time by %1"), tr("10min"), increaseTime());
	ADDBTN(lessTime,  ":minimum",""  , 92, 95, tr("Decreases minimum time by %1"), tr("10min"), decreaseTime());
#undef ADDBTN
	minMinutes = TIME_INITIAL_MAX;

	QAction *action = NULL;

#define ADD_ACTION( SHORTCUT, Slot ) \
	action = new QAction(this); \
	action->setShortcut( SHORTCUT ); \
	action->setShortcutContext(Qt::WindowShortcut); \
	addAction(action); \
	connect(action, SIGNAL(triggered(bool)), this, SLOT( Slot ))

	ADD_ACTION(Qt::Key_Escape, keyEscAction());
	ADD_ACTION(Qt::Key_Delete, keyDeleteAction());
	ADD_ACTION(Qt::Key_Up, keyUpAction());
	ADD_ACTION(Qt::Key_Down, keyDownAction());
	ADD_ACTION(Qt::Key_Left, keyLeftAction());
	ADD_ACTION(Qt::Key_Right, keyRightAction());
#undef ADD_ACTION

	// Prepare the stuff for the gas-choices.
	gasListView = new QListView();
	gasListView->setWindowFlags(Qt::Popup);
	gasListView->setModel(GasSelectionModel::instance());
	gasListView->hide();
	gasListView->installEventFilter(this);

	connect(gasListView, SIGNAL(activated(QModelIndex)), this, SLOT(selectGas(QModelIndex)));
	connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(drawProfile()));

	connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
			this, SLOT(pointInserted(const QModelIndex&, int, int)));
	connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
			this, SLOT(pointsRemoved(const QModelIndex&, int, int)));
	setRenderHint(QPainter::Antialiasing);
}
PseudoPluginInterface::PseudoPluginInterface() :
    _closeMainScreenOption(tr("core"), tr("close-main-screen-result"), ConfirmQuit,
                           metaObject()->className(), "Close main screen result", "The result of closing the main screen", this),
    _autoLoadPlugins(tr("core"), tr("autoload-plugins"), true,
                     metaObject()->className(), "Autoload plugins", "Automatically load all plugins that can be found", this)
{

    qRegisterMetaTypeStreamOperators<Ology::Core::PseudoPluginInterface::CloseMainScreenOption>("Ology::Core::PseudoPluginInterface::CloseMainScreenOption");

    registerSetting(&_closeMainScreenOption);
    registerSetting(&_autoLoadPlugins);

#define ADD_ACTION(class, shortcut) { \
        class *action = new class(this); \
        action->setShortcut(shortcut); \
        _actions << action; \
    }

    ADD_ACTION(Core::QuitAction, QKeySequence("Ctrl+Q"));
    ADD_ACTION(Core::CloseScreenAction, Qt::Key_Escape);
    ADD_ACTION(Core::MoreScreenAction, Qt::Key_F1);

    ADD_ACTION(Core::PageUpAction, QKeySequence()); //Qt::Key_PageUp);
    ADD_ACTION(Core::PageDownAction, QKeySequence()); //Qt::Key_PageDown);
    ADD_ACTION(Core::UpAction, QKeySequence()); //Qt::Key_Up);
    ADD_ACTION(Core::DownAction, QKeySequence()); //Qt::Key_Down);
    ADD_ACTION(Core::LeftAction, QKeySequence()); //Qt::Key_Left);
    ADD_ACTION(Core::RightAction, QKeySequence()); //Qt::Key_Right);
    ADD_ACTION(Core::FirstAction, QKeySequence()); //Qt::Key_Home);
    ADD_ACTION(Core::LastAction, QKeySequence()); //Qt::Key_End);

    ADD_ACTION(Core::PlayAction, QKeySequence());
    ADD_ACTION(Core::StopAction, QKeySequence());
    ADD_ACTION(Core::NextAction, Qt::CTRL + Qt::Key_Right);
    ADD_ACTION(Core::PrevAction, Qt::CTRL + Qt::Key_Left);
    ADD_ACTION(Core::PlayOrPauseAction, QKeySequence("Ctrl+P"));
    ADD_ACTION(Core::PauseOrUnpauseAction, QKeySequence());
}