Qt

 view release on metacpan or  search on metacpan

qtgui/examples/mainwindows/application/MainWindow.pm  view on Meta::CPAN

        return saveAs();
    } else {
        return saveFile(this->{curFile});
    }
}

sub saveAs {
    my $fileName = Qt::FileDialog::getSaveFileName(this);
    if (!defined $fileName){
        return 0;
    }

    return saveFile($fileName);
}

sub about {
    Qt::MessageBox::about(this, "About Application",
            "The <b>Application</b> example demonstrates how to " .
               "write modern GUI applications using Qt, with a menu bar, " .
               "toolbars, and a status bar.");
}

sub documentWasModified {
    this->setWindowModified(this->{textEdit}->document()->isModified());
}

sub createActions {
    my $textEdit = this->{textEdit};
    my $newAct =  Qt::Action(Qt::Icon("images/new.png"), "&New", this);
    $newAct->setShortcut(Qt::KeySequence("Ctrl+N"));
    $newAct->setStatusTip("Create a new file");
    this->connect($newAct, SIGNAL 'triggered()', this, SLOT 'newFile()');
    this->{newAct} = $newAct;

    my $openAct = Qt::Action(Qt::Icon("images/open.png"), "&Open...", this);
    $openAct->setShortcut(Qt::KeySequence("Ctrl+O"));
    $openAct->setStatusTip("Open an existing file");
    this->connect($openAct, SIGNAL 'triggered()', this, SLOT 'openFile()');
    this->{openAct} = $openAct;

    my $saveAct = Qt::Action(Qt::Icon("images/save.png"), "&Save", this);
    $saveAct->setShortcut(Qt::KeySequence("Ctrl+S"));
    $saveAct->setStatusTip("Save the document to disk");
    this->connect($saveAct, SIGNAL 'triggered()', this, SLOT 'save()');
    this->{saveAct} = $saveAct;

    my $saveAsAct = Qt::Action("Save &As...", this);
    $saveAsAct->setStatusTip("Save the document under a new name");
    this->connect($saveAsAct, SIGNAL 'triggered()', this, SLOT 'saveAs()');
    this->{saveAsAct} = $saveAsAct;

    my $exitAct = Qt::Action("E&xit", this);
    $exitAct->setShortcut(Qt::KeySequence("Ctrl+Q"));
    $exitAct->setStatusTip("Exit the application");
    this->connect($exitAct, SIGNAL 'triggered()', this, SLOT 'close()');
    this->{exitAct} = $exitAct;

    my $cutAct = Qt::Action(Qt::Icon("images/cut.png"), "Cu&t", this);
    $cutAct->setShortcut(Qt::KeySequence("Ctrl+X"));
    $cutAct->setStatusTip("Cut the current selection's contents to the " .
                            "clipboard");
    this->connect($cutAct, SIGNAL 'triggered()', $textEdit, SLOT 'cut()');
    this->{cutAct} = $cutAct;

    my $copyAct = Qt::Action(Qt::Icon("images/copy.png"), "&Copy", this);
    $copyAct->setShortcut(Qt::KeySequence("Ctrl+C"));
    $copyAct->setStatusTip("Copy the current selection's contents to the " .
                             "clipboard");
    this->connect($copyAct, SIGNAL 'triggered()', $textEdit, SLOT 'copy()');
    this->{copyAct} = $copyAct;

    my $pasteAct = Qt::Action(Qt::Icon("images/paste.png"), "&Paste", this);
    $pasteAct->setShortcut(Qt::KeySequence("Ctrl+V"));
    $pasteAct->setStatusTip("Paste the clipboard's contents into the current " .
                              "selection");
    this->connect($pasteAct, SIGNAL 'triggered()', $textEdit, SLOT 'paste()');
    this->{pasteAct} = $pasteAct;

    my $aboutAct = Qt::Action("&About", this);
    $aboutAct->setStatusTip("Show the application's About box");
    this->connect($aboutAct, SIGNAL 'triggered()', this, SLOT 'about()');
    this->{aboutAct} = $aboutAct;

    my $aboutQtAct = Qt::Action("About &Qt", this);
    $aboutQtAct->setStatusTip("Show the Qt4 library's About box");
    this->connect($aboutQtAct, SIGNAL 'triggered()', Qt::qApp(), SLOT 'aboutQt()');
    this->{aboutQtAct} = $aboutQtAct;

    $cutAct->setEnabled(0);
    $copyAct->setEnabled(0);
    this->connect($textEdit, SIGNAL 'copyAvailable(bool)',
                  $cutAct, SLOT 'setEnabled(bool)');
    this->connect($textEdit, SIGNAL 'copyAvailable(bool)',
                  $copyAct, SLOT 'setEnabled(bool)');
}

sub createMenus {
    my $fileMenu = this->menuBar()->addMenu("&File");
    $fileMenu->addAction(this->{newAct});
    $fileMenu->addAction(this->{openAct});
    $fileMenu->addAction(this->{saveAct});
    $fileMenu->addAction(this->{saveAsAct});
    $fileMenu->addSeparator();
    $fileMenu->addAction(this->{exitAct});

    my $editMenu = this->menuBar()->addMenu("&Edit");
    $editMenu->addAction(this->{cutAct});
    $editMenu->addAction(this->{copyAct});
    $editMenu->addAction(this->{pasteAct});

    this->menuBar()->addSeparator();

    my $helpMenu = this->menuBar()->addMenu("&Help");
    $helpMenu->addAction(this->{aboutAct});
    $helpMenu->addAction(this->{aboutQtAct});
}

sub createToolBars {
    my $fileToolBar = this->addToolBar("File");
    $fileToolBar->addAction(this->{newAct});
    $fileToolBar->addAction(this->{openAct});
    $fileToolBar->addAction(this->{saveAct});

    my $editToolBar = this->addToolBar("Edit");
    $editToolBar->addAction(this->{cutAct});
    $editToolBar->addAction(this->{copyAct});
    $editToolBar->addAction(this->{pasteAct});
}

sub createStatusBar {
    this->statusBar()->showMessage("Ready");
}

sub readSettings {



( run in 3.860 seconds using v1.01-cache-2.11-cpan-2398b32b56e )