UserBox::UserBox(unsigned long grpId) : QMainWindow(NULL, NULL, (WType_TopLevel | WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) #ifdef USE_KDE | (pMain->UserWindowInTaskManager() ? WStyle_Minimize : 0) #endif ), GrpId(this, "Group"), CurrentUser(this, "CurrentUser"), mLeft(this, "Left"), mTop(this, "Top"), mWidth(this, "Width"), mHeight(this, "Height"), ToolbarDock(this, "ToolbarDock", "Top"), ToolbarOffset(this, "ToolbarOffset"), ToolbarY(this, "ToolbarY") { ToolbarDock = pMain->UserBoxToolbarDock(); ToolbarOffset = pMain->UserBoxToolbarOffset(); ToolbarY = pMain->UserBoxToolbarY(); users = NULL; GrpId = grpId; msgView = NULL; progress = NULL; setWFlags(WDestructiveClose); infoWnd = NULL; historyWnd = NULL; transparent = new TransparentTop(this, pMain->UseTransparentContainer, pMain->TransparentContainer); menuUser = new QPopupMenu(this); menuUser->setCheckable(true); connect(menuUser, SIGNAL(activated(int)), this, SLOT(selectedUser(int))); curWnd = NULL; frm = new QFrame(this); setCentralWidget(frm); lay = new QVBoxLayout(frm); vSplitter = new QSplitter(Horizontal, frm); vSplitter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); lay->addWidget(vSplitter); splitter = new QSplitter(Vertical, vSplitter); modeChanged(pMain->SimpleMode()); frmUser = new QFrame(splitter); layUser = new QVBoxLayout(frmUser); tabSplitter = new Splitter(frm); tabSplitter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); tabs = new UserTabBar(tabSplitter); tabs->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); QSize s; status = new QStatusBar(tabSplitter); { QProgressBar p(status); status->addWidget(&p); s = status->minimumSizeHint(); } status->setMinimumSize(QSize(0, s.height())); tabSplitter->setResizeMode(status, QSplitter::KeepSize); lay->addWidget(tabSplitter); setIcon(Pict(pClient->getStatusIcon())); connect(tabs, SIGNAL(selected(int)), this, SLOT(selectedUser(int))); connect(tabs, SIGNAL(showUserPopup(int, QPoint)), this, SLOT(showUserPopup(int, QPoint))); toolbar = new QToolBar(this); toolbar->setHorizontalStretchable(true); toolbar->setVerticalStretchable(true); menuType = new QPopupMenu(this); connect(menuType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); btnType = new PictButton(toolbar); btnType->setPopup(menuType); btnType->setPopupDelay(0); toolbar->addSeparator(); btnUser = new PictButton(toolbar); btnUser->setPopup(menuUser); btnUser->setPopupDelay(0); toolbar->addSeparator(); btnIgnore = new QToolButton(toolbar); btnIgnore->setIconSet(Icon("ignorelist")); btnIgnore->setTextLabel(i18n("Add to ignore list")); connect(btnIgnore, SIGNAL(clicked()), this, SLOT(toIgnore())); menuGroup = new QPopupMenu(this); connect(menuGroup, SIGNAL(aboutToShow()), this, SLOT(showGrpMenu())); connect(menuGroup, SIGNAL(activated(int)), this, SLOT(moveUser(int))); btnGroup = new CToolButton(toolbar); btnGroup->setIconSet(Icon("grp_on")); btnGroup->setTextLabel(i18n("Move to group")); btnGroup->setPopup(menuGroup); btnGroup->setPopupDelay(0); toolbar->addSeparator(); btnInfo = new QToolButton(toolbar); btnInfo->setIconSet(Icon("info")); btnInfo->setTextLabel(i18n("User info")); btnInfo->setToggleButton(true); connect(btnInfo, SIGNAL(toggled(bool)), this, SLOT(toggleInfo(bool))); btnHistory = new QToolButton(toolbar); btnHistory->setIconSet(Icon("history")); btnHistory->setTextLabel(i18n("History")); btnHistory->setToggleButton(true); connect(btnHistory, SIGNAL(toggled(bool)), this, SLOT(toggleHistory(bool))); btnQuit = new QToolButton(Icon("exit"), i18n("Close"), "", this, SLOT(quit()), toolbar); connect(pClient, SIGNAL(event(ICQEvent*)), this, SLOT(processEvent(ICQEvent*))); connect(pClient, SIGNAL(messageRead(ICQMessage*)), this, SLOT(messageRead(ICQMessage*))); connect(pClient, SIGNAL(messageReceived(ICQMessage*)), this, SLOT(messageReceived(ICQMessage*))); connect(pMain, SIGNAL(iconChanged()), this, SLOT(iconChanged())); connect(pMain, SIGNAL(wmChanged()), this, SLOT(wmChanged())); connect(pMain, SIGNAL(modeChanged(bool)), this, SLOT(modeChanged(bool))); connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), this, SLOT(toolBarChanged(QToolBar*))); setGroupButtons(); wmChanged(); adjustPos(); adjustToolbar(); }
static void* ui_companion_qt_init(void) { ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle)); MainWindow *mainwindow = NULL; QHBoxLayout *browserButtonsHBoxLayout = NULL; QVBoxLayout *layout = NULL; QVBoxLayout *launchWithWidgetLayout = NULL; QHBoxLayout *coreComboBoxLayout = NULL; QMenuBar *menu = NULL; QDesktopWidget *desktop = NULL; QMenu *fileMenu = NULL; QMenu *editMenu = NULL; QMenu *viewMenu = NULL; QMenu *viewClosedDocksMenu = NULL; QRect desktopRect; QDockWidget *thumbnailDock = NULL; QDockWidget *thumbnail2Dock = NULL; QDockWidget *thumbnail3Dock = NULL; QDockWidget *browserAndPlaylistTabDock = NULL; QDockWidget *coreSelectionDock = NULL; QTabWidget *browserAndPlaylistTabWidget = NULL; QWidget *widget = NULL; QWidget *browserWidget = NULL; QWidget *playlistWidget = NULL; QWidget *coreSelectionWidget = NULL; QWidget *launchWithWidget = NULL; ThumbnailWidget *thumbnailWidget = NULL; ThumbnailWidget *thumbnail2Widget = NULL; ThumbnailWidget *thumbnail3Widget = NULL; QPushButton *browserDownloadsButton = NULL; QPushButton *browserUpButton = NULL; QPushButton *browserStartButton = NULL; ThumbnailLabel *thumbnail = NULL; ThumbnailLabel *thumbnail2 = NULL; ThumbnailLabel *thumbnail3 = NULL; QAction *editSearchAction = NULL; QAction *loadCoreAction = NULL; QAction *unloadCoreAction = NULL; QAction *exitAction = NULL; QComboBox *launchWithComboBox = NULL; QSettings *qsettings = NULL; if (!handle) return NULL; handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize()); handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init()); desktop = qApp->desktop(); desktopRect = desktop->availableGeometry(); mainwindow = handle->window->qtWindow; qsettings = mainwindow->settings(); mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT)); mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect)); mainwindow->setWindowTitle("RetroArch"); mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING); widget = new QWidget(mainwindow); widget->setObjectName("tableWidget"); layout = new QVBoxLayout(); layout->addWidget(mainwindow->contentTableWidget()); widget->setLayout(layout); mainwindow->setCentralWidget(widget); menu = mainwindow->menuBar(); fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE)); loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked())); loadCoreAction->setShortcut(QKeySequence("Ctrl+L")); unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction())); unloadCoreAction->setObjectName("unloadCoreAction"); unloadCoreAction->setEnabled(false); unloadCoreAction->setShortcut(QKeySequence("Ctrl+U")); exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close())); exitAction->setShortcut(QKeySequence::Quit); editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT)); editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus())); editSearchAction->setShortcut(QKeySequence::Find); viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW)); viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS)); viewClosedDocksMenu->setObjectName("viewClosedDocksMenu"); QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow())); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog())); playlistWidget = new QWidget(); playlistWidget->setLayout(new QVBoxLayout()); playlistWidget->setObjectName("playlistWidget"); playlistWidget->layout()->addWidget(mainwindow->playlistListWidget()); browserWidget = new QWidget(); browserWidget->setLayout(new QVBoxLayout()); browserWidget->setObjectName("browserWidget"); browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY)); browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP)); browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES)); QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked())); QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked())); QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked())); browserButtonsHBoxLayout = new QHBoxLayout(); browserButtonsHBoxLayout->addWidget(browserUpButton); browserButtonsHBoxLayout->addWidget(browserStartButton); browserButtonsHBoxLayout->addWidget(browserDownloadsButton); qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout); browserWidget->layout()->addWidget(mainwindow->dirTreeView()); browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget(); browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget"); /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too * setCoreActions() * onTabWidgetIndexChanged() * onCurrentListItemChanged() */ browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)); browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER)); browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow); browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock"); browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea); browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER)); browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock); browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); thumbnailWidget = new ThumbnailWidget(); thumbnail2Widget = new ThumbnailWidget(); thumbnail3Widget = new ThumbnailWidget(); thumbnailWidget->setLayout(new QVBoxLayout()); thumbnail2Widget->setLayout(new QVBoxLayout()); thumbnail3Widget->setLayout(new QVBoxLayout()); thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail = new ThumbnailLabel(); thumbnail->setObjectName("thumbnail"); thumbnail2 = new ThumbnailLabel(); thumbnail2->setObjectName("thumbnail2"); thumbnail3 = new ThumbnailLabel(); thumbnail3->setObjectName("thumbnail3"); thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&))); thumbnailWidget->layout()->addWidget(thumbnail); thumbnail2Widget->layout()->addWidget(thumbnail2); thumbnail3Widget->layout()->addWidget(thumbnail3); thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow); thumbnailDock->setObjectName("thumbnailDock"); thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART)); thumbnailDock->setWidget(thumbnailWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock); thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow); thumbnail2Dock->setObjectName("thumbnail2Dock"); thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN)); thumbnail2Dock->setWidget(thumbnail2Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock); thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow); thumbnail3Dock->setObjectName("thumbnail3Dock"); thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT)); thumbnail3Dock->setWidget(thumbnail3Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock); /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */ thumbnailDock->raise(); coreSelectionWidget = new QWidget(); coreSelectionWidget->setLayout(new QVBoxLayout()); launchWithComboBox = mainwindow->launchWithComboBox(); launchWithWidgetLayout = new QVBoxLayout(); launchWithWidget = new QWidget(); launchWithWidget->setLayout(launchWithWidgetLayout); coreComboBoxLayout = new QHBoxLayout(); mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); coreComboBoxLayout->addWidget(launchWithComboBox); coreComboBoxLayout->addWidget(mainwindow->startCorePushButton()); coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton()); coreComboBoxLayout->addWidget(mainwindow->runPushButton()); coreComboBoxLayout->addWidget(mainwindow->stopPushButton()); mainwindow->stopPushButton()->hide(); coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1); launchWithWidgetLayout->addLayout(coreComboBoxLayout); coreSelectionWidget->layout()->addWidget(launchWithWidget); coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding)); coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow); coreSelectionDock->setObjectName("coreSelectionDock"); coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea); coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE)); coreSelectionDock->setWidget(coreSelectionWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock); mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical); #endif /* this should come last */ mainwindow->resizeThumbnails(true, true, true); if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray()); if (qsettings->contains("save_dock_positions")) if (qsettings->contains("dock_positions")) mainwindow->restoreState(qsettings->value("dock_positions").toByteArray()); if (qsettings->contains("save_last_tab")) { if (qsettings->contains("last_tab")) { int lastTabIndex = qsettings->value("last_tab", 0).toInt(); if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex) browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex); } } if (qsettings->contains("theme")) { QString themeStr = qsettings->value("theme").toString(); MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr); if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM) { QString customThemeFilePath = qsettings->value("custom_theme").toString(); mainwindow->setCustomThemeFile(customThemeFilePath); } mainwindow->setTheme(theme); } else mainwindow->setTheme(); return handle; }
void MainWindow::setupActions() { kDebug() << "setup actions..."; // this let shortcuts work.. actionCollection()->addAssociatedWidget(this); KAction *a; // new window action a = new KAction(KIcon("window-new"), i18n("&New Window"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_N)); actionCollection()->addAction(QL1S("new_window"), a); connect(a, SIGNAL(triggered(bool)), Application::instance(), SLOT(newWindow())); // Standard Actions KStandardAction::open(this, SLOT(fileOpen()), actionCollection()); KStandardAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); KStandardAction::print(this, SLOT(printRequested()), actionCollection()); KStandardAction::quit(this , SLOT(close()), actionCollection()); a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection()); KShortcut findShortcut = KStandardShortcut::find(); findShortcut.setAlternate(Qt::Key_Slash); a->setShortcut(findShortcut); KStandardAction::findNext(this, SLOT(findNext()) , actionCollection()); KStandardAction::findPrev(this, SLOT(findPrevious()) , actionCollection()); a = KStandardAction::fullScreen(this, SLOT(viewFullScreen(bool)), this, actionCollection()); KShortcut fullScreenShortcut = KStandardShortcut::fullScreen(); fullScreenShortcut.setAlternate(Qt::Key_F11); a->setShortcut(fullScreenShortcut); a = actionCollection()->addAction(KStandardAction::Home); connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(homePage(Qt::MouseButtons, Qt::KeyboardModifiers))); KStandardAction::preferences(this, SLOT(preferences()), actionCollection()); a = KStandardAction::redisplay(m_view, SLOT(webReload()), actionCollection()); a->setText(i18n("Reload")); KShortcut reloadShortcut = KStandardShortcut::reload(); reloadShortcut.setAlternate(Qt::CTRL + Qt::Key_R); a->setShortcut(reloadShortcut); a = new KAction(KIcon("process-stop"), i18n("&Stop"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Period)); actionCollection()->addAction(QL1S("stop"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(webStop())); // stop reload Action m_stopReloadAction = new KAction(this); actionCollection()->addAction(QL1S("stop_reload") , m_stopReloadAction); m_stopReloadAction->setShortcutConfigurable(false); connect(m_view, SIGNAL(browserTabLoading(bool)), this, SLOT(browserLoading(bool))); browserLoading(false); //first init for blank start page a = new KAction(i18n("Open Location"), this); KShortcut openLocationShortcut(Qt::CTRL + Qt::Key_L); openLocationShortcut.setAlternate(Qt::Key_F6); a->setShortcut(openLocationShortcut); actionCollection()->addAction(QL1S("open_location"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(openLocation())); // set zoom bar actions m_zoomBar->setupActions(this); // tab list m_tabListMenu = new KMenu(); m_tabListMenu->addAction("hack"); // necessary to show the menu on the right side the first time connect(m_tabListMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabListMenu())); connect(m_tabListMenu, SIGNAL(triggered(QAction*)), this, SLOT(openActionTab(QAction*))); KActionMenu *tabAction = new KActionMenu(i18n("Tab List"), this); tabAction->setMenu(m_tabListMenu); tabAction->setIcon(KIcon("document-multiple")); tabAction->setDelayed(false); actionCollection()->addAction(QL1S("tab_list"), tabAction); // =============================== Tools Actions ================================= a = new KAction(i18n("View Page S&ource"), this); a->setIcon(KIcon("application-xhtml+xml")); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_U)); actionCollection()->addAction(QL1S("page_source"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource())); a = Application::instance()->privateBrowsingAction(); a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_P); actionCollection()->addAction(QL1S("private_browsing"), a); a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this); a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Delete); actionCollection()->addAction(QL1S("clear_private_data"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData())); // ========================= History related actions ============================== a = actionCollection()->addAction(KStandardAction::Back); connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers))); m_historyBackMenu = new KMenu(this); a->setMenu(m_historyBackMenu); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *))); a = actionCollection()->addAction(KStandardAction::Forward); connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers))); // ============================== General Tab Actions ==================================== a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_T)); actionCollection()->addAction(QL1S("new_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); a = new KAction(KIcon("view-refresh"), i18n("Reload All Tabs"), this); actionCollection()->addAction(QL1S("reload_all_tabs"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(reloadAllTabs())); a = new KAction(i18n("Show Next Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); actionCollection()->addAction(QL1S("show_next_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); actionCollection()->addAction(QL1S("show_prev_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab())); a = new KAction(KIcon("tab-new"), i18n("Open Last Closed Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_T)); actionCollection()->addAction(QL1S("open_last_closed_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(openLastClosedTab())); // Closed Tabs Menu KActionMenu *closedTabsMenu = new KActionMenu(KIcon("tab-new"), i18n("Closed Tabs"), this); closedTabsMenu->setDelayed(false); actionCollection()->addAction(QL1S("closed_tab_menu"), closedTabsMenu); // shortcuts for quickly switching to a tab for( int i = 1; i <= 9; i++ ) { a = new KAction(i18n("Switch to Tab %1", i), this); a->setShortcut(KShortcut( QString("Alt+%1").arg(i) )); a->setData( QVariant(i) ); actionCollection()->addAction(QL1S(("switch_tab_" + QString::number(i)).toAscii()), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(switchToTab())); } // ============================== Indexed Tab Actions ==================================== a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcuts( KStandardShortcut::close() ); actionCollection()->addAction(QL1S("close_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeTab())); a = new KAction(KIcon("tab-duplicate"), i18n("Clone Tab"), this); actionCollection()->addAction(QL1S("clone_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(cloneTab())); a = new KAction(KIcon("tab-close-other"), i18n("Close &Other Tabs"), this); actionCollection()->addAction(QL1S("close_other_tabs"), a); connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeOtherTabs())); a = new KAction(KIcon("view-refresh"), i18n("Reload Tab"), this); actionCollection()->addAction(QL1S("reload_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(reloadTab())); a = new KAction(KIcon("tab-detach"), i18n("Detach Tab"), this); actionCollection()->addAction(QL1S("detach_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(detachTab())); // Bookmark Menu KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu(this); bmMenu->setIcon(KIcon("bookmarks")); bmMenu->setDelayed(false); bmMenu->setShortcutConfigurable(true); bmMenu->setShortcut( KShortcut(Qt::ALT + Qt::Key_B) ); actionCollection()->addAction(QL1S("bookmarksActionMenu"), bmMenu); // ---------------- Encodings ----------------------------------- a = new KAction(KIcon("character-set"), i18n("Set Encoding"), this); actionCollection()->addAction(QL1S("encodings"), a); a->setMenu(m_encodingMenu); connect(m_encodingMenu, SIGNAL(aboutToShow()), this, SLOT(populateEncodingMenu())); connect(m_encodingMenu, SIGNAL(triggered(QAction *)), this, SLOT(setEncoding(QAction *))); }
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) , m_bookmarkTabsAction(0) , m_nextTabAction(0) , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_swappedDelayedWidget(false) , m_lineEditCompleter(0) , m_lineEdits(0) , m_tabBar(new TabBar(this)) { setElideMode(Qt::ElideRight); new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T), this, SLOT(openLastTab())); connect(m_tabBar, SIGNAL(loadUrl(const QUrl&, TabWidget::OpenUrlIn)), this, SLOT(loadUrl(const QUrl&, TabWidget::OpenUrlIn))); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); #if QT_VERSION < 0x040500 connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); #endif setTabBar(m_tabBar); #if QT_VERSION >= 0x040500 setDocumentMode(true); connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int))); #endif // Actions m_newTabAction = new QAction(this); m_newTabAction->setShortcuts(QKeySequence::AddTab); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(this); m_closeTabAction->setShortcuts(QKeySequence::Close); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_bookmarkTabsAction = new QAction(this); connect(m_bookmarkTabsAction, SIGNAL(triggered()), this, SLOT(bookmarkTabs())); m_newTabAction->setIcon(QIcon(QLatin1String(":addtab.png"))); m_newTabAction->setIconVisibleInMenu(false); #if QT_VERSION >= 0x040500 QSettings settings; settings.beginGroup(QLatin1String("tabs")); bool oneCloseButton = settings.value(QLatin1String("oneCloseButton"), false).toBool(); if (oneCloseButton) { #endif // With Qt < 4.5 do this always, with >=4.5 only if enabled. m_closeTabAction->setIcon(QIcon(QLatin1String(":closetab.png"))); m_closeTabAction->setIconVisibleInMenu(false); #if QT_VERSION >= 0x040500 } #endif m_nextTabAction = new QAction(this); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(this); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_recentlyClosedTabsMenu = new QMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); m_recentlyClosedTabsAction = new QAction(this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); #ifndef Q_WS_MAC // can't seem to figure out the background color :( QToolButton *addTabButton = new QToolButton(this); addTabButton->setDefaultAction(m_newTabAction); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(addTabButton, Qt::TopRightCorner); #endif #if QT_VERSION >= 0x040500 if (oneCloseButton) { #endif // corner buttons // With Qt < 4.5 do this always, with >=4.5 only if enabled. QToolButton *closeTabButton = new QToolButton(this); closeTabButton->setDefaultAction(m_closeTabAction); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(closeTabButton, Qt::TopLeftCorner); #if QT_VERSION >= 0x040500 } else { m_tabBar->setTabsClosable(true); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); } #endif connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); connect(BrowserApplication::historyManager(), SIGNAL(historyCleared()), this, SLOT(historyCleared())); // Initialize Actions' labels retranslate(); }
KoTagToolButton::KoTagToolButton(QWidget* parent) :QWidget(parent), d(new Private()) { QGridLayout* buttonLayout = new QGridLayout(this); buttonLayout->setMargin(0); buttonLayout->setSpacing(0); d->tagToolButton = new QToolButton(this); d->tagToolButton->setIcon(koIcon("list-add")); d->tagToolButton->setToolTip(i18nc("@info:tooltip", "<qt>Show the tag box options.</qt>")); d->tagToolButton->setPopupMode(QToolButton::InstantPopup); d->tagToolButton->setEnabled(true); QMenu* popup = new QMenu(this); KoLineEditAction* addTagAction = new KoLineEditAction(popup); addTagAction->setClickMessage(i18n("New tag")); addTagAction->setIcon(koIcon("document-new")); addTagAction->closeParentOnTrigger(true); popup->addAction(addTagAction); connect(addTagAction, SIGNAL(triggered(QString)), this, SIGNAL(newTagRequested(QString))); d->action_renameTag = new KoLineEditAction(popup); d->action_renameTag->setClickMessage(i18n("Rename tag")); d->action_renameTag->setIcon(koIcon("edit-rename")); d->action_renameTag->closeParentOnTrigger(true); popup->addAction(d->action_renameTag); connect(d->action_renameTag, SIGNAL(triggered(QString)), this, SIGNAL(renamingOfCurrentTagRequested(QString))); popup->addSeparator(); d->action_deleteTag = new QAction(popup); d->action_deleteTag->setText(i18n("Delete this tag")); d->action_deleteTag->setIcon(koIcon("edit-delete")); popup->addAction(d->action_deleteTag); connect(d->action_deleteTag, SIGNAL(triggered()), this, SIGNAL(deletionOfCurrentTagRequested())); popup->addSeparator(); d->action_undeleteTag = new QAction(popup); d->action_undeleteTag->setIcon(koIcon("edit-redo")); d->action_undeleteTag->setVisible(false); popup->addAction(d->action_undeleteTag); connect(d->action_undeleteTag, SIGNAL(triggered()), this, SLOT(onTagUndeleteClicked())); d->action_purgeTagUndeleteList = new QAction(popup); d->action_purgeTagUndeleteList->setText(i18n("Clear undelete list")); d->action_purgeTagUndeleteList->setIcon(koIcon("edit-clear")); d->action_purgeTagUndeleteList->setVisible(false); popup->addAction(d->action_purgeTagUndeleteList); connect(d->action_purgeTagUndeleteList, SIGNAL(triggered()), this, SIGNAL(purgingOfTagUndeleteListRequested())); connect(popup, SIGNAL(aboutToShow()), this, SIGNAL(popupMenuAboutToShow())); d->tagToolButton->setMenu(popup); buttonLayout->addWidget(d->tagToolButton); }
ChartBar::ChartBar(Context *context) : QWidget(context->mainWindow), context(context) { // left / right scroller icon static QIcon leftIcon = iconFromPNG(":images/mac/left.png"); static QIcon rightIcon = iconFromPNG(":images/mac/right.png"); setContentsMargins(0,0,0,0); // main layout QHBoxLayout *mlayout = new QHBoxLayout(this); mlayout->setSpacing(0); mlayout->setContentsMargins(0,0,0,0); // buttonBar Widget buttonBar = new ButtonBar(this); buttonBar->setContentsMargins(0,0,0,0); QHBoxLayout *vlayout = new QHBoxLayout(buttonBar); vlayout->setSpacing(0); vlayout->setContentsMargins(0,0,0,0); layout = new QHBoxLayout; layout->setSpacing(2); layout->setContentsMargins(0,0,0,0); vlayout->addLayout(layout); vlayout->addStretch(); // scrollarea scrollArea = new QScrollArea(this); scrollArea->setAutoFillBackground(false); scrollArea->setWidgetResizable(true); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setContentsMargins(0,0,0,0); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QFontMetrics fs(buttonFont); setFixedHeight(fs.height()+spacing_); scrollArea->setFixedHeight(fs.height()+spacing_); buttonBar->setFixedHeight(fs.height()+spacing_); scrollArea->setWidget(buttonBar); // scroll area turns it on .. we turn it off! buttonBar->setAutoFillBackground(false); // scroller buttons left = new QToolButton(this); left->setStyleSheet("QToolButton { border: none; padding: 0px; }"); left->setAutoFillBackground(false); left->setFixedSize(20,20); left->setIcon(leftIcon); left->setIconSize(QSize(20,20)); left->setFocusPolicy(Qt::NoFocus); mlayout->addWidget(left); connect(left, SIGNAL(clicked()), this, SLOT(scrollLeft())); // menu bar in the middle of the buttons mlayout->addWidget(scrollArea); right = new QToolButton(this); right->setStyleSheet("QToolButton { border: none; padding: 0px; }"); right->setAutoFillBackground(false); right->setFixedSize(20,20); right->setIcon(rightIcon); right->setIconSize(QSize(20,20)); right->setFocusPolicy(Qt::NoFocus); mlayout->addWidget(right); connect(right, SIGNAL(clicked()), this, SLOT(scrollRight())); // spacer to make the menuButton on the right QLabel *spacer = new QLabel("", this); spacer->setAutoFillBackground(false); spacer->setFixedHeight(20); spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); mlayout->addWidget(spacer); menuButton = new QToolButton(this); menuButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); menuButton->setAutoFillBackground(false); menuButton->setFixedSize(20,20); menuButton->setIcon(iconFromPNG(":images/sidebar/extra.png")); menuButton->setIconSize(QSize(10,10)); menuButton->setFocusPolicy(Qt::NoFocus); mlayout->addWidget(menuButton); //connect(p, SIGNAL(clicked()), action, SLOT(trigger())); signalMapper = new QSignalMapper(this); // maps each option connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(clicked(int))); barMenu = new QMenu("Add"); chartMenu = barMenu->addMenu(tr("Add Chart")); #ifdef GC_HAS_CLOUD_DB barMenu->addAction(tr("Upload Chart..."), context->mainWindow, SLOT(exportChartToCloudDB())); barMenu->addAction(tr("Download Chart..."), context->mainWindow, SLOT(addChartFromCloudDB())); #endif // menu connect(menuButton, SIGNAL(clicked()), this, SLOT(menuPopup())); connect(chartMenu, SIGNAL(aboutToShow()), this, SLOT(setChartMenu())); connect(chartMenu, SIGNAL(triggered(QAction*)), context->mainWindow, SLOT(addChart(QAction*))); // trap resize / mouse events installEventFilter(this); // appearance update connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); }
RuleWidget::RuleWidget(QString fileName) : QWidget() { ui.setupUi(this); ui.rulesTabs->setCurrentIndex(0); filePath=fileName; setProperty("FileName",filePath); setProperty("GroupType","Rule"); QSettings loadRule(fileName,QSettings::IniFormat); loadRule.beginGroup("JLRuleGroup"); groupName=loadRule.value("Name","Unknown").toString(); ui.limitRowsValue->setValue(loadRule.value("LogRowsCount",20).toInt()); ui.ruleBeep->setChecked(loadRule.value("BeepOnDone",false).toBool()); ui.notes->setPlainText(loadRule.value("Notes","").toString()); loadRule.endGroup(); ordersCancelTime=QTime(1,0,0,0); setAttribute(Qt::WA_DeleteOnClose,true); updateStyleSheets(); ui.rulesNoMessage->setVisible(true); ui.rulesTabs->setVisible(false); rulesModel=new RulesModel(groupName); connect(rulesModel,SIGNAL(writeLog(QString)),this,SLOT(writeLog(QString))); rulesModel->setParent(this); ui.rulesTable->setModel(rulesModel); mainWindow.setColumnResizeMode(ui.rulesTable,0,QHeaderView::ResizeToContents); mainWindow.setColumnResizeMode(ui.rulesTable,1,QHeaderView::Stretch); connect(rulesModel,SIGNAL(ruleDone()),this,SLOT(ruleDone())); connect(ui.rulesTable->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),this,SLOT(checkValidRulesButtons())); ui.rulesTable->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui.rulesTable, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(rulesMenuRequested(const QPoint&))); rulesEnableDisableMenu=new QMenu; rulesEnableDisableMenu->addAction("Enable Selected"); connect(rulesEnableDisableMenu->actions().last(),SIGNAL(triggered(bool)),this,SLOT(ruleEnableSelected())); rulesEnableDisableMenu->addAction("Disable Selected"); connect(rulesEnableDisableMenu->actions().last(),SIGNAL(triggered(bool)),this,SLOT(ruleDisableSelected())); rulesEnableDisableMenu->addSeparator(); rulesEnableDisableMenu->addAction("Enable All"); connect(rulesEnableDisableMenu->actions().last(),SIGNAL(triggered(bool)),this,SLOT(ruleEnableAll())); rulesEnableDisableMenu->addAction("Disable All"); connect(rulesEnableDisableMenu->actions().last(),SIGNAL(triggered(bool)),this,SLOT(ruleDisableAll())); ui.ruleEnableDisable->setMenu(rulesEnableDisableMenu); connect(rulesEnableDisableMenu,SIGNAL(aboutToShow()),this,SLOT(ruleDisableEnableMenuFix())); languageChanged(); setWindowTitle(groupName); QStringList rulesList=loadRule.childGroups(); Q_FOREACH(QString group, rulesList) { if(!group.startsWith("Rule_"))continue; RuleHolder holder=RuleScriptParser::readHolderFromSettings(loadRule,group); if(holder.isValid())rulesModel->addRule(holder); } saveRulesData(); checkValidRulesButtons(); mainWindow.fixTableViews(this); QSettings iniSettings(baseValues.iniFileName,QSettings::IniFormat,this); if(iniSettings.value("UI/OptimizeInterface",false).toBool())recursiveUpdateLayouts(this); }
QgsVectorLayerProperties::QgsVectorLayerProperties( QgsVectorLayer *lyr, QWidget * parent, Qt::WindowFlags fl ) : QgsOptionsDialogBase( "VectorLayerProperties", parent, fl ) , layer( lyr ) , mMetadataFilled( false ) , mSaveAsMenu( 0 ) , mLoadStyleMenu( 0 ) , mRendererDialog( 0 ) , labelingDialog( 0 ) , labelDialog( 0 ) , actionDialog( 0 ) , diagramPropertiesDialog( 0 ) , mFieldsPropertiesDialog( 0 ) { setupUi( this ); // QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states, // switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left), // and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots initOptionsBase( false ); QPushButton* b = new QPushButton( tr( "Style" ) ); QMenu* m = new QMenu( this ); mActionLoadStyle = m->addAction( tr( "Load Style" ), this, SLOT( loadStyle_clicked() ) ); mActionSaveStyleAs = m->addAction( tr( "Save Style" ), this, SLOT( saveStyleAs_clicked() ) ); m->addSeparator(); m->addAction( tr( "Save as Default" ), this, SLOT( saveDefaultStyle_clicked() ) ); m->addAction( tr( "Restore Default" ), this, SLOT( loadDefaultStyle_clicked() ) ); b->setMenu( m ); connect( m, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowStyleMenu() ) ); buttonBox->addButton( b, QDialogButtonBox::ResetRole ); connect( lyr->styleManager(), SIGNAL( currentStyleChanged( QString ) ), this, SLOT( syncToLayer() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( this, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); connect( mOptionsStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( mOptionsStackedWidget_CurrentChanged( int ) ) ); connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) ); connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) ); // connections for Map Tip display connect( htmlRadio, SIGNAL( toggled( bool ) ), htmlMapTip, SLOT( setEnabled( bool ) ) ); connect( htmlRadio, SIGNAL( toggled( bool ) ), insertFieldButton, SLOT( setEnabled( bool ) ) ); connect( htmlRadio, SIGNAL( toggled( bool ) ), fieldComboBox, SLOT( setEnabled( bool ) ) ); connect( htmlRadio, SIGNAL( toggled( bool ) ), insertExpressionButton, SLOT( setEnabled( bool ) ) ); connect( fieldComboRadio, SIGNAL( toggled( bool ) ), displayFieldComboBox, SLOT( setEnabled( bool ) ) ); if ( !layer ) return; QVBoxLayout *layout; if ( layer->hasGeometryType() ) { // Create the Labeling dialog tab layout = new QVBoxLayout( labelingFrame ); layout->setMargin( 0 ); labelingDialog = new QgsLabelingWidget( layer, QgisApp::instance()->mapCanvas(), labelingFrame ); labelingDialog->layout()->setContentsMargins( -1, 0, -1, 0 ); layout->addWidget( labelingDialog ); labelingFrame->setLayout( layout ); // Create the Labeling (deprecated) dialog tab layout = new QVBoxLayout( labelOptionsFrame ); layout->setMargin( 0 ); labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame ); labelDialog->layout()->setMargin( 0 ); layout->addWidget( labelDialog ); labelOptionsFrame->setLayout( layout ); connect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) ); } else { labelingDialog = 0; labelDialog = 0; mOptsPage_Labels->setEnabled( false ); // disable labeling item mOptsPage_LabelsOld->setEnabled( false ); // disable labeling (deprecated) item } // Create the Actions dialog tab QVBoxLayout *actionLayout = new QVBoxLayout( actionOptionsFrame ); actionLayout->setMargin( 0 ); const QgsFields &fields = layer->fields(); actionDialog = new QgsAttributeActionDialog( layer->actions(), fields, actionOptionsFrame ); actionDialog->layout()->setMargin( 0 ); actionLayout->addWidget( actionDialog ); // Create the menu for the save style button to choose the output format mSaveAsMenu = new QMenu( this ); mSaveAsMenu->addAction( tr( "QGIS Layer Style File..." ) ); mSaveAsMenu->addAction( tr( "SLD File..." ) ); //Only if the provider support loading & saving styles to db add new choices if ( layer->dataProvider()->isSaveAndLoadStyleToDBSupported() ) { //for loading mLoadStyleMenu = new QMenu( this ); mLoadStyleMenu->addAction( tr( "Load from file..." ) ); mLoadStyleMenu->addAction( tr( "Load from database" ) ); //mActionLoadStyle->setContextMenuPolicy( Qt::PreventContextMenu ); mActionLoadStyle->setMenu( mLoadStyleMenu ); QObject::connect( mLoadStyleMenu, SIGNAL( triggered( QAction * ) ), this, SLOT( loadStyleMenuTriggered( QAction * ) ) ); //for saving mSaveAsMenu->addAction( tr( "Save in database (%1)" ).arg( layer->providerType() ) ); }
static void* ui_companion_qt_init(void) { ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle)); MainWindow *mainwindow = NULL; QHBoxLayout *browserButtonsHBoxLayout = NULL; QVBoxLayout *layout = NULL; QVBoxLayout *launchWithWidgetLayout = NULL; QHBoxLayout *coreComboBoxLayout = NULL; QMenuBar *menu = NULL; QDesktopWidget *desktop = NULL; QMenu *fileMenu = NULL; QMenu *editMenu = NULL; QMenu *viewMenu = NULL; QMenu *viewClosedDocksMenu = NULL; QMenu *toolsMenu = NULL; QMenu *updaterMenu = NULL; QMenu *helpMenu = NULL; QRect desktopRect; QDockWidget *thumbnailDock = NULL; QDockWidget *thumbnail2Dock = NULL; QDockWidget *thumbnail3Dock = NULL; QDockWidget *browserAndPlaylistTabDock = NULL; QDockWidget *coreSelectionDock = NULL; QTabWidget *browserAndPlaylistTabWidget = NULL; QWidget *widget = NULL; QWidget *browserWidget = NULL; QWidget *playlistWidget = NULL; QWidget *coreSelectionWidget = NULL; QWidget *launchWithWidget = NULL; ThumbnailWidget *thumbnailWidget = NULL; ThumbnailWidget *thumbnail2Widget = NULL; ThumbnailWidget *thumbnail3Widget = NULL; QPushButton *browserDownloadsButton = NULL; QPushButton *browserUpButton = NULL; QPushButton *browserStartButton = NULL; ThumbnailLabel *thumbnail = NULL; ThumbnailLabel *thumbnail2 = NULL; ThumbnailLabel *thumbnail3 = NULL; QAction *editSearchAction = NULL; QAction *loadCoreAction = NULL; QAction *unloadCoreAction = NULL; QAction *exitAction = NULL; QComboBox *launchWithComboBox = NULL; QSettings *qsettings = NULL; QListWidget *listWidget = NULL; int i = 0; if (!handle) return NULL; handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize()); handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init()); desktop = qApp->desktop(); desktopRect = desktop->availableGeometry(); mainwindow = handle->window->qtWindow; qsettings = mainwindow->settings(); mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT)); mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect)); mainwindow->setWindowTitle("RetroArch"); mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING); listWidget = mainwindow->playlistListWidget(); widget = new FileDropWidget(mainwindow); widget->setObjectName("tableWidget"); widget->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList))); QObject::connect(widget, SIGNAL(deletePressed()), mainwindow, SLOT(deleteCurrentPlaylistItem())); QObject::connect(widget, SIGNAL(customContextMenuRequested(const QPoint&)), mainwindow, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&))); layout = new QVBoxLayout(); layout->addWidget(mainwindow->contentTableWidget()); layout->addWidget(mainwindow->contentGridWidget()); widget->setLayout(layout); mainwindow->setCentralWidget(widget); menu = mainwindow->menuBar(); fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE)); loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked())); loadCoreAction->setShortcut(QKeySequence("Ctrl+L")); unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction())); unloadCoreAction->setObjectName("unloadCoreAction"); unloadCoreAction->setEnabled(false); unloadCoreAction->setShortcut(QKeySequence("Ctrl+U")); exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close())); exitAction->setShortcut(QKeySequence::Quit); editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT)); editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus())); editSearchAction->setShortcut(QKeySequence::Find); viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW)); viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS)); viewClosedDocksMenu->setObjectName("viewClosedDocksMenu"); QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow())); viewMenu->addSeparator(); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS), mainwindow, SLOT(onIconViewClicked())); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST), mainwindow, SLOT(onListViewClicked())); viewMenu->addSeparator(); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog())); toolsMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_TOOLS)); updaterMenu = toolsMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ONLINE_UPDATER)); #ifdef Q_OS_WIN updaterMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_NIGHTLY), mainwindow, SLOT(updateRetroArchNightly())); #endif helpMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP)); helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_DOCUMENTATION)), mainwindow, SLOT(showDocs())); helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT)) + "...", mainwindow, SLOT(showAbout())); helpMenu->addAction("About Qt...", qApp, SLOT(aboutQt())); playlistWidget = new QWidget(); playlistWidget->setLayout(new QVBoxLayout()); playlistWidget->setObjectName("playlistWidget"); playlistWidget->layout()->addWidget(mainwindow->playlistListWidget()); browserWidget = new QWidget(); browserWidget->setLayout(new QVBoxLayout()); browserWidget->setObjectName("browserWidget"); browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY)); browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP)); browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES)); QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked())); QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked())); QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked())); browserButtonsHBoxLayout = new QHBoxLayout(); browserButtonsHBoxLayout->addWidget(browserUpButton); browserButtonsHBoxLayout->addWidget(browserStartButton); browserButtonsHBoxLayout->addWidget(browserDownloadsButton); qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout); browserWidget->layout()->addWidget(mainwindow->dirTreeView()); browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget(); browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget"); /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too * setCoreActions() * onTabWidgetIndexChanged() * onCurrentListItemChanged() */ browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)); browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER)); browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow); browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock"); browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea); browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER)); browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock); browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); thumbnailWidget = new ThumbnailWidget(); thumbnail2Widget = new ThumbnailWidget(); thumbnail3Widget = new ThumbnailWidget(); thumbnailWidget->setLayout(new QVBoxLayout()); thumbnail2Widget->setLayout(new QVBoxLayout()); thumbnail3Widget->setLayout(new QVBoxLayout()); thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail = new ThumbnailLabel(); thumbnail->setObjectName("thumbnail"); thumbnail2 = new ThumbnailLabel(); thumbnail2->setObjectName("thumbnail2"); thumbnail3 = new ThumbnailLabel(); thumbnail3->setObjectName("thumbnail3"); thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&))); thumbnailWidget->layout()->addWidget(thumbnail); thumbnail2Widget->layout()->addWidget(thumbnail2); thumbnail3Widget->layout()->addWidget(thumbnail3); thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow); thumbnailDock->setObjectName("thumbnailDock"); thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART)); thumbnailDock->setWidget(thumbnailWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock); thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow); thumbnail2Dock->setObjectName("thumbnail2Dock"); thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN)); thumbnail2Dock->setWidget(thumbnail2Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock); thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow); thumbnail3Dock->setObjectName("thumbnail3Dock"); thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT)); thumbnail3Dock->setWidget(thumbnail3Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock); /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */ thumbnailDock->raise(); coreSelectionWidget = new QWidget(); coreSelectionWidget->setLayout(new QVBoxLayout()); launchWithComboBox = mainwindow->launchWithComboBox(); launchWithWidgetLayout = new QVBoxLayout(); launchWithWidget = new QWidget(); launchWithWidget->setLayout(launchWithWidgetLayout); coreComboBoxLayout = new QHBoxLayout(); mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); coreComboBoxLayout->addWidget(launchWithComboBox); coreComboBoxLayout->addWidget(mainwindow->startCorePushButton()); coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton()); coreComboBoxLayout->addWidget(mainwindow->runPushButton()); coreComboBoxLayout->addWidget(mainwindow->stopPushButton()); mainwindow->stopPushButton()->hide(); coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1); launchWithWidgetLayout->addLayout(coreComboBoxLayout); coreSelectionWidget->layout()->addWidget(launchWithWidget); coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding)); coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow); coreSelectionDock->setObjectName("coreSelectionDock"); coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea); coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE)); coreSelectionDock->setWidget(coreSelectionWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock); mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical); #endif /* this should come last */ mainwindow->resizeThumbnails(true, true, true); if (qsettings->contains("all_playlists_list_max_count")) mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt()); if (qsettings->contains("all_playlists_grid_max_count")) mainwindow->setAllPlaylistsGridMaxCount(qsettings->value("all_playlists_grid_max_count", 5000).toInt()); if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray()); if (qsettings->contains("save_dock_positions")) if (qsettings->contains("dock_positions")) mainwindow->restoreState(qsettings->value("dock_positions").toByteArray()); if (qsettings->contains("theme")) { QString themeStr = qsettings->value("theme").toString(); MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr); if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM) { QString customThemeFilePath = qsettings->value("custom_theme").toString(); mainwindow->setCustomThemeFile(customThemeFilePath); } mainwindow->setTheme(theme); } else mainwindow->setTheme(); if (qsettings->contains("view_type")) { QString viewType = qsettings->value("view_type", "list").toString(); if (viewType == "list") mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); else if (viewType == "icons") mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS); else mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); /* we set it to the same thing a second time so that m_lastViewType is also equal to the startup view type */ mainwindow->setCurrentViewType(mainwindow->getCurrentViewType()); } else mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); /* We make sure to hook up the tab widget callback only after the tabs themselves have been added, * but before changing to a specific one, to avoid the callback firing before the view type is set. */ QObject::connect(browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), mainwindow, SLOT(onTabWidgetIndexChanged(int))); /* setting the last tab must come after setting the view type */ if (qsettings->contains("save_last_tab")) { int lastTabIndex = qsettings->value("last_tab", 0).toInt(); if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex) { browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex); mainwindow->onTabWidgetIndexChanged(lastTabIndex); } } else { browserAndPlaylistTabWidget->setCurrentIndex(0); mainwindow->onTabWidgetIndexChanged(0); } for (i = 0; i < listWidget->count() && listWidget->count() > 0; i++) { /* select the first non-hidden row */ if (!listWidget->isRowHidden(i)) { listWidget->setCurrentRow(i); break; } } return handle; }
MainWindow::MainWindow(const QDir &home) { /*---------------------------------------------------------------------- * Bootstrap *--------------------------------------------------------------------*/ setAttribute(Qt::WA_DeleteOnClose); mainwindows.append(this); // add us to the list of open windows context = new Context(this); context->athlete = new Athlete(context, home); setInstanceName(context->athlete->cyclist); setWindowIcon(QIcon(":images/gc.png")); setWindowTitle(context->athlete->home.dirName()); setContentsMargins(0,0,0,0); setAcceptDrops(true); GCColor *GCColorSet = new GCColor(context); // get/keep colorset GCColorSet->colorSet(); // shut up the compiler #ifdef Q_OS_MAC // get an autorelease pool setup static CocoaInitializer cocoaInitializer; #endif #ifdef GC_HAVE_WFAPI WFApi *w = WFApi::getInstance(); // ensure created on main thread w->apiVersion();//shutup compiler #endif Library::initialise(context->athlete->home); QNetworkProxyQuery npq(QUrl("http://www.google.com")); QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq); if (listOfProxies.count() > 0) { QNetworkProxy::setApplicationProxy(listOfProxies.first()); } if (desktop == NULL) desktop = QApplication::desktop(); static const QIcon hideIcon(":images/toolbar/main/hideside.png"); static const QIcon rhideIcon(":images/toolbar/main/hiderside.png"); static const QIcon showIcon(":images/toolbar/main/showside.png"); static const QIcon rshowIcon(":images/toolbar/main/showrside.png"); static const QIcon tabIcon(":images/toolbar/main/tab.png"); static const QIcon tileIcon(":images/toolbar/main/tile.png"); static const QIcon fullIcon(":images/toolbar/main/togglefull.png"); #if (defined Q_OS_MAC) && (defined GC_HAVE_LION) fullScreen = new LionFullScreen(context); #endif #ifndef Q_OS_MAC fullScreen = new QTFullScreen(context); #endif // if no workout directory is configured, default to the // top level GoldenCheetah directory if (appsettings->value(NULL, GC_WORKOUTDIR).toString() == "") appsettings->setValue(GC_WORKOUTDIR, QFileInfo(context->athlete->home.absolutePath() + "/../").absolutePath()); /*---------------------------------------------------------------------- * GUI setup *--------------------------------------------------------------------*/ // need to restore geometry before setUnifiedToolBar.. on Mac appsettings->setValue(GC_SETTINGS_LAST, context->athlete->home.dirName()); QVariant geom = appsettings->value(this, GC_SETTINGS_MAIN_GEOM); if (geom == QVariant()) { // first run -- lets set some sensible defaults... // lets put it in the middle of screen 1 QRect size = desktop->availableGeometry(); struct SizeSettings app = GCColor::defaultSizes(size.height(), size.width()); // center on the available screen (minus toolbar/sidebar) move((size.width()-size.x())/2 - app.width/2, (size.height()-size.y())/2 - app.height/2); // set to the right default resize(app.width, app.height); // set all the default font sizes appsettings->setValue(GC_FONT_DEFAULT_SIZE, app.defaultFont); appsettings->setValue(GC_FONT_TITLES_SIZE, app.titleFont); appsettings->setValue(GC_FONT_CHARTMARKERS_SIZE, app.markerFont); appsettings->setValue(GC_FONT_CHARTLABELS_SIZE, app.labelFont); appsettings->setValue(GC_FONT_CALENDAR_SIZE, app.calendarFont); appsettings->setValue(GC_FONT_POPUP_SIZE, app.popupFont); // set the default fontsize QFont font; font.setPointSize(app.defaultFont); QApplication::setFont(font); } else { QRect size = desktop->availableGeometry(); // ensure saved geometry isn't greater than current screen size if ((geom.toRect().height() >= size.height()) || (geom.toRect().width() >= size.width())) setGeometry(size.x()+30,size.y()+30,size.width()-60,size.height()-60); else setGeometry(geom.toRect()); } /*---------------------------------------------------------------------- * Mac Toolbar *--------------------------------------------------------------------*/ #ifdef Q_OS_MAC setUnifiedTitleAndToolBarOnMac(true); head = addToolBar(context->athlete->cyclist); head->setContentsMargins(0,0,0,0); // widgets QWidget *macAnalButtons = new QWidget(this); macAnalButtons->setContentsMargins(0,0,20,0); // lhs buttons QHBoxLayout *lb = new QHBoxLayout(macAnalButtons); lb->setContentsMargins(0,0,0,0); lb->setSpacing(0); import = new QtMacButton(this, QtMacButton::TexturedRounded); QPixmap *importImg = new QPixmap(":images/mac/download.png"); import->setImage(importImg); import->setToolTip("Download"); lb->addWidget(import); lb->addWidget(new Spacer(this)); compose = new QtMacButton(this, QtMacButton::TexturedRounded); QPixmap *composeImg = new QPixmap(":images/mac/compose.png"); compose->setImage(composeImg); compose->setToolTip("Create"); lb->addWidget(compose); // connect to actions connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide())); connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide())); lb->addWidget(new Spacer(this)); // activity actions .. peaks, split, delete QWidget *acts = new QWidget(this); acts->setContentsMargins(0,0,0,0); QHBoxLayout *pp = new QHBoxLayout(acts); pp->setContentsMargins(0,0,0,0); pp->setContentsMargins(0,0,0,0); pp->setSpacing(5); sidebar = new QtMacButton(this, QtMacButton::TexturedRounded); QPixmap *sidebarImg = new QPixmap(":images/mac/sidebar.png"); sidebar->setImage(sidebarImg); sidebar->setMinimumSize(25, 25); sidebar->setMaximumSize(25, 25); sidebar->setToolTip("Sidebar"); sidebar->setSelected(true); // assume always start up with sidebar selected actbuttons = new QtMacSegmentedButton(3, acts); actbuttons->setWidth(115); actbuttons->setNoSelect(); actbuttons->setImage(0, new QPixmap(":images/mac/stop.png")); actbuttons->setImage(1, new QPixmap(":images/mac/split.png")); actbuttons->setImage(2, new QPixmap(":images/mac/trash.png")); pp->addWidget(actbuttons); lb->addWidget(acts); lb->addStretch(); connect(actbuttons, SIGNAL(clicked(int,bool)), this, SLOT(actionClicked(int))); lb->addWidget(new Spacer(this)); QWidget *viewsel = new QWidget(this); viewsel->setContentsMargins(0,0,0,0); QHBoxLayout *pq = new QHBoxLayout(viewsel); pq->setContentsMargins(0,0,0,0); pq->setSpacing(5); pq->addWidget(sidebar); styleSelector = new QtMacSegmentedButton(2, viewsel); styleSelector->setWidth(80); // actually its 80 but we want a 30px space between is and the searchbox styleSelector->setImage(0, new QPixmap(":images/mac/tabbed.png"), 24); styleSelector->setImage(1, new QPixmap(":images/mac/tiled.png"), 24); pq->addWidget(styleSelector); connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar())); connect(styleSelector, SIGNAL(clicked(int,bool)), this, SLOT(toggleStyle())); // setup Mac thetoolbar head->addWidget(macAnalButtons); head->addWidget(new Spacer(this)); head->addWidget(new Spacer(this)); head->addWidget(viewsel); #ifdef GC_HAVE_LUCENE SearchFilterBox *searchBox = new SearchFilterBox(this,context,false); QCleanlooksStyle *toolStyle = new QCleanlooksStyle(); searchBox->setStyle(toolStyle); searchBox->setFixedWidth(200); head->addWidget(searchBox); connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); #endif #endif /*---------------------------------------------------------------------- * Windows and Linux Toolbar *--------------------------------------------------------------------*/ #ifndef Q_OS_MAC head = new GcToolBar(this); QCleanlooksStyle *toolStyle = new QCleanlooksStyle(); QPalette metal; metal.setColor(QPalette::Button, QColor(215,215,215)); // get those icons importIcon = iconFromPNG(":images/mac/download.png"); composeIcon = iconFromPNG(":images/mac/compose.png"); intervalIcon = iconFromPNG(":images/mac/stop.png"); splitIcon = iconFromPNG(":images/mac/split.png"); deleteIcon = iconFromPNG(":images/mac/trash.png"); sidebarIcon = iconFromPNG(":images/mac/sidebar.png"); tabbedIcon = iconFromPNG(":images/mac/tabbed.png"); tiledIcon = iconFromPNG(":images/mac/tiled.png"); QSize isize(19,19); Spacer *spacerl = new Spacer(this); spacerl->setFixedWidth(5); import = new QPushButton(this); import->setIcon(importIcon); import->setIconSize(isize); import->setFixedHeight(25); import->setStyle(toolStyle); import->setToolTip(tr("Download from Device")); import->setPalette(metal); connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide())); compose = new QPushButton(this); compose->setIcon(composeIcon); compose->setIconSize(isize); compose->setFixedHeight(25); compose->setStyle(toolStyle); compose->setToolTip(tr("Create Manual Activity")); compose->setPalette(metal); connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide())); sidebar = new QPushButton(this); sidebar->setIcon(sidebarIcon); sidebar->setIconSize(isize); sidebar->setFixedHeight(25); sidebar->setStyle(toolStyle); sidebar->setToolTip(tr("Toggle Sidebar")); sidebar->setPalette(metal); connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar())); actbuttons = new QtSegmentControl(this); actbuttons->setStyle(toolStyle); actbuttons->setIconSize(isize); actbuttons->setCount(3); actbuttons->setSegmentIcon(0, intervalIcon); actbuttons->setSegmentIcon(1, splitIcon); actbuttons->setSegmentIcon(2, deleteIcon); actbuttons->setSelectionBehavior(QtSegmentControl::SelectNone); //wince. spelling. ugh actbuttons->setFixedHeight(25); actbuttons->setSegmentToolTip(0, tr("Find Intervals...")); actbuttons->setSegmentToolTip(1, tr("Split Activity...")); actbuttons->setSegmentToolTip(2, tr("Delete Activity")); actbuttons->setPalette(metal); connect(actbuttons, SIGNAL(segmentSelected(int)), this, SLOT(actionClicked(int))); styleSelector = new QtSegmentControl(this); styleSelector->setStyle(toolStyle); styleSelector->setIconSize(isize); styleSelector->setCount(2); styleSelector->setSegmentIcon(0, tabbedIcon); styleSelector->setSegmentIcon(1, tiledIcon); styleSelector->setSegmentToolTip(0, tr("Tabbed View")); styleSelector->setSegmentToolTip(1, tr("Tiled View")); styleSelector->setSelectionBehavior(QtSegmentControl::SelectOne); //wince. spelling. ugh styleSelector->setFixedHeight(25); styleSelector->setPalette(metal); connect(styleSelector, SIGNAL(segmentSelected(int)), this, SLOT(setStyleFromSegment(int))); //avoid toggle infinitely head->addWidget(spacerl); head->addWidget(import); head->addWidget(compose); head->addWidget(actbuttons); head->addStretch(); head->addWidget(sidebar); head->addWidget(styleSelector); #ifdef GC_HAVE_LUCENE // add a search box on far right, but with a little space too SearchFilterBox *searchBox = new SearchFilterBox(this,context,false); searchBox->setStyle(toolStyle); searchBox->setFixedWidth(200); head->addWidget(searchBox); connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); #endif Spacer *spacer = new Spacer(this); spacer->setFixedWidth(5); head->addWidget(spacer); #endif /*---------------------------------------------------------------------- * ScopeBar *--------------------------------------------------------------------*/ scopebar = new GcScopeBar(context); connect(scopebar, SIGNAL(selectDiary()), this, SLOT(selectDiary())); connect(scopebar, SIGNAL(selectHome()), this, SLOT(selectHome())); connect(scopebar, SIGNAL(selectAnal()), this, SLOT(selectAnalysis())); connect(scopebar, SIGNAL(selectTrain()), this, SLOT(selectTrain())); // Add chart is on the scope bar chartMenu = new QMenu(this); QCleanlooksStyle *styler = new QCleanlooksStyle(); QPushButton *newchart = new QPushButton("+", this); scopebar->addWidget(newchart); newchart->setStyle(styler); newchart->setFixedHeight(20); newchart->setFixedWidth(24); newchart->setFlat(true); newchart->setFocusPolicy(Qt::NoFocus); newchart->setToolTip(tr("Add Chart")); newchart->setAutoFillBackground(false); newchart->setAutoDefault(false); newchart->setMenu(chartMenu); connect(chartMenu, SIGNAL(aboutToShow()), this, SLOT(setChartMenu())); connect(chartMenu, SIGNAL(triggered(QAction*)), this, SLOT(addChart(QAction*))); /*---------------------------------------------------------------------- * Central Widget *--------------------------------------------------------------------*/ tab = new Tab(context); /*---------------------------------------------------------------------- * Central Widget *--------------------------------------------------------------------*/ QWidget *central = new QWidget(this); setContentsMargins(0,0,0,0); central->setContentsMargins(0,0,0,0); QVBoxLayout *mainLayout = new QVBoxLayout(central); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0,0,0,0); #ifndef Q_OS_MAC // nonmac toolbar on main view -- its not // unified with the title bar. mainLayout->addWidget(head); #endif mainLayout->addWidget(scopebar); mainLayout->addWidget(tab); setCentralWidget(central); /*---------------------------------------------------------------------- * Application Menus *--------------------------------------------------------------------*/ #ifdef WIN32 menuBar()->setStyleSheet("QMenuBar { background: rgba(225,225,225); }" "QMenuBar::item { background: rgba(225,225,225); }"); menuBar()->setContentsMargins(0,0,0,0); #endif QMenu *fileMenu = menuBar()->addMenu(tr("&Athlete")); fileMenu->addAction(tr("&New..."), this, SLOT(newCyclist()), tr("Ctrl+N")); fileMenu->addAction(tr("&Open..."), this, SLOT(openCyclist()), tr("Ctrl+O")); fileMenu->addAction(tr("&Close Window"), this, SLOT(close()), tr ("Ctrl+W")); fileMenu->addAction(tr("&Quit All Windows"), this, SLOT(closeAll()), tr("Ctrl+Q")); QMenu *rideMenu = menuBar()->addMenu(tr("A&ctivity")); rideMenu->addAction(tr("&Download from device..."), this, SLOT(downloadRide()), tr("Ctrl+D")); rideMenu->addAction(tr("&Import from file..."), this, SLOT (importFile()), tr ("Ctrl+I")); rideMenu->addAction(tr("&Manual activity entry..."), this, SLOT(manualRide()), tr("Ctrl+M")); rideMenu->addSeparator (); rideMenu->addAction(tr("&Export..."), this, SLOT(exportRide()), tr("Ctrl+E")); rideMenu->addAction(tr("&Batch export..."), this, SLOT(exportBatch()), tr("Ctrl+B")); rideMenu->addAction(tr("Export Metrics as CSV..."), this, SLOT(exportMetrics()), tr("")); #ifdef GC_HAVE_SOAP rideMenu->addSeparator (); rideMenu->addAction(tr("&Upload to TrainingPeaks"), this, SLOT(uploadTP()), tr("Ctrl+U")); rideMenu->addAction(tr("Down&load from TrainingPeaks..."), this, SLOT(downloadTP()), tr("Ctrl+L")); #endif #ifdef GC_HAVE_LIBOAUTH tweetAction = new QAction(tr("Tweet Activity"), this); connect(tweetAction, SIGNAL(triggered(bool)), this, SLOT(tweetRide())); rideMenu->addAction(tweetAction); shareAction = new QAction(tr("Share (Strava, RideWithGPS, CyclingAnalytics)..."), this); connect(shareAction, SIGNAL(triggered(bool)), this, SLOT(share())); rideMenu->addAction(shareAction); #endif ttbAction = new QAction(tr("Upload to Trainingstagebuch..."), this); connect(ttbAction, SIGNAL(triggered(bool)), this, SLOT(uploadTtb())); rideMenu->addAction(ttbAction); rideMenu->addSeparator (); rideMenu->addAction(tr("&Save activity"), this, SLOT(saveRide()), tr("Ctrl+S")); rideMenu->addAction(tr("D&elete activity..."), this, SLOT(deleteRide())); rideMenu->addAction(tr("Split &activity..."), this, SLOT(splitRide())); rideMenu->addAction(tr("Merge activities..."), this, SLOT(mergeRide())); rideMenu->addSeparator (); QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools")); optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions())); optionsMenu->addAction(tr("Critical Power Estimator..."), this, SLOT(showTools())); optionsMenu->addAction(tr("Air Density (Rho) Estimator..."), this, SLOT(showRhoEstimator())); optionsMenu->addSeparator(); optionsMenu->addAction(tr("Get &Withings Data..."), this, SLOT (downloadMeasures())); optionsMenu->addAction(tr("Get &Zeo Data..."), this, SLOT (downloadMeasuresFromZeo())); optionsMenu->addSeparator(); optionsMenu->addAction(tr("Create a new workout..."), this, SLOT(showWorkoutWizard())); optionsMenu->addAction(tr("Download workouts from ErgDB..."), this, SLOT(downloadErgDB())); optionsMenu->addAction(tr("Import workouts or videos..."), this, SLOT(importWorkout())); optionsMenu->addAction(tr("Scan disk for videos and workouts..."), this, SLOT(manageLibrary())); #ifdef GC_HAVE_ICAL optionsMenu->addSeparator(); optionsMenu->addAction(tr("Upload Activity to Calendar"), this, SLOT(uploadCalendar()), tr ("")); //optionsMenu->addAction(tr("Import Calendar..."), this, SLOT(importCalendar()), tr ("")); // planned for v3.1 //optionsMenu->addAction(tr("Export Calendar..."), this, SLOT(exportCalendar()), tr ("")); // planned for v3.1 optionsMenu->addAction(tr("Refresh Calendar"), this, SLOT(refreshCalendar()), tr ("")); #endif optionsMenu->addSeparator(); optionsMenu->addAction(tr("Find intervals..."), this, SLOT(addIntervals()), tr ("")); // Add all the data processors to the tools menu const DataProcessorFactory &factory = DataProcessorFactory::instance(); QMap<QString, DataProcessor*> processors = factory.getProcessors(); if (processors.count()) { optionsMenu->addSeparator(); toolMapper = new QSignalMapper(this); // maps each option QMapIterator<QString, DataProcessor*> i(processors); connect(toolMapper, SIGNAL(mapped(const QString &)), this, SLOT(manualProcess(const QString &))); i.toFront(); while (i.hasNext()) { i.next(); // The localized processor name is shown in menu QAction *action = new QAction(QString("%1...").arg(i.value()->name()), this); optionsMenu->addAction(action); connect(action, SIGNAL(triggered()), toolMapper, SLOT(map())); toolMapper->setMapping(action, i.key()); } }
void App::initMenuBar() { /////////////////////////////////////////////////////////////////// // File Menu m_fileMenu = new QPopupMenu(); m_fileMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/filenew.xpm")), "&New", this, SLOT(slotFileNew()), CTRL+Key_N, ID_FILE_NEW); m_fileMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/fileopen.xpm")), "&Open...", this, SLOT(slotFileOpen()), CTRL+Key_O, ID_FILE_OPEN); m_fileMenu->insertSeparator(); m_fileMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/filesave.xpm")), "&Save", this, SLOT(slotFileSave()), CTRL+Key_S, ID_FILE_SAVE); m_fileMenu->insertItem("Save As...", this, SLOT(slotFileSaveAs()), 0, ID_FILE_SAVE_AS); m_fileMenu->insertSeparator(); m_fileMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/exit.xpm")), "E&xit", this, SLOT(slotFileQuit()), CTRL+Key_Q, ID_FILE_QUIT); /////////////////////////////////////////////////////////////////// // Edit Menu m_editMenu = new QPopupMenu(); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/add.xpm")), "Add &Channel...", this, SLOT(slotEmpty()), CTRL+Key_C, ID_EDIT_ADD_CHANNEL); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/remove.xpm")), "&Remove Channel", this, SLOT(slotEmpty()), CTRL+Key_R, ID_EDIT_REMOVE_CHANNEL); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/edit.xpm")), "Edit C&hannel...", this, SLOT(slotEmpty()), CTRL+Key_H, ID_EDIT_CHANNEL); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/up.xpm")), "Raise Channel", this, SLOT(slotEmpty()), CTRL+Key_Up, ID_EDIT_RAISE_CHANNEL); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/down.xpm")), "Lower Channel", this, SLOT(slotEmpty()), CTRL+Key_Down, ID_EDIT_LOWER_CHANNEL); m_editMenu->insertSeparator(); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/add.xpm")), "&Add Capability...", this, SLOT(slotEmpty()), CTRL+Key_A, ID_EDIT_ADD_CAPABILITY); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/remove.xpm")), "R&emove Capability", this, SLOT(slotEmpty()), CTRL+Key_E, ID_EDIT_REMOVE_CAPABILITY); m_editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/edit.xpm")), "Ed&it Capability...", this, SLOT(slotEmpty()), CTRL+Key_I, ID_EDIT_CAPABILITY); connect(m_editMenu, SIGNAL(activated(int)), this, SLOT(slotEditMenuActivated(int))); connect(m_editMenu, SIGNAL(aboutToShow()), this, SLOT(slotRefreshEditMenu())); /////////////////////////////////////////////////////////////////// // Window Menu m_windowMenu = new QPopupMenu(); connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotRefreshWindowMenu())); /////////////////////////////////////////////////////////////////// // Help menu m_helpMenu = new QPopupMenu(); m_helpMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/help.xpm")), "About...", this, SLOT(slotHelpAbout()), 0, ID_HELP_ABOUT); m_helpMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/qt.xpm")), "About Qt...", this, SLOT(slotHelpAboutQt()), 0, ID_HELP_ABOUT_QT); /////////////////////////////////////////////////////////////////// // Menubar configuration menuBar()->insertItem("File", m_fileMenu); menuBar()->insertItem("Edit", m_editMenu); menuBar()->insertItem("Window", m_windowMenu); menuBar()->insertSeparator(); menuBar()->insertItem("Help", m_helpMenu); menuBar()->setSeparator(QMenuBar::InWindowsStyle); }
styleAction->setChecked(true); //connect(showhideSidebar, SIGNAL(triggered(bool)), this, SLOT(showSidebar(bool))); viewMenu->addSeparator(); viewMenu->addAction(tr("Analysis"), this, SLOT(selectAnalysis())); viewMenu->addAction(tr("Home"), this, SLOT(selectHome())); viewMenu->addAction(tr("Train"), this, SLOT(selectTrain())); #ifdef GC_HAVE_ICAL viewMenu->addAction(tr("Diary"), this, SLOT(selectDiary())); #endif viewMenu->addSeparator(); subChartMenu = viewMenu->addMenu(tr("Add Chart")); viewMenu->addAction(tr("Reset Layout"), this, SLOT(resetWindowLayout())); windowMenu = menuBar()->addMenu(tr("&Window")); connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(setWindowMenu())); connect(rideMenu, SIGNAL(aboutToShow()), this, SLOT(setActivityMenu())); connect(subChartMenu, SIGNAL(aboutToShow()), this, SLOT(setSubChartMenu())); connect(subChartMenu, SIGNAL(triggered(QAction*)), this, SLOT(addChart(QAction*))); connect(windowMenu, SIGNAL(triggered(QAction*)), this, SLOT(selectWindow(QAction*))); QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(tr("&User Guide"), this, SLOT(helpView())); helpMenu->addAction(tr("&Log a bug or feature request"), this, SLOT(logBug())); helpMenu->addSeparator(); helpMenu->addAction(tr("&About GoldenCheetah"), this, SLOT(aboutDialog())); /*---------------------------------------------------------------------- * Lets go, choose latest ride and get GUI up and running *--------------------------------------------------------------------*/
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); // setup the docking widgets controlWidget = new ControlWidget(this); propertyWidget = new PropertyWidget(this); // setup the toolbar ui.fileToolBar->addAction(ui.actionNewTerrain); ui.fileToolBar->addAction(ui.actionOpenTerrain); ui.areaToolBar->addAction(ui.actionAreaSelect); ui.areaToolBar->addAction(ui.actionAreaCreate); ui.areaToolBar->addAction(ui.actionHintLine); ui.areaToolBar->addAction(ui.actionAvenueSketch); ui.actionAreaSelect->setChecked(true); // register the menu's action handlers connect(ui.actionNewTerrain, SIGNAL(triggered()), this, SLOT(onNewTerrain())); connect(ui.actionOpenTerrain, SIGNAL(triggered()), this, SLOT(onLoadTerrain())); connect(ui.actionSaveTerrain, SIGNAL(triggered()), this, SLOT(onSaveTerrain())); connect(ui.actionLoadRoads, SIGNAL(triggered()), this, SLOT(onLoadRoads())); connect(ui.actionAddRoads, SIGNAL(triggered()), this, SLOT(onAddRoads())); connect(ui.actionSaveRoads, SIGNAL(triggered()), this, SLOT(onSaveRoads())); connect(ui.actionClearRoads, SIGNAL(triggered()), this, SLOT(onClearRoads())); connect(ui.actionLoadAreas, SIGNAL(triggered()), this, SLOT(onLoadAreas())); connect(ui.actionSaveAreas, SIGNAL(triggered()), this, SLOT(onSaveAreas())); connect(ui.actionSaveImage, SIGNAL(triggered()), this, SLOT(onSaveImage())); connect(ui.actionSaveImageHD, SIGNAL(triggered()), this, SLOT(onSaveImageHD())); connect(ui.actionLoadCamera, SIGNAL(triggered()), this, SLOT(onLoadCamera())); connect(ui.actionSaveCamera, SIGNAL(triggered()), this, SLOT(onSaveCamera())); connect(ui.actionResetCamera, SIGNAL(triggered()), this, SLOT(onResetCamera())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.menuArea, SIGNAL(aboutToShow()), this, SLOT(onAreaMenu())); connect(ui.actionAreaSelect, SIGNAL(triggered()), this, SLOT(onAreaSelect())); connect(ui.actionAreaCreate, SIGNAL(triggered()), this, SLOT(onAreaCreate())); connect(ui.actionAreaDelete, SIGNAL(triggered()), this, SLOT(onAreaDelete())); connect(ui.actionAreaDeleteAll, SIGNAL(triggered()), this, SLOT(onAreaDeleteAll())); connect(ui.actionHintLine, SIGNAL(triggered()), this, SLOT(onHintLine())); connect(ui.actionCutRoads, SIGNAL(triggered()), this, SLOT(onCutRoads())); connect(ui.actionHighwaySketch, SIGNAL(triggered()), this, SLOT(onHighwaySketch())); connect(ui.actionAvenueSketch, SIGNAL(triggered()), this, SLOT(onAvenueSketch())); connect(ui.actionStreetSketch, SIGNAL(triggered()), this, SLOT(onStreetSketch())); connect(ui.actionControlPoints, SIGNAL(triggered()), this, SLOT(onControlPoints())); connect(ui.actionGenerateBlocks, SIGNAL(triggered()), this, SLOT(onGenerateBlocks())); connect(ui.actionGenerateParcels, SIGNAL(triggered()), this, SLOT(onGenerateParcels())); connect(ui.actionGenerateBuildings, SIGNAL(triggered()), this, SLOT(onGenerateBuildings())); connect(ui.actionGenerateVegetation, SIGNAL(triggered()), this, SLOT(onGenerateVegetation())); connect(ui.actionGenerateAll, SIGNAL(triggered()), this, SLOT(onGenerateAll())); connect(ui.actionGenerateRegularGrid, SIGNAL(triggered()), this, SLOT(onGenerateRegularGrid())); connect(ui.actionGenerateCurvyGrid, SIGNAL(triggered()), this, SLOT(onGenerateCurvyGrid())); connect(ui.actionRotationVideo, SIGNAL(triggered()), this, SLOT(onRotationVideo())); connect(ui.actionInterpolationVideo, SIGNAL(triggered()), this, SLOT(onInterpolationVideo())); connect(ui.actionBlendingVideo, SIGNAL(triggered()), this, SLOT(onBlendingVideo())); connect(ui.actionGrowingVideo, SIGNAL(triggered()), this, SLOT(onGrowingVideo())); connect(ui.action3DVideo, SIGNAL(triggered()), this, SLOT(on3DVideo())); connect(ui.actionMountainVideo, SIGNAL(triggered()), this, SLOT(onMountainVideo())); connect(ui.actionTerrainGeneration, SIGNAL(triggered()), this, SLOT(onTerrainGeneration())); connect(ui.actionUpdateMountain, SIGNAL(triggered()), this, SLOT(onUpdateMountain())); connect(ui.actionTerrainSegmentation, SIGNAL(triggered()), this, SLOT(onTerrainSegmentation())); connect(ui.actionExtractContour, SIGNAL(triggered()), this, SLOT(onExtractContour())); connect(ui.actionTerrainDataConverter, SIGNAL(triggered()), this, SLOT(onTerrainDataConverter())); connect(ui.actionTerrainDataConverter2, SIGNAL(triggered()), this, SLOT(onTerrainDataConverter2())); connect(ui.actionCamera3D, SIGNAL(triggered()), this, SLOT(onCamera3D())); connect(ui.actionCameraFlyOver, SIGNAL(triggered()), this, SLOT(onCameraFlyOver())); connect(ui.actionControlWidget, SIGNAL(triggered()), this, SLOT(onShowControlWidget())); connect(ui.actionPropertyWidget, SIGNAL(triggered()), this, SLOT(onShowPropertyWidget())); connect(ui.actionDebug, SIGNAL(triggered()), this, SLOT(onDebug())); // setup the GL widget glWidget = new GLWidget3D(this); setCentralWidget(glWidget); controlWidget->show(); addDockWidget(Qt::LeftDockWidgetArea, controlWidget); urbanGeometry = new UrbanGeometry(this); mode = MODE_AREA_SELECT; }
Menu::Menu(MenuRole role, QWidget *parent) : QMenu(parent), m_actionGroup(NULL), m_bookmark(NULL), m_role(role) { switch (role) { case BookmarksMenuRole: case BookmarkSelectorMenuRole: case NotesMenuRole: { installEventFilter(this); Menu *parentMenu = qobject_cast<Menu*>(parent); if (!parentMenu || parentMenu->getRole() != m_role) { if (m_role == NotesMenuRole) { connect(NotesManager::getModel(), SIGNAL(modelModified()), this, SLOT(clearModelMenu())); } else { connect(BookmarksManager::getModel(), SIGNAL(modelModified()), this, SLOT(clearModelMenu())); } } connect(this, SIGNAL(aboutToShow()), this, SLOT(populateModelMenu())); } break; case CharacterEncodingMenuRole: connect(this, SIGNAL(aboutToShow()), this, SLOT(populateCharacterEncodingMenu())); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(selectCharacterEncoding(QAction*))); break; case ClosedWindowsMenu: { setIcon(Utils::getIcon(QLatin1String("user-trash"))); MainWindow *mainWindow = MainWindow::findMainWindow(parent); if (mainWindow) { setEnabled(!SessionsManager::getClosedWindows().isEmpty() || !mainWindow->getWindowsManager()->getClosedWindows().isEmpty()); connect(mainWindow->getWindowsManager(), SIGNAL(closedWindowsAvailableChanged(bool)), this, SLOT(updateClosedWindowsMenu())); } connect(SessionsManager::getInstance(), SIGNAL(closedWindowsChanged()), this, SLOT(updateClosedWindowsMenu())); connect(this, SIGNAL(aboutToShow()), this, SLOT(populateClosedWindowsMenu())); } break; case ImportExportMenuRole: QMenu::addAction(tr("Import Opera Bookmarks…"))->setData(QLatin1String("OperaBookmarks")); QMenu::addAction(tr("Import HTML Bookmarks…"))->setData(QLatin1String("HtmlBookmarks")); QMenu::addSeparator(); QMenu::addAction(tr("Import Opera Notes…"))->setData(QLatin1String("OperaNotes")); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(openImporter(QAction*))); break; case SessionsMenuRole: connect(this, SIGNAL(aboutToShow()), this, SLOT(populateSessionsMenu())); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(openSession(QAction*))); break; case ToolBarsMenuRole: connect(this, SIGNAL(aboutToShow()), this, SLOT(populateToolBarsMenu())); break; case UserAgentMenuRole: connect(this, SIGNAL(aboutToShow()), this, SLOT(populateUserAgentMenu())); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(selectUserAgent(QAction*))); break; case WindowsMenuRole: connect(this, SIGNAL(aboutToShow()), this, SLOT(populateWindowsMenu())); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(selectWindow(QAction*))); break; default: break; } }
KateCTagsView::KateCTagsView(Kate::MainWindow *mw, const KComponentData& componentData) : Kate::PluginView (mw) , Kate::XMLGUIClient(componentData) , m_toolView (mw->createToolView ("kate_private_plugin_katectagsplugin", Kate::MainWindow::Bottom, SmallIcon("application-x-ms-dos-executable"), i18n("CTags")) ) , m_proc(0) { m_mWin = mw; KAction *back = actionCollection()->addAction("ctags_return_step"); back->setText(i18n("Jump back one step")); back->setShortcut(QKeySequence(Qt::ALT+Qt::Key_1) ); connect(back, SIGNAL(triggered(bool)), this, SLOT(stepBack())); KAction *decl = actionCollection()->addAction("ctags_lookup_current_as_declaration"); decl->setText(i18n("Go to Declaration")); decl->setShortcut(QKeySequence(Qt::ALT+Qt::Key_2) ); connect(decl, SIGNAL(triggered(bool)), this, SLOT(gotoDeclaration())); KAction *defin = actionCollection()->addAction("ctags_lookup_current_as_definition"); defin->setText(i18n("Go to Definition")); defin->setShortcut(QKeySequence(Qt::ALT+Qt::Key_3) ); connect(defin, SIGNAL(triggered(bool)), this, SLOT(gotoDefinition())); KAction *lookup = actionCollection()->addAction("ctags_lookup_current"); lookup->setText(i18n("Lookup Current Text")); lookup->setShortcut(QKeySequence(Qt::ALT+Qt::Key_4) ); connect(lookup, SIGNAL(triggered(bool)), this, SLOT(lookupTag())); // popup menu m_menu = new KActionMenu(i18n("CTags"), this); actionCollection()->addAction("popup_ctags", m_menu); m_gotoDec=m_menu->menu()->addAction(i18n("Go to Declaration: %1",QString()), this, SLOT(gotoDeclaration())); m_gotoDef=m_menu->menu()->addAction(i18n("Go to Definition: %1",QString()), this, SLOT(gotoDefinition())); m_lookup=m_menu->menu()->addAction(i18n("Lookup: %1",QString()), this, SLOT(lookupTag())); connect(m_menu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); QWidget *ctagsWidget = new QWidget(m_toolView); m_ctagsUi.setupUi(ctagsWidget); m_ctagsUi.cmdEdit->setText(DEFAULT_CTAGS_CMD); m_ctagsUi.addButton->setToolTip(i18n("Add a directory to index.")); m_ctagsUi.addButton->setIcon(KIcon("list-add")); m_ctagsUi.delButton->setToolTip(i18n("Remove a directory.")); m_ctagsUi.delButton->setIcon(KIcon("list-remove")); m_ctagsUi.updateButton->setToolTip(i18n("(Re-)generate the session specific CTags database.")); m_ctagsUi.updateButton->setIcon(KIcon("view-refresh")); m_ctagsUi.updateButton2->setToolTip(i18n("(Re-)generate the session specific CTags database.")); m_ctagsUi.updateButton2->setIcon(KIcon("view-refresh")); m_ctagsUi.resetCMD->setIcon(KIcon("view-refresh")); m_ctagsUi.tagsFile->setToolTip(i18n("Select new or existing database file.")); connect(m_ctagsUi.resetCMD, SIGNAL(clicked()), this, SLOT(resetCMD())); connect(m_ctagsUi.addButton, SIGNAL(clicked()), this, SLOT(addTagTarget())); connect(m_ctagsUi.delButton, SIGNAL(clicked()), this, SLOT(delTagTarget())); connect(m_ctagsUi.updateButton, SIGNAL(clicked()), this, SLOT(updateSessionDB())); connect(m_ctagsUi.updateButton2, SIGNAL(clicked()), this, SLOT(updateSessionDB())); connect(&m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(updateDone(int,QProcess::ExitStatus))); connect(m_ctagsUi.inputEdit, SIGNAL(textChanged(QString)), this, SLOT(startEditTmr())); m_editTimer.setSingleShot(true); connect(&m_editTimer, SIGNAL(timeout()), this, SLOT(editLookUp())); connect(m_ctagsUi.tagTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SLOT(tagHitClicked(QTreeWidgetItem*))); m_toolView->installEventFilter(this); mainWindow()->guiFactory()->addClient(this); m_commonDB = KStandardDirs::locateLocal("appdata", "plugins/katectags/common_db", true); }
void PanelKMenu::initialize() { // kdDebug(1210) << "PanelKMenu::initialize()" << endl; updateRecent(); if (initialized()) { return; } if (loadSidePixmap()) { // in case we've been through here before, let's disconnect disconnect(kapp, SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); connect(kapp, SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); } else { sidePixmap = sideTilePixmap = QPixmap(); } // add services PanelServiceMenu::initialize(); if (KickerSettings::showMenuTitles()) { int id; id = insertItem(new PopupMenuTitle(i18n("All Applications"), font()), -1 /* id */, 0); setItemEnabled( id, false ); id = insertItem(new PopupMenuTitle(i18n("Actions"), font()), -1 /* id */, -1); setItemEnabled( id, false ); } // create recent menu section createRecentMenuItems(); bool need_separator = false; // insert bookmarks if (KickerSettings::useBookmarks() && kapp->authorizeKAction("bookmarks")) { // Need to create a new popup each time, it's deleted by subMenus.clear() KPopupMenu * bookmarkParent = new KPopupMenu( this, "bookmarks" ); if(!bookmarkOwner) bookmarkOwner = new KBookmarkOwner; delete bookmarkMenu; // can't reuse old one, the popup has been deleted bookmarkMenu = new KBookmarkMenu( KonqBookmarkManager::self(), bookmarkOwner, bookmarkParent, actionCollection, true, false ); insertItem(KickerLib::menuIconSet("bookmark"), i18n("Bookmarks"), bookmarkParent); subMenus.append(bookmarkParent); need_separator = true; } // insert quickbrowser if (KickerSettings::useBrowser()) { PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this); browserMnu->initialize(); insertItem(KickerLib::menuIconSet("kdisknav"), i18n("Quick Browser"), KickerLib::reduceMenu(browserMnu)); subMenus.append(browserMnu); need_separator = true; } // insert dynamic menus QStringList menu_ext = KickerSettings::menuExtensions(); if (!menu_ext.isEmpty()) { for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it) { MenuInfo info(*it); if (!info.isValid()) continue; KPanelMenu *menu = info.load(); if (menu) { insertItem(KickerLib::menuIconSet(info.icon()), info.name(), menu); dynamicSubMenus.append(menu); need_separator = true; } } } if (need_separator) insertSeparator(); // insert client menus, if any if (clients.count() > 0) { QIntDictIterator<KickerClientMenu> it(clients); while (it){ if (it.current()->text.at(0) != '.') insertItem( it.current()->icon, it.current()->text, it.current(), it.currentKey() ); ++it; } insertSeparator(); } // run command if (kapp->authorize("run_command")) { insertItem(KickerLib::menuIconSet("run"), i18n("Run Command..."), this, SLOT( slotRunCommand())); insertSeparator(); } if (DM().isSwitchable() && kapp->authorize("switch_user")) { sessionsMenu = new QPopupMenu( this ); insertItem(KickerLib::menuIconSet("switchuser"), i18n("Switch User"), sessionsMenu); connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) ); connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) ); } /* If the user configured ksmserver to */ KConfig ksmserver("ksmserverrc", false, false); ksmserver.setGroup("General"); if (ksmserver.readEntry( "loginMode" ) == "restoreSavedSession") { insertItem(KickerLib::menuIconSet("filesave"), i18n("Save Session"), this, SLOT(slotSaveSession())); } if (kapp->authorize("lock_screen")) { insertItem(KickerLib::menuIconSet("lock"), i18n("Lock Session"), this, SLOT(slotLock())); } if (kapp->authorize("logout")) { insertItem(KickerLib::menuIconSet("exit"), i18n("Log Out..."), this, SLOT(slotLogout())); } #if 0 // WABA: tear off handles don't work together with dynamically updated // menus. We can't update the menu while torn off, and we don't know // when it is torn off. if (KGlobalSettings::insertTearOffHandle()) insertTearOffHandle(); #endif setInitialized(true); }
//------------------------------------------------------------------------------ QWidget *FeedPropertiesDialog::createColumnsTab() { QWidget *tab = new QWidget(); columnsTree_ = new QTreeWidget(this); columnsTree_->setObjectName("columnsTree"); columnsTree_->setIndentation(0); columnsTree_->setColumnCount(2); columnsTree_->setColumnHidden(1, true); columnsTree_->setSortingEnabled(false); columnsTree_->setHeaderHidden(true); #ifdef HAVE_QT5 columnsTree_->header()->setSectionResizeMode(0, QHeaderView::Stretch); #else columnsTree_->header()->setResizeMode(0, QHeaderView::Stretch); #endif QStringList treeItem; treeItem << "Name" << "Index"; columnsTree_->setHeaderLabels(treeItem); sortByColumnBox_ = new QComboBox(this); sortOrderBox_ = new QComboBox(this); treeItem.clear(); treeItem << tr("Ascending") << tr("Descending"); sortOrderBox_->addItems(treeItem); QHBoxLayout *styleLayout = new QHBoxLayout(); styleLayout->setMargin(0); styleLayout->addWidget(new QLabel(tr("Sort by:"))); styleLayout->addWidget(sortByColumnBox_); styleLayout->addSpacing(10); styleLayout->addWidget(sortOrderBox_); styleLayout->addStretch(); QWidget *styleWidget = new QWidget(this); styleWidget->setLayout(styleLayout); QVBoxLayout *mainVLayout = new QVBoxLayout(); mainVLayout->addWidget(columnsTree_, 1); mainVLayout->addWidget(styleWidget); addButtonMenu_ = new QMenu(this); addButton_ = new QPushButton(tr("Add")); addButton_->setMenu(addButtonMenu_); connect(addButtonMenu_, SIGNAL(aboutToShow()), this, SLOT(showMenuAddButton())); connect(addButtonMenu_, SIGNAL(triggered(QAction*)), this, SLOT(addColumn(QAction*))); removeButton_ = new QPushButton(tr("Remove")); removeButton_->setEnabled(false); connect(removeButton_, SIGNAL(clicked()), this, SLOT(removeColumn())); moveUpButton_ = new QPushButton(tr("Move up")); moveUpButton_->setEnabled(false); connect(moveUpButton_, SIGNAL(clicked()), this, SLOT(moveUpColumn())); moveDownButton_ = new QPushButton(tr("Move down")); moveDownButton_->setEnabled(false); connect(moveDownButton_, SIGNAL(clicked()), this, SLOT(moveDownColumn())); QPushButton *defaultButton = new QPushButton(tr("Default")); connect(defaultButton, SIGNAL(clicked()), this, SLOT(defaultColumns())); QVBoxLayout *buttonsVLayout = new QVBoxLayout(); buttonsVLayout->addWidget(addButton_); buttonsVLayout->addWidget(removeButton_); buttonsVLayout->addSpacing(10); buttonsVLayout->addWidget(moveUpButton_); buttonsVLayout->addWidget(moveDownButton_); buttonsVLayout->addSpacing(10); buttonsVLayout->addWidget(defaultButton); buttonsVLayout->addStretch(); QHBoxLayout *tabLayout = new QHBoxLayout(tab); tabLayout->setMargin(10); tabLayout->setSpacing(5); tabLayout->addLayout(mainVLayout); tabLayout->addLayout(buttonsVLayout); connect(columnsTree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(slotCurrentColumnChanged(QTreeWidgetItem*,QTreeWidgetItem*))); return tab; }
LDViewMainWindow::LDViewMainWindow(QApplication *a) :QMainWindow(),Ui::LDView(), fileSeparatorIndex(-1), toolbarMaxStep(new QLabel), toolbarCurrentStep(new QLabel), toolbarStepLabel(new QLabel("Step :")), toolbarViewAngle(NULL), toolbarWireframeMenu(new QMenu(this)), edgeMenu(new QMenu(this)), bfcMenu(new QMenu(this)), primitiveMenu(new QMenu(this)) { setupUi(this); toolbar->insertWidget(toolbarFirstStep,toolbarStepLabel); toolbar->insertWidget(toolbarFirstStep,toolbarCurrentStep); toolbar->insertWidget(toolbarFirstStep,toolbarMaxStep); if (modelViewer) modelViewer->setMainWindow(this); connect( fileOpenAction, SIGNAL( triggered() ), this, SLOT( fileOpen() ) ); connect( fileSaveSettingsAction, SIGNAL( triggered() ), this, SLOT( fileSaveSettings() ) ); connect( fileExportAction, SIGNAL( triggered() ), this, SLOT( fileExport() ) ); connect( fileExportOptionAction, SIGNAL( triggered() ), this, SLOT( fileExportOption() ) ); connect( file3DSExportOptionAction, SIGNAL( triggered() ), this, SLOT( file3DSExportOption() ) ); connect( fileJPEGOptionsAction, SIGNAL( triggered() ), this, SLOT( fileJPEGOptions() ) ); connect( fileSaveAction, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); connect( filePrintAction, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); connect( fileExitAction, SIGNAL( triggered() ), this, SLOT( fileExit() ) ); connect( helpContentsAction, SIGNAL( triggered() ), this, SLOT( helpContents() ) ); connect( helpAboutAction, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); connect( helpAboutQtAction, SIGNAL( triggered() ), this, SLOT( helpAboutQt() ) ); connect( editPreferencesAction, SIGNAL( triggered() ), this, SLOT( editPreferences() ) ); connect( viewToolBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewToolBar(bool) ) ); connect( toolbarWireframeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframe(bool) ) ); connect( toolbarEdgeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarEdge(bool) ) ); connect( toolbarPrimitiveSubstitutionAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarPrimitiveSubstitution(bool) ) ); connect( toolbarLightingAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarLighting(bool) ) ); connect( toolbarBFCAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarBFC(bool) ) ); connect( toolbarAxesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarAxes(bool) ) ); connect( toolbarSeamsAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarSeams(bool) ) ); connect( viewStatusBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewStatusBar(bool) ) ); connect( viewLatitudeRotationAction, SIGNAL( toggled(bool) ), this, SLOT( latitudeRotation(bool) ) ); connect( viewKeepRightSideUpAction, SIGNAL( toggled(bool) ), this, SLOT( keepRightSideUp(bool) ) ); connect( viewFullScreenAction, SIGNAL( triggered() ), this, SLOT( viewFullScreen() ) ); connect( viewResetViewAction, SIGNAL( triggered() ), this, SLOT( viewResetView() ) ); connect( helpOpenGLDriverInfoAction, SIGNAL( triggered() ), this, SLOT( helpOpenGLDriverInfo() ) ); connect( fileLDrawDirAction, SIGNAL( triggered() ), this, SLOT( fileLDrawDir() ) ); connect( fileExtraDirAction, SIGNAL( triggered() ), this, SLOT( fileExtraDir() ) ); connect( fileCheckForUpdatesAction, SIGNAL( triggered() ), this, SLOT( fileCheckForUpdates() ) ); connect( fileReloadAction, SIGNAL( triggered() ), this, SLOT( fileReload() ) ); connect( viewShowErrorsAction, SIGNAL( triggered() ), this, SLOT( viewShowErrors() ) ); connect( pollActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( pollChanged(QAction*) ) ); connect( viewZoomToFitAction, SIGNAL( triggered() ), this, SLOT( viewZoomToFit() ) ); connect( viewRightSideUpAction, SIGNAL( triggered() ), this, SLOT( viewRightSideUp() ) ); connect( viewModeActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( viewModeChanged(QAction*) ) ); connect( frontViewAngleAction, SIGNAL( triggered() ), this, SLOT( frontViewAngle() ) ); connect( backViewAngleAction, SIGNAL( triggered() ), this, SLOT( backViewAngle() ) ); connect( leftViewAngleAction, SIGNAL( triggered() ), this, SLOT( leftViewAngle() ) ); connect( rightViewAngleAction, SIGNAL( triggered() ), this, SLOT( rightViewAngle() ) ); connect( topViewAngleAction, SIGNAL( triggered() ), this, SLOT( topViewAngle() ) ); connect( bottomViewAngleAction, SIGNAL( triggered() ), this, SLOT( bottomViewAngle() ) ); connect( latLongViewAngleAction, SIGNAL( triggered() ), this, SLOT( latLongViewAngle() ) ); connect( isoViewAngleAction, SIGNAL( triggered() ), this, SLOT( isoViewAngle() ) ); connect( saveDefaultViewAngleAction, SIGNAL( triggered() ), this, SLOT( saveDefaultViewAngle() ) ); connect( fileCancelLoadAction, SIGNAL( triggered() ), this, SLOT( fileCancelLoad() ) ); connect( showViewInfoAction, SIGNAL( triggered() ), this, SLOT( showViewInfo() ) ); connect( showPovCameraAction, SIGNAL( triggered() ), this, SLOT( showPovCamera() ) ); connect( showPovAspectRatioAction, SIGNAL( toggled(bool) ), this, SLOT( showPovAspectRatio(bool) ) ); connect( toolsPartListAction, SIGNAL( triggered() ), this, SLOT( toolsPartList() ) ); connect( toolbarPrevStep, SIGNAL( triggered() ), this, SLOT( prevStep() ) ); connect( toolbarNextStep, SIGNAL( triggered() ), this, SLOT( nextStep() ) ); connect( toolbarFirstStep, SIGNAL( triggered() ), this, SLOT( firstStep() ) ); connect( toolbarLastStep, SIGNAL( triggered() ), this, SLOT( lastStep() ) ); connect( stepGoto, SIGNAL( triggered() ), this, SLOT( gotoStep() ) ); connect( toolsModelTreeAction, SIGNAL( triggered() ), this, SLOT( toolsModelTree() ) ); connect( toolsBoundingBoxAction, SIGNAL( triggered() ), this, SLOT( toolsBoundingBox() ) ); connect( toolsMpdModelSelectionAction, SIGNAL( triggered() ), this, SLOT( toolsMpdModelSelection() ) ); connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(doFileMenuAboutToShow())); connect(editMenu, SIGNAL(aboutToShow()), this, SLOT(doEditMenuAboutToShow())); connect(viewMenu, SIGNAL(aboutToShow()), this, SLOT(doViewMenuAboutToShow())); connect(toolsMenu,SIGNAL(aboutToShow()), this, SLOT(doToolsMenuAboutToShow())); connect(helpMenu, SIGNAL(aboutToShow()), this, SLOT(doHelpMenuAboutToShow())); int cnt,i; QAction *item; for ( cnt = i = 0; ; i++) { item = fileMenu->actions()[i]; if (item->isSeparator()) { if (++cnt == 2) break; } } fileSeparatorIndex = i; #ifdef __APPLE__ fileMenu->removeItemAt(fileSeparatorIndex); fileSeparatorIndex = -1; openRecentMenu = new QMenu(this, "openRecentMenu"); fileMenu->insertItem("Open Recent", openRecentMenu, -1, 1); #endif // __APPLE__ if (!recentFiles) { recentFiles = new TCStringArray(10); populateRecentFiles(); } populateRecentFileMenuItems(); setupStandardSizes(); #ifdef __APPLE__ // Since Preferences is the only item in the edit menu, we need to // delete the edit menu on the Mac, since the item is going to get // magically moved to the LDView menu. The problem is, if we delete // the edit menu, the magic stops working, since it's apparently all // done on the fly. So, we're going to create a new fully-functional // Preferences menu item at the top of the File menu, and THEN delete // the edit menu. This newly created menu item won't be visible to the // user, but it will make the other one continue to function after the // deletion of the edit menu. fileMenu->insertItem("Preferences", this, SLOT(doPreferences()), 0, -1, 0); // Remove the (empty without Preferences) edit menu. menuBar->removeItem(menuBar->idAt(1)); #endif //__APPLE__ toolbarViewAngle = new QToolButton(toolbar); toolbarViewAngle->setMenu(viewingAnglePopupMenu); toolbarViewAngle->setPopupMode(QToolButton::InstantPopup); toolbarViewAngle->setIcon(QPixmap( ":/images/images/toolbar_view.png")); toolbarViewAngle->setEnabled(false); toolbar->insertWidget(editPreferencesAction,toolbarViewAngle); connect( wireframeFogAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeFog(bool) ) ); connect( wireframeRemoveHiddenLinesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeRemoveHiddenLines(bool) ) ); toolbarWireframeMenu->addAction(wireframeFogAction); toolbarWireframeMenu->addAction(wireframeRemoveHiddenLinesAction); QToolButton *toolbarWireframe = (QToolButton *)toolbar->widgetForAction(toolbarWireframeAction); if (toolbarWireframe != NULL) { toolbarWireframe->setMenu(toolbarWireframeMenu); toolbarWireframe->setPopupMode(QToolButton::MenuButtonPopup); } connect( textureStudAction, SIGNAL( toggled(bool) ), this, SLOT( textureStud(bool) ) ); primitiveMenu->addAction(textureStudAction); QToolButton *toolbarPrimitives = (QToolButton *)toolbar->widgetForAction(toolbarPrimitiveSubstitutionAction); if (toolbarPrimitives) { toolbarPrimitives->setMenu(primitiveMenu); toolbarPrimitives->setPopupMode(QToolButton::MenuButtonPopup); } connect( edgeShowEdgeOnlyAction, SIGNAL( toggled(bool) ), this, SLOT( edgeShowEdgeOnly(bool) ) ); connect( edgeConditionalLineAction, SIGNAL( toggled(bool) ), this, SLOT( edgeConditionalLine(bool) ) ); connect( edgeHighQualityAction, SIGNAL( toggled(bool) ), this, SLOT( edgeHighQuality(bool) ) ); connect( edgeAlwaysBlackAction, SIGNAL( toggled(bool) ), this, SLOT( edgeAlwaysBlack(bool) ) ); edgeMenu->addAction(edgeShowEdgeOnlyAction); edgeMenu->addAction(edgeConditionalLineAction); edgeMenu->addAction(edgeHighQualityAction); edgeMenu->addAction(edgeAlwaysBlackAction); QToolButton *toolbarEdge = (QToolButton *)toolbar->widgetForAction(toolbarEdgeAction); if (toolbarEdge) { toolbarEdge->setMenu(edgeMenu); toolbarEdge->setPopupMode(QToolButton::MenuButtonPopup); } connect( bfcRedBackFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcRedBackFaces(bool) ) ); connect( bfcGreenFrontFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcGreenFrontFaces(bool) ) ); connect( bfcBlueNeutralFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcBlueNeutralFaces(bool) ) ); bfcMenu->addAction(bfcRedBackFacesAction); bfcMenu->addAction(bfcGreenFrontFacesAction); bfcMenu->addAction(bfcBlueNeutralFacesAction); QToolButton *toolbarBfc = (QToolButton *)toolbar->widgetForAction(toolbarBFCAction); if (toolbarBfc) { toolbarBfc->setMenu(bfcMenu); toolbarBfc->setPopupMode(QToolButton::MenuButtonPopup); } modelViewer->setApplication(a); }
MainGui::MainGui(QWidget *p) : QMainWindow(p), currenthdr(NULL) { setupUi(this); setAcceptDrops(true); //main toolbar setup QActionGroup *toolBarOptsGroup = new QActionGroup(this); toolBarOptsGroup->addAction(actionText_Under_Icons); toolBarOptsGroup->addAction(actionIcons_Only); toolBarOptsGroup->addAction(actionText_Alongside_Icons); toolBarOptsGroup->addAction(actionText_Only); menuToolbars->addAction(toolBar->toggleViewAction()); mdiArea = new QMdiArea(this); mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setBackground(QBrush(QColor::fromRgb(192, 192, 192)) ); setCentralWidget(mdiArea); qtpfsgui_options=QtpfsguiOptions::getInstance(); load_options(); setWindowTitle("Qtpfsgui "QTPFSGUIVERSION); connect(mdiArea,SIGNAL(subWindowActivated(QMdiSubWindow*)),this,SLOT(updateActions(QMdiSubWindow*))); connect(fileNewAction, SIGNAL(triggered()), this, SLOT(fileNewViaWizard())); connect(fileOpenAction, SIGNAL(triggered()), this, SLOT(fileOpen())); connect(fileSaveAsAction, SIGNAL(triggered()), this, SLOT(fileSaveAs())); connect(TonemapAction, SIGNAL(triggered()), this, SLOT(tonemap_requested())); connect(rotateccw, SIGNAL(triggered()), this, SLOT(rotateccw_requested())); connect(rotatecw, SIGNAL(triggered()), this, SLOT(rotatecw_requested())); connect(actionResizeHDR, SIGNAL(triggered()), this, SLOT(resize_requested())); connect(action_Projective_Transformation, SIGNAL(triggered()), this, SLOT(projectiveTransf_requested())); connect(actionBatch_Tone_Mapping, SIGNAL(triggered()), this, SLOT(batch_requested())); connect(Low_dynamic_range,SIGNAL(triggered()),this,SLOT(current_mdi_ldr_exp())); connect(Fit_to_dynamic_range,SIGNAL(triggered()),this,SLOT(current_mdi_fit_exp())); connect(Shrink_dynamic_range,SIGNAL(triggered()),this,SLOT(current_mdi_shrink_exp())); connect(Extend_dynamic_range,SIGNAL(triggered()),this,SLOT(current_mdi_extend_exp())); connect(Decrease_exposure,SIGNAL(triggered()),this,SLOT(current_mdi_decrease_exp())); connect(Increase_exposure,SIGNAL(triggered()),this,SLOT(current_mdi_increase_exp())); connect(zoomInAct,SIGNAL(triggered()),this,SLOT(current_mdi_zoomin())); connect(zoomOutAct,SIGNAL(triggered()),this,SLOT(current_mdi_zoomout())); connect(fitToWindowAct,SIGNAL(toggled(bool)),this,SLOT(current_mdi_fit_to_win(bool))); connect(normalSizeAct,SIGNAL(triggered()),this,SLOT(current_mdi_original_size())); connect(documentationAction,SIGNAL(triggered()),this,SLOT(openDocumentation())); connect(actionWhat_s_This,SIGNAL(triggered()),this,SLOT(enterWhatsThis())); connect(actionAbout_Qt,SIGNAL(triggered()),qApp,SLOT(aboutQt())); connect(actionAbout_Qtpfsgui,SIGNAL(triggered()),this,SLOT(aboutQtpfsgui())); connect(OptionsAction,SIGNAL(triggered()),this,SLOT(preferences_called())); connect(Transplant_Exif_Data_action,SIGNAL(triggered()),this,SLOT(transplant_called())); connect(actionTile,SIGNAL(triggered()),mdiArea,SLOT(tileSubWindows())); connect(actionCascade,SIGNAL(triggered()),mdiArea,SLOT(cascadeSubWindows())); connect(fileExitAction, SIGNAL(triggered()), this, SLOT(fileExit())); connect(menuWindows, SIGNAL(aboutToShow()), this, SLOT(updateWindowMenu())); connect(actionSave_Hdr_Preview, SIGNAL(triggered()), this, SLOT(saveHdrPreview())); //QSignalMapper? connect(actionText_Under_Icons,SIGNAL(triggered()),this,SLOT(Text_Under_Icons())); connect(actionIcons_Only,SIGNAL(triggered()),this,SLOT(Icons_Only())); connect(actionText_Alongside_Icons,SIGNAL(triggered()),this,SLOT(Text_Alongside_Icons())); connect(actionText_Only,SIGNAL(triggered()),this,SLOT(Text_Only())); windowMapper = new QSignalMapper(this); connect(windowMapper,SIGNAL(mapped(QWidget*)),this,SLOT(setActiveSubWindow(QWidget*))); //recent files for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActs[i] = new QAction(this); recentFileActs[i]->setVisible(false); connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } separatorRecentFiles = menuFile->addSeparator(); for (int i = 0; i < MaxRecentFiles; ++i) menuFile->addAction(recentFileActs[i]); updateRecentFileActions(); //this->showMaximized(); testTempDir(qtpfsgui_options->tempfilespath); statusBar()->showMessage(tr("Ready.... Now open an Hdr or create one!"),17000); }
void AppEditMenu::setupMenu(QMenu *editMenu, QToolBar *toolbar) { toolbar->addSeparator(); editUndoAction=editMenu->addAction(IconUtil::getIcon("undo"), tr("&Undo"), this, SLOT(undo()), QKeySequence(QKeySequence::Undo)); editUndoAction->setStatusTip(tr("Undo last edit action")); toolbar->addAction(editUndoAction); editRedoAction=editMenu->addAction(IconUtil::getIcon("redo"), tr("&Redo"), this, SLOT(redo()), QKeySequence(QKeySequence::Redo)); editRedoAction->setStatusTip(tr("Redo last undone edit action")); toolbar->addAction(editRedoAction); editMenu->addSeparator(); toolbar->addSeparator(); editCutAction=editMenu->addAction(IconUtil::getIcon("editcut"), tr("Cu&t"), this, SLOT(cut()), QKeySequence(QKeySequence::Cut)); editCutAction->setStatusTip(tr("Cut")); toolbar->addAction(editCutAction); editCopyAction=editMenu->addAction(IconUtil::getIcon("editcopy"), tr("&Copy"), this, SLOT(copy()), QKeySequence(QKeySequence::Copy)); editCopyAction->setStatusTip(tr("Copy")); toolbar->addAction(editCopyAction); //editCopyAsAction=editMenu->addAction(IconUtil::getIcon("editcopy"), tr("Copy as")); //editCopyAsAction->setMenu(createCopyAsMenu(editMenu)); editPasteAction=editMenu->addAction(IconUtil::getIcon("editpaste"), tr("&Paste"), this, SLOT(paste()), QKeySequence(QKeySequence::Paste)); editPasteAction->setStatusTip(tr("Paste")); toolbar->addAction(editPasteAction); editMenu->addSeparator(); editSelectAllAction=editMenu->addAction(IconUtil::getIcon("editselectall"), tr("Select &All"), this, SLOT(selectAll()), QKeySequence(QKeySequence::SelectAll)); editSelectAllAction->setStatusTip(tr("Select All")); editMenu->addSeparator(); toolbar->addSeparator(); editAdvancedAction = editMenu->addAction(tr("Advanced")); createEditAdvancedMenu(toolbar); editAdvancedAction->setMenu(editAdvancedMenu); editMenu->addSeparator(); editDescribeAction=editMenu->addAction(tr("Describe object"), this, SLOT(describeObject()), QKeySequence("F4")); editResolveAction=editMenu->addAction(tr("Object Menu")); createEditResolveMenu(); editResolveAction->setMenu(editResolveMenu); editMenu->addSeparator(); //toolbar->addSeparator(); editIncreaseFontSize=editMenu->addAction(tr("Increase font size"), this, SLOT(increaseFont()), QKeySequence(QKeySequence::ZoomIn)); editIncreaseFontSize->setStatusTip(tr("Increase font size")); editDecreaseFontSize=editMenu->addAction(tr("Decrease font size"), this, SLOT(decreaseFont()), QKeySequence(QKeySequence::ZoomOut)); editDecreaseFontSize->setStatusTip(tr("Decrease font size")); editResetFontSize=editMenu->addAction(tr("Reset font size"), this, SLOT(resetFont()), QKeySequence(tr("Ctrl+0", "Edit|Reset font size"))); editResetFontSize->setStatusTip(tr("Reset font size")); editMenu->addSeparator(); toolbar->addSeparator(); editFindAction=editMenu->addAction(IconUtil::getIcon("find"), tr("&Find..."), this, SLOT(showSearchWidget()), QKeySequence("Ctrl+F")); editFindAction->setStatusTip(tr("Find text")); toolbar->addAction(editFindAction); editFindPreviousAction=editMenu->addAction(IconUtil::getIcon("find_prev"), tr("Find p&revious"), this, SLOT(findPrevious()), QKeySequence("Shift+F3")); editFindPreviousAction->setStatusTip(tr("Find previous occurence of current search text")); toolbar->addAction(editFindPreviousAction); editFindNextAction=editMenu->addAction(IconUtil::getIcon("find_next"), tr("Find &next"), this, SLOT(findNext()), QKeySequence("F3")); editFindNextAction->setStatusTip(tr("Find next occurence of current search text")); toolbar->addAction(editFindNextAction); editMenu->addSeparator(); editGoToLineAction=editMenu->addAction(IconUtil::getIcon("goto_line"), tr("&Go to line..."), this, SLOT(goToLine()), QKeySequence("Ctrl+G")); editGoToLineAction->setStatusTip(tr("Go to line")); connect(editResolveMenu, SIGNAL(aboutToShow()), this, SLOT(populateResolveMenu())); }
if (language.compare(currentLanguage) == 0) { currentAction->setChecked(true); } } } connect(languageMenu, SIGNAL(triggered(QAction*)), this, SLOT(setLanguage(QAction*))); m_serialPortMenu = new QMenu(tr("Select port"), this); m_programMenu->addMenu(m_serialPortMenu); m_serialPortActionGroup = new QActionGroup(this); updateSerialPorts(); connect(m_serialPortMenu, SIGNAL(triggered(QAction*)), this, SLOT(setPort(QAction*))); connect(m_serialPortMenu, SIGNAL(aboutToShow()), this, SLOT(updateSerialPorts()), Qt::DirectConnection); m_programmerMenu = new QMenu(tr("Select programmer"), this); m_programMenu->addMenu(m_programmerMenu); m_programmerActionGroup = new QActionGroup(this); QHash<QString, QString> programmerNames = getProgrammerNames(); foreach (QString name, programmerNames.keys()) { addProgrammer(name, programmerNames.value(name)); } connect(m_programmerMenu, SIGNAL(triggered(QAction*)), this, SLOT(setProgrammer(QAction*))); m_programMenu->addSeparator(); m_programAction = new QAction(tr("Program"), this);
bool DiffAnalystWindow::initMenuBar() { bool ret=false; // //////////////////////////////////////////////////////////////////// // FILE m_pFileMenu = new QPopupMenu (this); if(m_pFileMenu == NULL) return false; menuBar ()->insertItem ("&File", m_pFileMenu); // New m_pFileMenu->insertItem (QIconSet (QPixmap (XpmFileNew)), "&New Session Wizard", this, SLOT (onFileNew ()), CTRL + Key_N); // Open m_pFileMenu->insertItem (QIconSet (QPixmap (XpmFileOpen)), "&Open", this, SLOT (onFileOpen ()), CTRL + Key_O); // ------------------- m_pFileMenu->insertSeparator (); // Save m_SaveId = m_pFileMenu->insertItem (QIconSet (QPixmap (XpmFileSave)), "&Save", this, SLOT (onFileSave ()), CTRL + Key_S); m_pFileMenu->setItemEnabled (m_SaveId, false); // Save As m_SaveAsId = m_pFileMenu->insertItem (QIconSet(QPixmap()), "Save &As", this, SLOT (onFileSaveAs ()), CTRL + Key_A); m_pFileMenu->setItemEnabled (m_SaveAsId, false); // ------------------- // m_pFileMenu->insertSeparator (); // export data // m_ExportDataId = m_pFileMenu->insertItem ("&Export...", this, // SLOT (onExportData ())); // m_pFileMenu->setItemEnabled (m_ExportDataId, false); // ------------------- m_pFileMenu->insertSeparator (); // Close m_CloseId = m_pFileMenu->insertItem ("&Close", this, SLOT (onFileClose ()), CTRL + Key_W); m_CloseAllId = m_pFileMenu->insertItem ("Close Al&l", this, SLOT (onCloseAllWindows ())); // Quit m_pFileMenu->insertItem ("&Quit", this, SLOT (close ()), CTRL + Key_Q); QObject::connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (onAboutToQuit ())); // //////////////////////////////////////////////////////////////////// // SETTINGS // m_pSettingsMenu = new QPopupMenu (this); // if(m_pSettingsMenu == NULL) return false; // menuBar ()->insertItem ("&Settings", m_pSettingsMenu); // ///////////////////////////////////////////////////////////////////// // TOOLS m_pToolsMenu = new QPopupMenu (this); if(m_pToolsMenu == NULL) return false; m_pToolsMenu->setCheckable (TRUE); connect (m_pToolsMenu, SIGNAL (aboutToShow ()), this, SLOT (toolsMenuAboutToShow ())); menuBar ()->insertItem ("&Tools", m_pToolsMenu); // ///////////////////////////////////////////////////////////////////// // VIEW m_pViewMenu = new QPopupMenu (this); if(m_pViewMenu == NULL) return false; menuBar ()->insertItem ("&View", m_pViewMenu); // View Management m_ViewManageId = m_pViewMenu->insertItem (QPixmap(viewconfig),"&View Management", this, SLOT (onViewManage ())); // ///////////////////////////////////////////////////////////////////// // WINDOWS m_pWindowsMenu = new QPopupMenu (this); if(m_pWindowsMenu == NULL) return false; connect (m_pWindowsMenu, SIGNAL (aboutToShow ()), this, SLOT (onWindowsMenuAboutToShow ())); menuBar ()->insertItem ("&Windows", m_pWindowsMenu); // ///////////////////////////////////////////////////////////////////// // HELPS m_pHelpMenu = new QPopupMenu (this); if(m_pHelpMenu == NULL) return false; menuBar ()->insertItem ("&Help", m_pHelpMenu); m_pHelpMenu->insertItem ("&About", this, SLOT (onHelpAbout ()), Key_F1); m_pHelpMenu->insertItem ("&Help", this, SLOT (onHelpContents ())); ret = true; return ret; }// DiffAnalystWindow::initMenuBar
void MainWindow2::createMenus() { // ---------- File Menu ------------- connect( ui->actionNew, &QAction::triggered, this, &MainWindow2::newDocument ); connect( ui->actionOpen, &QAction::triggered, this, &MainWindow2::openDocument ); connect( ui->actionSave_as, &QAction::triggered, this, &MainWindow2::saveAsNewDocument ); connect( ui->actionSave, &QAction::triggered, this, &MainWindow2::saveDocument ); connect( ui->actionExit, &QAction::triggered, this, &MainWindow2::close ); /// --- Export Menu --- connect( ui->actionExport_X_sheet, &QAction::triggered, editor, &Editor::exportX ); connect( ui->actionExport_Image_Sequence, &QAction::triggered, editor, &Editor::exportSeq ); connect( ui->actionExport_Image, &QAction::triggered, editor, &Editor::exportImage ); connect( ui->actionExport_Movie, &QAction::triggered, editor, &Editor::exportMov ); //exportFlashAct = new QAction(tr("&Flash/SWF..."), this); //exportFlashAct->setShortcut(tr("Ctrl+Alt+F")); //connect(exportFlashAct, SIGNAL(triggered()), editor, SLOT(exportFlash())); connect( ui->actionExport_Palette, &QAction::triggered, this, &MainWindow2::exportPalette ); /// --- Import Menu --- //connect( ui->actionExport_Svg_Image, &QAction::triggered, editor, &Editor::saveSvg ); connect( ui->actionImport_Image, &QAction::triggered, editor, &Editor::importImageFromDialog ); connect( ui->actionImport_Image_Sequence, &QAction::triggered, editor, &Editor::importImageSequence ); connect( ui->actionImport_Movie, &QAction::triggered, editor, &Editor::importMov ); //connect( ui->actionImport_Sound, &QAction::triggered, editor, &Editor::importSound ); ui->actionImport_Sound->setEnabled( false ); connect( ui->actionImport_Palette, &QAction::triggered, this, &MainWindow2::importPalette ); /// --- Edit Menu --- connect( ui->actionUndo, &QAction::triggered, editor, &Editor::undo ); connect( ui->actionRedo, &QAction::triggered, editor, &Editor::redo ); connect( ui->actionCut, &QAction::triggered, editor, &Editor::cut ); connect( ui->actionCopy, &QAction::triggered, editor, &Editor::copy ); connect( ui->actionPaste, &QAction::triggered, editor, &Editor::paste ); connect( ui->actionClearFrame, &QAction::triggered, editor, &Editor::clearCurrentFrame ); connect( ui->actionCrop, &QAction::triggered, editor, &Editor::crop ); connect( ui->actionCrop_To_Selection, &QAction::triggered, editor, &Editor::croptoselect ); connect( ui->actionFlip_X, &QAction::triggered, editor, &Editor::flipX ); connect( ui->actionFlip_Y, &QAction::triggered, editor, &Editor::flipY ); connect( ui->actionSelect_All, &QAction::triggered, editor, &Editor::selectAll ); connect( ui->actionDeselect_All, &QAction::triggered, editor, &Editor::deselectAll ); connect( ui->actionPreference, &QAction::triggered, this, &MainWindow2::showPreferences ); ui->actionRedo->setEnabled( false ); /// --- Layer Menu --- connect( ui->actionNew_Bitmap_Layer, &QAction::triggered, editor, &Editor::newBitmapLayer ); connect( ui->actionNew_Vector_Layer, &QAction::triggered, editor, &Editor::newVectorLayer ); connect( ui->actionNew_Sound_Layer, &QAction::triggered, editor, &Editor::newSoundLayer ); connect( ui->actionNew_Camera_Layer, &QAction::triggered, editor, &Editor::newCameraLayer ); connect( ui->actionDelete_Current_Layer, &QAction::triggered, editor, &Editor::deleteCurrentLayer ); /// --- View Menu --- connect( ui->actionZoom_In, &QAction::triggered, editor, &Editor::setzoom ); connect( ui->actionZoom_Out, &QAction::triggered, editor, &Editor::setzoom1 ); connect( ui->actionRotate_Clockwise, &QAction::triggered, editor, &Editor::rotatecw ); connect( ui->actionRotate_Anticlosewise, &QAction::triggered, editor, &Editor::rotateacw ); connect( ui->actionReset_Windows, &QAction::triggered, this, &MainWindow2::dockAllPalettes ); connect( ui->actionReset_View, &QAction::triggered, editor, &Editor::resetView ); connect( ui->actionHorizontal_Flip, &QAction::triggered, editor, &Editor::toggleMirror ); connect( ui->actionVertical_Flip, &QAction::triggered, editor, &Editor::toggleMirrorV ); ui->actionPreview->setEnabled( false ); //# connect(previewAct, SIGNAL(triggered()), editor, SLOT(getCameraLayer()));//TODO: Preview view ui->actionGrid->setEnabled( false ); connect( ui->actionGrid, &QAction::triggered, editor, &Editor::gridview ); //TODO: Grid view connect( ui->actionOnionPrevious, &QAction::triggered, editor, &Editor::toggleOnionPrev ); connect( ui->actionOnionNext, &QAction::triggered, editor, &Editor::toggleOnionNext ); connect( ui->actionMultiLayerOnionSkin, &QAction::triggered, editor, &Editor::toggleMultiLayerOnionSkin ); connect( editor, SIGNAL( onionPrevChanged( bool ) ), ui->actionOnionPrevious, SLOT( setChecked( bool ) ) ); connect( editor, SIGNAL( onionNextChanged( bool ) ), ui->actionOnionNext, SLOT( setChecked( bool ) ) ); connect( editor, SIGNAL(multiLayerOnionSkinChanged(bool)), ui->actionMultiLayerOnionSkin, SLOT(setChecked(bool))); /// --- Animation Menu --- connect( ui->actionPlay, &QAction::triggered, editor, &Editor::play ); connect( ui->actionLoop, &QAction::triggered, editor, &Editor::setLoop ); connect( ui->actionLoop, SIGNAL(toggled(bool) ), editor, SIGNAL(toggleLoop(bool)) ); //TODO: WTF? connect( editor, SIGNAL( loopToggled(bool) ), ui->actionLoop, SLOT(setChecked(bool)) ); // Loop Control connect(ui->actionLoopControl, SIGNAL(triggered(bool)), editor, SLOT(setLoopControl(bool))); connect(ui->actionLoopControl, SIGNAL(toggled(bool)), editor, SIGNAL(toggleLoopControl(bool))); connect(editor, SIGNAL(loopControlToggled(bool)), ui->actionLoopControl, SLOT(setChecked(bool))); // Loop Control connect(ui->actionAdd_Frame, &QAction::triggered, editor, &Editor::addNewKey ); connect(ui->actionRemove_Frame, &QAction::triggered, editor, &Editor::removeKey ); connect(ui->actionNext_Frame, &QAction::triggered, editor, &Editor::playNextFrame ); connect(ui->actionPrevious_Frame, &QAction::triggered, editor, &Editor::playPrevFrame ); connect(ui->actionNext_Keyframe, &QAction::triggered, editor, &Editor::scrubNextKeyframe ); connect(ui->actionPrev_Keyframe, &QAction::triggered, editor, &Editor::scrubPreviousKeyframe ); connect(ui->actionDuplicate_Frame, &QAction::triggered, editor, &Editor::duplicateKey ); /// --- Tool Menu --- connect(ui->actionMove, &QAction::triggered, m_pToolBox, &ToolBoxWidget::moveOn ); connect(ui->actionSelect, &QAction::triggered, m_pToolBox, &ToolBoxWidget::selectOn ); connect(ui->actionBrush, &QAction::triggered, m_pToolBox, &ToolBoxWidget::brushOn ); connect(ui->actionPolyline, &QAction::triggered, m_pToolBox, &ToolBoxWidget::polylineOn ); connect(ui->actionSmudge, &QAction::triggered, m_pToolBox, &ToolBoxWidget::smudgeOn ); connect(ui->actionPen, &QAction::triggered, m_pToolBox, &ToolBoxWidget::penOn ); connect(ui->actionHand, &QAction::triggered, m_pToolBox, &ToolBoxWidget::handOn ); connect(ui->actionPencil, &QAction::triggered, m_pToolBox, &ToolBoxWidget::pencilOn ); connect(ui->actionBucket, &QAction::triggered, m_pToolBox, &ToolBoxWidget::bucketOn ); connect(ui->actionEyedropper, &QAction::triggered, m_pToolBox, &ToolBoxWidget::eyedropperOn ); connect(ui->actionEraser, &QAction::triggered, m_pToolBox, &ToolBoxWidget::eraserOn ); connect(ui->actionTogglePalette, &QAction::triggered, m_pScribbleArea,&ScribbleArea::togglePopupPalette ); connect(ui->actionResetToolsDefault, &QAction::triggered, this, &MainWindow2::resetToolsSettings ); /// --- Window Menu --- connect(ui->actionToolsWidget, SIGNAL(toggled(bool)), m_pToolBox, SLOT(setVisible(bool))); connect(m_pToolBox, SIGNAL(visibilityChanged(bool)), ui->actionToolsWidget, SLOT(setChecked(bool))); connect(ui->actionOptionsWidget, SIGNAL(toggled(bool)), m_pToolOptionWidget, SLOT(setVisible(bool))); connect(m_pToolOptionWidget, SIGNAL(visibilityChanged(bool)), ui->actionOptionsWidget, SLOT(setChecked(bool))); connect(ui->actionColorWheel, SIGNAL(toggled(bool)), m_pColorPalette, SLOT(setVisible(bool))); connect(m_pColorPalette, SIGNAL(visibilityChanged(bool)), ui->actionColorWheel, SLOT(setChecked(bool))); connect(ui->actionTimeline, SIGNAL(toggled(bool)), m_pTimeLine, SLOT(setVisible(bool))); connect(m_pTimeLine, SIGNAL(visibilityChanged(bool)), ui->actionTimeline, SLOT(setChecked(bool))); connect(ui->actionDisplayOptions, SIGNAL(toggled(bool)), m_pDisplayOptionWidget, SLOT(setVisible(bool))); connect(m_pDisplayOptionWidget, SIGNAL(visibilityChanged(bool)), ui->actionDisplayOptions, SLOT(setChecked(bool))); /// --- Help Menu --- connect( ui->actionHelp, &QAction::triggered, this, &MainWindow2::helpBox); connect( ui->actionAbout, &QAction::triggered, this, &MainWindow2::aboutPencil ); // --------------- Menus ------------------ m_recentFileMenu = new RecentFileMenu( tr("Open Recent"), this ); m_recentFileMenu->loadFromDisk(); ui->menuFile->insertMenu( ui->actionSave, m_recentFileMenu ); QObject::connect( m_recentFileMenu, SIGNAL( loadRecentFile( QString ) ), this, SLOT( openFile( QString ) ) ); connect( ui->menuEdit, SIGNAL( aboutToShow() ), this, SLOT( undoActSetText() ) ); connect( ui->menuEdit, SIGNAL( aboutToHide() ), this, SLOT( undoActSetEnabled() ) ); }
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) , m_nextTabAction(0) , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) , m_lineEdits(0) , m_tabBar(new TabBar(this)) { setElideMode(Qt::ElideRight); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); setTabBar(m_tabBar); // Actions m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this); m_newTabAction->setShortcuts(QKeySequence::AddTab); m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this); m_closeTabAction->setShortcuts(QKeySequence::Close); m_closeTabAction->setIconVisibleInMenu(false); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_nextTabAction = new QAction(tr("Show Next Tab"), this); QList<QKeySequence> shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less)); m_nextTabAction->setShortcuts(shortcuts); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(tr("Show Previous Tab"), this); shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater)); m_previousTabAction->setShortcuts(shortcuts); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_recentlyClosedTabsMenu = new QMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); m_recentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); // corner buttons QToolButton *addTabButton = new QToolButton(this); addTabButton->setDefaultAction(m_newTabAction); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(addTabButton, Qt::TopLeftCorner); QToolButton *closeTabButton = new QToolButton(this); closeTabButton->setDefaultAction(m_closeTabAction); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(closeTabButton, Qt::TopRightCorner); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); }
SpawnListMenu::SpawnListMenu(SEQListView* spawnlist, SEQWindow* spawnlistWindow, FilterMgr* filterMgr, CategoryMgr* categoryMgr, QWidget* parent, const char* name) : m_spawnlist(spawnlist), m_spawnlistWindow(spawnlistWindow), m_filterMgr(filterMgr), m_categoryMgr(categoryMgr) { // Show Columns QPopupMenu* spawnListColMenu = new QPopupMenu; insertItem( "Show &Column", spawnListColMenu); spawnListColMenu->setCheckable(true); m_id_spawnList_Cols[tSpawnColName] = spawnListColMenu->insertItem("&Name"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColName], tSpawnColName); m_id_spawnList_Cols[tSpawnColLevel] = spawnListColMenu->insertItem("&Level"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColLevel], tSpawnColLevel); m_id_spawnList_Cols[tSpawnColHP] = spawnListColMenu->insertItem("&HP"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColHP], tSpawnColHP); m_id_spawnList_Cols[tSpawnColMaxHP] = spawnListColMenu->insertItem("&Max HP"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColMaxHP], tSpawnColMaxHP); m_id_spawnList_Cols[tSpawnColXPos] = spawnListColMenu->insertItem("Coord &1"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColXPos], tSpawnColXPos); m_id_spawnList_Cols[tSpawnColYPos] = spawnListColMenu->insertItem("Coord &2"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColYPos], tSpawnColYPos); m_id_spawnList_Cols[tSpawnColZPos] = spawnListColMenu->insertItem("Coord &3"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColZPos], tSpawnColZPos); m_id_spawnList_Cols[tSpawnColID] = spawnListColMenu->insertItem("I&D"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColID], tSpawnColID); m_id_spawnList_Cols[tSpawnColDist] = spawnListColMenu->insertItem("&Dist"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColDist], tSpawnColDist); m_id_spawnList_Cols[tSpawnColRace] = spawnListColMenu->insertItem("&Race"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColRace], tSpawnColRace); m_id_spawnList_Cols[tSpawnColClass] = spawnListColMenu->insertItem("&Class"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColClass], tSpawnColClass); m_id_spawnList_Cols[tSpawnColInfo] = spawnListColMenu->insertItem("&Info"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColInfo], tSpawnColInfo); m_id_spawnList_Cols[tSpawnColSpawnTime] = spawnListColMenu->insertItem("Spawn &Time"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColSpawnTime], tSpawnColSpawnTime); m_id_spawnList_Cols[tSpawnColDeity] = spawnListColMenu->insertItem("&Deity"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColDeity], tSpawnColDeity); m_id_spawnList_Cols[tSpawnColBodyType] = spawnListColMenu->insertItem("&Body Type"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColBodyType], tSpawnColBodyType); m_id_spawnList_Cols[tSpawnColGuildID] = spawnListColMenu->insertItem("Guild Tag"); spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColGuildID], tSpawnColGuildID); connect (spawnListColMenu, SIGNAL(activated(int)), this, SLOT(toggle_spawnListCol(int))); int x; QPopupMenu* filterMenu = new QPopupMenu; m_id_filterMenu = insertItem("Add &Filter", filterMenu); setItemEnabled(m_id_filterMenu, false); x = filterMenu->insertItem("&Hunt..."); filterMenu->setItemParameter(x, HUNT_FILTER); x = filterMenu->insertItem("&Caution..."); filterMenu->setItemParameter(x, CAUTION_FILTER); x = filterMenu->insertItem("&Danger..."); filterMenu->setItemParameter(x, DANGER_FILTER); x = filterMenu->insertItem("&Locate..."); filterMenu->setItemParameter(x, LOCATE_FILTER); x = filterMenu->insertItem("&Alert..."); filterMenu->setItemParameter(x, ALERT_FILTER); x = filterMenu->insertItem("&Filtered..."); filterMenu->setItemParameter(x, FILTERED_FILTER); x = filterMenu->insertItem("&Tracer..."); filterMenu->setItemParameter(x, TRACER_FILTER); connect (filterMenu, SIGNAL(activated(int)), this, SLOT(add_filter(int))); QPopupMenu* zoneFilterMenu = new QPopupMenu; m_id_zoneFilterMenu = insertItem("Add &Zone Filter", zoneFilterMenu); setItemEnabled(m_id_zoneFilterMenu, false); x = zoneFilterMenu->insertItem("&Hunt..."); zoneFilterMenu->setItemParameter(x, HUNT_FILTER); x = zoneFilterMenu->insertItem("&Caution..."); zoneFilterMenu->setItemParameter(x, CAUTION_FILTER); x = zoneFilterMenu->insertItem("&Danger..."); zoneFilterMenu->setItemParameter(x, DANGER_FILTER); x = zoneFilterMenu->insertItem("&Locate..."); zoneFilterMenu->setItemParameter(x, LOCATE_FILTER); x = zoneFilterMenu->insertItem("&Alert..."); zoneFilterMenu->setItemParameter(x, ALERT_FILTER); x = zoneFilterMenu->insertItem("&Filtered..."); zoneFilterMenu->setItemParameter(x, FILTERED_FILTER); x = zoneFilterMenu->insertItem("&Tracer..."); zoneFilterMenu->setItemParameter(x, TRACER_FILTER); connect (zoneFilterMenu, SIGNAL(activated(int)), this, SLOT(add_zoneFilter(int))); insertSeparator(-1); x = insertItem("&Add Category...", this, SLOT(add_category(int))); m_id_edit_category = insertItem("&Edit Category...", this, SLOT(edit_category(int))); m_id_delete_category = insertItem("&Delete Category...", this, SLOT(delete_category(int))); insertItem("&Reload Categories", this, SLOT(reload_categories(int))); insertSeparator(-1); insertItem("&Font...", this, SLOT(set_font(int))); insertItem("&Caption...", this, SLOT(set_caption(int))); connect(this, SIGNAL(aboutToShow()), this, SLOT(init_Menu())); }
ADVSyncViewManager::ADVSyncViewManager(AnnotatedDNAView* v) : QObject(v), adv(v) { assert(v->getSequenceContexts().isEmpty()); recursion = false; selectionRecursion = false; lockByStartPosAction = new QAction(tr("Lock scales: visible range start"), this); lockByStartPosAction->setObjectName("Lock scales: visible range start"); connect(lockByStartPosAction, SIGNAL(triggered()), SLOT(sl_lock())); lockByStartPosAction->setCheckable(true); lockBySeqSelAction = new QAction(tr("Lock scales: selected sequence"), this); lockBySeqSelAction->setObjectName("Lock scales: selected sequence"); connect(lockBySeqSelAction, SIGNAL(triggered()), SLOT(sl_lock())); lockBySeqSelAction->setCheckable(true); lockByAnnSelAction = new QAction(tr("Lock scales: selected annotation"), this); lockByAnnSelAction->setObjectName("Lock scales: selected annotation"); connect(lockByAnnSelAction, SIGNAL(triggered()), SLOT(sl_lock())); lockByAnnSelAction->setCheckable(true); lockActionGroup = new QActionGroup(this); lockActionGroup->addAction(lockByStartPosAction); lockActionGroup->addAction(lockBySeqSelAction); lockActionGroup->addAction(lockByAnnSelAction); lockActionGroup->setExclusive(true); syncByStartPosAction = new QAction(tr("Adjust scales: visible range start"), this); syncByStartPosAction->setObjectName("Adjust scales: visible range start"); connect(syncByStartPosAction, SIGNAL(triggered()), SLOT(sl_sync())); syncBySeqSelAction = new QAction(tr("Adjust scales: selected sequence"), this); syncBySeqSelAction->setObjectName("Adjust scales: selected sequence"); connect(syncBySeqSelAction, SIGNAL(triggered()), SLOT(sl_sync())); syncByAnnSelAction = new QAction(tr("Adjust scales: selected annotation"), this); syncByAnnSelAction->setObjectName("Adjust scales: selected annotation"); connect(syncByAnnSelAction, SIGNAL(triggered()), SLOT(sl_sync())); lockMenu = new QMenu(tr("Lock scales")); lockMenu->setIcon(QIcon(":core/images/lock_scales.png")); lockMenu->addActions(lockActionGroup->actions()); syncMenu = new QMenu(tr("Adjust scales")); syncMenu->setIcon(QIcon(":core/images/sync_scales.png")); syncMenu->addAction(syncByStartPosAction); syncMenu->addAction(syncBySeqSelAction); syncMenu->addAction(syncByAnnSelAction); lockButton = new QToolButton(); lockButton->setObjectName("Lock scales"); lockButton->setCheckable(true); connect(lockButton, SIGNAL(clicked()), SLOT(sl_lock())); lockButton->setDefaultAction(lockMenu->menuAction()); lockButton->setCheckable(true); syncButton = new QToolButton(); syncButton->setObjectName("Adjust scales"); connect(syncButton, SIGNAL(clicked()), SLOT(sl_sync())); syncButton->setDefaultAction(syncMenu->menuAction()); lockButtonTBAction = NULL; syncButtonTBAction = NULL; // auto-annotations highlighting ops toggleAutoAnnotationsMenu = new QMenu("Global automatic annotation highlighting"); toggleAutoAnnotationsMenu->setIcon(QIcon(":core/images/predefined_annotation_groups.png")); connect( toggleAutoAnnotationsMenu, SIGNAL(aboutToShow()), SLOT(sl_updateAutoAnnotationsMenu()) ); toggleAutoAnnotationsButton = new QToolButton(); toggleAutoAnnotationsButton->setObjectName("toggleAutoAnnotationsButton"); toggleAutoAnnotationsButton->setDefaultAction(toggleAutoAnnotationsMenu->menuAction()); toggleAutoAnnotationsButton->setPopupMode(QToolButton::InstantPopup); toggleAutoAnnotationsAction = NULL; // visual mode ops toggleAllAction = new QAction("Toggle All sequence views", this); toggleAllAction->setObjectName("toggleAllSequenceViews"); connect(toggleAllAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); toggleOveAction = new QAction("Toggle Overview", this); toggleOveAction->setObjectName("toggleOverview"); connect(toggleOveAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); togglePanAction = new QAction("Toggle Zoom view", this); togglePanAction->setObjectName("toggleZoomView"); connect(togglePanAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); toggleDetAction = new QAction("Toggle Details view", this); toggleDetAction->setObjectName("toggleDetailsView"); connect(toggleDetAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); toggleViewButtonAction = NULL; toggleViewButtonMenu = new QMenu(tr("Toggle views")); toggleViewButtonMenu->setIcon(QIcon(":core/images/adv_widget_menu.png")); toggleViewButtonMenu->addAction(toggleAllAction); //-> behavior can be not clear to user toggleViewButtonMenu->addAction(toggleOveAction); toggleViewButtonMenu->addAction(togglePanAction); toggleViewButtonMenu->addAction(toggleDetAction); connect(toggleViewButtonMenu, SIGNAL(aboutToShow()), SLOT(sl_updateVisualMode())); toggleViewButton = new QToolButton(); toggleViewButton->setObjectName("toggleViewButton"); toggleViewButton->setDefaultAction(toggleViewButtonMenu->menuAction()); toggleViewButton->setPopupMode(QToolButton::InstantPopup); updateEnabledState(); connect(adv, SIGNAL(si_sequenceWidgetAdded(ADVSequenceWidget*)), SLOT(sl_sequenceWidgetAdded(ADVSequenceWidget*))); connect(adv, SIGNAL(si_sequenceWidgetRemoved(ADVSequenceWidget*)), SLOT(sl_sequenceWidgetRemoved(ADVSequenceWidget*))); }
void QToolButtonPrivate::popupTimerDone() { Q_Q(QToolButton); popupTimer.stop(); if (!menuButtonDown && !down) return; menuButtonDown = true; QPointer<QMenu> actualMenu; bool mustDeleteActualMenu = false; if(menuAction) { actualMenu = menuAction->menu(); } else if (defaultAction && defaultAction->menu()) { actualMenu = defaultAction->menu(); } else { actualMenu = new QMenu(q); mustDeleteActualMenu = true; for(int i = 0; i < actions.size(); i++) actualMenu->addAction(actions.at(i)); } repeat = q->autoRepeat(); q->setAutoRepeat(false); bool horizontal = true; #if !defined(QT_NO_TOOLBAR) QToolBar *tb = qobject_cast<QToolBar*>(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; #endif QPoint p; QRect screen = QApplication::desktop()->availableGeometry(q); QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint(); QRect rect = q->rect(); if (horizontal) { if (q->isRightToLeft()) { if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = q->mapToGlobal(rect.bottomRight()); } else { p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height())); } p.rx() -= sh.width(); } else { if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = q->mapToGlobal(rect.bottomLeft()); } else { p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height())); } } } else { if (q->isRightToLeft()) { if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()) { p = q->mapToGlobal(rect.topRight()); } else { p = q->mapToGlobal(rect.topLeft()); p.rx() -= sh.width(); } } else { if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()) { p = q->mapToGlobal(rect.topRight()); } else { p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0)); } } } p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width())); p.ry() += 1; QPointer<QToolButton> that = q; actualMenu->setNoReplayFor(q); if (!mustDeleteActualMenu) //only if action are not in this widget QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); actualMenu->d_func()->causedPopup.widget = q; actualMenu->d_func()->causedPopup.action = defaultAction; actionsCopy = q->actions(); //(the list of action may be modified in slots) actualMenu->exec(p); if (!that) return; QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); if (mustDeleteActualMenu) delete actualMenu; else QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); actionsCopy.clear(); if (repeat) q->setAutoRepeat(true); }
void PopupView::createActions() { // Remove the Shift+Delete shortcut from the cut action, since it's used for deleting files KAction *cut = KStandardAction::cut(this, SLOT(cut()), this); KShortcut cutShortCut = cut->shortcut(); cutShortCut.remove(Qt::SHIFT + Qt::Key_Delete); cut->setShortcut(cutShortCut); KAction *copy = KStandardAction::copy(this, SLOT(copy()), this); KIO::FileUndoManager *manager = KIO::FileUndoManager::self(); KAction *undo = KStandardAction::undo(manager, SLOT(undo()), this); connect(manager, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool))); connect(manager, SIGNAL(undoTextChanged(QString)), SLOT(undoTextChanged(QString))); undo->setEnabled(manager->undoAvailable()); KAction *paste = KStandardAction::paste(this, SLOT(paste()), this); KAction *pasteTo = KStandardAction::paste(this, SLOT(pasteTo()), this); pasteTo->setEnabled(false); // Only enabled during popupMenu() QString actionText = KIO::pasteActionText(); if (!actionText.isEmpty()) { paste->setText(actionText); } else { paste->setEnabled(false); } KAction *rename = new KAction(KIcon("edit-rename"), i18n("&Rename"), this); rename->setShortcut(Qt::Key_F2); connect(rename, SIGNAL(triggered()), SLOT(renameSelectedIcon())); KAction *trash = new KAction(KIcon("user-trash"), i18n("&Move to Trash"), this); trash->setShortcut(Qt::Key_Delete); connect(trash, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), SLOT(moveToTrash(Qt::MouseButtons,Qt::KeyboardModifiers))); KAction *emptyTrash = new KAction(KIcon("trash-empty"), i18n("&Empty Trash Bin"), this); KConfig trashConfig("trashrc", KConfig::SimpleConfig); emptyTrash->setEnabled(!trashConfig.group("Status").readEntry("Empty", true)); connect(emptyTrash, SIGNAL(triggered()), SLOT(emptyTrashBin())); KAction *del = new KAction(i18n("&Delete"), this); del->setIcon(KIcon("edit-delete")); del->setShortcut(Qt::SHIFT + Qt::Key_Delete); connect(del, SIGNAL(triggered()), SLOT(deleteSelectedIcons())); // Create the new menu m_newMenu = new KNewFileMenu(&m_actionCollection, "new_menu", this); connect(m_newMenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowCreateNew())); m_actionCollection.addAction("undo", undo); m_actionCollection.addAction("cut", cut); m_actionCollection.addAction("copy", copy); m_actionCollection.addAction("paste", paste); m_actionCollection.addAction("pasteto", pasteTo); m_actionCollection.addAction("rename", rename); m_actionCollection.addAction("trash", trash); m_actionCollection.addAction("del", del); m_actionCollection.addAction("empty_trash", emptyTrash); }
WbDlg::WbDlg(SxeSession* session, PsiAccount* pa) { groupChat_ = session->groupChat(); pending_ = 0; keepOpen_ = false; allowEdits_ = true; selfDestruct_ = 0; setAttribute(Qt::WA_DeleteOnClose, false); // we want deferred endSession call and delete from manager setWindowTitle(CAP(tr("Whiteboard (%1)").arg(pa->jid().bare()))); QVBoxLayout *vb1 = new QVBoxLayout(this); // first row le_jid_ = new QLineEdit(this); le_jid_->setReadOnly(true); le_jid_->setFocusPolicy(Qt::NoFocus); le_jid_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); lb_ident_ = new AccountLabel(this); lb_ident_->setAccount(pa); lb_ident_->setShowJid(false); lb_ident_->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); QHBoxLayout *hb1 = new QHBoxLayout(); hb1->addWidget(le_jid_); hb1->addWidget(lb_ident_); vb1->addLayout(hb1); // mid area wbWidget_ = new WbWidget(session, this); wbWidget_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); vb1->addWidget(wbWidget_); // Bottom (tool) area act_save_ = new IconAction(tr("Save session"), "psi/saveBoard", tr("Save the contents of the whiteboard"), 0, this ); act_geometry_ = new IconAction(tr("Change the geometry"), "psi/whiteboard", tr("Change the geometry"), 0, this ); act_clear_ = new IconAction(tr("End session"), "psi/clearChat", tr("Clear the whiteboard"), 0, this ); act_end_ = new IconAction(tr("End session"), "psi/closetab", tr("End session"), 0, this ); // Black is the default color QPixmap pixmap(16, 16); pixmap.fill(QColor(Qt::black)); act_color_ = new QAction(QIcon(pixmap), tr("Stroke color"), this); pixmap.fill(QColor(Qt::lightGray)); act_fill_ = new IconAction(tr("Fill color"), "psi/select", tr("Fill color"),0, this, 0, true); act_fill_->setIcon(QIcon(pixmap)); act_fill_->setChecked(false); act_widths_ = new IconAction(tr("Stroke width" ), "psi/drawPaths", tr("Stroke width"), 0, this ); act_modes_ = new IconAction(tr("Edit mode" ), "psi/select", tr("Edit mode"), 0, this ); group_widths_ = new QActionGroup(this); group_modes_ = new QActionGroup(this); connect(act_color_, SIGNAL(triggered()), SLOT(setStrokeColor())); connect(act_fill_, SIGNAL(triggered(bool)), SLOT(setFillColor(bool))); connect(group_widths_, SIGNAL(triggered(QAction *)), SLOT(setStrokeWidth(QAction *))); connect(group_modes_, SIGNAL(triggered(QAction *)), SLOT(setMode(QAction *))); connect(act_save_, SIGNAL(triggered()), SLOT(save())); connect(act_geometry_, SIGNAL(triggered()), SLOT(setGeometry())); connect(act_clear_, SIGNAL(triggered()), wbWidget_, SLOT(clear())); connect(act_end_, SIGNAL(triggered()), SLOT(endSession())); pixmap = QPixmap(2, 2); pixmap.fill(QColor(Qt::black)); QAction* widthaction = new QAction(QIcon(pixmap), tr("Thin stroke"), group_widths_); widthaction->setData(QVariant(1)); widthaction->setCheckable(true); widthaction->trigger(); pixmap = QPixmap(6, 6); pixmap.fill(QColor(Qt::black)); widthaction = new QAction(QIcon(pixmap), tr("Medium stroke"), group_widths_); widthaction->setData(QVariant(3)); widthaction->setCheckable(true); pixmap = QPixmap(12, 12); pixmap.fill(QColor(Qt::black)); widthaction = new QAction(QIcon(pixmap), tr("Thick stroke"), group_widths_); widthaction->setData(QVariant(6)); widthaction->setCheckable(true); IconAction* action; action = new IconAction(tr("Select"), "psi/select", tr("Select"), 0, group_modes_ ); action->setData(QVariant(WbWidget::Select)); action->setCheckable(true); action = new IconAction(tr( "Translate"), "psi/translate", tr("Translate"), 0, group_modes_ ); action->setData(QVariant(WbWidget::Translate)); action->setCheckable(true); action = new IconAction(tr( "Rotate"), "psi/rotate", tr("Rotate"), 0, group_modes_ ); action->setData(QVariant(WbWidget::Rotate)); action->setCheckable(true); action = new IconAction(tr( "Scale"), "psi/scale", tr("Scale"), 0, group_modes_ ); action->setData(QVariant(WbWidget::Scale)); action->setCheckable(true); action = new IconAction(tr( "Erase"), "psi/erase", tr("Erase"), 0, group_modes_ ); action->setData(QVariant(WbWidget::Erase)); action->setCheckable(true); QAction *separator = new QAction(group_modes_); separator->setSeparator(true); action = new IconAction(tr( "Scroll view"), "psi/scroll", tr("Scroll"), 0, group_modes_ ); action->setData(QVariant(WbWidget::Scroll)); action->setCheckable(true); separator = new QAction(group_modes_); separator->setSeparator(true); action = new IconAction(tr( "Draw paths"), "psi/drawPaths", tr("Draw paths"), 0, group_modes_ ); action->setData(QVariant(WbWidget::DrawPath)); action->setCheckable(true); action->trigger(); // action = new IconAction(tr( "Draw lines"), "psi/drawLines", tr("Draw lines"), 0, group_modes_ ); // action->setData(QVariant(WbWidget::DrawLine)); // action->setCheckable(true); // action = new IconAction(tr( "Draw ellipses"), "psi/drawEllipses", tr("Draw ellipses"), 0, group_modes_ ); // action->setData(QVariant(WbWidget::DrawEllipse)); // action->setCheckable(true); // action = new IconAction(tr( "Draw circles"), "psi/drawCircles", tr("Draw circles"), 0, group_modes_ ); // action->setData(QVariant(WbWidget::DrawCircle)); // action->setCheckable(true); // action = new IconAction(tr( "Draw rectangles"), "psi/drawRectangles", tr("Draw rectangles"), 0, group_modes_ ); // action->setData(QVariant(WbWidget::DrawRectangle)); // action->setCheckable(true); // action = new IconAction(tr( "Add text"), "psi/addText", tr("Add text"), 0, group_modes_ ); // action->setData(QVariant(WbWidget::DrawText)); // action->setCheckable(true); action = new IconAction(tr( "Add images"), "psi/addImage", tr("Add images"), 0, group_modes_ ); action->setData(QVariant(WbWidget::DrawImage)); action->setCheckable(true); menu_widths_ = new QMenu(this); menu_widths_->addActions(group_widths_->actions()); act_widths_->setMenu(menu_widths_); menu_modes_ = new QMenu(this); menu_modes_->addActions(group_modes_->actions()); act_modes_->setMenu(menu_modes_); toolbar_ = new QToolBar(tr("Whiteboard toolbar"), this); toolbar_->setIconSize(QSize(16,16)); toolbar_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); toolbar_->addAction(act_end_); toolbar_->addAction(act_clear_); toolbar_->addAction(act_save_); toolbar_->addAction(act_geometry_); toolbar_->addWidget(new StretchWidget(this)); toolbar_->addAction(act_fill_); toolbar_->addAction(act_color_); QToolButton *bw = new QToolButton; bw->setIcon(IconsetFactory::icon("psi/drawPaths").icon()); bw->setMenu(menu_widths_); bw->setPopupMode(QToolButton::InstantPopup); toolbar_->addWidget(bw); QToolButton *bm = new QToolButton; bm->setIcon(IconsetFactory::icon("psi/select").icon()); bm->setMenu(menu_modes_); bm->setPopupMode(QToolButton::InstantPopup); toolbar_->addWidget(bm); vb1->addWidget(toolbar_); // Context menu pm_settings_ = new QMenu(this); connect(pm_settings_, SIGNAL(aboutToShow()), SLOT(buildMenu())); X11WM_CLASS("whiteboard"); // set the Jid -> le_jid. le_jid_->setText(QString("%1 (session: %2)").arg(session->target().full()).arg(session->session())); le_jid_->setCursorPosition(0); le_jid_->setToolTip(session->target().full()); // update the widget icon #ifndef Q_OS_MAC setWindowIcon(IconsetFactory::icon("psi/whiteboard").icon()); #endif setWindowOpacity(double(qMax(MINIMUM_OPACITY, PsiOptions::instance()->getOption("options.ui.chat.opacity").toInt())) / 100); setGeometryOptionPath(geometryOption); }
ToolBar::ToolBar(const QString &title, QWidget *parent) : QToolBar(parent), spinbox(0), spinboxAction(0) { tip = 0; setWindowTitle(title); setObjectName(title); setIconSize(QSize(32, 32)); QColor bg(palette().background().color()); menu = new QMenu("One", this); menu->setIcon(genIcon(iconSize(), 1, Qt::black)); menu->addAction(genIcon(iconSize(), "A", Qt::blue), "A"); menu->addAction(genIcon(iconSize(), "B", Qt::blue), "B"); menu->addAction(genIcon(iconSize(), "C", Qt::blue), "C"); addAction(menu->menuAction()); QAction *two = addAction(genIcon(iconSize(), 2, Qt::white), "Two"); QFont boldFont; boldFont.setBold(true); two->setFont(boldFont); addAction(genIcon(iconSize(), 3, Qt::red), "Three"); addAction(genIcon(iconSize(), 4, Qt::green), "Four"); addAction(genIcon(iconSize(), 5, Qt::blue), "Five"); addAction(genIcon(iconSize(), 6, Qt::yellow), "Six"); orderAction = new QAction(this); orderAction->setText(tr("Order Items in Tool Bar")); connect(orderAction, SIGNAL(triggered()), SLOT(order())); randomizeAction = new QAction(this); randomizeAction->setText(tr("Randomize Items in Tool Bar")); connect(randomizeAction, SIGNAL(triggered()), SLOT(randomize())); addSpinBoxAction = new QAction(this); addSpinBoxAction->setText(tr("Add Spin Box")); connect(addSpinBoxAction, SIGNAL(triggered()), SLOT(addSpinBox())); removeSpinBoxAction = new QAction(this); removeSpinBoxAction->setText(tr("Remove Spin Box")); removeSpinBoxAction->setEnabled(false); connect(removeSpinBoxAction, SIGNAL(triggered()), SLOT(removeSpinBox())); movableAction = new QAction(tr("Movable"), this); movableAction->setCheckable(true); connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool))); allowedAreasActions = new QActionGroup(this); allowedAreasActions->setExclusive(false); allowLeftAction = new QAction(tr("Allow on Left"), this); allowLeftAction->setCheckable(true); connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool))); allowRightAction = new QAction(tr("Allow on Right"), this); allowRightAction->setCheckable(true); connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool))); allowTopAction = new QAction(tr("Allow on Top"), this); allowTopAction->setCheckable(true); connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool))); allowBottomAction = new QAction(tr("Allow on Bottom"), this); allowBottomAction->setCheckable(true); connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool))); allowedAreasActions->addAction(allowLeftAction); allowedAreasActions->addAction(allowRightAction); allowedAreasActions->addAction(allowTopAction); allowedAreasActions->addAction(allowBottomAction); areaActions = new QActionGroup(this); areaActions->setExclusive(true); leftAction = new QAction(tr("Place on Left") , this); leftAction->setCheckable(true); connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool))); rightAction = new QAction(tr("Place on Right") , this); rightAction->setCheckable(true); connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool))); topAction = new QAction(tr("Place on Top") , this); topAction->setCheckable(true); connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool))); bottomAction = new QAction(tr("Place on Bottom") , this); bottomAction->setCheckable(true); connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool))); areaActions->addAction(leftAction); areaActions->addAction(rightAction); areaActions->addAction(topAction); areaActions->addAction(bottomAction); toolBarBreakAction = new QAction(tr("Insert break"), this); connect(toolBarBreakAction, SIGNAL(triggered(bool)), this, SLOT(insertToolBarBreak())); connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool))); connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool))); menu = new QMenu(title, this); menu->addAction(toggleViewAction()); menu->addSeparator(); menu->addAction(orderAction); menu->addAction(randomizeAction); menu->addSeparator(); menu->addAction(addSpinBoxAction); menu->addAction(removeSpinBoxAction); menu->addSeparator(); menu->addAction(movableAction); menu->addSeparator(); menu->addActions(allowedAreasActions->actions()); menu->addSeparator(); menu->addActions(areaActions->actions()); menu->addSeparator(); menu->addAction(toolBarBreakAction); connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); randomize(); }