Commit 85a16976 authored by Victor Yacovlev's avatar Victor Yacovlev

GUI: Implemented toolbar icons configuration

parent 648d734e
This diff is collapsed.
......@@ -21,6 +21,7 @@ set(SOURCES
switchworkspacedialog.cpp
systemopenfilesettings.cpp
guisettingspage.cpp
toolbarcontextmenu.cpp
)
set(EXTRA_LIBS
......@@ -51,6 +52,7 @@ set(MOC_HEADERS
switchworkspacedialog.h
systemopenfilesettings.h
guisettingspage.h
toolbarcontextmenu.h
)
set(FORMS
......
#include "guisettingspage.h"
#include "ui_guisettingspage.h"
#include "mainwindow.h"
#include "plugin.h"
#include "toolbarcontextmenu.h"
#include "extensionsystem/pluginmanager.h"
#include "kumirprogram.h"
#include "interfaces/actorinterface.h"
namespace CoreGUI {
const QString GUISettingsPage::LayoutKey = "MainWindowLayout";
......@@ -19,9 +26,207 @@ GUISettingsPage::GUISettingsPage(ExtensionSystem::SettingsPtr settings, QWidget
ui->gridLayout_2->setAlignment(ui->lblRowsFirst, Qt::AlignHCenter|Qt::AlignBottom);
ui->gridLayout_2->setAlignment(ui->btnColumnsFirst, Qt::AlignHCenter|Qt::AlignTop);
ui->gridLayout_2->setAlignment(ui->btnRowsFirst, Qt::AlignHCenter|Qt::AlignTop);
createVisibleIconsGrid();
init();
}
void GUISettingsPage::createVisibleIconsGrid()
{
static const QString qtcreatorIconsPath = ExtensionSystem::PluginManager::instance()->sharePath()
+ "/icons/from_qtcreator/";
static const QString iconsRoot = ExtensionSystem::PluginManager::instance()->sharePath()
+ "/icons/";
static const int MaxColumns = 2;
int row = 0;
int col = 0;
QFrame * line = 0;
QWidget * c = ui->visibleIconsGrid;
QGridLayout * l = new QGridLayout(c);
c->setLayout(l);
toolbarVisibleItems_ << new QCheckBox(MainWindow::tr("New program"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"filenew.png"));
toolbarVisibleItems_.last()->setObjectName("file-new");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(MainWindow::tr("Open..."), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"fileopen.png"));
toolbarVisibleItems_.last()->setObjectName("file-open");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(MainWindow::tr("Save"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"filesave.png"));
toolbarVisibleItems_.last()->setObjectName("file-save");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
line = new QFrame(this);
line->setObjectName(QString::fromUtf8("line"));
line->setFixedHeight(3);
line->setMinimumWidth(480);
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
l->addWidget(line, ++row, 0, 1, MaxColumns, Qt::AlignCenter);
row ++; col = 0;
toolbarVisibleItems_ << new QCheckBox(tr("Cut selection to clipboard"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"editcut.png"));
toolbarVisibleItems_.last()->setObjectName("edit-cut");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(tr("Copy selection to clipboard"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"editcopy.png"));
toolbarVisibleItems_.last()->setObjectName("edit-copy");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(tr("Paste from clipboard"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"editpaste.png"));
toolbarVisibleItems_.last()->setObjectName("edit-paste");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
line = new QFrame(this);
line->setObjectName(QString::fromUtf8("line"));
line->setFixedHeight(3);
line->setMinimumWidth(480);
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
l->addWidget(line, ++row, 0, 1, MaxColumns, Qt::AlignCenter);
row ++; col = 0;
toolbarVisibleItems_ << new QCheckBox(tr("Undo last action"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"undo.png"));
toolbarVisibleItems_.last()->setObjectName("edit-undo");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(tr("Redo last undoed action"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"redo.png"));
toolbarVisibleItems_.last()->setObjectName("edit-redo");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
line = new QFrame(this);
line->setObjectName(QString::fromUtf8("line"));
line->setFixedHeight(3);
line->setMinimumWidth(480);
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
l->addWidget(line, ++row, 0, 1, MaxColumns, Qt::AlignCenter);
row ++; col = 0;
toolbarVisibleItems_ << new QCheckBox(KumirProgram::tr("Blind run"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"run.png"));
toolbarVisibleItems_.last()->setObjectName("run-blind");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(KumirProgram::tr("Regular run"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"debugger_start.png"));
toolbarVisibleItems_.last()->setObjectName("run-regular");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(KumirProgram::tr("Stop"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"stop.png"));
toolbarVisibleItems_.last()->setObjectName("run-stop");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
line = new QFrame(this);
line->setObjectName(QString::fromUtf8("line"));
line->setFixedHeight(3);
line->setMinimumWidth(480);
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
l->addWidget(line, ++row, 0, 1, MaxColumns, Qt::AlignCenter);
row ++; col = 0;
toolbarVisibleItems_ << new QCheckBox(KumirProgram::tr("Step over"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"debugger_steponeproc_small.png"));
toolbarVisibleItems_.last()->setObjectName("run-step-over");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(KumirProgram::tr("Step in"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"debugger_stepinto_small.png"));
toolbarVisibleItems_.last()->setObjectName("run-step-in");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
toolbarVisibleItems_ << new QCheckBox(KumirProgram::tr("Step to end"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(qtcreatorIconsPath+"debugger_stepoverproc_small.png"));
toolbarVisibleItems_.last()->setObjectName("run-step-out");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
line = new QFrame(this);
line->setObjectName(QString::fromUtf8("line"));
line->setFixedHeight(3);
line->setMinimumWidth(480);
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
l->addWidget(line, ++row, 0, 1, MaxColumns, Qt::AlignCenter);
row ++; col = 0;
toolbarVisibleItems_ << new QCheckBox(Plugin::tr("Courses"), this);
toolbarVisibleItems_.last()->setIcon(QIcon(iconsRoot+"course.png"));
toolbarVisibleItems_.last()->setObjectName("window-courses");
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
QList<Shared::ActorInterface*> actors =
ExtensionSystem::PluginManager::instance()
->findPlugins<Shared::ActorInterface>();
Q_FOREACH(Shared::ActorInterface* actor, actors) {
const QString actorName = Shared::actorCanonicalName(actor->localizedModuleName(QLocale::Russian));
const QString actorObjectname = Shared::actorCanonicalName(actor->asciiModuleName()).replace(" ", "-").toLower();
QString mainIconFileName = iconsRoot+"actors/"+actor->mainIconName()+".png";
if (!QFile(mainIconFileName).exists())
mainIconFileName = iconsRoot+"actors/"+actor->mainIconName()+"_22x22.png";
QString rcIconFileName = iconsRoot+"actors/"+actor->pultIconName()+".png";
if (!QFile(rcIconFileName).exists())
rcIconFileName = iconsRoot+"actors/"+actor->pultIconName()+"_22x22.png";
if (actor->mainWidget()) {
const QString title = actorName;
const QString objectName = "window-actor-" + actorObjectname;
toolbarVisibleItems_ << new QCheckBox(title, this);
toolbarVisibleItems_.last()->setIcon(QIcon(mainIconFileName));
toolbarVisibleItems_.last()->setObjectName(objectName);
const bool tristate = "window-actor-robot"!=objectName && "window-actor-draw"!=objectName;
toolbarVisibleItems_.last()->setTristate(tristate);
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
}
if (actor->pultWidget()) {
const QString title = actorName + " - " + Plugin::tr("Remote Control");
const QString objectName = "window-control-" + actorObjectname;
toolbarVisibleItems_ << new QCheckBox(title, this);
toolbarVisibleItems_.last()->setIcon(QIcon(rcIconFileName));
toolbarVisibleItems_.last()->setObjectName(objectName);
const bool tristate = "window-control-robot"!=objectName;
toolbarVisibleItems_.last()->setTristate(tristate);
l->addWidget(toolbarVisibleItems_.last(), row, col, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
if (++col >= MaxColumns) {row++; col = 0;}
}
}
}
void GUISettingsPage::init()
{
const QString layoutValue = settings_->value(LayoutKey, ColumnsFirstValue).toString();
......@@ -31,6 +236,21 @@ void GUISettingsPage::init()
else {
ui->btnRowsFirst->setChecked(true);
}
// Visible toolbar icons
for (int i=0; i<toolbarVisibleItems_.size(); i++) {
QCheckBox* const item = toolbarVisibleItems_[i];
const QString key = "MainToolBar/" + (
item->objectName().isEmpty()
? QString("unknown") : item->objectName()
);
const Qt::CheckState state = ToolbarContextMenu::f2cs(
settings_->value(key, ToolbarContextMenu::cs2f(
ToolbarContextMenu::defaultVisible(item->objectName())
)).toFloat()
);
item->setCheckState(state);
}
}
void GUISettingsPage::accept()
......@@ -42,9 +262,25 @@ void GUISettingsPage::accept()
else {
settings_->setValue(LayoutKey, RowsFirstValue);
}
QStringList keys;
if (layoutValue != settings_->value(LayoutKey, RowsFirstValue).toString()) {
emit settingsChanged(QStringList() << LayoutKey);
keys << LayoutKey;
}
for (int i=0; i<toolbarVisibleItems_.size(); i++) {
QCheckBox* const item = toolbarVisibleItems_[i];
const QString key = "MainToolBar/" + (
item->objectName().isEmpty()
? QString("unknown") : item->objectName()
);
const double val = ToolbarContextMenu::cs2f(item->checkState());
settings_->setValue(key, val);
keys << key;
}
emit settingsChanged(keys);
}
void GUISettingsPage::resetToDefaults()
......@@ -52,9 +288,25 @@ void GUISettingsPage::resetToDefaults()
const QString layoutValue = settings_->value(LayoutKey, ColumnsFirstValue).toString();
ui->btnRowsFirst->setChecked(true);
settings_->setValue(LayoutKey, RowsFirstValue);
QStringList keys;
if (layoutValue != settings_->value(LayoutKey, RowsFirstValue).toString()) {
emit settingsChanged(QStringList() << LayoutKey);
keys << LayoutKey;
}
for (int i=0; i<toolbarVisibleItems_.size(); i++) {
QCheckBox* const item = toolbarVisibleItems_[i];
const QString key = "MainToolBar/" + (
item->objectName().isEmpty()
? QString("unknown") : item->objectName()
);
Qt::CheckState state = ToolbarContextMenu::defaultVisible(item->objectName());
item->setCheckState(state);
const double val = ToolbarContextMenu::cs2f(state);
settings_->setValue(key, val);
keys << key;
}
emit settingsChanged(keys);
}
GUISettingsPage::~GUISettingsPage()
......
......@@ -4,6 +4,7 @@
#include <extensionsystem/settings.h>
#include <QWidget>
#include <QCheckBox>
namespace CoreGUI {
......@@ -23,15 +24,17 @@ public:
~GUISettingsPage();
public slots:
void createVisibleIconsGrid();
void accept();
void init();
void resetToDefaults();
signals:
void settingsChanged(const QStringList & keys);
private:
private:
Ui::GUISettingsPage *ui;
ExtensionSystem::SettingsPtr settings_;
QList<QCheckBox*> toolbarVisibleItems_;
};
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>252</height>
<width>392</width>
<height>601</height>
</rect>
</property>
<property name="windowTitle">
......@@ -66,7 +66,7 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -79,6 +79,13 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="visibleIconsGrid">
<property name="title">
<string>Visible icons in toolbar</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -36,6 +36,7 @@ KumirProgram::KumirProgram(QObject *parent)
void KumirProgram::createActions()
{
regularRunAction_ = new QAction(tr("Regular run"), this);
regularRunAction_->setObjectName("run-regular");
const QString qtcreatorIconsPath = ExtensionSystem::PluginManager::instance()->sharePath()
+ "/icons/from_qtcreator/";
regularRunAction_->setIcon(QIcon(qtcreatorIconsPath+"debugger_start.png"));
......@@ -53,6 +54,7 @@ void KumirProgram::createActions()
testingRunAction_->setToolTip(testingRunAction_->text()+" <b>"+testingRunAction_->shortcut().toString()+"</b>");
stepRunAction_ = new QAction(tr("Step over"), this);
stepRunAction_->setObjectName("run-step-over");
stepRunAction_->setIcon(QIcon(qtcreatorIconsPath+"debugger_steponeproc_small.png"));
connect(stepRunAction_, SIGNAL(triggered()), this, SLOT(stepRun()));
#ifndef Q_OS_MAC
......@@ -63,6 +65,7 @@ void KumirProgram::createActions()
stepRunAction_->setToolTip(tr("Do big step")+" <b>"+stepRunAction_->shortcut().toString()+"</b>");
stepInAction_ = new QAction(tr("Step in"), this);
stepInAction_->setObjectName("run-step-in");
stepInAction_->setIcon(QIcon(qtcreatorIconsPath+"debugger_stepinto_small.png"));
connect(stepInAction_, SIGNAL(triggered()), this, SLOT(stepIn()));
#ifndef Q_OS_MAC
......@@ -73,6 +76,7 @@ void KumirProgram::createActions()
stepInAction_->setToolTip(tr("Do small step")+" <b>"+stepInAction_->shortcut().toString()+"</b>");
stepOutAction_ = new QAction(tr("Step to end"), this);
stepOutAction_->setObjectName("run-step-out");
stepOutAction_->setIcon(QIcon(qtcreatorIconsPath+"debugger_stepoverproc_small.png"));
connect(stepOutAction_, SIGNAL(triggered()), this, SLOT(stepOut()));
#ifndef Q_OS_MAC
......@@ -83,6 +87,7 @@ void KumirProgram::createActions()
stepOutAction_->setToolTip(tr("Run to end of algorhitm")+" <b>"+stepOutAction_->shortcut().toString()+"</b>");
stopAction_ = new QAction(tr("Stop"), this);
stopAction_->setObjectName("run-stop");
stopAction_->setIcon(QIcon(qtcreatorIconsPath+"stop.png"));
connect(stopAction_, SIGNAL(triggered()), this, SLOT(stop()));
#ifndef Q_OS_MAC
......@@ -104,6 +109,7 @@ void KumirProgram::createActions()
blindRunAction_ = new QAction(tr("Blind run"), this);
blindRunAction_->setObjectName("run-blind");
blindRunAction_->setIcon(QIcon(qtcreatorIconsPath+"run.png"));
connect(blindRunAction_, SIGNAL(triggered()), this, SLOT(blindRun()));
#ifndef Q_OS_MAC
......
......@@ -60,9 +60,11 @@ MainWindow::MainWindow(Plugin * p) :
+ "/icons/from_qtcreator/";
ui->actionNewProgram->setIcon(QIcon(qtcreatorIconsPath+"filenew.png"));
ui->actionNewProgram->setObjectName("file-new");
ui->actionOpen->setIcon(QIcon(qtcreatorIconsPath+"fileopen.png"));
ui->actionOpen->setObjectName("file-open");
ui->actionSave->setIcon(QIcon(qtcreatorIconsPath+"filesave.png"));
ui->actionSave->setProperty("role", "save");
ui->actionSave->setObjectName("file-save");
ui->menuFile->setWindowTitle(ui->menuFile->title());
......@@ -627,8 +629,8 @@ void MainWindow::checkCounterValue()
TabWidgetElement * twe = currentTab();
if (!twe)
return;
if (twe->editorInstance) {
Editor::InstanceInterface * editor = twe->editorInstance;
if (twe->editor()) {
Editor::InstanceInterface * editor = twe->editor();
quint32 errorsCount = editor->errorLinesCount();
statusBar_->setErrorsCounter(errorsCount);
}
......@@ -685,9 +687,9 @@ void MainWindow::timerEvent(QTimerEvent *e)
bool MainWindow::saveCurrentFile()
{
TabWidgetElement * twe = currentTab();
if (!twe->editorInstance)
if (!twe->editor())
return true;
const QString fileName = twe->editorInstance->documentContents().sourceUrl.toLocalFile();
const QString fileName = twe->editor()->documentContents().sourceUrl.toLocalFile();
bool result = 0;
if (fileName.isEmpty()) {
result = saveCurrentFileAs();
......@@ -738,7 +740,7 @@ void MainWindow::updateBrowserTitle(const QString &title, const Shared::Browser:
{
for (int i=0; i<tabWidget_->count(); i++) {
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(tabWidget_->widget(i));
if (twe->browserInstance == sender) {
if (twe->browser() == sender) {
tabWidget_->setTabText(i, title);
if (tabWidget_->currentIndex() == i)
setTitleForTab(i);
......@@ -902,7 +904,7 @@ bool MainWindow::saveCurrentFileAs()
const QString languageName = analizer->languageName();
const QString fileNameSuffix = analizer->defaultDocumentFileNameSuffix();
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(tabWidget_->currentWidget());
QString fileName = twe->editorInstance->documentContents().sourceUrl.toLocalFile();
QString fileName = twe->editor()->documentContents().sourceUrl.toLocalFile();
QString initialPath;
if (fileName.isEmpty()) {
QString lastFileName = m_plugin->mySettings()->value(Plugin::RecentFileKey).toString();
......@@ -913,7 +915,7 @@ bool MainWindow::saveCurrentFileAs()
initialPath = QFileInfo(lastFileName).absoluteDir().absolutePath();
}
const QString suffix = twe->type==Program ? fileNameSuffix : "txt";
initialPath += "/" + suggestNewFileName(suffix, twe->editorInstance->analizer(), initialPath);
initialPath += "/" + suggestNewFileName(suffix, twe->editor()->analizer(), initialPath);
}
else {
initialPath = fileName;
......@@ -950,7 +952,7 @@ bool MainWindow::saveCurrentFileTo(const QString &fileName)
{
TabWidgetElement * twe = currentTab();
try {
twe->editorInstance->saveDocument(fileName);
twe->editor()->saveDocument(fileName);
}
catch (const QString & error) {
QMessageBox::critical(this, tr("Can't save file"), error);
......@@ -989,7 +991,7 @@ bool MainWindow::closeTab(int index)
return false;
}
if (twe->type!=WWW) {
bool notSaved = twe->editorInstance->isModified();
bool notSaved = twe->editor()->isModified();
QMessageBox::StandardButton r;
if (!notSaved || twe->isCourseManagerTab()) {
r = QMessageBox::Discard;
......@@ -1052,7 +1054,7 @@ void MainWindow::createSettingsDialog()
using namespace ExtensionSystem;
settingsDialog_ = new Widgets::MultiPageDialog(this);
settingsDialog_->setWindowTitle(tr("Preferences"));
settingsDialog_->setMinimumSize(700, 500);
settingsDialog_->setMinimumSize(800, 500);
PluginManager * manager = PluginManager::instance();
QList<KPlugin*> plugins = manager->loadedPlugins();
foreach (KPlugin * p, plugins) {
......@@ -1110,7 +1112,7 @@ void MainWindow::newProgram()
editor->toolBarActions(),
editor->menus(),
type);
e->editorInstance = editor;
e->setEditor(editor);
tabWidget_->setCurrentWidget(e);
setTitleForTab(tabWidget_->indexOf(e));
e->setFocus();
......@@ -1150,7 +1152,7 @@ void MainWindow::newText(const QString &fileName, const QString & text)
editor->toolBarActions(),
editor->menus(),
Text);
e->editorInstance = editor;
e->setEditor(editor);
tabWidget_->setCurrentWidget(e);
setTitleForTab(tabWidget_->indexOf(e));
e->setFocus();
......@@ -1194,7 +1196,9 @@ TabWidgetElement * MainWindow::addCentralComponent(
if (type==Program) {
kumir = m_plugin->kumirProgram_;
}
TabWidgetElement * element = new TabWidgetElement(c, type != WWW,
TabWidgetElement * element = new TabWidgetElement(c,
m_plugin->mySettings(),
type != WWW,
toolbarActions, menus, type,
gr_fileActions, gr_otherActions, kumir);
......@@ -1253,7 +1257,7 @@ void MainWindow::setupContentForTab()
return;
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(currentTabWidget);
m_plugin->kumirProgram_->setEditorInstance(twe->editorInstance);
m_plugin->kumirProgram_->setEditorInstance(twe->editor());
}
void MainWindow::disableTabs()
......@@ -1273,6 +1277,12 @@ void MainWindow::updateSettings(SettingsPtr settings, const QStringList & keys)
// if (settings_) saveSettings();
settings_ = settings;
loadSettings(keys);
for (int i=0; i<tabWidget_->count(); i++) {
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(tabWidget_->widget(i));
if (twe) {
twe->updateSettingsObject(settings);
}
}
}
bool MainWindow::isColumnFirstLayout() const
......@@ -1359,8 +1369,8 @@ void MainWindow::restoreSession()
bool hasUnsavedChanges = false;
for (int i=0; i<tabWidget_->count(); i++) {
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(tabWidget_->widget(i));
if (twe->editorInstance) {
hasUnsavedChanges = hasUnsavedChanges || twe->editorInstance->isModified();
if (twe->editor()) {
hasUnsavedChanges = hasUnsavedChanges || twe->editor()->isModified();
}
if (hasUnsavedChanges)
break;
......@@ -1396,8 +1406,8 @@ void MainWindow::closeEvent(QCloseEvent *e)
// m_plugin->saveSession();
if (m_plugin->sessionsDisableFlag_ && tabsDisabledFlag_) {
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(tabWidget_->currentWidget());
if (twe->editorInstance) {
bool notSaved = twe->editorInstance->isModified();
if (twe->editor()) {
bool notSaved = twe->editor()->isModified();
if (!notSaved || twe->isCourseManagerTab()) {
if (ExtensionSystem::PluginManager::instance()->shutdown()) {
e->accept();
......@@ -1416,8 +1426,8 @@ void MainWindow::closeEvent(QCloseEvent *e)
QStringList unsavedFiles;
for (int i=0; i<tabWidget_->count(); i++) {
TabWidgetElement * twe = qobject_cast<TabWidgetElement*>(tabWidget_->widget(i));
if (twe->editorInstance) {
bool notSaved = twe->editorInstance->isModified();
if (twe->editor())