KexiFindDialog::KexiFindDialog(QWidget* parent) : QDialog(parent, Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::Tool) , d(new Private()) { setObjectName("KexiFindDialog"); setupUi(this); m_search->setCurrentIndex( (int)KexiSearchAndReplaceViewInterface::Options::SearchDown); layout()->setMargin(KDialog::marginHint()); layout()->setSpacing(KDialog::spacingHint()); KAction *a = KStandardAction::findNext(0, 0, 0); m_btnFind->setText(a->text()); m_btnFind->setIcon(KIcon(a->icon())); delete a; m_btnClose->setText(KStandardGuiItem::close().text()); m_btnClose->setIcon(KStandardGuiItem::close().icon()); connect(m_btnFind, SIGNAL(clicked()), this, SIGNAL(findNext())); connect(m_btnClose, SIGNAL(clicked()), this, SLOT(slotCloseClicked())); connect(m_btnReplace, SIGNAL(clicked()), this, SIGNAL(replaceNext())); connect(m_btnReplaceAll, SIGNAL(clicked()), this, SIGNAL(replaceAll())); // clear message after the text is changed connect(m_textToFind, SIGNAL(editTextChanged(const QString&)), this, SLOT(updateMessage(const QString&))); connect(m_textToReplace, SIGNAL(editTextChanged(const QString&)), this, SLOT(updateMessage(const QString&))); d->replaceMode = true; //to force updating by setReplaceMode() setReplaceMode(false); setLookInColumnList(QStringList(), QStringList()); }
void ActionConfigDialog::slotEditToolbar() { QString toolbarName; QString toolbarId; QListViewItem *oldItem; QListViewItem *item = actionTreeView->currentItem(); if (item->parent()) item = item->parent(); toolbarName = item->text(0); if ( toolbarName != i18n("All")) { emit configureToolbars(toolbarName +" <quanta>"); //update the tree view KAction *action; KActionCollection *ac = m_mainWindow->actionCollection(); ToolbarTabWidget *tb = ToolbarTabWidget::ref(); for (int i = 0; i < tb->count(); i++) { toolbarName = tb->label(i); toolbarId = tb->id(i); ToolbarEntry *p_toolbar = m_toolbarList[toolbarId]; if (p_toolbar) { oldItem = actionTreeView->findItem(toolbarName, 0); item = new KListViewItem(actionTreeView, oldItem, toolbarName); item->setOpen(oldItem->isOpen()); delete oldItem; QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild(); while (!node.isNull()) { if (node.nodeName() == "Action") { action = ac->action(node.toElement().attribute("name")); if (action) { oldItem = new KListViewItem(item, oldItem, action->text().replace(QRegExp("\\&(?!\\&)"),""), action->shortcut().toString(), action->name()); oldItem->setPixmap(0, SmallIcon(action->icon())); } } node = node.nextSibling(); } } } actionTreeView->setCurrentItem(allActionsItem); actionTreeView->setSelected(allActionsItem, true); } }
void KFSConfigPage::init() { KConfig *config = kapp->config(); config->setGroup( "fileselector" ); // toolbar QStringList l = config->readListEntry( "toolbar actions", ',' ); if ( l.isEmpty() ) // default toolbar l << "up" << "back" << "forward" << "home" << "short view" << "detailed view" << "bookmarks" << "sync_dir"; // actions from diroperator + two of our own QStringList allActions; allActions << "up" << "back" << "forward" << "home" << "reload" << "mkdir" << "delete" << "short view" << "detailed view" /*<< "view menu" << "show hidden" << "properties"*/ << "bookmarks" << "sync_dir"; QRegExp re("&(?=[^&])"); KAction *ac; QListBox *lb; for ( QStringList::Iterator it=allActions.begin(); it != allActions.end(); ++it ) { lb = l.contains( *it ) ? acSel->selectedListBox() : acSel->availableListBox(); if ( *it == "bookmarks" || *it == "sync_dir" ) ac = fileSelector->actionCollection()->action( (*it).latin1() ); else ac = fileSelector->dirOperator()->actionCollection()->action( (*it).latin1() ); if ( ac ) new ActionLBItem( lb, SmallIcon( ac->icon() ), ac->text().replace( re, "" ), *it ); } // sync int s = fileSelector->autoSyncEvents; cbSyncActive->setChecked( s & KateFileSelector::DocumentChanged ); cbSyncShow->setChecked( s & KateFileSelector::GotVisible ); // histories sbPathHistLength->setValue( fileSelector->cmbPath->maxItems() ); sbFilterHistLength->setValue( fileSelector->filter->maxCount() ); // session cbSesLocation->setChecked( config->readBoolEntry( "restore location", true ) ); cbSesFilter->setChecked( config->readBoolEntry( "restore last filter", true ) ); }
DvbEpgDialog::DvbEpgDialog(DvbManager *manager_, QWidget *parent) : KDialog(parent), manager(manager_) { setButtons(KDialog::Close); setCaption(i18nc("@title:window", "Program Guide")); QWidget *widget = new QWidget(this); QBoxLayout *mainLayout = new QHBoxLayout(widget); epgChannelTableModel = new DvbEpgChannelTableModel(this); epgChannelTableModel->setManager(manager); channelView = new QTreeView(widget); channelView->setMaximumWidth(30 * fontMetrics().averageCharWidth()); channelView->setModel(epgChannelTableModel); channelView->setRootIsDecorated(false); channelView->setUniformRowHeights(true); connect(channelView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(channelActivated(QModelIndex))); mainLayout->addWidget(channelView); QBoxLayout *rightLayout = new QVBoxLayout(); QBoxLayout *boxLayout = new QHBoxLayout(); KAction *scheduleAction = new KAction(QIcon::fromTheme(QLatin1String("media-record")), i18nc("@action:inmenu tv show", "Record Show"), this); connect(scheduleAction, SIGNAL(triggered()), this, SLOT(scheduleProgram())); QPushButton *pushButton = new QPushButton(scheduleAction->icon(), scheduleAction->text(), widget); connect(pushButton, SIGNAL(clicked()), this, SLOT(scheduleProgram())); boxLayout->addWidget(pushButton); boxLayout->addWidget(new QLabel(i18nc("@label:textbox", "Search:"), widget)); epgTableModel = new DvbEpgTableModel(this); epgTableModel->setEpgModel(manager->getEpgModel()); connect(epgTableModel, SIGNAL(layoutChanged()), this, SLOT(checkEntry())); KLineEdit *lineEdit = new KLineEdit(widget); lineEdit->setClearButtonShown(true); connect(lineEdit, SIGNAL(textChanged(QString)), epgTableModel, SLOT(setContentFilter(QString))); boxLayout->addWidget(lineEdit); rightLayout->addLayout(boxLayout); epgView = new QTreeView(widget); epgView->addAction(scheduleAction); epgView->header()->setResizeMode(QHeaderView::ResizeToContents); epgView->setContextMenuPolicy(Qt::ActionsContextMenu); epgView->setMinimumWidth(75 * fontMetrics().averageCharWidth()); epgView->setModel(epgTableModel); epgView->setRootIsDecorated(false); epgView->setUniformRowHeights(true); connect(epgView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(entryActivated(QModelIndex))); rightLayout->addWidget(epgView); contentLabel = new QLabel(widget); contentLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); contentLabel->setMargin(5); contentLabel->setWordWrap(true); QScrollArea *scrollArea = new QScrollArea(widget); scrollArea->setBackgroundRole(QPalette::Light); scrollArea->setMinimumHeight(12 * fontMetrics().height()); scrollArea->setWidget(contentLabel); scrollArea->setWidgetResizable(true); rightLayout->addWidget(scrollArea); mainLayout->addLayout(rightLayout); setMainWidget(widget); }
void MainWindow::selectPlugin( Kontact::Plugin *plugin ) { if ( !plugin ) return; if ( plugin->isRunningStandalone() ) { statusBar()->message( i18n( "Application is running standalone. Foregrounding..." ), 1000 ); mSidePane->indicateForegrunding( plugin ); plugin->bringToForeground(); return; } KApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) ); KParts::Part *part = plugin->part(); if ( !part ) { KApplication::restoreOverrideCursor(); KMessageBox::error( this, i18n( "Cannot load part for %1." ) .arg( plugin->title() ) + "\n" + lastErrorMessage() ); plugin->setDisabled( true ); mSidePane->updatePlugins(); return; } // store old focus widget QWidget *focusWidget = kapp->focusWidget(); if ( mCurrentPlugin && focusWidget ) { // save the focus widget only when it belongs to the activated part QWidget *parent = focusWidget->parentWidget(); while ( parent ) { if ( parent == mCurrentPlugin->part()->widget() ) mFocusWidgets.insert( mCurrentPlugin->identifier(), QGuardedPtr<QWidget>( focusWidget ) ); parent = parent->parentWidget(); } } if ( mSidePane ) mSidePane->selectPlugin( plugin ); plugin->select(); mPartManager->setActivePart( part ); QWidget *view = part->widget(); Q_ASSERT( view ); if ( view ) { mPartsStack->raiseWidget( view ); view->show(); if ( mFocusWidgets.contains( plugin->identifier() ) ) { focusWidget = mFocusWidgets[ plugin->identifier() ]; if ( focusWidget ) focusWidget->setFocus(); } else view->setFocus(); mCurrentPlugin = plugin; KAction *newAction = plugin->newActions()->first(); KAction *syncAction = plugin->syncActions()->first(); createGUI( plugin->part() ); KToolBar* navigatorToolBar = findToolBar( "navigatorToolBar" ); // Let the navigator toolbar be always the last one, if it's in the top dockwindow if ( navigatorToolBar && !navigatorToolBar->isHidden() && navigatorToolBar->barPos() == KToolBar::Top ) { topDock()->moveDockWindow( navigatorToolBar, -1 ); } setCaption( i18n( "Plugin dependent window title" ,"%1 - Kontact" ).arg( plugin->title() ) ); if ( newAction ) { mNewActions->setIcon( newAction->icon() ); mNewActions->setText( newAction->text() ); } else { // we'll use the action of the first plugin which offers one PluginList::Iterator it; for ( it = mPlugins.begin(); it != mPlugins.end(); ++it ) { newAction = (*it)->newActions()->first(); if ( newAction ) { mNewActions->setIcon( newAction->icon() ); mNewActions->setText( newAction->text() ); break; } } } if ( mSyncActionsEnabled ) { if ( syncAction ) { mSyncActions->setIcon( syncAction->icon() ); mSyncActions->setText( syncAction->text() ); } else { // we'll use the action of the first plugin which offers one PluginList::Iterator it; for ( it = mPlugins.begin(); it != mPlugins.end(); ++it ) { syncAction = (*it)->syncActions()->first(); if ( syncAction ) { mSyncActions->setIcon( syncAction->icon() ); mSyncActions->setText( syncAction->text() ); break; } } } } } QStringList invisibleActions = plugin->invisibleToolbarActions(); QStringList::ConstIterator it; for ( it = invisibleActions.begin(); it != invisibleActions.end(); ++it ) { KAction *action = part->actionCollection()->action( (*it).latin1() ); if ( action ) { QPtrListIterator<KToolBar> it( toolBarIterator() ); for ( ; it.current() ; ++it ) { action->unplug( it.current() ); } } } KApplication::restoreOverrideCursor(); }
ActionConfigDialog::ActionConfigDialog(const QDict<ToolbarEntry> &toolbarList, KMainWindow* parent, const char* name, bool modal, WFlags fl, const QString& defaultAction ) :ActionConfigDialogS( parent, name, modal, fl ) { m_mainWindow = parent; m_toolbarList = toolbarList; buttonOk->setIconSet(SmallIconSet("button_ok")); buttonCancel->setIconSet(SmallIconSet("button_cancel")); buttonApply->setIconSet(SmallIconSet("apply")); //buttonHelp->setIconSet(SmallIconSet("help")); currentAction = 0L; m_toolbarItem = 0L; connect(actionTreeView, SIGNAL(contextMenu(KListView *,QListViewItem *,const QPoint &)), SLOT(slotContextMenu(KListView *,QListViewItem *,const QPoint &))); connect(actionTreeView, SIGNAL(selectionChanged(QListViewItem *)), SLOT(slotSelectionChanged(QListViewItem *))); connect(shortcutKeyButton, SIGNAL(capturedShortcut(const KShortcut &)), SLOT(slotShortcutCaptured(const KShortcut &))); connect(scriptPath, SIGNAL(activated(const QString&)), SLOT(slotTextChanged(const QString&))); connect(this, SIGNAL(addToolbar()), m_mainWindow, SLOT(slotAddToolbar())); connect(this, SIGNAL(removeToolbar(const QString&)), m_mainWindow, SLOT(slotRemoveToolbar(const QString&))); connect(this, SIGNAL(deleteUserAction(KAction*)), m_mainWindow, SLOT(slotDeleteAction(KAction*))); connect(this, SIGNAL(configureToolbars(const QString&)), m_mainWindow, SLOT(slotConfigureToolbars(const QString&))); //fill up the tree view with the toolbars and actions actionTreeView->setSorting(-1); allActionsItem = new KListViewItem(actionTreeView, i18n("All")); actionTreeView->insertItem(allActionsItem); QListViewItem *item, *oldItem = allActionsItem; KAction *action; QString toolbarName; QString toolbarId; ToolbarTabWidget *tb = ToolbarTabWidget::ref(); QRegExp r("\\&(?!\\&)"); KActionCollection *ac = m_mainWindow->actionCollection(); for (int i = 0; i < tb->count(); i++) { toolbarName = tb->label(i); toolbarName.replace(r, ""); item = new KListViewItem(actionTreeView, oldItem, i18n(toolbarName.utf8())); actionTreeView->insertItem(item); toolbarId = tb->id(i); QListViewItem *oldActionItem = 0L; ToolbarEntry *p_toolbar = m_toolbarList[toolbarId]; if (p_toolbar) { QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild(); while (!node.isNull()) { if (node.nodeName() == "Action") { action = ac->action(node.toElement().attribute("name")); if (action) { oldActionItem = new KListViewItem(item, oldActionItem, action->text().replace(r,""), action->shortcut().toString(), action->name()); oldActionItem->setPixmap(0, SmallIcon(action->icon()) ); } } node = node.nextSibling(); } if (tb->label(tb->currentPageIndex()).replace(r, "") == toolbarName) { item->setOpen(true); if (item->firstChild()) { if (defaultAction.isEmpty()) { actionTreeView->setCurrentItem(item->firstChild()); } else { QListViewItem *actionItem = item->firstChild(); while (actionItem && actionItem->depth() > 0) { if (actionItem->text(0) == defaultAction || actionItem->text(0) == defaultAction + "...") { actionTreeView->setCurrentItem(actionItem); break; } actionItem = actionItem->nextSibling(); } } } } } oldItem = item; } uint acCount = ac->count(); for (uint i = 0; i < acCount; i++) { action = ac->action(i); item = new KListViewItem(allActionsItem, action->text().replace(r, ""), action->shortcut().toString(), action->name()); item->setPixmap(0, SmallIcon(action->icon()) ); } allActionsItem->sortChildItems(0, true); treeMenu = new KPopupMenu(actionTreeView); treeMenu->insertItem(i18n("&Add New Toolbar"), this, SLOT(slotAddToolbar())); treeMenu->insertItem(i18n("&Remove Toolbar"), this, SLOT(slotRemoveToolbar())); treeMenu->insertItem(i18n("&Edit Toolbar"), this, SLOT(slotEditToolbar())); globalShortcuts = KGlobal::config()->entryMap( "Global Shortcuts" ); }