Remember last configuration, even if it was unsaved.

This commit is contained in:
LoRd_MuldeR 2012-02-09 02:06:29 +01:00
parent 10934275f7
commit e648300812
6 changed files with 116 additions and 27 deletions

View File

@ -21,6 +21,8 @@
#include "model_options.h" #include "model_options.h"
#include "global.h"
#include <QDesktopServices> #include <QDesktopServices>
#include <QSettings> #include <QSettings>
#include <QStringList> #include <QStringList>
@ -82,7 +84,7 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
const QString templateName = name.simplified(); const QString templateName = name.simplified();
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
if(templateName.contains('<') || templateName.contains('>') || templateName.contains('\\') || templateName.contains('/')) if(templateName.contains('\\') || templateName.contains('/'))
{ {
return false; return false;
} }
@ -104,16 +106,17 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
return true; return true;
} }
QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(void) bool OptionsModel::loadTemplate(OptionsModel *model, const QString &name)
{ {
QMap<QString, OptionsModel*> list;
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
QStringList allTemplates = settings.childGroups();
while(!allTemplates.isEmpty()) if(name.contains('\\') || name.contains('/'))
{ {
settings.beginGroup(allTemplates.takeFirst()); return false;
}
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
settings.beginGroup(name);
bool complete = true; bool complete = true;
if(!settings.contains("rate_control_mode")) complete = false; if(!settings.contains("rate_control_mode")) complete = false;
@ -126,18 +129,39 @@ QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(void)
if(complete) if(complete)
{ {
OptionsModel *options = new OptionsModel(); model->setRCMode(static_cast<OptionsModel::RCMode>(settings.value("rate_control_mode", model->m_rcMode).toInt()));
options->setRCMode(static_cast<OptionsModel::RCMode>(settings.value("rate_control_mode", options->m_rcMode).toInt())); model->setBitrate(settings.value("target_bitrate", model->m_bitrate).toUInt());
options->setBitrate(settings.value("target_bitrate", options->m_bitrate).toUInt()); model->setQuantizer(settings.value("target_quantizer", model->m_quantizer).toDouble());
options->setQuantizer(settings.value("target_quantizer", options->m_quantizer).toDouble()); model->setPreset(settings.value("preset_name", model->m_preset).toString());
options->setPreset(settings.value("preset_name", options->m_preset).toString()); model->setTune(settings.value("tuning_name", model->m_tune).toString());
options->setTune(settings.value("tuning_name", options->m_tune).toString()); model->setProfile(settings.value("profile_name", model->m_profile).toString());
options->setProfile(settings.value("profile_name", options->m_profile).toString()); model->setCustom(settings.value("custom_params", model->m_custom).toString());
options->setCustom(settings.value("custom_params", options->m_custom).toString());
list.insert(settings.group(), options);
} }
settings.endGroup(); settings.endGroup();
return complete;
}
QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(void)
{
QMap<QString, OptionsModel*> list;
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
QStringList allTemplates = settings.childGroups();
while(!allTemplates.isEmpty())
{
QString name = allTemplates.takeFirst();
if(!(name.contains('<') || name.contains('>') || name.contains('\\') || name.contains('/')))
{
OptionsModel *options = new OptionsModel();
if(loadTemplate(options, name))
{
list.insert(name, options);
continue;
}
X264_DELETE(options);
}
} }
return list; return list;

View File

@ -63,6 +63,7 @@ public:
//Static functions //Static functions
static QString rcMode2String(RCMode mode); static QString rcMode2String(RCMode mode);
static bool saveTemplate(OptionsModel *model, const QString &name); static bool saveTemplate(OptionsModel *model, const QString &name);
static bool loadTemplate(OptionsModel *model, const QString &name);
static QMap<QString, OptionsModel*> loadAllTemplates(void); static QMap<QString, OptionsModel*> loadAllTemplates(void);
static bool templateExists(const QString &name); static bool templateExists(const QString &name);
static bool deleteTemplate(const QString &name); static bool deleteTemplate(const QString &name);

59
src/taskbar7.h Normal file
View File

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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);
};

View File

@ -21,7 +21,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 0 #define VER_X264_MINOR 0
#define VER_X264_PATCH 55 #define VER_X264_PATCH 61
#define VER_X264_MINIMUM_REV 2146 #define VER_X264_MINIMUM_REV 2146
#define VER_X264_CURRENT_API 120 #define VER_X264_CURRENT_API 120

View File

@ -43,6 +43,7 @@
const char *home_url = "http://mulder.brhack.net/"; const char *home_url = "http://mulder.brhack.net/";
const char *update_url = "http://code.google.com/p/mulder/downloads/list"; const char *update_url = "http://code.google.com/p/mulder/downloads/list";
const char *tpl_last = "<LAST_USED>";
#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #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); } #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::initPreferences(&m_preferences);
PreferencesDialog::loadPreferences(&m_preferences); PreferencesDialog::loadPreferences(&m_preferences);
//Create options object
m_options = new OptionsModel();
OptionsModel::loadTemplate(m_options, QString::fromLatin1(tpl_last));
//Freeze minimum size //Freeze minimum size
setMinimumSize(size()); setMinimumSize(size());
splitter->setSizes(QList<int>() << 16 << 196); splitter->setSizes(QList<int>() << 16 << 196);
@ -142,13 +147,12 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures)
m_label->addActions(jobsView->actions()); m_label->addActions(jobsView->actions());
connect(splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos())); connect(splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
updateLabelPos(); updateLabelPos();
//Create options object
m_options = new OptionsModel();
} }
MainWindow::~MainWindow(void) MainWindow::~MainWindow(void)
{ {
OptionsModel::saveTemplate(m_options, QString::fromLatin1(tpl_last));
X264_DELETE(m_jobList); X264_DELETE(m_jobList);
X264_DELETE(m_options); X264_DELETE(m_options);
X264_DELETE(m_label); X264_DELETE(m_label);

View File

@ -26,6 +26,7 @@
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>Windows7.1SDK</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">