#include "mac_startup.h"
#endif
+#ifdef Q_WS_X11
+QString getThemeName() {
+ QString themeName;
+
+ QProcess process;
+ process.start("dconf",
+ QStringList() << "read" << "/org/gnome/desktop/interface/gtk-theme");
+ if (process.waitForFinished()) {
+ themeName = process.readAllStandardOutput();
+ themeName = themeName.trimmed();
+ themeName.remove('\'');
+ if (!themeName.isEmpty()) return themeName;
+ }
+
+ QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
+ if (!rcPaths.isEmpty()) {
+ QStringList paths = rcPaths.split(QLatin1String(":"));
+ foreach (const QString &rcPath, paths) {
+ if (!rcPath.isEmpty()) {
+ QFile rcFile(rcPath);
+ if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&rcFile);
+ while(!in.atEnd()) {
+ QString line = in.readLine();
+ if (line.contains(QLatin1String("gtk-theme-name"))) {
+ line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
+ line.remove(QLatin1Char('\"'));
+ line = line.trimmed();
+ themeName = line;
+ break;
+ }
+ }
+ }
+ }
+ if (!themeName.isEmpty())
+ break;
+ }
+ }
+
+ // Fall back to gconf
+ if (themeName.isEmpty())
+ themeName = QGtkStyle::getGConfString(QLatin1String("/desktop/gnome/interface/gtk_theme"));
+
+ return themeName;
+}
+#endif
+
int main(int argc, char **argv) {
#ifdef Q_WS_MAC
app.setApplicationName(Constants::NAME);
app.setOrganizationName(Constants::ORG_NAME);
app.setOrganizationDomain(Constants::ORG_DOMAIN);
-#ifndef APP_WIN
app.setWheelScrollLines(1);
-#endif
app.setAttribute(Qt::AA_DontShowIconsInMenus);
#ifndef Q_WS_X11
Extra::appSetup(&app);
#else
+ bool isGtk = app.style()->metaObject()->className() == QLatin1String("QGtkStyle");
+ if (isGtk) {
+ app.setProperty("gtk", isGtk);
+ QString themeName = getThemeName();
+ app.setProperty("style", themeName);
+ }
QFile cssFile(":/style.css");
cssFile.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(cssFile.readAll());
#ifndef Q_WS_X11
Extra::windowSetup(&mainWin);
+#else
+ mainWin.setProperty("style", app.property("style"));
#endif
// no window icon on Mac
mainWin.setWindowIcon(appIcon);
#endif
- mainWin.show();
-
mainWin.connect(&app, SIGNAL(messageReceived(const QString &)), &mainWin, SLOT(messageReceived(const QString &)));
app.setActivationWindow(&mainWin, true);
}
}
+ mainWin.show();
+
// Seed random number generator
qsrand(QDateTime::currentDateTime().toTime_t());
// views mechanism
history = new QStack<QWidget*>();
- views = new QStackedWidget(this);
+ views = new QStackedWidget();
+ views->hide();
+ setCentralWidget(views);
// views
homeView = new HomeView(this);
showActivationView(false);
#endif
- setCentralWidget(views);
+ views->show();
// Global shortcuts
GlobalShortcuts &shortcuts = GlobalShortcuts::instance();
action->setStatusTip(tr("Show details about video downloads"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
action->setCheckable(true);
- action->setIcon(Utils::icon("go-down"));
+ action->setIcon(Utils::icon("document-save"));
action->setVisible(false);
connect(action, SIGNAL(toggled(bool)), SLOT(toggleDownloads(bool)));
actions->insert("downloads", action);
#ifndef APP_NO_DOWNLOADS
action->setShortcut(QKeySequence::Save);
#endif
- action->setIcon(Utils::icon("go-down"));
+ action->setIcon(Utils::icon("document-save"));
action->setEnabled(false);
#if QT_VERSION >= 0x040600
action->setPriority(QAction::LowPriority);
action = new QAction(tr("More..."), this);
actions->insert("more-region", action);
- action = new QAction(Utils::icon("related-videos"), tr("&Related Videos"), this);
+ action = new QAction(Utils::icon(QStringList() << "view-list" << "format-justify-fill"), tr("&Related Videos"), this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
action->setStatusTip(tr("Watch videos related to the current one"));
action->setEnabled(false);
setUnifiedTitleAndToolBarOnMac(true);
mainToolBar = new QToolBar(this);
-#if QT_VERSION < 0x040600 | defined(APP_MAC)
mainToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
-#else
- mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
-#endif
mainToolBar->setFloatable(false);
mainToolBar->setMovable(false);
mainToolBar->addAction(stopAct);
mainToolBar->addAction(pauseAct);
mainToolBar->addAction(skipAct);
+
mainToolBar->addAction(The::globalActions()->value("related-videos"));
+#ifndef APP_NO_DOWNLOADS
+ mainToolBar->addAction(The::globalActions()->value("download"));
+#endif
bool addFullScreenAct = true;
#ifdef Q_WS_MAC
#endif
if (addFullScreenAct) mainToolBar->addAction(fullscreenAct);
-#ifndef APP_NO_DOWNLOADS
- mainToolBar->addAction(The::globalActions()->value("download"));
-#endif
-
mainToolBar->addWidget(new Spacer());
QFont smallerFont = FontUtils::small();
regionButton = new QToolButton(this);
regionButton->setStatusTip(tr("Choose your content location"));
- regionButton->setIcon(Utils::icon("go-down"));
regionButton->setIconSize(QSize(16, 16));
regionButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
regionAction = statusToolBar->addWidget(regionButton);
#include "extra.h"
#endif
-QIcon Utils::icon(const QString &name) {
+QIcon getIcon(const QString &name) {
#ifdef Q_WS_X11
return QIcon::fromTheme(name);
#else
return Extra::getIcon(name);
#endif
}
+
+QIcon Utils::icon(const QString &name) {
+#ifdef Q_WS_X11
+ QString themeName = qApp->property("style").toString();
+ if (themeName == "Ambiance")
+ return icon(QStringList() << name + "-symbolic" << name);
+ else return getIcon(name);
+#else
+ return Extra::getIcon(name);
+#endif
+}
+
+QIcon Utils::icon(const QStringList &names) {
+ QIcon icon;
+ foreach (QString name, names) {
+ icon = getIcon(name);
+ if (!icon.availableSizes().isEmpty()) break;
+ }
+ return icon;
+}
#ifndef UTILS_H
#define UTILS_H
-#include <QtCore>
+#include <QtGui>
class Utils {
public:
static QIcon icon(const QString &name);
+ static QIcon icon(const QStringList &names);
private:
Utils() { }
SidebarHeader {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #262626, stop: 1 #3c3c3c);
- border: 0;
padding: 0;
margin: 0;
spacing: 0;
+ border-bottom: 1px solid black;
}
SidebarHeader QToolButton {
width: 0;
border-style: none;
}
+
+/* Ambiance */
+
+MainWindow[style="Ambiance"] > QToolBar {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #3c3b37, stop: 1 #474641);
+ border-top: 1px solid #474641;
+}
+
+MainWindow[style="Ambiance"] > QToolBar QLabel {
+ color: #dfdbd2;
+}
+
+MainWindow[style="Ambiance"] QSlider::groove:horizontal {
+ border: 1px solid #808080;
+ height: 8px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #ccc);
+ border-radius: 5px;
+}
+
+MainWindow[style="Ambiance"] QSlider::sub-page:horizontal {
+ border: 1px solid #808080;
+ height: 8px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #6c6c6c, stop:1 #B1B1B1);
+ border-radius: 5px;
+}
+
+MainWindow[style="Ambiance"] QSlider::handle:horizontal {
+ border: 1px solid #5c5c5c;
+ width: 14px;
+ height: 16px;
+ margin: -4px 0;
+ border-radius: 8px;
+ background: qradialgradient(
+ cx: .5, cy: .5,
+ fx: .33, fy: .33,
+ radius: .5,
+ stop: 0 #fff, stop: 1 #ccc);
+}
+
+MainWindow[style="Ambiance"] QSlider::handle:pressed {
+ background: qradialgradient(
+ cx: .5, cy: .5,
+ fx: .33, fy: .33,
+ radius: .5,
+ stop: 0 #ccc, stop: 1 #9c9c9c);
+}
+
+MainWindow[style="Ambiance"] Phonon--SeekSlider QSlider::sub-page:horizontal {
+ border: 1px solid #808080;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #6c6c6c);
+}