Esempio n. 1
0
MainMenubar::MainMenubar (QMainWindow *mw) : QMenuBar (mw, "mainMenubar")
{
  actions.setAutoDelete(FALSE);

  RcFile rcfile;

  QPixmap icon(finished);
  QAction *action  = new QAction(this, "actionExit");
  action->setMenuText(tr("E&xit"));
  action->setIconSet(icon);
  action->setAccel(Qt::CTRL+Qt::Key_Q);
  action->setStatusTip(tr("Quit Qtstalker (Ctrl+Q)"));
  action->setToolTip(tr("Quit Qtstalker (Ctrl+Q)"));
  connect(action, SIGNAL(activated()), this, SIGNAL(signalExit()));
  actions.replace(Exit, action);

  icon = configure;
  action = new QAction(this, "actionOptions");
  action->setMenuText(tr("Edit &Preferences"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Modify user preferences (Ctrl+0)"));
  action->setToolTip(tr("Modify user preferences (Ctrl+0)"));
  connect(action, SIGNAL(activated()), mw, SLOT(slotOptions()));
  actions.replace(Options, action);

  icon = nav;
  bool b;
  rcfile.loadData(RcFile::ShowSidePanel, b);
  action = new QAction(this, "actionPanel");
  action->setMenuText(tr("Side &Panel"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Toggle side-panel view (Ctrl+1)"));
  action->setToolTip(tr("Toggle side-panel view (Ctrl+1)"));
  action->setToggleAction(TRUE);
  action->setOn(b);
  connect(action, SIGNAL(toggled(bool)), mw, SLOT(slotHideNav(bool)));
  actions.replace(SidePanel, action);

  icon = gridicon;
  rcfile.loadData(RcFile::Grid, b);
  action = new QAction(this, "actionGrid");
  action->setMenuText(tr("Chart &Grid"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Toggle chart grid (Ctrl+2)"));
  action->setToolTip(tr("Toggle chart grid (Ctrl+2)"));
  action->setToggleAction(TRUE);
  action->setOn(b);
  connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalGrid(bool)));
  actions.replace(Grid, action);

  icon = scaletoscreen;
  rcfile.loadData(RcFile::ScaleToScreen, b);
  action = new QAction(this, "actionScale");
  action->setMenuText(tr("&Scale To Screen"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Scale chart to current screen data (Ctrl+3)"));
  action->setToolTip(tr("Scale chart to current screen data (Ctrl+3)"));
  action->setToggleAction(TRUE);
  action->setOn(b);
  connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalScale(bool)));
  actions.replace(ScaleToScreen, action);

  icon = crosshair;
  rcfile.loadData(RcFile::Crosshairs, b);
  action = new QAction(this, "actionCrosshairs");
  action->setMenuText(tr("Toggle &Crosshairs"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Toggle crosshairs (Ctrl+4)"));
  action->setToolTip(tr("Toggle crosshairs (Ctrl+4)"));
  action->setToggleAction(TRUE);
  action->setOn(b);
  connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalCrosshairs(bool)));
  actions.replace(Crosshairs, action);

  icon = co;
  rcfile.loadData(RcFile::DrawMode, b);
  action = new QAction(this, "actionDraw");
  action->setMenuText(tr("Toggle &Draw Mode"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Toggle drawing mode (Ctrl+5)"));
  action->setToolTip(tr("Toggle drawing mode (Ctrl+5)"));
  action->setToggleAction(TRUE);
  action->setOn(b);
  connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalDraw(bool)));
  actions.replace(DrawMode, action);

  icon = papertrade;
  rcfile.loadData(RcFile::PaperTradeMode, b);
  action = new QAction(this, "actionPaperTrade");
  action->setMenuText(tr("Toggle &Trade Mode"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Toggle paper-trade mode"));
  action->setToolTip(tr("Toggle paper-trade mode"));
  action->setToggleAction(TRUE);
  action->setOn(b);
  connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalPaperTrade(bool)));
  actions.replace(PaperTrade, action);

  icon = indicator;
  action = new QAction(this, "actionNewIndicator");
  action->setMenuText(tr("New &Indicator"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Add new indicator (Ctrl+7)"));
  action->setToolTip(tr("Add new indicator (Ctrl+7)"));
  connect(action, SIGNAL(activated()), this, SIGNAL(signalNewIndicator()));
  actions.replace(NewIndicator, action);

  icon = datawindow;
  action = new QAction(this, "actionDataWindow");
  action->setMenuText(tr("&Data Window"));
  action->setIconSet(icon);
  action->setAccel(Qt::ALT+Qt::Key_1);
  action->setStatusTip(tr("Show data window (Alt+1)"));
  action->setToolTip(tr("Show data window (Alt+1)"));
  connect(action, SIGNAL(activated()), mw, SLOT(slotDataWindow()));
  actions.replace(DataWindow, action);

  icon = quotes;
  action = new QAction(this, "actionQuote");
  action->setMenuText(tr("Load Quotes"));
  action->setIconSet(icon);
  action->setStatusTip(tr("Load Quotes (Ctrl+Y)"));
  action->setToolTip(tr("Load Quotes (Ctrl+Y)"));
  connect(action, SIGNAL(activated()), mw, SLOT(slotQuotes()));
  actions.replace(Quotes, action);

  icon = qtstalker;
  action = new QAction(this, "actionAbout");
  action->setMenuText(tr("&About"));
  action->setIconSet(icon);
  action->setStatusTip(tr("About Qtstalker."));
  action->setToolTip(tr("About Qtstalker."));
  connect(action, SIGNAL(activated()), mw, SLOT(slotAbout()));
  actions.replace(About, action);

  icon = help;
  action = new QAction(this, "actionHelp");
  action->setMenuText(tr("&Help"));
  action->setIconSet(icon);
  action->setAccel(Qt::Key_F1);
  action->setStatusTip(tr("Display Help (F1)"));
  action->setToolTip(tr("Display Help (F1)"));
  connect(action, SIGNAL(activated()), mw, SLOT(slotHelp()));
  actions.replace(Help, action);

  action = new QAction(this, "actionAdvancePaperTrade");
  action->setAccel(Qt::CTRL+Qt::Key_Right);
  connect(action, SIGNAL(activated()), this, SIGNAL(signalAdvancePaperTrade()));
  actions.replace(AdvancePaperTrade, action);

  action = new QAction(this, "actionIndicatorSummary");
  action->setMenuText(tr("Indicator Summary"));
  action->setStatusTip(tr("Indicator Summary"));
  action->setToolTip(tr("Indicator Summary"));
  connect(action, SIGNAL(activated()), mw, SLOT(slotIndicatorSummary()));
  actions.replace(IndicatorSummary, action);

  Q3Accel *a = new Q3Accel(mw);
  connect(a, SIGNAL(activated(int)), this, SLOT(slotAccel(int)));
  a->insertItem(Qt::CTRL+Qt::Key_0, Options);
  a->insertItem(Qt::CTRL+Qt::Key_1, SidePanel);
  a->insertItem(Qt::CTRL+Qt::Key_2, Grid);
  a->insertItem(Qt::CTRL+Qt::Key_3, ScaleToScreen);
  a->insertItem(Qt::CTRL+Qt::Key_4, Crosshairs);
  a->insertItem(Qt::CTRL+Qt::Key_5, DrawMode);
  a->insertItem(Qt::CTRL+Qt::Key_7, NewIndicator);
  a->insertItem(Qt::CTRL+Qt::Key_Y, Quotes);
  a->insertItem(Qt::CTRL+Qt::Key_Right, AdvancePaperTrade);
  a->insertItem(Qt::CTRL+Qt::Key_Escape, 8);

  createMenus();

  rcfile.loadData(RcFile::ShowMenuBar, b);
  if (!b)
    hide();
}
Esempio n. 2
0
TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
    : QMainWindow( parent, name, f )
{
    doc = 0;
    edited=false;

    setToolBarsMovable( false );
    connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );

    channel = new QCopChannel( "QPE/Application/textedit", this );
    connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
        this, SLOT(receive(const QCString&,const QByteArray&)) );

    setIcon( Opie::Core::OResource::loadPixmap( "textedit/TextEditor", Opie::Core::OResource::SmallIcon ) );

    QToolBar *bar = new QToolBar( this );
    bar->setHorizontalStretchable( true );
    menu = bar;

    QMenuBar *mb = new QMenuBar( bar );
    QPopupMenu *file = new QPopupMenu( this );
    QPopupMenu *edit = new QPopupMenu( this );
    QPopupMenu *advancedMenu = new QPopupMenu(this);

    font = new QPopupMenu( this );

    bar = new QToolBar( this );
    editBar = bar;

    QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
                              QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
//    a->addTo( bar );
    a->addTo( file );

    a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
    a->addTo( bar );
    a->addTo( file );

    a = new QAction( tr( "Save" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
    file->insertSeparator();
    a->addTo( bar );
    a->addTo( file );

    a = new QAction( tr( "Save As" ),  Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
    a->addTo( file );

    file->insertSeparator();
    deleteAction = new QAction( tr( "Delete" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( deleteAction, SIGNAL( activated() ), this, SLOT( fileDelete() ) );
    deleteAction->addTo( file );

    undoAction = new QAction( tr( "Undo" ), Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    undoAction->addTo( edit );
    undoAction->setEnabled( false );

    redoAction = new QAction( tr( "Redo" ), Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    redoAction->addTo( edit );
    redoAction->setEnabled( false );

    edit->insertSeparator();

    a = new QAction( tr( "Cut" ), Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
    a->addTo( editBar );
    a->addTo( edit );

    a = new QAction( tr( "Copy" ), Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
    a->addTo( editBar );
    a->addTo( edit );

    a = new QAction( tr( "Paste" ), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
    a->addTo( editBar );
    a->addTo( edit );


#ifndef QT_NO_CLIPBOARD
    a = new QAction( tr( "Insert Time and Date" ), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
    a->addTo( edit );
#endif

    a = new QAction( tr( "Goto Line..." ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ),
                    QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) );
    edit->insertSeparator();
    a->addTo( edit );

    a = new QAction( tr( "Find..." ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
    a->addTo( bar );
    a->addTo( edit );

    zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
    connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
    zin->addTo( font );

    zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
    connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
    zout->addTo( font );

    font->insertSeparator();

    font->insertItem(tr("Font"), this, SLOT(changeFont()) );

    font->insertSeparator();
    font->insertItem(tr("Advanced Features"), advancedMenu);

    QAction *wa = new QAction( tr("Wrap lines"),
                               QString::null, 0, this, 0 );
    connect( wa, SIGNAL( toggled(bool) ),
             this, SLOT( setWordWrap(bool) ) );
    wa->setToggleAction(true);
    wa->addTo( advancedMenu);

    desktopAction = new QAction( tr("Always open linked file"),
                                 QString::null, 0, this, 0 );
    connect( desktopAction, SIGNAL( toggled(bool) ),
             this, SLOT( doDesktop(bool) ) );
    desktopAction->setToggleAction(true);
    desktopAction->addTo( advancedMenu);

    filePermAction = new QAction( tr("File Permissions"),
                                  QString::null, 0, this, 0 );
    connect( filePermAction, SIGNAL( toggled(bool) ),
             this, SLOT( doFilePerms(bool) ) );
    filePermAction->setToggleAction(true);
    filePermAction->addTo( advancedMenu);

    nAutoSave = new QAction( tr("Auto Save 5 min."),
                                   QString::null, 0, this, 0 );
    connect( nAutoSave, SIGNAL( toggled(bool) ),
             this, SLOT( doTimer(bool) ) );
    nAutoSave->setToggleAction(true);
    nAutoSave->addTo( advancedMenu);

    mb->insertItem( tr( "File" ), file );
    mb->insertItem( tr( "Edit" ), edit );
    mb->insertItem( tr( "View" ), font );

    searchBar = new QToolBar(this);
    addToolBar( searchBar,  "Search", QMainWindow::Top, true );

    searchBar->setHorizontalStretchable( true );

    searchEdit = new QLineEdit( searchBar, "searchEdit" );
    searchBar->setStretchableWidget( searchEdit );
    connect( searchEdit, SIGNAL( textChanged(const QString&) ),
       this, SLOT( search() ) );

    a = new QAction( tr( "Find Next" ), Opie::Core::OResource::loadPixmap( "next", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
    a->addTo( searchBar );
    a->addTo( edit );

    a = new QAction( tr( "Close Find" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
    a->addTo( searchBar );

    searchBar->hide();

    editor = new QpeEditor( this );
    setCentralWidget( editor );
    editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
    connect( editor, SIGNAL( textChanged() ),
             this, SLOT( editorChanged() ) );
    connect( editor, SIGNAL( undoAvailable(bool) ),
             undoAction, SLOT( setEnabled(bool) ) );
    connect( editor, SIGNAL( redoAvailable(bool) ),
             redoAction, SLOT( setEnabled(bool) ) );
    connect( undoAction, SIGNAL( activated() ), editor, SLOT( undo() ) );
    connect( redoAction, SIGNAL( activated() ), editor, SLOT( redo() ) );

    QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);

    Config cfg("TextEdit");
    cfg. setGroup ( "Font" );

    QFont defaultFont = editor-> font ( );

    QString family = cfg. readEntry     ( "Family", defaultFont. family ( ));
    int size       = cfg. readNumEntry  ( "Size",   defaultFont. pointSize ( ));
    int weight     = cfg. readNumEntry  ( "Weight", defaultFont. weight ( ));
    bool italic    = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));

    defaultFont = QFont ( family, size, weight, italic );
    editor-> setFont ( defaultFont );

    cfg.setGroup ( "View" );

    openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
    filePerms = cfg.readBoolEntry ( "FilePermissions", false );
    featureAutoSave = cfg.readBoolEntry( "autosave", false);

    if(openDesktop) desktopAction->setOn( true );
    if(filePerms) filePermAction->setOn( true );
    if(featureAutoSave) nAutoSave->setOn(true);

//       {
//           doTimer(true);
//       }

    bool wrap = cfg. readBoolEntry ( "Wrap", true );
    wa-> setOn ( wrap );
    setWordWrap ( wrap );

/////////////////
    if( qApp->argc() > 1) {
        currentFileName=qApp->argv()[1];

        QFileInfo fi(currentFileName);

        if(fi.baseName().left(1) == "") {
            openDotFile(currentFileName);
        }
        else {
            openFile(currentFileName);
        }
    }
    else {
        newFile();
    }
}