Beispiel #1
0
bool OrganiseDialog::SetSongs(const SongList& songs) {
  total_size_ = 0;
  songs_.clear();

  for (const Song& song : songs) {
    if (song.url().scheme() != "file") {
      continue;
    }

    if (song.filesize() > 0) total_size_ += song.filesize();

    songs_ << song;
  }

  ui_->free_space->set_additional_bytes(total_size_);
  UpdatePreviews();
  SetLoadingSongs(false);

  if (songs_future_.isRunning()) {
    songs_future_.cancel();
  }
  songs_future_ = QFuture<SongList>();

  return songs_.count();
}
Beispiel #2
0
OrganiseDialog::OrganiseDialog(TaskManager* task_manager, QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_OrganiseDialog),
      task_manager_(task_manager),
      total_size_(0),
      resized_by_user_(false) {
  ui_->setupUi(this);
  connect(ui_->button_box->button(QDialogButtonBox::Reset), SIGNAL(clicked()),
          SLOT(Reset()));

  ui_->aftercopying->setItemIcon(1, IconLoader::Load("edit-delete"));

  // Valid tags
  QMap<QString, QString> tags;
  tags[tr("Title")] = "title";
  tags[tr("Album")] = "album";
  tags[tr("Artist")] = "artist";
  tags[tr("Artist's initial")] = "artistinitial";
  tags[tr("Album artist")] = "albumartist";
  tags[tr("Composer")] = "composer";
  tags[tr("Performer")] = "performer";
  tags[tr("Grouping")] = "grouping";
  tags[tr("Lyrics")] = "lyrics";
  tags[tr("Track")] = "track";
  tags[tr("Disc")] = "disc";
  tags[tr("BPM")] = "bpm";
  tags[tr("Year")] = "year";
  tags[tr("Genre")] = "genre";
  tags[tr("Comment")] = "comment";
  tags[tr("Length")] = "length";
  tags[tr("Bitrate", "Refers to bitrate in file organise dialog.")] = "bitrate";
  tags[tr("Samplerate")] = "samplerate";
  tags[tr("File extension")] = "extension";

  // Naming scheme input field
  new OrganiseFormat::SyntaxHighlighter(ui_->naming);

  connect(ui_->destination, SIGNAL(currentIndexChanged(int)),
          SLOT(UpdatePreviews()));
  connect(ui_->naming, SIGNAL(textChanged()), SLOT(UpdatePreviews()));
  connect(ui_->replace_ascii, SIGNAL(toggled(bool)), SLOT(UpdatePreviews()));
  connect(ui_->replace_the, SIGNAL(toggled(bool)), SLOT(UpdatePreviews()));
  connect(ui_->replace_spaces, SIGNAL(toggled(bool)), SLOT(UpdatePreviews()));

  // Get the titles of the tags to put in the insert menu
  QStringList tag_titles = tags.keys();
  qStableSort(tag_titles);

  // Build the insert menu
  QMenu* tag_menu = new QMenu(this);
  QSignalMapper* tag_mapper = new QSignalMapper(this);
  for (const QString& title : tag_titles) {
    QAction* action = tag_menu->addAction(title, tag_mapper, SLOT(map()));
    tag_mapper->setMapping(action, tags[title]);
  }

  connect(tag_mapper, SIGNAL(mapped(QString)), SLOT(InsertTag(QString)));
  ui_->insert->setMenu(tag_menu);
}
void CConfigurationDialog::OnInputChange(wxCommandEvent& event)
{
	UpdatePreviews();
}
CConfigurationDialog::CConfigurationDialog() : wxDialog(NULL, wxID_ANY, wxString(_("Chat Logger++ - Configuration")), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxMINIMIZE_BOX | wxDIALOG_NO_PARENT), m_config(_T("Chat Logger++"), _T("OSW"))
{
	m_bEnablePreviews = false;

	m_pNotebook = new wxNotebook(this, wxID_ANY);

	m_pLoggingPanel = new wxPanel(m_pNotebook, wxID_ANY);
	m_pNotebook->AddPage(m_pLoggingPanel, _("Logging"));

	m_pHelpPanel = new wxPanel(m_pNotebook, wxID_ANY);
	m_pNotebook->AddPage(m_pHelpPanel, _("Help && Formatting"));
	{
		wxTextCtrl* pTextCtrl = new wxTextCtrl(m_pHelpPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_RICH | wxTE_AUTO_URL | wxTE_READONLY);
		
		wxTextAttr originalAttr = pTextCtrl->GetDefaultStyle();
		wxTextAttr underlinedAttr = originalAttr;
		wxFont underlinedFont = pTextCtrl->GetDefaultStyle().GetFont();
		underlinedFont.SetUnderlined(true);
		underlinedAttr.SetFont(underlinedFont);

		pTextCtrl->SetDefaultStyle(underlinedAttr);
		pTextCtrl->AppendText(_("Common variables:\n\n"));
		pTextCtrl->SetDefaultStyle(originalAttr);

		pTextCtrl->AppendText
		(
			L"{Name}		- Sender's friend's name.\n"
			L"{Nickname}	- Sender's nickname, if it exists, otherwise their name.\n"
			L"{SteamID}	- Sender's SteamID.\n"
			L"{SteamID64}	- Sender's SteamID rendered as a 64bits integer.\n"
			L"\n"
			L"{MyName}	- Your current friend's name.\n"
			L"{MySteamID}	- Your SteamID.\n"
			L"{MySteamID64}	- Your SteamID rendered as a 64bits integer.\n"
			L"\n"
			L"{Date}		- Current date.\n"
			L"{Time}		- Current time.\n"
			L"{UnixTime}	- Seconds since unix epoch.\n"
			L"\n"
		);

		pTextCtrl->SetDefaultStyle(underlinedAttr);
		pTextCtrl->AppendText(_("Message specific variables:\n\n"));
		pTextCtrl->SetDefaultStyle(originalAttr);

		pTextCtrl->AppendText
		(
			L"{NewLine}	- New line character \"\\n\".\n"
			L"{Tab}		- Tab character \"\\t\".\n"
			L"\n"
			L"{Message}	- The actual chat message.\n"
			L"\n"
		);

		pTextCtrl->SetDefaultStyle(underlinedAttr);
		pTextCtrl->AppendText(_("Additional informations:\n\n"));
		pTextCtrl->SetDefaultStyle(originalAttr);

		pTextCtrl->AppendText
		(
			L"The format used for date and time is described here : http://www.cplusplus.com/reference/clibrary/ctime/strftime/ .\n"
			L"\n"
			L"This program is powered by Open Steamworks ( http://opensteamworks.org/ ).\n"
		);

		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);
		m_pHelpPanel->SetSizer(pBoxSizer);
		pBoxSizer->Add(pTextCtrl, 1, wxEXPAND);
	}

	wxBoxSizer *pBoxSizer = new wxBoxSizer(wxHORIZONTAL);
	m_pLoggingPanel->SetSizer(pBoxSizer);

	wxGridBagSizer *pGridBagSizer = new wxGridBagSizer(10, 10);
	pGridBagSizer->AddGrowableCol(0);
	pBoxSizer->Add(pGridBagSizer, 1, wxALL | wxEXPAND, 10);

	int iRow = 0;

	wxString logDirectory;
	m_config.Read(_T("LogDirectory"), &logDirectory, wxGetCwd());

	wxStaticText *pLogDirLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Log directory: "));
	m_pLogDirPicker = new wxDirPickerCtrl(m_pLoggingPanel, wxID_LogDirPicker, logDirectory);
	pGridBagSizer->Add(pLogDirLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);
	pGridBagSizer->Add(m_pLogDirPicker, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);

	{
		wxString filenameFormat;
		m_config.Read(_T("FilenameFormat"), &filenameFormat, _T("{SteamID} - {Nickname}.txt"));

		wxStaticText *pFilenameLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Filename format: "));
		pGridBagSizer->Add(pFilenameLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);

		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);

		m_pFilenameInput = new wxTextCtrl(pPanel, wxID_FilenameInput, filenameFormat);
		pBoxSizer->Add(m_pFilenameInput, 0, wxEXPAND);
		m_pFilenamePreviewLabel = new wxStaticText(pPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE);
		pBoxSizer->Add(m_pFilenamePreviewLabel, 1, wxEXPAND | wxALL, 5);
		pPanel->SetSizer(pBoxSizer);

		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);
	}

	wxString replacementChar;
	m_config.Read(_T("ReplacementChar"), &replacementChar, _T("_"));

	wxStaticText *pReplacementLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Invalid char replacement: "));
	m_pReplacementInput = new wxTextCtrl(m_pLoggingPanel, wxID_ReplacementInput, replacementChar);
	m_pReplacementInput->SetMaxLength(1);
	pGridBagSizer->Add(pReplacementLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);
	pGridBagSizer->Add(m_pReplacementInput, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);

	{
		wxStaticLine* pLine = new wxStaticLine(m_pLoggingPanel);
		pGridBagSizer->Add(pLine, wxGBPosition(iRow++, 0), wxGBSpan(1, 2), wxEXPAND);
	}

	{
		wxString messageFormat;
		m_config.Read(_T("MessageFormat"), &messageFormat, _T("[{Time}] {Name}: {Message}"));

		wxStaticText *pMessageLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Message format: "));
		pGridBagSizer->Add(pMessageLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);

		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);

		m_pMessageInput = new wxTextCtrl(pPanel, wxID_MessageInput, messageFormat);
		pBoxSizer->Add(m_pMessageInput, 0, wxEXPAND);
		m_pMessagePreviewLabel = new wxStaticText(pPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE);
		pBoxSizer->Add(m_pMessagePreviewLabel, 1, wxEXPAND | wxALL, 5);
		pPanel->SetSizer(pBoxSizer);

		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);
	}

	{
		wxString emoteFormat;
		m_config.Read(_T("EmoteFormat"), &emoteFormat, _T("[{Time}] * {Name} {Message}"));

		wxStaticText *pEmoteLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Emote format: "));
		pGridBagSizer->Add(pEmoteLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);

		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);

		m_pEmoteInput = new wxTextCtrl(pPanel, wxID_EmoteInput, emoteFormat);
		pBoxSizer->Add(m_pEmoteInput, 0, wxEXPAND);
		m_pEmotePreviewLabel = new wxStaticText(pPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE);
		pBoxSizer->Add(m_pEmotePreviewLabel, 1, wxEXPAND | wxALL, 5);
		pPanel->SetSizer(pBoxSizer);

		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);
	}

	{
		wxString separationString;
		m_config.Read(_T("SeparationString"), &separationString, _T("───────────────────"));

		wxStaticText *pSeparationLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Separation string: "));
		pGridBagSizer->Add(pSeparationLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);

		m_pSeparationInput = new wxTextCtrl(m_pLoggingPanel, wxID_SeparationInput, separationString);
		pGridBagSizer->Add(m_pSeparationInput, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);
	}

	{
		wxStaticLine* pLine = new wxStaticLine(m_pLoggingPanel);
		pGridBagSizer->Add(pLine, wxGBPosition(iRow++, 0), wxGBSpan(1, 2), wxEXPAND);
	}

	{
		wxString dateFormat;
		m_config.Read(_T("DateFormat"), &dateFormat, _T("%x"));

		wxStaticText *pDateLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Date format: "));
		pGridBagSizer->Add(pDateLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);

		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);

		m_pDateInput = new wxTextCtrl(pPanel, wxID_DateInput, dateFormat);
		pBoxSizer->Add(m_pDateInput, 0, wxEXPAND);
		m_pDatePreviewLabel = new wxStaticText(pPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE);
		pBoxSizer->Add(m_pDatePreviewLabel, 1, wxEXPAND | wxALL, 5);
		pPanel->SetSizer(pBoxSizer);

		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);
	}

	{
		wxString timeFormat;
		m_config.Read(_T("TimeFormat"), &timeFormat, _T("%X"));

		wxStaticText *pTimeLabel = new wxStaticText(m_pLoggingPanel, wxID_ANY, _("Time format: "));
		pGridBagSizer->Add(pTimeLabel, wxGBPosition(iRow, 0), wxDefaultSpan, wxTOP, 3);

		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);

		m_pTimeInput = new wxTextCtrl(pPanel, wxID_TimeInput, timeFormat);
		pBoxSizer->Add(m_pTimeInput, 0, wxEXPAND);
		m_pTimePreviewLabel = new wxStaticText(pPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE);
		pBoxSizer->Add(m_pTimePreviewLabel, 1, wxEXPAND | wxALL, 5);
		pPanel->SetSizer(pBoxSizer);

		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 1), wxDefaultSpan, wxEXPAND);
	}


	{
		wxStaticLine* pLine = new wxStaticLine(m_pLoggingPanel);
		pGridBagSizer->Add(pLine, wxGBPosition(iRow++, 0), wxGBSpan(1, 2), wxEXPAND);
	}

	{
		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxVERTICAL);

		bool bEnabled;
		m_config.Read(_T("Unstable"), &bEnabled, false);

		pUnstableCheckBox = new wxCheckBox(pPanel, wxID_ANY, _("Enable Group chat logging and Nickname support."));
		pUnstableCheckBox->SetValue(bEnabled);
		wxStaticText *pLabel = new wxStaticText(pPanel, wxID_ANY, _("These features are unstable and can break with any Steam update."));
		
		pBoxSizer->Add(pUnstableCheckBox);
		pBoxSizer->Add(pLabel, 0, wxLEFT, 17);
		pPanel->SetSizer(pBoxSizer);
		
		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 0), wxGBSpan(1, 2));
	}

	{
		wxPanel* pPanel = new wxPanel(m_pLoggingPanel);
		wxBoxSizer *pBoxSizer = new wxBoxSizer(wxHORIZONTAL);
		wxButton* pOKButton = new wxButton(pPanel, wxID_OK);
		pBoxSizer->Add(pOKButton);
		wxButton* pCancelButton = new wxButton(pPanel, wxID_CANCEL);
		pBoxSizer->Add(pCancelButton);
		pPanel->SetSizer(pBoxSizer);

		pGridBagSizer->Add(pPanel, wxGBPosition(iRow++, 0), wxGBSpan(1, 2), wxALIGN_RIGHT);
	}

	m_bEnablePreviews = true;

	UpdatePreviews();

	m_pNotebook->Fit();
	this->Fit();
}