Help::Help( const QString& home, MainWindow* parent, const char *name ) #if defined(HAVE_KDE) : KMainWindow( 0, name, WType_TopLevel | WDestructiveClose | WGroupLeader ), #else : QMainWindow( 0, name, WType_TopLevel | WDestructiveClose | WGroupLeader ), #endif mainWindow( parent ), helpDialog( 0 ) { bookmarkMenu = 0; browser = new TextBrowser( this ); browser->mimeSourceFactory()->setFilePath( home ); browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); browser->mimeSourceFactory()->addFilePath( QString( getenv( "QTDIR" ) ) + "/tools/designer/manual" ); browser->mimeSourceFactory()->addFilePath( QString( getenv( "QTDIR" ) ) + "/doc/html/designer" ); browser->mimeSourceFactory()->addFilePath( parent->documentationPath() ); connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); setCentralWidget( browser ); #if defined(HAVE_KDE) toolbar = new KToolBar( this ); #else toolbar = new QToolBar( this ); #endif addToolBar( toolbar, tr( "Tools" ) ); setupFileActions(); setupGoActions(); setupBookmarkMenu(); resize( 750,700 ); setToolBarsMovable( FALSE ); }
MainWindow::MainWindow() { setUnifiedTitleAndToolBarOnMac(true); ui.setupUi(this); #if defined(Q_WS_WIN) // Workaround for QMimeSourceFactory failing in QFileInfo::isReadable() for // certain user configs. See task: 34372 qt_ntfs_permission_lookup = 0; #endif setupCompleted = false; goActions = QList<QAction*>(); goActionDocFiles = new QMap<QAction*,QString>; windows.append(this); tabs = new TabbedBrowser(this); connect(tabs, SIGNAL(tabCountChanged(int)), this, SLOT(updateTabActions(int))); setCentralWidget(tabs); Config *config = Config::configuration(); updateProfileSettings(); dw = new QDockWidget(this); dw->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); dw->setWindowTitle(tr("Sidebar")); dw->setObjectName(QLatin1String("sidebar")); helpDock = new HelpDialog(dw, this); dw->setWidget(helpDock); addDockWidget(Qt::LeftDockWidgetArea, dw); // read geometry configuration setupGoActions(); restoreGeometry(config->windowGeometry()); restoreState(config->mainWindowState()); if (config->sideBarHidden()) dw->hide(); tabs->setup(); QTimer::singleShot(0, this, SLOT(setup())); #if defined(Q_WS_MAC) QMenu *windowMenu = new QMenu(tr("&Window"), this); menuBar()->insertMenu(ui.helpMenu->menuAction(), windowMenu); windowMenu->addAction(tr("Minimize"), this, SLOT(showMinimized()), QKeySequence(tr("Ctrl+M"))); // Use the same forward and backward browser shortcuts as Safari and Internet Explorer do // on the Mac. This means that if you have access to one of those cool Intellimice, the thing // works just fine, since that's how Microsoft hacked it. ui.actionGoPrevious->setShortcut(QKeySequence(Qt::CTRL|Qt::Key_Left)); ui.actionGoNext->setShortcut(QKeySequence(Qt::CTRL|Qt::Key_Right)); static const QLatin1String MacIconPath(":/trolltech/assistant/images/mac"); ui.actionGoNext->setIcon(QIcon(MacIconPath + QLatin1String("/next.png"))); ui.actionGoPrevious->setIcon(QIcon(MacIconPath + QLatin1String("/prev.png"))); ui.actionGoHome->setIcon(QIcon(MacIconPath + QLatin1String("/home.png"))); ui.actionEditCopy->setIcon(QIcon(MacIconPath + QLatin1String("/editcopy.png"))); ui.actionEditCopy->setIcon(QIcon(MacIconPath + QLatin1String("/editcopy.png"))); ui.actionEditFind->setIcon(QIcon(MacIconPath + QLatin1String("/find.png"))); ui.actionFilePrint->setIcon(QIcon(MacIconPath + QLatin1String("/print.png"))); ui.actionZoomOut->setIcon(QIcon(MacIconPath + QLatin1String("/zoomout.png"))); ui.actionZoomIn->setIcon(QIcon(MacIconPath + QLatin1String("/zoomin.png"))); ui.actionSyncToc->setIcon(QIcon(MacIconPath + QLatin1String("/synctoc.png"))); ui.actionHelpWhatsThis->setIcon(QIcon(MacIconPath + QLatin1String("/whatsthis.png"))); #endif }