Example #1
0
void MainWindow::search() {
    SearchDialog dialog(this);
    
    if (dialog.exec() == QDialog::Accepted) {
        if (dialog.service() == Resources::SOUNDCLOUD) {
            SoundCloudTracksPage *page = new SoundCloudTracksPage(m_tabWidget);
            m_tabWidget->addTab(page, tr("Search '%1'").arg(dialog.query()));
            m_tabWidget->setCurrentWidget(page);
            connect(page, SIGNAL(statusChanged(Page::Status)), this, SLOT(onTabStatusChanged()));
            connect(page, SIGNAL(statusTextChanged(QString)), statusBar(), SLOT(showMessage(QString)));
            connect(page, SIGNAL(windowTitleChanged(QString)), this, SLOT(updateTabText(QString)));
            
            QVariantMap filters;
            filters["q"] = dialog.query();
            filters["limit"] = MAX_RESULTS;
            page->get("/tracks", filters);
        }
        else {
            PluginTracksPage *page = new PluginTracksPage(dialog.service(), m_tabWidget);
            m_tabWidget->addTab(page, tr("Search '%1'").arg(dialog.query()));
            m_tabWidget->setCurrentWidget(page);
            connect(page, SIGNAL(statusChanged(Page::Status)), this, SLOT(onTabStatusChanged()));
            connect(page, SIGNAL(statusTextChanged(QString)), statusBar(), SLOT(showMessage(QString)));
            connect(page, SIGNAL(windowTitleChanged(QString)), this, SLOT(updateTabText(QString)));
            page->search(dialog.query(), dialog.order());
        }
        
        m_reloadAction->setEnabled(true);
        m_closeAction->setEnabled(true);
    }
}
Example #2
0
void Mac::OSXStyle::removeWindow(QWidget *w) {
    if (w && windowMenu && actions.contains(w)) {
        QAction *act=actions.take(w);
        windowMenu->removeAction(act);
        disconnect(act, SIGNAL(triggered()), this, SLOT(showWindow()));
        disconnect(w, SIGNAL(windowTitleChanged(QString)), this, SLOT(windowTitleChanged()));
        act->deleteLater();
    }
}
Example #3
0
void Mac::OSXStyle::addWindow(QWidget *w) {
    if (w && windowMenu && !actions.contains(w)) {
        QAction *action=windowMenu->addAction(w->windowTitle());
        action->setCheckable(true);
        connect(action, SIGNAL(triggered()), this, SLOT(showWindow()));
        connect(w, SIGNAL(windowTitleChanged(QString)), this, SLOT(windowTitleChanged()));
        actions.insert(w, action);
    }
}
Example #4
0
void App::onNew()
{
    root->clear();
    filename.clear();
    stack->clear();
    emit(windowTitleChanged(getWindowTitle()));
}
Example #5
0
void Menu::populateWindowsMenu()
{
	if (actions().isEmpty())
	{
		MainWindow *mainWindow = MainWindow::findMainWindow(this);

		if (mainWindow)
		{
			connect(mainWindow->getWindowsManager(), SIGNAL(windowAdded(qint64)), this, SLOT(populateWindowsMenu()));
			connect(mainWindow->getWindowsManager(), SIGNAL(windowRemoved(qint64)), this, SLOT(populateWindowsMenu()));
			connect(mainWindow->getWindowsManager(), SIGNAL(windowTitleChanged(QString)), this, SLOT(populateWindowsMenu()));
		}

		disconnect(this, SIGNAL(aboutToShow()), this, SLOT(populateWindowsMenu()));
	}

	clear();

	MainWindow *mainWindow = MainWindow::findMainWindow(this);

	if (!mainWindow)
	{
		return;
	}

	for (int i = 0; i < mainWindow->getWindowsManager()->getWindowCount(); ++i)
	{
		Window *window = mainWindow->getWindowsManager()->getWindowByIndex(i);

		if (window)
		{
			QMenu::addAction(window->getIcon(), (window->getTitle().isEmpty() ? tr("(Untitled)") : Utils::elideText(window->getTitle())))->setData(window->getIdentifier());
		}
	}
}
void WindowsManager::setActiveWindowByIndex(int index)
{
	if (!m_isRestored || index >= m_mainWindow->getTabBar()->count())
	{
		return;
	}

	if (index != m_mainWindow->getTabBar()->currentIndex())
	{
		m_mainWindow->getTabBar()->setCurrentIndex(index);

		return;
	}

	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	if (window)
	{
		disconnect(window, SIGNAL(statusMessageChanged(QString)), this, SLOT(setStatusMessage(QString)));
		disconnect(window, SIGNAL(zoomChanged(int)), this, SIGNAL(zoomChanged(int)));
		disconnect(window, SIGNAL(canZoomChanged(bool)), this, SIGNAL(canZoomChanged(bool)));
	}

	setStatusMessage(QString());

	window = getWindowByIndex(index);

	m_mainWindow->setCurrentWindow(window);

	if (window)
	{
		m_mainWindow->getWorkspace()->setActiveWindow(window);

		window->setFocus();
		window->markActive();

		setStatusMessage(window->getContentsWidget()->getStatusMessage());

		emit windowTitleChanged(window->getContentsWidget()->getTitle());
		emit zoomChanged(window->getContentsWidget()->getZoom());
		emit canZoomChanged(window->getContentsWidget()->canZoom());

		connect(window, SIGNAL(statusMessageChanged(QString)), this, SLOT(setStatusMessage(QString)));
		connect(window, SIGNAL(zoomChanged(int)), this, SIGNAL(zoomChanged(int)));
		connect(window, SIGNAL(canZoomChanged(bool)), this, SIGNAL(canZoomChanged(bool)));
	}

	m_mainWindow->getAction(ActionsManager::CloneTabAction)->setEnabled(window && window->canClone());

	emit currentWindowChanged(window ? window->getIdentifier() : -1);
}
Example #7
0
EditDialog::EditDialog(EditWidgetInterface *editWidget, QWidget *parent) :
    QDialog(parent),
    m_editWidget(editWidget),
    m_closeAfterSave(true),
    m_saved(false)
{
    setFont(QFont("Tahoma",10));
    setWindowTitle(editWidget->windowTitle());

    m_btnSave = new QPushButton(tr("Save"),this);
    m_btnCancel = new QPushButton(tr("Cancel"),this);
    m_btnSave->setMinimumHeight(MIN_HEIGHT_BTN);
    m_btnCancel->setMinimumHeight(MIN_HEIGHT_BTN);

    QHBoxLayout *objectActionsLay = new QHBoxLayout();
    objectActionsLay->addStretch();
    objectActionsLay->addWidget(m_btnSave);
    objectActionsLay->addWidget(m_btnCancel);

    m_btnSave->setAutoDefault(false);
    m_btnCancel->setAutoDefault(false);
    m_btnSave->setDefault(false);
    m_btnCancel->setDefault(false);

    QVBoxLayout *centrLay = new QVBoxLayout(this);
    centrLay->addWidget(editWidget);

    QShortcut *scSave = new QShortcut(this);
    scSave->setKey(QKeySequence::Save);
    connect(scSave, SIGNAL(activated()), m_editWidget, SLOT(save()));

    QShortcut *scAccept = new QShortcut(this);
    scAccept->setKey(Qt::CTRL + Qt::Key_Return);
    connect(scAccept, SIGNAL(activated()), SLOT(accept()));


    centrLay->addLayout(objectActionsLay);
    centrLay->setMargin(4);
    setLayout(centrLay);

    setFocusProxy(editWidget);


    connect(m_btnCancel,SIGNAL(clicked()),SLOT(reject()));
    connect(editWidget,SIGNAL(windowTitleChanged(QString)),
            SLOT(setWindowTitle(QString)));
    connect(editWidget, SIGNAL(saved()), SLOT(onEditWidgetSaved()));
}
Example #8
0
bool MyEventFilter::eventFilter(QObject* obj, QEvent* event)
{
	if (event->type() == QEvent::WindowTitleChange)
	{
		QWidget* window = qobject_cast<QWidget*>(obj);
		if (window)
			emit windowTitleChanged(window->windowTitle());
	}
	else if (event->type() == QEvent::ModifiedChange)
	{
		QWidget* window = qobject_cast<QWidget*>(obj);
		if (window)
			emit modifiedChanged(window->isWindowModified());
	}

	return QObject::eventFilter(obj, event);
}
Example #9
0
void MainWindow::showTransfers() {
    for (int i = 0; i < m_tabWidget->count(); i++) {
        if (qobject_cast<TransfersPage*>(m_tabWidget->widget(i))) {
            m_tabWidget->setCurrentIndex(i);
            m_reloadAction->setEnabled(true);
            m_closeAction->setEnabled(true);
            return;
        }
    }
    
    TransfersPage *page = new TransfersPage(m_tabWidget);
    m_tabWidget->addTab(page, page->windowTitle());
    m_tabWidget->setCurrentIndex(m_tabWidget->count() - 1);
    connect(page, SIGNAL(statusChanged(Page::Status)), this, SLOT(onTabStatusChanged()));
    connect(page, SIGNAL(statusTextChanged(QString)), statusBar(), SLOT(showMessage(QString)));
    connect(page, SIGNAL(windowTitleChanged(QString)), this, SLOT(updateTabText(QString)));
    m_reloadAction->setEnabled(true);
    m_closeAction->setEnabled(true);
}
Example #10
0
void WindowsManager::setTitle(const QString &title)
{
	QString text = (title.isEmpty() ? tr("Empty") : title);
	Window *window = qobject_cast<Window*>(sender());

	if (!window)
	{
		return;
	}

	const int index = getWindowIndex(window->getIdentifier());

	if (index == m_mainWindow->getTabBar()->currentIndex())
	{
		emit windowTitleChanged(text);
	}

	m_mainWindow->getTabBar()->setTabText(index, text.replace(QLatin1Char('&'), QLatin1String("&&")));
}
Example #11
0
void App::loadFile(QString f)
{
    filename = f;
    root->clear();
    root->uninstallWatcher(view_scene);

    QFile file(f);
    if (!file.open(QIODevice::ReadOnly))
    {
        QMessageBox::critical(NULL, "Loading error",
                              "<b>Loading error:</b><br>"
                              "File does not exist.");
        onNew();
        return;
    }

    SceneDeserializer::Info ds;
    const bool success = SceneDeserializer::run(
                             QJsonDocument::fromJson(file.readAll()).object(),
                             root, &ds);

    if (!success)
    {
        QMessageBox::critical(NULL, "Loading error",
                              "<b>Loading error:</b><br>" +
                              ds.error_message);
        onNew();
    } else {
        // If there's a warning message, show it in a box.
        if (!ds.warning_message.isNull())
            QMessageBox::information(NULL, "Loading information",
                                     "<b>Loading information:</b><br>" +
                                     ds.warning_message);

        graph_scene->setInspectorPositions(ds.inspectors);
        emit(windowTitleChanged(getWindowTitle()));
    }

    root->installWatcher(view_scene);
    view_scene->trigger(root->getState());
}
Example #12
0
void App::onSaveAs()
{
    QString f = QFileDialog::getSaveFileName(NULL, "Save as", "", "*.sb");
    if (!f.isEmpty())
    {
#ifdef Q_OS_LINUX
        if (!f.endsWith(".sb"))
            f += ".sb";
#endif
        if (!QFileInfo(QFileInfo(f).path()).isWritable())
        {
            QMessageBox::critical(NULL, "Save As error",
                                  "<b>Save As error:</b><br>"
                                  "Target file is not writable.");
            return;
        }
        filename = f;
        emit(windowTitleChanged(getWindowTitle()));
        return onSave();
    }
}
Example #13
0
App::App(int& argc, char** argv) :
    QApplication(argc, argv), root(new Graph()),
    graph_scene(new GraphScene(root)),
    view_scene(new ViewportScene(root)),
    stack(new UndoStack(this)), network(new QNetworkAccessManager(this))
{
    setGlobalStyle();

    root->installExternalHooks(new AppHooks(graph_scene));

    // When the clean flag on the undo stack changes, update window titles
    connect(stack, &QUndoStack::cleanChanged,
    [&](bool) {
        emit(windowTitleChanged(getWindowTitle()));
    });

    connect(view_scene, &ViewportScene::glowChanged,
            graph_scene, &GraphScene::onGlowChange);
    connect(graph_scene, &GraphScene::glowChanged,
            view_scene, &ViewportScene::onGlowChange);

    connect(network, &QNetworkAccessManager::finished,
            this, &App::onUpdateCheckFinished);
}
Example #14
0
bool WindowsManager::event(QEvent *event)
{
	if (event->type() == QEvent::LanguageChange)
	{
		for (int i = 0; i < m_mainWindow->getTabBar()->count(); ++i)
		{
			Window *window = getWindowByIndex(i);

			if (window)
			{
				QString text = (window->getTitle().isEmpty() ? tr("Empty") : window->getTitle());

				if (i == m_mainWindow->getTabBar()->currentIndex())
				{
					emit windowTitleChanged(text);
				}

				m_mainWindow->getTabBar()->setTabText(i, text.replace(QLatin1Char('&'), QLatin1String("&&")));
			}
		}
	}

	return QObject::event(event);
}
void MainWindow::setWindowTitle(const QString &title)
{
    QMainWindow::setWindowTitle(title);
    emit windowTitleChanged();
}
Example #16
0
void WindowsManager::closeWindow(Window *window)
{
	const int index = getWindowIndex(window);

	if (index < 0)
	{
		return;
	}

	if (window && !window->isPrivate())
	{
		const WindowHistoryInformation history = window->getContentsWidget()->getHistory();

		if (!window->isUrlEmpty() || history.entries.count() > 1)
		{
			const SessionWindow information = window->getSession();

			if (window->getType() != QLatin1String("web"))
			{
				removeStoredUrl(information.getUrl());
			}

			m_closedWindows.prepend(information);

			emit closedWindowsAvailableChanged(true);
		}
	}

	const QString lastTabClosingAction = SettingsManager::getValue(QLatin1String("TabBar/LastTabClosingAction")).toString();

	if (m_tabBar->count() == 1)
	{
		if (lastTabClosingAction == QLatin1String("closeWindow"))
		{
			ActionsManager::triggerAction(QLatin1String("CloseWindow"), m_mdi);

			return;
		}

		if (lastTabClosingAction == QLatin1String("openTab"))
		{
			window = getWindow(0);

			if (window)
			{
				window->clear();

				return;
			}
		}
		else
		{
			ActionsManager::getAction(QLatin1String("CloneTab"), m_mdi)->setEnabled(false);

			emit windowTitleChanged(QString());
		}
	}

	m_tabBar->removeTab(index);

	emit windowRemoved(index);

	if (m_tabBar->count() < 1 && lastTabClosingAction != QLatin1String("doNothing"))
	{
		open();
	}
}
Example #17
0
void MainWindow::setWindowTitle(const QString &title) {
    if (windowTitle() != title) {
        QMainWindow::setWindowTitle(title);
        Q_EMIT windowTitleChanged(windowTitle());
    }
}
Example #18
0
void WindowsManager::handleWindowClose(Window *window)
{
	const int index = (window ? getWindowIndex(window->getIdentifier()) : -1);

	if (index < 0)
	{
		return;
	}

	if (window && !window->isPrivate())
	{
		const WindowHistoryInformation history = window->getContentsWidget()->getHistory();

		if (!Utils::isUrlEmpty(window->getUrl()) || history.entries.count() > 1)
		{
			Window *nextWindow = getWindowByIndex(index + 1);
			Window *previousWindow = ((index > 0) ? getWindowByIndex(index - 1) : NULL);

			ClosedWindow closedWindow;
			closedWindow.window = window->getSession();
			closedWindow.nextWindow = (nextWindow ? nextWindow->getIdentifier() : 0);
			closedWindow.previousWindow = (previousWindow ? previousWindow->getIdentifier() : 0);

			if (window->getType() != QLatin1String("web"))
			{
				removeStoredUrl(closedWindow.window.getUrl());
			}

			m_closedWindows.prepend(closedWindow);

			emit closedWindowsAvailableChanged(true);
		}
	}

	const QString lastTabClosingAction = SettingsManager::getValue(QLatin1String("Interface/LastTabClosingAction")).toString();

	if (m_mainWindow->getTabBar()->count() == 1)
	{
		if (lastTabClosingAction == QLatin1String("closeWindow") || (lastTabClosingAction == QLatin1String("closeWindowIfNotLast") && SessionsManager::getWindows().count() > 1))
		{
			m_mainWindow->triggerAction(ActionsManager::CloseWindowAction);

			return;
		}

		if (lastTabClosingAction == QLatin1String("openTab"))
		{
			window = getWindowByIndex(0);

			if (window)
			{
				window->clear();

				return;
			}
		}
		else
		{
			m_mainWindow->getAction(ActionsManager::CloseTabAction)->setEnabled(false);
			m_mainWindow->setCurrentWindow(NULL);

			emit windowTitleChanged(QString());
		}
	}

	m_mainWindow->getTabBar()->removeTab(index);

	Action *closePrivateTabsAction = m_mainWindow->getAction(ActionsManager::ClosePrivateTabsAction);

	if (closePrivateTabsAction->isEnabled() && getWindowCount(true) == 0)
	{
		closePrivateTabsAction->setEnabled(false);
	}

	emit windowRemoved(window->getIdentifier());

	m_windows.remove(window->getIdentifier());

	if (m_mainWindow->getTabBar()->count() < 1 && lastTabClosingAction == QLatin1String("openTab"))
	{
		open();
	}
}
Example #19
0
void Util::setWindowTitle(QString title)
{
    iCurrentWinTitle = title;
    iWindow->setTitle(title);
    emit windowTitleChanged();
}