Exemple #1
0
void MainPanel::pressButtonSlot(int button)
{
    switch(button)
    {
    case CommandButtons::BUTTON_VIEW:
        viewCommand();
        break;

    case CommandButtons::BUTTON_EDIT:
        editCommand();
        break;

    case CommandButtons::BUTTON_COPY:
        copyCommand();
        break;

    case CommandButtons::BUTTON_MOVE:
        moveCommand();
        break;

    case CommandButtons::BUTTON_MK_DIR:
        mkdirCommand();
        break;

    case CommandButtons::BUTTON_DELETE:
        deleteCommand();
        break;

    case CommandButtons::BUTTON_EXIT:
        exitCommand();
        break;
    }
}
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()));
}
Exemple #3
0
void MainPanel::keyPressEvent(QKeyEvent* event)
{
    if(event == NULL)
        return QWidget::keyPressEvent(event);

    switch(event->key())
    {
    case Qt::Key_Left:
    case Qt::Key_Right:
        m_line->setFocus();
        break;

    case Qt::Key_F3:
        viewCommand();
        break;

    case Qt::Key_F4:
        editCommand();
        break;

    case Qt::Key_F5:
        copyCommand();
        break;

    case Qt::Key_F6:
        moveCommand();
        break;

    case Qt::Key_F7:
        mkdirCommand();
        break;

    case Qt::Key_F8:
        deleteCommand();
        break;
    }

    if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right)
        m_line->setFocus();
}
Exemple #4
0
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
}