Skip to content

Instantly share code, notes, and snippets.

@Chocimier
Created April 4, 2014 17:47
Show Gist options
  • Save Chocimier/9979538 to your computer and use it in GitHub Desktop.
Save Chocimier/9979538 to your computer and use it in GitHub Desktop.
ikony
diff --git a/src/core/WindowsManager.cpp b/src/core/WindowsManager.cpp
index 024d59a..3c838d2 100644
--- a/src/core/WindowsManager.cpp
+++ b/src/core/WindowsManager.cpp
@@ -324,6 +324,7 @@ void WindowsManager::addWindow(Window *window, bool background)
connect(window, SIGNAL(requestedNewWindow(ContentsWidget*,bool,bool)), this, SLOT(openWindow(ContentsWidget*,bool,bool)));
connect(window, SIGNAL(requestedSearch(QString,QString)), this, SLOT(search(QString,QString)));
connect(window, SIGNAL(titleChanged(QString)), this, SLOT(setTitle(QString)));
+ connect(window, SIGNAL(iconChanged(QIcon)), this, SLOT(passIcon(QIcon)));
emit windowAdded(index);
}
@@ -562,6 +563,7 @@ void WindowsManager::setActiveWindow(int index)
m_statusBar->setZoomEnabled(window->getContentsWidget()->canZoom());
emit windowTitleChanged(QStringLiteral("%1 - Otter").arg(window->getContentsWidget()->getTitle()));
+ emit windowIconChanged(window->getContentsWidget()->getIcon());
if (window->getContentsWidget()->getUndoStack())
{
@@ -582,6 +584,16 @@ void WindowsManager::setActiveWindow(int index)
emit currentWindowChanged(index);
}
+void WindowsManager::passIcon(const QIcon &icon)
+{
+ const int index = getWindowIndex(qobject_cast<Window*>(sender()));
+
+ if (index == m_tabBar->currentIndex())
+ {
+ emit windowIconChanged(icon);
+ }
+}
+
void WindowsManager::setTitle(const QString &title)
{
const QString text = (title.isEmpty() ? tr("Empty") : title);
diff --git a/src/core/WindowsManager.h b/src/core/WindowsManager.h
index 960113a..61a8452 100644
--- a/src/core/WindowsManager.h
+++ b/src/core/WindowsManager.h
@@ -87,6 +87,7 @@ protected slots:
void closeWindow(Window *window);
void removeStoredUrl(const QString &url);
void setTitle(const QString &title);
+ void passIcon(const QIcon &icon);
private:
MdiWidget *m_mdi;
@@ -107,6 +108,7 @@ signals:
void windowRemoved(int index);
void currentWindowChanged(int index);
void windowTitleChanged(QString title);
+ void windowIconChanged(QIcon icon);
void closedWindowsAvailableChanged(bool available);
};
diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp
index 8f45b97..0c48b5b 100644
--- a/src/ui/MainWindow.cpp
+++ b/src/ui/MainWindow.cpp
@@ -157,6 +157,7 @@ MainWindow::MainWindow(bool privateSession, const SessionMainWindow &windows, QW
connect(m_windowsManager, SIGNAL(requestedAddBookmark(QUrl,QString)), this, SLOT(actionAddBookmark(QUrl,QString)));
connect(m_windowsManager, SIGNAL(requestedNewWindow(bool,bool,QUrl)), this, SIGNAL(requestedNewWindow(bool,bool,QUrl)));
connect(m_windowsManager, SIGNAL(windowTitleChanged(QString)), this, SLOT(setWindowTitle(QString)));
+ connect(m_windowsManager, SIGNAL(windowIconChanged(QIcon)), this, SLOT(changeIcon(QIcon)));
connect(m_windowsManager, SIGNAL(closedWindowsAvailableChanged(bool)), m_ui->tabsDockWidget, SLOT(setClosedWindowsMenuEnabled(bool)));
connect(m_windowsManager, SIGNAL(closedWindowsAvailableChanged(bool)), m_ui->menuClosedWindows, SLOT(setEnabled(bool)));
connect(m_windowsManager, SIGNAL(actionsChanged()), this, SLOT(updateActions()));
@@ -604,6 +605,11 @@ void MainWindow::actionAboutApplication()
QMessageBox::about(this, QLatin1String("Otter"), QString(tr("<b>Otter %1</b><br>Web browser controlled by the user, not vice-versa.").arg(QApplication::applicationVersion())));
}
+void MainWindow::changeIcon(const QIcon &icon)
+{
+ setWindowIcon(icon);
+}
+
void MainWindow::menuFileAboutToShow()
{
m_ui->actionWorkOffline->setChecked(SettingsManager::getValue(QLatin1String("Network/WorkOffline")).toBool());
diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
index a6babd0..7b37d5c 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -88,6 +88,7 @@ protected slots:
void actionTransfers();
void actionPreferences();
void actionAboutApplication();
+ void changeIcon(const QIcon &icon);
void menuFileAboutToShow();
void menuSessionsAboutToShow();
void menuUserAgentAboutToShow();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment