void KComboBox::setLineEdit( QLineEdit *edit ) { if ( !editable() && edit && !qstrcmp( edit->className(), "QLineEdit" ) ) { // uic generates code that creates a read-only KComboBox and then // calls combo->setEditable( true ), which causes QComboBox to set up // a dumb QLineEdit instead of our nice KLineEdit. // As some KComboBox features rely on the KLineEdit, we reject // this order here. delete edit; edit = new KLineEdit( this, "combo edit" ); } QComboBox::setLineEdit( edit ); d->klineEdit = dynamic_cast<KLineEdit*>( edit ); setDelegate( d->klineEdit ); // Connect the returnPressed signal for both Q[K]LineEdits' if (edit) connect( edit, SIGNAL( returnPressed() ), SIGNAL( returnPressed() )); if ( d->klineEdit ) { // someone calling KComboBox::setEditable( false ) destroys our // lineedit without us noticing. And KCompletionBase::delegate would // be a dangling pointer then, so prevent that. Note: only do this // when it is a KLineEdit! connect( edit, SIGNAL( destroyed() ), SLOT( lineEditDeleted() )); connect( d->klineEdit, SIGNAL( returnPressed( const QString& )), SIGNAL( returnPressed( const QString& ) )); connect( d->klineEdit, SIGNAL( completion( const QString& )), SIGNAL( completion( const QString& )) ); connect( d->klineEdit, SIGNAL( substringCompletion( const QString& )), SIGNAL( substringCompletion( const QString& )) ); connect( d->klineEdit, SIGNAL( textRotation( KCompletionBase::KeyBindingType )), SIGNAL( textRotation( KCompletionBase::KeyBindingType )) ); connect( d->klineEdit, SIGNAL( completionModeChanged( KGlobalSettings::Completion )), SIGNAL( completionModeChanged( KGlobalSettings::Completion))); connect( d->klineEdit, SIGNAL( aboutToShowContextMenu( QPopupMenu * )), SIGNAL( aboutToShowContextMenu( QPopupMenu * )) ); connect( d->klineEdit, SIGNAL( completionBoxActivated( const QString& )), SIGNAL( activated( const QString& )) ); }
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : QWidget(parent), m_topLayout(0), m_urlNavigator(0), m_searchBox(0), m_view(0), m_filterBar(0), m_statusBar(0), m_statusBarTimer(0), m_statusBarTimestamp() { hide(); m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); m_topLayout->setMargin(0); m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)), this, SLOT(dropUrls(const KUrl&, QDropEvent*))); connect(m_urlNavigator, SIGNAL(activated()), this, SLOT(activate())); connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion))); const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); m_urlNavigator->setUrlEditable(settings->editableUrl()); m_urlNavigator->setShowFullPath(settings->showFullPath()); m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl())); KUrlComboBox* editor = m_urlNavigator->editor(); editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode())); m_searchBox = new DolphinSearchBox(this); m_searchBox->hide(); connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox())); connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(startSearching(QString))); connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus())); m_view = new DolphinView(url, this); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(itemTriggered(KFileItem)), this, SLOT(slotItemTriggered(KFileItem))); connect(m_view, SIGNAL(redirection(KUrl, KUrl)), this, SLOT(redirect(KUrl, KUrl))); connect(m_view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(slotStartedPathLoading())); connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotFinishedPathLoading())); connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateProgress(int))); connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(urlIsFileError(const KUrl&)), this, SLOT(openFile(const KUrl&))); connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(operationCompletedMessage(const QString&)), this, SLOT(showOperationCompletedMessage(const QString&))); connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&))); connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(const KUrl&)), this, SLOT(saveViewState())); connect(m_urlNavigator, SIGNAL(historyChanged()), this, SLOT(slotHistoryChanged())); // initialize status bar m_statusBar = new DolphinStatusBar(this, m_view); connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopLoading())); m_statusBarTimer = new QTimer(this); m_statusBarTimer->setSingleShot(true); m_statusBarTimer->setInterval(300); connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self(); connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), this, SLOT(delayedStatusBarUpdate())); // initialize filter bar m_filterBar = new FilterBar(this); m_filterBar->setVisible(settings->filterBar()); connect(m_filterBar, SIGNAL(filterChanged(const QString&)), this, SLOT(setNameFilter(const QString&))); connect(m_filterBar, SIGNAL(closeRequest()), this, SLOT(closeFilterBar())); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_filterBar, SLOT(clear())); m_topLayout->addWidget(m_urlNavigator); m_topLayout->addWidget(m_searchBox); m_topLayout->addWidget(m_view); m_topLayout->addWidget(m_filterBar); m_topLayout->addWidget(m_statusBar); setSearchModeEnabled(isSearchUrl(url)); }
DictApplet::DictApplet(const QString& configFile, Type type, int actions, QWidget *parent, const char *name) : KPanelApplet(configFile, type, actions, parent, name), waiting(0) { // first the widgets for a horizontal panel baseWidget = new QWidget(this); QGridLayout *baseLay = new QGridLayout(baseWidget,2,6,0,1); textLabel = new QLabel(i18n("Dictionary:"), baseWidget); textLabel->setBackgroundOrigin(AncestorOrigin); QFont f(textLabel->font()); f.setPixelSize(12); textLabel->setFont(f); baseLay->addWidget(textLabel,0,1); QToolTip::add(textLabel,i18n("Look up a word or phrase with Kdict")); iconLabel = new QLabel(baseWidget); iconLabel->setBackgroundOrigin(AncestorOrigin); QPixmap pm = KGlobal::iconLoader()->loadIcon("kdict", KIcon::Panel, KIcon::SizeSmall, KIcon::DefaultState, 0L, true); iconLabel->setPixmap(pm); baseLay->addWidget(iconLabel,1,0); iconLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); iconLabel->setFixedWidth(pm.width()+4); QToolTip::add(iconLabel,i18n("Look up a word or phrase with Kdict")); f.setPixelSize(10); clipboardBtn = new QPushButton(i18n("C"),baseWidget); clipboardBtn->setBackgroundOrigin(AncestorOrigin); clipboardBtn->setFont(f); clipboardBtn->setFixedSize(16,16); connect(clipboardBtn, SIGNAL(clicked()), SLOT(queryClipboard())); baseLay->addWidget(clipboardBtn,0,3); QToolTip::add(clipboardBtn,i18n("Define selected text")); defineBtn = new QPushButton(i18n("D"),baseWidget); defineBtn->setBackgroundOrigin(AncestorOrigin); defineBtn->setFont(f); defineBtn->setFixedSize(16,16); defineBtn->setEnabled(false); connect(defineBtn, SIGNAL(clicked()), SLOT(startDefine())); baseLay->addWidget(defineBtn,0,4); QToolTip::add(defineBtn,i18n("Define word/phrase")); matchBtn = new QPushButton(i18n("M"),baseWidget); matchBtn->setBackgroundOrigin(AncestorOrigin); matchBtn->setFont(f); matchBtn->setFixedSize(16,16); matchBtn->setEnabled(false); connect(matchBtn, SIGNAL(clicked()), SLOT(startMatch())); baseLay->addWidget(matchBtn,0,5); QToolTip::add(matchBtn,i18n("Find matching definitions")); completionObject = new KCompletion(); internalCombo = new KHistoryCombo(baseWidget); internalCombo->setBackgroundOrigin(AncestorOrigin); internalCombo->setCompletionObject(completionObject); internalCombo->setFocus(); internalCombo->clearEdit(); internalCombo->lineEdit()->installEventFilter( this ); connect(internalCombo, SIGNAL(returnPressed(const QString&)), SLOT(startQuery(const QString&))); connect(internalCombo, SIGNAL(textChanged(const QString&)), SLOT(comboTextChanged(const QString&))); QToolTip::add(internalCombo,i18n("Look up a word or phrase with Kdict")); baseLay->addMultiCellWidget(internalCombo,1,1,1,5); baseLay->setColStretch(2,1); // widgets for a vertical panel verticalBtn = new QPushButton(this); connect(verticalBtn, SIGNAL(pressed()), SLOT(showExternalCombo())); QToolTip::add(verticalBtn,i18n("Look up a word or phrase with Kdict")); popupBox = new PopupBox(); popupBox->setFixedSize(160, 22); connect(popupBox, SIGNAL(hidden()), SLOT(externalComboHidden())); externalCombo = new KHistoryCombo(popupBox); externalCombo->setCompletionObject(completionObject); connect(externalCombo, SIGNAL(returnPressed(const QString&)), SLOT(startQuery(const QString&))); externalCombo->setFixedSize(160, externalCombo->sizeHint().height()); connect(internalCombo, SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(updateCompletionMode(KGlobalSettings::Completion))); connect(externalCombo, SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(updateCompletionMode(KGlobalSettings::Completion))); // restore history and completion list KConfig *c = config(); c->setGroup("General"); QStringList list = c->readListEntry("Completion list"); completionObject->setItems(list); int mode = c->readNumEntry("Completion mode", KGlobalSettings::completionMode()); internalCombo->setCompletionMode((KGlobalSettings::Completion)mode); externalCombo->setCompletionMode((KGlobalSettings::Completion)mode); list = c->readListEntry("History list"); internalCombo->setHistoryItems(list); externalCombo->setHistoryItems(list); }