* work save
This commit is contained in:
parent
021873a9d6
commit
39bdd66dbb
|
@ -283,14 +283,14 @@ bool ColorManager::exists(const QString name)
|
||||||
return mSchemes.contains(name);
|
return mSchemes.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PColorScheme ColorManager::copy(const QString &sourceName)
|
QString ColorManager::copy(const QString &sourceName)
|
||||||
{
|
{
|
||||||
if (!mSchemes.contains(sourceName))
|
if (!mSchemes.contains(sourceName))
|
||||||
return PColorScheme();
|
return QString();
|
||||||
PColorScheme sourceScheme = mSchemes[sourceName];
|
PColorScheme sourceScheme = mSchemes[sourceName];
|
||||||
QString newName = sourceName+" Copy";
|
QString newName = sourceName+" Copy";
|
||||||
if (mSchemes.contains(newName))
|
if (mSchemes.contains(newName))
|
||||||
return PColorScheme();
|
return QString();
|
||||||
// save source with the new name
|
// save source with the new name
|
||||||
QString newFilepath = generateFullPathname(newName,false,false);
|
QString newFilepath = generateFullPathname(newName,false,false);
|
||||||
sourceScheme->save(newFilepath);
|
sourceScheme->save(newFilepath);
|
||||||
|
@ -299,7 +299,7 @@ PColorScheme ColorManager::copy(const QString &sourceName)
|
||||||
newScheme->setBundled(false);
|
newScheme->setBundled(false);
|
||||||
newScheme->setCustomed(false);
|
newScheme->setCustomed(false);
|
||||||
mSchemes[newName]=newScheme;
|
mSchemes[newName]=newScheme;
|
||||||
return newScheme;
|
return newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ColorManager::generateFilename(const QString &name, bool isCustomed)
|
QString ColorManager::generateFilename(const QString &name, bool isCustomed)
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
QStringList getDefines();
|
QStringList getDefines();
|
||||||
|
|
||||||
bool exists(const QString name);
|
bool exists(const QString name);
|
||||||
PColorScheme copy(const QString& source);
|
QString copy(const QString& source);
|
||||||
bool rename(const QString& oldName, const QString& newName);
|
bool rename(const QString& oldName, const QString& newName);
|
||||||
PColorScheme remove(const QString& name);
|
PColorScheme remove(const QString& name);
|
||||||
PColorScheme get(const QString& name);
|
PColorScheme get(const QString& name);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||||
SettingsWidget(name,group,parent),
|
SettingsWidget(name,group,parent),
|
||||||
|
@ -292,14 +293,18 @@ void EditorColorSchemeWidget::doSave()
|
||||||
|
|
||||||
void EditorColorSchemeWidget::on_actionCopy_Scheme_triggered()
|
void EditorColorSchemeWidget::on_actionCopy_Scheme_triggered()
|
||||||
{
|
{
|
||||||
|
QString newName = pColorManager->copy(ui->cbScheme->currentText());
|
||||||
|
if (newName.isEmpty())
|
||||||
|
return;
|
||||||
|
ui->cbScheme->addItem(newName);
|
||||||
|
ui->cbScheme->setCurrentText(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
|
void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
|
||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
PColorScheme scheme = pColorManager->get(ui->cbScheme->currentText());
|
PColorScheme scheme = getCurrentScheme();
|
||||||
if (scheme) {
|
if (scheme) {
|
||||||
if (scheme->customed()) {
|
if (scheme->customed()) {
|
||||||
menu.addAction(ui->actionReset_Scheme);
|
menu.addAction(ui->actionReset_Scheme);
|
||||||
|
@ -316,7 +321,5 @@ void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
|
||||||
QPoint p;
|
QPoint p;
|
||||||
p.setX(0);
|
p.setX(0);
|
||||||
p.setY(ui->btnSchemeMenu->height()+2);
|
p.setY(ui->btnSchemeMenu->height()+2);
|
||||||
QAction* action = menu.exec(ui->btnSchemeMenu->mapToGlobal(p));
|
menu.exec(ui->btnSchemeMenu->mapToGlobal(p));
|
||||||
if (action)
|
|
||||||
action->trigger();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue