Commit cab2b2f2 authored by Victor Yacovlev's avatar Victor Yacovlev

Updated WorkingDirectory select window

parent 699731d1
......@@ -1068,10 +1068,10 @@ Using Qt version %2</source>
<translation>Исполнители</translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="902"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="903"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="934"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="943"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="909"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="910"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="941"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="950"/>
<source>No actions for this tab</source>
<translation>Для этой вкладки нет действий</translation>
</message>
......@@ -1092,7 +1092,7 @@ Using Qt version %2</source>
<translation type="obsolete">Пауза</translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="909"/>
<location filename="../../../src/plugins/coregui/plugin.cpp" line="916"/>
<source>Start</source>
<translation>Начало</translation>
</message>
......@@ -1247,7 +1247,6 @@ Using Qt version %2</source>
<translation>Выбор каталога пользователя</translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.ui" line="44"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
......@@ -1256,7 +1255,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Kumir stores your programs, data and settings in a folder called a workspace.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Choose a workspace folder to use for this session.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<translation type="obsolete">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Droid Sans&apos;; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
......@@ -1265,6 +1264,15 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Кумир хранит Ваши программы, настройки и файлы данных в едином рабочем каталоге.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Выберете каталог, который будет использовать Кумир.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.ui" line="47"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Droid Sans&apos;; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation></translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.ui" line="60"/>
<source>Workspace:</source>
......@@ -1282,6 +1290,21 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.cpp" line="53"/>
<source>&lt;p class=&apos;heading&apos;&gt;Choose working directory&lt;/p&gt;</source>
<translation>&lt;p class=&apos;heading&apos;&gt;Выберите рабочий каталог&lt;/p&gt; </translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.cpp" line="54"/>
<source>&lt;p class=&apos;main&apos;&gt;Working directory is a place to access files within your program using &lt;span class=&apos;code&apos;&gt;WORKING_DIRECTORY&lt;/span&gt; location.&lt;/p&gt;</source>
<translation>&lt;p class=&apos;main&apos;&gt;Рабочий каталог - это каталог, в котором выполняется поиск файлов для ввода и вывода. Из программы это значение можно получить значением &lt;span class=&apos;code&apos;&gt;РАБОЧИЙ_КАТАЛОГ&lt;/span&gt;&lt;/p&gt;</translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.cpp" line="57"/>
<source>&lt;p class=&apos;main&apos;&gt;Kumir also uses this directory to store your personal settings.&lt;p&gt;</source>
<translation type="unfinished">&lt;p class=&apos;main&apos;&gt;Кроме того, в этом каталоге Кумир хранит Ваши персональные настройки.&lt;/p&gt;</translation>
</message>
<message>
<location filename="../../../src/plugins/coregui/switchworkspacedialog.cpp" line="81"/>
<source>Select directory for use as workspace</source>
<translation>Выбор рабочего каталога</translation>
</message>
......
......@@ -376,8 +376,8 @@ void KumirProgram::prepareRunner(Shared::GeneratorInterface::DebugLevel debugLev
ok = runner()->loadProgram(program);
}
const QString newCwd = QFileInfo(sourceProgramPath).absoluteDir().absolutePath();
QDir::setCurrent(newCwd);
// const QString newCwd = QFileInfo(sourceProgramPath).absoluteDir().absolutePath();
// QDir::setCurrent(newCwd);
if (runner()->hasBreakpointsSupport()) {
using Editor::Breakpoint;
......
......@@ -818,10 +818,17 @@ bool Plugin::showWorkspaceChooseDialog()
{
SwitchWorkspaceDialog * dialog = new
SwitchWorkspaceDialog(ExtensionSystem::PluginManager::instance()->globalSettings());
dialog->setMessage(sessionsDisableFlag_
? SwitchWorkspaceDialog::MSG_ChangeWorkingDirectory
: SwitchWorkspaceDialog::MSG_ChangeWorkspace);
dialog->setUseAlwaysHidden(sessionsDisableFlag_);
if (dialog->exec() == QDialog::Accepted) {
ExtensionSystem::PluginManager::instance()->switchToWorkspace(
dialog->currentWorkspace()
);
ExtensionSystem::PluginManager::instance()->
switchToWorkspace(
dialog->currentWorkspace(),
sessionsDisableFlag_
)
;
return true;
}
else {
......@@ -840,8 +847,8 @@ void Plugin::start()
}
}
else {
if (!sessionsDisableFlag_) ExtensionSystem::PluginManager::instance()->switchToDefaultWorkspace();
else {
ExtensionSystem::PluginManager::instance()->switchToDefaultWorkspace(sessionsDisableFlag_);
if (sessionsDisableFlag_) {
updateSettings(QStringList());
restoreSession();
}
......
......@@ -42,6 +42,34 @@ void SwitchWorkspaceDialog::setCurrentWorkspace(const QString &path)
}
}
void SwitchWorkspaceDialog::setMessage(SwitchWorkspaceDialog::Message message)
{
const QString css =
"<style type='text/css'>"
".main { font-size: 11pt; }"
".heading { font-size: 12pt; font-weight: bold; text-align: left; }"
".code { font-family: monospace; font-weight: bold;}"
"</style>";
const QString heading = tr("<p class='heading'>Choose working directory</p>");
QString text = tr("<p class='main'>Working directory is a place to access files within your program using <span class='code'>WORKING_DIRECTORY</span> location.</p>");
switch (message) {
case MSG_ChangeWorkspace:
text += tr("<p class='main'>Kumir also uses this directory to store your personal settings.<p>");
break;
case MSG_ChangeWorkingDirectory:
break;
}
const QString html =
css + heading + text;
ui->textBrowser->setHtml(html);
}
void SwitchWorkspaceDialog::setUseAlwaysHidden(bool v)
{
ui->checkBox->setVisible(! v);
}
QString SwitchWorkspaceDialog::currentWorkspace() const
{
return QDir::cleanPath(QDir::fromNativeSeparators(ui->comboBox->currentText()));
......
......@@ -22,9 +22,12 @@ class SwitchWorkspaceDialog
Q_OBJECT
public:
enum Message { MSG_ChangeWorkspace, MSG_ChangeWorkingDirectory };
explicit SwitchWorkspaceDialog(ExtensionSystem::SettingsPtr settings);
~SwitchWorkspaceDialog();
void setCurrentWorkspace(const QString &path);
void setMessage(Message message);
void setUseAlwaysHidden(bool v);
QString currentWorkspace() const;
private slots:
void handleBrowseClicked();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>225</height>
<width>699</width>
<height>285</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -20,6 +20,9 @@
<string>Workspace Launcher</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="sizePolicy">
......@@ -44,11 +47,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Droid Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Select a workspace&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Kumir stores your programs, data and settings in a folder called a workspace.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Choose a workspace folder to use for this session.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Droid Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
......@@ -91,14 +91,31 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
......@@ -85,17 +85,17 @@ void PluginManager::updateAllSettings()
}
}
void PluginManager::switchToDefaultWorkspace()
void PluginManager::switchToDefaultWorkspace(bool workDirOnly)
{
const QString workDir = pImpl_->mySettings->value(
CurrentWorkspaceKey,
QString(QDir::homePath()+"/Kumir/")).toString();
pImpl_->changeWorkingDirectory(workDir, false);
pImpl_->changeWorkingDirectory(workDir, false, workDirOnly);
}
void PluginManager::switchToWorkspace(const QString &path)
void PluginManager::switchToWorkspace(const QString &path, bool workDirOnly)
{
pImpl_->changeWorkingDirectory(path, true);
pImpl_->changeWorkingDirectory(path, true, workDirOnly);
}
......@@ -240,7 +240,7 @@ QString PluginManager::loadExtraModule(const std::string &canonicalFileName)
spec.gui = plugin->isGuiRequired();
pImpl_->specs.push_back(spec);
Settings * sett = new Settings(moduleName);
sett->changeWorkingDirectory(pImpl_->workspacePath);
sett->changeWorkingDirectory(pImpl_->settingsWorkspacePath);
pImpl_->settings.push_back(SettingsPtr(sett));
plugin->updateSettings(QStringList());
CommandLine runtimeParameters;
......
......@@ -156,8 +156,8 @@ public:
void updateAllSettings();
void switchToDefaultWorkspace();
void switchToWorkspace(const QString & path);
void switchToDefaultWorkspace(bool workDirOnly);
void switchToWorkspace(const QString & path, bool workDirOnly);
/** Stops all plugins in reverse-order of creation
* @returns true if there is not module blocking exit, false elsewhere
......
......@@ -176,26 +176,30 @@ bool PluginManagerImpl::extractRuntimeParametersForPlugin(const KPlugin *plugin,
return success;
}
void PluginManagerImpl::changeWorkingDirectory(const QString &path, bool saveChanges)
void PluginManagerImpl::changeWorkingDirectory(const QString &path, bool saveChanges, bool workDirOnly)
{
workspacePath = path;
for (int i=0; i<objects.size(); i++) {
KPlugin * p = objects[i];
SettingsPtr s = settings[i];
if (s) {
if (saveChanges) p->saveSession();
s->changeWorkingDirectory(path);
if (!workDirOnly) {
settingsWorkspacePath = path;
for (int i=0; i<objects.size(); i++) {
KPlugin * p = objects[i];
SettingsPtr s = settings[i];
if (s) {
if (saveChanges) p->saveSession();
s->changeWorkingDirectory(path);
}
}
}
QDir::root().mkpath(path);
QDir::setCurrent(path);
QDir::current().mkdir(".settings");
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, path+"/.settings");
for (int i=0; i<objects.size(); i++) {
KPlugin * p = objects[i];
p->changeCurrentDirectory(path);
p->updateSettings(QStringList());
p->restoreSession();
if (!workDirOnly) {
QDir::current().mkdir(".settings");
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, path+"/.settings");
for (int i=0; i<objects.size(); i++) {
KPlugin * p = objects[i];
p->changeCurrentDirectory(path);
p->updateSettings(QStringList());
p->restoreSession();
}
}
mySettings->setValue(PluginManager::CurrentWorkspaceKey, path);
}
......
......@@ -26,7 +26,7 @@ struct PluginManagerImpl {
GlobalState globalState;
SettingsPtr mySettings;
QString workspacePath;
QString settingsWorkspacePath;
QString parsePluginsRequest(const QString &templ, QList<PluginRequest> & plugins, QStringList & names);
......@@ -36,7 +36,7 @@ struct PluginManagerImpl {
QString reorderSpecsAndCreateStates(const QStringList & orderedList);
void createSettingsDialog();
QString loadPlugins();
void changeWorkingDirectory(const QString &path, bool saveChanges);
void changeWorkingDirectory(const QString &path, bool saveChanges, bool workDirOnly);
bool extractRuntimeParametersForPlugin(const KPlugin * plugin, CommandLine & parameters);
std::list<QString> namedProgramArguments;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment