OSDN Git Service

kuassel: remove mac and windows code
authorIvailo Monev <xakepa10@gmail.com>
Tue, 27 Jan 2015 03:30:26 +0000 (03:30 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 27 Jan 2015 03:30:26 +0000 (03:30 +0000)
13 files changed:
kuassel/src/common/identity.cpp
kuassel/src/common/settings.cpp
kuassel/src/common/settings.h
kuassel/src/core/core.cpp
kuassel/src/core/coreapplication.cpp
kuassel/src/qtui/coreconfigwizard.cpp
kuassel/src/qtui/legacysystemtray.cpp
kuassel/src/qtui/mainwin.cpp
kuassel/src/qtui/settingspages/appearancesettingspage.cpp
kuassel/src/qtui/taskbarnotificationbackend.cpp
kuassel/src/uisupport/graphicalui.cpp
kuassel/src/uisupport/graphicalui.h
kuassel/src/uisupport/multilineedit.cpp

index 084e27d..105cb0e 100644 (file)
 
 #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)
@@ -80,24 +70,6 @@ Identity::Identity(const Identity &other, 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()));
@@ -109,12 +81,7 @@ QString Identity::defaultNick()
 {
     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)
@@ -122,19 +89,6 @@ QString Identity::defaultNick()
     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
@@ -148,10 +102,7 @@ QString Identity::defaultRealName()
 {
     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)
@@ -161,13 +112,6 @@ QString Identity::defaultRealName()
     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
index d89b850..056e01a 100644 (file)
@@ -27,11 +27,7 @@ const int VERSION = 1;
 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_),
index 4f556d7..2b4fb02 100644 (file)
@@ -76,11 +76,7 @@ protected:
 private:
     inline QSettings::Format format()
     {
-#ifdef Q_OS_WIN
-        return QSettings::IniFormat;
-#else
         return QSettings::NativeFormat;
-#endif
     }
 
 
index f33741a..a8ecba3 100644 (file)
 
 // 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>
@@ -97,26 +93,14 @@ Core::Core()
 
     // 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...";
@@ -125,14 +109,7 @@ Core::Core()
             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()) {
@@ -156,7 +133,6 @@ Core::Core()
                 else
                     qWarning() << "!!! Moving your certificate has failed. Please move it manually into" << Quassel::configDirPath();
             }
-#endif /* !Q_OS_MAC */
             qWarning() << "*** Migration completed.\n\n";
         }
     }
@@ -933,21 +909,6 @@ QVariantMap Core::promptForSettings(const Storage *storage)
 }
 
 
-#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;
@@ -960,4 +921,3 @@ void Core::stdInEcho(bool on)
 }
 
 
-#endif /* Q_OS_WIN */
index 2ea44f8..e7ecdf0 100644 (file)
@@ -67,9 +67,6 @@ bool CoreApplicationInternal::init()
 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();
index adfe4d2..2ba8936 100644 (file)
@@ -53,9 +53,7 @@ CoreConfigWizard::CoreConfigWizard(CoreConnection *connection, const QList<QVari
     setStartId(IntroPage);
     //setStartId(StorageSelectionPage);
 
-#ifndef Q_OS_MAC
     setWizardStyle(ModernStyle);
-#endif
 
     setOption(HaveHelpButton, false);
     setOption(NoBackButtonOnStartPage, true);
index 690ee10..08a59d2 100644 (file)
@@ -33,10 +33,8 @@ LegacySystemTray::LegacySystemTray(QWidget *parent)
     // 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()));
 
index 46e3fa5..9bb14e0 100644 (file)
@@ -349,13 +349,8 @@ void MainWin::setupActions()
             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);
@@ -903,9 +898,6 @@ void MainWin::setupToolBars()
     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"));
@@ -914,23 +906,11 @@ void MainWin::setupToolBars()
     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
 }
 
 
index 1172fc4..55d62c1 100644 (file)
@@ -38,9 +38,6 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
 {
     ui.setupUi(this);
 
-#ifdef Q_OS_MAC
-    ui.minimizeOnClose->hide();
-#endif
 #ifdef QT_NO_SYSTEMTRAYICON
     ui.useSystemTrayIcon->hide();
 #endif
index ba6ff80..b16b273 100644 (file)
@@ -79,11 +79,7 @@ SettingsPage *TaskbarNotificationBackend::createConfigWidget() const
 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);
 
index 1e7da8b..1a4bb00 100644 (file)
@@ -47,17 +47,11 @@ GraphicalUi::GraphicalUi(QObject *parent) : AbstractUi(parent)
     Q_ASSERT(!_instance);
     _instance = this;
 
-#ifdef Q_OS_WIN
-    _dwTickCount = 0;
-#endif
 }
 
 
 void GraphicalUi::init()
 {
-#ifdef Q_OS_WIN
-    mainWidget()->installEventFilter(this);
-#endif
 }
 
 
@@ -135,11 +129,6 @@ void GraphicalUi::disconnectedFromCore()
 
 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);
 }
 
index 59d0658..e80993b 100644 (file)
@@ -28,9 +28,6 @@ class ContextMenuActionProvider;
 class ToolBarActionProvider;
 class UiStyle;
 
-#ifdef Q_OS_WIN
-#  include <windows.h>
-#endif
 
 class GraphicalUi : public AbstractUi
 {
@@ -116,9 +113,6 @@ private:
     static UiStyle *_uiStyle;
     static bool _onAllDesktops;
 
-#ifdef Q_OS_WIN
-    DWORD _dwTickCount;
-#endif
 };
 
 
index d086d7b..57917ee 100644 (file)
@@ -295,11 +295,7 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event)
     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) {
@@ -720,9 +716,6 @@ void MultiLineEdit::on_textChanged()
                 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;
             }