aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Ui')
-rw-r--r--src/plugins/Ui/skinned/actionmanager.cpp18
-rw-r--r--src/plugins/Ui/skinned/actionmanager.h3
-rw-r--r--src/plugins/Ui/skinned/hotkeyeditor.cpp4
-rw-r--r--src/plugins/Ui/skinned/hotkeyeditor.h5
-rw-r--r--src/plugins/Ui/skinned/listwidget.cpp46
-rw-r--r--src/plugins/Ui/skinned/listwidget.h2
-rw-r--r--src/plugins/Ui/skinned/playlist.cpp1
-rw-r--r--src/plugins/Ui/skinned/playstatus.h12
8 files changed, 50 insertions, 41 deletions
diff --git a/src/plugins/Ui/skinned/actionmanager.cpp b/src/plugins/Ui/skinned/actionmanager.cpp
index 1425879aa..189f56954 100644
--- a/src/plugins/Ui/skinned/actionmanager.cpp
+++ b/src/plugins/Ui/skinned/actionmanager.cpp
@@ -90,12 +90,14 @@ ActionManager::ActionManager(QObject *parent) :
m_actions[PL_SHOW_MANAGER] = createAction(tr("&Show Playlists"), "show_playlists",
tr("P"), "view-list-details");
m_actions[PL_GROUP_TRACKS] = createAction2(tr("&Group tracks"), "group_tracks", tr("Ctrl+G"));
+ m_actions[PL_SHOW_HEADER] = createAction2(tr("&Show header"), "show_header", tr("Ctrl+H"));
//other
m_actions[SETTINGS] = createAction(tr("&Settings"), "show_settings", tr("Ctrl+P"), "configure");
m_actions[ABOUT] = createAction(tr("&About"), "about", "");
m_actions[ABOUT_QT] = createAction(tr("&About Qt"), "about_qt", "");
m_actions[QUIT] = createAction(tr("&Exit"), "exit", tr("Ctrl+Q"), "application-exit");
m_settings->endGroup();
+ readStates();
delete m_settings;
m_settings = 0;
m_actions[ABOUT]->setIcon(qApp->windowIcon());
@@ -103,6 +105,7 @@ ActionManager::ActionManager(QObject *parent) :
ActionManager::~ActionManager()
{
+ saveStates();
m_instance = 0;
}
@@ -149,6 +152,21 @@ QAction *ActionManager::createAction2(QString name, QString confKey, QString key
return action;
}
+void ActionManager::readStates()
+{
+ m_settings->beginGroup("Skinned");
+ m_actions[PL_SHOW_HEADER]->setChecked(m_settings->value("pl_show_header", true).toBool());
+ m_settings->endGroup();
+}
+
+void ActionManager::saveStates()
+{
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ settings.beginGroup("Skinned");
+ settings.setValue("pl_show_header", m_actions[PL_SHOW_HEADER]->isChecked());
+ settings.endGroup();
+}
+
void ActionManager::saveActions()
{
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
diff --git a/src/plugins/Ui/skinned/actionmanager.h b/src/plugins/Ui/skinned/actionmanager.h
index a1f5d891d..1b6eb203e 100644
--- a/src/plugins/Ui/skinned/actionmanager.h
+++ b/src/plugins/Ui/skinned/actionmanager.h
@@ -90,6 +90,7 @@ public:
PL_SELECT_PREVIOUS,
PL_SHOW_MANAGER,
PL_GROUP_TRACKS,
+ PL_SHOW_HEADER,
SETTINGS,
ABOUT,
@@ -106,6 +107,8 @@ public:
private:
QAction *createAction(QString name, QString confKey, QString key, QString iconName = QString());
QAction *createAction2(QString name, QString confKey, QString key);
+ void readStates();
+ void saveStates();
QSettings *m_settings;
QHash <int, QAction *> m_actions;
diff --git a/src/plugins/Ui/skinned/hotkeyeditor.cpp b/src/plugins/Ui/skinned/hotkeyeditor.cpp
index fb9fe001f..951994a43 100644
--- a/src/plugins/Ui/skinned/hotkeyeditor.cpp
+++ b/src/plugins/Ui/skinned/hotkeyeditor.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011 by Ilya Kotov *
+ * Copyright (C) 2011-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -71,7 +71,7 @@ void HotkeyEditor::loadShortcuts()
m_ui->shortcutTreeWidget->addTopLevelItem(item);
//playlist
item = new QTreeWidgetItem (m_ui->shortcutTreeWidget, QStringList() << tr("Playlist"));
- for(int i = ActionManager::PL_ADD_FILE; i <= ActionManager::PL_GROUP_TRACKS; ++i)
+ for(int i = ActionManager::PL_ADD_FILE; i <= ActionManager::PL_SHOW_HEADER; ++i)
new ShortcutItem(item, i);
item->setExpanded(true);
m_ui->shortcutTreeWidget->addTopLevelItem(item);
diff --git a/src/plugins/Ui/skinned/hotkeyeditor.h b/src/plugins/Ui/skinned/hotkeyeditor.h
index 56bec1e0a..a2277b3f5 100644
--- a/src/plugins/Ui/skinned/hotkeyeditor.h
+++ b/src/plugins/Ui/skinned/hotkeyeditor.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011 by Ilya Kotov *
+ * Copyright (C) 2011-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -27,6 +27,9 @@ namespace Ui {
class HotkeyEditor;
}
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
class HotkeyEditor : public QWidget
{
Q_OBJECT
diff --git a/src/plugins/Ui/skinned/listwidget.cpp b/src/plugins/Ui/skinned/listwidget.cpp
index 835d97d40..7293e30f9 100644
--- a/src/plugins/Ui/skinned/listwidget.cpp
+++ b/src/plugins/Ui/skinned/listwidget.cpp
@@ -34,6 +34,7 @@
#include <qmmpui/playlistheadermodel.h>
#include "listwidget.h"
#include "playlistheader.h"
+#include "actionmanager.h"
#include "skin.h"
#include "popupwidget.h"
#include "playlist.h"
@@ -51,7 +52,7 @@ ListWidget::ListWidget(QWidget *parent)
m_timer->setInterval(50);
m_popupWidget = 0;
- m_header = 0;
+ m_header = new PlayListHeader(this);
m_update = false;
m_resize = false;
m_drop_index = INVALID_INDEX;
@@ -71,6 +72,7 @@ ListWidget::ListWidget(QWidget *parent)
connect(m_ui_settings, SIGNAL(repeatableTrackChanged(bool)), SLOT(updateRepeatIndicator()));
connect(m_timer, SIGNAL(timeout()), SLOT(autoscroll()));
connect(headerModel, SIGNAL(headerChanged()), SLOT(updateColumns()));
+ SET_ACTION(ActionManager::PL_SHOW_HEADER, this, SLOT(readSettings()));
}
ListWidget::~ListWidget()
@@ -85,31 +87,14 @@ void ListWidget::readSettings()
settings.beginGroup("Skinned");
m_show_protocol = settings.value ("pl_show_protocol", false).toBool();
bool show_popup = settings.value("pl_show_popup", false).toBool();
- bool show_header = settings.value("pl_show_header", true).toBool();
- if(m_update)
- {
- m_drawer.readSettings();
- }
-
- if(show_header && !m_header)
- {
- m_header = new PlayListHeader(this);
- m_header->setGeometry(0,0,width(), m_drawer.rowHeight());
- }
- else if(!show_header && m_header)
- {
- m_header->deleteLater();
- m_header = 0;
- }
- else if(m_header)
- {
- m_header->readSettings();
- }
+ m_header->readSettings();
+ m_header->setVisible(ACTION(ActionManager::PL_SHOW_HEADER)->isChecked());
if (m_update)
{
- m_row_count = (height() - (m_header ? m_header->height() : 0)) / m_drawer.rowHeight();
+ m_drawer.readSettings();
+ m_row_count = (height() - (m_header->isVisible() ? m_header->height() : 0)) / m_drawer.rowHeight();
updateList(PlayListModel::STRUCTURE);
if(m_popupWidget)
{
@@ -121,6 +106,7 @@ void ListWidget::readSettings()
{
m_update = true;
}
+
if(show_popup)
m_popupWidget = new PlayListPopup::PopupWidget(this);
}
@@ -262,7 +248,7 @@ void ListWidget::resizeEvent(QResizeEvent *e)
m_resize = true;
m_header->setGeometry(0,0,width(), m_drawer.rowHeight());
m_resize = false;
- m_row_count = (e->size().height() - (m_header ? m_header->height() : 0)) / m_drawer.rowHeight();
+ m_row_count = (e->size().height() - (m_header->isVisible() ? m_header->height() : 0)) / m_drawer.rowHeight();
updateList(PlayListModel::STRUCTURE);
QWidget::resizeEvent(e);
}
@@ -331,11 +317,7 @@ void ListWidget::updateList(int flags)
//song numbers width
m_drawer.calculateNumberWidth(m_model->trackCount());
- if(m_header)
- {
- m_header->setNumberWidth(m_drawer.numberWidth());
- m_header->hideSortIndicator();
- }
+ m_header->setNumberWidth(m_drawer.numberWidth());
items = m_model->mid(m_first, m_row_count);
@@ -349,6 +331,9 @@ void ListWidget::updateList(int flags)
items = m_model->mid(m_first, m_row_count);
}
+ if(flags & PlayListModel::STRUCTURE)
+ m_header->hideSortIndicator();
+
int prev_number = 0;
for(int i = 0; i < items.count(); ++i)
@@ -363,7 +348,7 @@ void ListWidget::updateList(int flags)
if(flags == PlayListModel::SELECTION)
continue;
- row->rect = QRect(5, (m_header ? m_header->height() : 0) + i * m_drawer.rowHeight(),
+ row->rect = QRect(5, (m_header->isVisible() ? m_header->height() : 0) + i * m_drawer.rowHeight(),
width() - 10, m_drawer.rowHeight() - 1);
row->titles = items[i]->formattedTitles();
@@ -619,8 +604,7 @@ void ListWidget::mouseReleaseEvent(QMouseEvent *e)
int ListWidget::indexAt(int y) const
{
- if(m_header)
- y -= m_header->height();
+ y -= m_header->isVisible() ? m_header->height() : 0;
for (int i = 0; i < qMin(m_row_count, m_model->count() - m_first); ++i)
{
if ((y >= i * m_drawer.rowHeight()) && (y <= (i+1) * m_drawer.rowHeight()))
diff --git a/src/plugins/Ui/skinned/listwidget.h b/src/plugins/Ui/skinned/listwidget.h
index dd1c5a28f..023d318b3 100644
--- a/src/plugins/Ui/skinned/listwidget.h
+++ b/src/plugins/Ui/skinned/listwidget.h
@@ -51,7 +51,6 @@ public:
~ListWidget();
- void readSettings();
/*!
* Returns count of currently visible rows.
*/
@@ -67,6 +66,7 @@ public:
PlayListModel *model();
public slots:
+ void readSettings();
void updateList(int flags);
void updateColumns();
void scroll(int); //0-99
diff --git a/src/plugins/Ui/skinned/playlist.cpp b/src/plugins/Ui/skinned/playlist.cpp
index 27352ae0e..2e772771a 100644
--- a/src/plugins/Ui/skinned/playlist.cpp
+++ b/src/plugins/Ui/skinned/playlist.cpp
@@ -316,6 +316,7 @@ void PlayList::createActions()
m_pl_manager, SLOT(reverseList()));
m_sortMenu->addAction(SET_ACTION(ActionManager::PL_GROUP_TRACKS, m_ui_settings, SLOT(setGroupsEnabled(bool))));
+ m_sortMenu->addAction(ACTION(ActionManager::PL_SHOW_HEADER));
ACTION(ActionManager::PL_GROUP_TRACKS)->setChecked(m_ui_settings->isGroupsEnabled());
//playlist context menu
m_listWidget->menu()->addAction(ActionManager::instance()->action(ActionManager::PL_SHOW_INFO));
diff --git a/src/plugins/Ui/skinned/playstatus.h b/src/plugins/Ui/skinned/playstatus.h
index a2139661d..f5fa6d8da 100644
--- a/src/plugins/Ui/skinned/playstatus.h
+++ b/src/plugins/Ui/skinned/playstatus.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -22,11 +22,11 @@
#include "pixmapwidget.h"
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
class Skin;
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
class PlayStatus : public PixmapWidget
{
Q_OBJECT
@@ -34,8 +34,8 @@ public:
PlayStatus(QWidget *parent = 0);
~PlayStatus();
-
- enum Type
+
+ enum Type
{
PLAY,
STOP,