Work on titles, shortening.
This commit is contained in:
parent
08b3b60d33
commit
1f13618f40
@ -202,6 +202,7 @@ set(APP_SOURCES
|
||||
src/core/basenetworkaccessmanager.cpp
|
||||
src/core/basewebpage.cpp
|
||||
src/core/webbrowsernetworkaccessmanager.cpp
|
||||
src/core/textfactory.cpp
|
||||
|
||||
# Basic application sources.
|
||||
src/main.cpp
|
||||
|
@ -26,6 +26,8 @@
|
||||
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@;")
|
||||
#endif
|
||||
|
||||
#define TEXT_TITLE_LIMIT 30
|
||||
|
||||
#define APP_CFG_PATH "data/config"
|
||||
#define APP_CFG_WEB_PATH "data/web"
|
||||
#define APP_CFG_FILE "config.ini"
|
||||
|
20
src/core/textfactory.cpp
Normal file
20
src/core/textfactory.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <QString>
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "core/textfactory.h"
|
||||
|
||||
|
||||
TextFactory::TextFactory() {
|
||||
}
|
||||
|
||||
TextFactory::~TextFactory() {
|
||||
}
|
||||
|
||||
QString TextFactory::shorten(const QString &input) {
|
||||
if (input.size() > TEXT_TITLE_LIMIT) {
|
||||
return input.left(TEXT_TITLE_LIMIT - 3) + QString(3, '.');
|
||||
}
|
||||
else {
|
||||
return input;
|
||||
}
|
||||
}
|
16
src/core/textfactory.h
Normal file
16
src/core/textfactory.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef TEXTFACTORY_H
|
||||
#define TEXTFACTORY_H
|
||||
|
||||
|
||||
class TextFactory {
|
||||
private:
|
||||
explicit TextFactory();
|
||||
|
||||
public:
|
||||
virtual ~TextFactory();
|
||||
|
||||
static QString shorten(const QString &input);
|
||||
|
||||
};
|
||||
|
||||
#endif // TEXTFACTORY_H
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/textfactory.h"
|
||||
#include "gui/tabwidget.h"
|
||||
#include "gui/tabbar.h"
|
||||
#include "gui/iconthemefactory.h"
|
||||
@ -129,14 +130,6 @@ int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||
initial_url);
|
||||
}
|
||||
|
||||
void TabWidget::changeIcon(int column, const QIcon &new_icon) {
|
||||
setTabIcon(column, new_icon);
|
||||
}
|
||||
|
||||
void TabWidget::changeTitle(int column, const QString &new_title) {
|
||||
setTabText(column, new_title);
|
||||
}
|
||||
|
||||
int TabWidget::addBrowser(bool move_after_current,
|
||||
bool make_active,
|
||||
const QUrl &initial_url) {
|
||||
@ -183,6 +176,14 @@ int TabWidget::addBrowser(bool move_after_current,
|
||||
return final_index;
|
||||
}
|
||||
|
||||
void TabWidget::changeIcon(int column, const QIcon &new_icon) {
|
||||
setTabIcon(column, new_icon);
|
||||
}
|
||||
|
||||
void TabWidget::changeTitle(int column, const QString &new_title) {
|
||||
setTabText(column, TextFactory::shorten(new_title));
|
||||
}
|
||||
|
||||
void TabWidget::fixContentAfterIndexChange(int from) {
|
||||
fixContentsIndexes(from, count() - 1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user