Exemple #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 );
}
Exemple #2
0
TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
        QMainWindow( parent, name, f )
{
    shutDown=false;
    nextUnnamed=0;
    currentView=0;
    viewCount=0;
    setCaption(tr("TinyKATE"));
    KGlobal::setAppName("TinyKATE");

    QMenuBar *mb = new QMenuBar( this );
    mb->setMargin( 0 );

    tabwidget=new OTabWidget(this);
    setCentralWidget(tabwidget);
    connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*)));

    //FILE ACTIONS
    QPopupMenu *popup = new QPopupMenu( this );

    // Action for creating a new document
    QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
                              QString::null, 0, this, 0 );
    a->addTo( popup );
    connect(a, SIGNAL(activated()), this, SLOT(slotNew()));

    // Action for opening an exisiting document
    a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    a->addTo(popup);
    connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));


    // Action for saving  document
    a = new QAction( tr( "Save" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    a->addTo(popup);
    connect(a, SIGNAL(activated()), this, SLOT(slotSave()));

    // Action for saving document to a new name
    a = new QAction( tr( "Save As" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    a->addTo(popup);
    connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));

    // Action for closing the currently active document
    a = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    a->addTo(popup);
    connect(a, SIGNAL(activated()), this, SLOT(slotClose()));


    mb->insertItem(tr("File"),popup);

    //EDIT ACTIONS
    popup = new QPopupMenu( this );
    bool useBigIcon = qApp->desktop()->size().width() > 330;

    // Action for cutting text
    editCut = new QToolButton( 0 );
    editCut->setUsesBigPixmap( useBigIcon );
    editCut->setAutoRaise( true );
    editCut->setIconSet( Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ) );

    // Action for Copying text
    editCopy = new QToolButton( 0 );
    editCopy->setUsesBigPixmap( useBigIcon );
    editCopy->setAutoRaise( true );
    editCopy->setIconSet( Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ) );

    // Action for pasting text
    editPaste =  new QToolButton( 0 );
    editPaste->setUsesBigPixmap( useBigIcon );
    editPaste->setAutoRaise( true );
    editPaste->setIconSet( Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ) );

    // Action for finding text
    editFind = new QAction( tr( "Find..." ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    editFind->addTo(popup);

    // Action for replacing text
    editReplace = new QAction( tr( "Replace..." ), QString::null, 0, this, 0 );
    editReplace->addTo(popup);

    // Action for going to a specific line
    editGotoLine = new QAction( tr( "Goto Line..." ), QString::null, 0, this, 0 );
    editGotoLine->addTo(popup);

    // Action for undo
    editUndo = new QToolButton( 0 );
    editUndo->setUsesBigPixmap( useBigIcon );
    editUndo->setAutoRaise( true );
    editUndo->setIconSet( Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ) );

    // Action for redo
    editRedo = new QToolButton( 0 );
    editRedo->setUsesBigPixmap( useBigIcon );
    editRedo->setAutoRaise( true );
    editRedo->setIconSet( Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ) );

    mb->insertItem(tr("Edit"),popup);

    //VIEW ACITONS
    popup = new QPopupMenu( this );

    viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
    viewIncFontSizes->addTo( popup );

    viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
    viewDecFontSizes->addTo( popup );

    mb->insertItem(tr("View"),popup);

    popup = new QPopupMenu( this );
    mb->insertItem(tr("Utils"),popup);


    mb->insertItem( editCut );
    mb->insertItem( editCopy );
    mb->insertItem( editPaste );
    mb->insertItem( editUndo );
    mb->insertItem(  editRedo );


    //Highlight management
    hlmenu=new QPopupMenu(this);
    HlManager *hlm=HlManager::self();
    for (int i=0;i<hlm->highlights();i++)
    {
        hlmenu->insertItem(hlm->hlName(i),i);
    }
    popup->insertItem(tr("Highlighting"),hlmenu);


    utilSettings = new QAction( tr( "Settings" ),
                                Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
                                QString::null, 0, this, 0 );
    utilSettings->addTo( popup);

    if( qApp->argc() > 1) open(qApp->argv()[1]);
    else slotNew();

}
Exemple #3
0
void MainWindow::initUI()
{
    // Build menu and tool bars
    setToolBarsMovable( false );

    m_menuBar.setHorizontalStretchable( true );
    QMenuBar *mb = new QMenuBar( &m_menuBar );
    mb->setMargin( 0 );

    // Find toolbar
    addToolBar( &m_findBar, QMainWindow::Top, true );
    m_findBar.setHorizontalStretchable( true );
    m_findEdit = new QLineEdit( &m_findBar );
    QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
    m_findBar.setStretchableWidget( m_findEdit );
    connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) );

    // Packages menu
    QPopupMenu *popup = new QPopupMenu( this );

    QAction *a = new QAction( tr( "Update lists" ), Opie::Core::OResource::loadPixmap( "packagemanager/update",
                              Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to update package lists from servers." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
    a->addTo( popup );
    a->addTo( &m_toolBar );

    QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Opie::Core::OResource::loadPixmap( "packagemanager/upgrade",
                                          Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) );
    connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
    actionUpgrade->addTo( popup );
    actionUpgrade->addTo( &m_toolBar );

    QPixmap iconDownload = Opie::Core::OResource::loadPixmap( "packagemanager/download", Opie::Core::OResource::SmallIcon );
    QPixmap iconRemove = Opie::Core::OResource::loadPixmap( "packagemanager/remove", Opie::Core::OResource::SmallIcon );
    QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
    actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) );
    connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
#ifndef USE_LIBOPKG
    actionDownload->addTo( popup );
    actionDownload->addTo( &m_toolBar );
#endif

    a = new QAction( tr( "Apply changes" ), Opie::Core::OResource::loadPixmap( "packagemanager/apply",
                     Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
    a->addTo( popup );
    a->addTo( &m_toolBar );

    a = new QAction( tr( "Install local package" ), Opie::Core::OResource::loadPixmap( "folder",
                     Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to install a package file located on device." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) );
    a->addTo( popup );
    //a->addTo( &m_toolBar );

    popup->insertSeparator();

    a = new QAction( tr( "Configure" ), Opie::Core::OResource::loadPixmap( "SettingsIcon",
                     Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to configure this application." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
    a->addTo( popup );
    mb->insertItem( tr( "Actions" ), popup );

    // View menu
    popup = new QPopupMenu( this );

    m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
    m_actionShowNotInstalled->setToggleAction( true );
    m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) );
    connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
    m_actionShowNotInstalled->addTo( popup );

    m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
    m_actionShowInstalled->setToggleAction( true );
    m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) );
    connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
    m_actionShowInstalled->addTo( popup );

    m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
    m_actionShowUpdated->setToggleAction( true );
    m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) );
    connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
    m_actionShowUpdated->addTo( popup );

    popup->insertSeparator();

    m_actionFilter = new QAction( tr( "Filter" ), Opie::Core::OResource::loadPixmap( "packagemanager/filter",
                                  Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    m_actionFilter->setToggleAction( true );
    m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) );
    connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
    m_actionFilter->addTo( popup );

    a = new QAction( tr( "Filter settings" ),  QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
    a->addTo( popup );

    popup->insertSeparator();

    a = new QAction( tr( "Find" ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to search for text in package names." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
    a->addTo( popup );

    m_actionFindNext = new QAction( tr( "Find next" ), Opie::Core::OResource::loadPixmap( "next",
                                    Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
    m_actionFindNext->setEnabled( false );
    m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) );
    connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
    m_actionFindNext->addTo( popup );
    m_actionFindNext->addTo( &m_findBar );

    mb->insertItem( tr( "View" ), popup );

    // Finish find toolbar creation
    a = new QAction( QString::null, Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),
                     QString::null, 0, this, 0 );
    a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) );
    connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) );
    a->addTo( &m_findBar );
    m_findBar.hide();
}
Exemple #4
0
void AdvancedFm::init() {
    b = false;
    setCaption( tr( "AdvancedFm" ) );

//    QFrame* frame = new QFrame(this);
//    setCentralWidget(frame);
//    QVBoxLayout *layout = new QVBoxLayout( frame );

    QVBoxLayout *layout = new QVBoxLayout( this);
    layout->setSpacing( 2);
    layout->setMargin( 0); // squeeze

    QMenuBar *menuBar = new QMenuBar(this);
    menuBar->setMargin( 0 ); // squeeze
    fileMenu = new QPopupMenu( this );
    viewMenu  = new QPopupMenu( this );
//    customDirMenu  = new QPopupMenu( this );

    layout->addWidget( menuBar );

    menuBar->insertItem( tr( "File" ), fileMenu);
    menuBar->insertItem( tr( "View" ), viewMenu);
    connect(fileMenu,SIGNAL(aboutToShow()),this,SLOT(enableDisableMenu()));

    bool useBigIcon = qApp->desktop()->size().width() > 330;

    cdUpButton = new QToolButton( 0,"cdUpButton");
    cdUpButton->setUsesBigPixmap( useBigIcon );
    cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) );
    cdUpButton->setAutoRaise( true );
    menuBar->insertItem( cdUpButton );

    qpeDirButton= new QToolButton( 0,"QPEButton");
    qpeDirButton->setUsesBigPixmap( useBigIcon );
    qpeDirButton->setPixmap( Opie::Core::OResource::loadPixmap( "logo/opielogo", Opie::Core::OResource::SmallIcon ) );
    qpeDirButton->setAutoRaise( true );
    menuBar->insertItem( qpeDirButton );

    fsButton = new OFileSystemButton( 0 );
    fsButton->setUsesBigPixmap( useBigIcon );
    fsButton->setAutoRaise( true );
    menuBar->insertItem( fsButton );

    docButton = new QToolButton( 0,"docsButton");
    docButton->setUsesBigPixmap( useBigIcon );
    docButton->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) );
    docButton->setAutoRaise( true );
    menuBar->insertItem( docButton );

    homeButton = new QToolButton( 0, "homeButton");
    homeButton->setUsesBigPixmap( useBigIcon );
    homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) );
    homeButton->setAutoRaise( true );
    menuBar->insertItem( homeButton );

//    fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() ));
//    fileMenu->insertSeparator();
    fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ), 0, 101);
    fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() ), 0, 102);
    fileMenu->insertSeparator();
    fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ), 0, 103);
    fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ), 0, 104);
    fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ), 0, 105);
    fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ), 0, 106);
    fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ), 0, 107);
    fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ), 0, 108);

    viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab()));
    viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab()));
    viewMenu->insertSeparator();
    viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab()));
    viewMenu->insertSeparator();
    viewMenu->insertItem( tr( "Show Hidden Files" ), this,  SLOT( showMenuHidden() ));
//    viewMenu->insertSeparator();
//    viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
    viewMenu->setCheckable(true);
    viewMenu->setItemChecked( viewMenu->idAt(0), true);
    viewMenu->setItemChecked( viewMenu->idAt(1), false);
    viewMenu->setItemChecked( viewMenu->idAt(5), false);

    s_addBookmark = tr("Bookmark Directory");
    s_removeBookmark = tr("Remove Current Directory from Bookmarks");

//    menuButton->insertItem("");

//    customDirMenu->insertItem(tr("Add This Directory"));
//    customDirMenu->insertItem(tr("Remove This Directory"));
//    customDirMenu->insertSeparator();

    QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later
    CBHB->setMargin( 0 );
    CBHB->setSpacing( 1 );

    menuButton = new MenuButton( this );

    menuButton->setUseLabel(false);
    menuButton->setMaximumWidth( 20 );
    menuButton->insertItem( s_addBookmark);
    menuButton->insertItem( s_removeBookmark);
    menuButton->insertSeparator();
//    menuButton->setFocusPolicy(NoFocus);
    CBHB->addWidget( menuButton );

    customDirsToMenu();

    currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
    currentPathCombo->setEditable(TRUE);
    currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
//    currentPathCombo->setFocusPolicy(NoFocus);
    CBHB->addWidget( currentPathCombo );

    layout->addLayout( CBHB );

    TabWidget = new OSplitter( Horizontal, this, "TabWidget" );
//    TabWidget = new QTabWidget( this, "TabWidget" );
    layout->addWidget( TabWidget, 4 );

    tab = new QWidget( TabWidget, "tab" );
    tabLayout = new QGridLayout( tab );
    tabLayout->setSpacing( 2);
    tabLayout->setMargin( 2);

    Local_View = new QListView( tab, "Local_View" );
    Local_View->addColumn( tr("File"),130);
    Local_View->addColumn( tr("Size"),-1);
    Local_View->setColumnAlignment(1,QListView::AlignRight);
    Local_View->addColumn( tr("Date"),-1);
    Local_View->setColumnAlignment(2,QListView::AlignRight);
    Local_View->setAllColumnsShowFocus(TRUE);
    Local_View->setMultiSelection( TRUE );
    Local_View->setSelectionMode(QListView::Extended);
    Local_View->setFocusPolicy(StrongFocus);
    Local_View->installEventFilter( this );

    QPEApplication::setStylusOperation( Local_View->viewport() , QPEApplication::RightOnHold);

    tabLayout->addWidget( Local_View, 0, 0 );

    TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1"));
//    TabWidget->insertTab( tab, tr("1"));

    tab_2 = new QWidget( TabWidget, "tab_2" );
    tabLayout_2 = new QGridLayout( tab_2 );
    tabLayout_2->setSpacing( 2);
    tabLayout_2->setMargin( 2);

    Remote_View = new QListView( tab_2, "Remote_View" );
    Remote_View->addColumn( tr("File"),130);
    Remote_View->addColumn( tr("Size"),-1);
    Remote_View->setColumnAlignment(1,QListView::AlignRight);
    Remote_View->addColumn( tr("Date"),-1);
    Remote_View->setColumnAlignment(2,QListView::AlignRight);
    Remote_View->setAllColumnsShowFocus(TRUE);
    Remote_View->setMultiSelection( TRUE );
    Remote_View->setSelectionMode(QListView::Extended);
    Remote_View->setFocusPolicy(StrongFocus);
    Remote_View->installEventFilter( this );

    QPEApplication::setStylusOperation( Remote_View->viewport(), QPEApplication::RightOnHold);

    tabLayout_2->addWidget( Remote_View, 0, 0 );

    TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
    TabWidget->setSizeChange( 370 );
//    TabWidget->insertTab( tab_2, tr( "2"));

    /*     tab_3 = new QWidget( TabWidget, "tab_3" );
                    tabLayout_3 = new QGridLayout( tab_3 );
                    tabLayout_3->setSpacing( 2);
                    tabLayout_3->setMargin( 2);


                    //     OFileDialog fileDialog;
                    // fileDialog;
                    //    fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
                    //     fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
                    //      OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");

                    QListView *fileTree;
                    fileTree = new QListView( tab_3, "tree" );


                    tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );

                    TabWidget->insertTab( tab_3, tr( "Remote" ) );
    */

    ///////////////

    currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
    currentDir.setPath( QDir::currentDirPath());

    currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
    currentRemoteDir.setPath( QDir::currentDirPath());

    filterStr="*";
    showHidden();
    TabWidget->setCurrentWidget(0);
}