1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-22 10:12:10 +02:00
falkonOfficial/src/plugins/GreaseMonkey/gm_notification.cpp

70 lines
2.1 KiB
C++
Raw Normal View History

2012-07-11 18:30:00 +02:00
/* ============================================================
* GreaseMonkey plugin for QupZilla
2014-01-11 16:11:42 +01:00
* Copyright (C) 2012-2014 David Rosca <nowrep@gmail.com>
2012-07-11 18:30:00 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "gm_notification.h"
#include "ui_gm_notification.h"
#include "gm_manager.h"
#include "gm_script.h"
#include "iconprovider.h"
#include <QFile>
GM_Notification::GM_Notification(GM_Manager* manager, const QString &tmpfileName, const QString &fileName)
: AnimatedWidget(AnimatedWidget::Down, 300, 0)
, ui(new Ui::GM_Notification)
, m_manager(manager)
, m_tmpFileName(tmpfileName)
, m_fileName(fileName)
{
2013-02-14 23:23:28 +01:00
setAutoFillBackground(true);
2012-07-11 18:30:00 +02:00
ui->setupUi(widget());
ui->close->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
connect(ui->install, SIGNAL(clicked()), this, SLOT(installScript()));
connect(ui->close, SIGNAL(clicked()), this, SLOT(hide()));
startAnimation();
}
void GM_Notification::installScript()
{
bool success = false;
GM_Script* script = 0;
QString message = tr("Cannot install script");
if (QFile::copy(m_tmpFileName, m_fileName)) {
script = new GM_Script(m_manager, m_fileName);
success = m_manager->addScript(script);
}
if (success) {
message = tr("'%1' installed successfully").arg(script->name());
}
m_manager->showNotification(message);
hide();
}
GM_Notification::~GM_Notification()
{
delete ui;
}