Qt
view release on metacpan or search on metacpan
qtgui/examples/mainwindows/mdi/MainWindow.pm view on Meta::CPAN
$text = sprintf "&%d %s", $i + 1,
$child->userFriendlyCurrentFile();
} else {
$text = sprintf "%s %s", $i + 1,
$child->userFriendlyCurrentFile();
}
my $action = this->{windowMenu}->addAction($text);
$action->setCheckable(1);
$action->setChecked($child == activeMdiChild());
this->connect($action, SIGNAL 'triggered()', this->{windowMapper}, SLOT 'map()');
this->{windowMapper}->setMapping($action, $windows[$i]);
}
}
sub createMdiChild {
my $child = MdiChild();
this->{mdiArea}->addSubWindow($child);
this->connect($child, SIGNAL 'copyAvailable(bool)',
this->{cutAct}, SLOT 'setEnabled(bool)');
this->connect($child, SIGNAL 'copyAvailable(bool)',
this->{copyAct}, SLOT 'setEnabled(bool)');
return $child;
}
sub createActions {
my $newAct = Qt::Action(Qt::Icon("images/new.png"), "&New", this);
this->{newAct} = $newAct;
$newAct->setShortcut(Qt::KeySequence("Ctrl+N"));
$newAct->setStatusTip("Create a new file");
this->connect($newAct, SIGNAL 'triggered()', this, SLOT 'newFile()');
my $openAct = Qt::Action(Qt::Icon("images/open.png"), "&Open...", this);
this->{openAct} = $openAct;
$openAct->setShortcut(Qt::KeySequence("Ctrl+O"));
$openAct->setStatusTip("Open an existing file");
this->connect($openAct, SIGNAL 'triggered()', this, SLOT 'openSlot()');
my $saveAct = Qt::Action(Qt::Icon("images/save.png"), "&Save", this);
this->{saveAct} = $saveAct;
$saveAct->setShortcut(Qt::KeySequence("Ctrl+S"));
$saveAct->setStatusTip("Save the document to disk");
this->connect($saveAct, SIGNAL 'triggered()', this, SLOT 'save()');
my $saveAsAct = Qt::Action("Save &As...", this);
this->{saveAsAct} = $saveAsAct;
$saveAsAct->setStatusTip("Save the document under a new name");
this->connect($saveAsAct, SIGNAL 'triggered()', this, SLOT 'saveAs()');
my $exitAct = Qt::Action("E&xit", this);
this->{exitAct} = $exitAct;
$exitAct->setShortcut(Qt::KeySequence("Ctrl+Q"));
$exitAct->setStatusTip("Exit the application");
this->connect($exitAct, SIGNAL 'triggered()', Qt::qApp(), SLOT 'closeAllWindows()');
my $cutAct = Qt::Action(Qt::Icon("images/cut.png"), "Cu&t", this);
this->{cutAct} = $cutAct;
$cutAct->setShortcut(Qt::KeySequence("Ctrl+X"));
$cutAct->setStatusTip("Cut the current selection's contents to the " .
"clipboard");
this->connect($cutAct, SIGNAL 'triggered()', this, SLOT 'cut()');
my $copyAct = Qt::Action(Qt::Icon("images/copy.png"), "&Copy", this);
this->{copyAct} = $copyAct;
$copyAct->setShortcut(Qt::KeySequence("Ctrl+C"));
$copyAct->setStatusTip("Copy the current selection's contents to the " .
"clipboard");
this->connect($copyAct, SIGNAL 'triggered()', this, SLOT 'copy()');
my $pasteAct = Qt::Action(Qt::Icon("images/paste.png"), "&Paste", this);
this->{pasteAct} = $pasteAct;
$pasteAct->setShortcut(Qt::KeySequence("Ctrl+V"));
$pasteAct->setStatusTip("Paste the clipboard's contents into the current " .
"selection");
this->connect($pasteAct, SIGNAL 'triggered()', this, SLOT 'paste()');
my $closeAct = Qt::Action("Cl&ose", this);
this->{closeAct} = $closeAct;
$closeAct->setShortcut(Qt::KeySequence("Ctrl+F4"));
$closeAct->setStatusTip("Close the active window");
this->connect($closeAct, SIGNAL 'triggered()',
this->{mdiArea}, SLOT 'closeActiveSubWindow()');
my $closeAllAct = Qt::Action("Close &All", this);
this->{closeAllAct} = $closeAllAct;
$closeAllAct->setStatusTip("Close all the windows");
this->connect($closeAllAct, SIGNAL 'triggered()',
this->{mdiArea}, SLOT 'closeAllSubWindows()');
my $tileAct = Qt::Action("&Tile", this);
this->{tileAct} = $tileAct;
$tileAct->setStatusTip("Tile the windows");
this->connect($tileAct, SIGNAL 'triggered()', this->{mdiArea}, SLOT 'tileSubWindows()');
my $cascadeAct = Qt::Action("&Cascade", this);
this->{cascadeAct} = $cascadeAct;
$cascadeAct->setStatusTip("Cascade the windows");
this->connect($cascadeAct, SIGNAL 'triggered()', this->{mdiArea}, SLOT 'cascadeSubWindows()');
my $nextAct = Qt::Action("Ne&xt", this);
this->{nextAct} = $nextAct;
$nextAct->setStatusTip("Move the focus to the next window");
this->connect($nextAct, SIGNAL 'triggered()',
this->{mdiArea}, SLOT 'activateNextSubWindow()');
my $previousAct = Qt::Action("Pre&vious", this);
this->{previousAct} = $previousAct;
$previousAct->setStatusTip("Move the focus to the previous " .
"window");
this->connect($previousAct, SIGNAL 'triggered()',
this->{mdiArea}, SLOT 'activatePreviousSubWindow()');
my $separatorAct = Qt::Action(this);
this->{separatorAct} = $separatorAct;
$separatorAct->setSeparator(1);
my $aboutAct = Qt::Action("&About", this);
this->{aboutAct} = $aboutAct;
$aboutAct->setStatusTip("Show the application's About box");
this->connect($aboutAct, SIGNAL 'triggered()', this, SLOT 'about()');
my $aboutQtAct = Qt::Action("About &Qt", this);
this->{aboutQtAct} = $aboutQtAct;
$aboutQtAct->setStatusTip("Show the Qt4 library's About box");
this->connect($aboutQtAct, SIGNAL 'triggered()', Qt::qApp(), SLOT 'aboutQt()');
}
sub createMenus {
my $fileMenu = this->menuBar()->addMenu("&File");
$fileMenu->addAction(this->{newAct});
$fileMenu->addAction(this->{openAct});
$fileMenu->addAction(this->{saveAct});
$fileMenu->addAction(this->{saveAsAct});
( run in 1.171 second using v1.01-cache-2.11-cpan-2398b32b56e )