Beispiel #1
0
UbuntuTray::UbuntuTray(Main *qtnote, QObject *parent) :
    TrayImpl(parent),
    qtnote(qtnote),
    contextMenu(0)
{
    menuUpdateTimer = new QTimer(this);
    menuUpdateTimer->setInterval(1000);
    menuUpdateTimer->setSingleShot(true);
    connect(menuUpdateTimer, SIGNAL(timeout()), SLOT(rebuildMenu()));

    sti = new QSystemTrayIcon(QIcon::fromTheme("qtnote", QIcon(":/icons/trayicon")), this);
    connect(sti, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SIGNAL(newNoteTriggered()));

    actQuit = new QAction(QIcon(":/icons/exit"), tr("&Quit"), this);
    actNew = new QAction(QIcon(":/icons/new"), tr("&New"), this);
    actAbout = new QAction(QIcon(":/icons/trayicon"), tr("&About"), this);
    actOptions = new QAction(QIcon(":/icons/options"), tr("&Options"), this);
    actManager = new QAction(QIcon(":/icons/manager"), tr("&Note Manager"), this);

    connect(actQuit, SIGNAL(triggered()), SIGNAL(exitTriggered()));
    connect(actNew, SIGNAL(triggered()), SIGNAL(newNoteTriggered()));
    connect(actManager, SIGNAL(triggered()), SIGNAL(noteManagerTriggered()));
    connect(actOptions, SIGNAL(triggered()), SIGNAL(optionsTriggered()));
    connect(actAbout, SIGNAL(triggered()), SIGNAL(aboutTriggered()));

    advancedMenu = new QMenu;
    advancedMenu->addAction(actOptions);
    advancedMenu->addAction(actManager);
    advancedMenu->addAction(actAbout);
    advancedMenu->addSeparator();
    advancedMenu->addAction(actQuit);
    advancedMenu->setTitle(tr("More.."));

    connect(NoteManager::instance(), SIGNAL(storageAdded(StorageItem)), menuUpdateTimer, SLOT(start()));
    connect(NoteManager::instance(), SIGNAL(storageRemoved(StorageItem)), menuUpdateTimer, SLOT(start()));
    connect(NoteManager::instance(), SIGNAL(storageChanged(StorageItem)), menuUpdateTimer, SLOT(start()));
    menuUpdateTimer->start();
}
Beispiel #2
0
CMainWindow::CMainWindow(QGLWidget *glwidget, QWidget *parent)
 : QStackedWidget(parent),
   m_main_menu(0),
   m_single_player(0),
   m_multi_player(0),
   m_glwidget(glwidget),
   m_pexeso_view(0),
   m_pexeso_scene(0),
   m_machine(0)
{
  PEXESO_ASSERT(m_glwidget != 0);

  /* create widgets */
  m_main_menu = new CMainMenuWidget;
  m_single_player = new CSinglePlayerMenuWidget;
  m_multi_player = new CMultiPlayerMenuWidget;
  /*
     according to dumentation it is possible to associate a single scene with multiple views,
     thus QGraphicsView will not take an ownership over scene and we must do it manually.
     Also this SO post confirms this:
     http://stackoverflow.com/questions/4955743/does-a-qgraphicsview-take-ownership-over-its-associated-graphics-scene
  */
  m_pexeso_scene = new CPexesoScene(this);
  m_pexeso_view = new CPexesoView(m_glwidget, m_pexeso_scene);
  //m_pexeso->makeCurrent(); // this sadly does not work from constructor

  addWidget(m_main_menu);
  addWidget(m_single_player);
  addWidget(m_multi_player);
  addWidget(m_pexeso_view);

  /* create the state machine and states */
  m_machine = new QStateMachine(this);
  connect(m_machine, SIGNAL(finished()), SLOT(close()));

  QState *s_main_menu = new QState;
  QState *s_sp_menu = new QState;
  QState *s_mp_menu = new QState;
  QState *s_load = new QState;        // the game is loading
  QState *s_game = new QState;        // the game has begun
  QFinalState *sf = new QFinalState;  // final state

  /* assign actions to states */
  s_main_menu->assignProperty(this, "currentIndex", 0);  // main menu screen has index 0
  //s_main_menu->assignProperty(this, "windowTitle", "s_main_menu");

  s_sp_menu->assignProperty(this, "currentIndex", 1);    // single player screen has index 1
  //s_sp_menu->assignProperty(this, "windowTitle", "s_sp_menu");
  connect(s_sp_menu, SIGNAL(exited()), m_single_player, SLOT(clearError()));  // clear any errors when this state is exited

  s_mp_menu->assignProperty(this, "currentIndex", 2);    // multi player screen has index 2
  //s_mp_menu->assignProperty(this, "windowTitle", "s_mp_menu");

  connect(s_load, SIGNAL(entered()), SLOT(handleGameLoadTrans()));
  //s_load->assignProperty(this, "windowTitle", "s_load");

  s_game->assignProperty(this, "currentIndex", 3);       // game widget screen
  //s_game->assignProperty(this, "windowTitle", "s_game");

  /* transitions from main menu */
  s_main_menu->addTransition(m_main_menu, SIGNAL(exitTriggered()), sf);
  s_main_menu->addTransition(m_main_menu, SIGNAL(singlePlayerTriggered()), s_sp_menu);
  s_main_menu->addTransition(m_main_menu, SIGNAL(multiPlayerTriggered()), s_mp_menu);

  /* transitions from single player menu */
  s_sp_menu->addTransition(m_single_player, SIGNAL(backTriggered()), s_main_menu);
  s_sp_menu->addTransition(m_single_player, SIGNAL(startGameTriggered()), s_load);

  /* transitions from multiplayer menu */
  /* these transitions work like this: when in state s_mp_menu and multiplayer
     menu screen triggeres a signal backTriggered() then the state machine will
     transition to s_main_menu state */
  s_mp_menu->addTransition(m_multi_player, SIGNAL(backTriggered()), s_main_menu);

  /* load transitions */
  s_load->addTransition(m_pexeso_scene, SIGNAL(errorTriggered()), s_sp_menu);
  s_load->addTransition(m_pexeso_scene, SIGNAL(startTriggered()), s_game);

  /* transitons from in-game menu */
  s_game->addTransition(m_pexeso_scene, SIGNAL(mainMenuTriggered()), s_main_menu);
  s_game->addTransition(m_pexeso_scene, SIGNAL(quitTriggered()), sf);
  s_game->addTransition(m_pexeso_scene, SIGNAL(gameOverTriggered()), s_main_menu);

  /* add states to state machine and start it */
  m_machine->addState(s_main_menu);
  m_machine->addState(s_sp_menu);
  m_machine->addState(s_mp_menu);
  m_machine->addState(s_load);
  m_machine->addState(s_game);
  m_machine->addState(sf);

  m_machine->setInitialState(s_main_menu);

  m_machine->start();
}
Beispiel #3
0
/*!
 * This is our default constructor, which creates a new menu bar populated with
 * the actions for our application.
 *
 * \param p The menu bar's parent widget.
 */
CSMainMenuBar::CSMainMenuBar(QWidget *p)
	: QMenuBar(p)
{
	// Initialize our dialog.

	aboutDialog = new CSAboutDialog(this);

	// Initialize the file menu.

	fileMenu = addMenu(tr("&File"));

	newCollectionAction = fileMenu->addAction(tr("&New Collection..."));
	newCollectionAction->setIcon(CSGUIUtils::getIconFromTheme("list-add"));
	newCollectionAction->setShortcut(Qt::CTRL + Qt::Key_N);
	newCollectionAction->setStatusTip(tr("Create a new collection"));

	syncAction = fileMenu->addAction(tr("&Sync..."));
	syncAction->setIcon(
		CSGUIUtils::getIconFromTheme("sync-synchronizing"));
	syncAction->setShortcut(Qt::CTRL + Qt::Key_S);
	syncAction->setStatusTip(tr("Sync two collections"));

	removeCollectionAction = fileMenu->addAction(
		tr("&Remove Collection..."));
	removeCollectionAction->setIcon(
		CSGUIUtils::getIconFromTheme("list-remove"));
	removeCollectionAction->setStatusTip(
		tr("Remove the current collection"));

	fileMenu->addSeparator();

	exitAction = fileMenu->addAction(tr("E&xit"));
	exitAction->setIcon(CSGUIUtils::getIconFromTheme("application-exit"));
	exitAction->setStatusTip(tr("Exit CuteSync"));

	// Initialize the settings menu.

	settingsMenu = addMenu(tr("&Settings"));

	resetSettingsAction = settingsMenu->addAction(tr("Reset Settings"));
	resetSettingsAction->setStatusTip(
		tr("Reset all saved data to its default state"));

	// Initialize the tools menu.

	toolsMenu = addMenu(tr("&Tools"));

	checkIPodAction = toolsMenu->addAction(tr("Check iPod Filesystem"));
	checkIPodAction->setStatusTip(
		tr("Check an iPod's filesystem for errors."));

	#ifdef CUTESYNC_DEBUG
		createIPodAction = toolsMenu->addAction(
			tr("Create Testing iPod"));
		createIPodAction->setStatusTip(
			tr("Create a false iPod for testing purposes."));
	#endif

	// Initialize the help menu.

	helpMenu = addMenu(tr("&Help"));

	aboutCuteSyncAction = helpMenu->addAction(tr("&About CuteSync..."));
	aboutCuteSyncAction->setIcon(
		CSGUIUtils::getIconFromTheme("help-about"));
	aboutCuteSyncAction->setStatusTip(
		tr("Display CuteSync's about dialog"));

	aboutQtAction = helpMenu->addAction(tr("About &Qt..."));
	aboutQtAction->setIcon(CSGUIUtils::getIconFromTheme("help-about"));
	aboutQtAction->setStatusTip(
		tr("Display the Qt library's about dialog"));

	// Connect actions.

	QObject::connect(newCollectionAction, SIGNAL(triggered()),
		this, SIGNAL(newTriggered()));
	QObject::connect(syncAction, SIGNAL(triggered()),
		this, SIGNAL(syncTriggered()));
	QObject::connect(removeCollectionAction, SIGNAL(triggered()),
		this, SIGNAL(removeTriggered()));
	QObject::connect(exitAction, SIGNAL(triggered()),
		this, SIGNAL(exitTriggered()));
	QObject::connect(resetSettingsAction, SIGNAL(triggered()),
		this, SIGNAL(resetSettingsTriggered()));
	QObject::connect(checkIPodAction, SIGNAL(triggered()),
		this, SIGNAL(checkIPodTriggered()));

	#ifdef CUTESYNC_DEBUG
		QObject::connect(createIPodAction, SIGNAL(triggered()),
			this, SIGNAL(createIPodTriggered()));
	#endif

	QObject::connect(aboutCuteSyncAction, SIGNAL(triggered()),
		this, SLOT(doAboutCuteSync()));
	QObject::connect(aboutQtAction, SIGNAL(triggered()),
		qApp, SLOT(aboutQt()));
}