Esempio n. 1
0
void LiteEditor::createActions()
{
    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor");

    m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this);
    actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo);

    m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this);
    actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y");

    m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this);
    actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut);

    m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this);
    actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy);

    m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this);
    actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste);

    m_selectAllAct = new QAction(tr("Select All"),this);
    actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll);

    m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this);
#ifndef QT_NO_PRINTER
    m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this);
    m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this);
    m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this);
#endif
    m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this);
    actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+[");

    m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this);
    actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]");


    m_selectBlockAct = new QAction(tr("Select Block"),this);
    actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U");

    m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this);
    actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E");

    m_foldAct = new QAction(tr("Fold"),this);   
    actionContext->regAction(m_foldAct,"Fold","Ctrl+<");

    m_unfoldAct = new QAction(tr("Unfold"),this);
    actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>");

    m_foldAllAct = new QAction(tr("Fold All"),this);
    actionContext->regAction(m_foldAllAct,"FoldAll","");

    m_unfoldAllAct = new QAction(tr("Unfold All"),this);
    actionContext->regAction(m_unfoldAllAct,"UnfoldAll","");

    connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold()));
    connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold()));
    connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll()));
    connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll()));

    m_gotoLineAct = new QAction(tr("Go To Line"),this);
    actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L");

    m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this);
    m_lockAct->setEnabled(false);

    m_duplicateAct = new QAction(tr("Duplicate"),this);
    actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+D");

    connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate()));

    m_deleteLineAct = new QAction(tr("Delete Line"),this);
    actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K");

    connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine()));

    m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this);
    actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return");
    connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore()));

    m_insertLineAfterAct = new QAction(tr("Insert Line After"),this);
    actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return");
    connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter()));

    m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++;Ctrl+=");

    m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-");

    m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0");

    m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this);
    actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace","");

    m_wordWrapAct = new QAction(tr("Word Wrap"),this);
    m_wordWrapAct->setCheckable(true);
    actionContext->regAction(m_wordWrapAct,"WordWrap","");

//    m_widget->addAction(m_foldAct);
//    m_widget->addAction(m_unfoldAct);
//    m_widget->addAction(m_gotoLineAct);

//    m_widget->addAction(m_gotoPrevBlockAct);
//    m_widget->addAction(m_gotoNextBlockAct);
//    m_widget->addAction(m_selectBlockAct);
//    m_widget->addAction(m_gotoMatchBraceAct);

    connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool)));

    connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo()));
    connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo()));
    connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut()));
    connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy()));
    connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste()));
    connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll()));
    connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock()));

    connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml()));
#ifndef QT_NO_PRINTER
    connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf()));
    connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint()));
    connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview()));
#endif
    connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock()));
    connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock()));
    connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace()));
    connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine()));
    connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace()));
    connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool)));

    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged()));
    clipbordDataChanged();
}
Esempio n. 2
0
bool command_executor::execute_command(const hotkey_command&  cmd, int /*index*/, bool press)
{
	// hotkey release handling
	if (!press) {
		switch(cmd.id) {
			// release a scroll key, un-apply scrolling in the given direction
			case HOTKEY_SCROLL_UP:
				scroll_up(false);
				break;
			case HOTKEY_SCROLL_DOWN:
				scroll_down(false);
				break;
			case HOTKEY_SCROLL_LEFT:
				scroll_left(false);
				break;
			case HOTKEY_SCROLL_RIGHT:
				scroll_right(false);
				break;
			default:
				return false; // nothing else handles a hotkey release
		}

		return true;
	}

	// hotkey press handling
	switch(cmd.id) {
		case HOTKEY_SCROLL_UP:
			scroll_up(true);
			break;
		case HOTKEY_SCROLL_DOWN:
			scroll_down(true);
			break;
		case HOTKEY_SCROLL_LEFT:
			scroll_left(true);
			break;
		case HOTKEY_SCROLL_RIGHT:
			scroll_right(true);
			break;
		case HOTKEY_CYCLE_UNITS:
			cycle_units();
			break;
		case HOTKEY_CYCLE_BACK_UNITS:
			cycle_back_units();
			break;
		case HOTKEY_ENDTURN:
			end_turn();
			break;
		case HOTKEY_UNIT_HOLD_POSITION:
			unit_hold_position();
			break;
		case HOTKEY_END_UNIT_TURN:
			end_unit_turn();
			break;
		case HOTKEY_LEADER:
			goto_leader();
			break;
		case HOTKEY_UNDO:
			undo();
			break;
		case HOTKEY_REDO:
			redo();
			break;
		case HOTKEY_TERRAIN_DESCRIPTION:
			terrain_description();
			break;
		case HOTKEY_UNIT_DESCRIPTION:
			unit_description();
			break;
		case HOTKEY_RENAME_UNIT:
			rename_unit();
			break;
		case HOTKEY_SAVE_GAME:
			save_game();
			break;
		case HOTKEY_SAVE_REPLAY:
			save_replay();
			break;
		case HOTKEY_SAVE_MAP:
			save_map();
			break;
		case HOTKEY_LOAD_GAME:
			load_game();
			break;
		case HOTKEY_TOGGLE_ELLIPSES:
			toggle_ellipses();
			break;
		case HOTKEY_TOGGLE_GRID:
			toggle_grid();
			break;
		case HOTKEY_STATUS_TABLE:
			status_table();
			break;
		case HOTKEY_RECALL:
			recall();
			break;
		case HOTKEY_LABEL_SETTINGS:
			label_settings();
			break;
		case HOTKEY_RECRUIT:
			recruit();
			break;
		case hotkey::HOTKEY_REPEAT_RECRUIT:
			repeat_recruit();
			break;
		case HOTKEY_SPEAK:
			speak();
			break;
		case HOTKEY_SPEAK_ALLY:
			whisper();
			break;
		case HOTKEY_SPEAK_ALL:
			shout();
			break;
		case HOTKEY_CREATE_UNIT:
			create_unit();
			break;
		case HOTKEY_CHANGE_SIDE:
			change_side();
			break;
		case HOTKEY_KILL_UNIT:
			kill_unit();
			break;
		case HOTKEY_PREFERENCES:
			preferences();
			break;
		case HOTKEY_OBJECTIVES:
			objectives();
			break;
		case HOTKEY_UNIT_LIST:
			unit_list();
			break;
		case HOTKEY_STATISTICS:
			show_statistics();
			break;
		case HOTKEY_STOP_NETWORK:
			stop_network();
			break;
		case HOTKEY_START_NETWORK:
			start_network();
			break;
		case HOTKEY_LABEL_TEAM_TERRAIN:
			label_terrain(true);
			break;
		case HOTKEY_LABEL_TERRAIN:
			label_terrain(false);
			break;
		case HOTKEY_CLEAR_LABELS:
			clear_labels();
			break;
		case HOTKEY_SHOW_ENEMY_MOVES:
			show_enemy_moves(false);
			break;
		case HOTKEY_BEST_ENEMY_MOVES:
			show_enemy_moves(true);
			break;
		case HOTKEY_DELAY_SHROUD:
			toggle_shroud_updates();
			break;
		case HOTKEY_UPDATE_SHROUD:
			update_shroud_now();
			break;
		case HOTKEY_CONTINUE_MOVE:
			continue_move();
			break;
		case HOTKEY_SEARCH:
			search();
			break;
		case HOTKEY_HELP:
			show_help();
			break;
		case HOTKEY_CHAT_LOG:
			show_chat_log();
			break;
		case HOTKEY_USER_CMD:
			user_command();
			break;
		case HOTKEY_CUSTOM_CMD:
			custom_command();
			break;
		case HOTKEY_AI_FORMULA:
			ai_formula();
			break;
		case HOTKEY_CLEAR_MSG:
			clear_messages();
			break;
		case HOTKEY_LANGUAGE:
			change_language();
			break;
		case HOTKEY_REPLAY_PLAY:
			play_replay();
			break;
		case HOTKEY_REPLAY_RESET:
			reset_replay();
			break;
		case HOTKEY_REPLAY_STOP:
			stop_replay();
			break;
		case HOTKEY_REPLAY_NEXT_TURN:
			replay_next_turn();
			break;
		case HOTKEY_REPLAY_NEXT_SIDE:
			replay_next_side();
			break;
		case HOTKEY_REPLAY_NEXT_MOVE:
			replay_next_move();
			break;
		case HOTKEY_REPLAY_SHOW_EVERYTHING:
			replay_show_everything();
			break;
		case HOTKEY_REPLAY_SHOW_EACH:
			replay_show_each();
			break;
		case HOTKEY_REPLAY_SHOW_TEAM1:
			replay_show_team1();
			break;
		case HOTKEY_REPLAY_SKIP_ANIMATION:
			replay_skip_animation();
			break;
		case HOTKEY_REPLAY_EXIT:
			replay_exit();
			break;
		case HOTKEY_WB_TOGGLE:
			whiteboard_toggle();
			break;
		case HOTKEY_WB_EXECUTE_ACTION:
			whiteboard_execute_action();
			break;
		case HOTKEY_WB_EXECUTE_ALL_ACTIONS:
			whiteboard_execute_all_actions();
			break;
		case HOTKEY_WB_DELETE_ACTION:
			whiteboard_delete_action();
			break;
		case HOTKEY_WB_BUMP_UP_ACTION:
			whiteboard_bump_up_action();
			break;
		case HOTKEY_WB_BUMP_DOWN_ACTION:
			whiteboard_bump_down_action();
			break;
		case HOTKEY_WB_SUPPOSE_DEAD:
			whiteboard_suppose_dead();
			break;
		case HOTKEY_SELECT_HEX:
			select_hex();
			break;
		case HOTKEY_DESELECT_HEX:
			deselect_hex();
			break;
		case HOTKEY_MOVE_ACTION:
			move_action();
			break;
		case HOTKEY_SELECT_AND_ACTION:
			select_and_action();
			break;
		case HOTKEY_ACCELERATED:
			toggle_accelerated_speed();
			break;
		case LUA_CONSOLE:
			lua_console();
			break;
		case HOTKEY_ZOOM_IN:
			zoom_in();
			break;
		case HOTKEY_ZOOM_OUT:
			zoom_out();
			break;
		case HOTKEY_ZOOM_DEFAULT:
			zoom_default();
			break;
		case HOTKEY_MAP_SCREENSHOT:
			map_screenshot();
			break;
		case HOTKEY_QUIT_TO_DESKTOP:
			quit_confirmation::quit_to_desktop();
			break;
		case HOTKEY_QUIT_GAME:
			quit_confirmation::quit_to_title();
			break;
		default:
			return false;
	}
	return true;
}
Esempio n. 3
0
 virtual bool perform(ExceptionState& es)
 {
     m_value = m_element->getAttribute(m_name);
     return redo(es);
 }
Esempio n. 4
0
PjModeler::PjModeler(const QDir &dir, QWidget *parent, QSqlDatabase db) :
    QWidget(parent),
    dir(dir)
{
    if( (  ! dir.exists("main.cpp")) &&
           ! QFile::copy( ":/file/files/main.cpp", dir.absoluteFilePath("main.cpp")) )
    {
        setEnabled(false);
        QMessageBox::critical(this,tr("Error"),"Failed to build the <b>main.cpp</b> file!",QMessageBox::Ok,QMessageBox::Ok);
    }

    //editor
    editor = new MainEditor;
    editor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    regionViewer = new QListView;
    regionViewer->setObjectName("RegionViewer");
    regionModel = new QStandardItemModel(this);
    mdDebug = new MdDebug;
    paroutModel = new ParoutModel(dir,editor,db);
    paroutViewer = new ParoutView;

    titleLabel = new QLabel;
    titleLabel->setObjectName("TitleLabel");
    titleLabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    titleLabel->setText("Simulation Datas exist! (Read-Only Mode)");

    editButton = new QToolButton;
    editButton->setText(tr("Enable Editing") );
    editButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
    editButton->setObjectName("Switcher");
    editButton->setCheckable(true);
    connect(editButton, SIGNAL(toggled(bool)), this,SLOT(setReadWrite(bool)) );

    nextButton = new QToolButton;
    nextButton->setIcon(QIcon(":/icon/images/next.png") );
    nextButton->setText(tr("Next Page"));
    nextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    nextButton->setToolTip(tr("Next Page"));
    nextButton->setObjectName("ToolButton");

    addchainButton = new QToolButton;
    addchainButton->setText(tr("Chain"));
    addchainButton->setIcon(QIcon(":/icon/images/addchain.png") );
    addchainButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    addchainButton->setToolTip(tr("New Chain"));
    addchainButton->setObjectName("ToolButton");

    addoutputButton = new QToolButton;
    addoutputButton->setText(tr("Output"));
    addoutputButton->setIcon(QIcon(":/icon/images/addoutput.png") );
    addoutputButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    addoutputButton->setToolTip(tr("New Output"));
    addoutputButton->setObjectName("ToolButton");


    titleBar = new QToolBar;
    titleBar->setObjectName("TitleBar");
    editAction = titleBar->addWidget(editButton);
    titleBar->addWidget(titleLabel);

    deleteAction = titleBar->addAction(QIcon(":/icon/images/delete.png"),tr("Delete"),this,SLOT(deleteExtraSelections()));
    deleteAction->setDisabled(true);
    undoAction = titleBar->addAction(QIcon(":/icon/images/undo.png"),tr("Undo"),editor,SLOT(undo()));
    undoAction->setDisabled(true);
    redoAction = titleBar->addAction(QIcon(":/icon/images/redo.png"),tr("Redo"),editor,SLOT(redo()));
    redoAction->setDisabled(true);
    saveAction = titleBar->addAction(QIcon(":/icon/images/save.png"),tr("Save"),this,SLOT(save()) );
    saveAction->setDisabled(true);
    titleBar->addSeparator();
    titleBar->addWidget(addchainButton);
    titleBar->addWidget(addoutputButton);
    titleBar->addSeparator();
    titleBar->addWidget(nextButton);

    //left splitter
    QSplitter *spl = new QSplitter(Qt::Vertical);
    spl->addWidget(regionViewer);
    spl->addWidget(paroutViewer);

    //rigth splitter
    QSplitter *spr = new QSplitter(Qt::Vertical);
    spr->addWidget(editor);
    spr->addWidget(mdDebug->textOutput);

    QVBoxLayout *lr = new QVBoxLayout;
    lr->addWidget(spr);
    lr->addWidget(mdDebug);

    QHBoxLayout *bodyLayout = new QHBoxLayout;
    bodyLayout->addWidget(spl);
    bodyLayout->addLayout(lr);

    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->setSpacing(0);
    mainLayout->addWidget(titleBar);
    mainLayout->addLayout(bodyLayout);

    QStringList conststrs;
    conststrs << "//!" << "for(unsigned long istep=0;istep<steps;++istep)";
    QFile file( dir.absoluteFilePath("main.cpp"));
//    file.setPermissions( QFileDevice::WriteOwner);
    editor->setEnabled( file.open(QIODevice::ReadOnly));
    editor->setPlainText( file.readAll());
    editor->setConstStrings( conststrs);
    editor->updateEnv();
    editor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //region widget
    regionViewer->setModel(regionModel);
    regionViewer->setSelectionMode(QAbstractItemView::ExtendedSelection);
    regionViewer->setEditTriggers(QAbstractItemView::NoEditTriggers);
    readRegion();

    //parout viewer.
    connect(paroutModel,SIGNAL(simulationExistence(bool)),this,SLOT(setReadOnlyMode(bool)) );

    paroutModel->initialize();
    paroutViewer->setEditTriggers(QAbstractItemView::EditKeyPressed | QAbstractItemView::DoubleClicked);
    paroutViewer->setSelectionMode(QAbstractItemView::SingleSelection);
    paroutViewer->setContextMenuPolicy(Qt::ActionsContextMenu);
    paroutViewer->setIndentation(0);
    paroutViewer->setAlternatingRowColors(true);
    paroutViewer->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
    paroutViewer->header()->setStretchLastSection(false);
    paroutViewer->header()->setMinimumSectionSize(15);
    paroutViewer->setModel(paroutModel);
    paroutDelegate = new ParoutDelegate(paroutViewer);
    paroutViewer->setItemDelegateForColumn(1,paroutDelegate);
    paroutViewer->resizeToContent();

    connect(undoAction,SIGNAL(triggered()),this,SLOT(readRegion()));
    connect(redoAction,SIGNAL(triggered()),this,SLOT(readRegion()));
    connect(addchainButton,SIGNAL(clicked()),this,SLOT(newChain()) );
    connect(addoutputButton,SIGNAL(clicked()),this,SLOT(newOutput()) );

    connect(regionViewer->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)),this,SLOT(regionViewerSelectionChanged()) );
    connect(nextButton,SIGNAL(clicked()),this,SIGNAL(switch2Analyse()) );
    connect(editor,SIGNAL(undoAvailable(bool)),undoAction,SLOT(setEnabled(bool)) );
    connect(editor,SIGNAL(redoAvailable(bool)),redoAction,SLOT(setEnabled(bool)) );
    connect(editor,SIGNAL(blockCountChanged(int)),this,SLOT(highlightCurrentSelection()) );
    connect(mdDebug,SIGNAL(runTriggered()),this,SLOT(debug()) );
    connect(mdDebug,SIGNAL(exploreDebugFolder()),this,SLOT(exploreDebugFolder()) );
    connect(editor,SIGNAL(modificationChanged(bool)),this,SLOT(slotModificationChanged(bool)) );
}
Esempio n. 5
0
KRegExpEditorPrivate::KRegExpEditorPrivate(TQWidget *parent, const char *name)
    : TQWidget(parent, name), _updating( false ), _autoVerify( true )
{
  setMinimumSize(730,300);
  TQDockArea* area = new TQDockArea(Qt::Horizontal, TQDockArea::Normal, this );
  area->setMinimumSize(2,2);
  TQDockArea* verArea1 = new TQDockArea(Qt::Vertical, TQDockArea::Normal, this );
  verArea1->setMinimumSize(2,2);
  TQDockArea* verArea2 = new TQDockArea(Qt::Vertical, TQDockArea::Reverse, this );
  verArea2->setMinimumSize(2,2);

  // The DockWindows.
  _regExpButtons = new RegExpButtons( area, "KRegExpEditorPrivate::regExpButton" );
  _verifyButtons = new VerifyButtons( area, "KRegExpEditorPrivate::VerifyButtons" );
  _auxButtons = new AuxButtons( area, "KRegExpEditorPrivate::AuxButtons" );
  _userRegExps = new UserDefinedRegExps( verArea1, "KRegExpEditorPrivate::userRegExps" );
  _userRegExps->setResizeEnabled( true );
  TQWhatsThis::add( _userRegExps, i18n( "In this window you will find predefined regular expressions. Both regular expressions "
                                       "you have developed and saved, and regular expressions shipped with the system." ));

  // Editor window
  _editor = new TQSplitter(Qt::Vertical, this, "KRegExpEditorPrivate::_editor" );

  _scrolledEditorWindow =
    new RegExpScrolledEditorWindow( _editor, "KRegExpEditorPrivate::_scrolledEditorWindow" );
  TQWhatsThis::add( _scrolledEditorWindow, i18n( "In this window you will develop your regular expressions. "
                                               "Select one of the actions from the action buttons above, and click the mouse in this "
                                               "window to insert the given action."));

  _info = new InfoPage( this, "_info" );
  _verifier = new Verifier( _editor, "KRegExpEditorPrivate::_verifier" );
  connect( _verifier, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( maybeVerify() ) );
  TQWhatsThis::add( _verifier, i18n("Type in some text in this window, and see what the regular expression you have developed matches.<p>"
                                   "Each second match will be colored in red and each other match will be colored blue, simply so you "
                                   "can distinguish them from each other.<p>"
                                   "If you select part of the regular expression in the editor window, then this part will be "
                                   "highlighted - This allows you to <i>debug</i> your regular expressions") );

  _editor->hide();
  _editor->setSizes( TQValueList<int>() << _editor->height()/2 << _editor->height()/2 );

  TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0, 6, "KRegExpEditorPrivate::topLayout" );
  topLayout->addWidget( area );
  TQHBoxLayout* rows = new TQHBoxLayout; // I need to cal addLayout explicit to get stretching right.
  topLayout->addLayout( rows, 1 );

  rows->addWidget( verArea1 );
  rows->addWidget( _editor, 1 );
  rows->addWidget( _info, 1 );
  rows->addWidget( verArea2 );

  // Connect the buttons
  connect( _regExpButtons, TQT_SIGNAL( clicked( int ) ),   _scrolledEditorWindow, TQT_SLOT( slotInsertRegExp( int ) ) );
  connect( _regExpButtons, TQT_SIGNAL( doSelect() ), _scrolledEditorWindow, TQT_SLOT( slotDoSelect() ) );
  connect( _userRegExps, TQT_SIGNAL( load( RegExp* ) ),    _scrolledEditorWindow, TQT_SLOT( slotInsertRegExp( RegExp*  ) ) );

  connect( _regExpButtons, TQT_SIGNAL( clicked( int ) ), _userRegExps,   TQT_SLOT( slotUnSelect() ) );
  connect( _regExpButtons, TQT_SIGNAL( doSelect() ),     _userRegExps,   TQT_SLOT( slotUnSelect() ) );
  connect( _userRegExps, TQT_SIGNAL( load( RegExp* ) ),  _regExpButtons, TQT_SLOT( slotUnSelect() ) );

  connect( _scrolledEditorWindow, TQT_SIGNAL( doneEditing() ), _regExpButtons, TQT_SLOT( slotSelectNewAction() ) );
  connect( _scrolledEditorWindow, TQT_SIGNAL( doneEditing() ), _userRegExps, TQT_SLOT( slotSelectNewAction() ) );

  connect( _regExpButtons, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotShowEditor() ) );
  connect( _userRegExps, TQT_SIGNAL( load( RegExp* ) ), this, TQT_SLOT( slotShowEditor() ) );
  connect( _regExpButtons, TQT_SIGNAL( doSelect() ), this, TQT_SLOT( slotShowEditor() ) );

  connect( _scrolledEditorWindow, TQT_SIGNAL( savedRegexp() ), _userRegExps, TQT_SLOT( slotPopulateUserRegexps() ) );

  connect( _auxButtons, TQT_SIGNAL( undo() ), this, TQT_SLOT( slotUndo() ) );
  connect( _auxButtons, TQT_SIGNAL( redo() ), this, TQT_SLOT( slotRedo() ) );
  connect( _auxButtons, TQT_SIGNAL( cut() ), _scrolledEditorWindow, TQT_SLOT( slotCut() ) );
  connect( _auxButtons, TQT_SIGNAL( copy() ), _scrolledEditorWindow, TQT_SLOT( slotCopy() ) );
  connect( _auxButtons, TQT_SIGNAL( paste() ), _scrolledEditorWindow, TQT_SLOT( slotPaste() ) );
  connect( _auxButtons, TQT_SIGNAL( save() ), _scrolledEditorWindow, TQT_SLOT( slotSave() ) );
  connect( _verifyButtons, TQT_SIGNAL( autoVerify( bool ) ), this, TQT_SLOT( setAutoVerify( bool ) ) );
  connect( _verifyButtons, TQT_SIGNAL( verify() ), this, TQT_SLOT( doVerify() ) );
  connect( _verifyButtons, TQT_SIGNAL( changeSyntax( const TQString& ) ), this, TQT_SLOT( setSyntax( const TQString& ) ) );

  connect( this, TQT_SIGNAL( canUndo( bool ) ), _auxButtons, TQT_SLOT( slotCanUndo( bool ) ) );
  connect( this, TQT_SIGNAL( canRedo( bool ) ), _auxButtons, TQT_SLOT( slotCanRedo( bool ) ) );
  connect( _scrolledEditorWindow, TQT_SIGNAL( anythingSelected( bool ) ), _auxButtons, TQT_SLOT( slotCanCut( bool ) ) );
  connect( _scrolledEditorWindow, TQT_SIGNAL( anythingSelected( bool ) ), _auxButtons, TQT_SLOT( slotCanCopy( bool ) ) );
  connect( _scrolledEditorWindow, TQT_SIGNAL( anythingOnClipboard( bool ) ), _auxButtons, TQT_SLOT( slotCanPaste( bool ) ) );
  connect( _scrolledEditorWindow, TQT_SIGNAL( canSave( bool ) ), _auxButtons, TQT_SLOT( slotCanSave( bool ) ) );

  connect( _scrolledEditorWindow, TQT_SIGNAL( verifyRegExp() ), this, TQT_SLOT( maybeVerify() ) );

  connect( _verifyButtons, TQT_SIGNAL( loadVerifyText( const TQString& ) ), this, TQT_SLOT( setVerifyText( const TQString& ) ) );

  // connect( _verifier, TQT_SIGNAL( countChanged( int ) ), _verifyButtons, TQT_SLOT( setMatchCount( int ) ) );

  // TQt anchors do not work for <pre>...</pre>, thefore scrolling to next/prev match
  // do not work. Enable this when they work.
  // connect( _verifyButtons, TQT_SIGNAL( gotoFirst() ), _verifier, TQT_SLOT( gotoFirst() ) );
  // connect( _verifyButtons, TQT_SIGNAL( gotoPrev() ), _verifier, TQT_SLOT( gotoPrev() ) );
  // connect( _verifyButtons, TQT_SIGNAL( gotoNext() ), _verifier, TQT_SLOT( gotoNext() ) );
  // connect( _verifyButtons, TQT_SIGNAL( gotoLast() ), _verifier, TQT_SLOT( gotoLast() ) );
  // connect( _verifier, TQT_SIGNAL( goForwardPossible( bool ) ), _verifyButtons, TQT_SLOT( enableForwardButtons( bool ) ) );
  // connect( _verifier, TQT_SIGNAL( goBackwardPossible( bool ) ), _verifyButtons, TQT_SLOT( enableBackwardButtons( bool ) ) );

  _auxButtons->slotCanPaste( false );
  _auxButtons->slotCanCut( false );
  _auxButtons->slotCanCopy( false );
  _auxButtons->slotCanSave( false );


  // Line Edit
  TQHBoxLayout* layout = new TQHBoxLayout( topLayout, 6 );
  TQLabel* label = new TQLabel( i18n("ASCII syntax:"), this );
  layout->addWidget( label );
  clearButton = new TQToolButton( this );
  const TQString icon( TQString::fromLatin1( TQApplication::reverseLayout() ? "clear_left" : "locationbar_erase" ) );
  TQIconSet clearIcon = SmallIconSet( icon );
  clearButton->setIconSet( clearIcon );
  layout->addWidget( clearButton );
  TQToolTip::add( clearButton, i18n("Clear expression") );
  _regexpEdit = new TQLineEdit( this );
  layout->addWidget( _regexpEdit );
  TQWhatsThis::add( _regexpEdit, i18n( "This is the regular expression in ASCII syntax. You are likely only "
				      "to be interested in this if you are a programmer, and need to "
				      "develop a regular expression using TQRegExp.<p>"
                                      "You may develop your regular expression both by using the graphical "
				      "editor, and by typing the regular expression in this line edit.") );

#ifdef TQT_ONLY
  TQPixmap pix( "icons/error.png" );
#else
  TQPixmap pix = TDEGlobal::iconLoader()->loadIcon(locate("data", TQString::fromLatin1("kregexpeditor/pics/error.png") ), TDEIcon::Toolbar );
#endif
  _error = new TQLabel( this );
  _error->setPixmap( pix );
  layout->addWidget( _error );
  _error->hide();

  _timer = new TQTimer(this);

  connect( _scrolledEditorWindow, TQT_SIGNAL( change() ), this, TQT_SLOT( slotUpdateLineEdit() ) );
  connect( _regexpEdit, TQT_SIGNAL(textChanged( const TQString& ) ), this, TQT_SLOT( slotTriggerUpdate() ) );
  connect( _timer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( slotTimeout() ) );
  connect( clearButton, TQT_SIGNAL( clicked() ), _regexpEdit, TQT_SLOT( clear() ) );

  // Push an initial empty element on the stack.
  _undoStack.push( _scrolledEditorWindow->regExp() );
  _redoStack.setAutoDelete( true );

  TQAccel* accel = new TQAccel( this );
  accel->connectItem( accel->insertItem( CTRL+Key_Z ), this, TQT_SLOT( slotUndo() ) );
  accel->connectItem( accel->insertItem( CTRL+Key_R ), this, TQT_SLOT( slotRedo() ) );

  setSyntax( TQString::fromLatin1( "TQt" ) );
}
Esempio n. 6
0
    QSettings s;
    s.beginGroup("UI");
    s.setValue("geo", saveGeometry());
    s.setValue("status", saveState());
    s.endGroup();
    delete ui;
}

void MainWindow::updateActiveProject(Project *project)
{  
    foreach (Manager* m, _managers) {
        m->setProject(project);
    }

    connect(ui->actionUndo, SIGNAL(triggered()), project, SLOT(undo()));
    connect(ui->actionRedo, SIGNAL(triggered()), project, SLOT(redo()));
    connect(ui->actionDuplicate_Selected, SIGNAL(triggered()), project, SLOT(duplicateSelected()));
    connect(ui->actionConvert, SIGNAL(triggered()), project, SLOT(convertSelected()));
    connect(ui->actionOptions, SIGNAL(triggered()), project, SLOT(showRenderOptions()));
    connect(ui->actionShowRenderFrame, &QAction::triggered, [project](bool checked) { project->showRenderFrame = checked; } );
    project->showRenderFrame = ui->actionShowRenderFrame->isChecked();
}

void MainWindow::addManager(Manager *manager)
{
    if (_pc) {
        manager->setProject(_pc->project());
    } else {
        manager->setProject(0);
    }
    _managers.append(manager);
Esempio n. 7
0
void KLineEdit::keyPressEvent( QKeyEvent *e )
{
    KKey key( e );

    if ( KStdAccel::copy().contains( key ) )
    {
        copy();
        return;
    }
    else if ( KStdAccel::paste().contains( key ) )
    {
        paste();
        return;
    }
    else if ( KStdAccel::pasteSelection().contains( key ) )
    {
        QString text = QApplication::clipboard()->text( QClipboard::Selection);
        insert( text );
        deselect();
        return;
    }

    else if ( KStdAccel::cut().contains( key ) )
    {
        cut();
        return;
    }
    else if ( KStdAccel::undo().contains( key ) )
    {
        undo();
        return;
    }
    else if ( KStdAccel::redo().contains( key ) )
    {
        redo();
        return;
    }
    else if ( KStdAccel::deleteWordBack().contains( key ) )
    {
        cursorWordBackward(true);
        if ( hasSelectedText() )
            del();

        e->accept();
        return;
    }
    else if ( KStdAccel::deleteWordForward().contains( key ) )
    {
        // Workaround for QT bug where
        cursorWordForward(true);
        if ( hasSelectedText() )
            del();

        e->accept();
        return;
    }
    else if ( KStdAccel::backwardWord().contains( key ) )
    {
      cursorWordBackward(false);
      e->accept();
      return;
    }
    else if ( KStdAccel::forwardWord().contains( key ) )
    {
      cursorWordForward(false);
      e->accept();
      return;
    }
    else if ( KStdAccel::beginningOfLine().contains( key ) )
    {
      home(false);
      e->accept();
      return;
    }
    else if ( KStdAccel::endOfLine().contains( key ) )
    {
      end(false);
      e->accept();
      return;
    }


    // Filter key-events if EchoMode is normal and
    // completion mode is not set to CompletionNone
    if ( echoMode() == QLineEdit::Normal &&
         completionMode() != KGlobalSettings::CompletionNone )
    {
        KeyBindingMap keys = getKeyBindings();
        KGlobalSettings::Completion mode = completionMode();
        bool noModifier = (e->state() == NoButton ||
                           e->state() == ShiftButton ||
                           e->state() == Keypad);

        if ( (mode == KGlobalSettings::CompletionAuto ||
              mode == KGlobalSettings::CompletionPopupAuto ||
              mode == KGlobalSettings::CompletionMan) && noModifier )
        {
            if ( !d->userSelection && hasSelectedText() &&
                 ( e->key() == Key_Right || e->key() == Key_Left ) &&
                 e->state()==NoButton )
            {
                QString old_txt = text();
                d->disableRestoreSelection = true;
                int start,end;
                getSelection(&start, &end);

                deselect();
                QLineEdit::keyPressEvent ( e );
                int cPosition=cursorPosition();
                if (e->key() ==Key_Right && cPosition > start )
                    validateAndSet(old_txt, cPosition, cPosition, old_txt.length());
                else
                    validateAndSet(old_txt, cPosition, start, old_txt.length());

                d->disableRestoreSelection = false;
                return;
            }

            if ( e->key() == Key_Escape )
            {
                if (hasSelectedText() && !d->userSelection )
                {
                    del();
                    setUserSelection(true);
                }

                // Don't swallow the Escape press event for the case
                // of dialogs, which have Escape associated to Cancel
                e->ignore();
                return;
            }

        }

        if ( (mode == KGlobalSettings::CompletionAuto ||
              mode == KGlobalSettings::CompletionMan) && noModifier )
        {
            QString keycode = e->text();
            if ( !keycode.isEmpty() && (keycode.unicode()->isPrint() ||
                e->key() == Key_Backspace || e->key() == Key_Delete ) )
            {
                bool hasUserSelection=d->userSelection;
                bool hadSelection=hasSelectedText();

                bool cursorNotAtEnd=false;

                int start,end;
                getSelection(&start, &end);
                int cPos = cursorPosition();

                // When moving the cursor, we want to keep the autocompletion as an
                // autocompletion, so we want to process events at the cursor position
                // as if there was no selection. After processing the key event, we
                // can set the new autocompletion again.
                if ( hadSelection && !hasUserSelection && start>cPos )
                {
                    del();
                    setCursorPosition(cPos);
                    cursorNotAtEnd=true;
                }

                d->disableRestoreSelection = true;
                QLineEdit::keyPressEvent ( e );
                d->disableRestoreSelection = false;

                QString txt = text();
                int len = txt.length();
                if ( !hasSelectedText() && len /*&& cursorPosition() == len */)
                {
                    if ( e->key() == Key_Backspace )
                    {
                        if ( hadSelection && !hasUserSelection && !cursorNotAtEnd )
                        {
                            backspace();
                            txt = text();
                            len = txt.length();
                        }

                        if ( !d->backspacePerformsCompletion || !len )
                            d->autoSuggest = false;
                    }

                    if (e->key() == Key_Delete )
                        d->autoSuggest=false;

                    if ( emitSignals() )
                        emit completion( txt );

                    if ( handleSignals() )
                        makeCompletion( txt );

                    if(  (e->key() == Key_Backspace || e->key() == Key_Delete) )
                        d->autoSuggest=true;

                    e->accept();
                }

                return;
            }

        }

        else if (( mode == KGlobalSettings::CompletionPopup ||
                   mode == KGlobalSettings::CompletionPopupAuto ) &&
                   noModifier && !e->text().isEmpty() )
        {
            QString old_txt = text();
            bool hasUserSelection=d->userSelection;
            bool hadSelection=hasSelectedText();
            bool cursorNotAtEnd=false;

            int start,end;
            getSelection(&start, &end);
            int cPos = cursorPosition();
            QString keycode = e->text();

            // When moving the cursor, we want to keep the autocompletion as an
            // autocompletion, so we want to process events at the cursor position
            // as if there was no selection. After processing the key event, we
            // can set the new autocompletion again.
            if (hadSelection && !hasUserSelection && start>cPos &&
               ( (!keycode.isEmpty() && keycode.unicode()->isPrint()) ||
                 e->key() == Key_Backspace || e->key() == Key_Delete ) )
            {
                del();
                setCursorPosition(cPos);
                cursorNotAtEnd=true;
            }

            uint selectedLength=selectedText().length();

            d->disableRestoreSelection = true;
            QLineEdit::keyPressEvent ( e );
            d->disableRestoreSelection = false;

            if (( selectedLength != selectedText().length() ) && !hasUserSelection )
                slotRestoreSelectionColors(); // and set userSelection to true

            QString txt = text();
            int len = txt.length();

            if ( txt != old_txt && len/* && ( cursorPosition() == len || force )*/ &&
                 ( (!keycode.isEmpty() && keycode.unicode()->isPrint()) ||
                   e->key() == Key_Backspace || e->key() == Key_Delete) )
            {
                if ( e->key() == Key_Backspace )
                {
                    if ( hadSelection && !hasUserSelection && !cursorNotAtEnd )
                    {
                        backspace();
                        txt = text();
                        len = txt.length();
                    }

                    if ( !d->backspacePerformsCompletion )
                        d->autoSuggest = false;
                }

                if (e->key() == Key_Delete )
                    d->autoSuggest=false;

                if ( d->completionBox )
                  d->completionBox->setCancelledText( txt );
	
                if ( emitSignals() )
                  emit completion( txt ); // emit when requested...

                if ( handleSignals() ) {
                  makeCompletion( txt );  // handle when requested...
                }

                if ( (e->key() == Key_Backspace || e->key() == Key_Delete ) &&
                    mode == KGlobalSettings::CompletionPopupAuto )
                  d->autoSuggest=true;

                e->accept();
            }
            else if (!len && d->completionBox && d->completionBox->isVisible())
                d->completionBox->hide();

            return;
        }

        else if ( mode == KGlobalSettings::CompletionShell )
        {
            // Handles completion.
            KShortcut cut;
            if ( keys[TextCompletion].isNull() )
                cut = KStdAccel::shortcut(KStdAccel::TextCompletion);
            else
                cut = keys[TextCompletion];

            if ( cut.contains( key ) )
            {
                // Emit completion if the completion mode is CompletionShell
                // and the cursor is at the end of the string.
                QString txt = text();
                int len = txt.length();
                if ( cursorPosition() == len && len != 0 )
                {
                    if ( emitSignals() )
                        emit completion( txt );
                    if ( handleSignals() )
                        makeCompletion( txt );
                    return;
                }
            }
            else if ( d->completionBox )
                d->completionBox->hide();
        }

        // handle rotation
        if ( mode != KGlobalSettings::CompletionNone )
        {
            // Handles previous match
            KShortcut cut;
            if ( keys[PrevCompletionMatch].isNull() )
                cut = KStdAccel::shortcut(KStdAccel::PrevCompletion);
            else
                cut = keys[PrevCompletionMatch];

            if ( cut.contains( key ) )
            {
                if ( emitSignals() )
                    emit textRotation( KCompletionBase::PrevCompletionMatch );
                if ( handleSignals() )
                    rotateText( KCompletionBase::PrevCompletionMatch );
                return;
            }

            // Handles next match
            if ( keys[NextCompletionMatch].isNull() )
                cut = KStdAccel::shortcut(KStdAccel::NextCompletion);
            else
                cut = keys[NextCompletionMatch];

            if ( cut.contains( key ) )
            {
                if ( emitSignals() )
                    emit textRotation( KCompletionBase::NextCompletionMatch );
                if ( handleSignals() )
                    rotateText( KCompletionBase::NextCompletionMatch );
                return;
            }
        }

        // substring completion
        if ( compObj() )
        {
            KShortcut cut;
            if ( keys[SubstringCompletion].isNull() )
                cut = KStdAccel::shortcut(KStdAccel::SubstringCompletion);
            else
                cut = keys[SubstringCompletion];

            if ( cut.contains( key ) )
            {
                if ( emitSignals() )
                    emit substringCompletion( text() );
                if ( handleSignals() )
                {
                    setCompletedItems( compObj()->substringCompletion(text()));
                    e->accept();
                }
                return;
            }
        }
    }

    uint selectedLength = selectedText().length();

    // Let QLineEdit handle any other keys events.
    QLineEdit::keyPressEvent ( e );

    if ( selectedLength != selectedText().length() )
        slotRestoreSelectionColors(); // and set userSelection to true
}
bool qtractorDirectAccessParamCommand::undo (void)
{
	return redo();
}
Esempio n. 9
0
MainForm::MainForm( QWidget* parent, const char* name, WFlags fl )
    : QMainWindow( parent, name, fl )
{
    (void)statusBar();
    if ( !name )
	setName( "MainForm" );
    setCentralWidget( new QWidget( this, "qt_central_widget" ) );
    MainFormLayout = new QVBoxLayout( centralWidget(), 11, 6, "MainFormLayout"); 

    listView = new QListView( centralWidget(), "listView" );
    listView->addColumn( tr( "Type" ) );
    listView->addColumn( tr( "Name" ) );
    listView->addColumn( tr( "Login" ) );
    listView->addColumn( tr( "Password" ) );
    listView->addColumn( tr( "Description" ) );
    listView->setResizeMode( QListView::AllColumns );
    listView->setSorting(-1);
    MainFormLayout->addWidget( listView );

    // actions
    createProfileAction = new QAction( this, "createProfileAction" );
    createProfileAction->setIconSet( QPixmap::fromMimeSource("new.png") );
    openProfileAction = new QAction(this, "openProfileAction" );
    openProfileAction->setIconSet( QPixmap::fromMimeSource("open.png") );
    tb_openProfileAction = new QAction(this, "tb_openProfileAction");
    tb_openProfileAction->setIconSet( QPixmap::fromMimeSource("tb_open.png") );
    closeProfileAction = new QAction( this, "closeProfileAction" );
    closeProfileAction->setIconSet( QPixmap::fromMimeSource("close.png") );
    tb_closeProfileAction = new QAction( this, "tb_closeProfileAction" );
    tb_closeProfileAction->setIconSet( QPixmap::fromMimeSource("tb_close.png") );
    deleteProfileAction = new QAction( this, "deleteProfileAction" );
    deleteProfileAction->setIconSet( QPixmap::fromMimeSource("delete_all.png") );
    changeProfileAction = new QAction( this, "changeProfileAction" );
    fileQuitAction = new QAction( this, "fileQuitAction" );
    fileSaveAction = new QAction( this, "fileSaveAction" );
    fileSaveAction->setIconSet( QPixmap::fromMimeSource("save.png") );
    tb_fileSaveAction = new QAction( this, "tb_fileSaveAction" );
    tb_fileSaveAction->setIconSet( QPixmap::fromMimeSource("tb_save.png") );
    editUndoAction = new QAction( this, "editUndoAction" );
    editUndoAction->setIconSet( QPixmap::fromMimeSource("undo.png") );
    tb_editUndoAction = new QAction( this, "editUndoAction" );
    tb_editUndoAction->setIconSet( QPixmap::fromMimeSource("tb_undo.png") );
    editRedoAction = new QAction( this, "editRedoAction" );
    editRedoAction->setIconSet( QPixmap::fromMimeSource("redo.png") );
    tb_editRedoAction = new QAction( this, "tb_editRedoAction" );
    tb_editRedoAction->setIconSet( QPixmap::fromMimeSource("tb_redo.png") );
    editNewField = new QAction( this, "editNewField" );
    editNewField->setIconSet( QPixmap::fromMimeSource("new.png") );
    editEditField = new QAction( this, "editEditField" );
    editEditField->setIconSet( QPixmap::fromMimeSource("edit.png") );
    tb_editEditField = new QAction( this, "tb_editEditField" );
    tb_editEditField->setIconSet( QPixmap::fromMimeSource("tb_edit.png") );
    tb_editNewField = new QAction( this, "tb_editNewField" );
    tb_editNewField->setIconSet( QPixmap::fromMimeSource("tb_new.png") );
    editDeleteField = new QAction( this, "editDeleteField" );
    editDeleteField->setIconSet( QPixmap::fromMimeSource("delete.png") );
    tb_editDeleteField = new QAction( this, "tb_editDeleteField" );
    tb_editDeleteField->setIconSet( QPixmap::fromMimeSource("tb_delete.png") );
    editDeleteAll = new QAction( this, "editDeleteAll" );
    editDeleteAll->setIconSet( QPixmap::fromMimeSource("delete_all.png") );
    helpAboutAction = new QAction( this, "helpAboutAction" );


    // toolbars
    fileToolbar = new QToolBar( tr("File"), this, DockTop );
    tb_openProfileAction->addTo( fileToolbar);
    tb_fileSaveAction->addTo( fileToolbar);
    tb_closeProfileAction->addTo( fileToolbar );
    
    editToolbar = new QToolBar( tr("Edit"), this, DockTop );
    tb_editUndoAction->addTo( editToolbar );
    tb_editRedoAction->addTo( editToolbar );
    editToolbar->addSeparator();
    tb_editNewField->addTo( editToolbar );
    tb_editEditField->addTo( editToolbar );
    tb_editDeleteField->addTo( editToolbar );

    // menubar
    MenuBarEditor = new QMenuBar( this, "MenuBarEditor" );


    File = new QPopupMenu( this );
    createProfileAction->addTo( File );
    openProfileAction->addTo( File );
    fileSaveAction->addTo( File );
    closeProfileAction->addTo( File );
    deleteProfileAction->addTo( File );
    changeProfileAction->addTo( File );
    File->insertSeparator();
    fileQuitAction->addTo( File );
    MenuBarEditor->insertItem( QString(""), File, 1 );
    
    Edit = new QPopupMenu( this );
    editUndoAction->addTo( Edit );
    editRedoAction->addTo( Edit );
    Edit->insertSeparator();
    editNewField->addTo( Edit );
    editEditField->addTo( Edit );
    editDeleteField->addTo( Edit );
    editDeleteAll->addTo(Edit);
    MenuBarEditor->insertItem( QString(""), Edit, 2 );
    
    Help = new QPopupMenu( this );
    helpAboutAction->addTo( Help );
    MenuBarEditor->insertItem( QString(""), Help, 3 );
    
    rmbMenu = new QPopupMenu( this );
    editUndoAction->addTo( rmbMenu );
    editRedoAction->addTo( rmbMenu );
    rmbMenu->insertSeparator();
    editNewField->addTo( rmbMenu );
    editEditField->addTo( rmbMenu );
    editDeleteField->addTo( rmbMenu );

    languageChange();
    resize( QSize(700, 400).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );
    
    connect(createProfileAction, SIGNAL( activated() ), this, SLOT( createProfile() )  );
    connect(openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() )  );
    connect(tb_openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() ) );
    connect(closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() )  );
    connect(tb_closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() )  );
    connect(deleteProfileAction, SIGNAL( activated() ), this, SLOT( deleteProfile() ) );
    connect(changeProfileAction, SIGNAL( activated() ), this, SLOT( changeProfile() ) );
    connect(fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) );
    connect(tb_fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) );
    connect(fileQuitAction, SIGNAL( activated() ), this, SLOT( close() ) );
    connect(editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) );
    connect(tb_editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) );
    connect(editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) );
    connect(tb_editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) );
    connect(editNewField, SIGNAL( activated() ), this, SLOT( newField() ) );
    connect(tb_editNewField, SIGNAL( activated() ), this, SLOT( newField() ) );
    connect(editEditField, SIGNAL(activated() ), this, SLOT( editField() ) );
    connect(tb_editEditField, SIGNAL(activated() ), this, SLOT( editField() ) );
    connect(editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) );
    connect(tb_editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) );
    connect(editDeleteAll, SIGNAL( activated() ), this, SLOT( deleteAll() ) );
    connect(helpAboutAction, SIGNAL( activated() ), this, SLOT( about() ) );
    
    connect(listView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( edit(QListViewItem *) ) );
    connect(listView, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint&, int) ), this, SLOT( slotRMB( QListViewItem*, const QPoint &, int ) ) );
    
    modified = false;
    Caption();
    
    if(!ifProfileExists())
	    createProfile();
    else
	    setEnabledActions(1);
}
bool qtractorPluginParamCommand::undo (void)
{
	// As we swap the prev/value this is non-idempotent.
	return redo();
}
bool qtractorAudioOutputMonitorCommand::undo (void)
{
	return redo();
}
bool qtractorPluginPropertyCommand::undo (void)
{
	// As we swap the prev/state this is non-idempotent.
	return redo();
}
bool qtractorActivatePluginCommand::undo (void)
{
	// As we toggle the prev/state this is non-idempotent.
	return redo();
}
bool qtractorAuxSendPluginCommand::undo (void)
{
	return redo();
}
Esempio n. 15
0
KexiFormView::KexiFormView(QWidget *parent, bool dbAware)
        : KexiDataAwareView(parent)
        , d(new Private)
{
    Q_UNUSED(dbAware);
    d->delayedFormContentsResizeOnShow = 0;
//! @todo remove?
    setSortedProperties(true);

    d->scrollView = new KexiFormScrollView(         // will be added to layout
        this, viewMode() == Kexi::DataViewMode);   // in KexiDataAwareView::init()

    initForm();

    if (viewMode() == Kexi::DesignViewMode) {
        connect(form(), SIGNAL(propertySetSwitched()), this, SLOT(slotPropertySetSwitched()));
        connect(form(), SIGNAL(modified(bool)), this, SLOT(setDirty(bool)));
        connect(d->scrollView, SIGNAL(resized()), this, SLOT(setFormModified()));

        connect(d->dbform, SIGNAL(handleDragMoveEvent(QDragMoveEvent*)),
                this, SLOT(slotHandleDragMoveEvent(QDragMoveEvent*)));
        connect(d->dbform, SIGNAL(handleDropEvent(QDropEvent*)),
                this, SLOT(slotHandleDropEvent(QDropEvent*)));

        // action stuff
        plugSharedAction("formpart_taborder", form(), SLOT(editTabOrder()));
        plugSharedAction("formpart_adjust_size", form(), SLOT(adjustWidgetSize()));
//! @todo add formpart_pixmap_collection action
//! @todo add formpart_connections action

        plugSharedAction("edit_copy", form(), SLOT(copyWidget()));
        plugSharedAction("edit_cut", form(), SLOT(cutWidget()));
        plugSharedAction("edit_paste", form(), SLOT(pasteWidget()));
        plugSharedAction("edit_delete", form(), SLOT(deleteWidget()));
        plugSharedAction("edit_select_all", form(), SLOT(selectAll()));
        plugSharedAction("formpart_clear_contents", form(), SLOT(clearWidgetContent()));
        plugSharedAction("edit_undo", form(), SLOT(undo()));
        plugSharedAction("edit_redo", form(), SLOT(redo()));

//! @todo add formpart_layout_menu action
        plugSharedAction("formpart_layout_hbox", form(), SLOT(layoutHBox()));
        plugSharedAction("formpart_layout_vbox", form(), SLOT(layoutVBox()));
        plugSharedAction("formpart_layout_grid", form(), SLOT(layoutGrid()));
#ifdef KEXI_SHOW_SPLITTER_WIDGET
        plugSharedAction("formpart_layout_hsplitter", form(), SLOT(layoutHSplitter()));
        plugSharedAction("formpart_layout_vsplitter", form(), SLOT(layoutVSplitter()));
#endif
        plugSharedAction("formpart_break_layout", form(), SLOT(breakLayout()));

        plugSharedAction("formpart_format_raise", form(), SLOT(bringWidgetToFront()));
        plugSharedAction("formpart_format_lower", form(), SLOT(sendWidgetToBack()));

        plugSharedAction("other_widgets_menu", form(), 0);
        setAvailable("other_widgets_menu", true);

        plugSharedAction("formpart_align_menu", form(), 0);
        plugSharedAction("formpart_align_to_left", form(), SLOT(alignWidgetsToLeft()));
        plugSharedAction("formpart_align_to_right", form(), SLOT(alignWidgetsToRight()));
        plugSharedAction("formpart_align_to_top", form(), SLOT(alignWidgetsToTop()));
        plugSharedAction("formpart_align_to_bottom", form(), SLOT(alignWidgetsToBottom()));
        plugSharedAction("formpart_align_to_grid", form(), SLOT(alignWidgetsToGrid()));

        plugSharedAction("formpart_adjust_size_menu", form(), 0);
        plugSharedAction("formpart_adjust_to_fit", form(), SLOT(adjustWidgetSize()));
        plugSharedAction("formpart_adjust_size_grid", form(), SLOT(adjustSizeToGrid()));
        plugSharedAction("formpart_adjust_height_small", form(),  SLOT(adjustHeightToSmall()));
        plugSharedAction("formpart_adjust_height_big", form(), SLOT(adjustHeightToBig()));
        plugSharedAction("formpart_adjust_width_small", form(), SLOT(adjustWidthToSmall()));
        plugSharedAction("formpart_adjust_width_big", form(), SLOT(adjustWidthToBig()));

        plugSharedAction("format_font", form(), SLOT(changeFont()));

        // - setup local actions
        QList<QAction*> viewActions;
        QAction* a;
        a = form()->action("edit_undo");
        a->setProperty("iconOnly", true);
        viewActions << a;
        a = form()->action("edit_redo");
        a->setProperty("iconOnly", true);
        viewActions << a;
        setViewActions(viewActions);
    }
Esempio n. 16
0
Editor::Editor( QWidget* parent, QString daten, ScribusView* vie) : QDialog( parent )
{
	setModal(true);
	setWindowTitle( tr( "Editor" ) );
	setWindowIcon(loadIcon("AppIcon.png"));
	view = vie;
	dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
	EditorLayout = new QVBoxLayout(this);
	EditTex = new QTextEdit(this);
	newAct = new QAction(QIcon(loadIcon("16/document-new.png")), tr("&New"), this);
	newAct->setShortcut(tr("Ctrl+N"));
	connect(newAct, SIGNAL(triggered()), EditTex, SLOT(clear()));
	openAct = new QAction(QIcon(loadIcon("16/document-open.png")), tr("&Open..."), this);
	connect(openAct, SIGNAL(triggered()), this, SLOT(OpenScript()));
	saveAsAct = new QAction( tr("Save &As..."), this);
	connect(saveAsAct, SIGNAL(triggered()), this, SLOT(SaveAs()));
	saveExitAct = new QAction( tr("&Save and Exit"), this);
	connect(saveExitAct, SIGNAL(triggered()), this, SLOT(accept()));
	exitAct = new QAction( tr("&Exit without Saving"), this);
	connect(exitAct, SIGNAL(triggered()), this, SLOT(reject()));
	undoAct = new QAction(QIcon(loadIcon("16/edit-undo.png")), tr("&Undo"), this);
	undoAct->setShortcut(tr("Ctrl+Z"));
	connect(undoAct, SIGNAL(triggered()), EditTex, SLOT(undo()));
	redoAct = new QAction(QIcon(loadIcon("16/edit-redo.png")),  tr("&Redo"), this);
	connect(redoAct, SIGNAL(triggered()), EditTex, SLOT(redo()));
	cutAct = new QAction(QIcon(loadIcon("16/edit-cut.png")), tr("Cu&t"), this);
	cutAct->setShortcut(tr("Ctrl+X"));
	connect(cutAct, SIGNAL(triggered()), EditTex, SLOT(cut()));
	copyAct = new QAction(QIcon(loadIcon("16/edit-copy.png")), tr("&Copy"), this);
	copyAct->setShortcut(tr("Ctrl+C"));
	connect(copyAct, SIGNAL(triggered()), EditTex, SLOT(copy()));
	pasteAct = new QAction(QIcon(loadIcon("16/edit-paste.png")), tr("&Paste"), this);
	pasteAct->setShortcut(tr("Ctrl-V"));
	connect(pasteAct, SIGNAL(triggered()), EditTex, SLOT(paste()));
	clearAct = new QAction(QIcon(loadIcon("16/edit-delete.png")), tr("C&lear"), this);
	connect(clearAct, SIGNAL(triggered()), this, SLOT(del()));
	getFieldAct = new QAction( tr("&Get Field Names"), this);
	connect(getFieldAct, SIGNAL(triggered()), this, SLOT(GetFieldN()));
	fmenu = new QMenu( tr("&File"));
	fmenu->addAction(newAct);
	fmenu->addAction(openAct);
	fmenu->addAction(saveAsAct);
	fmenu->addSeparator();
	fmenu->addAction(saveExitAct);
	fmenu->addAction(exitAct);
	emenu = new QMenu( tr("&Edit"));
	emenu->addAction(undoAct);
	emenu->addAction(redoAct);
	emenu->addSeparator();
	emenu->addAction(cutAct);
	emenu->addAction(copyAct);
	emenu->addAction(pasteAct);
	emenu->addAction(clearAct);
	emenu->addSeparator();
	emenu->addAction(getFieldAct);
	menuBar = new QMenuBar(this);
	menuBar->addMenu(fmenu);
	menuBar->addMenu(emenu);
	EditorLayout->setMenuBar( menuBar );
	EditTex->setMinimumSize( QSize( 400, 400 ) );
	EditTex->setPlainText(daten);
	EditorLayout->addWidget( EditTex );
#ifdef Q_OS_MAC
	Layout1_2 = new QHBoxLayout;
	Layout1_2->setSpacing( 5 );
	Layout1_2->setMargin( 0 );
	QSpacerItem* spacerr = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
	Layout1_2->addItem( spacerr );
	PushButton1 = new QPushButton( this );
	PushButton1->setText( tr( "OK" ) );
	PushButton1->setDefault( true );
	Layout1_2->addWidget( PushButton1 );
	PushButton2 = new QPushButton( this );
	PushButton2->setText( tr( "Cancel" ) );
	Layout1_2->addWidget( PushButton2 );
	EditorLayout->addLayout( Layout1_2 );
	connect(PushButton1, SIGNAL(clicked()), this, SLOT(accept()));
	connect(PushButton2, SIGNAL(clicked()), this, SLOT(reject()));
#endif
}
int QTextDocument::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: contentsChange((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 1: contentsChanged(); break;
        case 2: undoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: redoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: undoCommandAdded(); break;
        case 5: modificationChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: cursorPositionChanged((*reinterpret_cast< const QTextCursor(*)>(_a[1]))); break;
        case 7: blockCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: documentLayoutChanged(); break;
        case 9: undo(); break;
        case 10: redo(); break;
        case 11: appendUndoItem((*reinterpret_cast< QAbstractUndoItem*(*)>(_a[1]))); break;
        case 12: setModified((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 13: setModified(); break;
        }
        _id -= 14;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isModified(); break;
        case 2: *reinterpret_cast< QSizeF*>(_v) = pageSize(); break;
        case 3: *reinterpret_cast< QFont*>(_v) = defaultFont(); break;
        case 4: *reinterpret_cast< bool*>(_v) = useDesignMetrics(); break;
        case 5: *reinterpret_cast< QSizeF*>(_v) = size(); break;
        case 6: *reinterpret_cast< qreal*>(_v) = textWidth(); break;
        case 7: *reinterpret_cast< int*>(_v) = blockCount(); break;
        case 8: *reinterpret_cast< qreal*>(_v) = indentWidth(); break;
        case 9: *reinterpret_cast< QString*>(_v) = defaultStyleSheet(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 1: setModified(*reinterpret_cast< bool*>(_v)); break;
        case 2: setPageSize(*reinterpret_cast< QSizeF*>(_v)); break;
        case 3: setDefaultFont(*reinterpret_cast< QFont*>(_v)); break;
        case 4: setUseDesignMetrics(*reinterpret_cast< bool*>(_v)); break;
        case 6: setTextWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 8: setIndentWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 9: setDefaultStyleSheet(*reinterpret_cast< QString*>(_v)); break;
        case 10: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
void Double2StringFilterSetDigitsCmd::undo() { redo(); }
QAction *MainWindow::createAction(const QString icon, const QString toolTip, const QString statusTip, bool scripted)
{
    QAction *ACTION = new QAction(QIcon("icons/" + getSettingsGeneralIconTheme() + "/" + icon + ".png"), toolTip, this); //TODO: Qt4.7 wont load icons without an extension...
    ACTION->setStatusTip(statusTip);
    ACTION->setObjectName(icon);
    // TODO: Finish All Commands ... <.<

    if     (icon == "donothing")                  connect(ACTION, SIGNAL(triggered()), this, SLOT(doNothing()));
    else if(icon == "new")                      { ACTION->setShortcut(QKeySequence::New);      connect(ACTION, SIGNAL(triggered()), this, SLOT(newfile()));         }
    else if(icon == "open")                     { ACTION->setShortcut(QKeySequence::Open);     connect(ACTION, SIGNAL(triggered()), this, SLOT(openfile()));        }
    else if(icon == "save")                     { ACTION->setShortcut(QKeySequence::Save);     connect(ACTION, SIGNAL(triggered()), this, SLOT(savefile()));        }
    else if(icon == "saveas")                   { ACTION->setShortcut(QKeySequence::SaveAs);   connect(ACTION, SIGNAL(triggered()), this, SLOT(saveasfile()));      }
    else if(icon == "print")                    { ACTION->setShortcut(QKeySequence::Print);    connect(ACTION, SIGNAL(triggered()), this, SLOT(print()));           }
    else if(icon == "close")                    { ACTION->setShortcut(QKeySequence::Close);    connect(ACTION, SIGNAL(triggered()), this, SLOT(onCloseWindow()));   }
    else if(icon == "designdetails")            { ACTION->setShortcut(QKeySequence("Ctrl+D")); connect(ACTION, SIGNAL(triggered()), this, SLOT(designDetails()));   }
    else if(icon == "exit")                     { ACTION->setShortcut(QKeySequence("Ctrl+Q")); connect(ACTION, SIGNAL(triggered()), this, SLOT(exit()));            }

    else if(icon == "cut")                      { ACTION->setShortcut(QKeySequence::Cut);   connect(ACTION, SIGNAL(triggered()), this, SLOT(cut()));   }
    else if(icon == "copy")                     { ACTION->setShortcut(QKeySequence::Copy);  connect(ACTION, SIGNAL(triggered()), this, SLOT(copy()));  }
    else if(icon == "paste")                    { ACTION->setShortcut(QKeySequence::Paste); connect(ACTION, SIGNAL(triggered()), this, SLOT(paste())); }

    else if(icon == "windowcascade")              connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(cascade()));
    else if(icon == "windowtile")                 connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(tile()));
    else if(icon == "windowcloseall")             connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows()));
    else if(icon == "windownext")               { ACTION->setShortcut(QKeySequence::NextChild);     connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow()));     }
    else if(icon == "windowprevious")           { ACTION->setShortcut(QKeySequence::PreviousChild); connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); }

    else if(icon == "help")                       connect(ACTION, SIGNAL(triggered()), this, SLOT(help()));
    else if(icon == "changelog")                  connect(ACTION, SIGNAL(triggered()), this, SLOT(changelog()));
    else if(icon == "tipoftheday")                connect(ACTION, SIGNAL(triggered()), this, SLOT(tipOfTheDay()));
    else if(icon == "about")                      connect(ACTION, SIGNAL(triggered()), this, SLOT(about()));
    else if(icon == "aboutQt")                    connect(ACTION, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    else if(icon == "icon16")                     connect(ACTION, SIGNAL(triggered()), this, SLOT(icon16()));
    else if(icon == "icon24")                     connect(ACTION, SIGNAL(triggered()), this, SLOT(icon24()));
    else if(icon == "icon32")                     connect(ACTION, SIGNAL(triggered()), this, SLOT(icon32()));
    else if(icon == "icon48")                     connect(ACTION, SIGNAL(triggered()), this, SLOT(icon48()));
    else if(icon == "icon64")                     connect(ACTION, SIGNAL(triggered()), this, SLOT(icon64()));
    else if(icon == "icon128")                    connect(ACTION, SIGNAL(triggered()), this, SLOT(icon128()));

    else if(icon == "settingsdialog")             connect(ACTION, SIGNAL(triggered()), this, SLOT(settingsDialog()));

    else if(icon == "undo")                       connect(ACTION, SIGNAL(triggered()), this, SLOT(undo()));
    else if(icon == "redo")                       connect(ACTION, SIGNAL(triggered()), this, SLOT(redo()));

    else if(icon == "makelayercurrent")           connect(ACTION, SIGNAL(triggered()), this, SLOT(makeLayerActive()));
    else if(icon == "layers")                     connect(ACTION, SIGNAL(triggered()), this, SLOT(layerManager()));
    else if(icon == "layerprevious")              connect(ACTION, SIGNAL(triggered()), this, SLOT(layerPrevious()));

    else if(icon == "textbold")                 { ACTION->setCheckable(true); connect(ACTION, SIGNAL(toggled(bool)), this, SLOT(setTextBold(bool)));   }
void Double2StringFilterSetFormatCmd::undo() { redo(); }
Esempio n. 21
0
MRichTextEdit::MRichTextEdit(QWidget *parent)
    : QWidget(parent)
{
    setupUi(this);
    m_lastBlockList = 0;
    f_textedit->setTabStopWidth(40);

    connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this,     SLOT(slotCurrentCharFormatChanged(QTextCharFormat)));
    connect(f_textedit, SIGNAL(cursorPositionChanged()),
            this,     SLOT(slotCursorPositionChanged()));

    m_fontsize_h1 = 18;
    m_fontsize_h2 = 16;
    m_fontsize_h3 = 14;
    m_fontsize_h4 = 12;

    fontChanged(f_textedit->font());
    bgColorChanged(f_textedit->textColor());

    // paragraph formatting

    m_paragraphItems    << tr("Standard")
                        << tr("Heading 1")
                        << tr("Heading 2")
                        << tr("Heading 3")
                        << tr("Heading 4")
                        << tr("Monospace");
    f_paragraph->addItems(m_paragraphItems);

    connect(f_paragraph, SIGNAL(activated(int)),
            this, SLOT(textStyle(int)));

    // undo & redo

    f_undo->setShortcut(QKeySequence::Undo);
    f_redo->setShortcut(QKeySequence::Redo);

    connect(f_textedit->document(), SIGNAL(undoAvailable(bool)),
            f_undo, SLOT(setEnabled(bool)));
    connect(f_textedit->document(), SIGNAL(redoAvailable(bool)),
            f_redo, SLOT(setEnabled(bool)));

    f_undo->setEnabled(f_textedit->document()->isUndoAvailable());
    f_redo->setEnabled(f_textedit->document()->isRedoAvailable());

    connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo()));
    connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo()));

    // cut, copy & paste
    f_cut->setShortcut(QKeySequence::Cut);
    f_copy->setShortcut(QKeySequence::Copy);
    f_paste->setShortcut(QKeySequence::Paste);

    f_cut->setEnabled(false);
    f_copy->setEnabled(false);

    connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut()));
    connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy()));
    connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste()));

    connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool)));
    connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool)));

#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged()));
#endif

    // link
    f_link->setShortcut(Qt::CTRL + Qt::Key_L);

    connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool)));

    // bold, italic & underline
    f_bold->setShortcut(Qt::CTRL + Qt::Key_B);
    f_italic->setShortcut(Qt::CTRL + Qt::Key_I);
    f_underline->setShortcut(Qt::CTRL + Qt::Key_U);

    connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold()));
    connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic()));
    connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline()));
    connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout()));

    // lists
    f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus);
    f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal);

    connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool)));
    connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool)));

    // indentation
    f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma);
    f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period);

    connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation()));
    connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation()));

    // font size
    QFontDatabase db;
    foreach(int size, db.standardSizes())
    {
        f_fontsize->addItem(QString::number(size));
    }

    connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString)));
    f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font().pointSize())));


    // text background color
    QPixmap pix(16, 16);
    pix.fill(QApplication::palette().background().color());
    f_bgcolor->setIcon(pix);

    connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor()));

    // images
    connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage()));
}
Esempio n. 22
0
void LircCommander::slotExecute(const char *command)
{
    struct command tmp, *res;

    RG_DEBUG << "LircCommander::slotExecute: invoking command: " << command;

    // find the function for the name
    tmp.name = command;
    res = (struct command *)bsearch(&tmp, commands,
                                    sizeof(commands) / sizeof(struct command),
                                    sizeof(struct command),
                                    compareCommandName);
    if (res != NULL)
    {
        switch (res->code)
        {
        case cmd_play:
            emit play();
            break;
        case cmd_stop:
            emit stop();
            break;
        case cmd_record:
            emit record();
            break;
        case cmd_rewind:
            emit rewind();
            break;
        case cmd_rewindToBeginning:
            emit rewindToBeginning();
            break;
        case cmd_fastForward:
            emit fastForward();
            break;
        case cmd_fastForwardToEnd:
            emit fastForwardToEnd();
            break;
        case cmd_toggleRecord:
            emit toggleRecord();
            break;
        case cmd_trackDown:
            emit trackDown();
            break;
        case cmd_trackUp:
            emit trackUp();
            break;
        case cmd_trackMute:
            emit trackMute(); 
            break;
        case cmd_trackRecord:
            emit trackRecord(); 
            break;
        case cmd_undo:
            emit undo(); 
            break;
        case cmd_redo:
            emit redo(); 
            break;
        case cmd_aboutrg:
            emit aboutrg(); 
            break;
        case cmd_editInEventList:
            emit editInEventList(); 
            break;
        case cmd_editInMatrix:
            emit editInMatrix(); 
            break;
        case cmd_editInPercussionMatrix:
            emit editInPercussionMatrix(); 
            break;
        case cmd_editAsNotation:
            emit editAsNotation(); 
            break;
        case cmd_quit:
            emit quit(); 
            break;
        case cmd_closeTransport:
            emit closeTransport(); 
            break;
        case cmd_toggleTransportVisibility:
            emit toggleTransportVisibility(); 
            break;
        default:
            RG_DEBUG <<  "LircCommander::slotExecute: unhandled command " << command;
            return;
        }
        RG_DEBUG <<  "LircCommander::slotExecute: handled command: " << command;
    }
    else
    {
        RG_DEBUG <<  "LircCommander::slotExecute: invoking command: " << command
                 <<  " failed (command not defined in LircCommander::commands[])" << endl;
    };
}
Esempio n. 23
0
/* create tool bar */
void MainWindow::createToolBar ()
{
    newToolButton = new QToolButton;
    newToolButton->setIconSize(QSize(50, 50));
    newToolButton->setIcon(QIcon::fromTheme("window-new"));
    newToolButton->setToolTip(tr("Create a new Petri Net <span style=\"color:gray;\">Ctrl+N</span>"));
    connect(newToolButton, SIGNAL(clicked()), tabWidget, SLOT(createNew()));
        openToolButton = new QToolButton;
    openToolButton->setIconSize(QSize(50, 50));
    openToolButton->setIcon(QIcon::fromTheme("folder-open"));
    openToolButton->setToolTip(tr("Open a Petri Net document <span style=\"color:gray;\">Ctrl+O</span>"));
    connect(openToolButton, SIGNAL(clicked()), this, SLOT(open()));
        saveToolButton = new QToolButton;
    saveToolButton->setIconSize(QSize(50, 50));
    saveToolButton->setIcon(QIcon::fromTheme("document-save"));
    saveToolButton->setToolTip(tr("Save the current Petri Net <span style=\"color:gray;\">Ctrl+S</span>"));
    connect(saveToolButton, SIGNAL(clicked()), tabWidget, SLOT(save()));
        undoToolButton = new QToolButton;
    undoToolButton->setIconSize(QSize(50, 50));
    undoToolButton->setIcon(QIcon::fromTheme("edit-undo"));
    undoToolButton->setToolTip(tr("Undo the last action <span style=\"color:gray;\">Ctrl+Z</span>"));
    undoToolButton->setEnabled(false);
    connect(undoToolButton, SIGNAL(clicked()), tabWidget, SLOT(undo ()));
    connect(tabWidget, SIGNAL(canUndoChange (bool)), undoToolButton, SLOT(setEnabled (bool)));
        redoToolButton = new QToolButton;
    redoToolButton->setIconSize(QSize(50, 50));
    redoToolButton->setIcon(QIcon::fromTheme("edit-redo"));
    redoToolButton->setToolTip(tr("Redo the last undone action <span style=\"color:gray;\">Ctrl+Shif+Z</span>"));
    redoToolButton->setEnabled(false);
    connect(redoToolButton, SIGNAL(clicked()), tabWidget, SLOT(redo ()));
    connect(tabWidget, SIGNAL(canRedoChange(bool)), redoToolButton, SLOT(setEnabled (bool)));
        removeToolButton = new QToolButton;
    removeToolButton->setIconSize(QSize(50, 50));
    removeToolButton->setIcon(QIcon::fromTheme("edit-delete"));
    removeToolButton->setToolTip(tr("Remove the selected items <span style=\"color:gray;\">Del</span> "));
    connect(removeToolButton, SIGNAL(clicked()), tabWidget, SLOT(removeItems ()));
        cursorToolButton = new QToolButton;
    cursorToolButton->setIconSize(QSize(50, 50));
    cursorToolButton->setCheckable(true);
    cursorToolButton->setIcon(QIcon(QPixmap(":/images/cursor.png")));
    cursorToolButton->setToolTip(tr("Normal cursor"));
        addPlaceToolButton = new QToolButton;
    addPlaceToolButton->setIconSize(QSize(50, 50));
    addPlaceToolButton->setCheckable(true);
    addPlaceToolButton->setIcon(QIcon(QPixmap(":/images/place.png")));
    addPlaceToolButton->setToolTip(tr("Add places"));
        addTransToolButton = new QToolButton;
    addTransToolButton->setIconSize(QSize(50, 50));
    addTransToolButton->setCheckable(true);
    addTransToolButton->setIcon(QIcon(QPixmap(":/images/transition.png")));
    addTransToolButton->setToolTip(tr("Add transitions"));
        drawArcToolButton = new QToolButton;
    drawArcToolButton->setIconSize(QSize(50, 50));
    drawArcToolButton->setCheckable(true);
    drawArcToolButton->setIcon(QIcon(QPixmap(":/images/arc.png")));
    drawArcToolButton->setToolTip(tr("Draw Polylines Arcs"));
        addTokenToolButton = new QToolButton;
    addTokenToolButton->setIconSize(QSize(50, 50));
    addTokenToolButton->setCheckable(true);
    addTokenToolButton->setIcon(QIcon(QPixmap(":/images/token+.png")));
    addTokenToolButton->setToolTip(tr("Add Tokens"));
        subTokenToolButton = new QToolButton;
    subTokenToolButton->setIconSize(QSize(50, 50));
    subTokenToolButton->setCheckable(true);
    subTokenToolButton->setIcon(QIcon(QPixmap(":/images/token-.png")));
    subTokenToolButton->setToolTip(tr("Delete Tokens"));
        animateToolButton = new QToolButton;
    animateToolButton->setIconSize(QSize(50, 50));
    animateToolButton->setCheckable(true);
    animateToolButton->setIcon(QIcon(QPixmap(":/images/animate.png")));
    animateToolButton->setToolTip(tr("Animate the current drawen net"));

    buttonGroup = new QButtonGroup (this);
    buttonGroup->setExclusive(true);
    buttonGroup->addButton(cursorToolButton,      normalMode);
    buttonGroup->addButton(addPlaceToolButton,    addPlaceMode);
    buttonGroup->addButton(addTransToolButton,    addTransMode);
    buttonGroup->addButton(drawArcToolButton,     drawArcMode);
    buttonGroup->addButton(animateToolButton,     animationMode);
    buttonGroup->addButton(addTokenToolButton,    addToken);
    buttonGroup->addButton(subTokenToolButton,    subToken);
        connect(buttonGroup, SIGNAL(buttonClicked (int)),
                this, SLOT(buttonGroupClicked(int)));

    // default mode = normal mode
    cursorToolButton->setChecked (true);

    toolBar = new QToolBar;
    toolBar->addWidget(newToolButton);
    toolBar->addWidget(openToolButton);
    toolBar->addWidget(saveToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(undoToolButton);
    toolBar->addWidget(redoToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(removeToolButton);
    toolBar->addWidget(cursorToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(addPlaceToolButton);
    toolBar->addWidget(addTransToolButton);
    toolBar->addWidget(drawArcToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(addTokenToolButton);
    toolBar->addWidget(subTokenToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(animateToolButton);

    toolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea | Qt::RightToolBarArea);
    addToolBar(Qt::LeftToolBarArea, toolBar);
}
Esempio n. 24
0
void Editor::MenuRedo(void)
{
	redo();
}
Esempio n. 25
0
void ScenarioContextMenuManager::createSlotContextMenu(
        const iscore::DocumentContext& ctx,
        QMenu& menu,
        const SlotPresenter& slotp)
{
    auto& slotm = slotp.model();

    // First changing the process in the current slot
    auto processes_submenu = menu.addMenu(tr("Focus process in this slot"));
    for(const LayerModel& proc : slotm.layers)
    {
        QAction* procAct = new QAction{
                           proc.processModel().prettyName(),
                           processes_submenu};
        QObject::connect(procAct, &QAction::triggered, [&] () {
            PutLayerModelToFront cmd{slotm, proc.id()};
            cmd.redo();
        } );
        processes_submenu->addAction(procAct);
    }

    // Then creation of a new slot with existing processes
    auto new_processes_submenu = menu.addMenu(tr("Show process in new slot"));
    for(const LayerModel& proc : slotm.layers)
    {
        QAction* procAct = new QAction{
                           proc.processModel().prettyName(),
                           new_processes_submenu};
        QObject::connect(procAct, &QAction::triggered, [&] () {
            auto cmd = new Scenario::Command::AddLayerInNewSlot{
                       slotm.parentConstraint(),
                       proc.processModel().id()};
            CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd);
        } );
        new_processes_submenu->addAction(procAct);
    }

    // Then removal of slot
    auto removeSlotAct = new QAction{tr("Remove this slot"), nullptr};
    QObject::connect(removeSlotAct, &QAction::triggered, [&] () {
        auto cmd = new Scenario::Command::RemoveSlotFromRack{slotm};
        CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd);
    });
    menu.addAction(removeSlotAct);

    menu.addSeparator();

    // Then Add process in this slot
    auto existing_processes_submenu = menu.addMenu(tr("Add existing process in this slot"));
    for(const Process& proc : slotm.parentConstraint().processes)
    {
        // OPTIMIZEME by filtering before.
        if(std::none_of(slotm.layers.begin(), slotm.layers.end(), [&] (const LayerModel& layer) {
                        return &layer.processModel() == &proc;
    }))
        {
            QAction* procAct = new QAction{proc.prettyName(), existing_processes_submenu};
            QObject::connect(procAct, &QAction::triggered, [&] () {

                auto cmd2 = new Scenario::Command::AddLayerModelToSlot{
                            slotm,
                            proc};
                CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd2);
            } );
            existing_processes_submenu->addAction(procAct);
        }
    }

    auto addNewProcessInExistingSlot = new QAction{tr("Add new process in this slot"), &menu};
    QObject::connect(addNewProcessInExistingSlot, &QAction::triggered,
            [&] () {
        auto& fact = ctx.app.components.factory<DynamicProcessList>();
        AddProcessDialog dialog{fact, qApp->activeWindow()};

        QObject::connect(&dialog, &AddProcessDialog::okPressed,
            [&] (const auto& proc) {
            auto& constraint = slotm.parentConstraint();
            QuietMacroCommandDispatcher disp{
                new CreateProcessInExistingSlot,
                        ctx.commandStack};

            auto cmd1 = new AddOnlyProcessToConstraint{constraint, proc};
            cmd1->redo();
            disp.submitCommand(cmd1);

            auto cmd2 = new Scenario::Command::AddLayerModelToSlot{
                        slotm,
                        constraint.processes.at(cmd1->processId())};
            cmd2->redo();
            disp.submitCommand(cmd2);

            disp.commit();
        });

        dialog.launchWindow();
    });
    menu.addAction(addNewProcessInExistingSlot);

    // Then Add process in a new slot
    auto addNewProcessInNewSlot = new QAction{tr("Add process in a new slot"), &menu};
    QObject::connect(addNewProcessInNewSlot, &QAction::triggered,
            [&] () {
        auto& fact = ctx.app.components.factory<DynamicProcessList>();
        AddProcessDialog dialog{fact, qApp->activeWindow()};

        QObject::connect(&dialog, &AddProcessDialog::okPressed,
            [&] (const auto& proc) {
            auto& constraint = slotm.parentConstraint();
            QuietMacroCommandDispatcher disp{
                new CreateProcessInNewSlot,
                        ctx.commandStack};

            auto cmd1 = new AddOnlyProcessToConstraint{constraint, proc};
            cmd1->redo();
            disp.submitCommand(cmd1);

            auto& rack = slotm.rack();
            auto cmd2 = new Scenario::Command::AddSlotToRack{rack};
            cmd2->redo();
            disp.submitCommand(cmd2);

            auto cmd3 = new Scenario::Command::AddLayerModelToSlot{
                        rack.slotmodels.at(cmd2->createdSlot()),
                        constraint.processes.at(cmd1->processId())};
            cmd3->redo();
            disp.submitCommand(cmd3);

            disp.commit();
        });

        dialog.launchWindow();
    });
    menu.addAction(addNewProcessInNewSlot);

    menu.addSeparator();
}
Esempio n. 26
0
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
{
	switch(command) {
		case HOTKEY_CYCLE_UNITS:
			cycle_units();
			break;
		case HOTKEY_CYCLE_BACK_UNITS:
			cycle_back_units();
			break;
		case HOTKEY_ENDTURN:
			end_turn();
			break;
		case HOTKEY_UNIT_HOLD_POSITION:
			unit_hold_position();
			break;
		case HOTKEY_END_UNIT_TURN:
			end_unit_turn();
			break;
		case HOTKEY_LEADER:
			goto_leader();
			break;
		case HOTKEY_UNDO:
			undo();
			break;
		case HOTKEY_REDO:
			redo();
			break;
		case HOTKEY_UNIT_DESCRIPTION:
			unit_description();
			break;
		case HOTKEY_RENAME_UNIT:
			rename_unit();
			break;
		case HOTKEY_SAVE_GAME:
			save_game();
			break;
		case HOTKEY_SAVE_REPLAY:
			save_replay();
			break;
		case HOTKEY_SAVE_MAP:
			save_map();
			break;
		case HOTKEY_LOAD_GAME:
			load_game();
			break;
		case HOTKEY_TOGGLE_ELLIPSES:
			toggle_ellipses();
			break;
		case HOTKEY_TOGGLE_GRID:
			toggle_grid();
			break;
		case HOTKEY_STATUS_TABLE:
			status_table();
			break;
		case HOTKEY_RECALL:
			recall();
			break;
		case HOTKEY_RECRUIT:
			recruit();
			break;
		case hotkey::HOTKEY_REPEAT_RECRUIT:
			repeat_recruit();
			break;
		case HOTKEY_SPEAK:
			speak();
			break;
		case HOTKEY_SPEAK_ALLY:
			whisper();
			break;
		case HOTKEY_SPEAK_ALL:
			shout();
			break;
		case HOTKEY_CREATE_UNIT:
			create_unit();
			break;
		case HOTKEY_CHANGE_SIDE:
			change_side();
			break;
		case HOTKEY_PREFERENCES:
			preferences();
			break;
		case HOTKEY_OBJECTIVES:
			objectives();
			break;
		case HOTKEY_UNIT_LIST:
			unit_list();
			break;
		case HOTKEY_STATISTICS:
			show_statistics();
			break;
		case HOTKEY_STOP_NETWORK:
			stop_network();
			break;
		case HOTKEY_START_NETWORK:
			start_network();
			break;
		case HOTKEY_LABEL_TEAM_TERRAIN:
			label_terrain(true);
			break;
		case HOTKEY_LABEL_TERRAIN:
			label_terrain(false);
			break;
		case HOTKEY_CLEAR_LABELS:
			clear_labels();
			break;
		case HOTKEY_SHOW_ENEMY_MOVES:
			show_enemy_moves(false);
			break;
		case HOTKEY_BEST_ENEMY_MOVES:
			show_enemy_moves(true);
			break;
		case HOTKEY_DELAY_SHROUD:
			toggle_shroud_updates();
			break;
		case HOTKEY_UPDATE_SHROUD:
			update_shroud_now();
			break;
		case HOTKEY_CONTINUE_MOVE:
			continue_move();
			break;
		case HOTKEY_SEARCH:
			search();
			break;
		case HOTKEY_HELP:
			show_help();
			break;
		case HOTKEY_CHAT_LOG:
			show_chat_log();
			break;
		case HOTKEY_USER_CMD:
			user_command();
			break;
		case HOTKEY_CUSTOM_CMD:
			custom_command();
			break;
		case HOTKEY_AI_FORMULA:
			ai_formula();
			break;
		case HOTKEY_CLEAR_MSG:
			clear_messages();
			break;
		 case HOTKEY_LANGUAGE:
			change_language();
			break;
		 case HOTKEY_PLAY_REPLAY:
			play_replay();
			 break;
		 case HOTKEY_RESET_REPLAY:
			reset_replay();
			 break;
		 case HOTKEY_STOP_REPLAY:
			 stop_replay();
			 break;
		 case HOTKEY_REPLAY_NEXT_TURN:
			replay_next_turn();
			 break;
		 case HOTKEY_REPLAY_NEXT_SIDE:
			replay_next_side();
			 break;
		 case HOTKEY_REPLAY_SHOW_EVERYTHING:
			replay_show_everything();
			 break;
		 case HOTKEY_REPLAY_SHOW_EACH:
			replay_show_each();
			 break;
		 case HOTKEY_REPLAY_SHOW_TEAM1:
			replay_show_team1();
			 break;
		 case HOTKEY_REPLAY_SKIP_ANIMATION:
			replay_skip_animation();
			 break;
		 case HOTKEY_WB_TOGGLE:
			 whiteboard_toggle();
			 break;
		 case HOTKEY_WB_EXECUTE_ACTION:
			 whiteboard_execute_action();
			 break;
		 case HOTKEY_WB_EXECUTE_ALL_ACTIONS:
			 whiteboard_execute_all_actions();
			 break;
		 case HOTKEY_WB_DELETE_ACTION:
			 whiteboard_delete_action();
			 break;
		 case HOTKEY_WB_BUMP_UP_ACTION:
			 whiteboard_bump_up_action();
			 break;
		 case HOTKEY_WB_BUMP_DOWN_ACTION:
			 whiteboard_bump_down_action();
			 break;
		 case HOTKEY_WB_SUPPOSE_DEAD:
			 whiteboard_suppose_dead();
			 break;
		 case HOTKEY_LEFT_MOUSE_CLICK:
			 left_mouse_click();
			 break;
		 case HOTKEY_RIGHT_MOUSE_CLICK:
			 right_mouse_click();
			 break;
		 default:
			 return false;
	}
	return true;
}
Esempio n. 27
0
/* TextEdit */
TextEdit::TextEdit(QWidget *parent)
    : QMainWindow(parent)
{
    setIconSize(QSize(16, 16));
    setToolButtonStyle(Qt::ToolButtonFollowStyle);
    setupFileActions();
    setupEditActions();
    setupViewActions();
    setupTextActions();

    QStatusBar *pStatusBar = statusBar();
    pStatusBar->showMessage(tr("Ready"));

    {
        QMenu *helpMenu = new QMenu(tr("Help"), this);
        menuBar()->addMenu(helpMenu);
        helpMenu->addAction(tr("About"), this, SLOT(about()));
    }

    textEdit = new QTextEdit(this);
    connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat)));
    connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));

    setCentralWidget(textEdit);
    textEdit->setFocus();
    setCurrentFileName(QString());

    fontChanged(textEdit->font());
    colorChanged(textEdit->textColor());
    alignmentChanged(textEdit->alignment());

    connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
    connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool)));

    setWindowModified(textEdit->document()->isModified());
    actionSave->setEnabled(textEdit->document()->isModified());
    actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
    actionRedo->setEnabled(textEdit->document()->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));

    actionCut->setEnabled(false);
    actionCopy->setEnabled(false);

    connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));

    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif

    QString initialFile = ":/example.html";
    const QStringList args = QCoreApplication::arguments();
    if (args.count() == 2)
        initialFile = args.at(1);

    if (!load(initialFile))
        fileNew();

    QRect geom = QApplication::desktop()->availableGeometry();
    resize( 2 * geom.width() / 3, 2 * geom.height() / 3 );
}
Esempio n. 28
0
void MainWindow::finalize()
{
	resetWindowTitle();
	setWindowIcon( embed::getIconPixmap( "icon" ) );


	// project-popup-menu
	QMenu * project_menu = new QMenu( this );
	menuBar()->addMenu( project_menu )->setText( tr( "&File" ) );
	project_menu->addAction( embed::getIconPixmap( "project_new" ),
					tr( "&New" ),
					this, SLOT( createNewProject() ),
					QKeySequence::New );

	m_templatesMenu = new QMenu( tr("New from template"), this );
	connect( m_templatesMenu, SIGNAL( aboutToShow() ), SLOT( fillTemplatesMenu() ) );
	connect( m_templatesMenu, SIGNAL( triggered( QAction * ) ),
		 SLOT( createNewProjectFromTemplate( QAction * ) ) );

	project_menu->addMenu(m_templatesMenu);

	project_menu->addAction( embed::getIconPixmap( "project_open" ),
					tr( "&Open..." ),
					this, SLOT( openProject() ),
					QKeySequence::Open );

	m_recentlyOpenedProjectsMenu = project_menu->addMenu(
				embed::getIconPixmap( "project_open_recent" ),
					tr( "&Recently Opened Projects" ) );
	connect( m_recentlyOpenedProjectsMenu, SIGNAL( aboutToShow() ),
			this, SLOT( updateRecentlyOpenedProjectsMenu() ) );
	connect( m_recentlyOpenedProjectsMenu, SIGNAL( triggered( QAction * ) ),
			this, SLOT( openRecentlyOpenedProject( QAction * ) ) );

	project_menu->addAction( embed::getIconPixmap( "project_save" ),
					tr( "&Save" ),
					this, SLOT( saveProject() ),
					QKeySequence::Save );
	project_menu->addAction( embed::getIconPixmap( "project_saveas" ),
					tr( "Save &As..." ),
					this, SLOT( saveProjectAs() ),
					Qt::CTRL + Qt::SHIFT + Qt::Key_S );
	project_menu->addAction( embed::getIconPixmap( "project_save" ),
					tr( "Save as New &Version" ),
					this, SLOT( saveProjectAsNewVersion() ),
					Qt::CTRL + Qt::ALT + Qt::Key_S );

	project_menu->addAction( tr( "Save as default template" ),
				     this, SLOT( saveProjectAsDefaultTemplate() ) );

	project_menu->addSeparator();
	project_menu->addAction( embed::getIconPixmap( "project_import" ),
					tr( "Import..." ),
					Engine::getSong(),
					SLOT( importProject() ) );
	project_menu->addAction( embed::getIconPixmap( "project_export" ),
					tr( "E&xport..." ),
					Engine::getSong(),
					SLOT( exportProject() ),
					Qt::CTRL + Qt::Key_E );
	project_menu->addAction( embed::getIconPixmap( "project_export" ),
					tr( "E&xport Tracks..." ),
					Engine::getSong(),
					SLOT( exportProjectTracks() ),
					Qt::CTRL + Qt::SHIFT + Qt::Key_E );

	project_menu->addAction( embed::getIconPixmap( "midi_file" ),
					tr( "Export &MIDI..." ),
					Engine::getSong(),
					SLOT( exportProjectMidi() ),
					Qt::CTRL + Qt::Key_M );

	project_menu->addSeparator();
	project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ),
					qApp, SLOT( closeAllWindows() ),
					Qt::CTRL + Qt::Key_Q );


	QMenu * edit_menu = new QMenu( this );
	menuBar()->addMenu( edit_menu )->setText( tr( "&Edit" ) );
	m_undoAction = edit_menu->addAction( embed::getIconPixmap( "edit_undo" ),
					tr( "Undo" ),
					this, SLOT( undo() ),
					QKeySequence::Undo );
	m_redoAction = edit_menu->addAction( embed::getIconPixmap( "edit_redo" ),
					tr( "Redo" ),
					this, SLOT( redo() ),
					QKeySequence::Redo );
	// Ensure that both (Ctrl+Y) and (Ctrl+Shift+Z) activate redo shortcut regardless of OS defaults
	if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::Key_Y))
	{
		new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_Y ), this, SLOT(redo()) );
	}
	if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z ))
	{
		new QShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_Z ), this, SLOT(redo()) );
	}

	edit_menu->addSeparator();
	edit_menu->addAction( embed::getIconPixmap( "setup_general" ),
					tr( "Settings" ),
					this, SLOT( showSettingsDialog() ) );
	connect( edit_menu, SIGNAL(aboutToShow()), this, SLOT(updateUndoRedoButtons()) );

	m_viewMenu = new QMenu( this );
	menuBar()->addMenu( m_viewMenu )->setText( tr( "&View" ) );
	connect( m_viewMenu, SIGNAL( aboutToShow() ),
		 this, SLOT( updateViewMenu() ) );
	connect( m_viewMenu, SIGNAL(triggered(QAction*)), this,
		SLOT(updateConfig(QAction*)));


	m_toolsMenu = new QMenu( this );
	for( const Plugin::Descriptor* desc : pluginFactory->descriptors(Plugin::Tool) )
	{
		m_toolsMenu->addAction( desc->logo->pixmap(), desc->displayName );
		m_tools.push_back( ToolPlugin::instantiate( desc->name, /*this*/NULL )
						   ->createView(this) );
	}
	if( !m_toolsMenu->isEmpty() )
	{
		menuBar()->addMenu( m_toolsMenu )->setText( tr( "&Tools" ) );
		connect( m_toolsMenu, SIGNAL( triggered( QAction * ) ),
					this, SLOT( showTool( QAction * ) ) );
	}
Esempio n. 29
0
 virtual bool perform(ExceptionState& es)
 {
     m_oldText = m_textNode->wholeText();
     return redo(es);
 }
Esempio n. 30
0
// ********************************************************************** Handle events
void QHexEdit::keyPressEvent(QKeyEvent *event)
{
    // Cursor movements
    if (event->matches(QKeySequence::MoveToNextChar))
    {
        qint64 pos = _cursorPosition + 1;
        if (_editAreaIsAscii)
            pos += 1;
        setCursorPosition(pos);
        resetSelection(pos);
    }
    if (event->matches(QKeySequence::MoveToPreviousChar))
    {
        qint64 pos = _cursorPosition - 1;
        if (_editAreaIsAscii)
            pos -= 1;
        setCursorPosition(pos);
        resetSelection(pos);
    }
    if (event->matches(QKeySequence::MoveToEndOfLine))
    {
        qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)) + (2 * _bytesPerLine) - 1;
        setCursorPosition(pos);
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToStartOfLine))
    {
        qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine));
        setCursorPosition(pos);
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToPreviousLine))
    {
        setCursorPosition(_cursorPosition - (2 * _bytesPerLine));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToNextLine))
    {
        setCursorPosition(_cursorPosition + (2 * _bytesPerLine));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToNextPage))
    {
        setCursorPosition(_cursorPosition + (((_rowsShown - 1) * 2 * _bytesPerLine)));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToPreviousPage))
    {
        setCursorPosition(_cursorPosition - (((_rowsShown - 1) * 2 * _bytesPerLine)));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToEndOfDocument))
    {
        setCursorPosition(_chunks->size() * 2 );
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToStartOfDocument))
    {
        setCursorPosition(0);
        resetSelection(_cursorPosition);
    }

    // Select commands
    if (event->matches(QKeySequence::SelectAll))
    {
        resetSelection(0);
        setSelection(2 * _chunks->size() + 1);
    }
    if (event->matches(QKeySequence::SelectNextChar))
    {
        qint64 pos = _cursorPosition + 1;
        if (_editAreaIsAscii)
            pos += 1;
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectPreviousChar))
    {
        qint64 pos = _cursorPosition - 1;
        if (_editAreaIsAscii)
            pos -= 1;
        setSelection(pos);
        setCursorPosition(pos);
    }
    if (event->matches(QKeySequence::SelectEndOfLine))
    {
        qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)) + (2 * _bytesPerLine) - 1;
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectStartOfLine))
    {
        qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine));
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectPreviousLine))
    {
        qint64 pos = _cursorPosition - (2 * _bytesPerLine);
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectNextLine))
    {
        qint64 pos = _cursorPosition + (2 * _bytesPerLine);
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectNextPage))
    {
        qint64 pos = _cursorPosition + (((viewport()->height() / _pxCharHeight) - 1) * 2 * _bytesPerLine);
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectPreviousPage))
    {
        qint64 pos = _cursorPosition - (((viewport()->height() / _pxCharHeight) - 1) * 2 * _bytesPerLine);
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectEndOfDocument))
    {
        qint64 pos = _chunks->size() * 2;
        setCursorPosition(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectStartOfDocument))
    {
        qint64 pos = 0;
        setCursorPosition(pos);
        setSelection(pos);
    }

    // Edit Commands
    if (!_readOnly)
    {
        /* Cut */
        if (event->matches(QKeySequence::Cut))
        {
            QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex();
            for (qint64 idx = 32; idx < ba.size(); idx +=33)
                ba.insert(idx, "\n");
            QClipboard *clipboard = QApplication::clipboard();
            clipboard->setText(ba);
            if (_overwriteMode)
            {
                qint64 len = getSelectionEnd() - getSelectionBegin();
                replace(getSelectionBegin(), (int)len, QByteArray((int)len, char(0)));
            }
            else
            {
                remove(getSelectionBegin(), getSelectionEnd() - getSelectionBegin());
            }
            setCursorPosition(2 * getSelectionBegin());
            resetSelection(2 * getSelectionBegin());
        } else

        /* Paste */
        if (event->matches(QKeySequence::Paste))
        {
            QClipboard *clipboard = QApplication::clipboard();
            QByteArray ba = QByteArray().fromHex(clipboard->text().toLatin1());
            if (_overwriteMode)
            {
                ba = ba.left(std::min<qint64>(ba.size(), (_chunks->size() - _bPosCurrent)));
                replace(_bPosCurrent, ba.size(), ba);
            }
            else
                insert(_bPosCurrent, ba);
            setCursorPosition(_cursorPosition + 2 * ba.size());
            resetSelection(getSelectionBegin());
        } else

        /* Delete char */
        if (event->matches(QKeySequence::Delete))
        {
            if (getSelectionBegin() != getSelectionEnd())
            {
                _bPosCurrent = getSelectionBegin();
                if (_overwriteMode)
                {
                    QByteArray ba = QByteArray(getSelectionEnd() - getSelectionBegin(), char(0));
                    replace(_bPosCurrent, ba.size(), ba);
                }
                else
                {
                    remove(_bPosCurrent, getSelectionEnd() - getSelectionBegin());
                }
            }
            else
            {
                if (_overwriteMode)
                    replace(_bPosCurrent, char(0));
                else
                    remove(_bPosCurrent, 1);
            }
            setCursorPosition(2 * _bPosCurrent);
            resetSelection(2 * _bPosCurrent);
        } else

        /* Backspace */
        if ((event->key() == Qt::Key_Backspace) && (event->modifiers() == Qt::NoModifier))
        {
            if (getSelectionBegin() != getSelectionEnd())
            {
                _bPosCurrent = getSelectionBegin();
                setCursorPosition(2 * _bPosCurrent);
                if (_overwriteMode)
                {
                    QByteArray ba = QByteArray(getSelectionEnd() - getSelectionBegin(), char(0));
                    replace(_bPosCurrent, ba.size(), ba);
                }
                else
                {
                    remove(_bPosCurrent, getSelectionEnd() - getSelectionBegin());
                }
                resetSelection(2 * _bPosCurrent);
            }
            else
            {
                bool behindLastByte = false;
                if ((_cursorPosition / 2) == _chunks->size())
                    behindLastByte = true;

                _bPosCurrent -= 1;
                if (_overwriteMode)
                    replace(_bPosCurrent, char(0));
                else
                    remove(_bPosCurrent, 1);

                if (!behindLastByte)
                    _bPosCurrent -= 1;

                setCursorPosition(2 * _bPosCurrent);
                resetSelection(2 * _bPosCurrent);
            }
        } else

        /* undo */
        if (event->matches(QKeySequence::Undo))
        {
            undo();
        } else

        /* redo */
        if (event->matches(QKeySequence::Redo))
        {
            redo();
        } else

        if ((QApplication::keyboardModifiers() == Qt::NoModifier) ||
            (QApplication::keyboardModifiers() == Qt::KeypadModifier) ||
            (QApplication::keyboardModifiers() == Qt::ShiftModifier) ||
            (QApplication::keyboardModifiers() == (Qt::AltModifier | Qt::ControlModifier)) ||
            (QApplication::keyboardModifiers() == Qt::GroupSwitchModifier))
        {
            /* Hex and ascii input */
            int key;
            if (_editAreaIsAscii)
                key = (uchar)event->text()[0].toLatin1();
            else
                key = int(event->text()[0].toLower().toLatin1());

            if ((((key >= '0' && key <= '9') || (key >= 'a' && key <= 'f')) && _editAreaIsAscii == false)
                || (key >= ' ' && _editAreaIsAscii))
            {
                if (getSelectionBegin() != getSelectionEnd())
                {
                    if (_overwriteMode)
                    {
                        qint64 len = getSelectionEnd() - getSelectionBegin();
                        replace(getSelectionBegin(), (int)len, QByteArray((int)len, char(0)));
                    } else
                    {
                        remove(getSelectionBegin(), getSelectionEnd() - getSelectionBegin());
                        _bPosCurrent = getSelectionBegin();
                    }
                    setCursorPosition(2 * _bPosCurrent);
                    resetSelection(2 * _bPosCurrent);
                }

                // If insert mode, then insert a byte
                if (_overwriteMode == false)
                    if ((_cursorPosition % 2) == 0)
                        insert(_bPosCurrent, char(0));

                // Change content
                if (_chunks->size() > 0)
                {
                    char ch = key;
                    if (!_editAreaIsAscii){
                        QByteArray hexValue = _chunks->data(_bPosCurrent, 1).toHex();
                        if ((_cursorPosition % 2) == 0)
                            hexValue[0] = key;
                        else
                            hexValue[1] = key;
                        ch = QByteArray().fromHex(hexValue)[0];
                    }
                    replace(_bPosCurrent, ch);
                    if (_editAreaIsAscii)
                        setCursorPosition(_cursorPosition + 2);
                    else
                        setCursorPosition(_cursorPosition + 1);
                    resetSelection(_cursorPosition);
                }
            }
        }


    }

    /* Copy */
    if (event->matches(QKeySequence::Copy))
    {
        QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex();
        for (qint64 idx = 32; idx < ba.size(); idx +=33)
            ba.insert(idx, "\n");
        QClipboard *clipboard = QApplication::clipboard();
        clipboard->setText(ba);
    }

    // Switch between insert/overwrite mode
    if ((event->key() == Qt::Key_Insert) && (event->modifiers() == Qt::NoModifier))
    {
        setOverwriteMode(!overwriteMode());
        setCursorPosition(_cursorPosition);
    }

    // switch from hex to ascii edit
    if (event->key() == Qt::Key_Tab && !_editAreaIsAscii){
        _editAreaIsAscii = true;
        setCursorPosition(_cursorPosition);
    }

    // switch from ascii to hex edit
    if (event->key() == Qt::Key_Backtab  && _editAreaIsAscii){
        _editAreaIsAscii = false;
        setCursorPosition(_cursorPosition);
    }

    refresh();
}