SessionTabWidget::SessionTabWidget(Session* session, QWidget* parent) : TabWidget(parent) { d.hasQuit = false; d.handler.setSession(session); session->setParent(&d.handler); connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabActivated(int))); connect(this, SIGNAL(newTabRequested()), this, SLOT(onNewTabRequested()), Qt::QueuedConnection); connect(session, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged(bool))); connect(session, SIGNAL(disconnected()), this, SLOT(onDisconnected())); connect(&d.handler, SIGNAL(receiverToBeAdded(QString)), this, SLOT(openView(QString))); connect(&d.handler, SIGNAL(receiverToBeRemoved(QString)), this, SLOT(removeView(QString))); connect(&d.handler, SIGNAL(receiverToBeRenamed(QString,QString)), this, SLOT(renameView(QString,QString))); QShortcut* shortcut = new QShortcut(QKeySequence::AddTab, this); connect(shortcut, SIGNAL(activated()), this, SLOT(onNewTabRequested())); shortcut = new QShortcut(QKeySequence::Close, this); connect(shortcut, SIGNAL(activated()), this, SLOT(closeCurrentView())); applySettings(Application::settings()); registerSwipeGestures(Qt::Horizontal); MessageView* view = openView(d.handler.session()->host()); d.handler.setDefaultReceiver(view); setTabInactive(0, !session->isActive()); }
void CommandLine::executeCommand() { QString command = text(); QRegExp open(":open (.*)"); QRegExp newTab(":tabnew (.*)"); QRegExp protocol_checker("\\b(http://|https://)\\b"); QString url; int protocol_index = protocol_checker.indexIn(command); if (open.exactMatch(command)) { url = open.cap(1); if (protocol_index == -1) url = "http://" + url; emit(openUrlRequested(url)); } if (newTab.exactMatch(command)) { url = newTab.cap(1); if (protocol_index == -1) url = "http://" + url; emit(newTabRequested(url)); } emit(clear()); }
SessionTabWidget::SessionTabWidget(Session* session, QWidget* parent) : TabWidget(parent) { d.handler.setSession(session); connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabActivated(int))); connect(this, SIGNAL(newTabRequested()), this, SLOT(onNewTabRequested()), Qt::QueuedConnection); connect(this, SIGNAL(tabMenuRequested(int,QPoint)), this, SLOT(onTabMenuRequested(int,QPoint))); connect(session, SIGNAL(activeChanged(bool)), this, SLOT(updateStatus())); connect(session, SIGNAL(connectedChanged(bool)), this, SLOT(updateStatus())); connect(&d.handler, SIGNAL(receiverToBeAdded(QString)), this, SLOT(openView(QString))); connect(&d.handler, SIGNAL(receiverToBeRemoved(QString)), this, SLOT(removeView(QString))); connect(&d.handler, SIGNAL(receiverToBeRenamed(QString,QString)), this, SLOT(renameView(QString,QString))); QShortcut* shortcut = new QShortcut(QKeySequence::AddTab, this); connect(shortcut, SIGNAL(activated()), this, SLOT(onNewTabRequested())); shortcut = new QShortcut(QKeySequence::Close, this); connect(shortcut, SIGNAL(activated()), this, SLOT(closeCurrentView())); MessageView* view = openView(d.handler.session()->host()); d.handler.setDefaultReceiver(view); updateStatus(); applySettings(d.settings); }
void TabBar::dragMoveEvent(QDragMoveEvent *event) { int index = tabAt(event->pos()); if (index == -1) emit newTabRequested(); else emit setCurrentRequested(index); }
TabWidget::TabWidget(QWidget *parent): QTabWidget(parent) { tabBar_ = new TabBar(this); QObject::connect(tabBar_, SIGNAL(tabCloseRequested(int)), this, SLOT(slotTabCloseRequested(int))); QObject::connect(tabBar_, SIGNAL(newTabRequested()), this, SLOT(slotNewTabRequested())); QObject::connect(tabBar_, SIGNAL(setCurrentRequested(int)), this, SLOT(slotSetCurrentRequested(int))); QObject::connect(tabBar_, SIGNAL(dropRequested(int,const QMimeData*)), this, SLOT(slotDropRequested(int,const QMimeData*))); setTabBar(tabBar_); }
TabBar::TabBar(MainWindow* mainWindow) : QWidget(mainWindow) { QDBusConnection::sessionBus().registerObject("/yakuake/tabs", this, QDBusConnection::ExportScriptableSlots); setWhatsThis(i18nc("@info:whatsthis", "<title>Tab Bar</title>" "<para>The tab bar allows you to switch between sessions. You can double-click a tab to edit its label.</para>")); m_selectedSessionId = -1; m_renamingSessionId = -1; m_mousePressed = false; m_mousePressedIndex = -1; m_dropIndicator = 0; m_mainWindow = mainWindow; m_skin = mainWindow->skin(); connect(m_skin, SIGNAL(iconChanged()), this, SLOT(repaint())); m_tabContextMenu = new KMenu(this); connect(m_tabContextMenu, SIGNAL(hovered(QAction*)), this, SLOT(contextMenuActionHovered(QAction*))); m_toggleKeyboardInputMenu = new KMenu(i18nc("@title:menu", "Disable Keyboard Input"), this); m_toggleMonitorActivityMenu = new KMenu(i18nc("@title:menu", "Monitor for Activity"), this); m_toggleMonitorSilenceMenu = new KMenu(i18nc("@title:menu", "Monitor for Silence"), this); m_sessionMenu = new KMenu(this); connect(m_sessionMenu, SIGNAL(aboutToShow()), this, SLOT(readySessionMenu())); m_newTabButton = new QToolButton(this); m_newTabButton->setFocusPolicy(Qt::NoFocus); m_newTabButton->setMenu(m_sessionMenu); m_newTabButton->setPopupMode(QToolButton::DelayedPopup); m_newTabButton->setToolTip(i18nc("@info:tooltip", "New Session")); m_newTabButton->setWhatsThis(i18nc("@info:whatsthis", "Adds a new session. Press and hold to select session type from menu.")); connect(m_newTabButton, SIGNAL(clicked()), this, SIGNAL(newTabRequested())); m_closeTabButton = new KPushButton(this); m_closeTabButton->setFocusPolicy(Qt::NoFocus); m_closeTabButton->setToolTip(i18nc("@info:tooltip", "Close Session")); m_closeTabButton->setWhatsThis(i18nc("@info:whatsthis", "Closes the active session.")); connect(m_closeTabButton, SIGNAL(clicked()), this, SLOT(closeTabButtonClicked())); m_lineEdit = new KLineEdit(this); m_lineEdit->setFrame(false); m_lineEdit->setClearButtonShown(false); m_lineEdit->setAlignment(Qt::AlignHCenter); m_lineEdit->hide(); connect(m_lineEdit, SIGNAL(editingFinished()), m_lineEdit, SLOT(hide())); connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(interactiveRenameDone())); setAcceptDrops(true); }
void CTabWidget::tabChanged(int index) { if (index == count() - 1) { emit newTabRequested(); if (d.previous != -1) setCurrentIndex(d.previous); } else { d.previous = index; } }
void TabBar::mousePressEvent(QMouseEvent *event) { int index = tabAt(event->pos()); if (event->button() == Qt::MidButton) { event->accept(); if (index != -1) emit tabCloseRequested(index); else emit newTabRequested(); } else QTabBar::mousePressEvent(event); }
void WorkAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event) { int tabIndex = tabAt(event->pos()); // if tab was double-clicked, ignore this action if (tabIndex >= 0) return; int currentTab = currentIndex(); if (currentTab < 0) return; emit newTabRequested(currentTab); QTabBar::mouseDoubleClickEvent(event); }
/** * @brief Emits signal, based on specified action. Only actions * specified in this class are supported. If we don't know specified * action - no signal will be emited. * @param tabIndex: index of tab, for which signal will be emited. * @param action: context menu action. */ void WorkAreaTabBar::emitSignalForContextMenuAction(int tabIndex, QAction *action) { if (action == _newShellAction) emit newTabRequested(tabIndex); else if (action == _reloadShellAction) emit reloadTabRequested(tabIndex); else if (action == _duplicateShellAction) emit duplicateTabRequested(tabIndex); else if (action == _pinShellAction) emit pinTabRequested(tabIndex); else if (action == _closeShellAction) emit tabCloseRequested(tabIndex); else if (action == _closeOtherShellsAction) emit closeOtherTabsRequested(tabIndex); else if (action == _closeShellsToTheRightAction) emit closeTabsToTheRightRequested(tabIndex); }
void TabBar::mouseDoubleClickEvent(QMouseEvent* event) { if (QWhatsThis::inWhatsThisMode()) return; m_lineEdit->hide(); if (event->x() < 0) return; int index = tabAt(event->x()); if (event->button() == Qt::LeftButton) { if (event->x() <= m_tabWidths.last()) interactiveRename(m_tabs.at(index)); else if (event->x() > m_tabWidths.last()) emit newTabRequested(); } QWidget::mouseDoubleClickEvent(event); }
void DeclarativeTabModel::newTab(const QString &url, const QString &title) { // TODO: This doesn't really fit in here. We should consider adding of custom event for new tab creation. emit newTabRequested(url, title); }
void DeclarativeTabModel::newTab(const QString &url, const QString &title, int parentId) { emit newTabRequested(url, title, parentId); }
void DeclarativeTabModel::newTab(const QString &url, const QString &title, int parentId) { setWaitingForNewTab(true); emit newTabRequested(url, title, parentId); }
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), treeWidget(0), trayIcon(0), dockTile(0) { tabWidget = new MultiSessionTabWidget(this); connect(tabWidget, SIGNAL(newTabRequested()), this, SLOT(connectTo()), Qt::QueuedConnection); connect(tabWidget, SIGNAL(alerted(MessageView*,IrcMessage*)), this, SLOT(alert(MessageView*,IrcMessage*))); connect(tabWidget, SIGNAL(highlighted(MessageView*,IrcMessage*)), this, SLOT(highlight(MessageView*,IrcMessage*))); connect(tabWidget, SIGNAL(splitterChanged(QByteArray)), this, SLOT(splitterChanged(QByteArray))); connect(tabWidget, SIGNAL(sessionAdded(Session*)), this, SLOT(sessionAdded(Session*))); connect(tabWidget, SIGNAL(sessionRemoved(Session*)), this, SLOT(sessionRemoved(Session*))); HomePage* homePage = new HomePage(tabWidget); connect(homePage, SIGNAL(connectRequested()), this, SLOT(connectTo())); tabWidget->insertTab(0, homePage, tr("Home")); QSplitter* splitter = new QSplitter(this); splitter->setHandleWidth(1); splitter->addWidget(tabWidget); setCentralWidget(splitter); if (QSystemTrayIcon::isSystemTrayAvailable()) { trayIcon = new TrayIcon(this); trayIcon->setIcon(QApplication::windowIcon()); trayIcon->setVisible(true); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); } if (QtDockTile::isAvailable()) dockTile = new QtDockTile(this); QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+Q")), this); connect(shortcut, SIGNAL(activated()), this, SLOT(close())); #ifdef Q_WS_MAC QMenu* menu = new QMenu(this); menuBar()->addMenu(menu); QAction* action = new QAction(tr("Connect"), this); connect(action, SIGNAL(triggered()), this, SLOT(connectTo())); menu->addAction(action); action = new QAction(tr("Settings"), this); action->setMenuRole(QAction::PreferencesRole); connect(action, SIGNAL(triggered()), qApp, SLOT(showSettings())); menu->addAction(action); action = new QAction(tr("About %1").arg(Application::applicationName()), this); action->setMenuRole(QAction::AboutRole); connect(action, SIGNAL(triggered()), qApp, SLOT(aboutApplication())); menu->addAction(action); action = new QAction(tr("About Qt"), this); action->setMenuRole(QAction::AboutQtRole); connect(action, SIGNAL(triggered()), qApp, SLOT(aboutQt())); menu->addAction(action); #endif // Q_WS_MAC QSettings settings; if (settings.contains("geometry")) restoreGeometry(settings.value("geometry").toByteArray()); applySettings(Application::settings()); connect(qApp, SIGNAL(settingsChanged(Settings)), this, SLOT(applySettings(Settings))); QTimer::singleShot(1000, this, SLOT(initialize())); }
MainWindow::MainWindow(AudioPlayer &player, QWidget *parent) : QMainWindow(parent), statusBar_(this), player_(player), cursorFollowsPlayback_(false), saveTabs_(false) { setupUi(this); // Not saving a pointer to this QActionGroup *playbackOrderGroup = new QActionGroup(this); playbackOrderGroup->addAction(defaultAction); playbackOrderGroup->addAction(randomAction); playbackOrderGroup->addAction(repeatTrackAction); playbackOrderGroup->addAction(repeatPlaylistAction); installEventFilter(this); player.setMainWindow(this); QObject::connect(&player_, SIGNAL(playbackOrderChanged(PlaybackOrder)), this, SLOT(playbackOrderChanged(PlaybackOrder))); QObject::connect(&player_, SIGNAL(audioStateChanged(AudioState)), this, SLOT(slotAudioStateChanged(AudioState))); QObject::connect(&player_, SIGNAL(trackPlaying(PTrack)), this, SLOT(updateUI(PTrack))); playbackOrderChanged(player.playbackOrder()); QObject::connect(&player_, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); seekSlider_ = new SeekSlider(player_, this); volumeSlider_ = new QSlider(this); volumeSlider_->setOrientation(Qt::Horizontal); volumeSlider_->setMaximum(100); volumeSlider_->setMinimum(0); volumeSlider_->setValue(player_.volume() * 100); volumeSlider_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); QObject::connect(volumeSlider_, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int))); mainToolBar->addWidget(seekSlider_); mainToolBar->addWidget(volumeSlider_); trayIcon_ = new QSystemTrayIcon(this); setTrayIcon(false); connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); trayIcon_->show(); setStatusBar(&statusBar_); QObject::connect(&statusBar_, SIGNAL(statusBarDoubleClicked()), this, SLOT(statusBarDoubleClicked())); lyricsDock_ = new QDockWidget("Lyrics", this); // Not setting an object name because we don't want save its state // since Qt doesn't restore it correctly // lyricsDock_->setObjectName("LyricsDock"); lyricsWidget_ = new QPlainTextEdit(lyricsDock_); // lyricsWidget_->setObjectName("LyricsWidget"); lyricsWidget_->setReadOnly(true); lyricsDock_->setWidget(lyricsWidget_); QObject::connect(lyricsDock_, SIGNAL(visibilityChanged(bool)), this, SLOT(dockVisibilityChanged(bool))); // playlistTabs->setTabsClosable(true); QObject::connect(playlistTabs, SIGNAL(tabCloseRequested(int)), this, SLOT(removePlaylistTab(int))); QObject::connect(playlistTabs, SIGNAL(newTabRequested()), this, SLOT(newTabRequested())); QObject::connect(menu_File, SIGNAL(aboutToShow()), this, SLOT(menuFileAboutToShow())); setWindowIcon(QIcon(":/icon/logo22.png")); instance = this; console_ = new ConsoleWindow(this); QObject::connect(console_, SIGNAL(visibilityChanged(bool)), this, SLOT(consoleVisibilityChanged(bool))); readSettings(); config_.set("mainwindow.save_tabs", QVariant(saveTabs_)); QObject::connect(&config_, SIGNAL(keySet(QString, QVariant)), this, SLOT(configChanged(QString, QVariant))); setShortcuts(); }
WidgetIrcMain::WidgetIrcMain(QWidget* parent) : QWidget(parent), treeWidget(0), dockTile(0) { tabWidget = new MultiSessionTabWidget(this); qRegisterMetaTypeStreamOperators<ConnectionInfo>("ConnectionInfo"); qRegisterMetaTypeStreamOperators<ConnectionInfos>("ConnectionInfos"); connect(tabWidget, SIGNAL(newTabRequested()), this, SLOT(connectTo()), Qt::QueuedConnection); connect(tabWidget, SIGNAL(splitterChanged(QByteArray)), this, SLOT(splitterChanged(QByteArray))); WidgetIrcHomePage* homePage = new WidgetIrcHomePage(tabWidget); connect(homePage, SIGNAL(connectRequested()), this, SLOT(initialize())); tabWidget->insertTab(0, homePage, tr("Home")); splitterIrcMain = new QSplitter(this); splitterIrcMain->setHandleWidth(1); splitterIrcMain->addWidget(tabWidget); QVBoxLayout *centralLayout = new QVBoxLayout(this); setLayout(centralLayout); centralLayout->addWidget(splitterIrcMain); if (QtDockTile::isAvailable()) dockTile = new QtDockTile(this); QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+Q")), this); connect(shortcut, SIGNAL(activated()), this, SLOT(close())); #ifdef Q_WS_MAC QMenu* menu = new QMenu(this); menuBar()->addMenu(menu); QAction* action = new QAction(tr("Connect"), this); connect(action, SIGNAL(triggered()), this, SLOT(connectTo())); menu->addAction(action); action = new QAction(tr("Settings"), this); action->setMenuRole(QAction::PreferencesRole); connect(action, SIGNAL(triggered()), qApp, SLOT(showSettings())); menu->addAction(action); action = new QAction(tr("About %1").arg(Application::applicationName()), this); action->setMenuRole(QAction::AboutRole); connect(action, SIGNAL(triggered()), qApp, SLOT(aboutApplication())); menu->addAction(action); action = new QAction(tr("About Qt"), this); action->setMenuRole(QAction::AboutQtRole); connect(action, SIGNAL(triggered()), qApp, SLOT(aboutQt())); menu->addAction(action); #endif // Q_WS_MAC quazaaSettings.loadChat(); applySettings(); connect(&quazaaSettings, SIGNAL(chatSettingsChanged()), this, SLOT(applySettings())); QFile file(":Resource/stylesheet.css"); if (file.open(QFile::ReadOnly | QIODevice::Text)) setStyleSheet(QString::fromUtf8(file.readAll())); if(quazaaSettings.Chat.ConnectOnStartup) QTimer::singleShot(600, this, SLOT(initialize())); }
void TabWidget::slotNewTabRequested() { emit newTabRequested(); }