Ejemplo n.º 1
0
/*
   When the button in the filter box toggles:
   If off:
   If the name filer is anything but "" or "*", reset it.
   If on:
   Set last filter.
*/
void KateFileSelector::btnFilterClick()
{
  if ( !btnFilter->isOn() ) {
    slotFilterChange( TQString::null );
  }
  else {
    filter->lineEdit()->setText( lastFilter );
    slotFilterChange( lastFilter );
  }
}
Ejemplo n.º 2
0
void KateFileSelector::readConfig(TDEConfig *config, const TQString & name)
{
  dir->setViewConfig( config, name + ":view" );
  dir->readConfig(config, name + ":dir");
  dir->setView( KFile::Default );
  dir->view()->setSelectionMode(KFile::Extended);
  config->setGroup( name );

  // set up the toolbar
  setupToolbar( config );

  cmbPath->setMaxItems( config->readNumEntry( "pathcombo history len", 9 ) );
  cmbPath->setURLs( config->readPathListEntry( "dir history" ) );
  // if we restore history
  if ( config->readBoolEntry( "restore location", true ) || kapp->isRestored() ) {
    TQString loc( config->readPathEntry( "location" ) );
    if ( ! loc.isEmpty() ) {
//       waitingDir = loc;
//       TQTimer::singleShot(0, this, TQT_SLOT(initialDirChangeHack()));
      setDir( loc );
    }
  }

  // else is automatic, as cmpPath->setURL is called when a location is entered.

  filter->setMaxCount( config->readNumEntry( "filter history len", 9 ) );
  filter->setHistoryItems( config->readListEntry("filter history"), true );
  lastFilter = config->readEntry( "last filter" );
  TQString flt("");
  if ( config->readBoolEntry( "restore last filter", true ) || kapp->isRestored() )
    flt = config->readEntry("current filter");
  filter->lineEdit()->setText( flt );
  slotFilterChange( flt );

  autoSyncEvents = config->readNumEntry( "AutoSyncEvents", 0 );
}
Ejemplo n.º 3
0
KateFileBrowser::KateFileBrowser(Kate::MainWindow *mainWindow,
                                 QWidget * parent, const char * name)
  : KVBox (parent)
  , m_mainWindow(mainWindow)
{
  setObjectName(name);

  m_toolbar = new KToolBar(this);
  m_toolbar->setMovable(false);
  m_toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
  m_toolbar->setContextMenuPolicy(Qt::NoContextMenu);

  // includes some actions, but not hooked into the shortcut dialog atm
  m_actionCollection = new KActionCollection(this);
  m_actionCollection->addAssociatedWidget(this);

  KFilePlacesModel* model = new KFilePlacesModel(this);
  m_urlNavigator = new KUrlNavigator(model, KUrl(QDir::homePath()), this);
  connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)), SLOT(updateDirOperator(KUrl)));

  m_dirOperator = new KDirOperator(KUrl(), this);
  m_dirOperator->setView(KFile::/* Simple */Detail);
  m_dirOperator->view()->setSelectionMode(QAbstractItemView::ExtendedSelection);
  m_dirOperator->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));

  // Mime filter for the KDirOperator
  QStringList filter;
  filter << "text/plain" << "text/html" << "inode/directory";
  m_dirOperator->setNewFileMenuSupportedMimeTypes(filter);

  setFocusProxy(m_dirOperator);
  connect(m_dirOperator, SIGNAL(viewChanged(QAbstractItemView*)),
          this, SLOT(selectorViewChanged(QAbstractItemView*)));
  connect(m_urlNavigator, SIGNAL(returnPressed()),
          m_dirOperator, SLOT(setFocus()));
  // now all actions exist in dir operator and we can use them in the toolbar
  setupActions();
  setupToolbar();

  KHBox* filterBox = new KHBox(this);

  QLabel* filterLabel = new QLabel(i18n("Filter:"), filterBox);
  m_filter = new KHistoryComboBox(true, filterBox);
  filterLabel->setBuddy(m_filter);
  m_filter->setMaxCount(10);
  m_filter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));

  connect(m_filter, SIGNAL(editTextChanged(QString)),
          SLOT(slotFilterChange(QString)));
  connect(m_filter, SIGNAL(returnPressed(QString)),
          m_filter, SLOT(addToHistory(QString)));
  connect(m_filter, SIGNAL(returnPressed(QString)),
          m_dirOperator, SLOT(setFocus()));

  connect(m_dirOperator, SIGNAL(urlEntered(KUrl)),
          this, SLOT(updateUrlNavigator(KUrl)));

  // Connect the bookmark handler
  connect(m_bookmarkHandler, SIGNAL(openUrl(QString)),
          this, SLOT(setDir(QString)));

  m_filter->setWhatsThis(i18n("Enter a name filter to limit which files are displayed."));

  connect(m_dirOperator, SIGNAL(fileSelected(KFileItem)), this, SLOT(fileSelected(KFileItem)));
  connect(m_mainWindow, SIGNAL(viewChanged()), this, SLOT(autoSyncFolder()));
}
Ejemplo n.º 4
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();
}