Esempio n. 1
0
MainWindow::MainWindow(Application *app):
    m_app(app)
{
    setWindowTitle(qApp->applicationName());
    connect(app, &Application::error, this, &MainWindow::onError);

    QSplitter* splitter = new QSplitter(this);

    m_pages = new QTabWidget(splitter);
    m_pages->setDocumentMode(true);
    m_pages->setTabsClosable(true);
    m_pages->setMovable(true);
    m_pages->setTabBarAutoHide(true);
    m_pages->setTabPosition(QTabWidget::South);
    connect(m_pages, &QTabWidget::tabCloseRequested, this, &MainWindow::onCloseRequested);
    connect(m_pages, &QTabWidget::currentChanged, this, &MainWindow::onCurrentChanged);

    m_trees = new QStackedWidget(splitter);

    splitter->addWidget(m_trees);
    splitter->addWidget(m_pages);
    splitter->setStretchFactor(0, 0);
    splitter->setStretchFactor(1, 1);

    setCentralWidget(splitter);

    createActions();
    createMenus();
    createToolBars();
    createStatusBar();
    readSettings();

    newDoc();
}
Esempio n. 2
0
bool MainWindow::openFile (const File& file)
{
    createProjectContentCompIfNeeded();

    if (file.hasFileExtension (Project::projectFileExtension))
    {
        std::unique_ptr<Project> newDoc (new Project (file));

        auto result = newDoc->loadFrom (file, true);

        if (result.wasOk() && closeCurrentProject())
        {
            setProject (newDoc.get());
            newDoc.release()->setChangedFlag (false);

            jassert (getProjectContentComponent() != nullptr);
            getProjectContentComponent()->reloadLastOpenDocuments();

            if (auto* p = getProject())
                p->updateDeprecatedProjectSettingsInteractively();

            return true;
        }
    }
    else if (file.exists())
    {
        return getProjectContentComponent()->showEditorForFile (file, true);
    }

    return false;
}
Esempio n. 3
0
/**
 * Loads the given file into this graphic.
 */
bool RS_Graphic::open(const QString &filename, RS2::FormatType type) {
    RS_DEBUG->print("RS_Graphic::open(%s)", filename.toLatin1().data());

        bool ret = false;

    this->filename = filename;
        QFileInfo finfo(filename);
        // Construct new autosave filename by prepending # to the filename
        // part, using the same directory as the destination file.
        this->autosaveFilename = finfo.path() + "/#" + finfo.fileName();

    // clean all:
    newDoc();

    // import file:
    ret = RS_FileIO::instance()->fileImport(*this, filename, type);

        setModified(false);
        layerList.setModified(false);
        blockList.setModified(false);
    modifiedTime = finfo.lastModified();
    currentFileName=QString(filename);

    //cout << *((RS_Graphic*)graphic);
    //calculateBorders();

    RS_DEBUG->print("RS_Graphic::open(%s): OK", filename.toLatin1().data());

    return ret;
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
void MainWindow::makeMenu()
{
	QAction *a;
	QMenu *o;

	// file menu
	{
	o = menuBar()->addMenu(_("File"));
	a = new QAction(QPixmap(":/png/document-new.png"), _("New script"), this);
	connect(a, SIGNAL(triggered()), this, SLOT(newDoc()));
	a->setToolTip(_("Create new empty script window (Ctrl+N)."));
	a->setShortcut(Qt::CTRL+Qt::Key_N);	o->addAction(a);

	o->addAction(aload);
	o->addAction(asave);

	a = new QAction(_("Save as ..."), this);
	connect(a, SIGNAL(triggered()), this, SLOT(saveAs()));
	o->addAction(a);

	o->addSeparator();
	o->addAction(_("Print script"), edit, SLOT(printText()));
	a = new QAction(QPixmap(":/png/document-print.png"), _("Print graphics"), this);
	connect(a, SIGNAL(triggered()), graph->mgl, SLOT(print()));
	a->setToolTip(_("Open printer dialog and print graphics (Ctrl+P)"));
	a->setShortcut(Qt::CTRL+Qt::Key_P);	o->addAction(a);
	o->addSeparator();
	fileMenu = o->addMenu(_("Recent files"));
	o->addSeparator();
	o->addAction(_("Quit"), qApp, SLOT(closeAllWindows()));
	}

	menuBar()->addMenu(edit->menu);
	menuBar()->addMenu(graph->menu);

	// settings menu
	{
	o = menuBar()->addMenu(_("Settings"));
	a = new QAction(QPixmap(":/png/preferences-system.png"), _("Properties"), this);
	connect(a, SIGNAL(triggered()), this, SLOT(properties()));
	a->setToolTip(_("Show dialog for UDAV properties."));	o->addAction(a);
	o->addAction(_("Set arguments"), createArgsDlg(this), SLOT(exec()));

	o->addAction(acalc);
	o->addAction(ainfo);
	o->addAction(ahide);
	}

	menuBar()->addSeparator();
	o = menuBar()->addMenu(_("Help"));
	a = new QAction(QPixmap(":/png/help-contents.png"), _("MGL help"), this);
	connect(a, SIGNAL(triggered()), this, SLOT(showHelp()));
	a->setToolTip(_("Show help on MGL commands (F1)."));
	a->setShortcut(Qt::Key_F1);	o->addAction(a);
	a = new QAction(QPixmap(":/png/help-faq.png"), _("Hints"), this);
	connect(a, SIGNAL(triggered()), this, SLOT(showHint()));
	a->setToolTip(_("Show hints of MGL usage."));	o->addAction(a);
	o->addAction(_("About"), this, SLOT(about()));
	o->addAction(_("About Qt"), this, SLOT(aboutQt()));
}
Esempio n. 5
0
/**
 * Loads the given file into this graphic.
 */
bool RS_Graphic::loadTemplate(const QString &filename, RS2::FormatType type) {
    RS_DEBUG->print("RS_Graphic::loadTemplate(%s)", filename.toLatin1().data());

    bool ret = false;

    // Construct new autosave filename by prepending # to the filename part,
    // using system temporary dir.
    this->autosaveFilename = QDir::tempPath () + "/#" + "Unnamed.dxf";

    // clean all:
    newDoc();

    // import template file:
    ret = RS_FileIO::instance()->fileImport(*this, filename, type);

    setModified(false);
    layerList.setModified(false);
    blockList.setModified(false);
    QFileInfo finfo;
    modifiedTime = finfo.lastModified();

    RS_DEBUG->print("RS_Graphic::loadTemplate(%s): OK", filename.toLatin1().data());

    return ret;
}
Esempio n. 6
0
//TODO: add support of URL
void Translator::translateHtml(QString filePath, QDir &docDir)
{
    QFileInfo fileInfo(filePath);
    auto cmd = new QProcess(this);

    QTemporaryFile tmpDoc("document.html");
    cmd->setWorkingDirectory(QDir(DATALOCATION).absoluteFilePath("apertium-all-dev/bin"));
    QStringList args;
    qApp->processEvents();
    //deshtml
#ifdef Q_OS_WIN
    //windows bug with backslash
    //use replace to fix windows bug
    args << "/u" << "/c" << "type" << "\"" + filePath.replace('/', QDir::separator()) + "\""
         << "|" << "apertium-deshtml";
    cmd->setNativeArguments(args.join(' '));
    cmd->start("cmd.exe");
#endif
    cmd->waitForFinished();
    cmd->waitForReadyRead();
    if (!tmpDoc.open()) {
        emit fileTranslateRejected();
        cmd->deleteLater();
        return;
    }
    tmpDoc.setTextModeEnabled(true);
    tmpDoc.write(notLinuxTranslate(cmd->readAllStandardOutput()).toUtf8());
    tmpDoc.close();
    //rehtml
    //FIXME: rehtml or rehtml-noent???
    args.clear();
#ifdef Q_OS_WIN
    args << "/u" << "/c" << "type" << "\"" + tmpDoc.fileName().replace('/', QDir::separator()) + "\""
         << "|" << "apertium-rehtml";
    cmd->setNativeArguments(args.join(' '));
    cmd->start("cmd.exe");
#endif
    cmd->waitForFinished();
    cmd->waitForReadyRead();
    QString trFilePath = docDir.absoluteFilePath(fileInfo.baseName() + "_" +
                                                 parent->getCurrentSourceLang()
                                                 + "-" + parent->getCurrentTargetLang() + "." + fileInfo.suffix());
    QFile newDoc(trFilePath);
    if (!newDoc.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
        emit fileTranslateRejected();
        cmd->deleteLater();
        return;
    }
    newDoc.write(cmd->readAllStandardOutput());
    newDoc.close();
    emit fileTranslated(trFilePath);
    cmd->deleteLater();
    //#else
    //    // cmd->start("ar", QStringList() << "x" << "data.tmp");
    //#endif
}
Esempio n. 7
0
void ApplicationWindow::load()
{
    QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
    if ( !fn.isEmpty() ) {
	MDIWindow* w = newDoc();
	w->load( fn );
    }  else {
	statusBar()->message( "Loading aborted", 2000 );
    }
}
Esempio n. 8
0
Editor::Editor( QWidget * parent , const char * name )
    : QWidget( parent, name, WDestructiveClose )
{
    m = new QMenuBar( this, "menu" );

    QPopupMenu * file = new QPopupMenu();
    Q_CHECK_PTR( file );
    m->insertItem( "&File", file );

    file->insertItem( "&New",   this, SLOT(newDoc()),   ALT+Key_N );
    file->insertItem( "&Open...",  this, SLOT(load()),     ALT+Key_O );
    file->insertItem( "&Save...",  this, SLOT(save()),     ALT+Key_S );
    file->insertSeparator();
    open_as = new QPopupMenu();
    file->insertItem( "Open &As",  open_as );
    save_as = new QPopupMenu();
    file->insertItem( "Sa&ve As",  save_as );
    file->insertItem( "Add &Encoding", this, SLOT(addEncoding()) );    
#ifndef QT_NO_PRINTER
    file->insertSeparator();
    file->insertItem( "&Print...", this, SLOT(print()),    ALT+Key_P );
#endif
    file->insertSeparator();
    file->insertItem( "&Close", this, SLOT(close()),ALT+Key_W );
    file->insertItem( "&Quit",  qApp, SLOT(closeAllWindows()),     ALT+Key_Q );

    connect( save_as, SIGNAL(activated(int)), this, SLOT(saveAsEncoding(int)) );
    connect( open_as, SIGNAL(activated(int)), this, SLOT(openAsEncoding(int)) );
    rebuildCodecList();

    QPopupMenu * edit = new QPopupMenu();
    Q_CHECK_PTR( edit );
    m->insertItem( "&Edit", edit );

    edit->insertItem( "To &Uppercase",   this, SLOT(toUpper()),   ALT+Key_U );
    edit->insertItem( "To &Lowercase",   this, SLOT(toLower()),   ALT+Key_L );
#ifndef QT_NO_FONTDIALOG
    edit->insertSeparator();
    edit->insertItem( "&Select Font" ,	 this, SLOT(font()),     ALT+Key_T );
#endif
    changed = FALSE;
    e = new QMultiLineEdit( this, "editor" );
    connect( e, SIGNAL( textChanged() ), this, SLOT( textChanged() ) );

    // We use Unifont - if you have it installed you'll see all
    // Unicode character glyphs.
    //
    // Unifont only comes in one pixel size, so we cannot let
    // it change pixel size as the display DPI changes.
    //
    QFont unifont("unifont",16,50); unifont.setPixelSize(16);
    e->setFont( unifont );

    e->setFocus();
}
Esempio n. 9
0
MainWindow::MainWindow(QWidget* p_parent):
  QMainWindow(p_parent),
  m_lowerRegExp("[a-z]"),
  m_upperRegExp("[A-Z]"),
  m_symbolesCount(0),
  m_fileName("Untitled"),
  m_neverSavedBefore(true),
  m_fileSaved(true) {

  // Create text edit and set central widget
  m_textEdit = new QPlainTextEdit;
  setCentralWidget(m_textEdit);

  // Connections
  connect(m_textEdit, SIGNAL(textChanged(void)), this, SLOT(cryptText(void)));
  connect(m_textEdit, SIGNAL(textChanged(void)), this, SLOT(updateNotSavedState(void)));

  // Crypt/Decrypt action
  m_cryptAction = new QAction(this);
  addAction(m_cryptAction);
  m_cryptAction->setShortcut(QKeySequence("ALT+B"));
  m_cryptAction->setCheckable(true);
  connect(m_cryptAction, SIGNAL(toggled(bool)), this, SLOT(cryptDocument(bool)));

  // Save as action
  m_saveAsAction = new QAction(this);
  addAction(m_saveAsAction);
  m_saveAsAction->setShortcut(QKeySequence(QKeySequence::SaveAs));
  connect(m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));

  // Save action
  m_saveAction = new QAction(this);
  addAction(m_saveAction);
  m_saveAction->setShortcut(QKeySequence(QKeySequence::Save));
  connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save()));

  // Open action
  m_openAction = new QAction(this);
  addAction(m_openAction);
  m_openAction->setShortcut(QKeySequence(QKeySequence::Open));
  connect(m_openAction, SIGNAL(triggered()), this, SLOT(open()));

  // New action
  m_newAction = new QAction(this);
  addAction(m_newAction);
  m_newAction->setShortcut(QKeySequence(QKeySequence::New));
  connect(m_newAction, SIGNAL(triggered()), this, SLOT(newDoc()));

  // Set window title
  m_textEdit->setDocumentTitle(m_fileName);

  // Full screen
  setWindowState(Qt::WindowMaximized);
}
Esempio n. 10
0
void DocumentDatabase::addToDocumentList(int DocumentID, std::string Author, std::string Title, std::string PublishDate, int startSentenceID, int endSentenceID)
{
	// make sure there is enought space in the vector.
	if ((int)documentList.size() <= DocumentID)
	{
		Documents dummy;
		// Create a new item
		while ((int)documentList.size() <= DocumentID)
			documentList.push_back(dummy);
	}
	Documents newDoc(DocumentID,Author, Title, PublishDate, startSentenceID, endSentenceID);
	documentList[DocumentID] = newDoc;
}
Esempio n. 11
0
/*!
 * \brief Translating txt files not on Linux.
 *
 * \warning There are some problems with translating of documents
 * on Windows platform. All document translation functions should be rewrited.
 */
void Translator::translateTxt(QString filePath, QDir &docDir)
{
    QFile f(filePath);
    QFileInfo fileInfo(filePath);
    QTemporaryFile tmpDoc(fileInfo.baseName());
    auto cmd = new QProcess(this);
#ifdef Q_OS_WIN
    cmd->setWorkingDirectory(QDir(DATALOCATION).absoluteFilePath("apertium-all-dev/bin"));
#endif
    qApp->processEvents();
    //destxt
    cmd->start("cmd.exe", QStringList() << "/u" << "/c" << "type" << "\"" + filePath.replace('/',
                                                                                             QDir::separator()) + "\""
               << "|" << "apertium-destxt");
    cmd->waitForFinished();
    cmd->waitForReadyRead();
    if (!tmpDoc.open()) {
        emit fileTranslateRejected();
        cmd->deleteLater();
        return;
    }
    tmpDoc.setTextModeEnabled(true);
    tmpDoc.write(notLinuxTranslate(cmd->readAllStandardOutput()).toUtf8());
    //retxt
    cmd->start("cmd.exe", QStringList() << "/u" << "/c" << "type" << "\"" +
               tmpDoc.fileName().replace('/', QDir::separator())
               + "\"" << "|" << "apertium-retxt");
    cmd->waitForFinished();
    cmd->waitForReadyRead();
    QString trFilePath = docDir.absoluteFilePath(fileInfo.baseName() + "_" +
                                                 parent->getCurrentSourceLang()
                                                 + "-" + parent->getCurrentTargetLang() + "." + fileInfo.suffix());
    QFile newDoc(trFilePath);
    if (!newDoc.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
        emit fileTranslateRejected();
        cmd->deleteLater();
        return;
    }
    newDoc.write(cmd->readAllStandardOutput());
    newDoc.close();
    emit fileTranslated(trFilePath);
    cmd->deleteLater();
}
Esempio n. 12
0
Editor::Editor( QWidget * parent , const char * name )
    : QWidget( parent, name )
{
    m = new QMenuBar( this, "menu" );
    QPopupMenu * file = new QPopupMenu();
    CHECK_PTR( file );
    m->insertItem( "&File", file );

    file->insertItem( "New",   this, SLOT(newDoc()),   ALT+Key_N );
    file->insertItem( "Open",  this, SLOT(load()),     ALT+Key_O );
    file->insertItem( "Save",  this, SLOT(save()),     ALT+Key_S );
    file->insertSeparator();
    file->insertItem( "Print", this, SLOT(print()),    ALT+Key_P );
    file->insertSeparator();
    file->insertItem( "Close", this, SLOT(closeDoc()),ALT+Key_W );
    file->insertItem( "Quit",  qApp, SLOT(quit()),     ALT+Key_Q );

    e = new QMultiLineEdit( this, "editor" );
    e->setFocus();
}
Esempio n. 13
0
QToolBar* CGLWin::_createToolBar(void)
{
    _fileNewAction = new QAction( QPixmap(filenew_xpm), "&Clear Window", CTRL+Key_N, this);
    connect(_fileNewAction, SIGNAL(activated()), this, SLOT(newDoc()));

    _fileOpenAction = new QAction( QPixmap(fileopen), "&Open...", CTRL+Key_O, this);
    connect(_fileOpenAction, SIGNAL(activated()), this, SLOT(openCia3dFile()));

    _fileSaveAction = new QAction( QPixmap(filesave), "&Save snapshot", CTRL+Key_S, this);
    connect(_fileSaveAction, SIGNAL(activated()), this, SLOT(save()));

    _filePrintAction = new QAction( QPixmap(fileprint), "&Print", CTRL+Key_Q, this);
    connect(_filePrintAction, SIGNAL(activated()), this, SLOT(print()));

    // populate a tool bar with some actions
    QToolBar * fileTools = new QToolBar( this, "file operations" );
    fileTools->setLabel( "File Operations" );
    _fileNewAction->addTo( fileTools );
    _fileOpenAction->addTo( fileTools );
    _fileSaveAction->addTo( fileTools );
    _filePrintAction->addTo( fileTools );
	return fileTools;
}
NS_IMETHODIMP
nsXFormsInstanceElement::RestoreOriginalDocument()
{
  // This is called when xforms-reset is received by the model.  We assume
  // that the backup of the instance document has been populated and is
  // loaded into mOriginalDocument.
 
 if (!mOriginalDocument) {
    return NS_ERROR_FAILURE;
  }
  
  nsCOMPtr<nsIDOMNode> newDocNode;
  nsresult rv = mOriginalDocument->CloneNode(PR_TRUE,
                                             getter_AddRefs(newDocNode));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMDocument> newDoc(do_QueryInterface(newDocNode));
  NS_ENSURE_STATE(newDoc);
  
  rv = SetInstanceDocument(newDoc);
  NS_ENSURE_SUCCESS(rv, rv);
  
  return NS_OK;
}
/**
 * Loads the given fils into this graphic.
 */
bool RS_Graphic::open(const RS_String &filename, RS2::FormatType type) {
    RS_DEBUG->print("RS_Graphic::open(%s)", filename.latin1());

	bool ret = false;

    this->filename = filename;

    // clean all:
    newDoc();

    // import file:
    ret = RS_FILEIO->fileImport(*this, filename, type);
		
	setModified(false);
	layerList.setModified(false);
	blockList.setModified(false);

    //cout << *((RS_Graphic*)graphic);
    //calculateBorders();
	
    RS_DEBUG->print("RS_Graphic::open(%s): OK", filename.latin1());

    return ret;
}
billingreports::billingreports()
    : QMainWindow( 0, "billingreports", WDestructiveClose )
{
    printer = new QPrinter;
    QPixmap openIcon, saveIcon, printIcon;

    QToolBar * fileTools = new QToolBar( this, "file operations" );
    fileTools->setLabel( tr("File Operations") );

    openIcon = QPixmap( fileopen );
    QToolButton * fileOpen
	= new QToolButton( openIcon, tr("Open File"), QString::null,
			   this, SLOT(choose()), fileTools, "open file" );

    saveIcon = QPixmap( filesave );
    QToolButton * fileSave
	= new QToolButton( saveIcon, tr("Save File"), QString::null,
			   this, SLOT(save()), fileTools, "save file" );

    printIcon = QPixmap( fileprint );
    QToolButton * filePrint
	= new QToolButton( printIcon, tr("Print File"), QString::null,
			   this, SLOT(print()), fileTools, "print file" );


    (void)QWhatsThis::whatsThisButton( fileTools );

    QString fileOpenText = tr("<p><img source=\"fileopen\"> "
	         "Click this button to open a <em>new file</em>. <br>"
                 "You can also select the <b>Open</b> command "
                 "from the <b>File</b> menu.</p>");

    QWhatsThis::add( fileOpen, fileOpenText );

    QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", openIcon );

    QString fileSaveText = tr("<p>Click this button to save the file you "
                 "are editing. You will be prompted for a file name.\n"
                 "You can also select the <b>Save</b> command "
                 "from the <b>File</b> menu.</p>");

    QWhatsThis::add( fileSave, fileSaveText );

    QString filePrintText = tr("Click this button to print the file you "
                 "are editing.\n You can also select the Print "
                 "command from the File menu.");

    QWhatsThis::add( filePrint, filePrintText );


    QPopupMenu * file = new QPopupMenu( this );
    menuBar()->insertItem( tr("&File"), file );


    file->insertItem( tr("&New"), this, SLOT(newDoc()), CTRL+Key_N );

    int id;
    id = file->insertItem( openIcon, tr("&Open..."),
			   this, SLOT(choose()), CTRL+Key_O );
    file->setWhatsThis( id, fileOpenText );

    id = file->insertItem( saveIcon, tr("&Save"),
			   this, SLOT(save()), CTRL+Key_S );
    file->setWhatsThis( id, fileSaveText );

    id = file->insertItem( tr("Save &As..."), this, SLOT(saveAs()) );
    file->setWhatsThis( id, fileSaveText );

    file->insertSeparator();

    id = file->insertItem( printIcon, tr("&Print..."),
			   this, SLOT(print()), CTRL+Key_P );
    file->setWhatsThis( id, filePrintText );

    file->insertSeparator();

    file->insertItem( tr("&Close"), this, SLOT(close()), CTRL+Key_W );

    file->insertItem( tr("&Quit"), qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );

    menuBar()->insertSeparator();

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertItem( tr("&Help"), help );

    help->insertItem( tr("&About"), this, SLOT(about()), Key_F1 );
    help->insertItem( tr("About &Qt"), this, SLOT(aboutQt()) );
    help->insertSeparator();
    help->insertItem( tr("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1 );

    e = new QTextEdit( this, "editor" );
    e->setFocus();
    setCentralWidget( e );
    statusBar()->message( tr("Ready"), 2000 );

    resize( 450, 600 );
}
Esempio n. 17
0
	MainWindow::MainWindow(App *a)
		: m_close_shutdown(false), m_app(a)
	{
		setupUi(this);
		setDocumentName("");
		instruments->setIconSize(QSize(16,16));

		speed->setRange(MIN_SPEED, MAX_SPEED);
		tempo->setRange(MIN_TEMPO, MAX_TEMPO);
		rows->setRange(1, MAX_PATTERN_LENGTH);
		frames->setRange(1, MAX_FRAMES);

		title->setMaxLength(MAX_SONGINFO_LENGTH);
		author->setMaxLength(MAX_SONGINFO_LENGTH);
		copyright->setMaxLength(MAX_SONGINFO_LENGTH);
		instrumentName->setMaxLength(MAX_INSTRUMENT_NAME_LENGTH);

		QObject::connect(actionNew, SIGNAL(triggered()), this, SLOT(newDoc()));
		actionNew->setIcon(QIcon::fromTheme("document-new"));
		QObject::connect(action_Open, SIGNAL(triggered()), this, SLOT(open()));
		action_Open->setIcon(QIcon::fromTheme("document-open"));
		QObject::connect(action_Save, SIGNAL(triggered()), this, SLOT(save()));
		action_Save->setIcon(QIcon::fromTheme("document-save"));
		QObject::connect(actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs()));
		QObject::connect(action_Create_NSF, SIGNAL(triggered()), this, SLOT(unimplemented()));
		QObject::connect(actionCreate_WAV, SIGNAL(triggered()), this, SLOT(createWAV()));
		QObject::connect(actionImport_MIDI, SIGNAL(triggered()), this, SLOT(unimplemented()));
		QObject::connect(action_Configuration, SIGNAL(triggered()), this, SLOT(unimplemented()));
		QObject::connect(actionE_xit, SIGNAL(triggered()), this, SLOT(quit()));

		QObject::connect(actionModule_Properties, SIGNAL(triggered()), this, SLOT(moduleProperties()));

		QObject::connect(action_ViewToolbar, SIGNAL(toggled(bool)), this, SLOT(viewToolbar(bool)));
		QObject::connect(action_ViewStatusBar, SIGNAL(toggled(bool)), this, SLOT(viewStatusBar(bool)));
		QObject::connect(action_ViewControlpanel, SIGNAL(toggled(bool)), this, SLOT(viewControlpanel(bool)));
		QObject::connect(toolBar, SIGNAL(visibilityChanged(bool)), action_ViewToolbar, SLOT(setChecked(bool)));
		QObject::connect(controlPanel, SIGNAL(visibilityChanged(bool)), this, SLOT(controlPanelVisibilityChanged()));

		QObject::connect(action_About, SIGNAL(triggered()), this, SLOT(about()));
		QObject::connect(actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

		QObject::connect(songs, SIGNAL(activated(int)), this, SLOT(setSong(int)));

		QObject::connect(incPattern, SIGNAL(clicked()), this, SLOT(incrementPattern()));
		QObject::connect(decPattern, SIGNAL(clicked()), this, SLOT(decrementPattern()));
		QObject::connect(instruments, SIGNAL(itemSelectionChanged()), this, SLOT(instrumentSelect()));
		QObject::connect(instrumentName, SIGNAL(textEdited(QString)), this, SLOT(instrumentNameChange(QString)));
		QObject::connect(instruments, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(instrumentDoubleClicked(QModelIndex)));

		QObject::connect(speed, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int)));
		QObject::connect(tempo, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int)));
		QObject::connect(rows, SIGNAL(valueChanged(int)), this, SLOT(rowsChange(int)));
		QObject::connect(frames, SIGNAL(valueChanged(int)), this, SLOT(framesChange(int)));

		QObject::connect(title, SIGNAL(editingFinished()), this, SLOT(changeSongTitle()));
		QObject::connect(author, SIGNAL(editingFinished()), this, SLOT(changeSongAuthor()));
		QObject::connect(copyright, SIGNAL(editingFinished()), this, SLOT(changeSongCopyright()));

		QObject::connect(action_Play, SIGNAL(triggered()), this, SLOT(play()));
		action_Play->setIcon(QIcon::fromTheme("media-playback-start"));
		QObject::connect(action_Stop, SIGNAL(triggered()), this, SLOT(stop()));
		action_Stop->setIcon(QIcon::fromTheme("media-playback-stop"));
		QObject::connect(actionToggle_edit_mode, SIGNAL(triggered()), this, SLOT(toggleEditMode()));
		actionToggle_edit_mode->setIcon(QIcon::fromTheme("media-record"));

		QObject::connect(addInstrument_button, SIGNAL(clicked()), this, SLOT(addInstrument_2A03()));
		addInstrument_button->setIcon(QIcon::fromTheme("list-add"));
		addInstrument_button->setText(tr("Add Instrument"));
		QObject::connect(removeInstrument_button, SIGNAL(clicked()), this, SLOT(removeInstrument()));
		removeInstrument_button->setIcon(QIcon::fromTheme("list-remove"));
		removeInstrument_button->setText(tr("Remove Instrument"));
		QObject::connect(editInstrument_button, SIGNAL(clicked()), this, SLOT(editInstrument()));
		editInstrument_button->setText(tr("Edit Instrument"));

		{
			QMenu *m = new QMenu(this);
			QAction *add2a03 = m->addAction(tr("New 2A03 Instrument"));
			QAction *addmmc5 = m->addAction(tr("New MMC5 Instrument"));
			QAction *addvrc6 = m->addAction(tr("New VRC6 Instrument"));
			QAction *addvrc7 = m->addAction(tr("New VRC7 Instrument"));
			QAction *addfds  = m->addAction(tr("New FDS Instrument"));

			QObject::connect(add2a03, SIGNAL(triggered()), this, SLOT(addInstrument_2A03()));
			QObject::connect(addvrc6, SIGNAL(triggered()), this, SLOT(addInstrument_VRC6()));
			QObject::connect(addvrc7, SIGNAL(triggered()), this, SLOT(addInstrument_VRC7()));
			QObject::connect(addmmc5, SIGNAL(triggered()), this, SLOT(addInstrument_MMC5()));
			QObject::connect(addfds , SIGNAL(triggered()), this, SLOT(addInstrument_FDS()));

			m->setDefaultAction(add2a03);
			addInstrument_button->setMenu(m);
		}

		QObject::connect(step, SIGNAL(valueChanged(int)), this, SLOT(changeEditSettings()));
		QObject::connect(keyRepetition, SIGNAL(stateChanged(int)), this, SLOT(changeEditSettings()));

		{
			// recent files
			int capacity = gui::recentFileCapacity();
			m_recentFiles = new QAction*[capacity];
			for (int i = 0; i < capacity; i++)
			{
				QAction *a = new QAction(this);
				a->setVisible(false);
				connect(a, SIGNAL(triggered()),
						this, SLOT(openRecentFile()));
				m_recentFiles[i] = a;
				menuRecent->addAction(a);
			}

			// end recent files
		}

		reloadRecentFiles();

		// the designer doesn't allow adding widgets

		{
			octave = new QComboBox;
			for (int i = 0; i < 8; i++)
			{
				octave->addItem(QString("%1").arg(i));
			}
			connect(octave, SIGNAL(currentIndexChanged(int)), this, SLOT(octaveChange()));
			toolBar->addWidget(new QLabel(tr("Octave")));
			toolBar->addWidget(octave);
		}

		// temporary style changing (for demonstration)
		{
			menu_View->addSeparator();
			QMenu *styles = new QMenu(tr("Styles"));
			QAction *style_default = styles->addAction(tr("Default"));
			QAction *style_monochrome = styles->addAction(tr("Monochrome"));
			menu_View->addMenu(styles);

			connect(style_default, SIGNAL(triggered()), this, SLOT(selectDefaultStyle()));
			connect(style_monochrome, SIGNAL(triggered()), this, SLOT(selectMonochromeStyle()));
		}

		QMenu *m = new QMenu;
		m->addAction(tr("New 2A03 instrument"));

		actionAdd_instrument->setMenu(m);

		setDocInfo(m_app->activeDocInfo());

		m_instrumenteditor = new InstrumentEditor(this);

		blockSignals(true);
		blockSignals(false);
	}
ApplicationWindow::ApplicationWindow()
    : QMainWindow( 0, "example application main window", WDestructiveClose )
{
#ifndef QT_NO_PRINTER
    printer = new QPrinter( QPrinter::HighResolution );
#endif

    QAction * fileNewAction;
    QAction * fileOpenAction;
    QAction * fileSaveAction, * fileSaveAsAction, * filePrintAction;
    QAction * fileCloseAction, * fileQuitAction;

    fileNewAction = new QAction( "&New", CTRL+Key_N, this, "new" );
    connect( fileNewAction, SIGNAL( activated() ) , this,
             SLOT( newDoc() ) );

    fileOpenAction = new QAction( QPixmap( fileopen ), "&Open...",
                                  CTRL+Key_O, this, "open" );
    connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( choose() ) );

    const char * fileOpenText = "<p><img source=\"fileopen\"> "
                     "Click this button to open a <em>new file</em>. <br>"
                     "You can also select the <b>Open</b> command "
                     "from the <b>File</b> menu.</p>";
    QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
                          fileOpenAction->iconSet().pixmap() );
    fileOpenAction->setWhatsThis( fileOpenText );

    fileSaveAction = new QAction( QPixmap( filesave ),
                                  "&Save", CTRL+Key_S, this, "save" );
    connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );

    const char * fileSaveText = "<p>Click this button to save the file you "
                     "are editing. You will be prompted for a file name.\n"
                     "You can also select the <b>Save</b> command "
                     "from the <b>File</b> menu.</p>";
    fileSaveAction->setWhatsThis( fileSaveText );

    fileSaveAsAction = new QAction( "Save File As", "Save &As...", 0,  this,
                                    "save as" );
    connect( fileSaveAsAction, SIGNAL( activated() ) , this,
             SLOT( saveAs() ) );
    fileSaveAsAction->setWhatsThis( fileSaveText );

#ifndef QT_NO_PRINTER
    filePrintAction = new QAction( "Print File", QPixmap( fileprint ),
                                   "&Print...", CTRL+Key_P, this, "print" );
    connect( filePrintAction, SIGNAL( activated() ) , this,
             SLOT( print() ) );

    const char * filePrintText = "Click this button to print the file you "
                     "are editing.\n You can also select the Print "
                     "command from the File menu.";
    filePrintAction->setWhatsThis( filePrintText );
#else
    Q_UNUSED( filePrintAction )
#endif

    fileCloseAction = new QAction( "Close", "&Close", CTRL+Key_W, this,
                                   "close" );
    connect( fileCloseAction, SIGNAL( activated() ) , this,
             SLOT( close() ) );

    fileQuitAction = new QAction( "Quit", "&Quit", CTRL+Key_Q, this,
                                  "quit" );
    connect( fileQuitAction, SIGNAL( activated() ) , qApp,
             SLOT( closeAllWindows() ) );

    // populate a tool bar with some actions

    QToolBar * fileTools = new QToolBar( this, "file operations" );
    fileTools->setLabel( "File Operations" );
    fileOpenAction->addTo( fileTools );
    fileSaveAction->addTo( fileTools );
#ifndef QT_NO_PRINTER
    filePrintAction->addTo( fileTools );
#endif
    (void)QWhatsThis::whatsThisButton( fileTools );


    // populate a menu with all actions

    QPopupMenu * file = new QPopupMenu( this );
    menuBar()->insertItem( "&File", file );
    fileNewAction->addTo( file );
    fileOpenAction->addTo( file );
    fileSaveAction->addTo( file );
    fileSaveAsAction->addTo( file );
#ifndef QT_NO_PRINTER
    file->insertSeparator();
    filePrintAction->addTo( file );
#endif
    file->insertSeparator();
    fileCloseAction->addTo( file );
    fileQuitAction->addTo( file );


    menuBar()->insertSeparator();

    // add a help menu

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About", this, SLOT(about()), Key_F1 );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );
    help->insertSeparator();
    help->insertItem( "What's &This", this, SLOT(whatsThis()),
                      SHIFT+Key_F1 );


    // create and define the central widget

    e = new QTextEdit( this, "editor" );
    e->setFocus();
    setCentralWidget( e );
    statusBar()->message( "Ready", 2000 );

    resize( 450, 600 );
}
Esempio n. 19
0
ApplicationWindow::ApplicationWindow()
    : QMainWindow( 0, "example application main window", WDestructiveClose )
{
    int id;

    QPixmap openIcon, saveIcon;

    fileTools = new QToolBar( this, "file operations" );
    addToolBar( fileTools, tr( "File Operations" ), Top, TRUE );

    openIcon = QPixmap( fileopen );
    QToolButton * fileOpen
	= new QToolButton( openIcon, "Open File", QString::null,
			   this, SLOT(load()), fileTools, "open file" );

    saveIcon = QPixmap( filesave );
    QToolButton * fileSave
	= new QToolButton( saveIcon, "Save File", QString::null,
			   this, SLOT(save()), fileTools, "save file" );

#ifndef QT_NO_PRINTER
    printer = new QPrinter;
    QPixmap printIcon;

    printIcon = QPixmap( fileprint );
    QToolButton * filePrint
	= new QToolButton( printIcon, "Print File", QString::null,
			   this, SLOT(print()), fileTools, "print file" );
    QWhatsThis::add( filePrint, filePrintText );
#endif

    (void)QWhatsThis::whatsThisButton( fileTools );

    QWhatsThis::add( fileOpen, fileOpenText );
    QWhatsThis::add( fileSave, fileSaveText );

    QPopupMenu * file = new QPopupMenu( this );
    menuBar()->insertItem( "&File", file );

    file->insertItem( "&New", this, SLOT(newDoc()), CTRL+Key_N );

    id = file->insertItem( openIcon, "&Open",
			   this, SLOT(load()), CTRL+Key_O );
    file->setWhatsThis( id, fileOpenText );

    id = file->insertItem( saveIcon, "&Save",
			   this, SLOT(save()), CTRL+Key_S );
    file->setWhatsThis( id, fileSaveText );
    id = file->insertItem( "Save &as...", this, SLOT(saveAs()) );
    file->setWhatsThis( id, fileSaveText );
#ifndef QT_NO_PRINTER
    file->insertSeparator();
    id = file->insertItem( printIcon, "&Print",
			   this, SLOT(print()), CTRL+Key_P );
    file->setWhatsThis( id, filePrintText );
#endif
    file->insertSeparator();
    file->insertItem( "&Close", this, SLOT(closeWindow()), CTRL+Key_W );
    file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );

    windowsMenu = new QPopupMenu( this );
    windowsMenu->setCheckable( TRUE );
    connect( windowsMenu, SIGNAL( aboutToShow() ),
	     this, SLOT( windowsMenuAboutToShow() ) );
    menuBar()->insertItem( "&Windows", windowsMenu );

    menuBar()->insertSeparator();
    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertItem( "&Help", help );

    help->insertItem( "&About", this, SLOT(about()), Key_F1);
    help->insertItem( "About &Qt", this, SLOT(aboutQt()));
    help->insertSeparator();
    help->insertItem( "What's &This", this, SLOT(whatsThis()), SHIFT+Key_F1);

    QVBox* vb = new QVBox( this );
    vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
    ws = new QWorkspace( vb );
    setCentralWidget( vb );
    statusBar()->message( "Ready", 2000 );
}
Esempio n. 20
0
static void setPass1JambifiedDoc(Node *javaNode, const Node *cppNode, const QString &qName = "")
{
    Doc newDoc(cppNode->doc());

    if (javaNode->type() == Node::Function) {
        const FunctionNode *javaFunc = static_cast<const FunctionNode *>(javaNode);
        if (cppNode->type() == Node::Function) {
            const FunctionNode *cppFunc = static_cast<const FunctionNode *>(cppNode);
            if (const PropertyNode *property = cppFunc->associatedProperty()) {
                newDoc = property->doc();
                Text text(newDoc.body());

                Node *mutableCppNode = const_cast<Node *>(cppNode);
                if (property->getters().contains(mutableCppNode)) {
                    text = textWithFixedBrief(text, Text("Returns "), Text("."));
                } else if (property->setters().contains(mutableCppNode)) {
                    Text afterBrief;
                    if (javaFunc->parameterNames().count() == 1
                            && !javaFunc->parameterNames().first().isEmpty()) {
                        afterBrief << " to "
                                   << Atom(Atom::FormattingLeft, ATOM_FORMATTING_PARAMETER)
                                   << javaFunc->parameterNames().first()
                                   << Atom(Atom::FormattingRight, ATOM_FORMATTING_PARAMETER);
                    }
                    afterBrief << ".";
                    text = textWithFixedBrief(text, Text("Sets "), afterBrief);
                } else if (property->resetters().contains(mutableCppNode)) {
                    text = textWithFixedBrief(text, Text("Resets "), Text("."));
                }

                newDoc.setBody(text);
            } else {
                QStringList javaParams = javaFunc->parameterNames();
                QStringList cppParams = cppFunc->parameterNames();
                newDoc.renameParameters(cppParams, javaParams);

                if (cppNode->access() == Node::Private) {
                    Text text;
                    text << Atom::ParaLeft;
                    if (cppFunc->reimplementedFrom()) {
                        text << "This function is reimplemented for internal reasons.";
                    } else {
                        text << USED_INTERNALLY;
                    }
                    text << Atom::ParaRight;
                    newDoc.setBody(text);
                }
            }
        } else if (cppNode->type() == Node::Variable) {
            Text text(newDoc.body());

            if (qName == "variablegetter") {
                text = textWithFixedBrief(text, Text("Returns "), Text("."));
            } else if (qName == "variablesetter") {
                Text afterBrief;
                if (javaFunc->parameterNames().count() == 1
                        && !javaFunc->parameterNames().first().isEmpty()) {
                    afterBrief << " to "
                               << Atom(Atom::FormattingLeft, ATOM_FORMATTING_PARAMETER)
                               << javaFunc->parameterNames().first()
                               << Atom(Atom::FormattingRight, ATOM_FORMATTING_PARAMETER);
                }
                afterBrief << ".";
                text = textWithFixedBrief(text, Text("Sets "), afterBrief);
            }

            newDoc.setBody(text);
        }
    } else {    // ### enum value names?

    }

    javaNode->setDoc(newDoc, true);
}
Esempio n. 21
0
ToolbarDemo::ToolbarDemo()
    : QMainWindow(0, "Toolbar Demo")
{

	//主窗口本身是一个高级容器

	//建立动作
	QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
		*fileSaveAsAction, *filePrintAction, *fileCloseAction,
		*fileQuitAction;
	fileNewAction = new QAction( "New", tr("新建(&N)"), 
		CTRL+Key_N, this, "new" );
	connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
	fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), 
		tr("打开(&O)"), CTRL+Key_O, this, "open" );
	connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
	QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
		QPixmap( fileopen ) );
	fileOpenAction->setWhatsThis( tr(fileOpenText) );

	fileSaveAction = new QAction( "Save File", QPixmap( filesave ), 
		tr("保存(&S)"), CTRL+Key_S, this, "save" );
	connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
	fileSaveAction->setWhatsThis( tr(fileSaveText) );

	fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 
		0,  this, "save as" );
	connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
	fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
	filePrintAction = new QAction( "Print File", QPixmap( fileprint ), 
		tr("打印(&P)"), CTRL+Key_P, this, "print" );
	connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
	filePrintAction->setWhatsThis( tr(filePrintText) );

	fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, 
		this, "close" );
	connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );

	fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, 
		this, "quit" );
	connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));


	//建立按钮条
	QToolBar* fileTools = new QToolBar( this, "file operations" );
	fileTools->setLabel( "File Operations" );
	fileOpenAction->addTo( fileTools );
	fileSaveAction->addTo( fileTools );
	filePrintAction->addTo( fileTools );
	(void)QWhatsThis::whatsThisButton( fileTools );


	//建立文件菜单
	QPopupMenu * file = new QPopupMenu( this );
	menuBar()->insertItem( tr("文件(&F)"), file );
	fileNewAction->addTo( file );
	fileOpenAction->addTo( file );
	fileSaveAction->addTo( file );
	fileSaveAsAction->addTo( file );
	file->insertSeparator();
	filePrintAction->addTo( file );
	file->insertSeparator();
	fileCloseAction->addTo( file );
	fileQuitAction->addTo( file );

	//建立帮助菜单
	QPopupMenu * help = new QPopupMenu( this );
	menuBar()->insertSeparator();
	menuBar()->insertItem( tr("帮助(&H)"), help );
	help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
	help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
	help->insertSeparator();
	help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);


	QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
	e->setFocus();
	setCentralWidget( e );
	statusBar()->message( tr("准备就绪"), 2000 );
	resize( 400, 400 );

}
Esempio n. 22
0
ThemeDemo::ThemeDemo()
    : QMainWindow(0, "Toolbar Demo")
{

	appFont = QApplication::font();

	//建立动作
	QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
		*fileSaveAsAction, *filePrintAction, *fileCloseAction,
		*fileQuitAction;
	fileNewAction = new QAction( "New", tr("新建(&N)"), 
		CTRL+Key_N, this, "new" );
	connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
	fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), 
		tr("打开(&O)"), CTRL+Key_O, this, "open" );
	connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
	QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
		QPixmap( fileopen ) );
	fileOpenAction->setWhatsThis( tr(fileOpenText) );

	fileSaveAction = new QAction( "Save File", QPixmap( filesave ), 
		tr("保存(&S)"), CTRL+Key_S, this, "save" );
	connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
	fileSaveAction->setWhatsThis( tr(fileSaveText) );

	fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 
		0,  this, "save as" );
	connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
	fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
	filePrintAction = new QAction( "Print File", QPixmap( fileprint ), 
		tr("打印(&P)"), CTRL+Key_P, this, "print" );
	connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
	filePrintAction->setWhatsThis( tr(filePrintText) );

	fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, 
		this, "close" );
	connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );

	fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, 
		this, "quit" );
	connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));


	//建立按钮条
	QToolBar* fileTools = new QToolBar( this, "file operations" );
	fileTools->setLabel( "File Operations" );
	fileOpenAction->addTo( fileTools );
	fileSaveAction->addTo( fileTools );
	filePrintAction->addTo( fileTools );
	(void)QWhatsThis::whatsThisButton( fileTools );


	//建立文件菜单
	QPopupMenu * file = new QPopupMenu( this );
	menuBar()->insertItem( tr("文件(&F)"), file );
	fileNewAction->addTo( file );
	fileOpenAction->addTo( file );
	fileSaveAction->addTo( file );
	fileSaveAsAction->addTo( file );
	file->insertSeparator();
	filePrintAction->addTo( file );
	file->insertSeparator();
	fileCloseAction->addTo( file );
	fileQuitAction->addTo( file );

	//建立Style菜单
	QPopupMenu *style = new QPopupMenu( this );
	style->setCheckable( TRUE );
	menuBar()->insertItem( tr("风格(&S)") , style );
	sMetal = style->insertItem( "&Metal", this, SLOT( styleMetal() ) );
	sWood = style->insertItem( "&Norwegian Wood", this, SLOT( styleWood() ) );
	sPlatinum = style->insertItem( "&Platinum" , this ,SLOT( stylePlatinum() ) );
	sWindows = style->insertItem( "&Windows", this, SLOT( styleWindows() ) );
	sCDE = style->insertItem( "&CDE", this, SLOT( styleCDE() ) );
	sMotif = style->insertItem( "M&otif", this, SLOT( styleMotif() ) );
	sMotifPlus = style->insertItem( "Motif P&lus", this, SLOT( styleMotifPlus() ) );

	//建立帮助菜单
	QPopupMenu * help = new QPopupMenu( this );
	menuBar()->insertSeparator();
	menuBar()->insertItem( tr("帮助(&H)"), help );
	help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
	help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
	help->insertSeparator();
	help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);


	QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
	e->setFocus();
	setCentralWidget( e );
	statusBar()->message( tr("准备就绪"), 2000 );
	resize( 400, 400 );

}
Esempio n. 23
0
ApplicationWindow::ApplicationWindow()
    : QMainWindow( 0, "example application main window", WDestructiveClose )
{
    int id;

    printer = new QPrinter;
    QPixmap openIcon, saveIcon, printIcon;

    fileTools = new QToolBar( this, "file operations" );
    fileTools->setLabel( tr( "File Operations" ) );

    openIcon = QPixmap( fileopen );
    QToolButton * fileOpen
	= new QToolButton( openIcon, "Open File", QString::null,
			   this, SLOT(load()), fileTools, "open file" );

    saveIcon = QPixmap( filesave );
    QToolButton * fileSave
	= new QToolButton( saveIcon, "Save File", QString::null,
			   this, SLOT(save()), fileTools, "save file" );

    printIcon = QPixmap( fileprint );
    QToolButton * filePrint
	= new QToolButton( printIcon, "Print File", QString::null,
			   this, SLOT(print()), fileTools, "print file" );

    (void)QWhatsThis::whatsThisButton( fileTools );

    QWhatsThis::add( fileOpen, fileOpenText );
    QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", openIcon );
    QWhatsThis::add( fileSave, fileSaveText );
    QWhatsThis::add( filePrint, filePrintText );

    QPopupMenu * file = new QPopupMenu( this );
    menuBar()->insertItem( "&File", file );

    file->insertItem( "&New", this, SLOT(newDoc()), CTRL+Key_N );

    id = file->insertItem( openIcon, "&Open",
			   this, SLOT(load()), CTRL+Key_O );
    file->setWhatsThis( id, fileOpenText );

    id = file->insertItem( saveIcon, "&Save",
			   this, SLOT(save()), CTRL+Key_S );
    file->setWhatsThis( id, fileSaveText );
    id = file->insertItem( "Save &as...", this, SLOT(saveAs()) );
    file->setWhatsThis( id, fileSaveText );
    file->insertSeparator();
    id = file->insertItem( printIcon, "&Print",
			   this, SLOT(print()), CTRL+Key_P );
    file->setWhatsThis( id, filePrintText );
    file->insertSeparator();
    file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_W );
    file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertSeparator();
    menuBar()->insertItem( "&Help", help );

    help->insertItem( "&About", this, SLOT(about()), Key_F1 );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );
    help->insertSeparator();
    help->insertItem( "What's &This", this, SLOT(whatsThis()), SHIFT+Key_F1 );

    e = new QMultiLineEdit( this, "editor" );
    e->setFocus();
    setCentralWidget( e );
    statusBar()->message( "Ready", 2000 );
    resize( 450, 600 );
}