2008-01-20 19:40:12 +01:00
|
|
|
|
/*****************************************************************************
|
|
|
|
|
* Eliot
|
2012-10-07 16:25:41 +02:00
|
|
|
|
* Copyright (C) 2010-2012 Olivier Teuli<EFBFBD>re
|
2010-01-24 00:34:48 +01:00
|
|
|
|
* Authors: Olivier Teuli<EFBFBD>re <ipkiss @@ gmail.com>
|
2008-01-20 19:40:12 +01: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 2 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, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef QT_COMMON_H_
|
|
|
|
|
#define QT_COMMON_H_
|
|
|
|
|
|
2008-08-31 13:48:11 +02:00
|
|
|
|
#include "config.h"
|
2010-01-24 00:34:48 +01:00
|
|
|
|
#include <string>
|
2008-09-05 23:31:30 +02:00
|
|
|
|
#include <QtCore/QString>
|
2010-01-24 00:34:48 +01:00
|
|
|
|
#include "encoding.h"
|
2008-08-31 13:48:11 +02:00
|
|
|
|
|
2008-01-20 19:40:12 +01:00
|
|
|
|
#if ENABLE_NLS
|
|
|
|
|
# include <libintl.h>
|
|
|
|
|
# define _(String) gettext(String)
|
|
|
|
|
// Apparently needed on Windows, where libintl.h defines sprintf
|
|
|
|
|
// as libintl_sprintf...
|
|
|
|
|
# undef sprintf
|
|
|
|
|
#else
|
|
|
|
|
# define _(String) String
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-01-24 00:34:48 +01:00
|
|
|
|
// Convert to/from std::wstring
|
2011-07-30 21:45:18 +02:00
|
|
|
|
std::wstring wfq(const QString &q);
|
2010-01-24 00:34:48 +01:00
|
|
|
|
QString qfw(const wstring &wstr);
|
|
|
|
|
// Convert to/from local encoding
|
|
|
|
|
#define qfl(s) qfw(convertToWc(s))
|
2011-07-30 21:45:18 +02:00
|
|
|
|
#define lfq(s) convertToMb(wfq(s))
|
2008-01-20 19:40:12 +01:00
|
|
|
|
// Convert to/from utf-8 char*
|
2011-07-30 21:49:29 +02:00
|
|
|
|
#define qfu(s) QString::fromUtf8(string(s).c_str())
|
2011-07-30 21:45:18 +02:00
|
|
|
|
#define ufq(s) (s).toUtf8().data()
|
2008-01-20 19:40:12 +01:00
|
|
|
|
// Translation macro to use gettext
|
2010-02-12 19:16:57 +01:00
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
// On MacOSX, we force the encoding to UTF-8, because we have trouble
|
|
|
|
|
// detecting the current encoding properly (see call to
|
|
|
|
|
// bind_textdomain_codeset() in main.cpp)
|
|
|
|
|
# define _q(s) qfu(_(s))
|
|
|
|
|
#else
|
|
|
|
|
# define _q(s) QString::fromLocal8Bit(_(s))
|
|
|
|
|
#endif
|
2008-01-20 19:40:12 +01:00
|
|
|
|
|
2012-01-19 11:59:58 +01:00
|
|
|
|
|
|
|
|
|
class QObject;
|
|
|
|
|
class QWidget;
|
|
|
|
|
|
|
|
|
|
class QtCommon
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/// Unit test for the macros above
|
|
|
|
|
static void CheckConversions();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Kill the given widget, i.e. hide it, cut its signals, and mark it for deletion.
|
|
|
|
|
* If a iSource object is given, signals from the source will be disconnected
|
|
|
|
|
* from the widget to destroy as well.
|
|
|
|
|
*/
|
|
|
|
|
static void DestroyObject(QWidget *ioWidgetToDestroy,
|
|
|
|
|
QObject *iSource = NULL);
|
2012-01-20 18:08:12 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Ask for a confirmation.
|
|
|
|
|
* Return true if the user confirms, false otherwise.
|
|
|
|
|
* By default, the question is "Do you want to continue?".
|
|
|
|
|
* If a parent is provided, the window is centered on it.
|
|
|
|
|
*/
|
2012-04-29 01:49:03 +02:00
|
|
|
|
static bool requestConfirmation(QString confoKey,
|
|
|
|
|
QString iMsg,
|
2012-01-20 18:08:12 +01:00
|
|
|
|
QString iQuestion = "",
|
|
|
|
|
QWidget *iParent = 0);
|
|
|
|
|
|
2012-01-19 11:59:58 +01:00
|
|
|
|
};
|
2011-07-30 21:49:29 +02:00
|
|
|
|
|
2008-01-20 19:40:12 +01:00
|
|
|
|
#endif
|