[repo.or.cz] nomnom.git branch next updated: v0.2.0-13-g2b92801
Brought to you by:
legatvs
|
From: <nom...@li...> - 2011-10-27 19:51:26
|
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 2b9280145afba0e226448b5711ad499d2844982d (commit)
from d7ab7b3359e5346fa56a2e268960365edeb2bf08 (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/2b9280145afba0e226448b5711ad499d2844982d
commit 2b9280145afba0e226448b5711ad499d2844982d
Author: Toni Gundogdu <le...@gm...>
Date: Thu Oct 27 22:51:33 2011 +0300
Add "Copy" button to NErrorWhileDialog
* Make copying to clipboard easy
diff --git a/src/errorwhile/nerrorwhiledialog.cpp b/src/errorwhile/nerrorwhiledialog.cpp
index 62f20c6..7a999f9 100644
--- a/src/errorwhile/nerrorwhiledialog.cpp
+++ b/src/errorwhile/nerrorwhiledialog.cpp
@@ -17,7 +17,10 @@
#include <QDialogButtonBox>
#include <QPlainTextEdit>
+#include <QApplication>
#include <QVBoxLayout>
+#include <QPushButton>
+#include <QClipboard>
#include <QLabel>
#include <NErrorWhileDialog>
@@ -25,6 +28,35 @@
namespace nn
{
+typedef enum
+{
+ ErrorWhileRunning = 0x00,
+ ErrorMessageFollows,
+ ErrorCode,
+} LabelType;
+
+static QString label(const LabelType t, const QString& arg1="")
+{
+ static const char *str[] =
+ {
+ QT_TRANSLATE_NOOP("nn::NErrorWhileDialog",
+ "Error while running command:"),
+
+ QT_TRANSLATE_NOOP("nn::NErrorWhileDialog",
+ "Error message follows:"),
+
+ QT_TRANSLATE_NOOP("nn::NErrorWhileDialog",
+ "[code #%1]")
+ };
+
+ QString s = NErrorWhileDialog::tr(str[t]);
+
+ if (!arg1.isEmpty())
+ s = NErrorWhileDialog::tr(str[t]).arg(arg1);
+
+ return s;
+}
+
NErrorWhileDialog::NErrorWhileDialog(const QStringList& args,
const QString& errmsg,
const int errcode,
@@ -33,30 +65,66 @@ NErrorWhileDialog::NErrorWhileDialog(const QStringList& args,
{
QVBoxLayout *box = new QVBoxLayout;
- QLabel *l = new QLabel(tr("Error while running command:"));
+// Label
+
+ QLabel *l = new QLabel(label(ErrorWhileRunning));
box->addWidget(l);
+// Command args
+
QPlainTextEdit *t = new QPlainTextEdit(this);
t->setPlainText(args.join(" "));
t->setReadOnly(true);
box->addWidget(t);
- l = new QLabel(tr("Error message follows:"));
+// Label
+
+ l = new QLabel(label(ErrorMessageFollows));
box->addWidget(l);
+// Error message
+
t = new QPlainTextEdit(this);
- t->setPlainText(tr("%1n[code #%2]").arg(errmsg).arg(errcode));
+ const QString s = label(ErrorCode, QString("%1").arg(errcode));
+ t->setPlainText(QString("%1n%2").arg(errmsg).arg(s));
t->setReadOnly(true);
box->addWidget(t);
+// Button box
+
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
+ QPushButton *b = new QPushButton(tr("Co&py"));
+ b->setToolTip(tr("Copy to clipboard"));
+
+ bb->addButton(b, QDialogButtonBox::ActionRole);
+
connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(b, SIGNAL(clicked()), this, SLOT(copy()));
box->addWidget(bb);
+// Window
+
setFixedSize(QSize(400,340));
setWindowTitle(tr("Error"));
setLayout(box);
show();
+
+// Save
+
+ _errcode = errcode;
+ _errmsg = errmsg;
+ _args = args;
+}
+
+void NErrorWhileDialog::copy()
+{
+ QClipboard *c = QApplication::clipboard();
+ c->setText(QString("%1n%2nn%3n%4n%5n")
+ .arg(label(ErrorWhileRunning))
+ .arg(_args.join(" "))
+ .arg(label(ErrorMessageFollows))
+ .arg(_errmsg)
+ .arg(label(ErrorCode, QString("%1").arg(_errcode))));
}
} // namespace nn
diff --git a/src/errorwhile/nerrorwhiledialog.h b/src/errorwhile/nerrorwhiledialog.h
index 9308743..40e9386 100644
--- a/src/errorwhile/nerrorwhiledialog.h
+++ b/src/errorwhile/nerrorwhiledialog.h
@@ -18,11 +18,9 @@
#ifndef nerrorwhiledialog_h
#define nerrorwhiledialog_h
+#include <QStringList>
#include <QDialog>
-class QStringList;
-class QString;
-
namespace nn
{
@@ -34,6 +32,12 @@ public:
const QString&,
const int,
QWidget *parent=NULL);
+private slots:
+ void copy();
+private:
+ QStringList _args;
+ QString _errmsg;
+ int _errcode;
};
} // namespace nn
-----------------------------------------------------------------------
Summary of changes:
src/errorwhile/nerrorwhiledialog.cpp | 74 ++++++++++++++++++++++++++++++++-
src/errorwhile/nerrorwhiledialog.h | 10 +++-
2 files changed, 78 insertions(+), 6 deletions(-)
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")
|