Beispiel #1
0
FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl)
  : QMainWindow( parent, name, fl )
{

  // random seed
  srand(time(0));
  setCaption( tr("Fifteen Pieces") );

  QToolBar *toolbar = new QToolBar(this);
  toolbar->setHorizontalStretchable( FALSE );
  QMenuBar *menubar = new QMenuBar( toolbar );
  menubar->setMargin(0);
  QPopupMenu *game = new QPopupMenu( this );
  menubar->insertItem( tr( "Game" ), game );

  QWidget *spacer = new QWidget( toolbar );
  spacer->setBackgroundMode( PaletteButton );
  toolbar->setStretchableWidget( spacer );


  setToolBarsMovable( FALSE );
  QVBox *vbox = new QVBox( this );
  PiecesTable *table = new PiecesTable( vbox );
  setCentralWidget(vbox);



  QAction *a = new QAction( tr( "Randomize" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
			    QString::null, 0, this, 0 );
  connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) );
  a->addTo( game );
  a->addTo( toolbar );


  a  = new QAction( tr("Configure"), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
                    QString::null, 0, this, 0 );
  connect( a, SIGNAL( activated()), table, SLOT( slotConfigure()) );
  a->addTo( game );
}
HelpWindow::HelpWindow( const QString& home_, const QString& _path,
			QWidget* parent, const char *name )
    : QMainWindow( parent, name, WDestructiveClose ),
      pathCombo( 0 ), selectedURL()
{
    readHistory();
    readBookmarks();

    browser = new QTextBrowser( this );
    browser->mimeSourceFactory()->setFilePath( _path );
    browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
    connect( browser, SIGNAL( textChanged() ),
	     this, SLOT( textChanged() ) );

    setCentralWidget( browser );

    if ( !home_.isEmpty() )
	browser->setSource( home_ );

    connect( browser, SIGNAL( highlighted( const QString&) ),
	     statusBar(), SLOT( message( const QString&)) );

    resize( 640,700 );

    QPopupMenu* file = new QPopupMenu( this );
    file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N );
    file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
    file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P );

    // The same three icons are used twice each.
    QIconSet icon_back( QPixmap("textdrawing/previous.png") );
    QIconSet icon_forward( QPixmap("textdrawing/next.png") );
    QIconSet icon_home( QPixmap("textdrawing/home.png") );

    QPopupMenu* go = new QPopupMenu( this );
    backwardId = go->insertItem( icon_back,
				 tr("&Backward"), browser, SLOT( backward() ),
				 ALT | Key_Left );
    forwardId = go->insertItem( icon_forward,
				tr("&Forward"), browser, SLOT( forward() ),
				ALT | Key_Right );
    go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) );

    hist = new QPopupMenu( this );
    QStringList::Iterator it = history.begin();
    for ( ; it != history.end(); ++it )
	mHistory[ hist->insertItem( *it ) ] = *it;
    connect( hist, SIGNAL( activated( int ) ),
	     this, SLOT( histChosen( int ) ) );

    bookm = new QPopupMenu( this );
    bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
    bookm->insertSeparator();

    QStringList::Iterator it2 = bookmarks.begin();
    for ( ; it2 != bookmarks.end(); ++it2 )
	mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
    connect( bookm, SIGNAL( activated( int ) ),
	     this, SLOT( bookmChosen( int ) ) );

    menuBar()->insertItem( tr("&File"), file );
    menuBar()->insertItem( tr("&Go"), go );
    menuBar()->insertItem( tr( "History" ), hist );
    menuBar()->insertItem( tr( "Bookmarks" ), bookm );

    menuBar()->setItemEnabled( forwardId, FALSE);
    menuBar()->setItemEnabled( backwardId, FALSE);
    connect( browser, SIGNAL( backwardAvailable( bool ) ),
	     this, SLOT( setBackwardAvailable( bool ) ) );
    connect( browser, SIGNAL( forwardAvailable( bool ) ),
	     this, SLOT( setForwardAvailable( bool ) ) );


    QToolBar* toolbar = new QToolBar( this );
    addToolBar( toolbar, "Toolbar");
    QToolButton* button;

    button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar );
    connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
    button->setEnabled( FALSE );
    button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar );
    connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
    button->setEnabled( FALSE );
    button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar );

    toolbar->addSeparator();

    pathCombo = new QComboBox( TRUE, toolbar );
    connect( pathCombo, SIGNAL( activated( const QString & ) ),
	     this, SLOT( pathSelected( const QString & ) ) );
    toolbar->setStretchableWidget( pathCombo );
    setRightJustification( TRUE );
    setDockEnabled( DockLeft, FALSE );
    setDockEnabled( DockRight, FALSE );

    pathCombo->insertItem( home_ );

    browser->setFocus();
}
Beispiel #3
0
void QHTMLView::init()
{
  QString qs;
  QString qs2;
  mpTextBrowser = new QTextBrowser(this);
  mpTextBrowser->setTextFormat(Qt::RichText);
  setCentralWidget(mpTextBrowser);
  qs = xmlConfig->stringValue("HELP_INDEX");
  qs2 = xmlConfig->stringValue("HELP_LAST_PAGE");
  QFile qf1(qs);
  if(qf1.exists()) mpTextBrowser->setSource(qs);
  if(qs != qs2 )
  {
    QFile qf2(qs2);
    if(qf2.exists()) mpTextBrowser->setSource(qs2);
  }
  QPopupMenu* file = new QPopupMenu( this );
  file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
  file->insertSeparator();
  file->insertItem( tr("&Quit"), this, SLOT( close() ), ALT | Key_Q );

  QPopupMenu* go = new QPopupMenu( this );

  mIdBackward = go->insertItem(tr("&Backward"),mpTextBrowser,
                   SLOT( backward() ),ALT | Key_Left );
  mIdForward = go->insertItem(tr("&Forward"),mpTextBrowser,
                   SLOT( forward() ),ALT | Key_Right );
  go->insertItem(tr("&Home"),mpTextBrowser, SLOT( home() ) );

  QPopupMenu* help = new QPopupMenu( this );
  help->insertItem(tr("&About ..."),this,SLOT(about()));

#ifdef KDEAPP
  KMenuBar* mb = new KMenuBar(this);
#else
  QMenuBar* mb = new QMenuBar(this);
#endif
  mb->insertItem(tr("&File"),file);
  mb->insertItem(tr("&Go"),go);
  mb->insertSeparator();
  mb->insertItem(tr("&Help"),help );

  mb->setItemEnabled( mIdForward, false);
  mb->setItemEnabled( mIdBackward, false);

  connect(mpTextBrowser, SIGNAL( backwardAvailable( bool ) ),
    	    this, SLOT( setBackwardAvailable( bool ) ) );
  connect(mpTextBrowser, SIGNAL( forwardAvailable( bool ) ),
	        this, SLOT( setForwardAvailable( bool ) ) );
  connect(mpTextBrowser,SIGNAL(textChanged() ),this,
          SLOT( slotTextChanged() ) );

  QToolBar* toolbar = new QToolBar( this );
  addToolBar( toolbar);
  QToolButton* tb1;

	mPixForward = QPixmap((const char **)forward_xpm);
	mPixBackward = QPixmap((const char **)backward_xpm);
	mPixHome = QPixmap((const char **)home_xpm);

  tb1 = new QToolButton(mPixBackward, tr("Backward"), "", mpTextBrowser,
                        SLOT(backward()), toolbar );
  connect(mpTextBrowser, SIGNAL( backwardAvailable(bool) ),tb1,
          SLOT( setEnabled(bool) ) );
  tb1->setEnabled( false );

  tb1 = new QToolButton(mPixForward, tr("Forward"), "",mpTextBrowser,
                        SLOT(forward()), toolbar );
  connect(mpTextBrowser,SIGNAL(forwardAvailable(bool) ),tb1,
          SLOT( setEnabled(bool) ) );
  tb1->setEnabled( false );

  tb1 = new QToolButton(mPixHome, tr("Home"), "",this,
                        SLOT(home()), toolbar );
  QWidget* dummy = new QWidget(toolbar);
  toolbar->setStretchableWidget(dummy);
  setRightJustification(true);
}
FLHelpWindow::FLHelpWindow(const QString &home_,
                           const QString &_path,
                           QWidget *parent,
                           const char *name) :
  QMainWindow(parent, name, WDestructiveClose),
  pathCombo(0), selectedURL()
{
  readHistory();
  readBookmarks();

  browser = new QTextBrowser(this);

  browser->mimeSourceFactory() ->setFilePath(_path);
  browser->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()));

  setCentralWidget(browser);

  if (!home_.isEmpty())
    browser->setSource(home_);

  connect(browser, SIGNAL(highlighted(const QString &)), statusBar(),
          SLOT(message(const QString &)));

  resize(640, 700);

  QPopupMenu *file = new QPopupMenu(this);

  file->insertItem(tr("&Imprimir"), this, SLOT(print()), CTRL + Key_I);
  file->insertSeparator();
  file->insertItem(tr("&Cerrar"), this, SLOT(close()), Key_Escape);

  // The same three icons are used twice each.
  QIconSet icon_back(QPixmap::fromMimeSource("previous.png"));
  QIconSet icon_forward(QPixmap::fromMimeSource("next.png"));
  QIconSet icon_home(QPixmap::fromMimeSource("home.png"));

  QPopupMenu *go = new QPopupMenu(this);

  backwardId =
    go->insertItem(icon_back, tr("&Atrás"), browser, SLOT(backward()),
                   CTRL + Key_Left);
  forwardId =
    go->insertItem(icon_forward, tr("&Adelante"), browser,
                   SLOT(forward()), CTRL + Key_Right);
  go->insertItem(icon_home, tr("&Inicio"), browser, SLOT(home()));

  QPopupMenu *help = new QPopupMenu(this);

  help->insertItem(tr("&Acerca ..."), this, SLOT(about()));
  help->insertItem(tr("Acerca de &Qt ..."), this, SLOT(aboutQt()));

  hist = new QPopupMenu(this);
  QStringList::Iterator it = history.begin();
  for (; it != history.end(); ++it)
    mHistory[ hist->insertItem(*it)] = *it;
  connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int)));

  bookm = new QPopupMenu(this);
  bookm->insertItem(tr("Agregar Favorito"), this, SLOT(addBookmark()));
  bookm->insertSeparator();

  QStringList::Iterator it2 = bookmarks.begin();
  for (; it2 != bookmarks.end(); ++it2)
    mBookmarks[ bookm->insertItem(*it2)] = *it2;
  connect(bookm, SIGNAL(activated(int)), this, SLOT(bookmChosen(int)));

  menuBar() ->insertItem(tr("&Archivo"), file);
  menuBar() ->insertItem(tr("&Ir"), go);
  menuBar() ->insertItem(tr("Historial"), hist);
  menuBar() ->insertItem(tr("Favoritos"), bookm);
  menuBar() ->insertSeparator();
  menuBar() ->insertItem(tr("&Ayuda"), help);

  menuBar() ->setItemEnabled(forwardId, FALSE);
  menuBar() ->setItemEnabled(backwardId, FALSE);
  connect(browser, SIGNAL(backwardAvailable(bool)), this,
          SLOT(setBackwardAvailable(bool)));
  connect(browser, SIGNAL(forwardAvailable(bool)), this,
          SLOT(setForwardAvailable(bool)));


  QToolBar *toolbar = new QToolBar(this);

  addToolBar(toolbar, "Toolbar");
  QToolButton *button;

  button =
    new QToolButton(icon_back, tr("Atrás"), "", browser, SLOT(backward()),
                    toolbar);
  connect(browser, SIGNAL(backwardAvailable(bool)), button,
          SLOT(setEnabled(bool)));
  button->setEnabled(FALSE);
  button =
    new QToolButton(icon_forward, tr("Adelante"), "", browser,
                    SLOT(forward()), toolbar);
  connect(browser, SIGNAL(forwardAvailable(bool)), button,
          SLOT(setEnabled(bool)));
  button->setEnabled(FALSE);
  button =
    new QToolButton(icon_home, tr("Inicio"), "", browser, SLOT(home()),
                    toolbar);

  toolbar->addSeparator();

  pathCombo = new QComboBox(TRUE, toolbar);
  connect(pathCombo, SIGNAL(activated(const QString &)), this,
          SLOT(pathSelected(const QString &)));
  toolbar->setStretchableWidget(pathCombo);
  setRightJustification(TRUE);
  setDockEnabled(DockLeft, FALSE);
  setDockEnabled(DockRight, FALSE);

  pathCombo->insertItem(home_);
  browser->setFocus();
}
Beispiel #5
0
toMain::toMain()
        : toMainWindow()
{
    qApp->setMainWidget ( this );
    setDockMenuEnabled ( true );

    Edit = NULL;

    FileMenu = new QPopupMenu ( this );
    FileMenu->insertItem ( QPixmap ( ( const char ** ) connect_xpm ),
                           "&New Connection...", TO_NEW_CONNECTION );
    FileMenu->insertItem ( QPixmap ( ( const char ** ) disconnect_xpm ),
                           "&Close Connection", this, SLOT ( delConnection() ), 0, TO_CLOSE_CONNECTION );
    FileMenu->insertSeparator();
    FileMenu->insertItem ( QPixmap ( ( const char ** ) commit_xpm ), "&Commit Connection", TO_FILE_COMMIT );
    FileMenu->insertItem ( QPixmap ( ( const char ** ) rollback_xpm ), "&Rollback Connection", TO_FILE_ROLLBACK );
    FileMenu->insertItem ( "C&urrent Connection", TO_FILE_CURRENT );
    FileMenu->insertItem ( QPixmap ( ( const char ** ) trash_xpm ), "Reread Object Cache", TO_FILE_CLEARCACHE );
    FileMenu->insertSeparator();
    FileMenu->insertItem ( QPixmap ( ( const char ** ) fileopen_xpm ), "&Open File...", TO_FILE_OPEN );
    FileMenu->insertItem ( QPixmap ( ( const char ** ) filesave_xpm ), "&Save", TO_FILE_SAVE );
    FileMenu->insertItem ( "Save A&s...", TO_FILE_SAVE_AS );
    FileMenu->insertSeparator();
    FileMenu->insertItem ( QPixmap ( ( const char ** ) print_xpm ), "&Print..", TO_FILE_PRINT );
    FileMenu->insertSeparator();
    FileMenu->insertItem ( "&Quit", TO_FILE_QUIT );
    menuBar() ->insertItem ( "&File", FileMenu, TO_FILE_MENU );
    FileMenu->setAccel ( Key_G | CTRL, TO_NEW_CONNECTION );
    FileMenu->setAccel ( Key_O | CTRL, TO_FILE_OPEN );
    FileMenu->setAccel ( Key_S | CTRL, TO_FILE_SAVE );
    FileMenu->setAccel ( Key_W | CTRL, TO_FILE_COMMIT );
    FileMenu->setAccel ( Key_R | CTRL, TO_FILE_ROLLBACK );
    FileMenu->setAccel ( Key_U | CTRL, TO_FILE_CURRENT );
    connect ( FileMenu, SIGNAL ( aboutToShow() ), this, SLOT ( editFileMenu() ) );

    EditMenu = new QPopupMenu ( this );
    EditMenu->insertItem ( QPixmap ( ( const char ** ) undo_xpm ), "&Undo", TO_EDIT_UNDO );
    EditMenu->insertItem ( QPixmap ( ( const char ** ) redo_xpm ), "&Redo", TO_EDIT_REDO );
    EditMenu->insertSeparator();
    EditMenu->insertItem ( QPixmap ( ( const char ** ) cut_xpm ), "Cu&t", TO_EDIT_CUT );
    EditMenu->insertItem ( QPixmap ( ( const char ** ) copy_xpm ), "&Copy", TO_EDIT_COPY );
    EditMenu->insertItem ( QPixmap ( ( const char ** ) paste_xpm ), "&Paste", TO_EDIT_PASTE );
    EditMenu->insertSeparator();
    EditMenu->insertItem ( "&Search && Replace", TO_EDIT_SEARCH );
    EditMenu->insertItem ( "Search &Next", TO_EDIT_SEARCH_NEXT );
    EditMenu->insertItem ( "Select &All", TO_EDIT_SELECT_ALL );
    EditMenu->insertItem ( "Read All &Items", TO_EDIT_READ_ALL );
    EditMenu->insertSeparator();
    EditMenu->insertItem ( "&Options...", TO_EDIT_OPTIONS );
    EditMenu->setAccel ( Key_Z | CTRL, TO_EDIT_UNDO );
    EditMenu->setAccel ( Key_Y | CTRL, TO_EDIT_REDO );
    EditMenu->setAccel ( Key_X | CTRL, TO_EDIT_CUT );
    EditMenu->setAccel ( Key_C | CTRL, TO_EDIT_COPY );
    EditMenu->setAccel ( Key_V | CTRL, TO_EDIT_PASTE );
    EditMenu->setAccel ( Key_F | CTRL, TO_EDIT_SEARCH );
    EditMenu->setAccel ( Key_F3, TO_EDIT_SEARCH_NEXT );
    connect ( EditMenu, SIGNAL ( aboutToShow() ), this, SLOT ( editFileMenu() ) );
    menuBar() ->insertItem ( "&Edit", EditMenu, TO_EDIT_MENU );

    std::map<QString, toTool *> &tools = toTool::tools();

    QToolBar *toolbar = toAllocBar ( this, "Application", QString::null );

    LoadButton = new QToolButton ( QPixmap ( ( const char ** ) fileopen_xpm ),
                                   "Load file into editor",
                                   "Load file into editor",
                                   this, SLOT ( loadButton() ), toolbar );
    SaveButton = new QToolButton ( QPixmap ( ( const char ** ) filesave_xpm ),
                                   "Save file from editor",
                                   "Save file from editor",
                                   this, SLOT ( saveButton() ), toolbar );
    PrintButton = new QToolButton ( QPixmap ( ( const char ** ) print_xpm ),
                                    "Print",
                                    "Print",
                                    this, SLOT ( printButton() ), toolbar );
    PrintButton->setEnabled ( false );
    LoadButton->setEnabled ( false );
    SaveButton->setEnabled ( false );
    toolbar->addSeparator();
    UndoButton = new QToolButton ( QPixmap ( ( const char ** ) undo_xpm ),
                                   "Undo",
                                   "Undo",
                                   this, SLOT ( undoButton() ), toolbar );
    RedoButton = new QToolButton ( QPixmap ( ( const char ** ) redo_xpm ),
                                   "Redo",
                                   "Redo",
                                   this, SLOT ( redoButton() ), toolbar );
    CutButton = new QToolButton ( QPixmap ( ( const char ** ) cut_xpm ),
                                  "Cut to clipboard",
                                  "Cut to clipboard",
                                  this, SLOT ( cutButton() ), toolbar );
    CopyButton = new QToolButton ( QPixmap ( ( const char ** ) copy_xpm ),
                                   "Copy to clipboard",
                                   "Copy to clipboard",
                                   this, SLOT ( copyButton() ), toolbar );
    PasteButton = new QToolButton ( QPixmap ( ( const char ** ) paste_xpm ),
                                    "Paste from clipboard",
                                    "Paste from clipboard",
                                    this, SLOT ( pasteButton() ), toolbar );
    UndoButton->setEnabled ( false );
    RedoButton->setEnabled ( false );
    CutButton->setEnabled ( false );
    CopyButton->setEnabled ( false );
    PasteButton->setEnabled ( false );

    ToolsMenu = new QPopupMenu ( this );

#ifdef TOOL_TOOLBAR
    toolbar = new toAllocBar ( this, "Tools", QString::null );
#else
    toolbar->addSeparator();
#endif

    int toolID = TO_TOOLS;
    int lastPriorityPix = 0;
    int lastPriorityMenu = 0;
    SQLEditor = -1;
    DefaultTool = toolID;
    QString defName = toTool::globalConfig ( CONF_DEFAULT_TOOL, "" );

    HelpMenu = new QPopupMenu ( this );
    HelpMenu->insertItem ( "C&urrent Context", TO_HELP_CONTEXT );
    HelpMenu->insertItem ( "&Contents", TO_HELP_CONTENTS );
    HelpMenu->insertSeparator();
    HelpMenu->insertItem ( "&About TOra", TO_HELP_ABOUT );
    HelpMenu->insertItem ( "&License", TO_HELP_LICENSE );
    HelpMenu->insertItem ( "&Quotes", TO_HELP_QUOTES );
    HelpMenu->setAccel ( Key_F1, TO_HELP_CONTEXT );
    if ( !toFreeware() ) {
        HelpMenu->insertSeparator();
        HelpMenu->insertItem ( "&Register", TO_HELP_REGISTER );
    }
    QPopupMenu *toolAbout = NULL;

    for ( std::map<QString, toTool *>::iterator i = tools.begin();i != tools.end();i++ ) {
        const QPixmap *pixmap = ( *i ).second->toolbarImage();
        const char *toolTip = ( *i ).second->toolbarTip();
        const char *menuName = ( *i ).second->menuItem();

        QString tmp = ( *i ).second->name();
        tmp += CONF_TOOL_ENABLE;
        if ( toTool::globalConfig ( tmp, "Yes" ).isEmpty() )
            continue;

        if ( defName == menuName )
            DefaultTool = toolID;

        int priority = ( *i ).second->priority();
        if ( priority / 100 != lastPriorityPix / 100 &&
                pixmap ) {
            toolbar->addSeparator();
            lastPriorityPix = priority;
        }
        if ( priority / 100 != lastPriorityMenu / 100 &&
                menuName ) {
            ToolsMenu->insertSeparator();
            lastPriorityMenu = priority;
        }

        if ( pixmap ) {
            if ( !toolTip )
                toolTip = "";
            NeedConnection[new QToolButton ( *pixmap,
                                             toolTip,
                                             toolTip,
                                             ( *i ).second,
                                             SLOT ( createWindow ( void ) ),
                                             toolbar ) ] = ( *i ).second;
        }

        if ( menuName ) {
            if ( pixmap )
                ToolsMenu->insertItem ( *pixmap, menuName, toolID );
            else
                ToolsMenu->insertItem ( menuName, toolID );
            ToolsMenu->setItemEnabled ( toolID, false );
        }

        if ( ( *i ).second->hasAbout() && menuName ) {
            if ( !toolAbout ) {
                toolAbout = new QPopupMenu ( this );
                HelpMenu->insertItem ( "Tools", toolAbout );
            }
            if ( pixmap )
                toolAbout->insertItem ( *pixmap, menuName, toolID + TO_ABOUT_ID_OFFSET );
            else
                toolAbout->insertItem ( menuName, toolID + TO_ABOUT_ID_OFFSET );
        }

        Tools[toolID] = ( *i ).second;

        toolID++;
    }

#ifndef TOOL_TOOLBAR
    toolbar->setStretchableWidget ( new QLabel ( "", toolbar ) );
#endif

    new QToolButton ( QPixmap ( ( const char ** ) connect_xpm ),
                      "Connect to database",
                      "Connect to database",
                      this, SLOT ( addConnection() ), toolbar );
    DisconnectButton = new QToolButton ( QPixmap ( ( const char ** ) disconnect_xpm ),
                                         "Disconnect current connection",
                                         "Disconnect current connection",
                                         this, SLOT ( delConnection() ), toolbar );
    DisconnectButton->setEnabled ( false );
    toolbar->addSeparator();
    NeedConnection[new QToolButton ( QPixmap ( ( const char ** ) commit_xpm ),
                                     "Commit connection",
                                     "Commit connection",
                                     this,SLOT ( commitButton() ),toolbar ) ] = NULL;
    NeedConnection[new QToolButton ( QPixmap ( ( const char ** ) rollback_xpm ),
                                     "Rollback connection",
                                     "Rollback connection",
                                     this,SLOT ( rollbackButton() ),toolbar ) ] = NULL;
    toolbar->addSeparator();
    ConnectionSelection = new QComboBox ( toolbar );
    ConnectionSelection->setFixedWidth ( 200 );
    ConnectionSelection->setFocusPolicy ( NoFocus );
    connect ( ConnectionSelection, SIGNAL ( activated ( int ) ), this, SLOT ( changeConnection() ) );

    menuBar() ->insertItem ( "&Tools", ToolsMenu, TO_TOOLS_MENU );

    WindowsMenu = new QPopupMenu ( this );
    WindowsMenu->setCheckable ( true );
    connect ( WindowsMenu, SIGNAL ( aboutToShow() ), this, SLOT ( windowsMenu() ) );
    menuBar() ->insertItem ( "&Window", WindowsMenu, TO_WINDOWS_MENU );

    menuBar() ->insertSeparator();

    menuBar() ->insertItem ( "&Help", HelpMenu, TO_HELP_MENU );

    char buffer[100];
    sprintf ( buffer, DEFAULT_TITLE, TOVERSION );
    setCaption ( buffer );

#ifdef TO_KDE
    KDockWidget *mainDock = createDockWidget ( buffer, QPixmap ( ( const char ** ) toramini_xpm ) );
    Workspace = new QWorkspace ( mainDock );
    mainDock->setWidget ( Workspace );
    setView ( mainDock );
    setMainDockWidget ( mainDock );
    mainDock->setEnableDocking ( KDockWidget::DockNone );
#else
    Workspace = new QWorkspace ( this );
    setCentralWidget ( Workspace );
#endif
    setIcon ( QPixmap ( ( const char ** ) toramini_xpm ) );

    statusBar() ->message ( "Ready" );
    menuBar() ->setItemEnabled ( TO_CLOSE_CONNECTION, false );
    menuBar() ->setItemEnabled ( TO_FILE_COMMIT, false );
    menuBar() ->setItemEnabled ( TO_FILE_ROLLBACK, false );
    menuBar() ->setItemEnabled ( TO_FILE_CLEARCACHE, false );
    DisconnectButton->setEnabled ( false );

    for ( std::map<QToolButton *, toTool *>::iterator j = NeedConnection.begin();
            j != NeedConnection.end();j++ )
        ( *j ).first->setEnabled ( false );

    connect ( menuBar(), SIGNAL ( activated ( int ) ), this, SLOT ( commandCallback ( int ) ) );

    RowLabel = new QLabel ( statusBar() );
    statusBar() ->addWidget ( RowLabel, 0, true );
    RowLabel->setMinimumWidth ( 60 );
    RowLabel->hide();

    ColumnLabel = new QLabel ( statusBar() );
    statusBar() ->addWidget ( ColumnLabel, 0, true );
    ColumnLabel->setMinimumWidth ( 60 );
    ColumnLabel->hide();

    QToolButton *dispStatus = new toPopupButton ( statusBar() );
    dispStatus->setIconSet ( QPixmap ( ( const char ** ) up_xpm ) );
    statusBar() ->addWidget ( dispStatus, 0, true );
    StatusMenu = new QPopupMenu ( dispStatus );
    dispStatus->setPopup ( StatusMenu );
    connect ( StatusMenu, SIGNAL ( aboutToShow() ),
              this, SLOT ( statusMenu() ) );
    connect ( StatusMenu, SIGNAL ( activated ( int ) ), this, SLOT ( commandCallback ( int ) ) );

    toolID = TO_TOOLS;
    for ( std::map<QString, toTool *>::iterator k = tools.begin();k != tools.end();k++ ) {
        ( *k ).second->customSetup ( toolID );
        toolID++;
    }
    Search = NULL;

    if ( !toTool::globalConfig ( CONF_MAXIMIZE_MAIN, "Yes" ).isEmpty() )
        showMaximized();
    show();

    QString welcome;

    do {
        welcome = toCheckLicense ( false );
    } while ( welcome.isNull() );

    toStatusMessage ( welcome, true );

    connect ( &Poll, SIGNAL ( timeout() ), this, SLOT ( checkCaching() ) );

    try {
        toNewConnection newConnection ( this, "First connection", true );

        toConnection *conn;

        do {
            conn = NULL;
            if ( newConnection.exec() ) {
                conn = newConnection.makeConnection();
            } else {
                break;
            }
        } while ( !conn );

        if ( conn )
            addConnection ( conn );
    }
    TOCATCH
    connect ( toMainWidget() ->workspace(), SIGNAL ( windowActivated ( QWidget * ) ),
              this, SLOT ( windowActivated ( QWidget * ) ) );
}
Beispiel #6
0
HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name )
    : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
{
    readHistory();
    readBookmarks();

    browser = new QTextBrowser( this );
    QStringList Strlist;
    Strlist.append( home_);

    browser->mimeSourceFactory()->setFilePath( Strlist );

    browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );

    connect( browser, SIGNAL( textChanged() ),

             this, SLOT( textChanged() ) );

    setCentralWidget( browser );

    if ( !home_.isEmpty() )

////////////////////////////////
        browser->setSource( home_ );

////////////////////////////////
    connect( browser, SIGNAL( highlighted(const QString&) ),
       statusBar(), SLOT( message(const QString&)) );

    setGeometry( 0,0,236,280);

    QPopupMenu* file = new QPopupMenu( this );
//    file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N );
    file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
//    file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P );
    file->insertSeparator();
    file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q );
//    file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X );

    // The same three icons are used twice each.
////F FIXME
    QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/";
    QIconSet icon_back( QPixmap(pixs+"back.png") );
    QIconSet icon_forward( QPixmap(pixs+"forward.png") );
    QIconSet icon_home( QPixmap(pixs+"home.png") );

    QPopupMenu* go = new QPopupMenu( this );
    backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left );
    forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right );
    go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) );


    hist = new QPopupMenu( this );
    QStringList::Iterator it = history.begin();
    for ( ; it != history.end(); ++it )
    mHistory[ hist->insertItem( *it ) ] = *it;
    connect( hist, SIGNAL( activated(int) ), this, SLOT( histChosen(int) ) );

    bookm = new QPopupMenu( this );
    bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
    bookm->insertSeparator();

    QStringList::Iterator it2 = bookmarks.begin();
    for ( ; it2 != bookmarks.end(); ++it2 )
   mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
    connect( bookm, SIGNAL( activated(int) ),
       this, SLOT( bookmChosen(int) ) );

    menuBar()->insertItem( tr("&File"), file );
    menuBar()->insertItem( tr("&Go"), go );
    menuBar()->insertItem( tr( "History" ), hist );
    menuBar()->insertItem( tr( "Bookmarks" ), bookm );
//      menuBar()->insertSeparator();
//      menuBar()->insertItem( tr("&Help"), help );

    menuBar()->setItemEnabled( forwardId, FALSE);
    menuBar()->setItemEnabled( backwardId, FALSE);
    connect( browser, SIGNAL( backwardAvailable(bool) ), this, SLOT( setBackwardAvailable(bool) ) );
    connect( browser, SIGNAL( forwardAvailable(bool) ), this, SLOT( setForwardAvailable(bool) ) );


    QToolBar* toolbar = new QToolBar( this );
    addToolBar( toolbar, "Toolbar");
    QToolButton* button;

    button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar );
    connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
    button->setEnabled( FALSE );
    button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar );
    connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
    button->setEnabled( FALSE );
    new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar );

    toolbar->addSeparator();

    pathCombo = new QComboBox( TRUE, toolbar );
    connect( pathCombo, SIGNAL( activated(const QString&) ), this, SLOT( pathSelected(const QString&) ) );
    toolbar->setStretchableWidget( pathCombo );

//    pathCombo->setMaximumWidth(190);
//     setRightJustification( TRUE );
//      setDockEnabled( Left, FALSE );
//      setDockEnabled( Right, FALSE );

    pathCombo->insertItem( home_ );

    browser->setFocus();


}
Beispiel #7
0
MainView::MainView(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl)
{
	setIcon( Resource::loadPixmap( "remote" ) );
	setCaption(tr("uBrowser"));

	setToolBarsMovable( false );

	QToolBar *toolbar = new QToolBar(this, "toolbar");
	back = new QToolButton(Resource::loadPixmap("ubrowser/back"), 0, 0, 0, 0, toolbar, "back");
	forward = new QToolButton(Resource::loadPixmap("ubrowser/forward"), 0, 0, 0, 0, toolbar, "forward");
	home = new QToolButton(Resource::loadPixmap("ubrowser/home"), 0, 0, 0, 0, toolbar, "home");
	location = new QComboBox(true, toolbar, "location");
	go = new QToolButton(Resource::loadPixmap("ubrowser/go"), 0, 0, 0, 0, toolbar, "go");

	toolbar->setStretchableWidget(location);
	toolbar->setHorizontalStretchable(true);
	location->setAutoCompletion( true );

	addToolBar(toolbar);

	browser = new QTextBrowser(this, "browser");
	setCentralWidget(browser);

//make the button take you to the location
	connect(go, SIGNAL(clicked()), this, SLOT(goClicked()) );
	connect(location->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goClicked()) );

//make back, forward and home do their thing (isnt QTextBrowser great?)
	connect(back, SIGNAL(clicked()), browser, SLOT(backward()) );
	connect(forward, SIGNAL(clicked()), browser, SLOT(forward()) );
	connect(home, SIGNAL(clicked()), browser, SLOT(home()) );

//make back and forward buttons be enabled, only when you can go back or forward (again, i love QTextBrowser)
//this doesnt seem to work, but doesnt break anything either...
	connect(browser, SIGNAL(backwardAvailable(bool)), back, SLOT(setOn(bool)) );
	connect(browser, SIGNAL(forwardAvailable(bool)), forward, SLOT(setOn(bool)) );

//notify me when the text of the browser has changed (like when the user clicks a link)
	connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()) );

	http = new HttpFactory(browser);

	if( qApp->argc() > 1 )
	{
		char **argv = qApp->argv();
		int i = 0;
		QString *openfile = new QString( argv[0] );
		while( openfile->contains( "ubrowser" ) == 0 && i < qApp->argc() )
		{
			i++;
			*openfile = argv[i];
		}
		*openfile = argv[i+1];
		if( !openfile->startsWith( "http://" ) && !openfile->startsWith( "/" ) )
		{
			openfile->insert( 0, QDir::currentDirPath()+"/" );
		}
		location->setEditText( *openfile );
		goClicked();
	}
}
Beispiel #8
0
void MainWindow::makeMenu()
{
    QToolBar *toolBar = new QToolBar( this );
    QToolBar *searchBar = new QToolBar(this);
    QMenuBar *menuBar = new QMenuBar( toolBar );
    QPopupMenu *searchMenu = new QPopupMenu( menuBar );
//    QPopupMenu *viewMenu = new QPopupMenu( menuBar );
    QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
    QPopupMenu *searchOptions = new QPopupMenu( cfgMenu );

    setToolBarsMovable( false );
    toolBar->setHorizontalStretchable( true );
    menuBar->insertItem( tr( "Search" ), searchMenu );
    menuBar->insertItem( tr( "Settings" ), cfgMenu );

    //SETTINGS MENU
    cfgMenu->insertItem( tr( "Search" ), searchOptions );
    QPopupMenu *pop;
    for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
        pop = s->popupMenu();
        if (pop){
            cfgMenu->insertItem( s->text(0), pop );
        }
    }


    //SEARCH
    SearchAllAction = new QAction( tr("Search all"),QString::null,  0, this, 0 );
    SearchAllAction->setIconSet( Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ) );
//    QWhatsThis::add( SearchAllAction, tr("Search everything...") );
    connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) );
    SearchAllAction->addTo( searchMenu );
    searchMenu->insertItem( tr( "Options" ), searchOptions );

    //SEARCH OPTIONS
    //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null,  0, this, 0, true );
    //actionWholeWordsOnly->addTo( searchOptions );
    actionCaseSensitiv = new QAction( tr("Case sensitive"),QString::null,  0, this, 0, true );
    actionCaseSensitiv->addTo( searchOptions );
    actionWildcards = new QAction( tr("Use wildcards"),QString::null,  0, this, 0, true );
    actionWildcards->addTo( searchOptions );

    //SEARCH BAR
    LabelEnterText = new QLabel( searchBar, "Label" );
    LabelEnterText->setAutoMask( FALSE );
    LabelEnterText->setText( tr( "Search for: " ) );
    LabelEnterText->setFrameStyle( QFrame::NoFrame );
    LabelEnterText->setBackgroundMode( PaletteButton );

    addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
    QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
    QWhatsThis::add( searchEdit, tr("Enter your search terms here") );
    searchEdit->setFocus();
    searchBar->setHorizontalStretchable( TRUE );
    searchBar->setStretchableWidget( searchEdit );

    //Search button
    SearchAllAction->addTo( searchBar );

    //Clear text
    ClearSearchText = new QToolButton( searchBar, "ClearSearchText");
    ClearSearchText->setText( "" );
    ClearSearchText->setPixmap( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) );

    connect( searchEdit, SIGNAL( textChanged(const QString&) ),this, SLOT( setSearch(const QString&) ) );
    connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) );
}
Beispiel #9
0
void FileMainWindow::setup()
{
    QSplitter *splitter = new QSplitter( this );

    dirlist = new DirectoryView( splitter, "dirlist", TRUE );
    dirlist->addColumn( "Name" );
    dirlist->addColumn( "Type" );
    Directory *root = new Directory( dirlist, "/" );
    root->setOpen( TRUE );
    splitter->setResizeMode( dirlist, QSplitter::KeepSize );

    fileview = new QtFileIconView( "/", splitter );
    fileview->setSelectionMode( QIconView::Extended );

    setCentralWidget( splitter );

    QToolBar *toolbar = new QToolBar( this, "toolbar" );
    setRightJustification( TRUE );

    (void)new QLabel( tr( " Path: " ), toolbar );

    pathCombo = new QComboBox( TRUE, toolbar );
    pathCombo->setAutoCompletion( TRUE );
    toolbar->setStretchableWidget( pathCombo );
    connect( pathCombo, SIGNAL( activated( const QString & ) ),
	     this, SLOT ( changePath( const QString & ) ) );

    toolbar->addSeparator();

    QPixmap pix;

    pix = QPixmap( cdtoparent_xpm );
    upButton = new QToolButton( pix, "One directory up", QString::null,
				this, SLOT( cdUp() ), toolbar, "cd up" );

    pix = QPixmap( newfolder_xpm );
    mkdirButton = new QToolButton( pix, "New Folder", QString::null,
				   this, SLOT( newFolder() ), toolbar, "new folder" );

    connect( dirlist, SIGNAL( folderSelected( const QString & ) ),
	     fileview, SLOT ( setDirectory( const QString & ) ) );
    connect( fileview, SIGNAL( directoryChanged( const QString & ) ),
	     this, SLOT( directoryChanged( const QString & ) ) );
    connect( fileview, SIGNAL( startReadDir( int ) ),
	     this, SLOT( slotStartReadDir( int ) ) );
    connect( fileview, SIGNAL( readNextDir() ),
	     this, SLOT( slotReadNextDir() ) );
    connect( fileview, SIGNAL( readDirDone() ),
	     this, SLOT( slotReadDirDone() ) );

    setDockEnabled( DockLeft, FALSE );
    setDockEnabled( DockRight, FALSE );

    label = new QLabel( statusBar() );
    statusBar()->addWidget( label, 2, TRUE );
    progress = new QProgressBar( statusBar() );
    statusBar()->addWidget( progress, 1, TRUE );

    connect( fileview, SIGNAL( enableUp() ),
	     this, SLOT( enableUp() ) );
    connect( fileview, SIGNAL( disableUp() ),
	     this, SLOT( disableUp() ) );
    connect( fileview, SIGNAL( enableMkdir() ),
	     this, SLOT( enableMkdir() ) );
    connect( fileview, SIGNAL( disableMkdir() ),
	     this, SLOT( disableMkdir() ) );
}