mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-11 18:40:28 +00:00
- Disabled file counting to speed up sync
- Added better focus and tab control
This commit is contained in:
parent
32e5c2764e
commit
d776317e81
@ -52,6 +52,8 @@
|
||||
#include <boost/thread/xtime.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
static const std::string TAG = "Indexer";
|
||||
|
||||
using namespace musik::core;
|
||||
|
||||
Indexer::Indexer()
|
||||
@ -225,16 +227,16 @@ void Indexer::Synchronize() {
|
||||
|
||||
/* count the files that need to be processed */
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
this->status = 1;
|
||||
this->overallProgress = 0.0;
|
||||
}
|
||||
// {
|
||||
// boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
// this->status = 1;
|
||||
// this->overallProgress = 0.0;
|
||||
// }
|
||||
|
||||
for(std::size_t i = 0; i < paths.size(); ++i){
|
||||
std::string path = paths[i];
|
||||
this->CountFiles(path);
|
||||
}
|
||||
//for(std::size_t i = 0; i < paths.size(); ++i){
|
||||
// std::string path = paths[i];
|
||||
// this->CountFiles(path);
|
||||
// }
|
||||
|
||||
/* add new files */
|
||||
|
||||
@ -252,6 +254,8 @@ void Indexer::Synchronize() {
|
||||
|
||||
/* remove undesired entries from db (files themselves will remain) */
|
||||
|
||||
musik::debug::info(TAG, "cleanup 1/2");
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
this->status = 3;
|
||||
@ -264,6 +268,8 @@ void Indexer::Synchronize() {
|
||||
|
||||
/* cleanup -- remove stale artists, albums, genres, etc */
|
||||
|
||||
musik::debug::info(TAG, "cleanup 2/2");
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
this->overallProgress = 0.0;
|
||||
@ -277,6 +283,8 @@ void Indexer::Synchronize() {
|
||||
|
||||
/* optimize */
|
||||
|
||||
musik::debug::info(TAG, "optimizing");
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
this->overallProgress = 0.0;
|
||||
@ -295,6 +303,8 @@ void Indexer::Synchronize() {
|
||||
boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
this->status = 0;
|
||||
}
|
||||
|
||||
musik::debug::info(TAG, "done!");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
@ -403,8 +413,8 @@ void Indexer::SyncDirectory(
|
||||
for( ; file != end && !this->Exited() && !this->Restarted();++file) {
|
||||
if (is_directory(file->status())) {
|
||||
/* recursion here */
|
||||
musik::debug::info("indexer", this->GetStatus());
|
||||
this->SyncDirectory(file->path().string(), dirId,pathId,syncPath);
|
||||
musik::debug::info(TAG, "scanning " + file->path().string());
|
||||
this->SyncDirectory(file->path().string(), dirId, pathId, syncPath);
|
||||
}
|
||||
else {
|
||||
++this->filesIndexed;
|
||||
|
@ -15,5 +15,8 @@ void Colors::Init() {
|
||||
init_pair(BOX_COLOR_YELLOW_ON_BLACK, COLOR_YELLOW, COLOR_BLACK);
|
||||
init_pair(BOX_COLOR_WHITE_ON_BLACK, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(BOX_COLOR_RED_ON_BLACK, COLOR_RED, COLOR_BLACK);
|
||||
init_pair(BOX_COLOR_RED_ON_GREY, COLOR_RED, COLOR_WHITE);
|
||||
init_pair(BOX_COLOR_GREEN_ON_BLACK, COLOR_GREEN, COLOR_BLACK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#define BOX_COLOR_YELLOW_ON_BLACK 6
|
||||
#define BOX_COLOR_WHITE_ON_BLACK 7
|
||||
#define BOX_COLOR_RED_ON_BLACK 8
|
||||
#define BOX_COLOR_RED_ON_GREY 9
|
||||
#define BOX_COLOR_GREEN_ON_BLACK 10
|
||||
|
||||
class Colors {
|
||||
private:
|
||||
|
@ -39,7 +39,7 @@ CommandWindow::CommandWindow(Transport& transport, OutputWindow& output) {
|
||||
this->output = &output;
|
||||
this->paused = false;
|
||||
this->library = LibraryFactory::Libraries().at(0);
|
||||
this->output->WriteLine("type 'h' or 'help'\n");
|
||||
this->output->WriteLine("type 'h' or 'help'\n", BOX_COLOR_BLACK_ON_GREY);
|
||||
}
|
||||
|
||||
CommandWindow::~CommandWindow() {
|
||||
@ -66,9 +66,13 @@ void CommandWindow::WriteChar(int ch) {
|
||||
|
||||
if (!this->ProcessCommand(cmd)) {
|
||||
if (cmd.size()) {
|
||||
output->WriteLine("illegal command: '" + cmd + "'");
|
||||
output->WriteLine("> " + cmd, COLOR_PAIR(BOX_COLOR_BLACK_ON_GREY));
|
||||
output->WriteLine("illegal command: '" + cmd + "'\n", COLOR_PAIR(BOX_COLOR_RED_ON_GREY));
|
||||
}
|
||||
}
|
||||
else {
|
||||
output->WriteLine("> " + cmd + "\n", COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK));
|
||||
}
|
||||
|
||||
wclear(this->GetContents());
|
||||
this->bufferPosition = 0;
|
||||
@ -91,9 +95,9 @@ void CommandWindow::Seek(const std::vector<std::string>& args) {
|
||||
|
||||
void CommandWindow::SetVolume(const std::vector<std::string>& args) {
|
||||
if (args.size() > 0) {
|
||||
float newVolume = 0;
|
||||
if (tostr<float>(newVolume, args[0])) {
|
||||
this->SetVolume(newVolume);
|
||||
int newVolume = 0;
|
||||
if (tostr<int>(newVolume, args[0])) {
|
||||
this->SetVolume((float) newVolume / 100.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,16 +107,20 @@ void CommandWindow::SetVolume(float volume) {
|
||||
}
|
||||
|
||||
void CommandWindow::Help() {
|
||||
this->output->WriteLine("\nhelp:");
|
||||
this->output->WriteLine(" pl [file]: play file at path");
|
||||
this->output->WriteLine(" pa: toggle pause/resume");
|
||||
this->output->WriteLine(" st: stop playing");
|
||||
this->output->WriteLine(" ls: list currently playing");
|
||||
this->output->WriteLine(" lp: list loaded plugins");
|
||||
this->output->WriteLine(" v: <0.0-1.0>: set volume to p%");
|
||||
this->output->WriteLine(" sk <seconds>: seek to <seconds> into track");
|
||||
this->output->WriteLine(" rescan: rescan/index music directories");
|
||||
this->output->WriteLine("\n q: quit\n\n");
|
||||
int64 s = -1;
|
||||
this->output->WriteLine("\nhelp:\n", s);
|
||||
this->output->WriteLine(" <tab> to switch between windows\n", s);
|
||||
this->output->WriteLine(" pl [file]: play file at path", s);
|
||||
this->output->WriteLine(" pa: toggle pause/resume", s);
|
||||
this->output->WriteLine(" st: stop playing", s);
|
||||
//this->output->WriteLine(" ls: list currently playing", s);
|
||||
this->output->WriteLine(" lp: list loaded plugins", s);
|
||||
this->output->WriteLine(" v: <0 - 100>: set % volume", s);
|
||||
this->output->WriteLine(" sk <seconds>: seek to <seconds> into track", s);
|
||||
this->output->WriteLine(" addir <dir>: add a directory to be indexed", s);
|
||||
this->output->WriteLine(" rmdir <dir>: remove indexed directory path", s);
|
||||
this->output->WriteLine(" rescan: rescan metadata in index paths", s);
|
||||
this->output->WriteLine("\n q: quit\n\n", s);
|
||||
}
|
||||
|
||||
bool CommandWindow::ProcessCommand(const std::string& cmd) {
|
||||
@ -225,6 +233,6 @@ void CommandWindow::ListPlugins() const {
|
||||
"v" + std::string((*it)->Version()) + "\n"
|
||||
" author: " + std::string((*it)->Author()) + "\n";
|
||||
|
||||
this->output->WriteLine(format);
|
||||
this->output->WriteLine(format, BOX_COLOR_RED_ON_BLUE);
|
||||
}
|
||||
}
|
@ -3,19 +3,19 @@
|
||||
#include "curses_config.h"
|
||||
#include "BorderedWindow.h"
|
||||
#include "OutputWindow.h"
|
||||
|
||||
#include "IInput.h"
|
||||
#include <core/playback/Transport.h>
|
||||
#include <core/library/LibraryFactory.h>
|
||||
|
||||
using musik::core::LibraryPtr;
|
||||
using namespace musik::core::audio;
|
||||
|
||||
class CommandWindow : public BorderedWindow {
|
||||
class CommandWindow : public BorderedWindow, public IInput {
|
||||
public:
|
||||
CommandWindow(Transport& transport, OutputWindow& output);
|
||||
~CommandWindow();
|
||||
|
||||
void WriteChar(int ch);
|
||||
virtual void WriteChar(int ch);
|
||||
|
||||
private:
|
||||
void ListPlugins() const;
|
||||
|
8
src/musikbox/IInput.h
Executable file
8
src/musikbox/IInput.h
Executable file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
class IInput {
|
||||
public:
|
||||
virtual void WriteChar(int ch) = 0;
|
||||
};
|
@ -31,11 +31,15 @@ IScrollAdapter& LogWindow::GetScrollAdapter() {
|
||||
void LogWindow::Update() {
|
||||
boost::mutex::scoped_lock lock(pendingMutex);
|
||||
|
||||
if (!pending.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
WINDOW* contents = this->GetContents();
|
||||
|
||||
int64 attrs = COLOR_PAIR(BOX_COLOR_WHITE_ON_BLUE);
|
||||
|
||||
for (size_t i = 0; i < pending.size(); i++) {
|
||||
int64 attrs = COLOR_PAIR(BOX_COLOR_WHITE_ON_BLUE);
|
||||
|
||||
LogEntry* entry = pending[i];
|
||||
|
||||
switch (entry->level) {
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "OutputWindow.h"
|
||||
#include "TransportWindow.h"
|
||||
#include "ResourcesWindow.h"
|
||||
#include "IInput.h"
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
@ -95,49 +96,61 @@ int main(int argc, char* argv[])
|
||||
CommandWindow command(tp, output);
|
||||
TransportWindow transport(tp);
|
||||
|
||||
std::vector<ScrollableWindow*> order;
|
||||
std::vector<BorderedWindow*> order;
|
||||
order.push_back(&command);
|
||||
order.push_back(&logs);
|
||||
order.push_back(&output);
|
||||
|
||||
size_t index = 0;
|
||||
ScrollableWindow *scrollable = order.at(index);
|
||||
scrollable->SetBorderColor(BOX_COLOR_RED_ON_BLACK);
|
||||
BorderedWindow *focused = order.at(index);
|
||||
focused->SetBorderColor(BOX_COLOR_RED_ON_BLACK);
|
||||
|
||||
int ch;
|
||||
timeout(500);
|
||||
while (ch = getch()) {
|
||||
ScrollableWindow *scrollable = dynamic_cast<ScrollableWindow*>(focused);
|
||||
IInput *input = dynamic_cast<IInput*>(focused);
|
||||
|
||||
if (ch == -1) { /* timeout */
|
||||
logs.Update();
|
||||
transport.Repaint();
|
||||
resources.Repaint();
|
||||
}
|
||||
else if (ch == 9) { /* tab */
|
||||
scrollable->SetBorderColor(BOX_COLOR_WHITE_ON_BLACK);
|
||||
focused->SetBorderColor(BOX_COLOR_WHITE_ON_BLACK);
|
||||
|
||||
index++;
|
||||
if (index >= order.size()) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
scrollable = order.at(index);
|
||||
scrollable->SetBorderColor(BOX_COLOR_RED_ON_BLACK);
|
||||
focused = order.at(index);
|
||||
focused->SetBorderColor(BOX_COLOR_RED_ON_BLACK);
|
||||
}
|
||||
else if (ch >= KEY_F(0) && ch <= KEY_F(12)) {
|
||||
}
|
||||
else if (ch == KEY_NPAGE) {
|
||||
scrollable->PageDown();
|
||||
if (scrollable) {
|
||||
scrollable->PageDown();
|
||||
}
|
||||
}
|
||||
else if (ch == KEY_PPAGE) {
|
||||
scrollable->PageUp();
|
||||
if (scrollable) {
|
||||
scrollable->PageUp();
|
||||
}
|
||||
}
|
||||
else if (ch == KEY_DOWN) {
|
||||
scrollable->ScrollDown();
|
||||
if (scrollable) {
|
||||
scrollable->ScrollDown();
|
||||
}
|
||||
}
|
||||
else if (ch == KEY_UP) {
|
||||
scrollable->ScrollUp();
|
||||
if (scrollable) {
|
||||
scrollable->ScrollUp();
|
||||
}
|
||||
}
|
||||
else {
|
||||
command.WriteChar(ch);
|
||||
else if (input) {
|
||||
input->WriteChar(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ IScrollAdapter& OutputWindow::GetScrollAdapter() {
|
||||
return (IScrollAdapter&) *this->adapter;
|
||||
}
|
||||
|
||||
void OutputWindow::WriteLine(const std::string& text) {
|
||||
this->adapter->AddLine(text);
|
||||
void OutputWindow::WriteLine(const std::string& text, int64 attrs) {
|
||||
this->adapter->AddLine(text, attrs);
|
||||
this->OnAdapterChanged();
|
||||
}
|
@ -3,13 +3,14 @@
|
||||
#include "curses_config.h"
|
||||
#include "ScrollableWindow.h"
|
||||
#include "SimpleScrollAdapter.h"
|
||||
#include "Colors.h"
|
||||
|
||||
class OutputWindow : public ScrollableWindow {
|
||||
public:
|
||||
OutputWindow();
|
||||
~OutputWindow();
|
||||
|
||||
void WriteLine(const std::string& line);
|
||||
void WriteLine(const std::string& line, int64 attrs);
|
||||
virtual IScrollAdapter& GetScrollAdapter();
|
||||
|
||||
private:
|
||||
|
@ -118,6 +118,7 @@
|
||||
<ClCompile Include="BorderedWindow.cpp" />
|
||||
<ClCompile Include="Colors.cpp" />
|
||||
<ClCompile Include="CommandWindow.cpp" />
|
||||
<ClCompile Include="IInput.h" />
|
||||
<ClCompile Include="IScrollAdapter.h" />
|
||||
<ClCompile Include="LogWindow.cpp" />
|
||||
<ClCompile Include="OutputWindow.cpp" />
|
||||
|
@ -40,6 +40,9 @@
|
||||
<ClCompile Include="TransportWindow.cpp">
|
||||
<Filter>windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IInput.h">
|
||||
<Filter>curses</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="TransportEvents.h" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user