[Kst] branches/work/kst/portto4/kst/src/libkstapp
George Staikos
staikos at kde.org
Mon May 28 22:06:08 CEST 2007
SVN commit 669224 by staikos:
add multi-tab support, more actions that do nothing.
M +31 -0 mainwindow.cpp
M +6 -0 mainwindow.h
M +12 -1 tabwidget.cpp
M +1 -0 tabwidget.h
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #669223:669224
@@ -147,6 +147,30 @@
_createLineAct->setStatusTip(tr("Create a line for the current view"));
connect(_createLineAct, SIGNAL(triggered()), this, SLOT(createLine()));
+ _newTabAct = new QAction(tr("&New tab"), this);
+ _newTabAct->setStatusTip(tr("Create a new tab"));
+ connect(_newTabAct, SIGNAL(triggered()), tabWidget(), SLOT(createView()));
+
+ _closeTabAct = new QAction(tr("&Close tab"), this);
+ _closeTabAct->setStatusTip(tr("Close the current tab"));
+ connect(_closeTabAct, SIGNAL(triggered()), tabWidget(), SLOT(closeCurrentView()));
+
+ _saveAct = new QAction(tr("&Save"), this);
+ _saveAct->setStatusTip(tr("Save the current session"));
+ //connect(_saveAct, SIGNAL(triggered()), document(), SLOT(save()));
+
+ _saveAsAct = new QAction(tr("Save &as..."), this);
+ _saveAsAct->setStatusTip(tr("Save the current session"));
+ //connect(_saveAsAct, SIGNAL(triggered()), document(), SLOT(saveAs()));
+
+ _openAct = new QAction(tr("&Open..."), this);
+ _openAct->setStatusTip(tr("Open a new session"));
+ //connect(_openAct, SIGNAL(triggered()), this, SLOT(openDocument()));
+
+ _printAct = new QAction(tr("&Print..."), this);
+ _printAct->setStatusTip(tr("Print the current view"));
+ //connect(_printAct, SIGNAL(triggered()), this, SLOT(print()));
+
_exitAct = new QAction(tr("E&xit"), this);
_exitAct->setShortcut(tr("Ctrl+Q"));
_exitAct->setStatusTip(tr("Exit the application"));
@@ -163,7 +187,14 @@
void MainWindow::createMenus() {
_fileMenu = menuBar()->addMenu(tr("&File"));
+ _fileMenu->addAction(_newTabAct);
+ _fileMenu->addAction(_saveAct);
+ _fileMenu->addAction(_saveAsAct);
+ _fileMenu->addAction(_openAct);
_fileMenu->addSeparator();
+ _fileMenu->addAction(_printAct);
+ _fileMenu->addSeparator();
+ _fileMenu->addAction(_closeTabAct);
_fileMenu->addAction(_exitAct);
_editMenu = menuBar()->addMenu(tr("&Edit"));
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #669223:669224
@@ -74,6 +74,12 @@
QAction *_createEllipseAct;
QAction *_createLineAct;
+ QAction *_newTabAct;
+ QAction *_saveAct;
+ QAction *_saveAsAct;
+ QAction *_openAct;
+ QAction *_printAct;
+ QAction *_closeTabAct;
QAction *_exitAct;
QAction *_aboutAct;
QAction *_aboutQtAct;
--- branches/work/kst/portto4/kst/src/libkstapp/tabwidget.cpp #669223:669224
@@ -35,11 +35,13 @@
parent->undoGroup()->setActiveStack(view->undoStack());
}
+ static int cnt = 1;
QString label = view->objectName().isEmpty() ?
- tr("Plot %1").arg(QString::number(count())) :
+ tr("Plot %1").arg(cnt++) :
view->objectName();
addTab(view, label);
+ setCurrentWidget(view);
return view;
}
@@ -54,9 +56,18 @@
removeTab(indexOf(view));
}
+
+void TabWidget::closeCurrentView() {
+ delete currentView();
+ if (count() == 0) {
+ createView();
+ }
}
+}
+
+
#include "tabwidget.moc"
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/tabwidget.h #669223:669224
@@ -29,6 +29,7 @@
public Q_SLOTS:
View *createView();
+ void closeCurrentView();
private Q_SLOTS:
void viewDestroyed(QObject *object);
More information about the Kst
mailing list