void *CommandsDefPrivate::processEvent(Event *e) { CommandDef *def; list<CommandDef>::iterator it; switch (e->type()){ case EventCommandCreate: def = (CommandDef*)(e->param()); if (((m_bMenu ? def->menu_id : def->bar_id) == m_id) && (m_bMenu || def->icon)){ if (addCommand(def)) cfg.clear(); } break; case EventCommandChange: def = (CommandDef*)(e->param()); for (it = buttons.begin(); it != buttons.end(); ++it){ if ((*it).id == def->id){ *it = *def; break; } } break; case EventCommandRemove: if (delCommand((unsigned)(e->param()))) cfg.clear(); break; } return NULL; }
CustomActionsSettings::CustomActionsSettings(QWidget *parent) : QWidget(parent) , dlg(0) { QGridLayout *layout=new QGridLayout(this); layout->setMargin(0); QLabel *label=new QLabel(i18n("To have Cantata call external commands (e.g. to edit tags with another application), add an entry for the command below. When at least one command " "command is defined, a 'Custom Actions' entry will be added to the context menus in the Library, Folders, and Playlists views."), this); label->setWordWrap(true); layout->addWidget(label, 0, 0, 1, 2); tree=new QTreeWidget(this); add=new QPushButton(this); edit=new QPushButton(this); del=new QPushButton(this); layout->addWidget(tree, 1, 0, 4, 1); layout->addWidget(add, 1, 1, 1, 1); layout->addWidget(edit, 2, 1, 1, 1); layout->addWidget(del, 3, 1, 1, 1); layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding), 4, 1); add->setText(i18n("Add")); edit->setText(i18n("Edit")); del->setText(i18n("Remove")); add->setIcon(Icons::self()->addIcon); edit->setIcon(Icons::self()->editIcon); del->setIcon(Icons::self()->removeIcon); edit->setEnabled(false); del->setEnabled(false); tree->setHeaderLabels(QStringList() << i18n("Name") << i18n("Command")); tree->setAllColumnsShowFocus(true); tree->setSelectionMode(QAbstractItemView::ExtendedSelection); tree->setRootIsDecorated(false); tree->setSortingEnabled(true); setResizeMode(tree->header(), 0, QHeaderView::ResizeToContents); tree->header()->setStretchLastSection(true); tree->setAlternatingRowColors(false); tree->setItemDelegate(new BasicItemDelegate(this)); connect(tree, SIGNAL(itemSelectionChanged()), this, SLOT(controlButtons())); connect(add, SIGNAL(clicked()), SLOT(addCommand())); connect(edit, SIGNAL(clicked()), SLOT(editCommand())); connect(del, SIGNAL(clicked()), SLOT(delCommand())); }
void hotnews_unload(void) { delCommand("hotnews"); }
QxPreferences::QxPreferences(Ref<CharcoalDirectory> charcoalDirectory, QWidget* parent) : QxDialog(parent), charcoalDirectory_(charcoalDirectory), themeManager_(charcoalDirectory->themeManager()), paletteManager_(charcoalDirectory->paletteManager()) { setWindowTitle(qApp->applicationName() + " - Preferences"); #ifdef Q_WS_MAC #ifndef QT_MAC_USE_COCOA setAttribute(Qt::WA_MacShowFocusRect, false); #endif // QT_MAC_USE_COCOA #endif // Q_WS_MAC QGridLayout* grid = new QGridLayout(this); { tabs_ = new QTabWidget(this); tabs_->setElideMode(Qt::ElideNone); tabs_->setUsesScrollButtons(false); grid->addWidget(tabs_, 0, 0); // grid->setMargin(12); } { editor_ = new QxEditorPreferences(tabs_); tabs_->insertTab(tabs_->count(), editor_, tr("Editor")); editor_->fontSize_->setRange(8, 32); editor_->lineSpacing_->setRange(0, 32); editor_->tabWidth_->setRange(2, 32); editor_->indentWidth_->setRange(1, 32); connect(editor_->tabIndentMode_, SIGNAL(toggled(bool)), editor_->indentWidth_, SLOT(setDisabled(bool))); editor_->tabIndentMode_->setChecked(true); connect(editor_->font_, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(updateEditorFontOption(const QFont&))); connect(editor_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int))); connect(editor_->fontAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool))); connect(editor_->subpixelAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool))); connect(editor_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int))); connect(editor_->showLineNumbers_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool))); connect(editor_->showWhitespace_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool))); connect(editor_->tabWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int))); connect(editor_->autoIndent_, SIGNAL(toggled(bool)), this, SIGNAL(editorAutoIndentChanged(bool))); connect(editor_->tabIndentMode_, SIGNAL(toggled(bool)), this, SLOT(updateEditorIndent(bool))); connect(editor_->indentWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIndent(int))); } { terminal_ = new QxTerminalPreferences; tabs_->insertTab(tabs_->count(), terminal_, tr("Terminal")); terminal_->fontSize_->setRange(8, 32); terminal_->lineSpacing_->setRange(0, 32); terminal_->numberOfLines_->setRange(100000, 1000000); terminal_->numberOfLines_->setSingleStep(100000); terminal_->title_->addItems( QString( "$TITLE," "$FG," "$USER@$HOST," "$USER@$FQHOST," "$USER@$HOST:$CWD," "$FG [$USER@$HOST]," "$FG [$USER@$HOST]:$CWD" ).split(",") ); terminal_->title_->setCurrentIndex(5); connect(terminal_->font_, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(updateTerminalFontOption(const QFont&))); connect(terminal_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int))); connect(terminal_->fontAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool))); connect(terminal_->subpixelAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool))); connect(terminal_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int))); connect(terminal_->endlessLogging_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalEndlessLogging(bool))); connect(terminal_->numberOfLines_, SIGNAL(valueChanged(int)), this, SIGNAL(terminalNumberOfLinesChanged(int))); connect(terminal_->endlessLogging_, SIGNAL(toggled(bool)), terminal_->numberOfLines_, SLOT(setDisabled(bool))); connect(terminal_->title_, SIGNAL(activated(const QString&)), this, SIGNAL(terminalTitleChanged(const QString&))); QStringList paletteNames; for (int i = 0, n = paletteManager_->numPalette(); i < n; ++i) { Ref<Palette> palette = paletteManager_->paletteByIndex(i); if (palette->numColors() >= QxVideoTerminal::NumColors) { paletteNames << paletteManager_->paletteByIndex(i)->displayName(); paletteIndices_.append(i); } } QStringListModel* model = new QStringListModel(paletteNames, terminal_->palette_); terminal_->palette_->setModel(model); connect(terminal_->palette_, SIGNAL(activated(int)), this, SLOT(terminalPaletteActivated(int))); } { printing_ = new QxPrintingPreferences(tabs_); tabs_->insertTab(tabs_->count(), printing_, tr("Printing")); printing_->fontSize_->setRange(8, 32); printing_->lineSpacing_->setRange(0, 32); } /* { // performance HACK to reduce application launch time editor_->font_->setDisabled(true); terminal_->font_->setDisabled(true); printing_->font_->setDisabled(true); #ifdef Q_WS_MAC // visual HACK editor_->font_->setFixedWidth(editor_->font_->sizeHint().width()); #endif #if 0 editor_->font_->setMinimumContentsLength(20); editor_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); terminal_->font_->setMinimumContentsLength(20); terminal_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); printing_->font_->setMinimumContentsLength(20); printing_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); #endif QTimer::singleShot(0, this, SLOT(startFontFilter())); } */ { themesView_ = new QListView(tabs_); themesView_->setViewMode(QListView::IconMode); themesView_->setMovement(QListView::Static); themesView_->setResizeMode(QListView::Adjust); themesView_->setFlow(QListView::LeftToRight); // themesView_->setSpacing(10); tabs_->insertTab(tabs_->count(), themesView_, tr("Theme")); themesView_->setModel(new QxThemesModel(charcoalDirectory_, themesView_)); connect( themesView_->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(themeActivate(const QModelIndex&, const QModelIndex&)) ); } { commands_ = new QxCommandsPreferences(tabs_); tabs_->insertTab(tabs_->count(), commands_, tr("Commands")); connect(commands_->add_, SIGNAL(clicked()), this, SLOT(addCommand())); connect(commands_->edit_, SIGNAL(clicked()), this, SLOT(editCommand())); connect(commands_->del_, SIGNAL(clicked()), this, SLOT(delCommand())); connect(commands_->import_, SIGNAL(clicked()), this, SLOT(importConfig())); connect(commands_->export_, SIGNAL(clicked()), this, SLOT(exportConfig())); commandsList_ = new QxCommandsList; commandsModel_ = new QxCommandsModel(commandsList_); commands_->view_->setModel(commandsModel_); commands_->view_->setHeaderHidden(false); } { codetips_ = new QxCodetipsPreferences(this, tabs_); tabs_->insertTab(tabs_->count(), codetips_, tr("Code Tips")); } { misc_ = new QxMiscPreferences(tabs_); tabs_->insertTab(tabs_->count(), misc_, tr("Misc")); misc_->scrollingSpeed_->setRange(1, 6); misc_->scrollingSpeed_->setValue(3); misc_->kinematicScrolling_->setChecked(true); misc_->scrollingSpeed_->setEnabled(false); connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), misc_->scrollingSpeed_, SLOT(setDisabled(bool))); connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool))); connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool))); connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int))); connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int))); connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(setWheelScrollLines(int))); } /*{ config_ = new QxImportExportPreferences(tabs_); tabs_->insertTab(5, config_, tr("Import/Export")); config_->commands_->setChecked(true); connect(config_->import_, SIGNAL(pressed()), this, SLOT(importConfig())); connect(config_->export_, SIGNAL(pressed()), this, SLOT(exportConfig())); }*/ QFontComboBox::FontFilters filters = QFontComboBox::MonospacedFonts|QFontComboBox::ScalableFonts; editor_->font_->setFontFilters(filters); terminal_->font_->setFontFilters(filters); printing_->font_->setFontFilters(filters); #ifndef QT_MAC_USE_COCOA resize(524, 390); // visual HACK #else resize(599, 421); // visual HACK #endif }
tCmd * pC() { tCmd * cmd; simpleCmd * smpl = newCommand(); clearLexList(pSt.list); if (cur_l->type != LEX_WORD) { setParserError(PE_EXPECTED_WORD); delCommand(&smpl); return NULL; } addLex(pSt.list, pSt.l); for(;;) { if (gl()) { clearLexList(pSt.list); delCommand(&smpl); return NULL; } if (cur_l->type == LEX_WORD) addLex(pSt.list, pSt.l); else if (cur_l->type == LEX_REDIRECT_INPUT || cur_l->type == LEX_REDIRECT_OUTPUT || cur_l->type == LEX_REDIRECT_OUTPUT_APPEND) { int type = cur_l->type; if (glhard()) { clearLexList(pSt.list); delCommand(&smpl); return NULL; } if (cur_l->type != LEX_WORD) { setParserError(PE_EXPECTED_WORD); if(smpl->rdrInputFile != NULL) free(smpl->rdrInputFile); if(smpl->rdrOutputFile != NULL) free(smpl->rdrOutputFile); delCommand(&smpl); delLex(cur_l); clearLexList(pSt.list); return NULL; } if (type == LEX_REDIRECT_INPUT) { if(smpl->rdrInputFile != NULL) free(smpl->rdrInputFile); smpl->rdrInputFile = cur_l->str; } else if (type == LEX_REDIRECT_OUTPUT || type == LEX_REDIRECT_OUTPUT_APPEND) { if (type == LEX_REDIRECT_OUTPUT_APPEND) smpl->rdrOutputAppend = 1; else smpl->rdrOutputAppend = 0; if(smpl->rdrOutputFile != NULL) free(smpl->rdrOutputFile); smpl->rdrOutputFile = cur_l->str; } } else break; } genArgVector(smpl, pSt.list); smpl->file = smpl->argv[0]; cmd = genTCmd(smpl); cmd->cmdType = TCMD_SIMPLE; return cmd; }
void message_unload(void) { delCommand("message"); }