#include <KLocale>
-#ifdef Q_OS_MAC
-# include <CoreServices/CoreServices.h>
-# include "mac_utils.h"
-#endif
#ifdef Q_OS_UNIX
# include <sys/types.h>
# include <unistd.h>
#endif
-#ifdef Q_OS_WIN
-# include <windows.h>
-# include <Winbase.h>
-# define SECURITY_WIN32
-# include <Security.h>
-#endif
INIT_SYNCABLE_OBJECT(Identity)
Identity::Identity(IdentityId id, QObject *parent)
}
-#ifdef Q_OS_WIN
-#ifdef UNICODE
-QString tcharToQString(TCHAR *tchar)
-{
- return QString::fromUtf16(reinterpret_cast<ushort *>(tchar));
-}
-
-
-#else
-QString tcharToQString(TCHAR *tchar)
-{
- return QString::fromLocal8Bit(tchar);
-}
-
-
-#endif
-
-#endif
void Identity::init()
{
setObjectName(QString::number(id().toInt()));
{
QString nick = QString("quassel%1").arg(qrand() & 0xff); // FIXME provide more sensible default nicks
-#ifdef Q_OS_MAC
- QString shortUserName = CFStringToQString(CSCopyUserName(true));
- if (!shortUserName.isEmpty())
- nick = shortUserName;
-
-#elif defined(Q_OS_UNIX)
+#if defined(Q_OS_UNIX)
QString userName;
struct passwd *pwd = getpwuid(getuid());
if (pwd)
if (!userName.isEmpty())
nick = userName;
-#elif defined(Q_OS_WIN)
- TCHAR infoBuf[128];
- DWORD bufCharCount = 128;
- //if(GetUserNameEx(/* NameSamCompatible */ 1, infoBuf, &bufCharCount))
- if (GetUserNameEx(NameSamCompatible, infoBuf, &bufCharCount)) {
- QString nickName(tcharToQString(infoBuf));
- int lastBs = nickName.lastIndexOf('\\');
- if (lastBs != -1) {
- nickName = nickName.mid(lastBs + 1);
- }
- if (!nickName.isEmpty())
- nick = nickName;
- }
#endif
// cleaning forbidden characters from nick
{
QString generalDefault = i18n("Kuassel User");
-#ifdef Q_OS_MAC
- return CFStringToQString(CSCopyUserName(false));
-
-#elif defined(Q_OS_UNIX)
+#if defined(Q_OS_UNIX)
QString realName;
struct passwd *pwd = getpwuid(getuid());
if (pwd)
else
return generalDefault;
-#elif defined(Q_OS_WIN)
- TCHAR infoBuf[128];
- DWORD bufCharCount = 128;
- if (GetUserName(infoBuf, &bufCharCount))
- return tcharToQString(infoBuf);
- else
- return generalDefault;
#else
return generalDefault;
#endif
QHash<QString, QVariant> Settings::settingsCache;
QHash<QString, SettingsChangeNotifier *> Settings::settingsChangeNotifier;
-#ifdef Q_OS_MAC
-# define create_qsettings QSettings s(QCoreApplication::organizationDomain(), appName)
-#else
# define create_qsettings QSettings s(fileName(), format())
-#endif
// Settings::Settings(QString group_, QString appName_)
// : group(group_),
private:
inline QSettings::Format format()
{
-#ifdef Q_OS_WIN
- return QSettings::IniFormat;
-#else
return QSettings::NativeFormat;
-#endif
}
// migration related
#include <QFile>
-#ifdef Q_OS_WIN
-# include <windows.h>
-#else
# include <unistd.h>
# include <termios.h>
-#endif /* Q_OS_WIN */
#ifdef HAVE_UMASK
# include <sys/types.h>
// FIXME: MIGRATION 0.3 -> 0.4: Move database and core config to new location
// Move settings, note this does not delete the old files
-#ifdef Q_OS_MAC
- QSettings newSettings("quassel-irc.org", "quasselcore");
-#else
-# ifdef Q_OS_WIN
- QSettings::Format format = QSettings::IniFormat;
-# else
QSettings::Format format = QSettings::NativeFormat;
-# endif
QString newFilePath = Quassel::configDirPath() + "quasselcore"
+ ((format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"));
QSettings newSettings(newFilePath, format);
-#endif /* Q_OS_MAC */
if (newSettings.value("Config/Version").toUInt() == 0) {
-# ifdef Q_OS_MAC
- QString org = "quassel-irc.org";
-# else
QString org = "Quassel Project";
-# endif
QSettings oldSettings(org, "Quassel Core");
if (oldSettings.allKeys().count()) {
qWarning() << "\n\n*** IMPORTANT: Config and data file locations have changed. Attempting to auto-migrate your core settings...";
newSettings.setValue("Config/Version", 1);
qWarning() << "* Your core settings have been migrated to" << newSettings.fileName();
-#ifndef Q_OS_MAC /* we don't need to move the db and cert for mac */
-#ifdef Q_OS_WIN
- QString quasselDir = qgetenv("APPDATA") + "/quassel/";
-#elif defined Q_OS_MAC
- QString quasselDir = QDir::homePath() + "/Library/Application Support/Quassel/";
-#else
QString quasselDir = QDir::homePath() + "/.quassel/";
-#endif
QFileInfo info(Quassel::configDirPath() + "quassel-storage.sqlite");
if (!info.exists()) {
else
qWarning() << "!!! Moving your certificate has failed. Please move it manually into" << Quassel::configDirPath();
}
-#endif /* !Q_OS_MAC */
qWarning() << "*** Migration completed.\n\n";
}
}
}
-#ifdef Q_OS_WIN
-void Core::stdInEcho(bool on)
-{
- HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
- DWORD mode = 0;
- GetConsoleMode(hStdin, &mode);
- if (on)
- mode |= ENABLE_ECHO_INPUT;
- else
- mode &= ~ENABLE_ECHO_INPUT;
- SetConsoleMode(hStdin, mode);
-}
-
-
-#else
void Core::stdInEcho(bool on)
{
termios t;
}
-#endif /* Q_OS_WIN */
CoreApplication::CoreApplication(int &argc, char **argv)
: QCoreApplication(argc, argv), Quassel()
{
-#ifdef Q_OS_MAC
- disableCrashhandler();
-#endif /* Q_OS_MAC */
setRunMode(Quassel::CoreOnly);
_internal = new CoreApplicationInternal();
setStartId(IntroPage);
//setStartId(StorageSelectionPage);
-#ifndef Q_OS_MAC
setWizardStyle(ModernStyle);
-#endif
setOption(HaveHelpButton, false);
setOption(NoBackButtonOnStartPage, true);
// We don't want to trigger a minimize if a highlight is pending, so we brutally remove the internal connection for that
disconnect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
_trayIcon, SLOT(activateOrHide(QSystemTrayIcon::ActivationReason)));
-#ifndef Q_OS_MAC
connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(on_activated(QSystemTrayIcon::ActivationReason)));
-#endif
connect(_trayIcon, SIGNAL(messageClicked()),
SLOT(on_messageClicked()));
this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
// Jump keys
-#ifdef Q_OS_MAC
- const int bindModifier = Qt::ControlModifier | Qt::AltModifier;
- const int jumpModifier = Qt::ControlModifier;
-#else
const int bindModifier = Qt::ControlModifier;
const int jumpModifier = Qt::AltModifier;
-#endif
coll->addAction("BindJumpKey0", new Action(i18n("Set Quick Access #0"), coll, this, SLOT(bindJumpKey()),
QKeySequence(bindModifier + Qt::Key_0)))->setProperty("Index", 0);
connect(_nickListWidget, SIGNAL(nickSelectionChanged(QModelIndexList)),
QtUi::toolBarActionProvider(), SLOT(nickSelectionChanged(QModelIndexList)));
-#ifdef Q_OS_MAC
- setUnifiedTitleAndToolBarOnMac(true);
-#endif
_mainToolBar = new KToolBar("MainToolBar", this, Qt::TopToolBarArea, false, true, true);
_mainToolBar->setWindowTitle(i18n("Main Toolbar"));
QtUi::toolBarActionProvider()->addActions(_mainToolBar, ToolBarActionProvider::MainToolBar);
_toolbarMenu->addAction(_mainToolBar->toggleViewAction());
-#ifdef Q_OS_MAC
- QtUiSettings uiSettings;
-
- bool visible = uiSettings.value("ShowMainToolBar", QVariant(true)).toBool();
- _mainToolBar->setVisible(visible);
- connect(_mainToolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveMainToolBarStatus(bool)));
-#endif
}
void MainWin::saveMainToolBarStatus(bool enabled)
{
-#ifdef Q_OS_MAC
- QtUiSettings uiSettings;
- uiSettings.setValue("ShowMainToolBar", enabled);
-#else
Q_UNUSED(enabled);
-#endif
}
{
ui.setupUi(this);
-#ifdef Q_OS_MAC
- ui.minimizeOnClose->hide();
-#endif
#ifdef QT_NO_SYSTEMTRAYICON
ui.useSystemTrayIcon->hide();
#endif
TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "TaskbarNotification", parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
-#ifdef Q_OS_MAC
- layout->addWidget(enabledBox = new QCheckBox(i18n("Activate dock entry, timeout:"), this));
-#else
layout->addWidget(enabledBox = new QCheckBox(i18n("Mark taskbar entry, timeout:"), this));
-#endif
enabledBox->setIcon(KIcon("flag-blue"));
enabledBox->setEnabled(true);
Q_ASSERT(!_instance);
_instance = this;
-#ifdef Q_OS_WIN
- _dwTickCount = 0;
-#endif
}
void GraphicalUi::init()
{
-#ifdef Q_OS_WIN
- mainWidget()->installEventFilter(this);
-#endif
}
bool GraphicalUi::eventFilter(QObject *obj, QEvent *event)
{
-#ifdef Q_OS_WIN
- if (obj == mainWidget() && event->type() == QEvent::ActivationChange) {
- _dwTickCount = GetTickCount();
- }
-#endif
return AbstractUi::eventFilter(obj, event);
}
class ToolBarActionProvider;
class UiStyle;
-#ifdef Q_OS_WIN
-# include <windows.h>
-#endif
class GraphicalUi : public AbstractUi
{
static UiStyle *_uiStyle;
static bool _onAllDesktops;
-#ifdef Q_OS_WIN
- DWORD _dwTickCount;
-#endif
};
if (event == QKeySequence::InsertLineSeparator) {
#else
-# ifdef Q_OS_MAC
- if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::META) {
-# else
if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::SHIFT) {
-# endif
#endif
if (_mode == SingleLine) {
msg += "...</p>";
QMessageBox question(QMessageBox::NoIcon, i18n("Paste Protection"), msg, QMessageBox::Yes|QMessageBox::No);
question.setDefaultButton(QMessageBox::No);
-#ifdef Q_OS_MAC
- question.setWindowFlags(question.windowFlags() | Qt::Sheet);
-#endif
if (question.exec() != QMessageBox::Yes)
return;
}