📄 message.cxx
字号:
//// The contents of this file are subject to the Mozilla Public License// Version 1.0 (the "License"); you may not use this file except in// compliance with the License. You may obtain a copy of the License at// http://www.mozilla.org/MPL/// // Software distributed under the License is distributed on an "AS IS"// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See// the License for the specific language governing rights and limitations// under the License.// // The Original Code is CPhone, a cross platform voip gui.//// The Initial Developer of the Original Code is Derek Smithies.//// Copyright (C) 2002 Indranet Technologies Ltd, // http://www.indranet-technologies.com// All Rights Reserved.//// Contributor(s): _______________/* * * $Log: message.cxx,v $ * Revision 1.1 2003/05/09 03:02:35 dereksmithies * Add thread safe mechanism to display messages. * * * * * */#include <qevent.h>#include <qapplication.h>#include <qmessagebox.h>#ifdef __GNUC__#pragma implementation "message.h"#endif#include "message.h"#include <qmetaobject.h>ThreadSafeMessage::ThreadSafeMessage(){}ThreadSafeMessage::~ThreadSafeMessage(){}void::ThreadSafeMessage::DisplayError(PString thisMessage){ DisplayError(QString((const char *)thisMessage));}void::ThreadSafeMessage::DisplayWarning(PString thisMessage){ DisplayWarning(QString((const char *)thisMessage));}void::ThreadSafeMessage::DisplayInformation(PString thisMessage){ DisplayInformation(QString((const char *)thisMessage));}void ThreadSafeMessage::DisplayError(QString thisMessage){ mLevel = eCritical; GenerateMessage(thisMessage, "Failed to initialise");}void ThreadSafeMessage::DisplayWarning(QString thisMessage){ mLevel = eWarning; GenerateMessage(thisMessage, "Warning");}void ThreadSafeMessage::DisplayInformation(QString thisMessage){ mLevel = eInformation; GenerateMessage(thisMessage, "Info");}void ThreadSafeMessage::GenerateMessage(QString thisMessage, QString thisTitle){ title = thisTitle; message = thisMessage; QApplication::postEvent(this, new QCustomEvent(QEvent::User)); }bool ThreadSafeMessage::event(QEvent *e){ if (e->type() != QEvent::User) return FALSE; switch (mLevel) { case eCritical : QMessageBox::critical(0, title, message, 0, 0); break; case eWarning : QMessageBox::warning(0, title, message, 0, 0); break; case eInformation : QMessageBox::information(0, title, message); break; } deleteLater(); return TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -