diff --git a/src/model_options.cpp b/src/model_options.cpp index 3a271e5..eacf9c0 100644 --- a/src/model_options.cpp +++ b/src/model_options.cpp @@ -21,6 +21,8 @@ #include "model_options.h" +#include "global.h" + #include #include #include @@ -82,7 +84,7 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name) const QString templateName = name.simplified(); const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - if(templateName.contains('<') || templateName.contains('>') || templateName.contains('\\') || templateName.contains('/')) + if(templateName.contains('\\') || templateName.contains('/')) { return false; } @@ -104,6 +106,42 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name) return true; } +bool OptionsModel::loadTemplate(OptionsModel *model, const QString &name) +{ + const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + + if(name.contains('\\') || name.contains('/')) + { + return false; + } + + QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat); + settings.beginGroup(name); + + bool complete = true; + if(!settings.contains("rate_control_mode")) complete = false; + if(!settings.contains("target_bitrate")) complete = false; + if(!settings.contains("target_quantizer")) complete = false; + if(!settings.contains("preset_name")) complete = false; + if(!settings.contains("tuning_name")) complete = false; + if(!settings.contains("profile_name")) complete = false; + if(!settings.contains("custom_params")) complete = false; + + if(complete) + { + model->setRCMode(static_cast(settings.value("rate_control_mode", model->m_rcMode).toInt())); + model->setBitrate(settings.value("target_bitrate", model->m_bitrate).toUInt()); + model->setQuantizer(settings.value("target_quantizer", model->m_quantizer).toDouble()); + model->setPreset(settings.value("preset_name", model->m_preset).toString()); + model->setTune(settings.value("tuning_name", model->m_tune).toString()); + model->setProfile(settings.value("profile_name", model->m_profile).toString()); + model->setCustom(settings.value("custom_params", model->m_custom).toString()); + } + + settings.endGroup(); + return complete; +} + QMap OptionsModel::loadAllTemplates(void) { QMap list; @@ -113,31 +151,17 @@ QMap OptionsModel::loadAllTemplates(void) while(!allTemplates.isEmpty()) { - settings.beginGroup(allTemplates.takeFirst()); - - bool complete = true; - if(!settings.contains("rate_control_mode")) complete = false; - if(!settings.contains("target_bitrate")) complete = false; - if(!settings.contains("target_quantizer")) complete = false; - if(!settings.contains("preset_name")) complete = false; - if(!settings.contains("tuning_name")) complete = false; - if(!settings.contains("profile_name")) complete = false; - if(!settings.contains("custom_params")) complete = false; - - if(complete) + QString name = allTemplates.takeFirst(); + if(!(name.contains('<') || name.contains('>') || name.contains('\\') || name.contains('/'))) { OptionsModel *options = new OptionsModel(); - options->setRCMode(static_cast(settings.value("rate_control_mode", options->m_rcMode).toInt())); - options->setBitrate(settings.value("target_bitrate", options->m_bitrate).toUInt()); - options->setQuantizer(settings.value("target_quantizer", options->m_quantizer).toDouble()); - options->setPreset(settings.value("preset_name", options->m_preset).toString()); - options->setTune(settings.value("tuning_name", options->m_tune).toString()); - options->setProfile(settings.value("profile_name", options->m_profile).toString()); - options->setCustom(settings.value("custom_params", options->m_custom).toString()); - list.insert(settings.group(), options); + if(loadTemplate(options, name)) + { + list.insert(name, options); + continue; + } + X264_DELETE(options); } - - settings.endGroup(); } return list; diff --git a/src/model_options.h b/src/model_options.h index d25dc40..a4adee4 100644 --- a/src/model_options.h +++ b/src/model_options.h @@ -63,6 +63,7 @@ public: //Static functions static QString rcMode2String(RCMode mode); static bool saveTemplate(OptionsModel *model, const QString &name); + static bool loadTemplate(OptionsModel *model, const QString &name); static QMap loadAllTemplates(void); static bool templateExists(const QString &name); static bool deleteTemplate(const QString &name); diff --git a/src/taskbar7.h b/src/taskbar7.h new file mode 100644 index 0000000..81df2d0 --- /dev/null +++ b/src/taskbar7.h @@ -0,0 +1,59 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// This program 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 2 of the License, or +// (at your option) any later version. +// +// This program 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 this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// http://www.gnu.org/licenses/gpl-2.0.txt +/////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "global.h" + +class QWidget; +class QIcon; +struct ITaskbarList3; + +class WinSevenTaskbar +{ +public: + WinSevenTaskbar(void); + ~WinSevenTaskbar(void); + + //Taskbar states + enum WinSevenTaskbarState + { + WinSevenTaskbarNoState = 0, + WinSevenTaskbarNormalState = 1, + WinSevenTaskbarIndeterminateState = 2, + WinSevenTaskbarPausedState = 3, + WinSevenTaskbarErrorState = 4 + }; + + //Public interface + static bool handleWinEvent(MSG *message, long *result); + static bool setTaskbarState(QWidget *window, WinSevenTaskbarState state); + static void setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue); + static void setOverlayIcon(QWidget *window, const QIcon *icon); + + static void init(void); + static void uninit(void); + +private: + static ITaskbarList3 *m_ptbl; + static UINT m_winMsg; + static void createInterface(void); +}; diff --git a/src/version.h b/src/version.h index 111ae63..11631b7 100644 --- a/src/version.h +++ b/src/version.h @@ -21,7 +21,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 0 -#define VER_X264_PATCH 55 +#define VER_X264_PATCH 61 #define VER_X264_MINIMUM_REV 2146 #define VER_X264_CURRENT_API 120 diff --git a/src/win_main.cpp b/src/win_main.cpp index 21ef065..4335885 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -43,6 +43,7 @@ const char *home_url = "http://mulder.brhack.net/"; const char *update_url = "http://code.google.com/p/mulder/downloads/list"; +const char *tpl_last = ""; #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); } @@ -69,6 +70,10 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures) PreferencesDialog::initPreferences(&m_preferences); PreferencesDialog::loadPreferences(&m_preferences); + //Create options object + m_options = new OptionsModel(); + OptionsModel::loadTemplate(m_options, QString::fromLatin1(tpl_last)); + //Freeze minimum size setMinimumSize(size()); splitter->setSizes(QList() << 16 << 196); @@ -142,13 +147,12 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures) m_label->addActions(jobsView->actions()); connect(splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos())); updateLabelPos(); - - //Create options object - m_options = new OptionsModel(); } MainWindow::~MainWindow(void) { + OptionsModel::saveTemplate(m_options, QString::fromLatin1(tpl_last)); + X264_DELETE(m_jobList); X264_DELETE(m_options); X264_DELETE(m_label); diff --git a/x264_launcher.vcxproj b/x264_launcher.vcxproj index 4c55ad9..c072ec5 100644 --- a/x264_launcher.vcxproj +++ b/x264_launcher.vcxproj @@ -26,6 +26,7 @@ false true Unicode + Windows7.1SDK