Exemple #1
0
void BrailleMusicEditor::setupOptionsActions() {
  auto menu = new QMenu(tr("O&ptions"), this);
  menuBar()->addMenu(menu);
  QAction *settings = new QAction(tr("&Settings..."), this);
  connect(settings, SIGNAL(triggered()), this, SLOT(showOptions()));
  menu->addAction(settings);
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: newFile(); break;
        case 1: openFile(); break;
        case 2: loadFile((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 3: openRecentFile(); break;
        case 4: showOptions(); break;
        case 5: updateTime(); break;
        case 6: lookupAGS_ID(); break;
        case 7: lookupPCC_ID(); break;
        case 8: lookupPCC_ID((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 9: setEventType((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 10: setEventID((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: setEventTypeID((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 12: boo(); break;
        case 13: showError((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 14: login(); break;
        case 15: logout(); break;
        default: ;
        }
        _id -= 16;
    }
    return _id;
}
void ControllerAdaugaRefill::run(ModelStoc &stoc) {
    std::size_t maxSize = showOptions(stoc);
    ViewConsole &con = ViewConsole::getSingleton();
    std::size_t nr;
    do {
        con << "\nIntroduceti numarul produsului (0 pentru stop): ";
        std::stringstream str(con.getLine());
        str >> nr;
        if (nr) {
            // test for validity
            if (nr > maxSize) {
                con << "Numar invalid!";
            } else {

                con << "Numarul de produse de adaugat (numar): ";
                std::stringstream nrProdStr(con.getLine());
                int nrProd;
                nrProdStr >> nrProd;

                ModelStoc::bunuri_pointer_t bunuri = stoc.getBunuriPointer();
                stoc.addStocToBun(bunuri[nr - 1], nrProd);
            }
        } // else nr == 0
    } while (nr != 0);
}
Exemple #4
0
void LightscreenWindow::executeArgument(const QString &message)
{
    if (message == "--wake") {
        show();
        os::setForegroundWindow(this);
        qApp->alert(this, 2000);
    } else if (message == "--screen") {
        screenshotAction(Screenshot::WholeScreen);
    } else if (message == "--area") {
        screenshotAction(Screenshot::SelectedArea);
    } else if (message == "--activewindow") {
        screenshotAction(Screenshot::ActiveWindow);
    } else if (message == "--pickwindow") {
        screenshotAction(Screenshot::SelectedWindow);
    } else if (message == "--folder") {
        action(OpenScreenshotFolder);
    } else if (message == "--uploadlast") {
        uploadLast();
    } else if (message == "--viewhistory") {
        showHistoryDialog();
    } else if (message == "--options") {
        showOptions();
    } else if (message == "--quit") {
        qApp->quit();
    }
}
//---------------------------------------------------------------------
int MilkshapePlugin::Execute (msModel* pModel)
{
    // Do nothing if no model selected
    if (!pModel)
        return -1;

	Ogre::LogManager logMgr;
	logMgr.createLog("msOgreExporter.log", true);
	logMgr.logMessage("OGRE Milkshape Exporter Log");
	logMgr.logMessage("---------------------------");
	Ogre::ResourceGroupManager resGrpMgr;

	//
    // check, if we have something to export
    //
    if (msModel_GetMeshCount (pModel) == 0)
    {
        ::MessageBox (NULL, "The model is empty!  Nothing exported!", "OGRE Export", MB_OK | MB_ICONWARNING);
        return 0;
    }

    if (!showOptions()) return 0;

    if (exportMesh)
    {
        doExportMesh(pModel);
    }

    return 0;

}
void RS_ActionDrawText::init(int status) {
    RS_ActionInterface::init(status);
    if (RS_DIALOGFACTORY) {

        switch (status) {
        case ShowDialog: {
                reset();

				RS_Text tmp(NULL, *data);
                if (RS_DIALOGFACTORY->requestTextDialog(&tmp)) {
					data.reset(new RS_TextData(tmp.getData()));
                    setStatus(SetPos);
                    showOptions();
                } else {
                    hideOptions();
                    setFinished();
                }
            }
            break;

        case SetPos:
            RS_DIALOGFACTORY->requestOptions(this, true, true);
            deletePreview();
            preview->setVisible(true);
            preparePreview();
            break;

        default:
            break;
        }
    }
}
Exemple #7
0
void RS_ActionDrawText::init(int status) {
    RS_ActionInterface::init(status);
    if (RS_DIALOGFACTORY!=NULL) {

        switch (status) {
        case ShowDialog: {
                clearPreview();
                reset();

                RS_Text tmp(NULL, data);
                if (RS_DIALOGFACTORY->requestTextDialog(&tmp)) {
                    data = tmp.getData();
                    preparePreview();
                    preview->setVisible(false);

                    setStatus(SetPos);
                    showOptions();
                } else {
                    hideOptions();
                    finish();
                }
                graphicView->redraw();
            }
            break;

        case SetPos:
            RS_DIALOGFACTORY->requestOptions(this, true, true);
            break;

        default:
            break;
        }
    }
}
Exemple #8
0
/*
 * Main function
 */
int main(int argc, char* argv[])
{
    cout << "          Producers-Consumers demo running" << endl
         << "          --------------------------------" << endl << endl;

    // create an object to store and handle options
    run_options opt;

    // default parameters are set here
    opt.num_of_producers = 10;      // threads
    opt.num_of_consumers = 10;      // threads
    opt.production_duration = 500;  // milliseconds
    opt.consumption_duration = 500; // milliseconds
    opt.market_buffer_size = 1000;  // integers

    // parse and assign user-defined options (if any)
    setOptions(argc, argv, &opt);

    // display options
    showOptions(&opt);

    // create an object to simulate the producers-consumers problem
    Market MyMarket(&opt);

    // trigger the simulation
    MyMarket.run();

    return 0;
}
Exemple #9
0
int
main(int argc, char *argv[])
{
	printf("Platform-independent login recording test driver\n");

	__progname = ssh_get_progname(argv[0]);
	if (argc == 2) {
		if (strncmp(argv[1], "-i", 3) == 0)
			compile_opts_only = 1;
		else if (strncmp(argv[1], "-v", 3) == 0)
			be_verbose=1;
	}

	if (!compile_opts_only) {
		if (be_verbose && !testOutput())
			return 1;

		if (!testAPI())
			return 1;
	}

	showOptions();

	return 0;
} /* main() */
/**
 * Constructor.
 */
RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer& container,
                                             RS_GraphicView& graphicView)
    :RS_ActionInterface("Print Preview",
                        container, graphicView), hasOptions(false),scaleFixed(false)
    ,m_bPaperOffset(false)
{
    showOptions();
}
/*!
 * 	// Tab "General"
 */
void XYFitCurveDock::setupGeneral() {
    QWidget* generalTab = new QWidget(ui.tabGeneral);
    uiGeneralTab.setupUi(generalTab);
    QGridLayout* gridLayout = dynamic_cast<QGridLayout*>(generalTab->layout());
    if (gridLayout) {
        gridLayout->setContentsMargins(2,2,2,2);
        gridLayout->setHorizontalSpacing(2);
        gridLayout->setVerticalSpacing(2);
    }

    cbXDataColumn = new TreeViewComboBox(generalTab);
    gridLayout->addWidget(cbXDataColumn, 4, 4, 1, 2);

    cbYDataColumn = new TreeViewComboBox(generalTab);
    gridLayout->addWidget(cbYDataColumn, 5, 4, 1, 2);

    cbWeightsColumn = new TreeViewComboBox(generalTab);
    gridLayout->addWidget(cbWeightsColumn, 6, 4, 1, 2);

    uiGeneralTab.cbModel->addItem(i18n("Polynomial"));
    uiGeneralTab.cbModel->addItem(i18n("Power"));
    uiGeneralTab.cbModel->addItem(i18n("Exponential"));
    uiGeneralTab.cbModel->addItem(i18n("Inverse Exponential"));
    uiGeneralTab.cbModel->addItem(i18n("Fourier"));
    uiGeneralTab.cbModel->addItem(i18n("Gaussian"));
    uiGeneralTab.cbModel->addItem(i18n("Lorentz (Cauchy)"));
    uiGeneralTab.cbModel->addItem(i18n("Maxwell-Boltzmann"));
    uiGeneralTab.cbModel->addItem(i18n("Sigmoid"));
    uiGeneralTab.cbModel->addItem(i18n("Custom"));

    uiGeneralTab.teEquation->setMaximumHeight(uiGeneralTab.leName->sizeHint().height()*2);

    uiGeneralTab.tbConstants->setIcon( KIcon("labplot-format-text-symbol") );
    uiGeneralTab.tbFunctions->setIcon( KIcon("preferences-desktop-font") );
    uiGeneralTab.pbRecalculate->setIcon(KIcon("run-build"));

    QHBoxLayout* layout = new QHBoxLayout(ui.tabGeneral);
    layout->setMargin(0);
    layout->addWidget(generalTab);

    //Slots
    connect( uiGeneralTab.leName, SIGNAL(returnPressed()), this, SLOT(nameChanged()) );
    connect( uiGeneralTab.leComment, SIGNAL(returnPressed()), this, SLOT(commentChanged()) );
    connect( uiGeneralTab.chkVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) );

    connect( uiGeneralTab.cbModel, SIGNAL(currentIndexChanged(int)), this, SLOT(modelChanged(int)) );
    connect( uiGeneralTab.sbDegree, SIGNAL(valueChanged(int)), this, SLOT(updateModelEquation()) );
    connect( uiGeneralTab.teEquation, SIGNAL(expressionChanged()), this, SLOT(enableRecalculate()) );
    connect( uiGeneralTab.tbConstants, SIGNAL(clicked()), this, SLOT(showConstants()) );
    connect( uiGeneralTab.tbFunctions, SIGNAL(clicked()), this, SLOT(showFunctions()) );
    connect( uiGeneralTab.pbParameters, SIGNAL(clicked()), this, SLOT(showParameters()) );
    connect( uiGeneralTab.pbOptions, SIGNAL(clicked()), this, SLOT(showOptions()) );
    connect( uiGeneralTab.pbRecalculate, SIGNAL(clicked()), this, SLOT(recalculateClicked()) );
}
/// \brief Called when event loop is setup
void EventDispatcher::initFunction()
{
	if(core==NULL || copyEngineList==NULL)
	{
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"Unable to initialize correctly the software");
		return;
	}
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"Initialize the variable of event loop");
	connect(copyServer,	SIGNAL(newCopy(quint32,QStringList,QStringList)),			core,		SLOT(newCopy(quint32,QStringList,QStringList)));
	connect(copyServer,	SIGNAL(newCopy(quint32,QStringList,QStringList,QString,QString)),	core,		SLOT(newCopy(quint32,QStringList,QStringList,QString,QString)));
	connect(copyServer,	SIGNAL(newMove(quint32,QStringList,QStringList)),			core,		SLOT(newMove(quint32,QStringList,QStringList)));
	connect(copyServer,	SIGNAL(newMove(quint32,QStringList,QStringList,QString,QString)),	core,		SLOT(newMove(quint32,QStringList,QStringList,QString,QString)));
	connect(core,		SIGNAL(copyFinished(quint32,bool)),					copyServer,	SLOT(copyFinished(quint32,bool)));
	connect(core,		SIGNAL(copyCanceled(quint32)),						copyServer,	SLOT(copyCanceled(quint32)));
	if(localListener.tryConnect())
	{
		stopIt=true;
		//why before removed???
		QCoreApplication::quit();
		return;
	}
	localListener.listenServer();
	//load the systray icon
	if(backgroundIcon==NULL)
	{
		backgroundIcon=new SystrayIcon();
		//connect the slot
		//quit is for this object
//		connect(core,		SIGNAL(newCanDoOnlyCopy(bool)),					backgroundIcon,	SLOT(newCanDoOnlyCopy(bool)));
		connect(backgroundIcon,	SIGNAL(quit()),this,SLOT(quit()));
		//show option is for OptionEngine object
		connect(backgroundIcon,	SIGNAL(showOptions()),						&optionDialog,	SLOT(show()));
		connect(copyServer,	SIGNAL(listenerReady(ListeningState,bool,bool)),		backgroundIcon,	SLOT(listenerReady(ListeningState,bool,bool)));
		connect(copyServer,	SIGNAL(pluginLoaderReady(CatchState,bool,bool)),		backgroundIcon,	SLOT(pluginLoaderReady(CatchState,bool,bool)));
		connect(backgroundIcon,	SIGNAL(tryCatchCopy()),						copyServer,	SLOT(listen()));
		connect(backgroundIcon,	SIGNAL(tryUncatchCopy()),					copyServer,	SLOT(close()));
		if(options->getOptionValue("CopyListener","CatchCopyAsDefault").toBool())
			copyServer->listen();
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"copyServer.oneListenerIsLoaded(): "+QString::number(copyServer->oneListenerIsLoaded()));
		//backgroundIcon->readyToListen(copyServer.oneListenerIsLoaded());

		connect(backgroundIcon,	SIGNAL(addWindowCopyMove(CopyMode,QString)),				core,		SLOT(addWindowCopyMove(CopyMode,QString)));
		connect(backgroundIcon,	SIGNAL(addWindowTransfer(QString)),					core,		SLOT(addWindowTransfer(QString)));
		connect(copyEngineList,	SIGNAL(addCopyEngine(QString,bool)),					backgroundIcon,	SLOT(addCopyEngine(QString,bool)));
		connect(copyEngineList,	SIGNAL(removeCopyEngine(QString)),					backgroundIcon,	SLOT(removeCopyEngine(QString)));
		copyEngineList->setIsConnected();
		copyServer->resendState();
	}
	//conntect the last chance signal before quit
	connect(QCoreApplication::instance(),SIGNAL(aboutToQuit()),this,SLOT(quit()));
	//connect the slot for the help dialog
	connect(backgroundIcon,SIGNAL(showHelp()),&theHelp,SLOT(show()));
}
/**
 * Constructor.
 */
RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer& container,
        RS_GraphicView& graphicView)
    :RS_ActionInterface("Print Preview",
                        container, graphicView)
    , hasOptions(false)
    , scaleFixed(false)
    , m_bPaperOffset(false)
    , pPoints(new Points{})
{
    showOptions();
    actionType=RS2::ActionFilePrintPreview;
}
Exemple #14
0
MenuBar::MenuBar()
{
    init();
    
    connect(newPlaylist, SIGNAL(triggered()), this, SLOT(createNewPlaylist()));
    connect(openFile, SIGNAL(triggered()), this, SLOT(open()));
    connect(delPlaylist, SIGNAL(triggered()), this, SLOT(deletePlaylist()));
    connect(close, SIGNAL(triggered()), this, SLOT(quit()));
    connect(optionsAction, SIGNAL(triggered()), this, SLOT(showOptions()));
    connect(playlistEditAction, SIGNAL(triggered()), this, SLOT(showPlaylistEditor()));
    connect(about, SIGNAL(triggered()), this, SLOT(aboutDialog()));
}
Exemple #15
0
/**
 * Save settings and emit a signal to open options.
 * Occurs when the Setup Button is hit.
 */
void Login::setupButtonClicked(){
  QString selected = aolName->currentText();
	
  i_aimSettings->login_enable_save = save->isChecked();
  i_aimSettings->login_enable_auto = autoLogin->isChecked();
	
  if( setup::instance()->isRegisteredUser(selected) ){
    i_aimSettings->login_name = selected;
  } else {
    i_aimSettings->login_name = "";
  }
  emit (showOptions());
} 
LRESULT ModelTreeDialog::doToggleOptions(void)
{
	if (m_optionsShown)
	{
		hideOptions();
	}
	else
	{
		showOptions();
	}
	TCUserDefaults::setBoolForKey(m_optionsShown, MODEL_TREE_OPTIONS_SHOWN_KEY,
		false);
	return 0;
}
Exemple #17
0
void LightscreenWindow::showHotkeyError(const QStringList &hotkeys)
{
    static bool dontShow = false;

    if (dontShow) {
        return;
    }

    QString messageText;

    messageText = tr("Some hotkeys could not be registered, they might already be in use");

    if (hotkeys.count() > 1) {
        messageText += tr("<br>The failed hotkeys are the following:") + "<ul>";

        for (auto hotkey : hotkeys) {
            messageText += QString("%1%2%3").arg("<li><b>").arg(hotkey).arg("</b></li>");
        }

        messageText += "</ul>";
    } else {
        messageText += tr("<br>The failed hotkey is <b>%1</b>").arg(hotkeys[0]);
    }

    messageText += tr("<br><i>What do you want to do?</i>");

    QMessageBox msgBox(this);
    msgBox.setWindowTitle(tr("Lightscreen"));
    msgBox.setText(messageText);

    QPushButton *changeButton  = msgBox.addButton(tr("Change") , QMessageBox::ActionRole);
    QPushButton *disableButton = msgBox.addButton(tr("Disable"), QMessageBox::ActionRole);
    QPushButton *exitButton    = msgBox.addButton(tr("Quit")   , QMessageBox::ActionRole);

    msgBox.exec();

    if (msgBox.clickedButton() == exitButton) {
        dontShow = true;
        QTimer::singleShot(10, this, SLOT(quit()));
    } else if (msgBox.clickedButton() == changeButton) {
        showOptions();
    } else if (msgBox.clickedButton() == disableButton) {
        for (auto hotkey : hotkeys) {
            settings()->setValue(QString("actions/%1/enabled").arg(hotkey), false);
        }
    }
}
Exemple #18
0
void KJumpingCube::initKAction() {
  KStdGameAction::gameNew(this, SLOT(newGame()), actionCollection());
  KStdGameAction::load(this, SLOT(openGame()), actionCollection());
  KStdGameAction::save(this, SLOT(save()), actionCollection());
  KStdGameAction::saveAs(this, SLOT(saveAs()), actionCollection());
  KStdGameAction::quit(this, SLOT(close()), actionCollection());

  hintAction = KStdGameAction::hint(view, SLOT(getHint()), actionCollection());
  stopAction = new KAction(i18n("Stop &Thinking"), "stop",
  Qt::Key_Escape, this, SLOT(stop()), actionCollection(), "game_stop");
  stopAction->setEnabled(false);
  undoAction = KStdGameAction::undo(this, SLOT(undo()), actionCollection());
  undoAction->setEnabled(false);
  KStdAction::preferences(this, SLOT(showOptions()), actionCollection());

  setupGUI();
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: eventChanged((*reinterpret_cast< AGSEventType(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 1: newFile(); break;
        case 2: openFile(); break;
        case 3: closeFile(); break;
        case 4: exportFile(); break;
        case 5: importToDatabase(); break;
        case 6: loadFile((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 7: openRecentFile(); break;
        case 8: showOptions(); break;
        case 9: updateTime(); break;
        case 10: lookupAGS_ID(); break;
        case 11: lookupPCC_ID(); break;
        case 12: lookupPCC_ID((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 13: setEventTypeID((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 14: setEvent((*reinterpret_cast< AGSEventType(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 15: setLogoutTime(); break;
        case 16: setLogoutTime((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 17: setTShirtCalc((*reinterpret_cast< double(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 18: setTimer((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 19: setTimer((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 20: boo(); break;
        case 21: showError((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 22: login(); break;
        case 23: logout(); break;
        case 24: about(); break;
        case 25: tutorial(); break;
        case 26: reportABug(); break;
        case 27: testConnection(); break;
        case 28: { QString _r = generateHeader();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 29: rewriteHeader(); break;
        default: ;
        }
        _id -= 30;
    }
    return _id;
}
MainDialog::MainDialog(Slave * s, QWidget * parent)
: QDialog( parent )
, mSlave( s )
, mTrayIcon( 0 )
, mTrayMenu( 0 )
, mTrayMenuToggleAction( 0 )
, mBringToTop( true )
{
	setupUi(this);
	readConfig();

	connect( mSlave, SIGNAL( statusChange( const QString & ) ), SLOT( setStatus( const QString & ) ) );

	mActiveAssignmentsGroup->hide();

	QImage tray_image( ":images/"+cAppName+"Icon.png" );
	mTrayMenu = new QMenu( this );
	mTrayMenuToggleAction = mTrayMenu->addAction( QString( start ), this, SLOT( slotDisablePressed() ) );
	mTrayMenu->addAction( "Exit "+cAppName, qApp, SLOT( quit() ) );

	if( !tray_image.isNull() ) {
		QIcon tray_icon( QPixmap::fromImage( tray_image.scaled( 20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ) );
		mTrayIcon = new QSystemTrayIcon( tray_icon, this );
		mTrayIcon->setContextMenu( mTrayMenu );
		connect( mTrayIcon, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
			SLOT( slotTrayIconActivated( QSystemTrayIcon::ActivationReason ) ) );
		mTrayIcon->show();
	}
	QString logo_image( ":images/"+cAppName+"Logo.png" );
	mImageLabel->setPixmap(QPixmap(logo_image));

	connect( mAFButton, SIGNAL( clicked() ), SLOT( showAssfreezer() ) );
	connect( OptionsButton, SIGNAL( clicked() ), SLOT( showOptions() ) );
	connect( ClientLogButton, SIGNAL( clicked() ), SLOT( showClientLog() ) );
	connect( mShowAssignmentsButton, SIGNAL( toggled( bool ) ), SLOT( slotShowAssignments( bool ) ) );
	connect( DisableButton, SIGNAL( clicked() ), SLOT( slotDisablePressed() ) );
	
	setWindowFlags( Qt::Window | Qt::MSWindowsFixedSizeDialogHint );
	setAttribute( Qt::WA_QuitOnClose, true );

	layout()->setSizeConstraint(QLayout::SetFixedSize);
}
Exemple #21
0
MapBox::MapBox(MainWindow * parent) :
    QWidget(parent),
    m_qgv(0),
    m_scene(0),
    m_mapWidget(0),
    m_serviceProvider(0),
    m_mapManager(0),
    m_connectivityMode(QGraphicsGeoMap::HybridMode),
    m_popupMenu(0),
    m_popupMenuMapObject(0),
    m_displayMode(DisplayNone),
    m_optionsWidget(0)
{
    for (QVariantHash::const_iterator it = parent->programOptions().begin(); it != parent->programOptions().end(); ++it)
    {
        m_parameters.insert(it.key(), it.value());
    }

    m_scene = new QGraphicsScene(this);

    m_qgv = new QGraphicsView(m_scene, this);
    m_qgv->setOptimizationFlag(QGraphicsView::IndirectPainting, true);
    m_qgv->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_qgv->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_qgv->setFrameShape(QFrame::NoFrame);

    m_optionsButton = new QPushButton("Options", m_qgv);
    m_optionsButton->resize(m_optionsButton->sizeHint());
    connect(m_optionsButton, SIGNAL(clicked()), this, SLOT(showOptions()));

    QVBoxLayout * layout = new QVBoxLayout(this);
    layout->setMargin(0);
    setLayout(layout);
    setDisplayMode(DisplayMap);

    createDialogs();
    createPixmapIcon();
}
Exemple #22
0
/* Main function */
int main (int argc, char *argv[]) {
	/* Control Variables */
	char op, isbn[11], pwd[50], qtt[4];

	/* With the connection done, read to send requests to the server */
	int sockfd;
	struct sockaddr_in server;
	char message[1000] , server_reply[2000];
	struct timeval tv;

	tv.tv_sec = 5;  /* 30 Secs Timeout */
	tv.tv_usec = 0;  // Not init'ing this can cause strange errors

	sockfd = socket(AF_INET , SOCK_STREAM , 0);

	//Create socket
	if (sockfd == -1)
	{
		printf("Could not create socket");
	}
	puts("Socket created");
	setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));


	server.sin_addr.s_addr = inet_addr("127.0.0.1");
//	server.sin_addr.s_addr = inet_addr("187.106.45.71");
//	server.sin_addr.s_addr = inet_addr("143.106.174.65");
	server.sin_family = AF_INET;
	server.sin_port = htons( 8888 );

	//Connect to remote server
	if (connect(sockfd , (struct sockaddr *)&server , sizeof(server)) < 0)
	{
		perror("connect failed. Error");
		return 1;
	}
	while(1) {
		showOptions();	// Explains the options to the User

		scanf(" %c", &op);	// Take the option from user
		//printf("\n");
//		printf("\n--------\n%c\n--------\n",op);
		switch(op) {
			case 'h':	// A little help
				break;
			case 'l':	// Looking at the Store
				if( dataFetch(sockfd, NULL, "1") < 0)
					printf("PROBLEMS!!!!!!!\n");
				break;
			case 'd':	// Searching for Description
				printf("Waiting for ISBN of the Book!\n");
				scanf(" %s", isbn);	// Getting ISBN

				/* Calling the fetching result function */
				dataFetch(sockfd, isbn, "2");
				break;
			case 'i':	// Searching for Info
				printf("Waiting for ISBN of the Book!\n");
				scanf(" %s", isbn);	// Getting ISBN

				/* Calling the fetching result function  */
				printf("%d",dataFetch(sockfd, isbn, "3"));
				break;
//			case 'a':	// All Infos
//				/* Calling the fetching result function  */
//				listAllInfos(sockfd);
//				break;
			case 'a':	// All Infos
				/* Calling the fetching result function  */
				if( dataFetch(sockfd, NULL, "4") < 0)
					printf("PROBLEMS!!!!!!!\n");
				break;
			case 'c':	// Changing the stores numbers
//				printf("Enter the Library Password:"******"%s", pwd);
//				if (!autenticate(pwd)) {
//					printf("Wrong password! \
//						Access Denied!\n");

				printf("Waiting for the new stock amount!\n");
				scanf(" %s", qtt);	// Getting Quantity
				printf("Waiting for ISBN of the Book!\n");
				scanf(" %s", isbn);	// Getting ISBN
				alterStock(sockfd, isbn, qtt);
				break;
//				}

//				changeStocks(sockfd);
//				break;
//			case 'n':	// Numbers on stock
//				printf("Waiting for ISBN of the Book!\n");
//				scanf("%s", isbn);	// Getting ISBN

				/* Calling the stocks numbers */
//				reportNumbers(sockfd, isbn);
			case 'n':	// Numbers on stock
				printf("Waiting for ISBN of the Book!\n");
				scanf("%s", isbn);	// Getting ISBN

				/* Calling the stocks numbers */
				dataFetch(sockfd, isbn, "6");
				break;
			case 'p':
				printf("Digite a senha para cliente livraria...\n");
				scanf(" %s", pwd);
				pass(sockfd, pwd);
				break;
			case 'q':	// Quiting the program!
				printf("Quiting now!\n");
				break;
			default:	// Unknow command
				printf("Bad instruction, try again!\n");
				break;
		} /* End Switch */

		if (op == 'q')
			break;

	}
	
	close(sockfd);
	return 0;	// Terminating program

}
Exemple #23
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    EdamProtocol *edam = EdamProtocol::GetInstance();

    ui->setupUi(this);

    pdfCache * pdf = new pdfCache(this);

    CustomNetworkAccessManager *nm = new CustomNetworkAccessManager(ui->editor->page()->networkAccessManager(), this, pdf);
    edam->setCNAM(nm);
    ui->editor->page()->setNetworkAccessManager(nm);

    Speller::setSettings(new DBSpellSettings(this, ui->editor));

    ui->editor->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->editor->load(QUrl("qrc:///html/noteajax.html"));

    jsB = new jsBridge(this, pdf);
    jsB->setWebView(ui->editor);
    enmlWritter = new enml2(this);

    connect(ui->editor->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJSObject()));

    loaded = false;
    editingEnabled = false;


    tagsActions = new QActionGroup(this);
    newTag = new TagLabel(this);
    newTag->hide();
    ui->tagsBar->addWidget(newTag);

    appIcon = QIcon(":img/hippo64.png");

    trayIcon = NULL;

    bool sysTrayEnabled = sql::readSyncStatus("systemTray", true).toBool();

    if (QSystemTrayIcon::isSystemTrayAvailable() && sysTrayEnabled)
        enableSystemTrayIcon(true);

    connect(edam, SIGNAL(AuthenticateFailed()), this, SLOT(authentificationFailed()));
    connect(edam, SIGNAL(syncFinished()), this, SLOT(syncFinished()));
    connect(edam, SIGNAL(syncStarted(int)), this, SLOT(syncStarted(int)));
    connect(edam, SIGNAL(noteGuidChanged(QString,QString)), this, SLOT(changeNoteGuid(QString,QString)));
    connect(ui->notebooks, SIGNAL(itemSelectionChanged()), this, SLOT(switchNotebook()));
    connect(ui->tags, SIGNAL(itemSelectionChanged()), this, SLOT(switchTag()));
    connect(ui->tags, SIGNAL(tagAdded(QString,QString)), this, SLOT(addTag(QString,QString)));
    connect(ui->tags, SIGNAL(tagsUpdated()), this, SLOT(updateTagsToolBar()));
    connect(ui->tags, SIGNAL(tagsUpdated()), this, SLOT(switchTag()));
    connect(ui->NotesList, SIGNAL(noteSwitched()), this, SLOT(switchNote()));
    connect(ui->action_Abaut, SIGNAL(triggered()), this, SLOT(loadAboutInfo()));
    connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeWindow()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionSync, SIGNAL(triggered()), this, SLOT(sync()));
    connect(ui->noteTitle, SIGNAL(textEdited(QString)), this, SLOT(noteTitleChange(QString)));
    connect(ui->actionAccount_info, SIGNAL(triggered()), this, SLOT(showUserInfo()));
    connect(ui->editor->page(), SIGNAL(linkClicked(QUrl)), this, SLOT(openURL(QUrl)));
    connect(ui->editor->page(), SIGNAL(microFocusChanged()), this, SLOT(updateEditButtonsState()));
    connect(ui->editor, SIGNAL(selectionChanged()), this, SLOT(updateSelectionButtonsState()));
    connect(ui->editor->page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
    connect(ui->editor, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(editorContextMenuRequested(QPoint)));
    connect(ui->editor, SIGNAL(fileInserted(QString)), this, SLOT(insertFile(QString)));
    connect(ui->notebooks, SIGNAL(noteMoved(QString,QString)), this, SLOT(moveNote(QString,QString)));
    connect(ui->notebooks, SIGNAL(noteDeleted(QString)), this, SLOT(deleteNote(QString)));
    connect(ui->notebooks, SIGNAL(noteRestored(QString,QString)), this, SLOT(restoreNote(QString,QString)));
    connect(ui->NotesList, SIGNAL(noteDeleted(QString)), this, SLOT(deleteNote(QString)));
    connect(ui->NotesList, SIGNAL(noteRestored(QString)), this, SLOT(restoreNote(QString)));
    connect(ui->NotesList, SIGNAL(noteCreated()), this, SLOT(newNote()));
    connect(ui->NotesList, SIGNAL(reloaded()), this, SLOT(updateCurrentNoteName()));
    connect(ui->editButton, SIGNAL(toggled(bool)), this, SLOT(setEditable(bool)));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->toolBox, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
    connect(ui->editor->page(), SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(linkHovered(QString,QString,QString)));
    connect(jsB, SIGNAL(hintMessage(QString,int)), ui->statusbar, SLOT(showMessage(QString,int)));
    connect(jsB, SIGNAL(noteChanged(QString)), this, SLOT(updateTagsToolBar(QString)));
    connect(jsB, SIGNAL(activeNoteSelectionChanged(bool)), ui->actionDelete_Note, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(activeNoteSelectionChanged(bool)), ui->editButton, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(editingStarted(bool)), ui->editButton, SLOT(setChecked(bool)));
    connect(jsB, SIGNAL(titleUpdated(QString,QString)), this, SLOT(updateNoteTitle(QString,QString)));
    connect(jsB, SIGNAL(conflictAdded(qint64,QString,bool)), this, SLOT(addConflict(qint64,QString,bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionNote_Info, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionExport, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionPrint, SLOT(setEnabled(bool)));
    connect(ui->editor, SIGNAL(tagUpdated(QString,bool)), this, SLOT(updateTag(QString,bool)));
    connect(tagsActions, SIGNAL(triggered(QAction*)), this, SLOT(tagClicked(QAction*)));
    connect(newTag, SIGNAL(tagCreated(QString)), this, SLOT(createTag(QString)));
    connect(ui->actionKeep_only_this_Version, SIGNAL(triggered()), this, SLOT(keepThisVersion()));
    connect(ui->actionNote_Info, SIGNAL(triggered()), this, SLOT(showNoteInfo()));
    connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(exportNote()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(this, SIGNAL(titleChanged(QString,QString)), jsB, SIGNAL(titleChanged(QString,QString)));


    setWindowIcon(appIcon);
    setWindowTitle("Hippo Notes");

    setTabOrder(ui->noteTitle, ui->editor);

    ui->notebooks->setSortingEnabled(true);
    ui->notebooks->sortByColumn(0, Qt::AscendingOrder);
    ui->editBar->setVisible(false);

    ui->mainToolBar->addAction(ui->actionNew_Note);
    ui->mainToolBar->addAction(ui->actionSync);

    QFontComboBox *font = new QFontComboBox(this);
    font->setDisabled(true);
    font->setFontFilters(QFontComboBox::ScalableFonts);
    font->setEditable(false);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), font, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(updateFont(QFont)), font, SLOT(setCurrentFont(QFont)));
    connect(font, SIGNAL(activated(QString)), this, SLOT(changeFont(QString)));
    ui->editBar->addWidget(font);

    QComboBox *fontSize = new QComboBox(this);
    fontSize->setDisabled(true);
    fontSize->setEditable(false);
    for (int i = 1; i <= 7; i++)
        fontSize->addItem(QString::number(i));
    connect(this, SIGNAL(editButtonsStateChanged(bool)), fontSize, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(updateFontSize(int)), fontSize, SLOT(setCurrentIndex(int)));
    connect(fontSize, SIGNAL(activated(QString)), this, SLOT(changeFontSize(QString)));
    ui->editBar->addWidget(fontSize);

    QAction *boldIco = ui->editor->pageAction(QWebPage::ToggleBold);
    boldIco->setIcon(QIcon::fromTheme("format-text-bold"));
    ui->editBar->addAction(boldIco);

    QAction *italicIco = ui->editor->pageAction(QWebPage::ToggleItalic);
    italicIco->setIcon(QIcon::fromTheme("format-text-italic"));
    ui->editBar->addAction(italicIco);

    QAction *underlineIco = ui->editor->pageAction(QWebPage::ToggleUnderline);
    underlineIco->setIcon(QIcon::fromTheme("format-text-underline"));
    ui->editBar->addAction(underlineIco);

    QAction *strikethroughIco = ui->editor->pageAction(QWebPage::ToggleStrikethrough);
    strikethroughIco->setIcon(QIcon::fromTheme("format-text-strikethrough"));
    ui->editBar->addAction(strikethroughIco);

    ui->editBar->addSeparator();

    QAction *undoIco = ui->editor->pageAction(QWebPage::Undo);
    undoIco->setIcon(QIcon::fromTheme("edit-undo"));
    undoIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
    ui->editBar->addAction(undoIco);
    ui->menu_Edit->addAction(undoIco);

    QAction *redoIco = ui->editor->pageAction(QWebPage::Redo);
    redoIco->setIcon(QIcon::fromTheme("edit-redo"));
    redoIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z));
    ui->editBar->addAction(redoIco);
    ui->menu_Edit->addAction(redoIco);

    ui->editBar->addSeparator();

    QAction *rformatIco = ui->editor->pageAction(QWebPage::RemoveFormat);
    rformatIco->setIcon(QIcon::fromTheme("edit-clear"));
    ui->editBar->addAction(rformatIco);

    ui->editBar->addSeparator();

    QAction *leftIco = ui->editor->pageAction(QWebPage::AlignLeft);
    leftIco->setIcon(QIcon::fromTheme("format-justify-left"));
    ui->editBar->addAction(leftIco);

    QAction *centerIco = ui->editor->pageAction(QWebPage::AlignCenter);
    centerIco->setIcon(QIcon::fromTheme("format-justify-center"));
    ui->editBar->addAction(centerIco);

    QAction *rightIco = ui->editor->pageAction(QWebPage::AlignRight);
    rightIco->setIcon(QIcon::fromTheme("format-justify-right"));
    ui->editBar->addAction(rightIco);

    QAction *fillIco = ui->editor->pageAction(QWebPage::AlignJustified);
    fillIco->setIcon(QIcon::fromTheme("format-justify-fill"));
    ui->editBar->addAction(fillIco);

    ui->editBar->addSeparator();

    QAction *indentIco = ui->editor->pageAction(QWebPage::Indent);
    indentIco->setIcon(QIcon::fromTheme("format-indent-more"));
    ui->editBar->addAction(indentIco);

    QAction *outdentIco = ui->editor->pageAction(QWebPage::Outdent);
    outdentIco->setIcon(QIcon::fromTheme("format-indent-less"));
    ui->editBar->addAction(outdentIco);

    QAction *superscriptIco = ui->editor->pageAction(QWebPage::ToggleSuperscript);
    superscriptIco->setIcon(QIcon::fromTheme("format-text-superscript"));
    ui->editBar->addAction(superscriptIco);

    QAction *subscriptIco = ui->editor->pageAction(QWebPage::ToggleSubscript);
    subscriptIco->setIcon(QIcon::fromTheme("format-text-subscript"));
    ui->editBar->addAction(subscriptIco);

    QAction *unorderedIco = ui->editor->pageAction(QWebPage::InsertUnorderedList);
    unorderedIco->setIcon(QIcon::fromTheme("format-list-unordered"));
    ui->editBar->addAction(unorderedIco);

    QAction *orderedIco = ui->editor->pageAction(QWebPage::InsertOrderedList);
    orderedIco->setIcon(QIcon::fromTheme("format-list-ordered"));
    ui->editBar->addAction(orderedIco);

    QAction *lineIco = new QAction("Insert horizontal line", this);
    lineIco->setIcon(QIcon::fromTheme("insert-horizontal-rule"));
    lineIco->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), lineIco, SLOT(setEnabled(bool)));
    connect(lineIco, SIGNAL(triggered()), this, SLOT(insertHorizontalLine()));
    ui->editBar->addAction(lineIco);

    ui->menu_Edit->addSeparator();

    QAction *cutIco = ui->editor->pageAction(QWebPage::Cut);
    cutIco->setIcon(QIcon::fromTheme("edit-cut"));
    cutIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X));
    ui->menu_Edit->addAction(cutIco);

    QAction *copyIco = ui->editor->pageAction(QWebPage::Copy);
    copyIco->setIcon(QIcon::fromTheme("edit-copy"));
    copyIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
    ui->menu_Edit->addAction(copyIco);

    QAction *pasteIco = ui->editor->pageAction(QWebPage::Paste);
    pasteIco->setIcon(QIcon::fromTheme("edit-paste"));
    pasteIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
    ui->menu_Edit->addAction(pasteIco);

    QAction *pasteSpecialIco = ui->editor->pageAction(QWebPage::PasteAndMatchStyle);
    pasteSpecialIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
    ui->menu_Edit->addAction(pasteSpecialIco);

    ui->menu_Edit->addSeparator();

    QAction *insertUrlIco = new QAction("Create link", this);
    insertUrlIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
    insertUrlIco->setDisabled(true);
    insertUrlIco->setIcon(QIcon::fromTheme("insert-link"));
    connect(this, SIGNAL(selectionButtonsStateChanged(bool)), insertUrlIco, SLOT(setDisabled(bool)));
    connect(insertUrlIco, SIGNAL(triggered()), this, SLOT(insertUrl()));
    ui->menu_Edit->addAction(insertUrlIco);

    QAction *todoIco = new QAction("Insert To-do Checkbox", this);
    todoIco->setIcon(QIcon::fromTheme("checkbox"));
    todoIco->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), todoIco, SLOT(setEnabled(bool)));
    connect(todoIco, SIGNAL(triggered()), jsB, SIGNAL(insertToDo()));
    ui->menu_Edit->addAction(todoIco);

    QAction *insertImage = new QAction("Insert Image", this);
    insertImage->setIcon(QIcon::fromTheme("insert-image"));
    insertImage->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), insertImage, SLOT(setEnabled(bool)));
    connect(insertImage, SIGNAL(triggered()), this, SLOT(insertImg()));
    ui->menu_Edit->addAction(insertImage);

    QAction *insertFile = new QAction("Insert File", this);
    insertFile->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), insertFile, SLOT(setEnabled(bool)));
    connect(insertFile, SIGNAL(triggered()), this, SLOT(insertFile()));
    ui->menu_Edit->addAction(insertFile);

    QAction *encryptIco = new QAction("Encrypt Selected Text...", this);
    encryptIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_X));
    encryptIco->setDisabled(true);
    encryptIco->setIcon(QIcon::fromTheme("document-edit-encrypt"));
    connect(this, SIGNAL(selectionButtonsStateChanged(bool)), encryptIco, SLOT(setDisabled(bool)));
    connect(encryptIco, SIGNAL(triggered()), jsB, SIGNAL(encryptText()));
    ui->menu_Edit->addAction(encryptIco);

    ui->menu_Edit->addSeparator();

    QAction *options = new QAction("&Options...", this);
    options->setIcon(QIcon::fromTheme("preferences-other"));
    connect(options, SIGNAL(triggered()), this, SLOT(showOptions()));
    ui->menu_Edit->addAction(options);


    clearConflictBar();
    connect(jsB, SIGNAL(showConflict()), ui->conflictBar, SLOT(show()));
    connect(jsB, SIGNAL(showConflict()), ui->conflictBarBottom, SLOT(show()));

    conflictsGroup = new QActionGroup(this);
    connect(conflictsGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeNoteVersion(QAction*)));

    searchIndex = new SearchIndex(this);
    connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(search()));
    connect(edam, SIGNAL(syncFinished()), searchIndex, SLOT(buildSearchIndex()));
    connect(jsB, SIGNAL(noteUpdated(QString)), searchIndex, SLOT(updateNoteIndex(QString)));
    connect(edam, SIGNAL(noteUpdated(QString)), searchIndex, SLOT(dropNoteIndex(QString)));
    connect(ui->searchInput, SIGNAL(returnPressed()), this, SLOT(search()));

    QByteArray mainWindowGeometry = sql::readSyncStatus("mainWindowGeometry").toString().toLatin1();
    if (!mainWindowGeometry.isEmpty())
        restoreGeometry(QByteArray::fromBase64(mainWindowGeometry));

    QByteArray mainWidgetsSplitterState = sql::readSyncStatus("mainWidgetsSplitterState").toString().toLatin1();
    if (!mainWidgetsSplitterState.isEmpty())
        ui->mainWidgetsSplitter->restoreState(QByteArray::fromBase64(mainWidgetsSplitterState));

    //showWindow();
    edam->init();
}
Exemple #24
0
//////////////////////////////////////////////////////////////
/// \brief QQCmdToolButtons::optionsButtonClicked
///
void QQCmdToolButtons::optionsButtonClicked()
{
	emit showOptions();
}
Exemple #25
0
Home::Home(QWidget *parent) :  QBookForm(parent),
          m_category1(0)
        , m_category2(0)
        , m_category3(0)
        , memoryCategory1List(0)
        , memoryCategory2List(0)
        , memoryCategory3List(0)
        , b_isMostRecentFromSD(false)
      {
        setupUi(this);

        connect(libraryBtn,     SIGNAL(clicked()), this, SLOT(goToLibrary()));
        connect(helpBtn,        SIGNAL(clicked()), this, SLOT(goToHelp()));
        connect(searchBtn,      SIGNAL(clicked()), this, SLOT(goToSearch()));
        connect(settingsBtn,    SIGNAL(clicked()), this, SLOT(goToSettings()));
        connect(showAllBtn,     SIGNAL(clicked()), this, SLOT(viewAll()));
        connect(recommendedBtn, SIGNAL(clicked()), this, SLOT(showOptions()));

    #ifndef HACKERS_EDITION
        connect(storeBtn,       SIGNAL(clicked()), QBookApp::instance(),SLOT(goToShop()));
    #endif
        connect(readBookBtn, SIGNAL(clicked()), this, SLOT(openMostRecentBook()));

        QFile fileSpecific(":/res/home_styles.qss");
        QFile fileCommons(":/res/home_styles_generic.qss");
        fileSpecific.open(QFile::ReadOnly);
        fileCommons.open(QFile::ReadOnly);

        QString styles = QLatin1String(fileSpecific.readAll() + fileCommons.readAll());
        setStyleSheet(styles);

        if(QBook::getInstance()->getResolution() == QBook::RES600x800){
            defaultHelpBook = new BookInfo(QString(USERGUIDEPATH) + "/userGuideTouch_" + QBook::settings().value("setting/language", QVariant("es")).toString()+ ".epub");
        }else{ //We do it to preserve back compatibility
            defaultHelpBook = new BookInfo(QString(USERGUIDEPATH) + "/userGuide_" + QBook::settings().value("setting/language", QVariant("es")).toString()+ ".pdf");

        }

        defaultHelpBook->title = tr("Guia de Ayuda");
        defaultHelpBook->thumbnail = ":/res/unknow_book.png";
        defaultHelpBook->fontSize = 1; //Optimal to show images

        homeBooksListOptions = new HomeBooksListOptions(this);
        connect(homeBooksListOptions, SIGNAL(viewSelected(Home::VIEW)), this, SLOT(viewSelected(Home::VIEW)));
        connect(homeBooksListOptions, SIGNAL(hideMe()), this, SLOT(showOptions()));
        connect(homeBooksList, SIGNAL(openBook(const BookInfo*)), this, SLOT(openBook(const BookInfo*)));

#ifndef HACKERS_EDITION
        memoryCategory1List = new bqDeviceServicesCategoryObject();
        memoryCategory2List = new bqDeviceServicesCategoryObject();
        memoryCategory3List = new bqDeviceServicesCategoryObject();
        m_category1 = new bqDeviceServicesCategoryObject();
        m_category2 = new bqDeviceServicesCategoryObject();
        m_category3 = new bqDeviceServicesCategoryObject();
#endif
        bookAccessLbl->hide();
        numberAccessLbl->hide();
        subscriptionTagLbl->hide();

        currentView = Home::RECENT;
}
Exemple #26
0
                feature_flow_image_label,
                SLOT(setVisible(bool)),
                "Show/Hide image with sparse feature flow (arrows).",
                true);

    //Settings Menu
    QMenu *st = menuBar()->addMenu(tr("&Settings"));

    newMenuItem(st, "&Reload Config",
                SLOT(reloadConfig()),
                "Reload Configuration from Parameter Server.",
                "",
                QIcon::fromTheme("reload"));

    newMenuItem(st, "&View Current Settings",
                SLOT(showOptions()),
                "Display the currently active options",
                "?");
                
    newMenuItem(st, "Set internal &Parameter",
                SLOT(setParam()),
                "Change a parameter (This will also change the value on the ROS Parameter server)");
                
    newMenuItem(st, "Set Ma&ximum Edge Error",
                SLOT(pruneEdgesWithHighError()),
                "Set the maximum allowed for edges (reoptimize to see the effect)",
                "Ctrl+X");
                
    //Help Menu
    QMenu *hm= menuBar()->addMenu(tr("&Help"));
void RS_ActionPrintPreview::resume() {
    RS_ActionInterface::resume();
    showOptions();
}
void RS_ActionPrintPreview::init(int status) {
    RS_ActionInterface::init(status);
    showOptions();
}
Exemple #29
0
/* Main function */
int main (int argc, char *argv[]) {
	/* Control Variables */
	char op, isbn[11], pwd[50], qtt[4], sIP[20];

	/* With the connection done, read to send requests to the server */
	int sockfd;
	struct addrinfo hints, *servinfo, *tmp;
	char message[1000] , server_reply[2000];
	struct timeval tv;

	tv.tv_sec = 5;  /* 30 Secs Timeout */
	tv.tv_usec = 0;  // Not init'ing this can cause strange errors


	/* Defining the IP */
	if (argv[1] == NULL)	strcpy(sIP, SERVIP);		/* Default */
	else if (argv[1]=="0")	strcpy(sIP, "127.0.0.1");	/* Host */
	else 			strcpy(sIP, argv[1]);		/* Passed */

	/* Setting hints to get the list of addrinfo struct */
	memset(&hints, 0, sizeof hints);
	hints.ai_family = AF_UNSPEC;	/* Any kind of IP */
	hints.ai_socktype = SOCK_DGRAM;	/* UDP */


	/* Create the list of structs */
	if (getaddrinfo (sIP,MYPORT, &hints, &servinfo) != 0) {
		printf("Erro na alocacao de Enderecos!\n");
		return -1;
	}

	/* Take the first of the addrinfo inside the list */
	for (tmp = servinfo; tmp != NULL; tmp = tmp->ai_next) {
		/* Get the Socket Descriptor */
		if ((sockfd = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol)) == -1 ) {
			printf("Error on socket creation! Trying next address struct!\n");
			continue;
		}
		break;
	}

	if (tmp == NULL) {
		printf("Falha ao criar sockets! Abortando!\n");
		return -2;
	}


	/* Start the loop of requests to the server! */
	while(1) {
		showOptions();	// Explains the options to the User

		scanf(" %c", &op);	// Take the option from user


		switch(op) {
			case 'h':	// A little help
				break;


			case 'l':	// Looking at the Store
				if( dataFetch(sockfd, NULL, "1", tmp) < 0)
					printf("PROBLEMS!!!!!!!\n");
				break;


			case 'd':	// Searching for Description
				printf("Waiting for ISBN of the Book!\n");
				scanf(" %s", isbn);	// Getting ISBN

				/* Calling the fetching result function */
				dataFetch(sockfd, isbn, "2", tmp);
				break;


			case 'i':	// Searching for Info
				printf("Waiting for ISBN of the Book!\n");
				scanf(" %s", isbn);	// Getting ISBN

				/* Calling the fetching result function  */
				printf("%d",dataFetch(sockfd, isbn, "3", tmp));
				break;


			case 'a':	// All Infos
					/* Calling the fetching result function  */
				if( dataFetch(sockfd, NULL, "4", tmp) < 0)
					printf("PROBLEMS!!!!!!!\n");
				break;


			case 'c':	// Changing the stores numbers
				printf("Waiting for the new stock amount!\n");
				scanf(" %s", qtt);	// Getting Quantity
				printf("Waiting for ISBN of the Book!\n");
				scanf(" %s", isbn);	// Getting ISBN
				alterStock(sockfd, isbn, qtt, tmp);
				break;


			case 'n':	// Numbers on stock
				printf("Waiting for ISBN of the Book!\n");
				scanf("%s", isbn);	// Getting ISBN

				/* Calling the stocks numbers */
				dataFetch(sockfd, isbn, "6", tmp);
				break;


			case 'p':
				printf("Digite a senha para cliente livraria...\n");
				scanf(" %s", pwd);
				pass(sockfd, pwd, tmp);
				break;


			case 'q':	// Quiting the program!
				printf("Quiting now!\n");
				break;


			default:	// Unknow command
				printf("Bad instruction, try again!\n");
				break;
		} /* End Switch */

		if (op == 'q')
			break;

	}
	
	freeaddrinfo(servinfo);
	close(sockfd);
	return 0;	// Terminating program

}
Exemple #30
0
MainWindow::MainWindow(const QDir &home)
{
    /*----------------------------------------------------------------------
     *  Bootstrap
     *--------------------------------------------------------------------*/
    setAttribute(Qt::WA_DeleteOnClose);
    mainwindows.append(this);  // add us to the list of open windows
    context = new Context(this);
    context->athlete = new Athlete(context, home);

    setInstanceName(context->athlete->cyclist);
    setWindowIcon(QIcon(":images/gc.png"));
    setWindowTitle(context->athlete->home.dirName());
    setContentsMargins(0,0,0,0);
    setAcceptDrops(true);
    GCColor *GCColorSet = new GCColor(context); // get/keep colorset
    GCColorSet->colorSet(); // shut up the compiler

    #ifdef Q_OS_MAC
    // get an autorelease pool setup
    static CocoaInitializer cocoaInitializer;
    #endif
    #ifdef GC_HAVE_WFAPI
    WFApi *w = WFApi::getInstance(); // ensure created on main thread
    w->apiVersion();//shutup compiler
    #endif
    Library::initialise(context->athlete->home);
    QNetworkProxyQuery npq(QUrl("http://www.google.com"));
    QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
    if (listOfProxies.count() > 0) {
        QNetworkProxy::setApplicationProxy(listOfProxies.first());
    }

    if (desktop == NULL) desktop = QApplication::desktop();
    static const QIcon hideIcon(":images/toolbar/main/hideside.png");
    static const QIcon rhideIcon(":images/toolbar/main/hiderside.png");
    static const QIcon showIcon(":images/toolbar/main/showside.png");
    static const QIcon rshowIcon(":images/toolbar/main/showrside.png");
    static const QIcon tabIcon(":images/toolbar/main/tab.png");
    static const QIcon tileIcon(":images/toolbar/main/tile.png");
    static const QIcon fullIcon(":images/toolbar/main/togglefull.png");

#if (defined Q_OS_MAC) && (defined GC_HAVE_LION)
    fullScreen = new LionFullScreen(context);
#endif
#ifndef Q_OS_MAC
    fullScreen = new QTFullScreen(context);
#endif

    // if no workout directory is configured, default to the
    // top level GoldenCheetah directory
    if (appsettings->value(NULL, GC_WORKOUTDIR).toString() == "")
        appsettings->setValue(GC_WORKOUTDIR, QFileInfo(context->athlete->home.absolutePath() + "/../").absolutePath());

    /*----------------------------------------------------------------------
     *  GUI setup
     *--------------------------------------------------------------------*/

    // need to restore geometry before setUnifiedToolBar.. on Mac
    appsettings->setValue(GC_SETTINGS_LAST, context->athlete->home.dirName());
    QVariant geom = appsettings->value(this, GC_SETTINGS_MAIN_GEOM);
    if (geom == QVariant()) {

        // first run -- lets set some sensible defaults...
        // lets put it in the middle of screen 1
        QRect size = desktop->availableGeometry();
        struct SizeSettings app = GCColor::defaultSizes(size.height(), size.width());

        // center on the available screen (minus toolbar/sidebar)
        move((size.width()-size.x())/2 - app.width/2,
             (size.height()-size.y())/2 - app.height/2);

        // set to the right default
        resize(app.width, app.height);

        // set all the default font sizes
        appsettings->setValue(GC_FONT_DEFAULT_SIZE, app.defaultFont);
        appsettings->setValue(GC_FONT_TITLES_SIZE, app.titleFont);
        appsettings->setValue(GC_FONT_CHARTMARKERS_SIZE, app.markerFont);
        appsettings->setValue(GC_FONT_CHARTLABELS_SIZE, app.labelFont);
        appsettings->setValue(GC_FONT_CALENDAR_SIZE, app.calendarFont);
        appsettings->setValue(GC_FONT_POPUP_SIZE, app.popupFont);

        // set the default fontsize
        QFont font;
        font.setPointSize(app.defaultFont);
        QApplication::setFont(font);

    } else {

        QRect size = desktop->availableGeometry();

        // ensure saved geometry isn't greater than current screen size
        if ((geom.toRect().height() >= size.height()) || (geom.toRect().width() >= size.width()))
            setGeometry(size.x()+30,size.y()+30,size.width()-60,size.height()-60);
        else
            setGeometry(geom.toRect());
    }


    /*----------------------------------------------------------------------
     *  Mac Toolbar
     *--------------------------------------------------------------------*/
#ifdef Q_OS_MAC 
    setUnifiedTitleAndToolBarOnMac(true);
    head = addToolBar(context->athlete->cyclist);
    head->setContentsMargins(0,0,0,0);

    // widgets
    QWidget *macAnalButtons = new QWidget(this);
    macAnalButtons->setContentsMargins(0,0,20,0);

    // lhs buttons
    QHBoxLayout *lb = new QHBoxLayout(macAnalButtons);
    lb->setContentsMargins(0,0,0,0);
    lb->setSpacing(0);
    import = new QtMacButton(this, QtMacButton::TexturedRounded);
    QPixmap *importImg = new QPixmap(":images/mac/download.png");
    import->setImage(importImg);
    import->setToolTip("Download");
    lb->addWidget(import);
    lb->addWidget(new Spacer(this));
    compose = new QtMacButton(this, QtMacButton::TexturedRounded);
    QPixmap *composeImg = new QPixmap(":images/mac/compose.png");
    compose->setImage(composeImg);
    compose->setToolTip("Create");
    lb->addWidget(compose);

    // connect to actions
    connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide()));
    connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide()));

    lb->addWidget(new Spacer(this));

    // activity actions .. peaks, split, delete
    QWidget *acts = new QWidget(this);
    acts->setContentsMargins(0,0,0,0);
    QHBoxLayout *pp = new QHBoxLayout(acts);
    pp->setContentsMargins(0,0,0,0);
    pp->setContentsMargins(0,0,0,0);
    pp->setSpacing(5);
    sidebar = new QtMacButton(this, QtMacButton::TexturedRounded);
    QPixmap *sidebarImg = new QPixmap(":images/mac/sidebar.png");
    sidebar->setImage(sidebarImg);
    sidebar->setMinimumSize(25, 25);
    sidebar->setMaximumSize(25, 25);
    sidebar->setToolTip("Sidebar");
    sidebar->setSelected(true); // assume always start up with sidebar selected

    actbuttons = new QtMacSegmentedButton(3, acts);
    actbuttons->setWidth(115);
    actbuttons->setNoSelect();
    actbuttons->setImage(0, new QPixmap(":images/mac/stop.png"));
    actbuttons->setImage(1, new QPixmap(":images/mac/split.png"));
    actbuttons->setImage(2, new QPixmap(":images/mac/trash.png"));
    pp->addWidget(actbuttons);
    lb->addWidget(acts);
    lb->addStretch();
    connect(actbuttons, SIGNAL(clicked(int,bool)), this, SLOT(actionClicked(int)));

    lb->addWidget(new Spacer(this));

    QWidget *viewsel = new QWidget(this);
    viewsel->setContentsMargins(0,0,0,0);
    QHBoxLayout *pq = new QHBoxLayout(viewsel);
    pq->setContentsMargins(0,0,0,0);
    pq->setSpacing(5);
    pq->addWidget(sidebar);
    styleSelector = new QtMacSegmentedButton(2, viewsel);
    styleSelector->setWidth(80); // actually its 80 but we want a 30px space between is and the searchbox
    styleSelector->setImage(0, new QPixmap(":images/mac/tabbed.png"), 24);
    styleSelector->setImage(1, new QPixmap(":images/mac/tiled.png"), 24);
    pq->addWidget(styleSelector);
    connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar()));
    connect(styleSelector, SIGNAL(clicked(int,bool)), this, SLOT(toggleStyle()));

    // setup Mac thetoolbar
    head->addWidget(macAnalButtons);
    head->addWidget(new Spacer(this));
    head->addWidget(new Spacer(this));
    head->addWidget(viewsel);

#ifdef GC_HAVE_LUCENE
    SearchFilterBox *searchBox = new SearchFilterBox(this,context,false);
    QCleanlooksStyle *toolStyle = new QCleanlooksStyle();
    searchBox->setStyle(toolStyle);
    searchBox->setFixedWidth(200);
    head->addWidget(searchBox);
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList)));
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter()));
#endif

#endif 

    /*----------------------------------------------------------------------
     *  Windows and Linux Toolbar
     *--------------------------------------------------------------------*/
#ifndef Q_OS_MAC

    head = new GcToolBar(this);

    QCleanlooksStyle *toolStyle = new QCleanlooksStyle();
    QPalette metal;
    metal.setColor(QPalette::Button, QColor(215,215,215));

    // get those icons
    importIcon = iconFromPNG(":images/mac/download.png");
    composeIcon = iconFromPNG(":images/mac/compose.png");
    intervalIcon = iconFromPNG(":images/mac/stop.png");
    splitIcon = iconFromPNG(":images/mac/split.png");
    deleteIcon = iconFromPNG(":images/mac/trash.png");
    sidebarIcon = iconFromPNG(":images/mac/sidebar.png");
    tabbedIcon = iconFromPNG(":images/mac/tabbed.png");
    tiledIcon = iconFromPNG(":images/mac/tiled.png");
    QSize isize(19,19);

    Spacer *spacerl = new Spacer(this);
    spacerl->setFixedWidth(5);

    import = new QPushButton(this);
    import->setIcon(importIcon);
    import->setIconSize(isize);
    import->setFixedHeight(25);
    import->setStyle(toolStyle);
    import->setToolTip(tr("Download from Device"));
    import->setPalette(metal);
    connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide()));

    compose = new QPushButton(this);
    compose->setIcon(composeIcon);
    compose->setIconSize(isize);
    compose->setFixedHeight(25);
    compose->setStyle(toolStyle);
    compose->setToolTip(tr("Create Manual Activity"));
    compose->setPalette(metal);
    connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide()));

    sidebar = new QPushButton(this);
    sidebar->setIcon(sidebarIcon);
    sidebar->setIconSize(isize);
    sidebar->setFixedHeight(25);
    sidebar->setStyle(toolStyle);
    sidebar->setToolTip(tr("Toggle Sidebar"));
    sidebar->setPalette(metal);
    connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar()));

    actbuttons = new QtSegmentControl(this);
    actbuttons->setStyle(toolStyle);
    actbuttons->setIconSize(isize);
    actbuttons->setCount(3);
    actbuttons->setSegmentIcon(0, intervalIcon);
    actbuttons->setSegmentIcon(1, splitIcon);
    actbuttons->setSegmentIcon(2, deleteIcon);
    actbuttons->setSelectionBehavior(QtSegmentControl::SelectNone); //wince. spelling. ugh
    actbuttons->setFixedHeight(25);
    actbuttons->setSegmentToolTip(0, tr("Find Intervals..."));
    actbuttons->setSegmentToolTip(1, tr("Split Activity..."));
    actbuttons->setSegmentToolTip(2, tr("Delete Activity"));
    actbuttons->setPalette(metal);
    connect(actbuttons, SIGNAL(segmentSelected(int)), this, SLOT(actionClicked(int)));

    styleSelector = new QtSegmentControl(this);
    styleSelector->setStyle(toolStyle);
    styleSelector->setIconSize(isize);
    styleSelector->setCount(2);
    styleSelector->setSegmentIcon(0, tabbedIcon);
    styleSelector->setSegmentIcon(1, tiledIcon);
    styleSelector->setSegmentToolTip(0, tr("Tabbed View"));
    styleSelector->setSegmentToolTip(1, tr("Tiled View"));
    styleSelector->setSelectionBehavior(QtSegmentControl::SelectOne); //wince. spelling. ugh
    styleSelector->setFixedHeight(25);
    styleSelector->setPalette(metal);
    connect(styleSelector, SIGNAL(segmentSelected(int)), this, SLOT(setStyleFromSegment(int))); //avoid toggle infinitely

    head->addWidget(spacerl);
    head->addWidget(import);
    head->addWidget(compose);
    head->addWidget(actbuttons);

    head->addStretch();
    head->addWidget(sidebar);
    head->addWidget(styleSelector);

#ifdef GC_HAVE_LUCENE
    // add a search box on far right, but with a little space too
    SearchFilterBox *searchBox = new SearchFilterBox(this,context,false);
    searchBox->setStyle(toolStyle);
    searchBox->setFixedWidth(200);
    head->addWidget(searchBox);
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList)));
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter()));
#endif
    Spacer *spacer = new Spacer(this);
    spacer->setFixedWidth(5);
    head->addWidget(spacer);
#endif

    /*----------------------------------------------------------------------
     * ScopeBar
     *--------------------------------------------------------------------*/
    scopebar = new GcScopeBar(context);
    connect(scopebar, SIGNAL(selectDiary()), this, SLOT(selectDiary()));
    connect(scopebar, SIGNAL(selectHome()), this, SLOT(selectHome()));
    connect(scopebar, SIGNAL(selectAnal()), this, SLOT(selectAnalysis()));
    connect(scopebar, SIGNAL(selectTrain()), this, SLOT(selectTrain()));

    // Add chart is on the scope bar
    chartMenu = new QMenu(this);
    QCleanlooksStyle *styler = new QCleanlooksStyle();
    QPushButton *newchart = new QPushButton("+", this);
    scopebar->addWidget(newchart);
    newchart->setStyle(styler);
    newchart->setFixedHeight(20);
    newchart->setFixedWidth(24);
    newchart->setFlat(true);
    newchart->setFocusPolicy(Qt::NoFocus);
    newchart->setToolTip(tr("Add Chart"));
    newchart->setAutoFillBackground(false);
    newchart->setAutoDefault(false);
    newchart->setMenu(chartMenu);
    connect(chartMenu, SIGNAL(aboutToShow()), this, SLOT(setChartMenu()));
    connect(chartMenu, SIGNAL(triggered(QAction*)), this, SLOT(addChart(QAction*)));

    /*----------------------------------------------------------------------
     * Central Widget
     *--------------------------------------------------------------------*/

    tab = new Tab(context);

    /*----------------------------------------------------------------------
     * Central Widget
     *--------------------------------------------------------------------*/

    QWidget *central = new QWidget(this);
    setContentsMargins(0,0,0,0);
    central->setContentsMargins(0,0,0,0);
    QVBoxLayout *mainLayout = new QVBoxLayout(central);
    mainLayout->setSpacing(0);
    mainLayout->setContentsMargins(0,0,0,0);
#ifndef Q_OS_MAC // nonmac toolbar on main view -- its not 
                 // unified with the title bar.
    mainLayout->addWidget(head);
#endif
    mainLayout->addWidget(scopebar);
    mainLayout->addWidget(tab);
    setCentralWidget(central);

    /*----------------------------------------------------------------------
     * Application Menus
     *--------------------------------------------------------------------*/
#ifdef WIN32
    menuBar()->setStyleSheet("QMenuBar { background: rgba(225,225,225); }"
		    	     "QMenuBar::item { background: rgba(225,225,225); }");
    menuBar()->setContentsMargins(0,0,0,0);
#endif

    QMenu *fileMenu = menuBar()->addMenu(tr("&Athlete"));
    fileMenu->addAction(tr("&New..."), this, SLOT(newCyclist()), tr("Ctrl+N"));
    fileMenu->addAction(tr("&Open..."), this, SLOT(openCyclist()), tr("Ctrl+O"));
    fileMenu->addAction(tr("&Close Window"), this, SLOT(close()), tr ("Ctrl+W"));
    fileMenu->addAction(tr("&Quit All Windows"), this, SLOT(closeAll()), tr("Ctrl+Q"));

    QMenu *rideMenu = menuBar()->addMenu(tr("A&ctivity"));
    rideMenu->addAction(tr("&Download from device..."), this, SLOT(downloadRide()), tr("Ctrl+D"));
    rideMenu->addAction(tr("&Import from file..."), this, SLOT (importFile()), tr ("Ctrl+I"));
    rideMenu->addAction(tr("&Manual activity entry..."), this, SLOT(manualRide()), tr("Ctrl+M"));
    rideMenu->addSeparator ();
    rideMenu->addAction(tr("&Export..."), this, SLOT(exportRide()), tr("Ctrl+E"));
    rideMenu->addAction(tr("&Batch export..."), this, SLOT(exportBatch()), tr("Ctrl+B"));
    rideMenu->addAction(tr("Export Metrics as CSV..."), this, SLOT(exportMetrics()), tr(""));
#ifdef GC_HAVE_SOAP
    rideMenu->addSeparator ();
    rideMenu->addAction(tr("&Upload to TrainingPeaks"), this, SLOT(uploadTP()), tr("Ctrl+U"));
    rideMenu->addAction(tr("Down&load from TrainingPeaks..."), this, SLOT(downloadTP()), tr("Ctrl+L"));
#endif

#ifdef GC_HAVE_LIBOAUTH
    tweetAction = new QAction(tr("Tweet Activity"), this);
    connect(tweetAction, SIGNAL(triggered(bool)), this, SLOT(tweetRide()));
    rideMenu->addAction(tweetAction);

    shareAction = new QAction(tr("Share (Strava, RideWithGPS, CyclingAnalytics)..."), this);
    connect(shareAction, SIGNAL(triggered(bool)), this, SLOT(share()));
    rideMenu->addAction(shareAction);
#endif

    ttbAction = new QAction(tr("Upload to Trainingstagebuch..."), this);
    connect(ttbAction, SIGNAL(triggered(bool)), this, SLOT(uploadTtb()));
    rideMenu->addAction(ttbAction);

    rideMenu->addSeparator ();
    rideMenu->addAction(tr("&Save activity"), this, SLOT(saveRide()), tr("Ctrl+S"));
    rideMenu->addAction(tr("D&elete activity..."), this, SLOT(deleteRide()));
    rideMenu->addAction(tr("Split &activity..."), this, SLOT(splitRide()));
    rideMenu->addAction(tr("Merge activities..."), this, SLOT(mergeRide()));
    rideMenu->addSeparator ();

    QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools"));
    optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions()));
    optionsMenu->addAction(tr("Critical Power Estimator..."), this, SLOT(showTools()));
    optionsMenu->addAction(tr("Air Density (Rho) Estimator..."), this, SLOT(showRhoEstimator()));

    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Get &Withings Data..."), this,
                        SLOT (downloadMeasures()));
    optionsMenu->addAction(tr("Get &Zeo Data..."), this,
                        SLOT (downloadMeasuresFromZeo()));
    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Create a new workout..."), this, SLOT(showWorkoutWizard()));
    optionsMenu->addAction(tr("Download workouts from ErgDB..."), this, SLOT(downloadErgDB()));
    optionsMenu->addAction(tr("Import workouts or videos..."), this, SLOT(importWorkout()));
    optionsMenu->addAction(tr("Scan disk for videos and workouts..."), this, SLOT(manageLibrary()));

#ifdef GC_HAVE_ICAL
    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Upload Activity to Calendar"), this, SLOT(uploadCalendar()), tr (""));
    //optionsMenu->addAction(tr("Import Calendar..."), this, SLOT(importCalendar()), tr ("")); // planned for v3.1
    //optionsMenu->addAction(tr("Export Calendar..."), this, SLOT(exportCalendar()), tr ("")); // planned for v3.1
    optionsMenu->addAction(tr("Refresh Calendar"), this, SLOT(refreshCalendar()), tr (""));
#endif
    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Find intervals..."), this, SLOT(addIntervals()), tr (""));

    // Add all the data processors to the tools menu
    const DataProcessorFactory &factory = DataProcessorFactory::instance();
    QMap<QString, DataProcessor*> processors = factory.getProcessors();

    if (processors.count()) {

        optionsMenu->addSeparator();
        toolMapper = new QSignalMapper(this); // maps each option
        QMapIterator<QString, DataProcessor*> i(processors);
        connect(toolMapper, SIGNAL(mapped(const QString &)), this, SLOT(manualProcess(const QString &)));

        i.toFront();
        while (i.hasNext()) {
            i.next();
            // The localized processor name is shown in menu
            QAction *action = new QAction(QString("%1...").arg(i.value()->name()), this);
            optionsMenu->addAction(action);
            connect(action, SIGNAL(triggered()), toolMapper, SLOT(map()));
            toolMapper->setMapping(action, i.key());
        }
    }