aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Semke <alexander.semke@web.de>2016-11-05 12:29:01 (GMT)
committerAlexander Semke <alexander.semke@web.de>2016-11-05 12:29:01 (GMT)
commitfc63cd2c6d1cb8ec13a5179326f56c84a535f126 (patch)
tree085dd9b94deb07ec7ec0ea53006ae9166bf118d6
parent1c129e725c99aad7fbbf8cffe96412a6000faeda (diff)
Don't try to save/load variables if no file name was provided.
-rw-r--r--src/panelplugins/variablemgr/variablemanagerwidget.cpp21
-rw-r--r--src/panelplugins/variablemgr/variablemanagerwidget.h5
2 files changed, 9 insertions, 17 deletions
diff --git a/src/panelplugins/variablemgr/variablemanagerwidget.cpp b/src/panelplugins/variablemgr/variablemanagerwidget.cpp
index 4f903d2..fb59bf2 100644
--- a/src/panelplugins/variablemgr/variablemanagerwidget.cpp
+++ b/src/panelplugins/variablemgr/variablemanagerwidget.cpp
@@ -24,16 +24,13 @@
#include <QIcon>
#include <QTreeView>
#include <QToolButton>
-#include <QAbstractItemModel>
#include <QDialog>
#include <QPushButton>
-#include <KLocalizedString>
#include <QDebug>
#include <KIconLoader>
#include <QFileDialog>
#include <KMessageBox>
-#include <KConfigGroup>
#include "session.h"
#include "extension.h"
@@ -41,10 +38,8 @@
#include "ui_newvardlg.h"
-VariableManagerWidget::VariableManagerWidget(Cantor::Session* session, QWidget* parent) : QWidget(parent)
+VariableManagerWidget::VariableManagerWidget(Cantor::Session* session, QWidget* parent) : QWidget(parent), m_session(0)
{
- m_session=0;
-
QVBoxLayout* layout=new QVBoxLayout(this);
m_table=new QTreeView(this);
@@ -55,29 +50,28 @@ VariableManagerWidget::VariableManagerWidget(Cantor::Session* session, QWidget*
QHBoxLayout* btnLayout=new QHBoxLayout(this);
int size=KIconLoader::global()->currentSize(KIconLoader::MainToolbar);
- m_newBtn=new QToolButton(this);
+ QToolButton* m_newBtn=new QToolButton(this);
m_newBtn->setIcon(QIcon::fromTheme(QLatin1String("document-new")));
m_newBtn->setToolTip(i18n("Add new variable"));
m_newBtn->setIconSize(QSize(size, size));
connect(m_newBtn, &QToolButton::clicked, this, &VariableManagerWidget::newVariable);
btnLayout->addWidget(m_newBtn);
-
- m_loadBtn=new QToolButton(this);
+ QToolButton* m_loadBtn=new QToolButton(this);
m_loadBtn->setIcon(QIcon::fromTheme(QLatin1String("document-open")));
m_loadBtn->setToolTip(i18n("Load Variables"));
m_loadBtn->setIconSize(QSize(size, size));
connect(m_loadBtn, &QToolButton::clicked, this, &VariableManagerWidget::load);
btnLayout->addWidget(m_loadBtn);
- m_saveBtn=new QToolButton(this);
+ QToolButton* m_saveBtn=new QToolButton(this);
m_saveBtn->setIcon(QIcon::fromTheme(QLatin1String("document-save")));
m_saveBtn->setToolTip(i18n("Store Variables"));
m_saveBtn->setIconSize(QSize(size, size));
connect(m_saveBtn, &QToolButton::clicked, this, &VariableManagerWidget::save);
btnLayout->addWidget(m_saveBtn);
- m_clearBtn=new QToolButton(this);
+ QToolButton* m_clearBtn=new QToolButton(this);
m_clearBtn->setIcon(QIcon::fromTheme(QLatin1String("edit-clear")));
m_clearBtn->setToolTip(i18n("Clear Variables"));
m_clearBtn->setIconSize(QSize(size, size));
@@ -147,6 +141,8 @@ void VariableManagerWidget::clearVariables()
void VariableManagerWidget::save()
{
const QString file=QFileDialog::getSaveFileName(this, i18n("Save"), QString(), QString());
+ if (file.trimmed().isEmpty())
+ return;
Cantor::VariableManagementExtension* ext=
dynamic_cast<Cantor::VariableManagementExtension*>(m_session->backend()->extension(QLatin1String("VariableManagementExtension")));
@@ -158,6 +154,8 @@ void VariableManagerWidget::save()
void VariableManagerWidget::load()
{
const QString file=QFileDialog::getOpenFileName(this, i18n("Load file"), QString(), QString());
+ if (file.trimmed().isEmpty())
+ return;
Cantor::VariableManagementExtension* ext=
dynamic_cast<Cantor::VariableManagementExtension*>(m_session->backend()->extension(QLatin1String("VariableManagementExtension")));
@@ -197,5 +195,4 @@ void VariableManagerWidget::newVariable()
}
delete dlg;
-
}
diff --git a/src/panelplugins/variablemgr/variablemanagerwidget.h b/src/panelplugins/variablemgr/variablemanagerwidget.h
index 413b8e0..34fe83c 100644
--- a/src/panelplugins/variablemgr/variablemanagerwidget.h
+++ b/src/panelplugins/variablemgr/variablemanagerwidget.h
@@ -28,7 +28,6 @@ class Session;
}
class QTreeView;
-class QToolButton;
class QAbstractItemModel;
class VariableManagerWidget : public QWidget
@@ -54,10 +53,6 @@ class VariableManagerWidget : public QWidget
Cantor::Session* m_session;
QAbstractItemModel* m_model;
QTreeView* m_table;
- QToolButton* m_newBtn;
- QToolButton* m_loadBtn;
- QToolButton* m_saveBtn;
- QToolButton* m_clearBtn;
};
#endif /* _VARIABLEMANAGERWIDGET_H */