forked from qt-creator/qt-creator
The macros plugin use a directory in userResourcePath.
It is not possible to manage different directory for the macro plugin, it uses the user resource path per default. This change cleans a lot of code, specially we don't need any specific settings for the macro plugin, and the option page is more simple. Merge-request: 240 Reviewed-by: con <qtc-committer@nokia.com>
This commit is contained in:
committed by
con
parent
23e024de64
commit
acf607f009
@@ -36,7 +36,6 @@
|
||||
#include "macrosconstants.h"
|
||||
#include "macroevent.h"
|
||||
#include "macro.h"
|
||||
#include "macrosettings.h"
|
||||
#include "imacrohandler.h"
|
||||
#include "savedialog.h"
|
||||
#include "actionmacrohandler.h"
|
||||
@@ -63,7 +62,6 @@
|
||||
#include <QtCore/QList>
|
||||
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QKeySequence>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QFileDialog>
|
||||
@@ -107,7 +105,6 @@ public:
|
||||
MacroManagerPrivate(MacroManager *qq);
|
||||
|
||||
MacroManager *q;
|
||||
MacroSettings settings;
|
||||
QMap<QString, Macro *> macros;
|
||||
Macro *currentMacro;
|
||||
bool isRecording;
|
||||
@@ -120,10 +117,8 @@ public:
|
||||
TextEditorMacroHandler *textEditorHandler;
|
||||
FindMacroHandler *findHandler;
|
||||
|
||||
void init();
|
||||
void appendDirectory(const QString &directory);
|
||||
void removeDirectory(const QString &directory);
|
||||
void addMacro(Macro *macro, QKeySequence ks=QKeySequence());
|
||||
void initialize();
|
||||
void addMacro(Macro *macro);
|
||||
void removeMacro(const QString &name);
|
||||
void changeMacroDescription(Macro *macro, const QString &description);
|
||||
|
||||
@@ -137,23 +132,20 @@ MacroManager::MacroManagerPrivate::MacroManagerPrivate(MacroManager *qq):
|
||||
isRecording(false),
|
||||
mapper(new QSignalMapper(qq))
|
||||
{
|
||||
settings.fromSettings(Core::ICore::instance()->settings());
|
||||
|
||||
connect(mapper, SIGNAL(mapped(QString)), q, SLOT(executeMacro(QString)));
|
||||
|
||||
// Load/unload macros
|
||||
foreach (const QString &dir, settings.directories)
|
||||
appendDirectory(dir);
|
||||
// Load existing macros
|
||||
initialize();
|
||||
|
||||
actionHandler = new ActionMacroHandler;
|
||||
textEditorHandler = new TextEditorMacroHandler;
|
||||
findHandler = new FindMacroHandler;
|
||||
}
|
||||
|
||||
void MacroManager::MacroManagerPrivate::appendDirectory(const QString &directory)
|
||||
void MacroManager::MacroManagerPrivate::initialize()
|
||||
{
|
||||
macros.clear();
|
||||
QDir dir(directory);
|
||||
QDir dir(q->macrosDirectory());
|
||||
QStringList filter;
|
||||
filter << QString("*.")+Constants::M_EXTENSION;
|
||||
QStringList files = dir.entryList(filter, QDir::Files);
|
||||
@@ -162,32 +154,11 @@ void MacroManager::MacroManagerPrivate::appendDirectory(const QString &directory
|
||||
QString fileName = dir.absolutePath()+"/"+name;
|
||||
Macro *macro = new Macro;
|
||||
macro->loadHeader(fileName);
|
||||
|
||||
// Create shortcut
|
||||
QKeySequence ks;
|
||||
if (settings.shortcuts.contains(macro->displayName()))
|
||||
ks.fromString(settings.shortcuts.value(macro->displayName()).toString());
|
||||
|
||||
addMacro(macro, ks);
|
||||
addMacro(macro);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroManager::MacroManagerPrivate::removeDirectory(const QString &directory)
|
||||
{
|
||||
QMapIterator<QString, Macro *> it(macros);
|
||||
QDir dir(directory);
|
||||
QStringList removeList;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
QFileInfo fileInfo(it.value()->fileName());
|
||||
if (fileInfo.absoluteDir() == dir.absolutePath())
|
||||
removeList.append(it.key());
|
||||
}
|
||||
foreach (const QString &name, removeList)
|
||||
removeMacro(name);
|
||||
}
|
||||
|
||||
void MacroManager::MacroManagerPrivate::addMacro(Macro *macro, QKeySequence ks)
|
||||
void MacroManager::MacroManagerPrivate::addMacro(Macro *macro)
|
||||
{
|
||||
// Add sortcut
|
||||
Core::Context context(TextEditor::Constants::C_TEXTEDITOR);
|
||||
@@ -196,9 +167,7 @@ void MacroManager::MacroManagerPrivate::addMacro(Macro *macro, QKeySequence ks)
|
||||
QShortcut *shortcut = new QShortcut(core->mainWindow());
|
||||
shortcut->setWhatsThis(macro->description());
|
||||
const QString macroId = QLatin1String(Constants::PREFIX_MACRO) + macro->displayName();
|
||||
Core::Command *command = am->registerShortcut(shortcut, macroId, context);
|
||||
if (!ks.isEmpty())
|
||||
command->setDefaultKeySequence(ks);
|
||||
am->registerShortcut(shortcut, macroId, context);
|
||||
connect(shortcut, SIGNAL(activated()), mapper, SLOT(map()));
|
||||
mapper->setMapping(shortcut, macro->displayName());
|
||||
|
||||
@@ -274,22 +243,8 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
|
||||
if (dialog.name().isEmpty())
|
||||
return;
|
||||
|
||||
// Check if there's a default directory
|
||||
// If not, ask a directory to the user
|
||||
QString directory = settings.defaultDirectory;
|
||||
QDir dir(directory);
|
||||
if (directory.isEmpty() || !dir.exists()) {
|
||||
directory = QFileDialog::getExistingDirectory(
|
||||
mainWindow,
|
||||
tr("Choose a default macro directory"),
|
||||
QDir::homePath());
|
||||
if (directory.isNull())
|
||||
return;
|
||||
settings.directories.append(directory);
|
||||
settings.defaultDirectory= directory;
|
||||
q->saveSettings();
|
||||
}
|
||||
QString fileName = directory + '/' + dialog.name()
|
||||
// Save in the resource path
|
||||
QString fileName = q->macrosDirectory() + '/' + dialog.name()
|
||||
+ '.' + Constants::M_EXTENSION;
|
||||
currentMacro->setDescription(dialog.description());
|
||||
currentMacro->save(fileName);
|
||||
@@ -324,11 +279,6 @@ MacroManager::~MacroManager()
|
||||
delete d;
|
||||
}
|
||||
|
||||
const MacroSettings &MacroManager::settings() const
|
||||
{
|
||||
return d->settings;
|
||||
}
|
||||
|
||||
void MacroManager::startMacro()
|
||||
{
|
||||
d->isRecording = true;
|
||||
@@ -397,30 +347,12 @@ bool MacroManager::executeMacro(const QString &name)
|
||||
return true;
|
||||
}
|
||||
|
||||
void MacroManager::appendDirectory(const QString &directory)
|
||||
{
|
||||
d->appendDirectory(directory);
|
||||
d->settings.directories.append(directory);
|
||||
}
|
||||
|
||||
void MacroManager::removeDirectory(const QString &directory)
|
||||
{
|
||||
d->removeDirectory(directory);
|
||||
d->settings.directories.removeAll(directory);
|
||||
}
|
||||
|
||||
void MacroManager::setDefaultDirectory(const QString &directory)
|
||||
{
|
||||
d->settings.defaultDirectory = directory;
|
||||
}
|
||||
|
||||
void MacroManager::deleteMacro(const QString &name)
|
||||
{
|
||||
Macro *macro = d->macros.value(name);
|
||||
if (macro) {
|
||||
QString fileName = macro->fileName();
|
||||
d->removeMacro(name);
|
||||
d->settings.shortcuts.remove(name);
|
||||
QFile::remove(fileName);
|
||||
}
|
||||
}
|
||||
@@ -430,11 +362,6 @@ const QMap<QString,Macro*> &MacroManager::macros() const
|
||||
return d->macros;
|
||||
}
|
||||
|
||||
void MacroManager::saveSettings()
|
||||
{
|
||||
d->settings.toSettings(Core::ICore::instance()->settings());
|
||||
}
|
||||
|
||||
void MacroManager::registerMacroHandler(IMacroHandler *handler)
|
||||
{
|
||||
d->handlers.prepend(handler);
|
||||
@@ -461,3 +388,12 @@ void Macros::MacroManager::saveLastMacro()
|
||||
if (d->currentMacro->events().count())
|
||||
d->showSaveDialog();
|
||||
}
|
||||
|
||||
QString Macros::MacroManager::macrosDirectory() const
|
||||
{
|
||||
const QString &path =
|
||||
Core::ICore::instance()->userResourcePath() + QLatin1String("/macros");
|
||||
if (QFile::exists(path) || QDir().mkpath(path))
|
||||
return path;
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ class Macro;
|
||||
class IMacroHandler;
|
||||
|
||||
namespace Internal {
|
||||
class MacroSettings;
|
||||
class MacroOptionsWidget;
|
||||
}
|
||||
|
||||
@@ -62,11 +61,12 @@ public:
|
||||
|
||||
static MacroManager *instance();
|
||||
|
||||
const Internal::MacroSettings &settings() const;
|
||||
const QMap<QString, Macro *> ¯os() const;
|
||||
|
||||
void registerMacroHandler(IMacroHandler *handler);
|
||||
|
||||
QString macrosDirectory() const;
|
||||
|
||||
public slots:
|
||||
void startMacro();
|
||||
void endMacro();
|
||||
@@ -79,10 +79,6 @@ protected:
|
||||
|
||||
void deleteMacro(const QString &name);
|
||||
void changeMacro(const QString &name, const QString &description);
|
||||
void appendDirectory(const QString &directory);
|
||||
void removeDirectory(const QString &directory);
|
||||
void setDefaultDirectory(const QString &directory);
|
||||
void saveSettings();
|
||||
|
||||
private:
|
||||
static MacroManager *m_instance;
|
||||
|
||||
@@ -85,7 +85,6 @@ QIcon MacroOptionsPage::categoryIcon() const
|
||||
QWidget *MacroOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
m_widget = new MacroOptionsWidget(parent);
|
||||
m_widget->setSettings(MacroManager::instance()->settings());
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@
|
||||
|
||||
#include "macrooptionswidget.h"
|
||||
#include "ui_macrooptionswidget.h"
|
||||
#include "macrosettings.h"
|
||||
#include "macrosconstants.h"
|
||||
#include "macromanager.h"
|
||||
#include "macro.h"
|
||||
#include "macrosconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
@@ -58,13 +58,8 @@
|
||||
#include <QtGui/QLineEdit>
|
||||
|
||||
namespace {
|
||||
int DIRECTORY = 1;
|
||||
int MACRO = 2;
|
||||
|
||||
int DEFAULT_ROLE = Qt::UserRole;
|
||||
int NAME_ROLE = Qt::UserRole;
|
||||
int WRITE_ROLE = Qt::UserRole+1;
|
||||
int ID_ROLE = Qt::UserRole+2;
|
||||
}
|
||||
|
||||
using namespace Macros;
|
||||
@@ -73,53 +68,42 @@ using namespace Macros::Internal;
|
||||
|
||||
MacroOptionsWidget::MacroOptionsWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::MacroOptionsWidget),
|
||||
changingCurrent(false)
|
||||
m_ui(new Ui::MacroOptionsWidget),
|
||||
m_changingCurrent(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
m_ui->removeButton->setIcon(QIcon(Core::Constants::ICON_MINUS));
|
||||
|
||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
||||
connect(m_ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
||||
this, SLOT(changeCurrentItem(QTreeWidgetItem*)));
|
||||
connect(ui->removeButton, SIGNAL(clicked()),
|
||||
connect(m_ui->removeButton, SIGNAL(clicked()),
|
||||
this, SLOT(remove()));
|
||||
connect(ui->defaultButton, SIGNAL(clicked()),
|
||||
this, SLOT(setDefault()));
|
||||
connect(ui->addButton, SIGNAL(clicked()),
|
||||
this, SLOT(addDirectoy()));
|
||||
connect(ui->description, SIGNAL(textChanged(QString)),
|
||||
connect(m_ui->description, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(changeDescription(QString)));
|
||||
|
||||
ui->treeWidget->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
m_ui->treeWidget->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
MacroOptionsWidget::~MacroOptionsWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::setSettings(const MacroSettings &s)
|
||||
void MacroOptionsWidget::initialize()
|
||||
{
|
||||
m_macroToRemove.clear();
|
||||
m_macroToChange.clear();
|
||||
m_directories.clear();
|
||||
ui->treeWidget->clear();
|
||||
m_ui->treeWidget->clear();
|
||||
|
||||
// Create the treeview
|
||||
foreach (const QString &dir, s.directories)
|
||||
appendDirectory(dir, s.defaultDirectory==dir);
|
||||
m_directories = s.directories;
|
||||
createTable();
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::appendDirectory(const QString &directory, bool isDefault)
|
||||
void MacroOptionsWidget::createTable()
|
||||
{
|
||||
QDir dir(directory);
|
||||
QTreeWidgetItem *dirItem = new QTreeWidgetItem(ui->treeWidget, DIRECTORY);
|
||||
dirItem->setText(0, dir.absolutePath());
|
||||
dirItem->setData(0, DEFAULT_ROLE, isDefault);
|
||||
dirItem->setFirstColumnSpanned(true);
|
||||
if (isDefault)
|
||||
dirItem->setIcon(0, QPixmap(":/extensionsystem/images/ok.png"));
|
||||
|
||||
QDir dir(MacroManager::instance()->macrosDirectory());
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::ActionManager *am = core->actionManager();
|
||||
|
||||
@@ -128,7 +112,7 @@ void MacroOptionsWidget::appendDirectory(const QString &directory, bool isDefaul
|
||||
it.next();
|
||||
QFileInfo fileInfo(it.value()->fileName());
|
||||
if (fileInfo.absoluteDir() == dir.absolutePath()) {
|
||||
QTreeWidgetItem *macroItem = new QTreeWidgetItem(dirItem, MACRO);
|
||||
QTreeWidgetItem *macroItem = new QTreeWidgetItem(m_ui->treeWidget);
|
||||
macroItem->setText(0, it.value()->displayName());
|
||||
macroItem->setText(1, it.value()->description());
|
||||
macroItem->setData(0, NAME_ROLE, it.value()->displayName());
|
||||
@@ -141,122 +125,58 @@ void MacroOptionsWidget::appendDirectory(const QString &directory, bool isDefaul
|
||||
}
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::addDirectoy()
|
||||
{
|
||||
QString directory = ui->directoryPathChooser->path();
|
||||
appendDirectory(directory, ui->treeWidget->children().count()==0);
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::changeCurrentItem(QTreeWidgetItem *current)
|
||||
{
|
||||
changingCurrent = true;
|
||||
m_changingCurrent = true;
|
||||
if (!current) {
|
||||
ui->removeButton->setEnabled(false);
|
||||
ui->defaultButton->setEnabled(false);
|
||||
ui->description->clear();
|
||||
ui->macroGroup->setEnabled(false);
|
||||
}
|
||||
else if (current->type() == DIRECTORY) {
|
||||
bool isDefault = current->data(0, DEFAULT_ROLE).toBool();
|
||||
ui->removeButton->setEnabled(!isDefault);
|
||||
ui->defaultButton->setEnabled(!isDefault);
|
||||
ui->description->clear();
|
||||
ui->macroGroup->setEnabled(false);
|
||||
m_ui->removeButton->setEnabled(false);
|
||||
m_ui->description->clear();
|
||||
m_ui->macroGroup->setEnabled(false);
|
||||
} else {
|
||||
ui->removeButton->setEnabled(true);
|
||||
ui->defaultButton->setEnabled(false);
|
||||
ui->description->setText(current->text(1));
|
||||
ui->description->setEnabled(current->data(0, WRITE_ROLE).toBool());
|
||||
ui->macroGroup->setEnabled(true);
|
||||
m_ui->removeButton->setEnabled(true);
|
||||
m_ui->description->setText(current->text(1));
|
||||
m_ui->description->setEnabled(current->data(0, WRITE_ROLE).toBool());
|
||||
m_ui->macroGroup->setEnabled(true);
|
||||
}
|
||||
changingCurrent = false;
|
||||
m_changingCurrent = false;
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::remove()
|
||||
{
|
||||
QTreeWidgetItem *current = ui->treeWidget->currentItem();
|
||||
if (current->type() == MACRO)
|
||||
m_macroToRemove.append(current->text(0));
|
||||
QTreeWidgetItem *current = m_ui->treeWidget->currentItem();
|
||||
m_macroToRemove.append(current->data(0, NAME_ROLE).toString());
|
||||
delete current;
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::setDefault()
|
||||
{
|
||||
QTreeWidgetItem *current = ui->treeWidget->currentItem();
|
||||
if (!current || current->type() != DIRECTORY)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
|
||||
QTreeWidgetItem *item = ui->treeWidget->topLevelItem(i);
|
||||
if (item->data(0, DEFAULT_ROLE).toBool()) {
|
||||
item->setIcon(0, QPixmap());
|
||||
item->setData(0, DEFAULT_ROLE, false);
|
||||
}
|
||||
}
|
||||
|
||||
current->setData(0, DEFAULT_ROLE, true);
|
||||
current->setIcon(0, QPixmap(":/extensionsystem/images/ok.png"));
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::apply()
|
||||
{
|
||||
// Remove macro
|
||||
foreach (const QString &name, m_macroToRemove)
|
||||
foreach (const QString &name, m_macroToRemove) {
|
||||
MacroManager::instance()->deleteMacro(name);
|
||||
m_macroToChange.remove(name);
|
||||
}
|
||||
|
||||
// Change macro
|
||||
QMapIterator<QString, ChangeSet> it(m_macroToChange);
|
||||
QMapIterator<QString, QString> it(m_macroToChange);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
MacroManager::instance()->changeMacro(it.key(), it.value().description);
|
||||
MacroManager::instance()->changeMacro(it.key(), it.value());
|
||||
}
|
||||
|
||||
// Get list of dir to append or remove
|
||||
QStringList dirToAppend;
|
||||
QStringList dirToRemove = m_directories;
|
||||
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
|
||||
QTreeWidgetItem *item = ui->treeWidget->topLevelItem(i);
|
||||
if (!m_directories.contains(item->text(0)))
|
||||
dirToAppend.append(item->text(0));
|
||||
dirToRemove.removeAll(item->text(0));
|
||||
if (item->data(0, DEFAULT_ROLE).toBool())
|
||||
MacroManager::instance()->setDefaultDirectory(item->text(0));
|
||||
}
|
||||
|
||||
// Append/remove directory
|
||||
foreach (const QString &dir, dirToAppend)
|
||||
MacroManager::instance()->appendDirectory(dir);
|
||||
foreach (const QString &dir, dirToRemove)
|
||||
MacroManager::instance()->removeDirectory(dir);
|
||||
|
||||
MacroManager::instance()->saveSettings();
|
||||
|
||||
// Reinitialize the page
|
||||
setSettings(MacroManager::instance()->settings());
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::changeData(QTreeWidgetItem *current, int column, QVariant value)
|
||||
{
|
||||
QString macroName = current->data(0, NAME_ROLE).toString();
|
||||
if (!m_macroToChange.contains(macroName)) {
|
||||
m_macroToChange[macroName].description = current->text(1);
|
||||
m_macroToChange[macroName].shortcut = (current->data(0, ID_ROLE).toInt() >= 0);
|
||||
}
|
||||
|
||||
// Change the description
|
||||
if (column == 1) {
|
||||
m_macroToChange[macroName].description = value.toString();
|
||||
current->setText(1, value.toString());
|
||||
QFont font = current->font(1);
|
||||
font.setItalic(true);
|
||||
current->setFont(1, font);
|
||||
}
|
||||
initialize();
|
||||
}
|
||||
|
||||
void MacroOptionsWidget::changeDescription(const QString &description)
|
||||
{
|
||||
QTreeWidgetItem *current = ui->treeWidget->currentItem();
|
||||
if (changingCurrent || !current || current->type() == DIRECTORY)
|
||||
QTreeWidgetItem *current = m_ui->treeWidget->currentItem();
|
||||
if (m_changingCurrent || !current)
|
||||
return;
|
||||
changeData(current, 1, description);
|
||||
|
||||
QString macroName = current->data(0, NAME_ROLE).toString();
|
||||
m_macroToChange[macroName] = description;
|
||||
current->setText(1, description);
|
||||
QFont font = current->font(1);
|
||||
font.setItalic(true);
|
||||
current->setFont(1, font);
|
||||
}
|
||||
|
||||
@@ -59,34 +59,26 @@ public:
|
||||
explicit MacroOptionsWidget(QWidget *parent = 0);
|
||||
~MacroOptionsWidget();
|
||||
|
||||
void setSettings(const MacroSettings &s);
|
||||
void initialize();
|
||||
|
||||
void apply();
|
||||
|
||||
private slots:
|
||||
void addDirectoy();
|
||||
void remove();
|
||||
void setDefault();
|
||||
void changeCurrentItem(QTreeWidgetItem *current);
|
||||
|
||||
private:
|
||||
void appendDirectory(const QString &directory, bool isDefault = false);
|
||||
void changeData(QTreeWidgetItem *current, int column, QVariant value);
|
||||
void createTable();
|
||||
|
||||
private slots:
|
||||
void changeDescription(const QString &description);
|
||||
|
||||
private:
|
||||
Ui::MacroOptionsWidget *ui;
|
||||
Ui::MacroOptionsWidget *m_ui;
|
||||
QStringList m_macroToRemove;
|
||||
QStringList m_directories;
|
||||
bool changingCurrent;
|
||||
bool m_changingCurrent;
|
||||
|
||||
struct ChangeSet {
|
||||
QString description;
|
||||
bool shortcut;
|
||||
};
|
||||
QMap<QString, ChangeSet> m_macroToChange;
|
||||
QMap<QString, QString> m_macroToChange;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -20,37 +20,7 @@
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Directory:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Utils::PathChooser" name="directoryPathChooser" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<property name="textElideMode">
|
||||
<enum>Qt::ElideLeft</enum>
|
||||
@@ -87,33 +57,35 @@
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="defaultButton">
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="removeButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default Directory</string>
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>213</width>
|
||||
<height>20</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -141,14 +113,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -9,7 +9,6 @@ include(macros_dependencies.pri)
|
||||
HEADERS += macrosplugin.h \
|
||||
macros_global.h \
|
||||
macrosconstants.h \
|
||||
macrosettings.h \
|
||||
macro.h \
|
||||
macroevent.h \
|
||||
macromanager.h \
|
||||
@@ -24,7 +23,6 @@ HEADERS += macrosplugin.h \
|
||||
imacrohandler.h
|
||||
|
||||
SOURCES += macrosplugin.cpp \
|
||||
macrosettings.cpp \
|
||||
macro.cpp \
|
||||
macroevent.cpp \
|
||||
macromanager.cpp \
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2010 Nicolas Arnaud-Cormos.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** No Commercial Usage
|
||||
**
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "macrosettings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
using namespace Macros::Internal;
|
||||
|
||||
static const char GROUP[] = "Macro";
|
||||
static const char DEFAULT_DIRECTORY[] = "DefaultDirectory";
|
||||
static const char DIRECTORIES[] = "Directories";
|
||||
static const char SHORTCUTS[] = "Shortcuts";
|
||||
|
||||
|
||||
MacroSettings::MacroSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void MacroSettings::toSettings(QSettings *s) const
|
||||
{
|
||||
s->beginGroup(QLatin1String(GROUP));
|
||||
s->setValue(QLatin1String(DEFAULT_DIRECTORY), defaultDirectory);
|
||||
s->setValue(QLatin1String(DIRECTORIES), directories);
|
||||
s->setValue(QLatin1String(SHORTCUTS), shortcuts);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void MacroSettings::fromSettings(QSettings *s)
|
||||
{
|
||||
s->beginGroup(QLatin1String(GROUP));
|
||||
defaultDirectory = s->value(QLatin1String(DEFAULT_DIRECTORY), QString("")).toString();
|
||||
directories = s->value(QLatin1String(DIRECTORIES)).toStringList();
|
||||
shortcuts = s->value(QLatin1String(SHORTCUTS)).toMap();
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
bool MacroSettings::equals(const MacroSettings &ms) const
|
||||
{
|
||||
return defaultDirectory == ms.defaultDirectory &&
|
||||
shortcuts == ms.shortcuts &&
|
||||
directories == ms.directories;
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2010 Nicolas Arnaud-Cormos.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** No Commercial Usage
|
||||
**
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef MACROSPLUGIN_MACROSETTINGS_H
|
||||
#define MACROSPLUGIN_MACROSETTINGS_H
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
|
||||
class MacroSettings
|
||||
{
|
||||
public:
|
||||
MacroSettings();
|
||||
|
||||
void toSettings(QSettings *s) const;
|
||||
void fromSettings(QSettings *s);
|
||||
|
||||
bool equals(const MacroSettings &ms) const;
|
||||
|
||||
QString defaultDirectory;
|
||||
QStringList directories;
|
||||
QMap<QString, QVariant> shortcuts;
|
||||
};
|
||||
|
||||
inline bool operator==(const MacroSettings &m1, const MacroSettings &m2) { return m1.equals(m2); }
|
||||
inline bool operator!=(const MacroSettings &m1, const MacroSettings &m2) { return !m1.equals(m2); }
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Macros
|
||||
|
||||
#endif // MACROSPLUGIN_MACROSETTINGS_H
|
||||
Reference in New Issue
Block a user