Exemple #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    TestAssistance *pt = TestAssistance::get();
    //main window init
    ui->setupUi(this);
    ui->toolBox->hide();
    if(pt->isUserAdmin()){
        ui->actionAdmin->setEnabled(true);
        ui->mainToolBar->addSeparator();
        ui->mainToolBar->addAction(ui->actionAdmin);
    }
    else
        ui->actionAdmin->setEnabled(false);
    setWindowTitle(tr("[*]自动出卷系统 ") + TESTASSITANCE_VERSION);
    setWindowIcon(QIcon(":/TestAssist.ico"));

    setupFileActions();
    setupEditActions();
    setupTextActions();

    //init editor
    initTextEditor();
    setWindowModified(false);
    setWelcomActions(false);

    //init status
    QLabel *plabel = new QLabel(ui->statusBar);
    plabel->setText("当前用户:" + pt->get()->getUserName() +
                    "    是否为管理员:" + (pt->get()->isUserAdmin()?"yes":"no"));
    ui->statusBar->addWidget(plabel);
}
DevGUI::DevGUI()
 : QMainWindow(0), noname_count(0)
{
	setupFileActions();
    setupEditActions();
    setupTextActions();
    setupCompiler();
    setupExplorer();
	
	Editor = new DevMDI(this);
	Editor->setWindowState(Qt::WindowMaximized);
    
	connect(Editor, SIGNAL(currentChanged(int)),
			this, SLOT(editorChanged()));
	setCentralWidget(Editor);

	connect(QApplication::clipboard()	, SIGNAL(dataChanged()),
			this						, SLOT  (clipboardDataChanged()) );
	
	for (int i = 1; i < DEV_APP->argc(); ++i)
		load(DEV_APP->argv()[i]);
	
	setWindowState(Qt::WindowMaximized);
	setWindowTitle("Dev-Qt++ 0.1.0 [*]");
	show();
}
Exemple #3
0
Help::Help( const QString& home, MainWindow* parent, const char *name )
#if defined(HAVE_KDE)
    : KMainWindow( 0, name, WType_TopLevel | WDestructiveClose | WGroupLeader ),
#else
    : QMainWindow( 0, name, WType_TopLevel | WDestructiveClose | WGroupLeader ),
#endif
      mainWindow( parent ), helpDialog( 0 )
{
    bookmarkMenu = 0;
    browser = new TextBrowser( this );
    browser->mimeSourceFactory()->setFilePath( home );
    browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
    browser->mimeSourceFactory()->addFilePath( QString( getenv( "QTDIR" ) ) + "/tools/designer/manual" );
    browser->mimeSourceFactory()->addFilePath( QString( getenv( "QTDIR" ) ) + "/doc/html/designer" );
    browser->mimeSourceFactory()->addFilePath( parent->documentationPath() );
    connect( browser, SIGNAL( textChanged() ),
	     this, SLOT( textChanged() ) );

    setCentralWidget( browser );

#if defined(HAVE_KDE)
    toolbar = new KToolBar( this );
#else
    toolbar = new QToolBar( this );
#endif
    addToolBar( toolbar, tr( "Tools" ) );

    setupFileActions();
    setupGoActions();
    setupBookmarkMenu();

    resize( 750,700 );

    setToolBarsMovable( FALSE );
}
Exemple #4
0
/** Constructor */
MessageWindow::MessageWindow(QWidget *parent, Qt::WindowFlags flags)
: RWindow("MessageWindow", parent, flags)
{
    /* Invoke the Qt Designer generated object setup routine */
    ui.setupUi(this);
        
	setAttribute ( Qt::WA_DeleteOnClose, true );

	actionSaveAs = NULL;
	actionPrint = NULL;
	actionPrintPreview = NULL;

	setupFileActions();

	connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));

	connect(ui.actionTextBesideIcon, SIGNAL(triggered()), this, SLOT(buttonStyle()));
	connect(ui.actionIconOnly, SIGNAL(triggered()), this, SLOT(buttonStyle()));
	connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonStyle()));

	ui.actionTextBesideIcon->setData(Qt::ToolButtonTextBesideIcon);
	ui.actionIconOnly->setData(Qt::ToolButtonIconOnly);
	ui.actionTextUnderIcon->setData(Qt::ToolButtonTextUnderIcon);

	msgWidget = NULL;
	
    // create tag menu
	TagsMenu *menu = new TagsMenu (tr("Tags"), this);
	connect(menu, SIGNAL(aboutToShow()), this, SLOT(tagAboutToShow()));
	connect(menu, SIGNAL(tagSet(int, bool)), this, SLOT(tagSet(int, bool)));
	connect(menu, SIGNAL(tagRemoveAll()), this, SLOT(tagRemoveAll()));

	ui.tagButton->setMenu(menu);
    
    // create print menu
	QMenu *printmenu = new QMenu();
	printmenu->addAction(ui.actionPrint);
	printmenu->addAction(ui.actionPrint_Preview);
	ui.printbutton->setMenu(printmenu);

	// create view menu
	QMenu *viewmenu = new QMenu();
	viewmenu->addAction(ui.actionTextBesideIcon);
	viewmenu->addAction(ui.actionIconOnly);
	//viewmenu->addAction(ui.actionTextUnderIcon);
	ui.viewtoolButton->setMenu(viewmenu);

	processSettings(true);

    /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
TextEdit::TextEdit( QWidget *parent, const char *name )
    : QMainWindow( parent, name, 0 )
{
    setupFileActions();
    setupEditActions();
    setupTextActions();

    tabWidget = new QTabWidget( this );
    connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
	     this, SLOT( editorChanged( QWidget * ) ) );
    setCentralWidget( tabWidget );
}
Exemple #6
0
TextEdit::TextEdit( QWidget *parent, const char *name )
    : QMainWindow( parent, name )
{
    setupFileActions();
    setupEditActions();
    setupTextActions();

    tabWidget = new QTabWidget( this );
    connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
	     this, SLOT( editorChanged( QWidget * ) ) );
    setCentralWidget( tabWidget );

    if ( qApp->argc() == 1 ) {
	load( "example.html" );
    } else {
	for ( int i = 1; i < qApp->argc(); ++i )
	    load( qApp->argv()[ i ] );
    }
}
Exemple #7
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
                                        , timer_(new QTimer(this))
{
    setDockNestingEnabled( true );
    setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
    setCorner( Qt::BottomRightCorner, Qt::BottomDockWidgetArea );

    statusBar()->setProperty( "p_styled", true );
    statusBar()->addWidget( new QLabel );
    
    if ( auto p = statusBar()->findChild<QLabel *>() ) {
        p->setText( "STATUS:" );
    }

    setupFileActions();
    setupEditActions();
    {
        QMenu *helpMenu = new QMenu(tr("Help"), this);
        menuBar()->addMenu(helpMenu);
        helpMenu->addAction(tr("About"), this, SLOT(about()));
        helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
    }
#if defined USING_CHARTS
    auto widget = new ChartView( this );
#else
    auto widget = new WaveformView( this );
#endif
    setCentralWidget( widget );    

    grabGesture( Qt::PanGesture );
    grabGesture( Qt::PinchGesture );

    connect( document::instance(), &document::updateData, this, &MainWindow::handleUpdateData );

    createDockWidgets();
}
Exemple #8
0
TextEdit::TextEdit(QWidget *parent)
    : QMainWindow(parent)
{
    setToolButtonStyle(Qt::ToolButtonFollowStyle);
    setupFileActions();
    setupEditActions();
    setupTextActions();

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

    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();
}
/** Constructor */
CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags)
: mBlogId(cId), QMainWindow (parent, flags)
{
	/* Invoke the Qt Designer generated object setup routine */
	ui.setupUi(this);

	setAttribute ( Qt::WA_DeleteOnClose, true );

	setupFileActions();
  setupEditActions();
  setupViewActions();
  setupInsertActions();
  setupParagraphActions();
  
  setAcceptDrops(true);
	setStartupText();
	
	newBlogMsg();
		
	ui.toolBar_2->addAction(ui.actionIncreasefontsize);
  ui.toolBar_2->addAction(ui.actionDecreasefontsize);
  ui.toolBar_2->addAction(ui.actionBlockquoute);
  ui.toolBar_2->addAction(ui.actionOrderedlist);
  ui.toolBar_2->addAction(ui.actionUnorderedlist);
  ui.toolBar_2->addAction(ui.actionBlockquoute);
  ui.toolBar_2->addAction(ui.actionCode);
  ui.toolBar_2->addAction(ui.actionsplitPost);
  
  setupTextActions();

	connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg()));
	connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew()));
	
	connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease()));
  connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease()));
  connect(ui.actionBlockquoute, SIGNAL (triggered()), this, SLOT (blockQuote()));
  connect(ui.actionCode, SIGNAL (triggered()), this, SLOT (toggleCode()));
  connect(ui.actionsplitPost, SIGNAL (triggered()), this, SLOT (addPostSplitter()));  
  connect(ui.actionOrderedlist, SIGNAL (triggered()), this, SLOT (addOrderedList()));
  connect(ui.actionUnorderedlist, SIGNAL (triggered()), this, SLOT (addUnorderedList()));

  //connect(webView, SIGNAL(loadFinished(bool)),this, SLOT(updateTextEdit()));
  connect( ui.msgEdit, SIGNAL( textChanged(const QString &)), this, SLOT(updateTextEdit()));
  
  connect( ui.msgEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this, SLOT(currentCharFormatChanged(QTextCharFormat)));
  connect( ui.msgEdit, SIGNAL(cursorPositionChanged()),
            this, SLOT(cursorPositionChanged()));
	
	QPalette palette = QApplication::palette();
  codeBackground = palette.color( QPalette::Active, QPalette::Midlight );
  
  fontChanged(ui.msgEdit->font());
  colorChanged(ui.msgEdit->textColor());
  alignmentChanged(ui.msgEdit->alignment());
  
    connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)),
            actionSave, SLOT(setEnabled(bool)));
    connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)),
            this, SLOT(setWindowModified(bool)));
    connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)),
            actionUndo, SLOT(setEnabled(bool)));
    connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)),
            ui.actionUndo, SLOT(setEnabled(bool)));        
    connect( ui.msgEdit->document(), SIGNAL(redoAvailable(bool)),
            actionRedo, SLOT(setEnabled(bool)));

    setWindowModified( ui.msgEdit->document()->isModified());
    actionSave->setEnabled( ui.msgEdit->document()->isModified());
    actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable());
    ui.actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable());
    actionRedo->setEnabled( ui.msgEdit->document()->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo()));
    connect(ui.actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), ui.msgEdit, SLOT(redo()));
    
    actionCut->setEnabled(false);
    actionCopy->setEnabled(false);

    connect(actionCut, SIGNAL(triggered()), ui.msgEdit, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), ui.msgEdit, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), ui.msgEdit, SLOT(paste()));
    
    connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
    
#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif
  
  //defaultCharFormat
  defaultCharFormat = ui.msgEdit->currentCharFormat();

  const QFont defaultFont = ui.msgEdit->document()->defaultFont();
  defaultCharFormat.setFont( defaultFont );
  defaultCharFormat.setForeground( ui.msgEdit->currentCharFormat().foreground() );
  defaultCharFormat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) );
  defaultCharFormat.setBackground( palette.color( QPalette::Active,
                                                    QPalette::Base ) );
  defaultCharFormat.setProperty( TextFormat::HasCodeStyle, QVariant( false ) );

  //defaultBlockFormat
  defaultBlockFormat = ui.msgEdit->textCursor().blockFormat();
  
}
Exemple #10
0
// ---------------------------------------------------------------------------
TextEdit::TextEdit(QWidget * parent)
    : QMainWindow(parent, Qt::Dialog)
{
	setWindowModality (Qt::ApplicationModal);
	
    setupFileActions();
    setupEditActions();


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

    textEdit = new QPlainTextEdit(this);
//	textEdit->setLineWrapMode(QTextEdit::NoWrap);

    connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
            this, SLOT(currentCharFormatChanged(const QTextCharFormat &)));

    connect(textEdit, SIGNAL(cursorPositionChanged()),
            this, SLOT(cursorPositionChanged()));

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


    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)));

    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));

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

    if (!load(initialFile))
        fileNew();
}
Exemple #11
0
void TupMainWindow::setupMenu()
{
    // Setting up the file menu
    setupFileActions();

    // Menu File	
    m_fileMenu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(m_fileMenu);

    // Adding Option New	
    /*
    QMenu *newMenu = new QMenu(tr("&New"), this);
    newMenu->setIcon(QPixmap(THEME_DIR + "icons/file_new.png"));
    m_fileMenu->addMenu(newMenu);
    newMenu->addAction(m_actionManager->find("newproject"));
    newMenu->addSeparator();
    */

    m_fileMenu->addAction(m_actionManager->find("newproject"));
    m_fileMenu->addAction(m_actionManager->find("openproject"));
    m_fileMenu->addAction(m_actionManager->find("opennetproject"));
    m_fileMenu->addAction(m_actionManager->find("exportprojectserver"));

    // Adding Option Open Recent	
    m_recentProjectsMenu = new QMenu(tr("Recents"), this);
    // m_recentProjectsMenu->setIcon(QPixmap(THEME_DIR + "icons/recent_files.png"));

    TCONFIG->beginGroup("General");
    QStringList recents = TCONFIG->value("Recents").toString().split(';');
    updateOpenRecentMenu(m_recentProjectsMenu, recents);	
    m_fileMenu->addMenu(m_recentProjectsMenu);

    // Adding Options save, save as, close, export, import palettes and exit	
    m_fileMenu->addAction(m_actionManager->find("saveproject"));

    m_fileMenu->addAction(m_actionManager->find("saveprojectas"));
    m_fileMenu->addAction(m_actionManager->find("closeproject"));

    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_actionManager->find("export"));
    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_actionManager->find("ImportPalettes"));
    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_actionManager->find("Exit"));
    m_fileMenu->addSeparator();

    // Setting up the Settings menu
    setupSettingsActions();
    m_settingsMenu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(m_settingsMenu);

    // Adding Options wizard and preferences
    //m_settingsMenu->addAction(m_actionManager->find("wizard"));
    m_settingsMenu->addAction(m_actionManager->find("preferences"));
    // Temporary out while SQA is done
    m_actionManager->enable("preferences", false);

// Temporary out while SQA is done
    // Setting up the insert menu
    // setupInsertActions();
    // Menu Insert
    m_insertMenu = new QMenu(tr("&Import"), this);
    menuBar()->addMenu(m_insertMenu);

    // Adding Options insert scene, insert layer and insert frame
    /*
    m_insertMenu->addAction(m_actionManager->find("InsertScene"));
    m_insertMenu->addAction(m_actionManager->find("InsertLayer"));
    m_insertMenu->addAction(m_actionManager->find("InsertFrame"));
    m_insertMenu->addSeparator();
    */

    // Adding Options import bitmap and import audio file
    m_insertMenu->addAction(m_actionManager->find("importbitmap"));
    m_insertMenu->addAction(m_actionManager->find("importbitmaparray"));
    m_insertMenu->addAction(m_actionManager->find("importsvg"));
    m_insertMenu->addAction(m_actionManager->find("importsvgarray"));

    //m_insertMenu->addAction(m_actionManager->find("importaudiofile"));

    // Setting up the window menu
    // setupWindowActions();
    m_windowMenu = new QMenu(tr("&Window"),this);
    menuBar()->addMenu(m_windowMenu);

    // Adding Options show debug, palette, pen, library, timeline, scenes, exposure, help
    m_windowMenu->addAction(m_actionManager->find("show palette"));
    m_windowMenu->addAction(m_actionManager->find("show pen"));
    m_windowMenu->addAction(m_actionManager->find("show library"));
    m_windowMenu->addAction(m_actionManager->find("show timeline"));
    m_actionManager->enable("show timeline", false);
    m_windowMenu->addAction(m_actionManager->find("show scenes"));
    m_windowMenu->addAction(m_actionManager->find("show exposure"));
    m_windowMenu->addAction(m_actionManager->find("show help"));

#if defined(QT_GUI_LIB) && defined(K_DEBUG)
    m_windowMenu->addAction(m_actionManager->find("show debug"));
#endif

    // m_actionManager->enable("show help", false);
    m_windowMenu->addSeparator();

    // Setup perspective menu
    m_viewMenu = new QMenu(tr("Modules"),this);
    QActionGroup *group = new QActionGroup(this);
    group->setExclusive(true);

    // Adding Option Animation
    QAction *drawingPerspective = new QAction(tr("Animation"), this);
    drawingPerspective->setIcon(QPixmap(THEME_DIR + "icons/animation_mode.png")); 
    drawingPerspective->setIconVisibleInMenu(true);
    drawingPerspective->setShortcut(QKeySequence("Ctrl+1"));
    drawingPerspective->setData(Animation);
    group->addAction(drawingPerspective);

    // Adding Option Player 
    QAction *animationPerspective = new QAction(tr("Player"), this);
    animationPerspective->setIcon(QPixmap(THEME_DIR + "icons/play_small.png"));
    animationPerspective->setIconVisibleInMenu(true);
    animationPerspective->setShortcut(QKeySequence("Ctrl+2"));
    animationPerspective->setData(Player);
    group->addAction(animationPerspective);

   // Adding Option Help 
    QAction *helpPerspective = new QAction(tr("Help"), this);
    helpPerspective->setIcon(QPixmap(THEME_DIR + "icons/help_mode.png"));
    helpPerspective->setIconVisibleInMenu(true);
    helpPerspective->setShortcut(QKeySequence("Ctrl+3"));
    helpPerspective->setData(Help);
    group->addAction(helpPerspective);

   // Adding Option News 
    QAction *newsPerspective = new QAction(tr("News"), this);
    newsPerspective->setIcon(QPixmap(THEME_DIR + "icons/news_mode.png"));
    newsPerspective->setIconVisibleInMenu(true);
    newsPerspective->setShortcut(QKeySequence("Ctrl+4"));
    newsPerspective->setData(News);
    group->addAction(newsPerspective);

    m_viewMenu->addActions(group->actions());
    connect(group, SIGNAL(triggered(QAction *)), this, SLOT(changePerspective(QAction *)));
    menuBar()->addMenu(m_viewMenu);
	
    // Setting up the help menu
    setupHelpActions();
    m_helpMenu = new QMenu(tr("&Help"),this);
    menuBar()->addMenu(m_helpMenu);
    m_helpMenu->addAction(m_actionManager->find("tipofday"));
    m_helpMenu->addSeparator();
    m_helpMenu->addAction(m_actionManager->find("about tupi"));

    setMenuItemsContext(false);
}
Exemple #12
0
BrailleMusicEditor::BrailleMusicEditor(QWidget *parent)
: QMainWindow(parent), ok(this), fail(this), lilypond(this) {
#ifdef Q_OS_OSX
  setUnifiedTitleAndToolBarOnMac(true);
#endif

  setToolButtonStyle(Qt::ToolButtonFollowStyle);
  setupFileActions();
  setupEditActions();
  setupOptionsActions();
  setupSoundEffects();

  {
    auto helpMenu = new QMenu(tr("Help"), this);
    menuBar()->addMenu(helpMenu);
    helpMenu->addAction(tr("About"), this, SLOT(about()));
    helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
    helpMenu->addAction(tr("&Report a problem..."), this, SLOT(reportBug()));
  }

  textEdit = new QTextEdit(this);
  textEdit->setWordWrapMode(QTextOption::NoWrap);
  connect(textEdit, &QTextEdit::cursorPositionChanged,
          this, &BrailleMusicEditor::cursorPositionChanged);
  connect(textEdit, &QTextEdit::textChanged,
          this, &BrailleMusicEditor::textChanged);

  svgScrollArea = new QScrollArea(this);
  svgScrollArea->setFocusPolicy(Qt::NoFocus);

  auto splitter = new QSplitter(Qt::Vertical);
  splitter->addWidget(textEdit);
  splitter->addWidget(svgScrollArea);

  QSettings settings;
  if (settings.value("ui/persist_layout",1).toInt() &&
      settings.contains("ui/layout_data")) {
	  splitter->restoreState(settings.value("ui/layout_data").toByteArray());
    } else {
      splitter->setStretchFactor(0, 1);
      splitter->setStretchFactor(1, 1);
    }
  setCentralWidget(splitter);
 
  textEdit->setFocus();
  setCurrentFileName(QString());

  QFont textFont("Helvetica");
  textFont.setStyleHint(QFont::SansSerif);
  textEdit->setFont(textFont);
  fontChanged(textEdit->font());
  colorChanged(textEdit->textColor());

  connect(textEdit->document(), &QTextDocument::modificationChanged,
          actionSave, &QAction::setEnabled);
  connect(textEdit->document(), &QTextDocument::modificationChanged,
          this, &BrailleMusicEditor::setWindowModified);
  connect(textEdit->document(), &QTextDocument::undoAvailable,
          actionUndo, &QAction::setEnabled);
  connect(textEdit->document(), &QTextDocument::redoAvailable,
          actionRedo, &QAction::setEnabled);

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

  connect(actionUndo, &QAction::triggered, textEdit, &QTextEdit::undo);
  connect(actionRedo, &QAction::triggered, textEdit, &QTextEdit::redo);

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

  connect(actionCut, &QAction::triggered, textEdit, &QTextEdit::cut);
  connect(actionCopy, &QAction::triggered, textEdit, &QTextEdit::copy);
  connect(actionPaste, &QAction::triggered, textEdit, &QTextEdit::paste);

  connect(textEdit, &QTextEdit::copyAvailable, actionCut, &QAction::setEnabled);
  connect(textEdit, &QTextEdit::copyAvailable, actionCopy, &QAction::setEnabled);

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

  connect(&lilypond, &QProcess::started,
          this, &BrailleMusicEditor::lilyPondStarted);
  connect(&lilypond, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>
                     (&QProcess::finished),
          this, &BrailleMusicEditor::lilyPondFinished);
  connect(&lilypond, static_cast<void (QProcess::*)(QProcess::ProcessError)>
                     (&QProcess::error),
          this, &BrailleMusicEditor::lilyPondError);

  QString initialFile = ":/examples/bwv988-v01.bmc";
  const QStringList args = QCoreApplication::arguments();
  if (args.count() == 2) initialFile = args.at(1);

  if (!load(initialFile)) fileNew();
}
TextEdit::TextEdit(QWidget *parent)
  : QMainWindow(parent)
{
  setToolButtonStyle(Qt::ToolButtonFollowStyle);
  setupFileActions();
  setupEditActions();
  setupTextActions();

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

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

  ///////////
  //setCentralWidget(textEdit);
  //blank=new Blank(this);
  //setCentralWidget(blank);


  //create a transparent canvas and put it on the top of textEdit
  image =new MyCanvas(900,800,this);
  textEdit->setFixedSize(QSize(800,800));
  textEdit->setBackgroundRole(QPalette::Light);   //scrollArea对象的背景色设为Dark
  image->setFixedSize(QSize(800,800));
  image->setStyleSheet(QString::fromUtf8("border:1px solid #000000;"));

  QScrollArea* scrollArea = new QScrollArea;
  scrollArea->setFixedSize(QSize(1800,900));
  //scrollArea->setWidget(image);     //将画布添加到scrollArea中
  scrollArea->setBackgroundRole(QPalette::Light);   //scrollArea对象的背景色设为Dark
  //scrollArea->setBackgroundColor(QColor::white);

//    QStackedLayout *stackedLayout = new QStackedLayout;
//    stackedLayout->addWidget(image);
//    stackedLayout->addWidget(textEdit);
//    stackedLayout->setStackingMode(QStackedLayout::StackAll);

  QHBoxLayout* hLayout=new QHBoxLayout();
  hLayout->addWidget(textEdit);
  hLayout->addWidget(image);
//  scrollArea->setLayout(stackedLayout);
  scrollArea->setLayout(hLayout);
  //scrollArea->setGeometry(QRect(50,50,800,800));



  setCentralWidget(scrollArea);    //将scrollArea加入到主窗口的中心区new QPainter(this);
  scrollArea->setAlignment(Qt::AlignHCenter);
  //after canvas handle the mouse-drag event, emit it to the edittext for farther handling
  connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),this,SLOT(onMouseMove(QMouseEvent*)));
  //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(mouseMoveEvent(QMouseEvent*)));
  //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(cursorPositionChanged(QMouseEvent*)));
  //connect(this,SIGNAL(mouseMoveSig(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));
  //connect(textEdit,SIGNAL(mouseMoveEvent(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));

  // 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 = ":/data/example.html";
  QString initialFile = ":/data/test.txt";
  const QStringList args = QCoreApplication::arguments();
  if (args.count() == 2)
    initialFile = args.at(1);

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