23 #include <QMessageBox>
24 #include <QFileDialog>
25 #include <QInputDialog>
26 #include <QMessageBox>
32 #define SETTING_MSG_FILTER "MessageFilter"
33 #define SETTING_MAX_MSG_COUNT "MaxMsgCount"
34 #define SETTING_ENABLE_LOGFILE "EnableLogFile"
35 #define SETTING_LOGFILE "LogFile"
36 #define DEFAULT_MSG_FILTER \
37 (tc::ErrorSeverity|tc::WarnSeverity|tc::NoticeSeverity)
38 #define DEFAULT_MAX_MSG_COUNT 50
39 #define DEFAULT_ENABLE_LOGFILE false
40 #if defined(Q_OS_WIN32)
43 #define DEFAULT_LOGFILE \
44 (win32_program_files_folder()+"\\Tor\\tor-log.txt")
46 #define DEFAULT_LOGFILE (QDir::homePath() + "/.tor/tor-log.txt")
49 #define ADD_TO_FILTER(f,v,b) (f = ((b) ? ((f) | (v)) : ((f) & ~(v))))
60 :
VidaliaTab(tr(
"Message Log"),
"MessageLog", parent),
84 ui.frmSettings->setVisible(
false);
98 connect(
ui.actionSave_Selected, SIGNAL(triggered()),
101 connect(
ui.actionSave_All, SIGNAL(triggered()),
104 connect(
ui.actionSelect_All, SIGNAL(triggered()),
107 connect(
ui.actionCopy, SIGNAL(triggered()),
110 connect(
ui.actionFind, SIGNAL(triggered()),
113 connect(
ui.actionClear, SIGNAL(triggered()),
114 this, SLOT(
clear()));
116 connect(
ui.actionHelp, SIGNAL(triggered()),
119 connect(
ui.btnSaveSettings, SIGNAL(clicked()),
122 connect(
ui.btnCancelSettings, SIGNAL(clicked()),
128 QToolBar *tb =
new QToolBar(tr(
"toolbar"));
129 tb->addAction(
ui.actionSave_All);
130 tb->addAction(
ui.actionSave_Selected);
131 tb->addAction(
ui.actionCopy);
132 tb->addAction(
ui.actionSelect_All);
133 tb->addAction(
ui.actionFind);
134 tb->addAction(
ui.actionClear);
135 tb->addAction(
ui.actionSettings);
136 tb->addAction(
ui.actionHelp);
138 tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
139 ui.verticalLayout->insertWidget(0, tb);
141 #if defined(Q_WS_MAC)
142 ui.actionHelp->setShortcut(QString(
"Ctrl+?"));
144 ui.actionClose->setShortcut(QString(
"Esc"));
153 ui.chkTorErr->setToolTip(tr(
"Messages that appear when something has \n"
154 "gone very wrong and Tor cannot proceed."));
155 ui.chkTorWarn->setToolTip(tr(
"Messages that only appear when \n"
156 "something has gone wrong with Tor."));
157 ui.chkTorNote->setToolTip(tr(
"Messages that appear infrequently \n"
158 "during normal Tor operation and are \n"
159 "not considered errors, but you may \n"
161 ui.chkTorInfo->setToolTip(tr(
"Messages that appear frequently \n"
162 "during normal Tor operation."));
163 ui.chkTorDebug->setToolTip(tr(
"Hyper-verbose messages primarily of \n"
164 "interest to Tor developers."));
171 ui.retranslateUi(
this);
183 ui.spnbxMaxCount->setValue(maxMsgCount);
184 ui.listMessages->setMaximumMessageCount(maxMsgCount);
191 ui.lineFile->setText(QDir::convertSeparators(logfile));
205 QApplication::setOverrideCursor(Qt::WaitCursor);
207 QApplication::restoreOverrideCursor();
230 p(tr(
"Vidalia was unable to register for Tor's log events.")) +
p(errmsg),
246 p(tr(
"Vidalia was unable to open the specified log file."))+
p(errmsg),
268 p(tr(
"You must enter a filename to be able to save log "
276 ui.lineFile->setText(QDir::convertSeparators(
ui.lineFile->text()));
281 ui.listMessages->setMaximumMessageCount(
ui.spnbxMaxCount->value());
294 QApplication::setOverrideCursor(Qt::WaitCursor);
296 QApplication::restoreOverrideCursor();
299 ui.actionSettings->toggle();
308 ui.actionSettings->toggle();
318 QString filename = QDir::convertSeparators(
319 QFileDialog::getSaveFileName(
this,
320 tr(
"Select Log File"),
"tor-log.txt"));
321 if (!filename.isEmpty()) {
322 ui.lineFile->setText(filename);
332 if (!messages.size()) {
336 QString fileName = QFileDialog::getSaveFileName(
this,
337 tr(
"Save Log Messages"),
339 QDateTime::currentDateTime().toString(
"MM.dd.yyyy")
340 +
".txt", tr(
"Text Files (*.txt)"));
343 if (!fileName.isEmpty()) {
348 if (!logFile.
open(fileName, &errmsg)) {
350 p(tr(
"Cannot write file %1\n\n%2."))
358 QApplication::setOverrideCursor(Qt::WaitCursor);
359 foreach (QString msg, messages) {
360 logFile << msg <<
"\n";
362 QApplication::restoreOverrideCursor();
370 save(
ui.listMessages->selectedMessages());
377 save(
ui.listMessages->allMessages());
383 ui.listMessages->selectAll();
392 contents =
ui.listMessages->selectedMessages().join(
"\n");
394 if (!contents.isEmpty()) {
396 QApplication::clipboard()->setText(contents);
405 ui.listMessages->clearMessages();
417 QString text = QInputDialog::getText(
this, tr(
"Find in Message Log"),
418 tr(
"Find:"), QLineEdit::Normal, QString(), &ok);
420 if (ok && !text.isEmpty()) {
422 QTreeWidgetItem *firstItem = 0;
425 QList<LogTreeItem *> results =
ui.listMessages->find(text,
true);
426 if (results.size() > 0) {
427 tree =
ui.listMessages;
428 firstItem =
dynamic_cast<QTreeWidgetItem *
>(results.at(0));
433 p(tr(
"Search found 0 matches.")),
436 tree->scrollToItem(firstItem);
449 setUpdatesEnabled(
false);
457 QString currStatusTip;
460 if (!currStatusTip.isEmpty()) {
461 currStatusTip =
ui.listMessages->statusTip();
470 setUpdatesEnabled(
true);
void saveSetting(QString name, QVariant value)
bool open(QString filename, QString *errmsg=0)
#define SETTING_MSG_FILTER
#define DEFAULT_MAX_MSG_COUNT
void log(tc::Severity severity, const QString &msg)
void save(const QStringList &messages)
#define SETTING_MAX_MSG_COUNT
bool setEvent(TorEvents::Event e, bool add=true, bool set=true, QString *errmsg=0)
bool setEvents(QString *errmsg=0)
bool rotateLogFile(const QString &filename)
static int information(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
static TorControl * torControl()
QVariant getSetting(QString name, QVariant defaultValue)
stop errmsg connect(const QHostAddress &address, quint16 port)
#define DEFAULT_MSG_FILTER
#define DEFAULT_ENABLE_LOGFILE
#define ADD_TO_FILTER(f, v, b)
static int warning(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
MessageLog(QStatusBar *st=0, QWidget *parent=0)
virtual void retranslateUi()
void setTitle(const QString &title)
void helpRequested(const QString &topic)
#define SETTING_ENABLE_LOGFILE
static void createShortcut(const QKeySequence &key, QWidget *sender, QObject *receiver, const char *slot)