diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9de264d4f..34e0440dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,6 +134,7 @@ set(SOURCES devices/deviceproperties.cpp devices/devicestatefiltermodel.cpp devices/deviceview.cpp + devices/deviceviewcontainer.cpp devices/filesystemdevice.cpp engines/enginebase.cpp @@ -446,6 +447,7 @@ set(HEADERS devices/deviceproperties.h devices/devicestatefiltermodel.h devices/deviceview.h + devices/deviceviewcontainer.h devices/filesystemdevice.h engines/enginebase.h @@ -672,6 +674,7 @@ set(UI covers/coversearchstatisticsdialog.ui devices/deviceproperties.ui + devices/deviceviewcontainer.ui globalsearch/globalsearchsettingspage.ui globalsearch/globalsearchview.ui diff --git a/src/devices/deviceviewcontainer.cpp b/src/devices/deviceviewcontainer.cpp new file mode 100644 index 000000000..eb2de1926 --- /dev/null +++ b/src/devices/deviceviewcontainer.cpp @@ -0,0 +1,56 @@ +/* This file is part of Clementine. + Copyright 2012, David Sansome + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#include "deviceviewcontainer.h" +#include "ui_deviceviewcontainer.h" +#include "ui/iconloader.h" + +DeviceViewContainer::DeviceViewContainer(QWidget *parent) + : QWidget(parent), + ui_(new Ui::DeviceViewContainer), + loaded_icons_(false) { + ui_->setupUi(this); + + QPalette palette(ui_->windows_is_broken_frame->palette()); + palette.setColor(QPalette::Background, QColor(255, 255, 222)); + ui_->windows_is_broken_frame->setPalette(palette); + +#ifdef Q_OS_WIN + ui_->windows_is_broken_frame->show(); +#else + ui_->windows_is_broken_frame->hide(); +#endif +} + +DeviceViewContainer::~DeviceViewContainer() { + delete ui_; +} + +void DeviceViewContainer::showEvent(QShowEvent* e) { + if (!loaded_icons_) { + loaded_icons_ = true; + + ui_->close_frame_button->setIcon(IconLoader::Load("edit-delete")); + ui_->warning_icon->setPixmap(IconLoader::Load("dialog-warning").pixmap(22)); + } + + QWidget::showEvent(e); +} + +DeviceView* DeviceViewContainer::view() const { + return ui_->view; +} diff --git a/src/devices/deviceviewcontainer.h b/src/devices/deviceviewcontainer.h new file mode 100644 index 000000000..ae28b8ecc --- /dev/null +++ b/src/devices/deviceviewcontainer.h @@ -0,0 +1,46 @@ +/* This file is part of Clementine. + Copyright 2012, David Sansome + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef DEVICEVIEWCONTAINER_H +#define DEVICEVIEWCONTAINER_H + +#include + +namespace Ui { + class DeviceViewContainer; +} + +class DeviceView; + +class DeviceViewContainer : public QWidget { + Q_OBJECT + + public: + explicit DeviceViewContainer(QWidget* parent = 0); + ~DeviceViewContainer(); + + DeviceView* view() const; + + protected: + void showEvent(QShowEvent*); + + private: + Ui::DeviceViewContainer* ui_; + bool loaded_icons_; +}; + +#endif // DEVICEVIEWCONTAINER_H diff --git a/src/devices/deviceviewcontainer.ui b/src/devices/deviceviewcontainer.ui new file mode 100644 index 000000000..6084fae3c --- /dev/null +++ b/src/devices/deviceviewcontainer.ui @@ -0,0 +1,99 @@ + + + DeviceViewContainer + + + + 0 + 0 + 391 + 396 + + + + Form + + + + 0 + + + 0 + + + + + true + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + 0 + 0 + + + + iPods and USB devices currently don't work on Windows. Sorry! + + + true + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + DeviceView + QWidget +
devices/deviceview.h
+ 1 +
+
+ + + + close_frame_button + clicked() + windows_is_broken_frame + hide() + + + 362 + 31 + + + 369 + 40 + + + + +
diff --git a/src/playlist/playlistlistcontainer.cpp b/src/playlist/playlistlistcontainer.cpp index 9a2929169..2f42c69f2 100644 --- a/src/playlist/playlistlistcontainer.cpp +++ b/src/playlist/playlistlistcontainer.cpp @@ -101,6 +101,7 @@ PlaylistListContainer::~PlaylistListContainer() { void PlaylistListContainer::showEvent(QShowEvent* e) { // Loading icons is expensive so only do it when the view is first opened if (loaded_icons_) { + QWidget::showEvent(e); return; } loaded_icons_ = true; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 1aa3bc0a9..639704564 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -41,6 +41,7 @@ #include "devices/devicemanager.h" #include "devices/devicestatefiltermodel.h" #include "devices/deviceview.h" +#include "devices/deviceviewcontainer.h" #include "engines/enginebase.h" #include "engines/gstengine.h" #include "globalsearch/globalsearch.h" @@ -172,7 +173,8 @@ MainWindow::MainWindow(Application* app, file_view_(new FileView(this)), playlist_list_(new PlaylistListContainer(this)), internet_view_(new InternetViewContainer(this)), - device_view_(new DeviceView(this)), + device_view_container_(new DeviceViewContainer(this)), + device_view_(device_view_container_->view()), song_info_view_(new SongInfoView(this)), artist_info_view_(new ArtistInfoView(this)), settings_dialog_(NULL), @@ -237,7 +239,7 @@ MainWindow::MainWindow(Application* app, ui_->tabs->AddTab(file_view_, IconLoader::Load("document-open"), tr("Files")); ui_->tabs->AddTab(playlist_list_, IconLoader::Load("view-media-playlist"), tr("Playlists")); ui_->tabs->AddTab(internet_view_, IconLoader::Load("applications-internet"), tr("Internet")); - ui_->tabs->AddTab(device_view_, IconLoader::Load("multimedia-player-ipod-mini-blue"), tr("Devices")); + ui_->tabs->AddTab(device_view_container_, IconLoader::Load("multimedia-player-ipod-mini-blue"), tr("Devices")); ui_->tabs->AddSpacer(); ui_->tabs->AddTab(song_info_view_, IconLoader::Load("view-media-lyrics"), tr("Song info")); ui_->tabs->AddTab(artist_info_view_, IconLoader::Load("x-clementine-artist"), tr("Artist info")); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 9d25ab01e..8779e84ee 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -44,6 +44,7 @@ class CoverProviders; class Database; class DeviceManager; class DeviceView; +class DeviceViewContainer; class EditTagDialog; class Equalizer; class ErrorDialog; @@ -289,6 +290,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { FileView* file_view_; PlaylistListContainer* playlist_list_; InternetViewContainer* internet_view_; + DeviceViewContainer* device_view_container_; DeviceView* device_view_; SongInfoView* song_info_view_; ArtistInfoView* artist_info_view_;