[repo.or.cz] nomnom.git branch next updated: v0.2.0-6-gd89b9cb
Brought to you by:
legatvs
|
From: <nom...@li...> - 2011-10-24 18:17:04
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project nomnom.git.
The branch, next has been updated
via d89b9cbf3e03965b17801196c7e81b5a8ee4b25d (commit)
from 1f2afdc5c32bc92fd0e6e4d01f174355c8ab988f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/nomnom.git/commit/d89b9cbf3e03965b17801196c7e81b5a8ee4b25d
commit d89b9cbf3e03965b17801196c7e81b5a8ee4b25d
Author: Toni Gundogdu <le...@gm...>
Date: Sun Oct 23 03:18:11 2011 +0300
Use NErrorWhileDialog instead
diff --git a/src/DownloadDiag.cpp b/src/DownloadDiag.cpp
index 2c948c4..3cd4436 100644
--- a/src/DownloadDiag.cpp
+++ b/src/DownloadDiag.cpp
@@ -27,7 +27,7 @@
#include "DownloadDiag.h"
DownloadDialog::DownloadDialog(QWidget *parent/*=NULL*/)
- : QProgressDialog(parent), _canceled(false)
+ : QProgressDialog(parent), _canceled(false), _errcode(-1)
{
_proc.setProcessChannelMode(QProcess::MergedChannels);
@@ -61,6 +61,11 @@ QString DownloadDialog::errmsg() const
return _errmsg;
}
+int DownloadDialog::errcode() const
+{
+ return _errcode;
+}
+
void DownloadDialog::start(QStringList& args)
{
#ifdef ENABLE_VERBOSE
@@ -92,11 +97,8 @@ void DownloadDialog::onCurlError(QProcess::ProcessError n)
if (!_canceled)
{
hide();
- _errmsg = tr("Error while running command:<p>%1</p>"
- "Qt error message follows (code #%2):<p>%3</p>")
- .arg(_args.join(" "))
- .arg(n)
- .arg(_proc.errorString());
+ _errmsg = _proc.errorString();
+ _errcode = n;
emit error();
}
cancel();
@@ -146,10 +148,8 @@ void DownloadDialog::onCurlReadyRead()
if (rx_err.indexIn(ln) != -1)
{
- _errmsg = tr("Error while running command:<p>%1</p>"
- "curl error message follows:<p>%3</p>")
- .arg(_args.join(" "))
- .arg(rx_err.cap(1));
+ _errmsg = rx_err.cap(1);
+ _errcode = -1;
break;
}
update_label(this, ln);
diff --git a/src/DownloadDiag.h b/src/DownloadDiag.h
index c768aef..11eea6e 100644
--- a/src/DownloadDiag.h
+++ b/src/DownloadDiag.h
@@ -33,6 +33,7 @@ public:
void start(QStringList&);
QString errmsg() const;
bool canceled() const;
+ int errcode() const;
bool failed() const;
signals:
void finished();
@@ -48,6 +49,7 @@ private:
QString _errmsg;
QProcess _proc;
bool _canceled;
+ int _errcode;
};
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index e5b2f90..2ab4378 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ noinst_HEADERS=
nodist_nomnom_SOURCES= moc_nfeedprogressdialog.cpp + moc_nerrorwhiledialog.cpp moc_nsettingsdialog.cpp moc_ndetectdialog.cpp moc_ntripwireedit.cpp @@ -40,6 +41,9 @@ moc_ProcProgDiag.cpp:
moc_Media.cpp:
$(MOC) -o $@ $(top_srcdir)/src/Media.h
+moc_nerrorwhiledialog.cpp:
+ $(MOC) -o $@ $(top_srcdir)/src/errorwhile/nerrorwhiledialog.h
+
moc_nfeedprogressdialog.cpp:
$(MOC) -o $@ $(top_srcdir)/src/feed/nfeedprogressdialog.h
@@ -75,6 +79,7 @@ src= settings/nsettingsmutator.cpp settings/nsettingsdialog.cpp settings/nsettings.cpp + errorwhile/nerrorwhiledialog.cpp widgets/ntripwireedit.cpp detect/ndetectdialog.cpp detect/ndetect.cpp @@ -95,6 +100,8 @@ src= Media.cpp
hdr=+ NErrorWhileDialog + errorwhile/nerrorwhiledialog.h NFeedProgressDialog NFeedDialog NFeed diff --git a/src/NErrorWhileDialog b/src/NErrorWhileDialog
new file mode 100644
index 0000000..c6da8ae
--- /dev/null
+++ b/src/NErrorWhileDialog
@@ -0,0 +1 @@
+#include "errorwhile/nerrorwhiledialog.h"
diff --git a/src/ProcProgDiag.cpp b/src/ProcProgDiag.cpp
index 21ab9d0..5943460 100644
--- a/src/ProcProgDiag.cpp
+++ b/src/ProcProgDiag.cpp
@@ -27,8 +27,7 @@
static QHash<QString,QRegExp> rx_labels;
ProcessProgressDialog::ProcessProgressDialog(QWidget *parent/*=NULL*/)
- : QProgressDialog(parent),
- _canceled(false)
+ : QProgressDialog(parent), _canceled(false), _errcode(-1)
{
_proc.setProcessChannelMode(QProcess::MergedChannels);
@@ -68,6 +67,11 @@ QString ProcessProgressDialog::errmsg() const
return _errmsg;
}
+int ProcessProgressDialog::errcode() const
+{
+ return _errcode;
+}
+
void ProcessProgressDialog::start(QStringList& args)
{
#ifdef ENABLE_VERBOSE
@@ -102,11 +106,8 @@ void ProcessProgressDialog::onProcError(QProcess::ProcessError n)
if (!_canceled)
{
hide();
- _errmsg = tr("Error while running command:<p>%1</p>"
- "Qt error message follows (code #%2):<p>%3</p>")
- .arg(_args.join(" "))
- .arg(n)
- .arg(_proc.errorString());
+ _errcode = static_cast<int>(n);
+ _errmsg = _proc.errorString();
emit error();
}
cancel();
@@ -152,11 +153,8 @@ void ProcessProgressDialog::onProcFinished(int ec, QProcess::ExitStatus es)
_errmsg = _buffer;
if (rx_error.indexIn(_buffer) != -1)
{
- _errmsg = tr("Error while running command:<p>%1</p>"
- "quvi error message follows (code #%2):<p>%3</p>")
- .arg(_args.join(" "))
- .arg(ec)
- .arg(rx_error.cap(1).simplified());
+ _errmsg = rx_error.cap(1).simplified();
+ _errcode = static_cast<int>(ec);
}
#ifdef ENABLE_VERBOSE
qDebug() << __PRETTY_FUNCTION__ << __LINE__ << "errmsg=" << _errmsg;
diff --git a/src/ProcProgDiag.h b/src/ProcProgDiag.h
index 0cd1717..bb8f456 100644
--- a/src/ProcProgDiag.h
+++ b/src/ProcProgDiag.h
@@ -32,6 +32,7 @@ public:
void start(QStringList&);
QString errmsg() const;
bool canceled() const;
+ int errcode() const;
bool failed() const;
private slots:
void onProcFinished(int, QProcess::ExitStatus);
@@ -45,9 +46,10 @@ signals:
private:
QStringList _args;
QString _buffer;
- QProcess _proc;
QString _errmsg;
+ QProcess _proc;
bool _canceled;
+ int _errcode;
};
#endif
diff --git a/src/errorwhile/nerrorwhiledialog.cpp b/src/errorwhile/nerrorwhiledialog.cpp
new file mode 100644
index 0000000..62f20c6
--- /dev/null
+++ b/src/errorwhile/nerrorwhiledialog.cpp
@@ -0,0 +1,64 @@
+/* NomNom
+ * Copyright (C) 2011 Toni Gundogdu <le...@gm...>
+ *
+ * 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 <QDialogButtonBox>
+#include <QPlainTextEdit>
+#include <QVBoxLayout>
+#include <QLabel>
+
+#include <NErrorWhileDialog>
+
+namespace nn
+{
+
+NErrorWhileDialog::NErrorWhileDialog(const QStringList& args,
+ const QString& errmsg,
+ const int errcode,
+ QWidget *parent)
+ : QDialog(parent)
+{
+ QVBoxLayout *box = new QVBoxLayout;
+
+ QLabel *l = new QLabel(tr("Error while running command:"));
+ box->addWidget(l);
+
+ QPlainTextEdit *t = new QPlainTextEdit(this);
+ t->setPlainText(args.join(" "));
+ t->setReadOnly(true);
+ box->addWidget(t);
+
+ l = new QLabel(tr("Error message follows:"));
+ box->addWidget(l);
+
+ t = new QPlainTextEdit(this);
+ t->setPlainText(tr("%1n[code #%2]").arg(errmsg).arg(errcode));
+ t->setReadOnly(true);
+ box->addWidget(t);
+
+ QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
+ connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
+ box->addWidget(bb);
+
+ setFixedSize(QSize(400,340));
+ setWindowTitle(tr("Error"));
+ setLayout(box);
+ show();
+}
+
+} // namespace nn
+
+/* vim: set ts=2 sw=2 tw=72 expandtab: */
diff --git a/src/feed/nfeedprogressdialog.h b/src/errorwhile/nerrorwhiledialog.h
similarity index 59%
copy from src/feed/nfeedprogressdialog.h
copy to src/errorwhile/nerrorwhiledialog.h
index bc4658f..9308743 100644
--- a/src/feed/nfeedprogressdialog.h
+++ b/src/errorwhile/nerrorwhiledialog.h
@@ -15,40 +15,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef nfeedprogressdialog_h
-#define nfeedprogressdialog_h
+#ifndef nerrorwhiledialog_h
+#define nerrorwhiledialog_h
-#include <QProgressDialog>
-#include <QProcess>
-
-#include <NFeed>
+#include <QDialog>
class QStringList;
+class QString;
namespace nn
{
-class NFeedProgressDialog : public QProgressDialog
+class NErrorWhileDialog : public QDialog
{
Q_OBJECT
public:
- NFeedProgressDialog(QWidget *parent=NULL);
-public:
- bool results(feed::NFeedList&, QString&);
- bool open(QStringList&);
- QString errmsg() const;
- bool cancelled() const;
-private slots:
- void finished(int, QProcess::ExitStatus);
- void error(QProcess::ProcessError);
- void cleanup();
- void read();
-private:
- QStringList _args;
- QString _buffer;
- QString _errmsg;
- QProcess *_proc;
- bool _cancelled;
+ NErrorWhileDialog(const QStringList&,
+ const QString&,
+ const int,
+ QWidget *parent=NULL);
};
} // namespace nn
diff --git a/src/feed/nfeeddialog.cpp b/src/feed/nfeeddialog.cpp
index b518657..e287f58 100644
--- a/src/feed/nfeeddialog.cpp
+++ b/src/feed/nfeeddialog.cpp
@@ -24,6 +24,7 @@
#include <QToolBox>
#include <NFeedProgressDialog>
+#include <NErrorWhileDialog>
#include <NFeedDialog>
extern nn::feed::NFeedList feedItems; // main.cpp
@@ -122,11 +123,19 @@ void NFeedDialog::parse(QStringList args)
if (d->cancelled())
return;
+ NErrorWhileDialog *ewd = NULL;
+
if (r)
{
- QString msg;
- if (!d->results(feedItems, msg))
- NFeedDialog::m_info(this, msg);
+ QString errmsg;
+ if (!d->results(feedItems, errmsg))
+ {
+ ewd = new NErrorWhileDialog(args,
+ errmsg,
+ -1,
+ this);
+ ewd->exec();
+ }
else
{
_toolbox->setCurrentIndex(1);
@@ -134,7 +143,13 @@ void NFeedDialog::parse(QStringList args)
}
}
else
- m_info(this, d->errmsg());
+ {
+ ewd = new NErrorWhileDialog(args,
+ d->errmsg(),
+ d->errcode(),
+ this);
+ ewd->exec();
+ }
}
void NFeedDialog::selected(QString s)
diff --git a/src/feed/nfeedprogressdialog.cpp b/src/feed/nfeedprogressdialog.cpp
index eca7269..2abcdff 100644
--- a/src/feed/nfeedprogressdialog.cpp
+++ b/src/feed/nfeedprogressdialog.cpp
@@ -32,7 +32,7 @@ namespace nn
{
NFeedProgressDialog::NFeedProgressDialog(QWidget *parent/*=NULL*/)
- : QProgressDialog(parent), _proc(NULL), _cancelled(false)
+ : QProgressDialog(parent), _cancelled(false), _errcode(-1), _proc(NULL)
{
_proc = new QProcess;
_proc->setProcessChannelMode(QProcess::MergedChannels);
@@ -48,7 +48,7 @@ NFeedProgressDialog::NFeedProgressDialog(QWidget *parent/*=NULL*/)
setAutoClose(false);
}
-bool NFeedProgressDialog::open(QStringList& args)
+bool NFeedProgressDialog::open(QStringList args)
{
setLabelText(tr("Working..."));
@@ -118,11 +118,8 @@ void NFeedProgressDialog::error(QProcess::ProcessError n)
{
if (!_cancelled)
{
- _errmsg = tr("Error while running command:<p>%1</p>"
- "Qt error message follows (code #%2):<p>%3</p>")
- .arg(_args.first())
- .arg(n)
- .arg(_proc->errorString());
+ _errmsg = _proc->errorString();
+ _errcode = n;
}
cancel();
}
@@ -144,11 +141,8 @@ void NFeedProgressDialog::finished(int ec, QProcess::ExitStatus es)
QString m = (rx.indexIn(_buffer) != -1)
? rx.cap(1).simplified()
: _buffer;
- _errmsg = tr("Error while running command:<p>%1</p>"
- "Error message follows (code #%2):<p>%3</p>")
- .arg(_args.join(" "))
- .arg(ec)
- .arg(m);
+ _errcode = ec;
+ _errmsg = m;
}
}
cancel();
@@ -167,6 +161,11 @@ QString NFeedProgressDialog::errmsg() const
return _errmsg;
}
+int NFeedProgressDialog::errcode() const
+{
+ return _errcode;
+}
+
bool NFeedProgressDialog::cancelled() const
{
return _cancelled;
diff --git a/src/feed/nfeedprogressdialog.h b/src/feed/nfeedprogressdialog.h
index bc4658f..4a468bd 100644
--- a/src/feed/nfeedprogressdialog.h
+++ b/src/feed/nfeedprogressdialog.h
@@ -35,9 +35,10 @@ public:
NFeedProgressDialog(QWidget *parent=NULL);
public:
bool results(feed::NFeedList&, QString&);
- bool open(QStringList&);
+ bool open(QStringList);
QString errmsg() const;
bool cancelled() const;
+ int errcode() const;
private slots:
void finished(int, QProcess::ExitStatus);
void error(QProcess::ProcessError);
@@ -49,6 +50,7 @@ private:
QString _errmsg;
QProcess *_proc;
bool _cancelled;
+ int _errcode;
};
} // namespace nn
diff --git a/src/i/MainWindow.cpp b/src/i/MainWindow.cpp
index 14aafb5..c92aa2a 100644
--- a/src/i/MainWindow.cpp
+++ b/src/i/MainWindow.cpp
@@ -30,6 +30,7 @@
#include <QDebug>
#endif
+#include <NErrorWhileDialog>
#include <NSettingsMutator>
#include <NSettingsDialog>
#include <NAboutDialog>
@@ -250,7 +251,12 @@ void MainWindow::handleURL(const QString& url)
if (failed)
{
- nn::info(this, proc->errmsg());
+ nn::NErrorWhileDialog *d =
+ new nn::NErrorWhileDialog(q_args,
+ proc->errmsg(),
+ proc->errcode(),
+ this);
+ d->exec();
return;
}
@@ -293,7 +299,14 @@ void MainWindow::handleURL(const QString& url)
downloadMedia();
}
else
- nn::info(this, errmsg);
+ {
+ nn::NErrorWhileDialog *d =
+ new nn::NErrorWhileDialog(q_args,
+ errmsg,
+ proc->errcode(),
+ this);
+ d->exec();
+ }
}
// Query formats to an URL.
@@ -397,7 +410,15 @@ void MainWindow::streamMedia()
const QString cmd = args.takeFirst();
if (!QProcess::startDetached(cmd, args))
- nn::info(this, tr("Error while running command:<p>%1</p>").arg(cmd));
+ {
+ nn::NErrorWhileDialog *d =
+ new nn::NErrorWhileDialog(QStringList() << cmd << args,
+ tr("Unknown error while attempting to "
+ "start a detached process"),
+ -1,
+ this);
+ d->exec();
+ }
}
// Download media (to a file).
@@ -470,7 +491,12 @@ void MainWindow::downloadMedia()
if (download->failed())
{
- nn::info(this, download->errmsg());
+ nn::NErrorWhileDialog *d =
+ new nn::NErrorWhileDialog(args,
+ download->errmsg(),
+ download->errcode(),
+ this);
+ d->exec();
return;
}
}
@@ -507,8 +533,13 @@ void MainWindow::downloadMedia()
if (!QProcess::startDetached(cmd, args))
{
- nn::info(this,
- tr("Error while running command:<p>%1</p>").arg(cmd));
+ nn::NErrorWhileDialog *d =
+ new nn::NErrorWhileDialog(QStringList() << cmd << args,
+ tr("Unknown error while attempting to "
+ "start a detached process"),
+ -1,
+ this);
+ d->exec();
}
}
}
-----------------------------------------------------------------------
Summary of changes:
src/DownloadDiag.cpp | 20 +++---
src/DownloadDiag.h | 2 +
src/Makefile.am | 7 ++
src/NErrorWhileDialog | 1 +
src/ProcProgDiag.cpp | 22 +++----
src/ProcProgDiag.h | 4 +-
src/errorwhile/nerrorwhiledialog.cpp | 64 ++++++++++++++++++++
.../nerrorwhiledialog.h} | 23 +++----
src/feed/nfeeddialog.cpp | 23 ++++++-
src/feed/nfeedprogressdialog.cpp | 23 ++++----
src/feed/nfeedprogressdialog.h | 4 +-
src/i/MainWindow.cpp | 43 +++++++++++--
12 files changed, 177 insertions(+), 59 deletions(-)
create mode 100644 src/NErrorWhileDialog
create mode 100644 src/errorwhile/nerrorwhiledialog.cpp
copy src/{about/naboutdialog.h => errorwhile/nerrorwhiledialog.h} (75%)
repo.or.cz automatic notification. Contact project admin le...@gm...
if you want to unsubscribe, or site admin ad...@re... if you receive
no reply.
--
nomnom.git ("The graphical media download tool")
|