Merge pull request #103 from dinvlad/master

Added full-screen mode for Mac OS X Lion
This commit is contained in:
chulai 2012-07-15 16:38:02 -07:00
commit bdda29a267
4 changed files with 52 additions and 1 deletions

View file

@ -103,7 +103,8 @@ mac {
-logg \ -logg \
-lhunspell-1.2 -lhunspell-1.2
INCLUDEPATH = maclibs/include INCLUDEPATH = maclibs/include
LIBS += -Lmaclibs/lib LIBS += -Lmaclibs/lib -framework AppKit
OBJECTIVE_SOURCES += lionsupport.mm
ICON = icons/macicon.icns ICON = icons/macicon.icns
QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks & \ QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks & \
cp -nR maclibs/lib/ GoldenDict.app/Contents/Frameworks/ & \ cp -nR maclibs/lib/ GoldenDict.app/Contents/Frameworks/ & \

20
lionsupport.h Normal file
View file

@ -0,0 +1,20 @@
#ifndef LIONSUPPORT_H
#define LIONSUPPORT_H
#include "mainwindow.hh"
class LionSupport
{
public:
/**
* Returns whether the current system is Lion.
*/
static bool isLion();
/**
* Adds fullscreen button to window for Lion.
*/
static void addFullscreen(MainWindow *window);
};
#endif // LIONSUPPORT_H

22
lionsupport.mm Normal file
View file

@ -0,0 +1,22 @@
#include "lionsupport.h"
bool LionSupport::isLion()
{
NSString *string = [NSString string];
// this selector was added only in Lion. so we can check if it's responding, we are on Lion
return [string respondsToSelector:@selector(linguisticTagsInRange:scheme:options:orthography:tokenRanges:)];
}
void LionSupport::addFullscreen(MainWindow *window)
{
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (isLion()) // checks if lion is running
{
NSView *nsview = (NSView *) window->winId();
NSWindow *nswindow = [nsview window];
[nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
}
#else
#warning No fullscreen support will be included in this build
#endif
}

View file

@ -20,6 +20,10 @@
#include "dprintf.hh" #include "dprintf.hh"
#include <QDebug> #include <QDebug>
#ifdef Q_OS_MAC
#include "lionsupport.h"
#endif
using std::set; using std::set;
using std::wstring; using std::wstring;
using std::map; using std::map;
@ -506,6 +510,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
doDeferredInit( dictionaries ); doDeferredInit( dictionaries );
updateStatusLine(); updateStatusLine();
#ifdef Q_OS_MAC
LionSupport::addFullscreen(this);
#endif
} }
void MainWindow::ctrlTabPressed() void MainWindow::ctrlTabPressed()