* work save

This commit is contained in:
royqh1979@gmail.com 2021-06-20 14:49:38 +08:00
parent 021873a9d6
commit 39bdd66dbb
3 changed files with 13 additions and 10 deletions

View File

@ -283,14 +283,14 @@ bool ColorManager::exists(const QString name)
return mSchemes.contains(name);
}
PColorScheme ColorManager::copy(const QString &sourceName)
QString ColorManager::copy(const QString &sourceName)
{
if (!mSchemes.contains(sourceName))
return PColorScheme();
return QString();
PColorScheme sourceScheme = mSchemes[sourceName];
QString newName = sourceName+" Copy";
if (mSchemes.contains(newName))
return PColorScheme();
return QString();
// save source with the new name
QString newFilepath = generateFullPathname(newName,false,false);
sourceScheme->save(newFilepath);
@ -299,7 +299,7 @@ PColorScheme ColorManager::copy(const QString &sourceName)
newScheme->setBundled(false);
newScheme->setCustomed(false);
mSchemes[newName]=newScheme;
return newScheme;
return newName;
}
QString ColorManager::generateFilename(const QString &name, bool isCustomed)

View File

@ -129,7 +129,7 @@ public:
QStringList getDefines();
bool exists(const QString name);
PColorScheme copy(const QString& source);
QString copy(const QString& source);
bool rename(const QString& oldName, const QString& newName);
PColorScheme remove(const QString& name);
PColorScheme get(const QString& name);

View File

@ -6,6 +6,7 @@
#include <QAction>
#include <QMessageBox>
#include <QDebug>
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
@ -292,14 +293,18 @@ void EditorColorSchemeWidget::doSave()
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()
{
QMenu menu;
PColorScheme scheme = pColorManager->get(ui->cbScheme->currentText());
PColorScheme scheme = getCurrentScheme();
if (scheme) {
if (scheme->customed()) {
menu.addAction(ui->actionReset_Scheme);
@ -316,7 +321,5 @@ void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
QPoint p;
p.setX(0);
p.setY(ui->btnSchemeMenu->height()+2);
QAction* action = menu.exec(ui->btnSchemeMenu->mapToGlobal(p));
if (action)
action->trigger();
menu.exec(ui->btnSchemeMenu->mapToGlobal(p));
}